From 4f07abe65586d66b0000e9b877ce467d71178aa2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 Feb 2017 21:01:20 +0100 Subject: add a minversion to the theme and fallback to default if requirement is not met. mark incompatible themes in the theme selector --- Zotlabs/Render/Theme.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index dadb18051..53bcfe664 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,8 +69,13 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $chosen_theme = $_GET['theme_preview']; - // Allow theme selection of the form 'theme_name:schema_name' + // Check if $chosen_theme is compatible with core. If not fall back to default + $min_version = ((file_exists('view/theme/' . $chosen_theme . '/.MINVERSION')) ? file_get_contents('view/theme/' . $chosen_theme . '/.MINVERSION') : 0); + if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $chosen_theme = ''; + } + // Allow theme selection of the form 'theme_name:schema_name' $themepair = explode(':', $chosen_theme); if($chosen_theme && (file_exists('view/theme/' . $themepair[0] . '/css/style.css') || file_exists('view/theme/' . $themepair[0] . '/php/style.php'))) { -- cgit v1.2.3 From 0f208fb36bca5e3395d34ce3553d98bab389ddd3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:13:08 +0100 Subject: set minversion and maxversion for themes in view/theme/themename/php/theme.php instead of separate file. --- Zotlabs/Render/Theme.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 53bcfe664..7464a0db2 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -70,8 +70,9 @@ class Theme { $chosen_theme = $_GET['theme_preview']; // Check if $chosen_theme is compatible with core. If not fall back to default - $min_version = ((file_exists('view/theme/' . $chosen_theme . '/.MINVERSION')) ? file_get_contents('view/theme/' . $chosen_theme . '/.MINVERSION') : 0); - if((version_compare($min_version, STD_VERSION, '>=')) || ($min_version == 0)) { + $info = get_theme_info($chosen_theme); + $compatible = check_plugin_versions($info); + if(!$compatible) { $chosen_theme = ''; } -- cgit v1.2.3 From f93431b43ef1e8211b6f00361d9399bf0383451b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 10:44:50 +0100 Subject: do not mess up schemas --- Zotlabs/Render/Theme.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 7464a0db2..71eef50c3 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,16 +69,18 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $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($chosen_theme); + $info = get_theme_info($themepair[0]); $compatible = check_plugin_versions($info); if(!$compatible) { $chosen_theme = ''; } - // Allow theme selection of the form 'theme_name:schema_name' - $themepair = explode(':', $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); } -- cgit v1.2.3 From 7f423016f0c67302a9155d58f2cf6148e5399a87 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Feb 2017 11:11:53 +0100 Subject: whitespace --- Zotlabs/Render/Theme.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 71eef50c3..3a0116abe 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -69,8 +69,6 @@ class Theme { if(array_key_exists('theme_preview',$_GET)) $chosen_theme = $_GET['theme_preview']; - - // Allow theme selection of the form 'theme_name:schema_name' $themepair = explode(':', $chosen_theme); -- cgit v1.2.3 From 755b75161494ea9810ab0e38242cb1a318793ed3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 16:55:47 -0700 Subject: Comanche: allow widgets to be class based and stored appropriately in Zotlabs --- Zotlabs/Render/Comanche.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 5826063fd..899fbd8aa 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -410,6 +410,20 @@ class Comanche { } } + $clsname = ucfirst($name); + $nsname = "Zotlabs\\Widget\\" . $clsname; + if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) + require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); + elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) + require_once('Zotlabs/Widget/' . $clsname . '.php'); + if(class_exists($nsname)) { + $x = new $nsname; + $f = 'widget'; + if(method_exists($x,$f)) { + return $x->$f($vars); + } + } + $func = 'widget_' . trim($name); if(! function_exists($func)) { -- cgit v1.2.3 From 242ef70a775a86050152c0aea9096ec1cd6d0312 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 17:05:16 -0700 Subject: use absolute namespace --- Zotlabs/Render/Comanche.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 899fbd8aa..60a7b232c 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -411,7 +411,8 @@ class Comanche { } $clsname = ucfirst($name); - $nsname = "Zotlabs\\Widget\\" . $clsname; + $nsname = "\\Zotlabs\\Widget\\" . $clsname; + if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) -- cgit v1.2.3 From 6c92a240cca673b4cdac25a2e64503a0d50c0124 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 16 Mar 2017 18:36:58 -0700 Subject: remove include/widgets.php --- Zotlabs/Render/Comanche.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 60a7b232c..5c1ca7d10 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -4,8 +4,6 @@ namespace Zotlabs\Render; require_once('include/security.php'); require_once('include/menu.php'); -require_once('include/widgets.php'); - class Comanche { -- cgit v1.2.3 From 1bf37305a8850e3336f47d2de63fdd26e16fe595 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 May 2017 20:55:31 -0400 Subject: Implemented switch statement logic in Comanche layout parser. --- Zotlabs/Render/Comanche.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Render') diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 5c1ca7d10..beee9796e 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -18,7 +18,49 @@ class Comanche { $s = str_replace($mtch[0], '', $s); } } - + + /* + * This section supports the "switch" statement of the form given by the following + * example. The [default][/default] block must be the last in the arbitrary + * list of cases. The first case that matches the switch variable is used + * and the rest are not evaluated. + * + * [switch observer.language] + * [case de] + * [block]german-content[/block] + * [/case] + * [case es] + * [block]spanish-content[/block] + * [/case] + * [default] + * [block]english-content[/block] + * [/default] + * [/switch] + */ + + $cnt = preg_match_all("/\[switch (.*?)\](.*?)\[default\](.*?)\[\/default\]\s*\[\/switch\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $switch_done = 0; + $switch_var = $this->get_condition_var($mtch[1]); + $default = $mtch[3]; + $cases = array(); + $cntt = preg_match_all("/\[case (.*?)\](.*?)\[\/case\]/ism", $mtch[2], $cases, PREG_SET_ORDER); + if($cntt) { + foreach($cases as $case) { + if($case[1] === $switch_var) { + $switch_done = 1; + $s = str_replace($mtch[0], $case[2], $s); + break; + } + } + if($switch_done === 0) { + $s = str_replace($mtch[0], $default, $s); + } + } + } + } + $cnt = preg_match_all("/\[if (.*?)\](.*?)\[else\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { -- cgit v1.2.3