diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-03-08 09:39:46 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-03-08 09:39:46 +0100 |
commit | bc2b948f1f6e62b1c277a4042200bb6678956f3f (patch) | |
tree | 8586c30e495607eee23f16c0aad40974f0711275 /Zotlabs/Render | |
parent | 23e3e2c50499fab52769929a448e73012fd915af (diff) | |
parent | ff9442474d07cce24c8f66db39ec34471c3874a2 (diff) | |
download | volse-hubzilla-bc2b948f1f6e62b1c277a4042200bb6678956f3f.tar.gz volse-hubzilla-bc2b948f1f6e62b1c277a4042200bb6678956f3f.tar.bz2 volse-hubzilla-bc2b948f1f6e62b1c277a4042200bb6678956f3f.zip |
Merge branch 2.2RC2.2
Diffstat (limited to 'Zotlabs/Render')
-rw-r--r-- | Zotlabs/Render/Comanche.php | 57 | ||||
-rw-r--r-- | Zotlabs/Render/Theme.php | 12 |
2 files changed, 65 insertions, 4 deletions
diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 562a9f791..5826063fd 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -99,13 +99,28 @@ class Comanche { } } + /** + * Currently supported condition variables: + * + * $config.xxx.yyy - get_config with cat = xxx and k = yyy + * $request - request uri for this page + * $observer.language - viewer's preferred language (closest match) + * $observer.address - xchan_addr or false + * $observer.name - xchan_name or false + * $observer - xchan_hash of observer or empty string + */ + function get_condition_var($v) { if($v) { $x = explode('.',$v); if($x[0] == 'config') return get_config($x[1],$x[2]); + elseif($x[0] === 'request') + return $_SERVER['REQUEST_URI']; elseif($x[0] === 'observer') { if(count($x) > 1) { + if($x[1] == 'language') + return \App::$language; $y = \App::get_observer(); if(! $y) return false; @@ -125,20 +140,35 @@ class Comanche { function test_condition($s) { // This is extensible. The first version of variable testing supports tests of the forms: + + // [if $config.system.foo ~= baz] which will check if get_config('system','foo') contains the string 'baz'; // [if $config.system.foo == baz] which will check if get_config('system','foo') is the string 'baz'; // [if $config.system.foo != baz] which will check if get_config('system','foo') is not the string 'baz'; - // You may check numeric entries, but these checks are evaluated as strings. + // [if $config.system.foo >= 3] which will check if get_config('system','foo') is greater than or equal to 3; + // [if $config.system.foo > 3] which will check if get_config('system','foo') is greater than 3; + + // [if $config.system.foo <= 3] which will check if get_config('system','foo') is less than or equal to 3; + // [if $config.system.foo < 3] which will check if get_config('system','foo') is less than 3; + // [if $config.system.foo {} baz] which will check if 'baz' is an array element in get_config('system','foo') // [if $config.system.foo {*} baz] which will check if 'baz' is an array key in get_config('system','foo') // [if $config.system.foo] which will check for a return of a true condition for get_config('system','foo'); // The values 0, '', an empty array, and an unset value will all evaluate to false. + if(preg_match('/[\$](.*?)\s\~\=\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if(stripos($x,trim($matches[2])) !== false) + return true; + return false; + } + if(preg_match('/[\$](.*?)\s\=\=\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if($x == trim($matches[2])) return true; return false; } + if(preg_match('/[\$](.*?)\s\!\=\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if($x != trim($matches[2])) @@ -146,6 +176,31 @@ class Comanche { return false; } + if(preg_match('/[\$](.*?)\s\>\=\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x >= trim($matches[2])) + return true; + return false; + } + if(preg_match('/[\$](.*?)\s\<\=\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x <= trim($matches[2])) + return true; + return false; + } + if(preg_match('/[\$](.*?)\s\>\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x > trim($matches[2])) + return true; + return false; + } + if(preg_match('/[\$](.*?)\s\>\s(.*?)$/',$s,$matches)) { + $x = $this->get_condition_var($matches[1]); + if($x < trim($matches[2])) + return true; + return false; + } + if(preg_match('/[\$](.*?)\s\{\}\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if(is_array($x) && in_array(trim($matches[2]),$x)) diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 9f9009d72..3a0116abe 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -70,9 +70,15 @@ class Theme { $chosen_theme = $_GET['theme_preview']; // Allow theme selection of the form 'theme_name:schema_name' - $themepair = explode(':', $chosen_theme); + // Check if $chosen_theme is compatible with core. If not fall back to default + $info = get_theme_info($themepair[0]); + $compatible = check_plugin_versions($info); + if(!$compatible) { + $chosen_theme = ''; + } + if($chosen_theme && (file_exists('view/theme/' . $themepair[0] . '/css/style.css') || file_exists('view/theme/' . $themepair[0] . '/php/style.php'))) { return($themepair); } @@ -125,9 +131,9 @@ class Theme { $opts .= $schema_str; if(file_exists('view/theme/' . $t . '/php/style.php')) - return('view/theme/' . $t . '/php/style.pcss' . $opts); + return('/view/theme/' . $t . '/php/style.pcss' . $opts); - return('view/theme/' . $t . '/css/style.css'); + return('/view/theme/' . $t . '/css/style.css'); } function debug() { |