public function renderView($view, array $vars = [], $ignored = false, $viewtype = '', $issue_missing_notice = true)
{
$view = $this->canonicalizeViewName($view);
if (!is_string($view) || !is_string($viewtype)) {
$this->logger->log("View and Viewtype in views must be a strings: {$view}", 'NOTICE');
return '';
}
// basic checking for bad paths
if (strpos($view, '..') !== false) {
return '';
}
if (!is_array($vars)) {
$this->logger->log("Vars in views must be an array: {$view}", 'ERROR');
$vars = array();
}
// Get the current viewtype
if ($viewtype === '' || !_elgg_is_valid_viewtype($viewtype)) {
$viewtype = elgg_get_viewtype();
}
// allow altering $vars
$vars_hook_params = ['view' => $view, 'vars' => $vars, 'viewtype' => $viewtype];
$vars = $this->hooks->trigger(self::VIEW_VARS_HOOK, $view, $vars_hook_params, $vars);
// allow $vars to hijack output
if (isset($vars[self::OUTPUT_KEY])) {
return (string) $vars[self::OUTPUT_KEY];
}
$view_orig = $view;
$viewlist = $this->getViewList($view);
$content = '';
foreach ($viewlist as $view) {
$rendering = $this->renderViewFile($view, $vars, $viewtype, $issue_missing_notice);
if ($rendering !== false) {
$content .= $rendering;
continue;
}
// attempt to load default view
if ($viewtype !== 'default' && $this->doesViewtypeFallback($viewtype)) {
$rendering = $this->renderViewFile($view, $vars, 'default', $issue_missing_notice);
if ($rendering !== false) {
$content .= $rendering;
}
}
}
// Plugin hook
$params = ['view' => $view_orig, 'vars' => $vars, 'viewtype' => $viewtype];
$content = $this->hooks->trigger(self::VIEW_HOOK, $view_orig, $params, $content);
return $content;
}