Source for file function.eaPage.php
Documentation is available at function.eaPage.php
* smarty function plugin to produce page URLs
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @subpackage code/base/smarty
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: function.eaPage.php 103 2007-07-31 19:27:19Z m2mtech $
* @link http://www.ea-geier.at/
* prevent multiple inclusion of this file
if (defined('eaSMARTYeaPage')) return true;
define('eaSMARTYeaPage', true);
* - {eaURL state=STATE [type=TYPE]}
* @param array function parameters
* - PAGES number of pages
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
$vars = array('url', 'lim', 'cur', 'pages');
if (isset ($params[$var]))
$ $var = smarty_function_escape_special_chars($params[$var]);
$cur = (integer) $cur; if (!$cur) $cur = 1;
$pages = (integer) $pages; if (!$pages) $pages = 1;
if ($cur > $pages) $cur = $pages;
$start = $cur - 3; if ($start < 1) $start = 1;
$end = $cur + 3; if ($end > $pages) $end = $pages;
$prev = $cur - 1; if ($prev < 1) $prev = 1;
$next = $cur + 1; if ($next > $pages) $next = $pages;
if ($prev != $cur) $return .= '<a href="' . $url . $prev . '"><</a>';
for ($i = $start; $i <= $end; $i++ ) {
if ($i == $cur) $return .= $i . ' ';
else $return .= '<a href="' . $url . $i . '">' . $i . '</a> ';
$return = substr($return, 0, - 1);
if ($next != $cur) $return .= '<a href="' . $url . $next . '">></a>';
|