summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-12-18 23:18:37 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-12-18 23:18:37 +0100
commit891474b0d6b8cc77a8480cd91f1e48ad3bc3e73b (patch)
treededc4a94ec16651266bf15d46a6687efb901c63e /lib
parent49318b4d93b4dc5fbd58fa87b2efa8f1577fb7b7 (diff)
parent51a22431ee824357dce0100cb000032f29aabd47 (diff)
downloadnextcloud-server-891474b0d6b8cc77a8480cd91f1e48ad3bc3e73b.tar.gz
nextcloud-server-891474b0d6b8cc77a8480cd91f1e48ad3bc3e73b.zip
Merge pull request #12759 from owncloud/core-reduce-js-and-css
make sure styles and scripts are only loaded once
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/private/util.php34
2 files changed, 25 insertions, 11 deletions
diff --git a/lib/base.php b/lib/base.php
index ae87ecff394..009732ead7b 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -336,7 +336,6 @@ class OC {
public static function initTemplateEngine() {
// Add the stuff we need always
-
// following logic will import all vendor libraries that are
// specified in core/js/core.json
$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
@@ -351,7 +350,6 @@ class OC {
throw new \Exception('Cannot read core/js/core.json');
}
- OC_Util::addScript("jquery-showpassword");
OC_Util::addScript("placeholders");
OC_Util::addScript("jquery-tipsy");
OC_Util::addScript("compatibility");
diff --git a/lib/private/util.php b/lib/private/util.php
index 6ccb9dba087..b97c0684629 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -333,9 +333,9 @@ class OC_Util {
/**
* generates a path for JS/CSS files. If no application is provided it will create the path for core.
*
- * @param $application application to get the files from
- * @param $directory directory withing this application (css, js, vendor, etc)
- * @param $file the file inside of the above folder
+ * @param string $application application to get the files from
+ * @param string $directory directory withing this application (css, js, vendor, etc)
+ * @param string $file the file inside of the above folder
* @return string the path
*/
private static function generatePath($application, $directory, $file) {
@@ -358,7 +358,10 @@ class OC_Util {
* @return void
*/
public static function addScript($application, $file = null) {
- self::$scripts[] = OC_Util::generatePath($application, 'js', $file);
+ $path = OC_Util::generatePath($application, 'js', $file);
+ if (!in_array($path, self::$scripts)) {
+ self::$scripts[] = $path;
+ }
}
/**
@@ -369,7 +372,10 @@ class OC_Util {
* @return void
*/
public static function addVendorScript($application, $file = null) {
- self::$scripts[] = OC_Util::generatePath($application, 'vendor', $file);
+ $path = OC_Util::generatePath($application, 'vendor', $file);
+ if (!in_array($path, self::$scripts)) {
+ self::$scripts[] = $path;
+ }
}
/**
@@ -384,9 +390,12 @@ class OC_Util {
$languageCode = $l->getLanguageCode($application);
}
if (!empty($application)) {
- self::$scripts[] = "$application/l10n/$languageCode";
+ $path = "$application/l10n/$languageCode";
} else {
- self::$scripts[] = "l10n/$languageCode";
+ $path = "l10n/$languageCode";
+ }
+ if (!in_array($path, self::$scripts)) {
+ self::$scripts[] = $path;
}
}
@@ -398,7 +407,10 @@ class OC_Util {
* @return void
*/
public static function addStyle($application, $file = null) {
- self::$styles[] = OC_Util::generatePath($application, 'css', $file);
+ $path = OC_Util::generatePath($application, 'css', $file);
+ if (!in_array($path, self::$styles)) {
+ self::$styles[] = $path;
+ }
}
/**
@@ -409,7 +421,10 @@ class OC_Util {
* @return void
*/
public static function addVendorStyle($application, $file = null) {
- self::$styles[] = OC_Util::generatePath($application, 'vendor', $file);
+ $path = OC_Util::generatePath($application, 'vendor', $file);
+ if (!in_array($path, self::$styles)) {
+ self::$styles[] = $path;
+ }
}
/**
@@ -1344,4 +1359,5 @@ class OC_Util {
public static function isPhpCharSetUtf8() {
return ini_get('default_charset') === 'UTF-8';
}
+
}