Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

pager.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  This program is free software; you can redistribute it and/or
00004  modify it under the terms of the GNU General Public License
00005  as published by the Free Software Foundation; either version 2
00006  of the License, or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful,
00009  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  GNU General Public License for more details.
00012 
00013  You should have received a copy of the GNU General Public License
00014  along with this program; if not, write to the Free Software
00015  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016  ***************************************************************************/
00017 
00018 
00035 class Pager
00036 {
00037     var $intPage;       
00038     var $intMaxPage;    
00039     var $intItemLimit;  
00040     var $firstline;     
00041     var $lastline;      
00042     var $intTotal;      
00043     var $intMaxLink;    
00044     var $strUrl;        
00045 
00046   // var linktype       verschiedene Pager möglich machen
00047   // var linkdecoration     aussehen des einzelnen Links setzen
00048 
00056     function Pager ( $intCount, $intMax, $intMaxLinks, $strUrl )
00057     {
00058         $this->intPage = 1;
00059         $this->intTotal = $intCount;
00060         $this->strUrl = $strUrl;
00061         $this->intItemLimit = min( $intCount, $intMax );
00062         $this->intMaxLink = round ( $intMaxLinks / 2 );
00063         if( $this->intMaxLink < 5 )
00064         {
00065             $this->intMaxLink = 5;
00066         }
00067         $this->intMaxPage = ($this->intItemLimit > 0) ? round( ($this->intTotal/$this->intItemLimit) + 0.49, 0 ) : 0;
00068     }
00069 
00070 
00071   /* ---------------------------------------------------------------------------------
00072    * Methoden
00073    * ---------------------------------------------------------------------------------
00074    */
00075     function setcurrent( $intCurrent = -1 )
00076     {
00077         if ( $intCurrent == -1 )
00078         {
00079             $this->intPage = -1;
00080             $this->firstline = 0;
00081             $this->lastline = $this->intTotal;
00082         }
00083         else
00084         {
00085             $this->intPage = ( $this->intItemLimit > 0 ) ? round( ($intCurrent / $this->intItemLimit) + 0.5, 0 ) : 0;
00086             $this->firstline = $intCurrent;
00087             $this->lastline = $intCurrent + $this->intItemLimit;
00088         }
00089     }
00090 
00091     function pagelink ( $intPageNo )
00092     {
00093         // current page doesnt become a link
00094         if( $this->intPage == $intPageNo )
00095         {
00096             return ( ($intPageNo != -1) ? $intPageNo : 'alle' );
00097         }
00098 
00099         $strText = '<b><a href="'.$this->strUrl.'p_count='.$this->intItemLimit.'&amp;p_start=';
00100 
00101         $strText .= ( $intPageNo != -1 ) ? (($intPageNo-1) * $this->intItemLimit) . '">'.$intPageNo : '-1">alle';
00102 
00103         $strText .= '</a></b>';
00104         return( $strText );
00105     }
00106 
00107 
00108     function link()
00109     {
00110         if( $this->intMaxPage == 1 )
00111         {
00112             return( '' );
00113         }
00114 
00115         $strText = 'gehe zu Seite:&nbsp;';
00116         $strLinkbase = '';
00117 
00118 /*
00119     // zurueck oder first link koennte auch noch angefuegt werden
00120     if( $this->page > 1 ) {
00121       $text .= "zurück";
00122     }
00123 */
00124 
00125         // @todo limit
00126         // set all links (should be limited later)
00127         for ( $intCount = 1; $intCount <= $this->intMaxPage; $intCount++ )
00128         {
00129             if( $intCount == 1 || $intCount == $this->intMaxPage || abs( $this->intPage - $intCount ) < $this->intMaxLink )
00130             {
00131                 $strText .= '&nbsp;' . $this->pagelink( $intCount );
00132             }
00133             elseif (abs( $this->intPage - $intCount ) == $this->intMaxLink)
00134             {
00135                 $strText .= '&nbsp;...&nbsp;';
00136             }
00137         }
00138 
00139         // weiter oder last link koennte auch noch angefuegt werden
00140         //....
00141 
00142         $strText .= '&nbsp;(' . $this->pagelink( -1 ).')';
00143 
00144         return( $strText );
00145     }
00146 
00147     function pagestring()
00148     {
00149         return ( $this->intPage == -1 ) ? 'Alle Datens&auml;tze' : 'Seite&nbsp;' . $this->intPage . '&nbsp;von&nbsp;' . $this->intMaxPage;
00150     }
00151 }

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2