allow themes to use "style.php" instead of "style.css".

Load style.php trhu mod/view.php to pass it friendica framework.
This commit is contained in:
Fabio Comuni 2012-03-30 21:18:25 +02:00
parent 77f57e1b13
commit 01af7d355a
2 changed files with 26 additions and 5 deletions

View file

@ -1261,17 +1261,20 @@ function current_theme(){
$system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
$theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); $theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css')) if($theme_name &&
(file_exists('view/theme/' . $theme_name . '/style.css') ||
file_exists('view/theme/' . $theme_name . '/style.php')))
return($theme_name); return($theme_name);
foreach($app_base_themes as $t) { foreach($app_base_themes as $t) {
if(file_exists('view/theme/' . $t . '/style.css')) if(file_exists('view/theme/' . $t . '/style.css')||
file_exists('view/theme/' . $t . '/style.php'))
return($t); return($t);
} }
$fallback = glob('view/theme/*/style.css'); $fallback = glob('view/theme/*/style.[css|php]');
if(count($fallback)) if(count($fallback))
return (str_replace('view/theme/','', str_replace("/style.css","",$fallback[0]))); return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
}} }}
@ -1283,6 +1286,8 @@ if(! function_exists('current_theme_url')) {
function current_theme_url() { function current_theme_url() {
global $a; global $a;
$t = current_theme(); $t = current_theme();
if (file_exists('view/theme/' . $t . '/style.php'))
return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss');
return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
}} }}

16
mod/view.php Normal file
View file

@ -0,0 +1,16 @@
<?php
/**
* load view/theme/$current_theme/style.php with friendica contex
*/
function view_init($a){
header("Content-Type: text/css");
if ($a->argc == 4){
$theme = $a->argv[2];
$THEMEPATH = "view/theme/$theme";
require_once("view/theme/$theme/style.php");
}
killme();
}