aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-11 19:28:58 -0700
committerfriendica <info@friendica.com>2012-08-11 19:28:58 -0700
commitf261871346373f649644bbfc390815294f4ecfeb (patch)
treeacb1191f6a665e7383ca5a60f01b8a3a746a247b /include/plugin.php
parente80d69d25b816cda36e2c772db2805f2dc744bbe (diff)
downloadvolse-hubzilla-f261871346373f649644bbfc390815294f4ecfeb.tar.gz
volse-hubzilla-f261871346373f649644bbfc390815294f4ecfeb.tar.bz2
volse-hubzilla-f261871346373f649644bbfc390815294f4ecfeb.zip
cleanup all the theme include stuff - this could make Friendica themes work out of the box, maybe.
Diffstat (limited to 'include/plugin.php')
-rw-r--r--include/plugin.php47
1 files changed, 35 insertions, 12 deletions
diff --git a/include/plugin.php b/include/plugin.php
index c9490eb8a..2460e8ad6 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -422,12 +422,9 @@ 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];
+ else
+ $path = theme_include($source[0]);
+
if($path)
return '<link rel="stylesheet" href="' . z_root() . '/' . $path . '" type="text/css" media="' . $source[1] . '" />' . "\r\n";
@@ -451,14 +448,40 @@ 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];
+ else
+ $path = theme_include($source);
if($path)
return '<script src="' . z_root() . '/' . $source . '" ></script>' . "\r\n" ;
}
+
+function theme_include($file) {
+
+ $paths = array(
+ 'view/theme/$theme/$ext/$file',
+ 'view/theme/$theme/$file',
+ 'view/theme/$parent/$ext/$file',
+ 'view/theme/$parent/$file',
+ 'view/$ext/$file',
+ 'view/$file'
+ );
+
+ $parent = get_app()->theme_info['extends'];
+ if(! $parent)
+ $parent = 'NOPATH';
+
+ foreach($paths as $p) {
+ $f = replace_macros($p,array(
+ '$theme' => current_theme(),
+ '$ext' => substr($file,strrpos($file,'.')+1),
+ '$parent' => $parent,
+ '$file' => $file
+ ));
+ if(strstr($f,'NOPATH'))
+ continue;
+ if(file_exists($f))
+ return $f;
+ }
+ return '';
+}