PKPTemplateManager::smartyPageLinks PHP Method

    function smartyPageLinks($params, $smarty)
    {
        $iterator = $params['iterator'];
        $name = $params['name'];
        if (isset($params['params']) && is_array($params['params'])) {
            $extraParams = $params['params'];
            unset($params['params']);
            $params = array_merge($params, $extraParams);
        }
        if (isset($params['anchor'])) {
            $anchor = $params['anchor'];
            unset($params['anchor']);
        } else {
            $anchor = null;
        }
        if (isset($params['all_extra'])) {
            $allExtra = ' ' . $params['all_extra'];
            unset($params['all_extra']);
        } else {
            $allExtra = '';
        }
        unset($params['iterator']);
        unset($params['name']);
        $numPageLinks = $smarty->get_template_vars('numPageLinks');
        if (!is_numeric($numPageLinks)) {
            $numPageLinks = 10;
        }
        $page = $iterator->getPage();
        $pageCount = $iterator->getPageCount();
        $pageBase = max($page - floor($numPageLinks / 2), 1);
        $paramName = $name . 'Page';
        if ($pageCount <= 1) {
            return '';
        }
        $value = '';
        $router = $this->_request->getRouter();
        $requestedArgs = null;
        if (is_a($router, 'PageRouter')) {
            $requestedArgs = $router->getRequestedArgs($this->_request);
        }
        if ($page > 1) {
            $params[$paramName] = 1;
            $value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>&lt;&lt;</a>&nbsp;';
            $params[$paramName] = $page - 1;
            $value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>&lt;</a>&nbsp;';
        }
        for ($i = $pageBase; $i < min($pageBase + $numPageLinks, $pageCount + 1); $i++) {
            if ($i == $page) {
                $value .= "<strong>{$i}</strong>&nbsp;";
            } else {
                $params[$paramName] = $i;
                $value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>' . $i . '</a>&nbsp;';
            }
        }
        if ($page < $pageCount) {
            $params[$paramName] = $page + 1;
            $value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>&gt;</a>&nbsp;';
            $params[$paramName] = $pageCount;
            $value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>&gt;&gt;</a>&nbsp;';
        }
        return $value;
    }