diff options
Diffstat (limited to 'mod/sitepages/sitepages_functions.php')
-rw-r--r-- | mod/sitepages/sitepages_functions.php | 130 |
1 files changed, 1 insertions, 129 deletions
diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php index baf8e365b..80db39d14 100644 --- a/mod/sitepages/sitepages_functions.php +++ b/mod/sitepages/sitepages_functions.php @@ -62,15 +62,12 @@ function sitepages_create_sitepage_object($page_type) { function sitepages_get_edit_section_content($page_type) { set_context('admin'); - $keywords = ''; - $title = elgg_view_title(elgg_echo('sitepages')); $menu = elgg_view('sitepages/menu', array('page_type' => $page_type)); switch ($page_type) { case 'front': $view = 'sitepages/forms/editfront'; - $keywords = elgg_view('sitepages/keywords'); break; case 'seo': @@ -86,7 +83,7 @@ function sitepages_get_edit_section_content($page_type) { $form .= elgg_view($view, array('page_type' => $page_type)); $body = $title . $menu . $form; - $content = elgg_view_layout('one_column_with_sidebar', $body, $keywords); + $content = elgg_view_layout('one_column_with_sidebar', $body); return $content; } @@ -111,131 +108,6 @@ function sitepages_get_page_content($page_type) { return $content; } - -/** - * Used to determine how to handle special non-static keywords. - * - * @param unknown_type $matches - * @return html - */ -function sitepages_parse_view_match($matches) { - global $CONFIG; - - $keyword = $matches[0]; - $type = trim($matches[1]); - $params_string = trim($matches[2]); - - switch ($type) { - case 'entity': - $options = sitepages_keywords_parse_entity_params($params_string); - // must use this lower-level function because I missed refactoring - // the list entity functions for relationships. - // (which, since you're here, is the only function that runs through all - // possible options for elgg_get_entities*() functions...) - $entities = elgg_get_entities_from_relationship($options); - $content = elgg_view_entity_list($entities, count($entities), $options['offset'], - $options['limit'], $options['full_view'], $options['view_type_toggle'], $options['pagination']); - break; - - case 'view': - // parses this into an acceptable array for $vars. - $info = sitepages_keywords_parse_view_params($params_string); - $content = elgg_view($info['view'], $info['vars']); - - 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; -} - -/** - * Creates an array from a "name=value, name1=value2" string. - * - * @param $string - * @return array - */ -function sitepages_keywords_tokenize_params($string) { - $pairs = array_map('trim', explode(',', $string)); - $params = array(); - - foreach ($pairs as $pair) { - list($name, $value) = explode('=', $pair); - - $name = trim($name); - $value = trim($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; -} - -/** - * - * @param $string - * @return unknown_type - */ -function sitepages_keywords_parse_view_params($string) { - $vars = sitepages_keywords_tokenize_params($string); - - // the first element key is the view - $var_keys = array_keys($vars); - $view = $var_keys[0]; - - $info = array( - 'view' => $view, - 'vars' => $vars - ); - - return $info; - -} - -/** - * Returns an options array suitable for using in elgg_get_entities() - * - * @param string $string "name=value, name2=value2" - * @return array - */ -function sitepages_keywords_parse_entity_params($string) { - $params = sitepages_keywords_tokenize_params($string); - - // handle some special cases - if (isset($params['owner'])) { - if ($user = get_user_by_username($params['owner'])) { - $params['owner_guid'] = $user->getGUID(); - } - } - - // @todo probably need to add more for - // group -> container_guid, etc - return $params; -} - /** * Utility object to store site page information. */ |