/**
* Generate the module
*/
protected function compile()
{
// Get all active pages
$objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages);
// Return if there are no pages
if ($objPages === null) {
return;
}
$arrPages = array();
// Sort the array keys according to the given order
if ($this->orderPages != '') {
$tmp = deserialize($this->orderPages);
if (!empty($tmp) && is_array($tmp)) {
$arrPages = array_map(function () {
}, array_flip($tmp));
}
}
// Add the items to the pre-sorted array
while ($objPages->next()) {
/** @var PageModel $objModel */
$objModel = $objPages->current();
$arrPages[$objPages->id] = $objModel->loadDetails()->row();
// see #3765
}
$items = array();
foreach ($arrPages as $arrPage) {
$arrPage['title'] = strip_insert_tags($arrPage['title']);
$arrPage['pageTitle'] = strip_insert_tags($arrPage['pageTitle']);
// Get href
switch ($arrPage['type']) {
case 'redirect':
$href = $arrPage['url'];
break;
case 'forward':
if (($objNext = \PageModel::findPublishedById($arrPage['jumpTo'])) !== null) {
$strForceLang = null;
$objNext->loadDetails();
// Check the target page language (see #4706)
if (\Config::get('addLanguageToUrl')) {
$strForceLang = $objNext->language;
}
$href = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true);
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
$href = $this->generateFrontendUrl($arrPage, null, $arrPage['rootLanguage'], true);
break;
}
$items[] = array('href' => $href, 'title' => specialchars($arrPage['pageTitle'] ?: $arrPage['title']), 'link' => $arrPage['title']);
}
$this->Template->items = $items;
$this->Template->formId = 'tl_quicklink_' . $this->id;
$this->Template->request = ampersand(\Environment::get('request'), true);
$this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink'];
$this->Template->button = specialchars($GLOBALS['TL_LANG']['MSC']['go']);
}