[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_handlers/ -> np_class.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_handlers/np_class.php,v $
  14  |     $Revision: 1.8 $
  15  |     $Date: 2006/10/07 00:19:31 $
  16  |     $Author: mcfly_e107 $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  if (!defined('e107_INIT')) { exit; }
  21  
  22  @include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_np.php");
  23  @include_once(e_LANGUAGEDIR."English/lan_np.php");
  24  
  25  /**
  26   * Next / Previous handling class
  27   *
  28   */
  29  class nextprev {
  30      
  31      /**
  32       * Generate next / previous pages and appropriate links (
  33       *
  34       * @param string $url, refer url
  35       * @param int $from, start figure
  36       * @param int $view, items per page
  37       * @param int $total, total items
  38       * @param string $td, comfort text
  39       * @param string $qs, QUERY_STRING, default null
  40       * @param bool $return, Output onto page or return the links
  41       * @return nextprev string
  42       */
  43  	function nextprev($url, $from, $view, $total, $td, $qs = "", $return = false) {
  44          if ($total > $view) {
  45              $pages = ceil($total / $view);
  46          } else {
  47              $pages = FALSE;
  48          }
  49  
  50          if ($pages) {
  51              $nppage = NP_3." ";
  52              if ($pages > 10) {
  53                  $current = ($from/$view)+1;
  54  
  55                  for($c = 0; $c <= 2; $c++) {
  56                      $nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
  57                  }
  58  
  59                  if ($current >= 3 && $current <= 5) {
  60                      for($c = 3; $c <= $current; $c++) {
  61                          $nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c+1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
  62                      }
  63                  }
  64                  else if($current >= 6 && $current <= ($pages-5)) {
  65                      $nppage .= " ... ";
  66                      for($c = ($current-2); $c <= $current; $c++) {
  67                          $nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c+1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
  68                      }
  69                  }
  70                  $nppage .= " ... ";
  71  
  72  
  73                  if (($current + 5) > $pages && $current != $pages) {
  74                      $tmp = ($current-2);
  75                  } else {
  76                      $tmp = $pages-3;
  77                  }
  78  
  79                  for($c = $tmp; $c <= ($pages-1); $c++) {
  80                      $nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
  81                  }
  82  
  83              } else {
  84                  for($c = 0; $c < $pages; $c++) {
  85                      if ($view * $c == $from ? $nppage .= "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : $nppage .= "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
  86                  }
  87              }
  88              $text = "<div style='text-align:right'><div class='nextprev'><span class='smalltext'>{$nppage}</span></div></div>\n<br /><br />\n";
  89              if($return == true){
  90                  return $text;
  91              } else {
  92                  echo $text;
  93                  return null;
  94              }
  95          }
  96      }
  97  }
  98  
  99  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7