29     protected $file_exists_cache = array();
 
   51     private $overriden_locations = array();
 
   62         $this->hooks = $hooks;
 
   63         $this->logger = $logger;
 
   74             if (
$user !== $this->user_wrapped) {
 
   75                 $warning = 
'Use elgg_get_logged_in_user_entity() rather than assuming elgg_view() ' 
   76                             . 
'populates $vars["user"]';
 
   77                 $this->user_wrapper = new \Elgg\DeprecationWrapper(
$user, $warning, 1.8);
 
   78                 $this->user_wrapped = 
$user;
 
   80             $user = $this->user_wrapper;
 
   89         $handle = opendir($folder);
 
   91             while (
$view = readdir($handle)) {
 
   92                 if (!empty($view_base)) {
 
   93                     $view_base_new = $view_base . 
"/";
 
   98                 if (substr(
$view, 0, 1) !== 
'.') {
 
   99                     if (is_dir($folder . 
"/" . 
$view)) {
 
  100                         $this->autoregisterViews($view_base_new . 
$view, $folder . 
"/" . 
$view,
 
  103                         $this->setViewLocation($view_base_new . basename(
$view, 
'.php'),
 
  124             if (!isset($this->CONFIG->viewpath)) {
 
  125                 return dirname(dirname(dirname(__FILE__))) . 
"/views/";
 
  127                 return $this->CONFIG->viewpath;
 
  144         if (!isset($this->CONFIG->views)) {
 
  145             $this->CONFIG->views = new \stdClass;
 
  148         if (!isset($this->CONFIG->views->locations)) {
 
  149             $this->CONFIG->views->locations = array(
$viewtype => array(
$view => $location));
 
  151         } 
else if (!isset($this->CONFIG->views->locations[
$viewtype])) {
 
  152             $this->CONFIG->views->locations[
$viewtype] = array(
$view => $location);
 
  169         if (!isset($this->CONFIG->viewtype)) {
 
  170             $this->CONFIG->viewtype = new \stdClass;
 
  173         if (!isset($this->CONFIG->viewtype->fallback)) {
 
  174             $this->CONFIG->viewtype->fallback = array();
 
  177         $this->CONFIG->viewtype->fallback[] = 
$viewtype;
 
  186         if (isset($this->CONFIG->viewtype) && isset($this->CONFIG->viewtype->fallback)) {
 
  187             return in_array(
$viewtype, $this->CONFIG->viewtype->fallback);
 
  207         $rendered = $this->renderView(
$view, 
$vars, 
false, 
'', 
false);
 
  221             $this->logger->log(
"View and Viewtype in views must be a strings: $view", 
'NOTICE');
 
  225         if (strpos(
$view, 
'..') !== 
false) {
 
  229         if (!is_array(
$vars)) {
 
  230             $this->logger->log(
"Vars in views must be an array: $view", 
'ERROR');
 
  240         $vars_hook_params = [
 
  245         $vars = $this->hooks->trigger(
'view_vars', 
$view, $vars_hook_params, 
$vars);
 
  250         if (!isset($this->CONFIG->pagesetupdone) && $this->CONFIG->boot_complete) {
 
  251             $this->CONFIG->pagesetupdone = 
true;
 
  258         if (!isset(
$vars[
'user'])) {
 
  259             $vars[
'user'] = $this->getUserWrapper();
 
  261         if (!isset(
$vars[
'config'])) {
 
  262             if (!$this->config_wrapper) {
 
  263                 $warning = 
'Do not rely on $vars["config"] or $CONFIG being available in views';
 
  264                 $this->config_wrapper = new \Elgg\DeprecationWrapper($this->CONFIG, $warning, 1.8);
 
  266             $vars[
'config'] = $this->config_wrapper;
 
  268         if (!isset(
$vars[
'url'])) {
 
  269             if (!$this->site_url_wrapper) {
 
  270                 $warning = 
'Do not rely on $vars["url"] being available in views';
 
  271                 $this->site_url_wrapper = new \Elgg\DeprecationWrapper(
elgg_get_site_url(), $warning, 1.8);
 
  273             $vars[
'url'] = $this->site_url_wrapper;
 
  279         if (isset(
$vars[
'full']) && !isset(
$vars[
'full_view'])) {
 
  283         if (isset(
$vars[
'full_view'])) {
 
  288         if (isset(
$vars[
'internalname']) && !isset(
$vars[
'__ignoreInternalname']) && !isset(
$vars[
'name'])) {
 
  291         } elseif (isset(
$vars[
'name'])) {
 
  292             if (!isset(
$vars[
'internalname'])) {
 
  293                 $vars[
'__ignoreInternalname'] = 
'';
 
  299         if (isset(
$vars[
'internalid']) && !isset(
$vars[
'__ignoreInternalid']) && !isset(
$vars[
'name'])) {
 
  302         } elseif (isset(
$vars[
'id'])) {
 
  303             if (!isset(
$vars[
'internalid'])) {
 
  304                 $vars[
'__ignoreInternalid'] = 
'';
 
  310         if ($bypass == 
false && isset($this->CONFIG->template_handler) && !empty($this->CONFIG->template_handler)) {
 
  311             $template_handler = $this->CONFIG->template_handler;
 
  312             if (is_callable($template_handler)) {
 
  313                 return call_user_func($template_handler, 
$view, 
$vars);
 
  318         if (isset($this->CONFIG->views->extensions[
$view])) {
 
  319             $viewlist = $this->CONFIG->views->extensions[
$view];
 
  321             $viewlist = array(500 => 
$view);
 
  325         foreach ($viewlist as 
$view) {
 
  328             if ($rendering !== 
false) {
 
  336                 $rendering = $this->renderViewFile(
$view, 
$vars, 
'default', $issue_missing_notice);
 
  337                 if ($rendering !== 
false) {
 
  348         $content_tmp = $this->hooks->trigger(
'display', 
'view', 
$params, 
$content);
 
  366         if (!isset($this->file_exists_cache[
$path])) {
 
  367             $this->file_exists_cache[
$path] = file_exists(
$path);
 
  369         return $this->file_exists_cache[
$path];
 
  388         $CONFIG = $this->config_wrapper;
 
  390         if ($this->fileExists(
"{$view_location}$viewtype/$view.php")) {
 
  392             include(
"{$view_location}$viewtype/$view.php");
 
  393             return ob_get_clean();
 
  394         } 
else if ($this->fileExists(
"{$view_location}$viewtype/$view")) {
 
  395             return file_get_contents(
"{$view_location}$viewtype/$view");
 
  397             if ($issue_missing_notice) {
 
  398                 $this->logger->log(
"$viewtype/$view view does not exist.", 
'NOTICE');
 
  419             if (!isset($this->CONFIG->viewpath)) {
 
  420                 $location = dirname(dirname(dirname(__FILE__))) . 
"/views/";
 
  422                 $location = $this->CONFIG->viewpath;
 
  428         if ($this->fileExists(
"{$location}$viewtype/$view.php") ||
 
  429                 $this->fileExists(
"{$location}$viewtype/$view")) {
 
  435         if ($recurse && isset($this->CONFIG->views->extensions[
$view])) {
 
  436             foreach ($this->CONFIG->views->extensions[
$view] as $view_extension) {
 
  438                 if ($this->viewExists($view_extension, 
$viewtype, 
false)) {
 
  446             return $this->viewExists(
$view, 
'default');
 
  459         if (!isset($this->CONFIG->views)) {
 
  460             $this->CONFIG->views = (object) array(
 
  461                 'extensions' => array(),
 
  463             $this->CONFIG->views->extensions[
$view][500] = (string) 
$view;
 
  465             if (!isset($this->CONFIG->views->extensions[
$view])) {
 
  466                 $this->CONFIG->views->extensions[
$view][500] = (string) 
$view;
 
  471         while (isset($this->CONFIG->views->extensions[
$view][
$priority])) {
 
  475         $this->CONFIG->views->extensions[
$view][
$priority] = (string) $view_extension;
 
  476         ksort($this->CONFIG->views->extensions[
$view]);
 
  486         if (!isset($this->CONFIG->views)) {
 
  490         if (!isset($this->CONFIG->views->extensions)) {
 
  494         if (!isset($this->CONFIG->views->extensions[
$view])) {
 
  498         $priority = array_search($view_extension, $this->CONFIG->views->extensions[
$view]);
 
  514         if (!isset($this->CONFIG->views)) {
 
  515             $this->CONFIG->views = new \stdClass;
 
  518         if (!isset($this->CONFIG->views->simplecache)) {
 
  519             $this->CONFIG->views->simplecache = array();
 
  522         $this->CONFIG->views->simplecache[
$view] = 
true;
 
  531         if (!isset($this->CONFIG->views)) {
 
  532             $this->CONFIG->views = new \stdClass;
 
  535         if (!isset($this->CONFIG->views->simplecache)) {
 
  536             $this->CONFIG->views->simplecache = array();
 
  539         if (isset($this->CONFIG->views->simplecache[
$view])) {
 
  543             $viewtypes = array($currentViewtype);
 
  545             if ($this->doesViewtypeFallback($currentViewtype) && $currentViewtype != 
'default') {
 
  546                 $viewtypes[] = 
'defaut';
 
  551                 $view_file = $this->getViewLocation(
$view, 
$viewtype) . 
"$viewtype/$view";
 
  552                 if ($this->fileExists($view_file)) {
 
  572         $view_dir = 
"$path/views/";
 
  575         if (!is_dir($view_dir)) {
 
  580         $handle = opendir($view_dir);
 
  582             $failed_dir = $view_dir;
 
  586         while (
false !== ($view_type = readdir($handle))) {
 
  587             $view_type_dir = $view_dir . $view_type;
 
  589             if (
'.' !== substr($view_type, 0, 1) && is_dir($view_type_dir)) {
 
  590                 if ($this->autoregisterViews(
'', $view_type_dir, $view_dir, $view_type)) {
 
  593                     $failed_dir = $view_type_dir;
 
  610         return $this->overriden_locations;
 
  622         $this->overriden_locations = $locations;
 
$content
Set robots.txt action.
 
getViewLocation($view, $viewtype='')
@access private
 
doesViewtypeFallback($viewtype)
@access private
 
renderDeprecatedView($view, array $vars, $suggestion, $version)
Display a view with a deprecation notice.
 
extendView($view, $view_extension, $priority=501, $viewtype='')
@access private
 
getOverriddenLocations()
Get views overridden by setViewLocation() calls.
 
__construct(\Elgg\PluginHooksService $hooks, \Elgg\Logger $logger)
Constructor.
 
setViewLocation($view, $location, $viewtype='')
@access private
 
renderView($view, array $vars=array(), $bypass=false, $viewtype='', $issue_missing_notice=true)
@access private
 
unextendView($view, $view_extension)
@access private
 
viewExists($view, $viewtype='', $recurse=true)
@access private
 
registerCacheableView($view)
@access private
 
setOverriddenLocations(array $locations)
Set views overridden by setViewLocation() calls.
 
fileExists($path)
Wrapper for file_exists() that caches false results (the stat cache only caches true results).
 
getUserWrapper()
Get the user object in a wrapper.
 
isCacheableView($view)
@access private
 
registerPluginViews($path, &$failed_dir='')
Register a plugin's views.
 
registerViewtypeFallback($viewtype)
@access private
 
autoregisterViews($view_base, $folder, $base_location_path, $viewtype)
@access private
 
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
 
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
 
if(file_exists($welcome)) $vars
 
elgg_get_viewtype()
Return the current view type.
 
elgg_register_viewtype($viewtype)
Register a viewtype.
 
_elgg_is_valid_viewtype($viewtype)
Checks if $viewtype is a string suitable for use as a viewtype name.