home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Pager.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  7.8 KB  |  146 lines

  1. <?php
  2. // +-----------------------------------------------------------------------+
  3. // | Copyright (c) 2002-2003, Richard Heyes                                |
  4. // | All rights reserved.                                                  |
  5. // |                                                                       |
  6. // | Redistribution and use in source and binary forms, with or without    |
  7. // | modification, are permitted provided that the following conditions    |
  8. // | are met:                                                              |
  9. // |                                                                       |
  10. // | o Redistributions of source code must retain the above copyright      |
  11. // |   notice, this list of conditions and the following disclaimer.       |
  12. // | o Redistributions in binary form must reproduce the above copyright   |
  13. // |   notice, this list of conditions and the following disclaimer in the |
  14. // |   documentation and/or other materials provided with the distribution.|
  15. // | o The names of the authors may not be used to endorse or promote      |
  16. // |   products derived from this software without specific prior written  |
  17. // |   permission.                                                         |
  18. // |                                                                       |
  19. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  20. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  21. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  22. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  23. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  24. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  25. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  26. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  27. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  28. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  29. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  30. // |                                                                       |
  31. // +-----------------------------------------------------------------------+
  32. // | Authors: Richard Heyes <richard@phpguru.org>                          |
  33. // |          Lorenzo Alberton <l.alberton at quipo.it>                    |
  34. // +-----------------------------------------------------------------------+
  35. //
  36. // $Id: Pager.php,v 1.12 2004/01/13 00:15:00 quipo Exp $
  37.  
  38. /**
  39.  * File Pager.php
  40.  *
  41.  * @package Pager
  42.  */
  43. /**
  44.  * Pager - Wrapper class for [Sliding|Jumping]-window Pager
  45.  *
  46.  * Usage examples can be found in the doc provided
  47.  *
  48.  * @author  Richard Heyes <richard@phpguru.org>,
  49.  * @author  Lorenzo Alberton <l.alberton at quipo.it>
  50.  * @version  $Id: Pager.php,v 1.12 2004/01/13 00:15:00 quipo Exp $
  51.  * @package Pager
  52.  */
  53. class Pager
  54. {
  55.  
  56.     // {{{ Pager()
  57.  
  58.     /**
  59.      * Constructor
  60.      *
  61.      * -------------------------------------------------------------------------
  62.      * VALID options are (default values are set some lines before):
  63.      *  - mode       (string): "Jumping" or "Sliding"  -window - It determines
  64.      *                         pager behaviour. See the manual for more details
  65.      *  - totalItems (int):    # of items to page.
  66.      *  - perPage    (int):    # of items per page.
  67.      *  - delta      (int):    # of page #s to show before and after the current
  68.      *                         one
  69.      *  - linkClass  (string): name of CSS class used for link styling.
  70.      *  - append     (bool):   if true pageID is appended as GET value to the
  71.      *                         URL - if false it is embedded in the URL
  72.      *                         according to "fileName" specs
  73.      *  - path       (string): complete path to the page (without the page name)
  74.      *  - fileName   (string): name of the page, with a %d if append=true
  75.      *  - urlVar     (string): name of pageNumber URL var, for example "pageID"
  76.      *  - altPrev    (string): alt text to display for prev page, on prev link.
  77.      *  - altNext    (string): alt text to display for next page, on next link.
  78.      *  - altPage    (string): alt text to display before the page number.
  79.      *  - prevImg    (string): sth (it can be text such as "<< PREV" or an
  80.      *                         <img/> as well...) to display instead of "<<".
  81.      *  - nextImg    (string): same as prevImg, used for NEXT link, instead of
  82.      *                         the default value, which is ">>".
  83.      *  - separator  (string): what to use to separate numbers (can be an
  84.      *                         <img/>, a comma, an hyphen, or whatever.
  85.      *  - spacesBeforeSeparator
  86.      *               (int):    number of spaces before the separator.
  87.      *  - firstPagePre (string):
  88.      *                         string used before first page number (can be an
  89.      *                         <img/>, a "{", an empty string, or whatever.
  90.      *  - firstPageText (string):
  91.      *                         string used in place of first page number
  92.      *  - firstPagePost (string):
  93.      *                         string used after first page number (can be an
  94.      *                         <img/>, a "}", an empty string, or whatever.
  95.      *  - lastPagePre (string):
  96.      *                         similar to firstPagePre.
  97.      *  - lastPageText (string):
  98.      *                         similar to firstPageText.
  99.      *  - lastPagePost (string):
  100.      *                         similar to firstPagePost.
  101.      *  - spacesAfterSeparator
  102.      *               (int):    number of spaces after the separator.
  103.      *  - firstLinkTitle (string):
  104.      *                          string used as title in <link rel="first"> tag
  105.      *  - lastLinkTitle (string):
  106.      *                          string used as title in <link rel="last"> tag
  107.      *  - prevLinkTitle (string):
  108.      *                          string used as title in <link rel="prev"> tag
  109.      *  - nextLinkTitle (string):
  110.      *                          string used as title in <link rel="next"> tag
  111.      *  - curPageLinkClassName
  112.      *               (string): name of CSS class used for current page link.
  113.      *  - clearIfVoid(bool):   if there's only one page, don't display pager.
  114.      *  - extraVars (array):   additional URL vars to be added to the querystring
  115.      *  - itemData   (array):  array of items to page.
  116.      *  - useSessions (bool):  if true, number of items to display per page is
  117.      *                         stored in the $_SESSION[$_sessionVar] var.
  118.      *  - closeSession (bool): if true, the session is closed just after R/W.
  119.      *  - sessionVar (string): name of the session var for perPage value.
  120.      *                         A value != from default can be useful when
  121.      *                         using more than one Pager istance in the page.
  122.      *  - pearErrorMode (constant):
  123.      *                         PEAR_ERROR mode for raiseError().
  124.      *                         Default is PEAR_ERROR_RETURN.
  125.      * -------------------------------------------------------------------------
  126.      * REQUIRED options are:
  127.      *  - fileName IF append==false (default is true)
  128.      *  - itemData OR totalItems (if itemData is set, totalItems is overwritten)
  129.      * -------------------------------------------------------------------------
  130.      *
  131.      * @param mixed $options    An associative array of option names and
  132.      *                          their values.
  133.      * @access public
  134.      */
  135.     function Pager($options = array())
  136.     {
  137.         $mode = (isset($options['mode']) ? $options['mode'] : 'Jumping');
  138.         $pager_class = 'Pager_' . ucfirst($mode);
  139.         $pager_classfile = 'Pager' . DIRECTORY_SEPARATOR . $mode . '.php';
  140.         require_once $pager_classfile;
  141.         $this = new $pager_class($options);
  142.     }
  143.  
  144.     // }}}
  145. }
  146. ?>