37 $this->hooks = $hooks;
38 $this->logger = $logger;
49 if (
$user !== $this->user_wrapped) {
50 $warning =
'Use elgg_get_logged_in_user_entity() rather than assuming elgg_view() ' 51 .
'populates $vars["user"]';
63 $handle = opendir($folder);
65 while (
$view = readdir($handle)) {
66 if (!empty($view_base)) {
67 $view_base_new = $view_base .
"/";
72 if (substr(
$view, 0, 1) !==
'.') {
73 if (is_dir($folder .
"/" .
$view)) {
98 if (!isset($CONFIG->viewpath)) {
99 return dirname(dirname(dirname(__FILE__))) .
"/views/";
101 return $CONFIG->viewpath;
118 if (!isset($CONFIG->views)) {
119 $CONFIG->views =
new stdClass;
122 if (!isset($CONFIG->views->locations)) {
123 $CONFIG->views->locations = array(
$viewtype => array(
$view => $location));
125 }
else if (!isset($CONFIG->views->locations[
$viewtype])) {
139 if (!isset($CONFIG->viewtype)) {
140 $CONFIG->viewtype =
new stdClass;
143 if (!isset($CONFIG->viewtype->fallback)) {
144 $CONFIG->viewtype->fallback = array();
147 $CONFIG->viewtype->fallback[] =
$viewtype;
156 if (isset($CONFIG->viewtype) && isset($CONFIG->viewtype->fallback)) {
157 return in_array(
$viewtype, $CONFIG->viewtype->fallback);
191 $this->logger->log(
"View and Viewtype in views must be a strings: $view",
'NOTICE');
195 if (strpos(
$view,
'..') !==
false) {
199 if (!is_array(
$vars)) {
200 $this->logger->log(
"Vars in views must be an array: $view",
'ERROR');
212 if (!isset($CONFIG->pagesetupdone) && $CONFIG->boot_complete) {
213 $CONFIG->pagesetupdone =
true;
220 if (!isset(
$vars[
'user'])) {
223 if (!isset(
$vars[
'config'])) {
224 if (!$this->config_wrapper) {
225 $warning =
'Do not rely on $vars["config"] or $CONFIG being available in views';
230 if (!isset(
$vars[
'url'])) {
231 if (!$this->site_url_wrapper) {
232 $warning =
'Do not rely on $vars["url"] being available in views';
241 if (isset(
$vars[
'full']) && !isset(
$vars[
'full_view'])) {
245 if (isset(
$vars[
'full_view'])) {
250 if (isset(
$vars[
'internalname']) && !isset(
$vars[
'__ignoreInternalname']) && !isset(
$vars[
'name'])) {
253 } elseif (isset(
$vars[
'name'])) {
254 if (!isset(
$vars[
'internalname'])) {
255 $vars[
'__ignoreInternalname'] =
'';
261 if (isset(
$vars[
'internalid']) && !isset(
$vars[
'__ignoreInternalid']) && !isset(
$vars[
'name'])) {
264 } elseif (isset(
$vars[
'id'])) {
265 if (!isset(
$vars[
'internalid'])) {
266 $vars[
'__ignoreInternalid'] =
'';
272 if ($bypass ==
false && isset($CONFIG->template_handler) && !empty($CONFIG->template_handler)) {
273 $template_handler = $CONFIG->template_handler;
274 if (is_callable($template_handler)) {
275 return call_user_func($template_handler,
$view,
$vars);
280 if (isset($CONFIG->views->extensions[
$view])) {
281 $viewlist = $CONFIG->views->extensions[
$view];
283 $viewlist = array(500 =>
$view);
287 foreach ($viewlist as
$view) {
289 $rendering = $this->renderViewFile($view,
$vars,
$viewtype, $issue_missing_notice);
290 if ($rendering !==
false) {
298 $rendering = $this->renderViewFile($view,
$vars,
'default', $issue_missing_notice);
299 if ($rendering !==
false) {
328 if (!isset($this->file_exists_cache[
$path])) {
329 $this->file_exists_cache[
$path] = file_exists($path);
331 return $this->file_exists_cache[
$path];
352 if ($this->
fileExists(
"{$view_location}$viewtype/$view.php")) {
354 include(
"{$view_location}$viewtype/$view.php");
355 return ob_get_clean();
356 }
else if ($this->
fileExists(
"{$view_location}$viewtype/$view")) {
357 return file_get_contents(
"{$view_location}$viewtype/$view");
359 if ($issue_missing_notice) {
360 $this->logger->log(
"$viewtype/$view view does not exist.",
'NOTICE');
378 if (!isset($CONFIG->viewpath)) {
379 $location = dirname(dirname(dirname(__FILE__))) .
"/views/";
381 $location = $CONFIG->viewpath;
387 if ($this->
fileExists(
"{$location}$viewtype/$view.php") ||
388 $this->
fileExists(
"{$location}$viewtype/$view")) {
394 if ($recurse && isset($CONFIG->views->extensions[$view])) {
395 foreach ($CONFIG->views->extensions[$view] as $view_extension) {
418 if (!isset($CONFIG->views)) {
419 $CONFIG->views = (object) array(
420 'extensions' => array(),
422 $CONFIG->views->extensions[
$view][500] = (string)
$view;
424 if (!isset($CONFIG->views->extensions[
$view])) {
425 $CONFIG->views->extensions[
$view][500] = (string)
$view;
434 $CONFIG->views->extensions[
$view][
$priority] = (string) $view_extension;
435 ksort($CONFIG->views->extensions[
$view]);
445 if (!isset($CONFIG->views)) {
449 if (!isset($CONFIG->views->extensions)) {
453 if (!isset($CONFIG->views->extensions[
$view])) {
457 $priority = array_search($view_extension, $CONFIG->views->extensions[
$view]);
473 if (!isset($CONFIG->views)) {
474 $CONFIG->views =
new stdClass;
477 if (!isset($CONFIG->views->simplecache)) {
478 $CONFIG->views->simplecache = array();
481 $CONFIG->views->simplecache[
$view] =
true;
490 if (!isset($CONFIG->views)) {
491 $CONFIG->views =
new stdClass;
494 if (!isset($CONFIG->views->simplecache)) {
495 $CONFIG->views->simplecache = array();
498 if (isset($CONFIG->views->simplecache[
$view])) {
502 $viewtypes = array($currentViewtype);
505 $viewtypes[] =
'defaut';
_elgg_is_valid_viewtype($viewtype)
Checks if $viewtype is a string suitable for use as a viewtype name.
extendView($view, $view_extension, $priority=501, $viewtype= '')
private
autoregisterViews($view_base, $folder, $base_location_path, $viewtype)
private
setViewLocation($view, $location, $viewtype= '')
private
viewExists($view, $viewtype= '', $recurse=true)
private
isCacheableView($view)
private
renderView($view, array $vars=array(), $bypass=false, $viewtype= '', $issue_missing_notice=true)
private
__construct(Elgg_PluginHooksService $hooks, Elgg_Logger $logger)
Constructor.
elgg_get_viewtype()
Return the current view type.
registerCacheableView($view)
private
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
getUserWrapper()
Get the user object in a wrapper.
getViewLocation($view, $viewtype= '')
private
doesViewtypeFallback($viewtype)
private
renderDeprecatedView($view, array $vars, $suggestion, $version)
Display a view with a deprecation notice.
unextendView($view, $view_extension)
private
$content
Set robots.txt action.
registerViewtypeFallback($viewtype)
private
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
fileExists($path)
Wrapper for file_exists() that caches false results (the stat cache only caches true results)...
if(file_exists($welcome)) $vars