diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-28 23:46:09 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-28 23:46:09 +0000 |
commit | 320655648e2a04928d17a0be3e9f7f05f7623b69 (patch) | |
tree | ff43808a4b6a636e6af3bde268c1b1f022e69d71 /engine | |
parent | c8b7c673286a72662975b82647a5614576141028 (diff) | |
download | elgg-320655648e2a04928d17a0be3e9f7f05f7623b69.tar.gz elgg-320655648e2a04928d17a0be3e9f7f05f7623b69.tar.bz2 |
Added elgg_register_viewtype().
git-svn-id: http://code.elgg.org/elgg/trunk@7732 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/views.php | 25 |
1 files changed, 22 insertions, 3 deletions
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 @@ -113,6 +113,26 @@ function elgg_get_viewtype() { } /** + * 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. * * @param string $view_type View type @@ -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); } } } |