/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$intActive = null;
$articles = array();
$intCount = 1;
while ($this->objArticles->next()) {
/** @var ArticleModel $objArticle */
$objArticle = $this->objArticles->current();
$strAlias = $objArticle->alias ?: $objArticle->id;
// Active article
if (\Input::get('articles') == $strAlias) {
$articles[] = array('isActive' => true, 'href' => $this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias), 'title' => specialchars($objArticle->title, true), 'link' => $intCount);
$intActive = $intCount - 1;
} else {
$articles[] = array('isActive' => false, 'href' => $this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias), 'title' => specialchars($objArticle->title, true), 'link' => $intCount);
}
++$intCount;
}
$this->Template->articles = $articles;
$total = count($articles);
// Link to first element
if ($intActive > 1) {
$this->Template->first = array('href' => $articles[0]['href'], 'title' => $articles[0]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['first']);
}
$key = $intActive - 1;
// Link to previous element
if ($intCount > 1 && $key >= 0) {
$this->Template->previous = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['previous']);
}
$key = $intActive + 1;
// Link to next element
if ($intCount > 1 && $key < $total) {
$this->Template->next = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['next']);
}
$key = $total - 1;
// Link to last element
if ($intCount > 1 && $intActive < $key - 1) {
$this->Template->last = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['last']);
}
}