ea-Geiercode-base-smarty
[ class tree: ea-Geier ] [ index: ea-Geier ] [ all elements ]

Source for file function.eaPage.php

Documentation is available at function.eaPage.php

  1. <?php
  2. /**
  3.  * smarty function plugin to produce page URLs
  4.  *
  5.  * LICENSE:
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
  13.  * GNU General Public License for more details.
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program; if not, write to the Free Software Foundation, Inc.,
  16.  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17.  *
  18.  * @package       ea-Geier
  19.  * @subpackage code/base/smarty
  20.  * @author       m2mtech <tech@m2m.at>
  21.  * @copyright  2007 m2m server software gmbh
  22.  * @license       http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
  23.  * @version       $Id: function.eaPage.php 103 2007-07-31 19:27:19Z m2mtech $
  24.  * @link       http://www.ea-geier.at/
  25.  */
  26.  
  27. /**
  28.  * prevent multiple inclusion of this file
  29.  */
  30. if (defined('eaSMARTYeaPage')) return true;
  31. define('eaSMARTYeaPage'true);
  32.  
  33. /**
  34.  * Smarty {eaPage} plugin
  35.  *
  36.  * creates page links
  37.  *
  38.  * - {eaURL state=STATE [type=TYPE]}
  39.  * @param    array    function parameters
  40.  *                     - URL    base url
  41.  *                     - LIM    limitter
  42.  *                     - CUR    current page
  43.  *                     - PAGES number of pages
  44.  * @param    Smarty 
  45.  * @return    string 
  46.  */
  47. function smarty_function_eaPage($params&$smarty{
  48.     // escape parameter
  49.     require_once $smarty->_get_plugin_filepath('shared''escape_special_chars');
  50.     
  51.     $vars array('url''lim''cur''pages');
  52.     foreach ($vars as $var
  53.         if (isset($params[$var]))
  54.             $$var smarty_function_escape_special_chars($params[$var]);
  55.         else $$var '';
  56.  
  57.     $url .= $lim 'page';
  58.  
  59.     $cur = (integer) $curif (!$cur$cur 1;
  60.     $pages = (integer) $pagesif (!$pages$pages 1;
  61.     if ($cur $pages$cur $pages;
  62.  
  63.     $start $cur 3if ($start 1)       $start 1;
  64.     $end   $cur 3if ($end $pages)  $end      $pages;
  65.     $prev  $cur 1if ($prev 1)       $prev 1;
  66.     $next  $cur 1if ($next $pages$next  $pages;
  67.     
  68.     $return '';
  69.     
  70.     if ($prev != $cur$return .= '<a href="' $url $prev '">&lt;</a>';
  71.     for ($i $start$i <= $end$i++{
  72.         if ($i == $cur$return .= $i ' ';
  73.         else $return .= '<a href="' $url $i '">' $i '</a> ';
  74.     }
  75.     $return substr($return0-1);
  76.     if ($next != $cur$return .= '<a href="' $url $next '">&gt;</a>';
  77.  
  78.     return $return;
  79. }
  80.  
  81. ?>

Documentation generated on Sun, 09 Sep 2007 17:08:46 +0200 by phpDocumentor 1.3.1