]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added elgg_register_viewtype().
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 28 Dec 2010 23:46:09 +0000 (23:46 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 28 Dec 2010 23:46:09 +0000 (23:46 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7732 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/views.php

index b5240b4318018a83b9068e823287350b44fe2c50..396eb7c126934aba55aa85ea694f1a815e6f3118 100644 (file)
@@ -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);
                }
        }
 }