- Setup: check php version (5.4 required)

- Comanche: implement conditionals. Currently the only supported tests are true/false for system config settings
and supports the following forms:

[if $config.system.foo]
[widget=widget1][/widget]
[else]
[widget=widget2][/widget]
[/if]

[if $config.system.foo]
[widget=widget1][/widget]
[/if]
This commit is contained in:
redmatrix 2016-05-05 18:15:07 -07:00
parent 8ffdc4859b
commit 2e3da0cbbb
2 changed files with 41 additions and 1 deletions

View File

@ -407,6 +407,11 @@ class Setup extends \Zotlabs\Web\Controller {
function check_php(&$phpath, &$checks) {
$help = '';
if(version_compare(PHP_VERSION, '5.4') < 0) {
$help .= t('PHP version 5.4 or greater is required.');
$this->check_add($checks, t('PHP version'), false, false, $help);
}
if (strlen($phpath)) {
$passed = file_exists($phpath);
} else {

View File

@ -53,6 +53,31 @@ function comanche_parser(&$a, $s, $pass = 0) {
}
}
$cnt = preg_match_all("/\[if (.*?)\](.*?)\[else\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
if(comanche_test_condition($mtch[1])) {
$s = str_replace($mtch[0], $mtch[2], $s);
}
else {
$s = str_replace($mtch[0], $mtch[3], $s);
}
}
}
else {
$cnt = preg_match_all("/\[if (.*?)\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
if(comanche_test_condition($mtch[1])) {
$s = str_replace($mtch[0], $mtch[2], $s);
}
else {
$s = str_replace($mtch[0], '', $s);
}
}
}
}
if($pass == 0) {
$cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches);
if($cnt)
@ -86,7 +111,6 @@ function comanche_parser(&$a, $s, $pass = 0) {
App::$layout['webpage'] = comanche_webpage($a,$mtch[1]);
}
}
}
else {
$cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
@ -100,6 +124,17 @@ function comanche_parser(&$a, $s, $pass = 0) {
}
function comanche_test_condition($s) {
if(preg_match("/[\$]config[\.](.*?)/",$s,$matches)) {
$x = explode('.',$s);
if(get_config($x[1],$x[2]))
return true;
}
return false;
}
function comanche_menu($s, $class = '') {