aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/util.php')
-rw-r--r--lib/private/util.php53
1 files changed, 42 insertions, 11 deletions
diff --git a/lib/private/util.php b/lib/private/util.php
index 667d358655f..9abaef71a68 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -439,16 +439,23 @@ class OC_Util {
*
* @param string $application application id
* @param string|null $file filename
+ * @param bool $prepend prepend the Script to the beginning of the list
* @return void
*/
- public static function addScript($application, $file = null) {
+ public static function addScript($application, $file = null, $prepend = false) {
$path = OC_Util::generatePath($application, 'js', $file);
+ //TODO eliminate double code
if (!in_array($path, self::$scripts)) {
// core js files need separate handling
if ($application !== 'core' && $file !== null) {
self::addTranslations($application);
}
- self::$scripts[] = $path;
+ if ($prepend===true) {
+ array_unshift(self::$scripts, $path);
+ }
+ else {
+ self::$scripts[] = $path;
+ }
}
}
@@ -457,12 +464,18 @@ class OC_Util {
*
* @param string $application application id
* @param string|null $file filename
+ * @param bool $prepend prepend the Script to the beginning of the list
* @return void
*/
- public static function addVendorScript($application, $file = null) {
+ public static function addVendorScript($application, $file = null, $prepend = false) {
$path = OC_Util::generatePath($application, 'vendor', $file);
- if (!in_array($path, self::$scripts)) {
- self::$scripts[] = $path;
+ //TODO eliminate double code
+ if (! in_array ( $path, self::$scripts )) {
+ if ($prepend === true) {
+ array_unshift ( self::$scripts, $path );
+ } else {
+ self::$scripts [] = $path;
+ }
}
}
@@ -471,8 +484,9 @@ class OC_Util {
*
* @param string $application application id
* @param string $languageCode language code, defaults to the current language
+ * @param bool $prepend prepend the Script to the beginning of the list
*/
- public static function addTranslations($application, $languageCode = null) {
+ public static function addTranslations($application, $languageCode = null, $prepend = false) {
if (is_null($languageCode)) {
$languageCode = \OC_L10N::findLanguage($application);
}
@@ -481,8 +495,13 @@ class OC_Util {
} else {
$path = "l10n/$languageCode";
}
+ //TODO eliminate double code
if (!in_array($path, self::$scripts)) {
- self::$scripts[] = $path;
+ if ($prepend === true) {
+ array_unshift ( self::$scripts, $path );
+ } else {
+ self::$scripts [] = $path;
+ }
}
}
@@ -491,12 +510,18 @@ class OC_Util {
*
* @param string $application application id
* @param string|null $file filename
+ * @param bool $prepend prepend the Style to the beginning of the list
* @return void
*/
- public static function addStyle($application, $file = null) {
+ public static function addStyle($application, $file = null, $prepend = false) {
$path = OC_Util::generatePath($application, 'css', $file);
+ //TODO eliminate double code
if (!in_array($path, self::$styles)) {
- self::$styles[] = $path;
+ if ($prepend === true) {
+ array_unshift ( self::$styles, $path );
+ } else {
+ self::$styles[] = $path;
+ }
}
}
@@ -505,12 +530,18 @@ class OC_Util {
*
* @param string $application application id
* @param string|null $file filename
+ * @param bool $prepend prepend the Style to the beginning of the list
* @return void
*/
- public static function addVendorStyle($application, $file = null) {
+ public static function addVendorStyle($application, $file = null, $prepend = false) {
$path = OC_Util::generatePath($application, 'vendor', $file);
+ //TODO eliminate double code
if (!in_array($path, self::$styles)) {
- self::$styles[] = $path;
+ if ($prepend === true) {
+ array_unshift ( self::$styles, $path );
+ } else {
+ self::$styles[] = $path;
+ }
}
}