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

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PEAR :: Pager_Sliding Example                          |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2003 The PHP Group                                |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 2.0 of the PHP license,       |
  8. // | that is bundled with this package in the file LICENSE, and is        |
  9. // | available at through the world-wide-web at                           |
  10. // | http://www.php.net/license/2_02.txt.                                 |
  11. // | If you did not receive a copy of the PHP license and are unable to   |
  12. // | obtain it through the world-wide-web, please send a note to          |
  13. // | license@php.net so we can mail you a copy immediately.               |
  14. // +----------------------------------------------------------------------+
  15. // | Author: Lorenzo Alberton <l.alberton at quipo.it>                    |
  16. // +----------------------------------------------------------------------+
  17.  
  18. require_once 'Pager/Sliding.php';
  19.  
  20. $params['totalItems'] = 800;
  21. $pager = &new Pager_Sliding($params);
  22. $data  = $pager->getPageData();
  23. $links = $pager->getLinks();
  24.  
  25.  
  26. ?>
  27. <html>
  28. <head>
  29. <title>Pager_Sliding examples</title>
  30. <style type="text/css">
  31. <!--
  32. a.myClass {
  33.     color: red;
  34.     font-family: verdana;
  35.     font-size: 10pt;
  36. }
  37. .myClass2 {
  38.     color: #222;
  39.     font-family: verdana;
  40.     font-size: 8pt;
  41. }
  42. // -->
  43. </style>
  44. </head>
  45. <body>
  46. <h1>Pager_Sliding</h1>
  47.  
  48. <hr />
  49. <span class="myClass2">Author: Lorenzo Alberton  <l.alberton at quipo.it></span> <br />
  50. go to <a href="SWPager_example1.php">Example1</a> - <a href="SWPager_example3.php">Example3</a> - <a href="SWPager_example4.php">Example4</a> - <a href="../">home</a>
  51. <hr />
  52.  
  53. <h2>Example 2</h2>
  54.  
  55. <?php
  56. $params = array(
  57.             'separator'  => ',',
  58.             'spacesBeforeSeparator' => 0,
  59.             'spacesAfterSeparator'  => 3,
  60.             'perPage'    => 3,
  61.             'delta'      => 3,
  62.             'urlVar'     => 'ID',
  63.             'altPrev'    => 'Pagina precedente',
  64.             'altNext'    => 'Pagina successiva',
  65.             'altPage'    => 'pagina n.',
  66.             'prevImg'    => '<img src="prev.gif" border="0" />',
  67.             'nextImg'    => '<img src="next.gif" border="0" />',
  68.             'linkClass'  => 'myClass',
  69.             'firstPagePre'  => '',
  70.             'firstPagePost' => '',
  71.             'lastPagePre'   => '{',
  72.             'lastPagePost'  => '}',
  73.             'itemData'   => array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
  74.             );
  75. $pager = &new Pager_Sliding($params);
  76. $data  = $pager->getPageData();
  77. $links = $pager->getLinks();
  78. ?>
  79.  
  80.  
  81. <pre>
  82. SETTINGS:
  83. $params = array(
  84.             'separator'  => ',',
  85.             'spacesBeforeSeparator' => 0,
  86.             'spacesAfterSeparator'  => 3,
  87.             'perPage'    => 3,
  88.             'delta'      => 3,
  89.             'urlVar'     => 'ID',
  90.             'altPrev'    => 'Pagina precedente',
  91.             'altNext'    => 'Pagina successiva',
  92.             'altPage'    => 'pagina n.',
  93.             'prevImg'    => '<img src="prev.gif" />',
  94.             'nextImg'    => '<img src="next.gif" />',
  95.             'linkClass'  => 'myClass',
  96.             'firstPagePre'  => '',
  97.             'firstPagePost' => '',
  98.             'lastPagePre'   => '{',
  99.             'lastPagePost'  => '}',
  100.             'itemData'   => array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
  101.             );
  102. $pager = &new Pager_Sliding($params);
  103. </pre>
  104.  
  105. <hr />
  106.  
  107. <b>Have a look at:</b><br />
  108. - separator <i>(comma instead of pipe)</i>,<br />
  109. - alt text <i>("pagina" instead of "page")</i>, <br />
  110. - img used as prev/next links <i>(image instead of « »)</i>, <br />
  111. - different urlVar used than default <i>("ID" instead of "pageID")</i>,<br />
  112. - CSS <i>(red links)</i>,<br />
  113. - number of page numbers showed <i>(delta=3 instead of 2)</i>,<br />
  114. - last page embraced by curly braces <i>(instead of [9])</i>,<br />
  115. - first page not embraced by anything <i>(instead of [1])</i><br />
  116.  
  117.  
  118. <br /> <br />
  119.  
  120. <table border="1" width="500" summary="example 1">
  121.     <tr>
  122.         <td colspan="3" align="center">
  123.             <?php echo $links['all']; ?>
  124.         </td>
  125.     </tr>
  126.  
  127.  
  128.     <tr>
  129.         <td colspan="3">
  130.             <pre>PAGED DATA: <?php print_r($data); ?></pre>
  131.         </td>
  132.     </tr>
  133. </table>
  134.  
  135.  
  136. <h4>Results from methods:</h4>
  137.  
  138. <pre>
  139. getCurrentPageID()...: <?php var_dump($pager->getCurrentPageID()); ?>
  140. getNextPageID()......: <?php var_dump($pager->getNextPageID()); ?>
  141. getPreviousPageID()..: <?php var_dump($pager->getPreviousPageID()); ?>
  142. numItems()...........: <?php var_dump($pager->numItems()); ?>
  143. numPages()...........: <?php var_dump($pager->numPages()); ?>
  144. isFirstPage()........: <?php var_dump($pager->isFirstPage()); ?>
  145. isLastPage().........: <?php var_dump($pager->isLastPage()); ?>
  146. isLastPageComplete().: <?php var_dump($pager->isLastPageComplete()); ?>
  147. $pager->range........: <?php var_dump($pager->range); ?>
  148. </pre>
  149.  
  150. <hr />
  151.  
  152. </body>
  153. </html>