Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Re-add the $blnFixDomain argument to keep backwards compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Mar 1, 2016
1 parent 20d5335 commit 3589218
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 99 deletions.
7 changes: 7 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Contao Open Source CMS changelog
================================

Version 3.5.8 (2016-02-29)
--------------------------

### Fixed
Re-add the `$blnFixDomain` argument to keep backwards compatibility.


Version 3.5.7 (2016-02-29)
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion system/modules/core/classes/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ protected function jumpToOrReload($intId, $strParams=null, $strForceLang=null)
{
if ($intId['id'] != $objPage->id || $blnForceRedirect)
{
$this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang));
$this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang, true));
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions system/modules/core/library/Contao/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,10 +1075,11 @@ public static function redirect($strLocation, $intStatus=303)
* @param array $arrRow An array of page parameters
* @param string $strParams An optional string of URL parameters
* @param string $strForceLang Force a certain language
* @param boolean $blnFixDomain Check the domain of the target page and append it if necessary
*
* @return string An URL that can be used in the front end
*/
public static function generateFrontendUrl(array $arrRow, $strParams=null, $strForceLang=null)
public static function generateFrontendUrl(array $arrRow, $strParams=null, $strForceLang=null, $blnFixDomain=false)
{
$strUrl = '';

Expand All @@ -1087,6 +1088,11 @@ public static function generateFrontendUrl(array $arrRow, $strParams=null, $strF
@trigger_error('Using Controller::generateFrontendUrl() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
}

if ($blnFixDomain !== true)
{
@trigger_error('Using Controller::generateFrontendUrl() without $blnFixDomain has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
}

if (!isset($arrRow['rootId']))
{
$row = \PageModel::findWithDetails($arrRow['id']);
Expand Down Expand Up @@ -1160,7 +1166,7 @@ public static function generateFrontendUrl(array $arrRow, $strParams=null, $strF
}

// Add the domain if it differs from the current one (see #3765 and #6927)
if (!empty($arrRow['domain']) && $arrRow['domain'] != \Environment::get('host'))
if ($blnFixDomain && !empty($arrRow['domain']) && $arrRow['domain'] != \Environment::get('host'))
{
$strUrl = ($arrRow['rootUseSSL'] ? 'https://' : 'http://') . $arrRow['domain'] . TL_PATH . '/' . $strUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion system/modules/core/models/PageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,6 @@ public function getFrontendUrl($strParams=null, $strForceLang=null)
@trigger_error('Using PageModel::getFrontendUrl() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
}

return \Controller::generateFrontendUrl($this->loadDetails()->row(), $strParams, $strForceLang);
return \Controller::generateFrontendUrl($this->loadDetails()->row(), $strParams, $strForceLang, true);
}
}
54 changes: 28 additions & 26 deletions system/modules/core/modules/ModuleBooknav.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ModuleBooknav extends \Module

/**
* Pages array
* @var array
* @var \PageModel[]
*/
protected $arrPages = array();

Expand Down Expand Up @@ -86,7 +86,7 @@ protected function compile()
}

// Get all book pages
$this->arrPages[$objTarget->id] = $objTarget->row();
$this->arrPages[$objTarget->id] = $objTarget;
$this->getBookPages($objTarget->id, $groups, time());

/** @var \PageModel $objPage */
Expand All @@ -98,18 +98,18 @@ protected function compile()
$intKey = $objPage->pid;

// Skip forward pages (see #5074)
while ($this->arrPages[$intKey]['type'] == 'forward' && isset($this->arrPages[$intKey]['pid']))
while ($this->arrPages[$intKey]->type == 'forward' && isset($this->arrPages[$intKey]->pid))
{
$intKey = $this->arrPages[$intKey]['pid'];
$intKey = $this->arrPages[$intKey]->pid;
}

// Hide the link if the reference page is a forward page (see #5374)
if (isset($this->arrPages[$intKey]))
{
$this->Template->hasUp = true;
$this->Template->upHref = $this->generateFrontendUrl($this->arrPages[$intKey]);
$this->Template->upTitle = specialchars($this->arrPages[$intKey]['title'], true);
$this->Template->upPageTitle = specialchars($this->arrPages[$intKey]['pageTitle'], true);
$this->Template->upHref = $this->arrPages[$intKey]->getFrontendUrl();
$this->Template->upTitle = specialchars($this->arrPages[$intKey]->title, true);
$this->Template->upPageTitle = specialchars($this->arrPages[$intKey]->pageTitle, true);
$this->Template->upLink = $GLOBALS['TL_LANG']['MSC']['up'];
}
}
Expand All @@ -127,10 +127,10 @@ protected function compile()
$intKey = $arrLookup[($intCurrent - 1)];

$this->Template->hasPrev = true;
$this->Template->prevHref = $this->generateFrontendUrl($this->arrPages[$intKey]);
$this->Template->prevTitle = specialchars($this->arrPages[$intKey]['title'], true);
$this->Template->prevPageTitle = specialchars($this->arrPages[$intKey]['pageTitle'], true);
$this->Template->prevLink = $this->arrPages[$intKey]['title'];
$this->Template->prevHref = $this->arrPages[$intKey]->getFrontendUrl();
$this->Template->prevTitle = specialchars($this->arrPages[$intKey]->title, true);
$this->Template->prevPageTitle = specialchars($this->arrPages[$intKey]->pageTitle, true);
$this->Template->prevLink = $this->arrPages[$intKey]->title;
}

// Next page
Expand All @@ -139,10 +139,10 @@ protected function compile()
$intKey = $arrLookup[($intCurrent + 1)];

