aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/template/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/template/functions.php')
-rw-r--r--lib/private/template/functions.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php
index 3cbf0d9748f..cbe751e59b5 100644
--- a/lib/private/template/functions.php
+++ b/lib/private/template/functions.php
@@ -24,6 +24,56 @@ function print_unescaped($string) {
}
/**
+ * Shortcut for adding 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 script($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ OC_Util::addScript($app, $f);
+ }
+ } else {
+ OC_Util::addScript($app, $file);
+ }
+}
+
+/**
+ * Shortcut for adding 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 style($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ OC_Util::addStyle($app, $f);
+ }
+ } else {
+ OC_Util::addStyle($app, $file);
+ }
+}
+
+/**
+ * Shortcut for HTML imports
+ * @param string $app the appname
+ * @param string|string[] $file the path relative to the app's component folder,
+ * if an array is given it will add all components
+ */
+function component($app, $file) {
+ if(is_array($file)) {
+ foreach($file as $f) {
+ $url = link_to($app, 'component/' . $f . '.html');
+ OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
+ }
+ } else {
+ $url = link_to($app, 'component/' . $file . '.html');
+ OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
+ }
+}
+
+/**
* make OC_Helper::linkTo available as a simple function
* @param string $app app
* @param string $file file