aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-24 21:26:46 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-24 21:26:46 +0000
commitc2acc52e22c62eeecfde81ecddf0ca9770dd7895 (patch)
treede54479bde8ea51df8c53e422b301be0e159ee99
parent9706785797c06f1fb3a04ee8022749b473457a85 (diff)
downloadelgg-c2acc52e22c62eeecfde81ecddf0ca9770dd7895.tar.gz
elgg-c2acc52e22c62eeecfde81ecddf0ca9770dd7895.tar.bz2
Cleaned up some code in elgg_view().
git-svn-id: http://code.elgg.org/elgg/trunk@3578 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/elgglib.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 2b2180532..351750b0b 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -255,20 +255,25 @@ 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";
- if (file_exists("$view_location$viewtype/$view.php")
- && !include("$view_location$viewtype/$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") {
- if (include("{$view_location}default/$view.php")) {
+ $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 does not exist", 'ERROR');
+ elgg_log("The view $view could not be included", 'WARNING');
}
- } else if (!file_exists("$view_location$viewtype/$view.php")) {
+
+ } else if (!file_exists($view_file)) {
elgg_log("The view $view does not exist", 'WARNING');
}
@@ -625,6 +630,7 @@ function elgg_view_entity(ElggEntity $entity, $full = false, $bypass = true, $de
}
}
}
+
if (!isset($entity_class)) {
return false;
}
@@ -1749,12 +1755,12 @@ function __elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
*/
function elgg_log($message, $level='NOTICE') {
global $CONFIG;
-
+
// only log when debugging is enabled
if (isset($CONFIG->debug)) {
// debug to screen or log?
$to_screen = !($CONFIG->debug == 'NOTICE');
-
+
switch ($level) {
case 'ERROR':
// always report
@@ -1775,10 +1781,10 @@ function elgg_log($message, $level='NOTICE') {
}
break;
}
-
+
return TRUE;
}
-
+
return FALSE;
}
@@ -2332,7 +2338,7 @@ function __elgg_shutdown_hook() {
global $START_MICROTIME;
trigger_elgg_event('shutdown', 'system');
-
+
$time = (float)(microtime(TRUE) - $START_MICROTIME);
elgg_log("Page {$_SERVER['REQUEST_URI']} generated in $time seconds", 'DEBUG');
}