cleanup all the theme include stuff - this could make Friendica themes work out of the box, maybe.
This commit is contained in:
parent
e80d69d25b
commit
f261871346
@ -422,12 +422,9 @@ function format_css_if_exists($source) {
|
|||||||
|
|
||||||
if(strpos($source[0],'/') !== false)
|
if(strpos($source[0],'/') !== false)
|
||||||
$path = $source[0];
|
$path = $source[0];
|
||||||
elseif(file_exists('view/theme/'. current_theme() . '/css/' . $source[0]))
|
else
|
||||||
$path = 'view/theme/'. current_theme() . '/css/' . $source[0];
|
$path = theme_include($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)
|
if($path)
|
||||||
return '<link rel="stylesheet" href="' . z_root() . '/' . $path . '" type="text/css" media="' . $source[1] . '" />' . "\r\n";
|
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)
|
if(strpos($source,'/') !== false)
|
||||||
$path = $source;
|
$path = $source;
|
||||||
elseif(file_exists('view/theme/'. current_theme() . '/js/' . $source))
|
else
|
||||||
$path = 'view/theme/'. current_theme() . '/js/' . $source;
|
$path = theme_include($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)
|
if($path)
|
||||||
return '<script src="' . z_root() . '/' . $source . '" ></script>' . "\r\n" ;
|
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 '';
|
||||||
|
}
|
||||||
|
34
index.php
34
index.php
@ -91,19 +91,6 @@ if((x($_GET,'zrl')) && (! $install)) {
|
|||||||
zrl_init($a);
|
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'))
|
if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
|
||||||
require("auth.php");
|
require("auth.php");
|
||||||
|
|
||||||
@ -119,7 +106,6 @@ if(! x($_SESSION,'authenticated'))
|
|||||||
$a->init_pagehead();
|
$a->init_pagehead();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(! x($_SESSION,'sysmsg'))
|
if(! x($_SESSION,'sysmsg'))
|
||||||
$_SESSION['sysmsg'] = array();
|
$_SESSION['sysmsg'] = array();
|
||||||
|
|
||||||
@ -336,12 +322,8 @@ if($a->module != 'install') {
|
|||||||
* Build the page - now that we have all the components
|
* 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');
|
require_once(theme_include('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');
|
|
||||||
|
|
||||||
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
|
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
|
||||||
head_add_css('mod_' . $a->module . '.css');
|
head_add_css('mod_' . $a->module . '.css');
|
||||||
@ -398,13 +380,11 @@ $profile = $a->profile;
|
|||||||
|
|
||||||
header("Content-type: text/html; charset=utf-8");
|
header("Content-type: text/html; charset=utf-8");
|
||||||
|
|
||||||
$template = 'view/theme/' . current_theme() . '/php/'
|
require_once(theme_include(
|
||||||
. ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
|
((x($a->page,'template'))
|
||||||
|
? $a->page['template']
|
||||||
if(file_exists($template))
|
: 'default' )
|
||||||
require_once($template);
|
. '.php' ));
|
||||||
else
|
|
||||||
require_once(str_replace('theme/' . current_theme() . '/', '', $template));
|
|
||||||
|
|
||||||
session_write_close();
|
session_write_close();
|
||||||
exit;
|
exit;
|
||||||
|
Reference in New Issue
Block a user