mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
add "falsey" test
This commit is contained in:
@@ -123,7 +123,8 @@ class MessageFilter {
|
||||
* - ?foo {} baz which will check if 'baz' is an array element in item.foo
|
||||
* - ?foo {*} baz which will check if 'baz' is an array key in item.foo
|
||||
* - ?foo which will check for a return of a true condition for item.foo;
|
||||
*
|
||||
* - ?!foo which will check for a return of a false condition for item.foo;
|
||||
*
|
||||
* The values 0, '', an empty array, and an unset value will all evaluate to false.
|
||||
*
|
||||
* @param string $s
|
||||
@@ -205,6 +206,15 @@ class MessageFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ordering of this check (for falsiness) with relation to the following one (check for truthiness) is important.
|
||||
if (preg_match('/\!(.*?)$/', $s, $matches)) {
|
||||
$x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR);
|
||||
if (!$x) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/(.*?)$/', $s, $matches)) {
|
||||
$x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR);
|
||||
if ($x) {
|
||||
|
||||
@@ -219,7 +219,8 @@ class Comanche {
|
||||
* - [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');
|
||||
*
|
||||
* - [if !$config.system.foo] which will check for a return of a false condition for get_config('system','foo');
|
||||
*
|
||||
* The values 0, '', an empty array, and an unset value will all evaluate to false.
|
||||
*
|
||||
* @param int|string $s
|
||||
@@ -299,6 +300,15 @@ class Comanche {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ordering of this check (for falsiness) with relation to the following one (check for truthiness) is important.
|
||||
if (preg_match('/[\!\$](.*?)$/', $s, $matches)) {
|
||||
$x = $this->get_condition_var($matches[1]);
|
||||
if (!$x) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(preg_match('/[\$](.*?)$/',$s,$matches)) {
|
||||
$x = $this->get_condition_var($matches[1]);
|
||||
if($x)
|
||||
|
||||
Reference in New Issue
Block a user