aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Render
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Render')
-rw-r--r--Zotlabs/Render/Comanche.php57
-rw-r--r--Zotlabs/Render/Theme.php12
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() {