/** * @see \wcf\system\template\IModifierTemplatePlugin::execute() */ public function execute($tagArgs, TemplateEngine $tplObj) { if (($lang = $tplObj->get('__language')) === null) { $lang = WCF::getLanguage(); } return $lang->getDynamicVariable($tagArgs[0]); }
/** * @see wcf\system\template\IFunctionTemplatePlugin::execute() */ public function execute($tagArgs, TemplateEngine $tplObj) { // needed params: controller, link, page, pages if (!isset($tagArgs['link'])) throw new SystemException("missing 'link' argument in pages tag"); if (!isset($tagArgs['controller'])) throw new SystemException("missing 'controller' argument in pages tag"); if (!isset($tagArgs['pages'])) { if (($tagArgs['pages'] = $tplObj->get('pages')) === null) { throw new SystemException("missing 'pages' argument in pages tag"); } } $html = ''; if ($tagArgs['pages'] > 1) { // create and encode route link $parameters = array(); if (isset($tagArgs['id'])) $parameters['id'] = $tagArgs['id']; if (isset($tagArgs['title'])) $parameters['title'] = $tagArgs['title']; if (isset($tagArgs['object'])) $parameters['object'] = $tagArgs['object']; if (isset($tagArgs['application'])) $parameters['application'] = $tagArgs['application']; $link = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink($tagArgs['controller'], $parameters, $tagArgs['link'])); if (!isset($tagArgs['page'])) { if (($tagArgs['page'] = $tplObj->get('pageNo')) === null) { $tagArgs['page'] = 0; } } // open div and ul $html .= "<nav class=\"pageNavigation\" data-link=\"".$link."\" data-pages=\"".$tagArgs['pages']."\">\n<ul>\n"; // previous page $html .= $this->makePreviousLink($link, $tagArgs['page']); // first page $html .= $this->makeLink($link, 1, $tagArgs['page']); // calculate page links $maxLinks = static::SHOW_LINKS - 4; $linksBeforePage = $tagArgs['page'] - 2; if ($linksBeforePage < 0) $linksBeforePage = 0; $linksAfterPage = $tagArgs['pages'] - ($tagArgs['page'] + 1); if ($linksAfterPage < 0) $linksAfterPage = 0; if ($tagArgs['page'] > 1 && $tagArgs['page'] < $tagArgs['pages']) { $maxLinks--; } $half = $maxLinks / 2; $left = $right = $tagArgs['page']; if ($left < 1) $left = 1; if ($right < 1) $right = 1; if ($right > $tagArgs['pages'] - 1) $right = $tagArgs['pages'] - 1; if ($linksBeforePage >= $half) { $left -= $half; } else { $left -= $linksBeforePage; $right += $half - $linksBeforePage; } if ($linksAfterPage >= $half) { $right += $half; } else { $right += $linksAfterPage; $left -= $half - $linksAfterPage; } $right = intval(ceil($right)); $left = intval(ceil($left)); if ($left < 1) $left = 1; if ($right > $tagArgs['pages']) $right = $tagArgs['pages']; // left ... links if ($left > 1) { if ($left - 1 < 2) { $html .= $this->makeLink($link, 2, $tagArgs['page']); } else { $html .= '<li class="button jumpTo"><a title="'.WCF::getLanguage()->getDynamicVariable('wcf.global.page.jumpTo').'" class="jsTooltip">'.StringUtil::HELLIP.'</a></li>'."\n"; } } // visible links for ($i = $left + 1; $i < $right; $i++) { $html .= $this->makeLink($link, $i, $tagArgs['page']); } // right ... links if ($right < $tagArgs['pages']) { if ($tagArgs['pages'] - $right < 2) { $html .= $this->makeLink($link, $tagArgs['pages'] - 1, $tagArgs['page']); } else { $html .= '<li class="button jumpTo"><a title="'.WCF::getLanguage()->getDynamicVariable('wcf.global.page.jumpTo').'" class="jsTooltip">'.StringUtil::HELLIP.'</a></li>'."\n"; } } // last page $html .= $this->makeLink($link, $tagArgs['pages'], $tagArgs['page']); // next page $html .= $this->makeNextLink($link, $tagArgs['page'], $tagArgs['pages']); // close div and ul $html .= "</ul></nav>\n"; } // assign html output to template var if (isset($tagArgs['assign'])) { $tplObj->assign($tagArgs['assign'], $html); if (!isset($tagArgs['print']) || !$tagArgs['print']) return ''; } return $html; }