]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1161: Views now default to 'default' if not found.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 27 Oct 2009 13:54:55 +0000 (13:54 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 27 Oct 2009 13:54:55 +0000 (13:54 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3585 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index 2eecfefb6f1fef3e1ec22cacb28fbdaed1924396..4ac43e4defde537ffb6b2a28c81a22be96ed5539 100644 (file)
@@ -238,7 +238,6 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype
                }
        }
 
-
        // Get the current viewtype
        if (empty($viewtype)) {
                $viewtype = elgg_get_viewtype();
@@ -256,27 +255,16 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype
        foreach($viewlist as $priority => $view) {
                $view_location = elgg_get_view_location($view, $viewtype);
                $view_file = "$view_location$viewtype/$view.php";
+               $default_view_file = "{$view_location}default/$view.php";
 
                // try to include view, defaulting to 'default' view if error.
-
-               if (file_exists($view_file)     && !include($view_file)) {
-                       $success = false;
-
-                       if ($viewtype != "default") {
-                               $default_view_file = "{$view_location}default/$view.php";
-                               if (file_exists($default_view_file) && include($default_view_file)) {
-                                       $success = true;
-                               }
-                       }
-
-                       if (!$success) {
-                               elgg_log("The view $view could not be included", 'WARNING');
+               if (!file_exists($view_file) || !include($view_file)) {
+                       if ($viewtype != 'default' && file_exists($default_view_file) && include($default_view_file)) {
+                               elgg_log("$viewtype/$view view does not exist.  Using default/$view instead.", 'WARNING');
+                       } else {
+                               elgg_log("Neither $viewtype/$view nor default/$view view exists.", 'WARNING');
                        }
-
-               } else if (!file_exists($view_file)) {
-                       elgg_log("The view $view does not exist", 'WARNING');
                }
-
        }
 
        // Save the output buffer into the $content variable