public function loadDetails()
{
// Loaded already
if ($this->blnDetailsLoaded) {
return $this;
}
// Set some default values
$this->protected = (bool) $this->protected;
$this->groups = $this->protected ? \StringUtil::deserialize($this->groups) : false;
$this->layout = $this->includeLayout ? $this->layout : false;
$this->mobileLayout = $this->includeLayout ? $this->mobileLayout : false;
$this->cache = $this->includeCache ? $this->cache : false;
$this->clientCache = $this->includeCache ? $this->clientCache : false;
$pid = $this->pid;
$type = $this->type;
$alias = $this->alias;
$name = $this->title;
$title = $this->pageTitle ?: $this->title;
$folderUrl = '';
$palias = '';
$pname = '';
$ptitle = '';
$trail = array($this->id, $pid);
// Inherit the settings
if ($this->type == 'root') {
$objParentPage = $this;
// see #4610
} else {
// Load all parent pages
$objParentPage = \PageModel::findParentsById($pid);
if ($objParentPage !== null) {
while ($pid > 0 && $type != 'root' && $objParentPage->next()) {
$pid = $objParentPage->pid;
$type = $objParentPage->type;
// Parent title
if ($ptitle == '') {
$palias = $objParentPage->alias;
$pname = $objParentPage->title;
$ptitle = $objParentPage->pageTitle ?: $objParentPage->title;
}
// Page title
if ($type != 'root') {
$alias = $objParentPage->alias;
$name = $objParentPage->title;
$title = $objParentPage->pageTitle ?: $objParentPage->title;
$folderUrl = basename($alias) . '/' . $folderUrl;
$trail[] = $objParentPage->pid;
}
// Cache
if ($objParentPage->includeCache) {
$this->cache = $this->cache ?: $objParentPage->cache;
$this->clientCache = $this->clientCache ?: $objParentPage->clientCache;
}
// Layout
if ($objParentPage->includeLayout) {
if ($this->layout === false) {
$this->layout = $objParentPage->layout;
}
if ($this->mobileLayout === false) {
$this->mobileLayout = $objParentPage->mobileLayout;
}
}
// Protection
if ($objParentPage->protected && $this->protected === false) {
$this->protected = true;
$this->groups = \StringUtil::deserialize($objParentPage->groups);
}
}
}
// Set the titles
$this->mainAlias = $alias;
$this->mainTitle = $name;
$this->mainPageTitle = $title;
$this->parentAlias = $palias;
$this->parentTitle = $pname;
$this->parentPageTitle = $ptitle;
$this->folderUrl = $folderUrl;
}
// Set the root ID and title
if ($objParentPage !== null && $objParentPage->type == 'root') {
$this->rootId = $objParentPage->id;
$this->rootAlias = $objParentPage->alias;
$this->rootTitle = $objParentPage->title;
$this->rootPageTitle = $objParentPage->pageTitle ?: $objParentPage->title;
$this->domain = $objParentPage->dns;
$this->rootLanguage = $objParentPage->language;
$this->language = $objParentPage->language;
$this->staticFiles = $objParentPage->staticFiles;
$this->staticPlugins = $objParentPage->staticPlugins;
$this->dateFormat = $objParentPage->dateFormat;
$this->timeFormat = $objParentPage->timeFormat;
$this->datimFormat = $objParentPage->datimFormat;
$this->adminEmail = $objParentPage->adminEmail;
// Store whether the root page has been published
$time = \Date::floorToMinute();
$this->rootIsPublic = $objParentPage->published && ($objParentPage->start == '' || $objParentPage->start <= $time) && ($objParentPage->stop == '' || $objParentPage->stop > $time + 60);
$this->rootIsFallback = true;
$this->rootUseSSL = $objParentPage->useSSL;
$this->rootFallbackLanguage = $objParentPage->language;
// Store the fallback language (see #6874)
if (!$objParentPage->fallback) {
$this->rootIsFallback = false;
$this->rootFallbackLanguage = null;
$objFallback = static::findPublishedFallbackByHostname($objParentPage->dns);
if ($objFallback !== null) {
$this->rootFallbackLanguage = $objFallback->language;
}
}
} elseif (TL_MODE == 'FE' && $this->type != 'root') {
\System::log('Page ID "' . $this->id . '" does not belong to a root page', __METHOD__, TL_ERROR);
throw new NoRootPageFoundException('No root page found');
}
$this->trail = array_reverse($trail);
// Use the global date format if none is set (see #6104)
if ($this->dateFormat == '') {
$this->dateFormat = \Config::get('dateFormat');
}
if ($this->timeFormat == '') {
$this->timeFormat = \Config::get('timeFormat');
}
if ($this->datimFormat == '') {
$this->datimFormat = \Config::get('datimFormat');
}
// Prevent saving (see #6506 and #7199)
$this->preventSaving();
$this->blnDetailsLoaded = true;
return $this;
}