public function viewExists($view, $viewtype = '', $recurse = true)
{
$view = $this->canonicalizeViewName($view);
if (empty($view) || !is_string($view)) {
return false;
}
// Detect view type
if ($viewtype === '' || !_elgg_is_valid_viewtype($viewtype)) {
$viewtype = elgg_get_viewtype();
}
$file = $this->findViewFile($view, $viewtype);
if ($file) {
return true;
}
// If we got here then check whether this exists as an extension
// We optionally recursively check whether the extended view exists also for the viewtype
if ($recurse && isset($this->extensions[$view])) {
foreach ($this->extensions[$view] as $view_extension) {
// do not recursively check to stay away from infinite loops
if ($this->viewExists($view_extension, $viewtype, false)) {
return true;
}
}
}
// Now check if the default view exists if the view is registered as a fallback
if ($viewtype != 'default' && $this->doesViewtypeFallback($viewtype)) {
return $this->viewExists($view, 'default');
}
return false;
}