aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/plugin.php47
-rw-r--r--index.php34
2 files changed, 42 insertions, 39 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 '';
+}
diff --git a/index.php b/index.php
index 4de315520..35f10239d 100644
--- a/index.php
+++ b/index.php
@@ -91,19 +91,6 @@ if((x($_GET,'zrl')) && (! $install)) {
zrl_init($a);
}
-/**
- *
- * For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
- * Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
- * this way. There's a PHP flag to link the headers because by default this will over-write any other
- * link header.
- *
- * What we really need to do is output the raw headers ourselves so we can keep them separate.
- *
- */
-
-// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
-
if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
require("auth.php");
@@ -119,7 +106,6 @@ if(! x($_SESSION,'authenticated'))
$a->init_pagehead();
-
if(! x($_SESSION,'sysmsg'))
$_SESSION['sysmsg'] = array();
@@ -336,12 +322,8 @@ if($a->module != 'install') {
* Build the page - now that we have all the components
*/
-if(file_exists('view/theme/' . current_theme() . '/php/theme_init.php'))
- require_once('view/theme/' . current_theme() . '/php/theme_init.php');
-elseif(file_exists('view/theme/' . $a->theme_info['extends'] . '/php/theme_init.php'))
- require_once('view/theme/' . $a->theme_info['extends'] . '/php/theme_init.php');
-else
- require_once('view/php/theme_init.php');
+
+require_once(theme_include('theme_init.php'));
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
head_add_css('mod_' . $a->module . '.css');
@@ -398,13 +380,11 @@ $profile = $a->profile;
header("Content-type: text/html; charset=utf-8");
-$template = 'view/theme/' . current_theme() . '/php/'
- . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
-
-if(file_exists($template))
- require_once($template);
-else
- require_once(str_replace('theme/' . current_theme() . '/', '', $template));
+require_once(theme_include(
+ ((x($a->page,'template'))
+ ? $a->page['template']
+ : 'default' )
+ . '.php' ));
session_write_close();
exit;