home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Sliding_example3.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  4.3 KB  |  137 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_example2.php">Example2</a> - <a href="SWPager_example4.php">Example4</a> - <a href="../">home</a>
  51. <hr />
  52.  
  53. <h2>Example 3</h2>
  54.  
  55. <?php
  56. $month = 'september';
  57. $params = array(
  58.             'append'    => false,
  59.             'urlVar'    => 'num',
  60.             'path'      => 'http://myserver.com/articles/' . $month,
  61.             'fileName'  => 'art%d.html',
  62.             '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'),
  63.             'perPage'   => 3
  64.             );
  65. $pager = &new Pager_Sliding($params);
  66. $data  = $pager->getPageData();
  67. $links = $pager->getLinks();
  68. ?>
  69.  
  70. <h3>This shows how this Pager can be used with mod_rewrite</h3>
  71. <h5 style="color: red; font-weight: 700;">NB: on this server mod_rewrite is not active, so links won't work, but have a look at the status bar to see how url is written.</h5>
  72. <br />
  73.  
  74. <pre>
  75. Let's suppose we have a .htaccess like this:
  76. -----------------------------------
  77. RewriteEngine on
  78. #Options FollowSymlinks
  79.  
  80. RewriteBase /
  81. RewriteRule ^articles/([a-z]{1,12})/art([0-9]{1,4})\.html$ /article.php?num=$2&month=$1 [L]
  82. -----------------------------------
  83.  
  84. It should transform an url like:
  85.    /articles/march/art15.html
  86. into:
  87.    /article.php?num=15&month=march
  88.  
  89. </pre>
  90. <br />
  91. <hr />
  92. <pre>
  93. SETTINGS:
  94. $month = 'september';
  95. $params = array(
  96.             'append'    => false,
  97.             'urlVar'    => 'num',
  98.             'path'      => 'http://myserver.com/articles/' . $month,
  99.             'fileName'  => 'art%d.html',  //Pager replaces "%d" with page number...
  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.             'perPage'   => 3
  102.             );
  103. $pager = &new Pager_Sliding($params);
  104. </pre>
  105. <table border="1" width="500" summary="example 1">
  106.     <tr>
  107.         <td colspan="3" align="center">
  108.             <?php echo $links['all']; ?>
  109.         </td>
  110.     </tr>
  111.  
  112.  
  113.     <tr>
  114.         <td colspan="3">
  115.             <pre>PAGED DATA: <?php print_r($data); ?></pre>
  116.         </td>
  117.     </tr>
  118. </table>
  119.  
  120. <h4>Results from methods:</h4>
  121.  
  122. <pre>
  123. getCurrentPageID()...: <?php var_dump($pager->getCurrentPageID()); ?>
  124. getNextPageID()......: <?php var_dump($pager->getNextPageID()); ?>
  125. getPreviousPageID()..: <?php var_dump($pager->getPreviousPageID()); ?>
  126. numItems()...........: <?php var_dump($pager->numItems()); ?>
  127. numPages()...........: <?php var_dump($pager->numPages()); ?>
  128. isFirstPage()........: <?php var_dump($pager->isFirstPage()); ?>
  129. isLastPage().........: <?php var_dump($pager->isLastPage()); ?>
  130. isLastPageComplete().: <?php var_dump($pager->isLastPageComplete()); ?>
  131. $pager->range........: <?php var_dump($pager->range); ?>
  132. </pre>
  133.  
  134. <hr />
  135.  
  136. </body>
  137. </html>