aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-09 16:26:44 -0700
committerfriendica <info@friendica.com>2012-08-09 16:26:44 -0700
commit0292d46e5de06529012ebb14ce934fb476d595d0 (patch)
tree16208e490a8e2d6d90996c936c6f467533aaf612 /include/plugin.php
parent432595314affa179bdce439d6e90955cee99cd9e (diff)
downloadvolse-hubzilla-0292d46e5de06529012ebb14ce934fb476d595d0.tar.gz
volse-hubzilla-0292d46e5de06529012ebb14ce934fb476d595d0.tar.bz2
volse-hubzilla-0292d46e5de06529012ebb14ce934fb476d595d0.zip
merge comment threading, provide plugin/theme functions to handle css/js includes
Diffstat (limited to 'include/plugin.php')
-rw-r--r--include/plugin.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 22745835d..a6780d701 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -402,3 +402,64 @@ function upgrade_bool_message($bbcode = false) {
$x = upgrade_link($bbcode);
return t('This action is not available under your subscription plan.') . (($x) ? ' ' . $x : '') ;
}
+
+
+
+function head_add_css($src,$media = 'screen') {
+ get_app()->css_sources[] = array($src,$type);
+
+}
+
+function head_get_css() {
+ $str = '';
+ $sources = get_app()->css_sources;
+ if(count($sources))
+ foreach($sources as $source)
+ $str .= format_css_if_exists($source);
+ return $str;
+}
+
+function format_css_if_exists($source) {
+
+ if(strpos($source[0],'/') !== false)
+ $path = $source[0];
+ elseif(file_exists('view/theme/'. current_theme() . '/css/' . $source[0]))
+ $path = 'view/theme/'. current_theme() . '/css/' . $source[0];
+ elseif(file_exists('view/theme/'. get_app()->theme_info['extends'] . '/css/' . $source[0]))
+ $path = 'view/theme/'. get_app()->theme_info['extends'] . '/css/' . $source[0];
+ elseif(file_exists('view/css/' . $source[0]))
+ $path = 'view/css/' . $source[0];
+ if($path)
+ return '<link rel="stylesheet" href="' . $path . '" type="text/css" media="' . $source[1] . '" />';
+
+}
+
+
+function head_add_js($src) {
+ get_app()->js_sources[] = $src;
+}
+
+function head_get_js() {
+ $str = '';
+ $sources = get_app()->js_sources;
+ if(count($sources))
+ foreach($sources as $source)
+ $str .= format_js_if_exists($source);
+ return $str;
+}
+
+function format_js_if_exists($source) {
+
+ if(strpos($source,'/') !== false)
+ $path = $source;
+ elseif(file_exists('view/theme/'. current_theme() . '/js/' . $source))
+ $path = 'view/theme/'. current_theme() . '/js/' . $source;
+ elseif(file_exists('view/theme/'. get_app()->theme_info['extends'] . '/js/' . $source))
+ $path = 'view/theme/'. get_app()->theme_info['extends'] . '/js/' . $source;
+ elseif(file_exists('view/js/' . $source))
+ $path = 'view/js/' . $source[0];
+ if($path)
+ return '<script src="' . $source . '" />';
+
+}
+