Documentation TYPO3 par Ameos

class.recordnavigator.php

00001 <?php
00002 /*
00003 Name: Class.RecordNavigator.php
00004 Type: Class
00005 Purpose: Provide interface for creating next/previous and page # links
00006 Usage:
00007 
00008 $RN = new RecordNavigator(
00009         "SELECT COUNT(*) FROM yourtable",
00010         $passedOffset,
00011         20,
00012         "yourscript.php?catid=1"
00013 );
00014 $RN->createSequence();
00015 $RN->createPrevNext("previous", "next");
00016 echo($RN->getNavigator());
00017 
00018 */
00019 class RecordNavigator
00020 {
00021         var $queryCount;
00022         var $offset;
00023         var $limiter;
00024         var $seqStr;
00025         var $scriptPath;
00026 
00027         var $cObj = null; // for making typo3 links
00028 
00029         /* constructor */
00030         function RecordNavigator($queryCount, $offset, $limiter, $scriptpath)
00031         { 
00032                 $this->queryCount       = $queryCount;
00033                 $this->offset           = $offset;
00034                 $this->limiter          = $limiter;
00035                 $this->scriptPath       = $scriptpath;
00036 
00037                 $this->cObj = new tslib_cObj();
00038         }
00039         
00040         /* create page # sequence */
00041         function createSequence()
00042         {
00043                 $numPages = ceil($this->queryCount / $this->limiter);
00044                 $nextOffset = 0;
00045                 
00046                 /* if there are more records than currently counted, generate sequence */
00047                 if($this->queryCount > $this->limiter)
00048                 {               
00049                         for($i = 1; $i <= $numPages; $i++)
00050                         {
00051                                 if($this->offset != $nextOffset)
00052                                 {
00053                                         $this->seqStr .= '<li>'.$this->cObj->getTypoLink(
00054                                                 $i, 
00055                                                 $GLOBALS['TSFE']->id, 
00056                                                 array('offset' => $nextOffset), 
00057                                                 ''
00058                                         ).'</li>';
00059                                 }
00060                                 else
00061                                 {
00062                                         $this->seqStr .= '<li class="current">'.$i.'</li>';
00063                                 }
00064                                         
00065                                 $nextOffset += $this->limiter;
00066                         }
00067                 }
00068         }
00069         
00070         /* create previous/next links */
00071         function createPrevNext($prevLabel, $nextLabel)
00072         {
00073                 if((int) $this->offset != 0)
00074                 {
00075                         $prevOffset = $this->offset - $this->limiter;
00076                         
00077                         $this->seqStr = '<li class="prev">'.$this->cObj->getTypoLink(
00078                                 $prevLabel,
00079                                 $GLOBALS['TSFE']->id,
00080                                 array('offset' => $prevOffset),
00081                                 '').'</li>'.$this->seqStr;
00082                 }
00083                 if($this->queryCount > ($this->offset + $this->limiter))
00084                 {
00085                         $nextOffset = $this->offset + $this->limiter;
00086                         $this->seqStr .= '<li class="next">'.$this->cObj->getTypoLink(
00087                                 $nextLabel,
00088                                 $GLOBALS['TSFE']->id,
00089                                 array('offset' => $nextOffset),
00090                                 '').'</li>';
00091                 }
00092         }
00093         
00094         /* return full navigation string */
00095         function getNavigator()
00096         {
00097                 return '<ul class="prevnext">'.$this->seqStr.'</ul>';
00098         }
00099 }
00100 
00101 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tt_guest/pi/class.recordnavigator.php"])       {
00102         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tt_guest/pi/class.recordnavigator.php"]);
00103 }
00104 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6