summaryrefslogtreecommitdiffstats
path: root/lib/private/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r--lib/private/helper.php52
1 files changed, 4 insertions, 48 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 66e7acb407a..a34640d8e36 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -41,8 +41,7 @@ class OC_Helper {
* Returns a url to the given app and file.
*/
public static function linkToRoute($route, $parameters = array()) {
- $urlLinkTo = OC::getRouter()->generate($route, $parameters);
- return $urlLinkTo;
+ return OC::$server->getURLGenerator()->linkToRoute($route, $parameters);
}
/**
@@ -56,32 +55,7 @@ class OC_Helper {
* Returns a url to the given app and file.
*/
public static function linkTo( $app, $file, $args = array() ) {
- 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;
- $urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
- } else {
- $urlLinkTo = OC_App::getAppWebPath($app) . '/' . $file;
- }
- } else {
- $urlLinkTo = OC::$WEBROOT . '/' . $app . '/' . $file;
- }
- } else {
- if (file_exists(OC::$SERVERROOT . '/core/' . $file)) {
- $urlLinkTo = OC::$WEBROOT . '/core/' . $file;
- } else {
- $urlLinkTo = OC::$WEBROOT . '/' . $file;
- }
- }
-
- if ($args && $query = http_build_query($args, '', '&')) {
- $urlLinkTo .= '?' . $query;
- }
-
- return $urlLinkTo;
+ return OC::$server->getURLGenerator()->linkTo($app, $file, $args);
}
/**
@@ -107,7 +81,7 @@ class OC_Helper {
* Returns a absolute url to the given app and file.
*/
public static function makeURLAbsolute($url) {
- return OC_Request::serverProtocol() . '://' . OC_Request::serverHost() . $url;
+ return OC::$server->getURLGenerator()->makeURLAbsolute($url);
}
/**
@@ -156,25 +130,7 @@ class OC_Helper {
* Returns the path to the image.
*/
public static function imagePath($app, $image) {
- // Read the selected theme from the config file
- $theme = OC_Util::getTheme();
-
- // Check if the app is in the app folder
- if (file_exists(OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
- } elseif (file_exists(OC_App::getAppPath($app) . "/img/$image")) {
- return OC_App::getAppWebPath($app) . "/img/$image";
- } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/$app/img/$image";
- } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/$app/img/$image")) {
- return OC::$WEBROOT . "/$app/img/$image";
- } elseif (file_exists(OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/core/img/$image";
- } elseif (file_exists(OC::$SERVERROOT . "/core/img/$image")) {
- return OC::$WEBROOT . "/core/img/$image";
- } else {
- throw new RuntimeException('image not found: image:' . $image . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT);
- }
+ return OC::$server->getURLGenerator()->imagePath($app, $image);
}
/**