diff options
Diffstat (limited to 'mod/sitepages/sitepages_functions.php')
-rw-r--r-- | mod/sitepages/sitepages_functions.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php index 44cb0640d..baf8e365b 100644 --- a/mod/sitepages/sitepages_functions.php +++ b/mod/sitepages/sitepages_functions.php @@ -119,6 +119,8 @@ function sitepages_get_page_content($page_type) { * @return html */ function sitepages_parse_view_match($matches) { + global $CONFIG; + $keyword = $matches[0]; $type = trim($matches[1]); $params_string = trim($matches[2]); @@ -142,6 +144,19 @@ function sitepages_parse_view_match($matches) { break; + default: + // match against custom keywords with optional args + if (isset($CONFIG->sitepages_keywords[$type])) { + $keyword_info = $CONFIG->sitepages_keywords[$type]; + $vars = sitepages_keywords_tokenize_params($params_string); + $content = elgg_view($keyword_info['view'], $vars); + } + break; + } + + // if nothing matched return the original string. + if (!$content) { + $content = $matches[0]; } return $content; @@ -155,7 +170,6 @@ function sitepages_parse_view_match($matches) { */ function sitepages_keywords_tokenize_params($string) { $pairs = array_map('trim', explode(',', $string)); - $params = array(); foreach ($pairs as $pair) { @@ -163,7 +177,18 @@ function sitepages_keywords_tokenize_params($string) { $name = trim($name); $value = trim($value); - $params[$name] = $value; + + // normalize BOOL values + if ($value === 'true') { + $value = TRUE; + } elseif ($value === 'false') { + $value = FALSE; + } + + // don't check against value since a falsy/empty value is valid. + if ($name) { + $params[$name] = $value; + } } return $params; @@ -211,8 +236,6 @@ function sitepages_keywords_parse_entity_params($string) { return $params; } - - /** * Utility object to store site page information. */ |