From 320655648e2a04928d17a0be3e9f7f05f7623b69 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 28 Dec 2010 23:46:09 +0000 Subject: Added elgg_register_viewtype(). git-svn-id: http://code.elgg.org/elgg/trunk@7732 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/views.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/views.php b/engine/lib/views.php index b5240b431..396eb7c12 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -112,6 +112,26 @@ function elgg_get_viewtype() { return 'default'; } +/** + * Register a view type as valid. + * + * @param string $view_type The view type to register + * @return bool + */ +function elgg_register_viewtype($view_type) { + global $CONFIG; + + if (!isset($CONFIG->view_types) || !is_array($CONFIG->view_types)) { + $CONFIG->view_types = array(); + } + + if (!in_array($view_type, $CONFIG->view_types)) { + $CONFIG->view_types[] = $view_type; + } + + return true; +} + /** * Checks if $view_type is valid on this installation. * @@ -658,7 +678,7 @@ function elgg_view_layout($layout_name, $vars = array()) { */ function elgg_view_menu($menu_name, array $vars = array()) { global $CONFIG; - + $vars['name'] = $menu_name; $sort_by = elgg_get_array_value('sort_by', $vars, 'title'); @@ -1546,13 +1566,12 @@ function elgg_views_boot() { // discover the built-in view types // @todo cache this $view_path = $CONFIG->viewpath; - $CONFIG->view_types = array(); $views = scandir($view_path); foreach ($views as $view) { if ('.' !== substr($view, 0, 1) && is_dir($view_path . $view)) { - $CONFIG->view_types[] = $view; + elgg_register_viewtype($view); } } } -- cgit v1.2.3