当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty_Internal_Template::getChunkPath方法代码示例

本文整理汇总了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));
    }
}
开发者ID:Welvin,项目名称:stingle,代码行数:97,代码来源:function.draw_pager.php


注:本文中的Smarty_Internal_Template::getChunkPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。