aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-11 13:17:34 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-11 13:17:34 +0000
commit739ba4e2e92c62ebb768cf49b7eedd464014d616 (patch)
tree527f75cef1f25d73c979cfd203490317755feae6 /engine/lib
parent0c5e0a8a09e51db5eacdd096108548ebabd0ef95 (diff)
downloadelgg-739ba4e2e92c62ebb768cf49b7eedd464014d616.tar.gz
elgg-739ba4e2e92c62ebb768cf49b7eedd464014d616.tar.bz2
fixes #1339 - elgg_view_exists now handles view extensions for non-default viewtypes (for one level of recursion)
git-svn-id: http://code.elgg.org/elgg/trunk@3666 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/elgglib.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 88d42ad66..cf8b7a31f 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -294,14 +294,15 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype
*
* @param string $view The view name
* @param string $viewtype If set, forces the viewtype
+ * @param bool $recurse If false, do not recursively check extensions
* @return true|false Depending on success
*/
-function elgg_view_exists($view, $viewtype = '') {
+function elgg_view_exists($view, $viewtype = '', $recurse = true) {
global $CONFIG;
// Detect view type
if (empty($viewtype)) {
- $viewtype = elgg_get_viewtype();
+ $viewtype = elgg_get_viewtype();
}
if (!isset($CONFIG->views->locations[$viewtype][$view])) {
@@ -319,9 +320,14 @@ function elgg_view_exists($view, $viewtype = '') {
}
// If we got here then check whether this exists as an extension
- // Note that this currently does not recursively check whether the extended view exists also
- if (isset($CONFIG->views->extensions[$view])) {
- return true;
+ // We optionally recursively check whether the extended view exists also for the viewtype
+ if ($recurse && isset($CONFIG->views->extensions[$view])) {
+ foreach( $CONFIG->views->extensions[$view] as $view_extension ) {
+ // do not recursively check to stay away from infinite loops
+ if (elgg_view_exists($view_extension, $viewtype, false)) {
+ return true;
+ }
+ }
}
return false;