$this->Template->hasNext = true;
$this->Template->nextHref = $this->generateFrontendUrl($this->arrPages[$intKey]);
$this->Template->nextTitle = specialchars($this->arrPages[$intKey]['title'], true);
$this->Template->nextPageTitle = specialchars($this->arrPages[$intKey]['pageTitle'], true);
$this->Template->nextLink = $this->arrPages[$intKey]['title'];
$this->Template->nextHref = $this->arrPages[$intKey]->getFrontendUrl();
$this->Template->nextTitle = specialchars($this->arrPages[$intKey]->title, true);
$this->Template->nextPageTitle = specialchars($this->arrPages[$intKey]->pageTitle, true);
$this->Template->nextLink = $this->arrPages[$intKey]->title;
}
}

Expand All @@ -158,21 +158,23 @@ protected function getBookPages($intParentId, $groups, $time)
{
$objPages = \PageModel::findPublishedSubpagesWithoutGuestsByPid($intParentId, $this->showHidden);

if ($objPages !== null)
if ($objPages === null)
{
while ($objPages->next())
return;
}

foreach ($objPages as $objPage)
{
$_groups = deserialize($objPage->groups);

// Do not show protected pages unless a back end or front end user is logged in
if (!$objPage->protected || BE_USER_LOGGED_IN || (is_array($_groups) && count(array_intersect($groups, $_groups))) || $this->showProtected)
{
$_groups = deserialize($objPages->groups);
$this->arrPages[$objPage->id] = $objPage;

// Do not show protected pages unless a back end or front end user is logged in
if (!$objPages->protected || BE_USER_LOGGED_IN || (is_array($_groups) && count(array_intersect($groups, $_groups))) || $this->showProtected)
if ($objPage->subpages > 0)
{
$this->arrPages[$objPages->id] = $objPages->row();

if ($objPages->subpages > 0)
{
$this->getBookPages($objPages->id, $groups, $time);
}
$this->getBookPages($objPage->id, $groups, $time);
}
}
}
Expand Down
41 changes: 21 additions & 20 deletions system/modules/core/modules/ModuleBreadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function compile()

$type = null;
$pageId = $objPage->id;
$pages = array($objPage->row());
$pages = array($objPage);
$items = array();

// Get all pages up to the root page
Expand All @@ -73,7 +73,7 @@ protected function compile()
{
$type = $objPages->type;
$pageId = $objPages->pid;
$pages[] = $objPages->row();
$pages[] = $objPages->current();
}
}

Expand All @@ -96,19 +96,19 @@ protected function compile()
array_pop($pages);
}

// Build the breadcrumb menu
/** @var \PageModel[] $pages */
for ($i=(count($pages)-1); $i>0; $i--)
{
if (($pages[$i]['hide'] && !$this->showHidden) || (!$pages[$i]['published'] && !BE_USER_LOGGED_IN))
if (($pages[$i]->hide && !$this->showHidden) || (!$pages[$i]->published && !BE_USER_LOGGED_IN))
{
continue;
}

// Get href
switch ($pages[$i]['type'])
switch ($pages[$i]->type)
{
case 'redirect':
$href = $pages[$i]['url'];
$href = $pages[$i]->url;

if (strncasecmp($href, 'mailto:', 7) === 0)
{
Expand All @@ -117,15 +117,16 @@ protected function compile()
break;

case 'forward':
if (($objNext = \PageModel::findPublishedById($pages[$i]['jumpTo'])) !== null)
if (($objNext = $pages[$i]->getRelated('jumpTo')) !== null)
{
/** @var \PageModel $objNext $href */
$href = $objNext->getFrontendUrl();
break;
}
// DO NOT ADD A break; STATEMENT

default:
$href = $this->generateFrontendUrl($pages[$i]);
$href = $pages[$i]->getFrontendUrl();
break;
}

Expand All @@ -134,9 +135,9 @@ protected function compile()
'isRoot' => false,
'isActive' => false,
'href' => $href,
'title' => specialchars($pages[$i]['pageTitle'] ?: $pages[$i]['title'], true),
'link' => $pages[$i]['title'],
'data' => $pages[$i],
'title' => specialchars($pages[$i]->pageTitle ?: $pages[$i]->title, true),
'link' => $pages[$i]->title,
'data' => $pages[$i]->row(),
'class' => ''
);
}
Expand All @@ -148,10 +149,10 @@ protected function compile()
(
'isRoot' => false,
'isActive' => false,
'href' => $this->generateFrontendUrl($pages[0]),
'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title'], true),
'link' => $pages[0]['title'],
'data' => $pages[0],
'href' => $pages[0]->getFrontendUrl(),
'title' => specialchars($pages[0]->pageTitle ?: $pages[0]->title, true),
'link' => $pages[0]->title,
'data' => $pages[0]->row(),
'class' => ''
);

Expand All @@ -176,7 +177,7 @@ protected function compile()
(
'isRoot' => false,
'isActive' => true,
'href' => $this->generateFrontendUrl($pages[0], '/articles/' . $strAlias),
'href' => $pages[0]->getFrontendUrl('/articles/' . $strAlias),
'title' => specialchars($objArticle->title, true),
'link' => $objArticle->title,
'data' => $objArticle->row(),
Expand All @@ -192,10 +193,10 @@ protected function compile()
(
'isRoot' => false,
'isActive' => true,
'href' => $this->generateFrontendUrl($pages[0]),
'title' => specialchars($pages[0]['pageTitle'] ?: $pages[0]['title']),
'link' => $pages[0]['title'],
'data' => $pages[0],
'href' => $pages[0]->getFrontendUrl(),
'title' => specialchars($pages[0]->pageTitle ?: $pages[0]->title),
'link' => $pages[0]->title,
'data' => $pages[0]->row(),
'class' => ''
);
}
Expand Down

0 comments on commit 3589218

Please sign in to comment.