summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-10-20 12:37:32 +0200
committerLukas Reschke <lukas@owncloud.com>2014-10-20 15:09:43 +0200
commit7b94c7f9c1d2dd8115506d90f04f9e3e2f989cf5 (patch)
tree8dc35a7af5fd7c2c94534d57eb2efa03ef69b65a /lib/private
parent8da6e4b9f09d6d7a03fb602c6d5fe73e87b96a87 (diff)
downloadnextcloud-server-7b94c7f9c1d2dd8115506d90f04f9e3e2f989cf5.tar.gz
nextcloud-server-7b94c7f9c1d2dd8115506d90f04f9e3e2f989cf5.zip
Refer to relative path instead of absolute path
There is no need to refer to the absolute path here if we can use the relative one. Conflicts: lib/private/templatelayout.php
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/templatelayout.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php
index 10abff6267a..558ddad4af2 100644
--- a/lib/private/templatelayout.php
+++ b/lib/private/templatelayout.php
@@ -157,7 +157,7 @@ class OC_TemplateLayout extends OC_Template {
public function generateAssets() {
$jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
- $jsHash = self::hashScriptNames($jsFiles);
+ $jsHash = self::hashFileNames($jsFiles);
if (!file_exists("assets/$jsHash.js")) {
$jsFiles = array_map(function ($item) {
@@ -179,7 +179,7 @@ class OC_TemplateLayout extends OC_Template {
}
$cssFiles = self::findStylesheetFiles(OC_Util::$styles);
- $cssHash = self::hashScriptNames($cssFiles);
+ $cssHash = self::hashFileNames($cssFiles);
if (!file_exists("assets/$cssHash.css")) {
$cssFiles = array_map(function ($item) {
@@ -211,16 +211,29 @@ class OC_TemplateLayout extends OC_Template {
}
/**
+ * Converts the absolute filepath to a relative path from \OC::$SERVERROOT
+ * @param string $filePath Absolute path
+ * @return string Relative path
+ * @throws Exception If $filePath is not under \OC::$SERVERROOT
+ */
+ public static function convertToRelativePath($filePath) {
+ $relativePath = explode(\OC::$SERVERROOT, $filePath);
+ if(count($relativePath) !== 2) {
+ throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
+ }
+
+ return $relativePath[1];
+ }
+
+ /**
* @param array $files
* @return string
*/
- private static function hashScriptNames($files) {
- $files = array_map(function ($item) {
- $root = $item[0];
- $file = $item[2];
- return $root . '/' . $file;
- }, $files);
+ private static function hashFileNames($files) {
+ foreach($files as $i => $file) {
+ $files[$i] = self::convertToRelativePath($file[0]).'/'.$file[2];
+ }
sort($files);
// include the apps' versions hash to invalidate the cached assets