diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-12-31 17:36:02 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-12-31 17:36:02 +0400 |
commit | ae5671d2813f74562b77ae4288f01b4ed5ed52be (patch) | |
tree | 56144eb9746f798e827a0c70018ecb63c0c3e6de /lib/private/urlgenerator.php | |
parent | 988710b0fc4e77b1a565a9f3ee4e7f24a539e057 (diff) |
new config parameter 'front_controller_active' which will instruct the url generator to generate urls without index.php
Diffstat (limited to 'lib/private/urlgenerator.php')
-rw-r--r-- | lib/private/urlgenerator.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index 7795011fd06..4e3c1109000 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -15,6 +15,19 @@ use RuntimeException; * Class to generate URLs */ class URLGenerator implements IURLGenerator { + + /** + * @var \OCP\IConfig + */ + private $config; + + /** + * @param \OCP\IConfig $config + */ + public function __construct($config) { + $this->config = $config; + } + /** * @brief Creates an url using a defined route * @param $route @@ -41,12 +54,18 @@ class URLGenerator implements IURLGenerator { * Returns a url to the given app and file. */ public function linkTo( $app, $file, $args = array() ) { + $frontControllerActive=($this->config->getSystemValue('front_controller_active', 'false') == 'true'); + if( $app != '' ) { $app_path = \OC_App::getAppPath($app); // Check if the app is in the app folder if ($app_path && file_exists($app_path . '/' . $file)) { if (substr($file, -3) == 'php' || substr($file, -3) == 'css') { + $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; + if ($frontControllerActive) { + $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; + } $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; } else { $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; @@ -58,7 +77,11 @@ class URLGenerator implements IURLGenerator { if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; } else { - $urlLinkTo = \OC::$WEBROOT . '/' . $file; + if ($frontControllerActive && $file === 'index.php') { + $urlLinkTo = \OC::$WEBROOT; + } else { + $urlLinkTo = \OC::$WEBROOT . '/' . $file; + } } } |