backports Tinebase_Core::getUrl
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 09:29:41 +0000 (11:29 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 09:32:44 +0000 (11:32 +0200)
... from 2015.11-develop

Change-Id: I7382b9e44b72b1e1a17e5b4c19947099a9c95d1c
Reviewed-on: http://gerrit.tine20.com/customers/3244
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Core.php

index 4a28a9d..e0a6835 100644 (file)
@@ -1502,7 +1502,39 @@ class Tinebase_Core
         
         return $hostname;
     }
-    
+
+    /**
+     * returns requested url part
+     *
+     * @param string $part
+     * @return string
+     */
+    public static function getUrl($part = 'full')
+    {
+        $request = new Zend_Controller_Request_Http();
+        $pathname = $request->getBasePath();
+        $hostname = $request->getHttpHost();
+        $protocol = $request->getScheme();
+
+        switch ($part) {
+            case 'path':
+                $url = $pathname;
+                break;
+            case 'host':
+                $url = $hostname;
+                break;
+            case 'protocol':
+                $url = $protocol;
+                break;
+            case 'full':
+            default:
+                $url = $protocol . '://' . $hostname . $pathname;
+                break;
+        }
+
+        return $url;
+    }
+
     /**
      * Singleton instance
      *