本文整理匯總了PHP中Smarty_Internal_Template::getChunkPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smarty_Internal_Template::getChunkPath方法的具體用法?PHP Smarty_Internal_Template::getChunkPath怎麽用?PHP Smarty_Internal_Template::getChunkPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::getChunkPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: smarty_function_draw_pager
/**
* Draw Pager
*
* @param $id
* @param $visualPagesCount
* @param $exclude
* @param $additionalParams
* @param $linkClass
* @return string
*/
function smarty_function_draw_pager($params, Smarty_Internal_Template &$smarty)
{
$id = null;
$visualPagesCount = null;
$excludedGetsArray = array();
extract($params);
if (empty($visualPagesCount)) {
$visualPagesCount = ConfigManager::getConfig("Pager", "Pager")->AuxConfig->defaultVisualPagesCount;
}
if (empty($id)) {
$id = null;
}
if (isset($exclude) and !empty($exclude)) {
$excludedGetsArray = explode(",", str_replace(" ", "", $exclude));
}
$pager = Pager::getPager($id);
if ($pager instanceof Pager) {
if (isset($baseLink) and !empty($baseLink)) {
// Remove heading slash if present
$link = ltrim($baseLink, "/");
$link = Reg::get(ConfigManager::getConfig("RewriteURL")->Objects->rewriteURL)->glink($link);
} else {
$link = getCurrentUrl(array_merge(array($pager->getUrlParam()), $excludedGetsArray));
}
if (isset($additionalParams) and !empty($additionalParams)) {
RewriteURL::ensureLastSlash($additionalParams);
$urlParam = $additionalParams . $pager->getUrlParam();
} else {
$urlParam = $pager->getUrlParam();
}
$currentPageNumber = $pager->getCurrentPageNumber();
$pagesCount = $pager->getTotalPagesCount();
if ($pagesCount > 1) {
$pageNumStart = $currentPageNumber - floor($visualPagesCount / 2);
if ($pageNumStart < 1) {
$pageNumStart = 1;
}
$pageNumEnd = $pageNumStart + $visualPagesCount - 1;
if ($pageNumEnd > $pagesCount) {
$pageNumEnd = $pagesCount;
$pageNumStart = $pageNumEnd - $visualPagesCount + 1;
if ($pageNumStart < 1) {
$pageNumStart = 1;
}
}
if ($pageNumStart > 1) {
$pagerFirstPageLink = $link . $urlParam . ':1';
$smarty->assign('pagerFirstPageLink', $pagerFirstPageLink);
}
if ($pageNumEnd < $pagesCount) {
$pagerLastPageLink = $link . $urlParam . ':' . $pagesCount;
$smarty->assign('pagerLastPageLink', $pagerLastPageLink);
}
if ($currentPageNumber > 1) {
$prevPageLink = $link . $urlParam . ':' . ($currentPageNumber - 1);
$smarty->assign('pagerPreviousPageLink', $prevPageLink);
}
$pagerNumbersArray = array();
for ($pgNum = $pageNumStart; $pgNum <= $pageNumEnd; $pgNum++) {
$isCurrent = false;
if ($pgNum == $currentPageNumber) {
$isCurrent = true;
}
$pageLink = $link . $urlParam . ':' . $pgNum;
array_push($pagerNumbersArray, array("pageNum" => $pgNum, "pageLink" => $pageLink, "isCurrent" => $isCurrent));
}
if ($currentPageNumber < $pagesCount) {
$nextPageLink = $link . $urlParam . ':' . ($currentPageNumber + 1);
$smarty->assign('pagerNextPageLink', $nextPageLink);
}
if (isset($linkClass) and !empty($linkClass)) {
$smarty->assign("linkClass", $linkClass);
}
$smarty->assign("pagerPageNumStart", $pageNumStart);
$smarty->assign("pagerPageNumEnd", $pageNumEnd);
$smarty->assign("pagerCurrentPageNumber", $currentPageNumber);
$smarty->assign("pagerTotalPagesCount", $pagesCount);
$smarty->assign("pagerNumbersArray", $pagerNumbersArray);
}
if (isset($tplChunkFile)) {
$pagerChunkFileName = $tplChunkFile;
} else {
$pagerChunkFileName = ConfigManager::getConfig("Pager", "Pager")->AuxConfig->pagerChunkFileName;
}
return $smarty->fetch($smarty->getChunkPath($pagerChunkFileName));
}
}