summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-11-04 11:59:33 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-11-04 11:59:33 +0100
commitfde8ef065531e71060fa59f3cb8a42dc7a07f276 (patch)
treef1a6e82398d5e5e6f61daca3f72ab2cdc2d888d7 /lib/private
parentf6cf654354db53cbd47a17cf9204a510156345c2 (diff)
parentd94606cfa23d26dd0d7c3697a3be27902198469a (diff)
downloadnextcloud-server-fde8ef065531e71060fa59f3cb8a42dc7a07f276.tar.gz
nextcloud-server-fde8ef065531e71060fa59f3cb8a42dc7a07f276.zip
Merge pull request #11916 from owncloud/introduce-bower
Introduce bower dependency managment for frontend libraries
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/template/functions.php32
-rw-r--r--lib/private/util.php58
2 files changed, 74 insertions, 16 deletions
diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php
index dede604c01d..0e2c5775c46 100644
--- a/lib/private/template/functions.php
+++ b/lib/private/template/functions.php
@@ -40,6 +40,22 @@ function script($app, $file) {
}
/**
+ * Shortcut for adding vendor scripts to a page
+ * @param string $app the appname
+ * @param string|string[] $file the filename,
+ * if an array is given it will add all scripts
+ */
+function vendorScript($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ OC_Util::addVendorScript($app, $f);
+ }
+ } else {
+ OC_Util::addVendorScript($app, $file);
+ }
+}
+
+/**
* Shortcut for adding styles to a page
* @param string $app the appname
* @param string|string[] $file the filename,
@@ -56,6 +72,22 @@ function style($app, $file) {
}
/**
+ * Shortcut for adding vendor styles to a page
+ * @param string $app the appname
+ * @param string|string[] $file the filename,
+ * if an array is given it will add all styles
+ */
+function vendorStyle($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ OC_Util::addVendorStyle($app, $f);
+ }
+ } else {
+ OC_Util::addVendorStyle($app, $file);
+ }
+}
+
+/**
* Shortcut for adding translations to a page
* @param string $app the appname
* if an array is given it will add all styles
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);
}
/**