From 3dc7b6ff6bbcc7d885214a89d6fb3a5892fdf4b0 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 31 Jul 2008 12:26:40 +0000 Subject: Introducing elgg_get_view_location() git-svn-id: https://code.elgg.org/elgg/trunk@1626 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 0f15e3092..2aabe5c36 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -120,6 +120,28 @@ return $viewtype; } + + /** + * Return the location of a given view. + * + * @param string $view The view. + */ + function elgg_get_view_location($view) + { + global $CONFIG; + + if (!isset($CONFIG->views->locations[$view])) { + if (!isset($CONFIG->viewpath)) { + return dirname(dirname(dirname(__FILE__))) . "/views/"; + } else { + return $CONFIG->viewpath; + } + } else { + return $CONFIG->views->locations[$view]; + } + + return false; + } /** * Handles templating views @@ -192,16 +214,8 @@ // Start the output buffer, find the requested view file, and execute it ob_start(); foreach($viewlist as $priority => $view) { - - if (!isset($CONFIG->views->locations[$view])) { - if (!isset($CONFIG->viewpath)) { - $view_location = dirname(dirname(dirname(__FILE__))) . "/views/"; - } else { - $view_location = $CONFIG->viewpath; - } - } else { - $view_location = $CONFIG->views->locations[$view]; - } + + $view_location = elgg_get_view_location($view); if (file_exists($view_location . "{$viewtype}/{$view}.php") && !@include($view_location . "{$viewtype}/{$view}.php")) { -- cgit v1.2.3