From af113e044fe8225a40ddd128f9226b973b0b6437 Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 12 Apr 2010 22:23:05 +0000 Subject: Updated site pages docs. Added ability to pass arguments to custom keywords. Added user_list keyword. Reject logged out front pages that don't have [[login_box]]. git-svn-id: http://code.elgg.org/elgg/trunk@5710 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/sitepages/sitepages_functions.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'mod/sitepages/sitepages_functions.php') 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. */ -- cgit v1.2.3