summaryrefslogtreecommitdiffstats
path: root/lib/private/util.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-11-03 11:18:17 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-11-03 20:54:40 +0100
commitd763b320486a3cd475c0e7a1537b0954341287d6 (patch)
tree5d8d536d1be75cd6558bb41698328664dd0f29fb /lib/private/util.php
parentd2276215a475062c781f57d80f912f421f4b69fe (diff)
downloadnextcloud-server-d763b320486a3cd475c0e7a1537b0954341287d6.tar.gz
nextcloud-server-d763b320486a3cd475c0e7a1537b0954341287d6.zip
ability to add bower resources
* add addVendorScript & addVendorStyle * refactoring of addScript and addStyle * add shortcuts vendorScript and vendorStyle
Diffstat (limited to 'lib/private/util.php')
-rw-r--r--lib/private/util.php58
1 files changed, 42 insertions, 16 deletions
diff --git a/lib/private/util.php b/lib/private/util.php
index de4bef4cb8a..bee0a579192 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -331,25 +331,48 @@ class OC_Util {
}
/**
- * add a javascript file
+ * generates a path for JS/CSS files. If no application is provided it will create the path for core.
*
- * @param string $application application id
- * @param string|null $file filename
- * @return void
+ * @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
+ * @return string the path
*/
- public static function addScript($application, $file = null) {
+ private static function generatePath($application, $directory, $file) {
if (is_null($file)) {
$file = $application;
$application = "";
}
if (!empty($application)) {
- self::$scripts[] = "$application/js/$file";
+ return "$application/$directory/$file";
} else {
- self::$scripts[] = "js/$file";
+ return "$directory/$file";
}
}
/**
+ * add a javascript file
+ *
+ * @param string $application application id
+ * @param string|null $file filename
+ * @return void
+ */
+ public static function addScript($application, $file = null) {
+ self::$scripts[] = OC_Util::generatePath($application, 'js', $file);
+ }
+
+ /**
+ * add a javascript file from the vendor sub folder
+ *
+ * @param string $application application id
+ * @param string|null $file filename
+ * @return void
+ */
+ public static function addVendorScript($application, $file = null) {
+ self::$scripts[] = OC_Util::generatePath($application, 'vendor', $file);
+ }
+
+ /**
* add a translation JS file
*
* @param string $application application id
@@ -375,15 +398,18 @@ class OC_Util {
* @return void
*/
public static function addStyle($application, $file = null) {
- if (is_null($file)) {
- $file = $application;
- $application = "";
- }
- if (!empty($application)) {
- self::$styles[] = "$application/css/$file";
- } else {
- self::$styles[] = "css/$file";
- }
+ self::$styles[] = OC_Util::generatePath($application, 'css', $file);
+ }
+
+ /**
+ * add a css file from the vendor sub folder
+ *
+ * @param string $application application id
+ * @param string|null $file filename
+ * @return void
+ */
+ public static function addVendorStyle($application, $file = null) {
+ self::$styles[] = OC_Util::generatePath($application, 'vendor', $file);
}
/**