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/";
122 if (!isset(
$CONFIG->views->locations)) {
139 if (!isset(
$CONFIG->viewtype)) {
140 $CONFIG->viewtype =
new stdClass;
143 if (!isset(
$CONFIG->viewtype->fallback)) {
144 $CONFIG->viewtype->fallback = array();
156 if (isset(
$CONFIG->viewtype) && isset(
$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');
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);
283 $viewlist = array(500 =>
$view);
287 foreach ($viewlist as
$view) {
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/";
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) {
419 $CONFIG->views = (object) array(
420 'extensions' => array(),
449 if (!isset(
$CONFIG->views->extensions)) {
477 if (!isset(
$CONFIG->views->simplecache)) {
478 $CONFIG->views->simplecache = array();
494 if (!isset(
$CONFIG->views->simplecache)) {
495 $CONFIG->views->simplecache = array();
502 $viewtypes = array($currentViewtype);
505 $viewtypes[] =
'defaut';
$content
Set robots.txt action.
getUserWrapper()
Get the user object in a wrapper.
extendView($view, $view_extension, $priority=501, $viewtype='')
@access private
renderDeprecatedView($view, array $vars, $suggestion, $version)
Display a view with a deprecation notice.
setViewLocation($view, $location, $viewtype='')
@access private
fileExists($path)
Wrapper for file_exists() that caches false results (the stat cache only caches true results).
renderView($view, array $vars=array(), $bypass=false, $viewtype='', $issue_missing_notice=true)
@access private
autoregisterViews($view_base, $folder, $base_location_path, $viewtype)
@access private
isCacheableView($view)
@access private
doesViewtypeFallback($viewtype)
@access private
registerViewtypeFallback($viewtype)
@access private
getViewLocation($view, $viewtype='')
@access private
registerCacheableView($view)
@access private
viewExists($view, $viewtype='', $recurse=true)
@access private
__construct(Elgg_PluginHooksService $hooks, Elgg_Logger $logger)
Constructor.
unextendView($view, $view_extension)
@access private
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event,...
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_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
if(file_exists($welcome)) $vars
elgg_get_viewtype()
Return the current view type.
_elgg_is_valid_viewtype($viewtype)
Checks if $viewtype is a string suitable for use as a viewtype name.