<?php include_once '../doc-typo3-funcs.php'; $doxygen_vars = array( "title" => "TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/adodb-pager.inc.php Source File", "datetime" => "Sat Dec 2 19:22:24 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?> <!-- Generated by Doxygen 1.4.6 --> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul></div> <div class="nav"> <a class="el" href="dir_c8daf1ad746050abf985cc546c89e248.html">typo3_src-4.0.1</a> » <a class="el" href="dir_18071ae4545d8b3e0364d30c0659c74a.html">typo3</a> » <a class="el" href="dir_57bf1ed8249c1fd5b014486d01bcb27a.html">sysext</a> » <a class="el" href="dir_e81b1679233d44b74aed493d6fe8e943.html">adodb</a> » <a class="el" href="dir_1f526b87ad011e46f671ba6e798564e1.html">adodb</a></div> <h1>adodb-pager.inc.php</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <?php <a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="comment">/*</span> <a name="l00004"></a>00004 <span class="comment"> V4.90 8 June 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.</span> <a name="l00005"></a>00005 <span class="comment"> Released under both BSD license and Lesser GPL library license. </span> <a name="l00006"></a>00006 <span class="comment"> Whenever there is any discrepancy between the two licenses, </span> <a name="l00007"></a>00007 <span class="comment"> the BSD license will take precedence. </span> <a name="l00008"></a>00008 <span class="comment"> Set tabs to 4 for best viewing.</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment"> This class provides recordset pagination with </span> <a name="l00011"></a>00011 <span class="comment"> First/Prev/Next/Last links. </span> <a name="l00012"></a>00012 <span class="comment"> </span> <a name="l00013"></a>00013 <span class="comment"> Feel free to modify this class for your own use as</span> <a name="l00014"></a>00014 <span class="comment"> it is very basic. To learn how to use it, see the </span> <a name="l00015"></a>00015 <span class="comment"> example in adodb/tests/testpaging.php.</span> <a name="l00016"></a>00016 <span class="comment"> </span> <a name="l00017"></a>00017 <span class="comment"> "Pablo Costa" <pablo@cbsp.com.br> implemented Render_PageLinks().</span> <a name="l00018"></a>00018 <span class="comment"> </span> <a name="l00019"></a>00019 <span class="comment"> Please note, this class is entirely unsupported, </span> <a name="l00020"></a>00020 <span class="comment"> and no free support requests except for bug reports</span> <a name="l00021"></a>00021 <span class="comment"> will be entertained by the author.</span> <a name="l00022"></a>00022 <span class="comment"></span> <a name="l00023"></a>00023 <span class="comment">*/</span> <a name="l00024"></a><a class="code" href="classADODB__Pager.html">00024</a> <span class="keyword">class </span><a class="code" href="classADODB__Pager.html">ADODB_Pager</a> { <a name="l00025"></a><a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">00025</a> var <a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">$id</a>; <span class="comment">// unique id for pager (defaults to 'adodb')</span> <a name="l00026"></a><a class="code" href="classADODB__Pager.html#03d1254277bdbd47be90a2517dafb2c1">00026</a> var <a class="code" href="classADODB__Pager.html#03d1254277bdbd47be90a2517dafb2c1">$db</a>; <span class="comment">// ADODB connection object</span> <a name="l00027"></a><a class="code" href="classADODB__Pager.html#6c426e16f23103ff2ca6f5b758c15d5b">00027</a> var <a class="code" href="classADODB__Pager.html#6c426e16f23103ff2ca6f5b758c15d5b">$sql</a>; <span class="comment">// sql used</span> <a name="l00028"></a><a class="code" href="classADODB__Pager.html#af5aff2eafac2add1cd98b2c3d7ad47f">00028</a> var <a class="code" href="classADODB__Pager.html#af5aff2eafac2add1cd98b2c3d7ad47f">$rs</a>; <span class="comment">// recordset generated</span> <a name="l00029"></a><a class="code" href="classADODB__Pager.html#8379d551ae9c4d439fbf15f0e664dac8">00029</a> var <a class="code" href="classADODB__Pager.html#8379d551ae9c4d439fbf15f0e664dac8">$curr_page</a>; <span class="comment">// current page number before Render() called, calculated in constructor</span> <a name="l00030"></a><a class="code" href="classADODB__Pager.html#5cd3214f9fa3243e094e114f40807c55">00030</a> var <a class="code" href="classADODB__Pager.html#5cd3214f9fa3243e094e114f40807c55">$rows</a>; <span class="comment">// number of rows per page</span> <a name="l00031"></a><a class="code" href="classADODB__Pager.html#1b9bdbf072a36edefe624b3e23c9224d">00031</a> var <a class="code" href="classADODB__Pager.html#1b9bdbf072a36edefe624b3e23c9224d">$linksPerPage</a>=10; <span class="comment">// number of links per page in navigation bar</span> <a name="l00032"></a><a class="code" href="classADODB__Pager.html#06a047608429f87497219d6bebe2d0dc">00032</a> var <a class="code" href="classADODB__Pager.html#06a047608429f87497219d6bebe2d0dc">$showPageLinks</a>; <a name="l00033"></a>00033 <a name="l00034"></a><a class="code" href="classADODB__Pager.html#158e51c490ed9f11a8e371aa76da6631">00034</a> var <a class="code" href="classADODB__Pager.html#158e51c490ed9f11a8e371aa76da6631">$gridAttributes</a> = 'width=100% border=1 bgcolor=white'; <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="comment">// Localize text strings here</span> <a name="l00037"></a><a class="code" href="classADODB__Pager.html#9a77225db504cbe901984b64d78d6ffb">00037</a> var <a class="code" href="classADODB__Pager.html#9a77225db504cbe901984b64d78d6ffb">$first</a> = '<code>|&lt;</code>'; <a name="l00038"></a><a class="code" href="classADODB__Pager.html#9fa3c3d758be3f435c0f11d272b67a62">00038</a> var <a class="code" href="classADODB__Pager.html#9fa3c3d758be3f435c0f11d272b67a62">$prev</a> = '<code>&lt;&lt;</code>'; <a name="l00039"></a><a class="code" href="classADODB__Pager.html#1e27471decad7f6b1792b7f10e600881">00039</a> var <a class="code" href="classADODB__Pager.html#1e27471decad7f6b1792b7f10e600881">$next</a> = '<code>>></code>'; <a name="l00040"></a><a class="code" href="classADODB__Pager.html#3fbb764c8afd904fc3a845819b133bd3">00040</a> var <a class="code" href="classADODB__Pager.html#3fbb764c8afd904fc3a845819b133bd3">$last</a> = '<code>>|</code>'; <a name="l00041"></a><a class="code" href="classADODB__Pager.html#cf718ed96ac8ef1c41657bd6f65336f1">00041</a> var <a class="code" href="classADODB__Pager.html#cf718ed96ac8ef1c41657bd6f65336f1">$moreLinks</a> = '...'; <a name="l00042"></a><a class="code" href="classADODB__Pager.html#09f3b592246f587af688a166f7144347">00042</a> var <a class="code" href="classADODB__Pager.html#09f3b592246f587af688a166f7144347">$startLinks</a> = '...'; <a name="l00043"></a><a class="code" href="classADODB__Pager.html#9082c4373ae8d25dd78d64342fb3600d">00043</a> var <a class="code" href="classADODB__Pager.html#9082c4373ae8d25dd78d64342fb3600d">$gridHeader</a> = <span class="keyword">false</span>; <a name="l00044"></a><a class="code" href="classADODB__Pager.html#cb57eb422d44ef9262b8dcea6cda6862">00044</a> var <a class="code" href="classADODB__Pager.html#cb57eb422d44ef9262b8dcea6cda6862">$htmlSpecialChars</a> = <span class="keyword">true</span>; <a name="l00045"></a><a class="code" href="classADODB__Pager.html#2389dae008d5f77fc77859d3bbd90639">00045</a> var <a class="code" href="classADODB__Pager.html#2389dae008d5f77fc77859d3bbd90639">$page</a> = 'Page'; <a name="l00046"></a><a class="code" href="classADODB__Pager.html#0863a1d254eb7d30124b9b13aacfb413">00046</a> var <a class="code" href="classADODB__Pager.html#0863a1d254eb7d30124b9b13aacfb413">$linkSelectedColor</a> = 'red'; <a name="l00047"></a><a class="code" href="classADODB__Pager.html#1cd8779b020636021a83e89f01ffaf58">00047</a> var <a class="code" href="classADODB__Pager.html#1cd8779b020636021a83e89f01ffaf58">$cache</a> = 0; #secs to cache with CachePageExecute() <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="comment">//----------------------------------------------</span> <a name="l00050"></a>00050 <span class="comment">// constructor</span> <a name="l00051"></a>00051 <span class="comment">//</span> <a name="l00052"></a>00052 <span class="comment">// $db adodb connection object</span> <a name="l00053"></a>00053 <span class="comment">// $sql sql statement</span> <a name="l00054"></a>00054 <span class="comment">// $id optional id to identify which pager, </span> <a name="l00055"></a>00055 <span class="comment">// if you have multiple on 1 page. </span> <a name="l00056"></a>00056 <span class="comment">// $id should be only be [a-z0-9]*</span> <a name="l00057"></a>00057 <span class="comment">//</span> <a name="l00058"></a><a class="code" href="classADODB__Pager.html#9868a55d34e913bfa40c6e65e92b4d19">00058</a> function <a class="code" href="classADODB__Pager.html">ADODB_Pager</a>(&<a class="code" href="classADODB__Pager.html#03d1254277bdbd47be90a2517dafb2c1">$db</a>,<a class="code" href="classADODB__Pager.html#6c426e16f23103ff2ca6f5b758c15d5b">$sql</a>,<a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">$id</a> = 'adodb', <a class="code" href="classADODB__Pager.html#06a047608429f87497219d6bebe2d0dc">$showPageLinks</a> = false) <a name="l00059"></a>00059 { <a name="l00060"></a>00060 global $PHP_SELF; <a name="l00061"></a>00061 <a name="l00062"></a>00062 <a class="code" href="classADODB__Pager.html#8379d551ae9c4d439fbf15f0e664dac8">$curr_page</a> = <a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">$id</a>.'_curr_page'; <a name="l00063"></a>00063 <span class="keywordflow">if</span> (empty($PHP_SELF)) $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); <span class="comment">// htmlspecialchars() to prevent XSS attacks</span> <a name="l00064"></a>00064 <a name="l00065"></a>00065 $this->sql = $sql; <a name="l00066"></a>00066 $this-><span class="keywordtype">id</span> = <a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">$id</a>; <a name="l00067"></a>00067 $this->db = $db; <a name="l00068"></a>00068 $this->showPageLinks = <a class="code" href="classADODB__Pager.html#06a047608429f87497219d6bebe2d0dc">$showPageLinks</a>; <a name="l00069"></a>00069 <a name="l00070"></a>00070 $next_page = <a class="code" href="classADODB__Pager.html#b17e1aea30f6def76e6f63faa2b76db5">$id</a>.'_next_page'; <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keywordflow">if</span> (isset($_GET[$next_page])) { <a name="l00073"></a>00073 $_SESSION[<a class="code" href="classADODB__Pager.html#8379d551ae9c4d439fbf15f0e664dac8">$curr_page</a>] = (integer) $_GET[$next_page]; <a name="l00074"></a>00074 } <a name="l00075"></a>00075 <span class="keywordflow">if</span> (empty($_SESSION[<a class="code" href="classADODB__Pager.html#8379d551ae9c4d439fbf15f0e664dac8">$curr_page</a>])) $_SESSION[$curr_page] = 1; ## at first page <a name="l00076"></a>00076 <a name="l00077"></a>00077 $this->curr_page = $_SESSION[$curr_page]; <a name="l00078"></a>00078 <a name="l00079"></a>00079 } <a name="l00080"></a>00080 <a name="l00081"></a>00081 <span class="comment">//---------------------------</span> <a name="l00082"></a>00082 <span class="comment">// Display link to first page</span> <a name="l00083"></a><a class="code" href="classADODB__Pager.html#e81c8f8e603b5c35db492aa118fade83">00083</a> function <a class="code" href="classADODB__Pager.html#e81c8f8e603b5c35db492aa118fade83">Render_First</a>($anchor=<span class="keyword">true</span>) <a name="l00084"></a>00084 { <a name="l00085"></a>00085 global $PHP_SELF; <a name="l00086"></a>00086 <span class="keywordflow">if</span> ($anchor) { <a name="l00087"></a>00087 ?> <a name="l00088"></a>00088 <a href=<span class="stringliteral">"<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"</span>><?php echo $this->first;?></a> &nbsp; <a name="l00089"></a>00089 <?php <a name="l00090"></a>00090 } <span class="keywordflow">else</span> { <a name="l00091"></a>00091 print <span class="stringliteral">"$this->first &nbsp; "</span>; <a name="l00092"></a>00092 } <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <a name="l00095"></a>00095 <span class="comment">//--------------------------</span> <a name="l00096"></a>00096 <span class="comment">// Display link to next page</span> <a name="l00097"></a><a class="code" href="classADODB__Pager.html#57eea18cfd2a3778a2840fbfaa98f8b6">00097</a> function <a class="code" href="classADODB__Pager.html#57eea18cfd2a3778a2840fbfaa98f8b6">render_next</a>($anchor=<span class="keyword">true</span>) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 global $PHP_SELF; <a name="l00100"></a>00100 <a name="l00101"></a>00101 <span class="keywordflow">if</span> ($anchor) { <a name="l00102"></a>00102 ?> <a name="l00103"></a>00103 <a href=<span class="stringliteral">"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"</span>><?php echo $this->next;?></a> &nbsp; <a name="l00104"></a>00104 <?php <a name="l00105"></a>00105 } <span class="keywordflow">else</span> { <a name="l00106"></a>00106 print <span class="stringliteral">"$this->next &nbsp; "</span>; <a name="l00107"></a>00107 } <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="comment">//------------------</span> <a name="l00111"></a>00111 <span class="comment">// Link to last page</span> <a name="l00112"></a>00112 <span class="comment">// </span> <a name="l00113"></a>00113 <span class="comment">// for better performance with large recordsets, you can set</span> <a name="l00114"></a>00114 <span class="comment">// $this->db->pageExecuteCountRows = false, which disables</span> <a name="l00115"></a>00115 <span class="comment">// last page counting.</span> <a name="l00116"></a><a class="code" href="classADODB__Pager.html#945a241a5cdd50f6431cb5fb6d5d733e">00116</a> function <a class="code" href="classADODB__Pager.html#945a241a5cdd50f6431cb5fb6d5d733e">render_last</a>($anchor=<span class="keyword">true</span>) <a name="l00117"></a>00117 { <a name="l00118"></a>00118 global $PHP_SELF; <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordflow">if</span> (!$this->db->pageExecuteCountRows) <span class="keywordflow">return</span>; <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keywordflow">if</span> ($anchor) { <a name="l00123"></a>00123 ?> <a name="l00124"></a>00124 <a href=<span class="stringliteral">"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"</span>><?php echo $this->last;?></a> &nbsp; <a name="l00125"></a>00125 <?php <a name="l00126"></a>00126 } <span class="keywordflow">else</span> { <a name="l00127"></a>00127 print <span class="stringliteral">"$this->last &nbsp; "</span>; <a name="l00128"></a>00128 } <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="comment">//---------------------------------------------------</span> <a name="l00132"></a>00132 <span class="comment">// original code by "Pablo Costa" <pablo@cbsp.com.br> </span> <a name="l00133"></a><a class="code" href="classADODB__Pager.html#8373f14a7c0946a37e04b029d9d50b6b">00133</a> function <a class="code" href="classADODB__Pager.html#8373f14a7c0946a37e04b029d9d50b6b">render_pagelinks</a>() <a name="l00134"></a>00134 { <a name="l00135"></a>00135 global $PHP_SELF; <a name="l00136"></a>00136 $pages = $this->rs->LastPageNo(); <a name="l00137"></a>00137 $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages; <a name="l00138"></a>00138 <span class="keywordflow">for</span>($i=1; $i <= $pages; $i+=$linksperpage) <a name="l00139"></a>00139 { <a name="l00140"></a>00140 <span class="keywordflow">if</span>($this->rs->AbsolutePage() >= $i) <a name="l00141"></a>00141 { <a name="l00142"></a>00142 $start = $i; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 } <a name="l00145"></a>00145 $numbers = ''; <a name="l00146"></a>00146 $end = $start+$linksperpage-1; <a name="l00147"></a>00147 $link = $this-><span class="keywordtype">id</span> . <span class="stringliteral">"_next_page"</span>; <a name="l00148"></a>00148 <span class="keywordflow">if</span>($end > $pages) $end = $pages; <a name="l00149"></a>00149 <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keywordflow">if</span> ($this->startLinks && $start > 1) { <a name="l00152"></a>00152 $pos = $start - 1; <a name="l00153"></a>00153 $numbers .= <span class="stringliteral">"<a href=$PHP_SELF?$link=$pos>$this->startLinks</a> "</span>; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="keywordflow">for</span>($i=$start; $i <= $end; $i++) { <a name="l00157"></a>00157 <span class="keywordflow">if</span> ($this->rs->AbsolutePage() == $i) <a name="l00158"></a>00158 $numbers .= <span class="stringliteral">"<font color=$this->linkSelectedColor><b>$i</b></font> "</span>; <a name="l00159"></a>00159 <span class="keywordflow">else</span> <a name="l00160"></a>00160 $numbers .= <span class="stringliteral">"<a href=$PHP_SELF?$link=$i>$i</a> "</span>; <a name="l00161"></a>00161 <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <span class="keywordflow">if</span> ($this->moreLinks && $end < $pages) <a name="l00164"></a>00164 $numbers .= <span class="stringliteral">"<a href=$PHP_SELF?$link=$i>$this->moreLinks</a> "</span>; <a name="l00165"></a>00165 print $numbers . ' &nbsp; '; <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <span class="comment">// Link to previous page</span> <a name="l00168"></a><a class="code" href="classADODB__Pager.html#cc0ac88a61a709587f40cfc9801e0196">00168</a> function render_prev($anchor=<span class="keyword">true</span>) <a name="l00169"></a>00169 { <a name="l00170"></a>00170 global $PHP_SELF; <a name="l00171"></a>00171 <span class="keywordflow">if</span> ($anchor) { <a name="l00172"></a>00172 ?> <a name="l00173"></a>00173 <a href=<span class="stringliteral">"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"</span>><?php echo $this->prev;?></a> &nbsp; <a name="l00174"></a>00174 <?php <a name="l00175"></a>00175 } <span class="keywordflow">else</span> { <a name="l00176"></a>00176 print <span class="stringliteral">"$this->prev &nbsp; "</span>; <a name="l00177"></a>00177 } <a name="l00178"></a>00178 } <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="comment">//--------------------------------------------------------</span> <a name="l00181"></a>00181 <span class="comment">// Simply rendering of grid. You should override this for</span> <a name="l00182"></a>00182 <span class="comment">// better control over the format of the grid</span> <a name="l00183"></a>00183 <span class="comment">//</span> <a name="l00184"></a>00184 <span class="comment">// We use output buffering to keep code clean and readable.</span> <a name="l00185"></a><a class="code" href="classADODB__Pager.html#845475060f01c08a639e32e775664008">00185</a> function RenderGrid() <a name="l00186"></a>00186 { <a name="l00187"></a>00187 global $gSQLBlockRows; <span class="comment">// used by rs2html to indicate how many rows to display</span> <a name="l00188"></a>00188 include_once(ADODB_DIR.'/tohtml.inc.php'); <a name="l00189"></a>00189 ob_start(); <a name="l00190"></a>00190 $gSQLBlockRows = $this->rows; <a name="l00191"></a>00191 rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars); <a name="l00192"></a>00192 $s = ob_get_contents(); <a name="l00193"></a>00193 ob_end_clean(); <a name="l00194"></a>00194 <span class="keywordflow">return</span> $s; <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <a name="l00197"></a>00197 <span class="comment">//-------------------------------------------------------</span> <a name="l00198"></a>00198 <span class="comment">// Navigation bar</span> <a name="l00199"></a>00199 <span class="comment">//</span> <a name="l00200"></a>00200 <span class="comment">// we use output buffering to keep the code easy to read.</span> <a name="l00201"></a><a class="code" href="classADODB__Pager.html#8e32138c65e26fbc16993c4b92f28b52">00201</a> function RenderNav() <a name="l00202"></a>00202 { <a name="l00203"></a>00203 ob_start(); <a name="l00204"></a>00204 <span class="keywordflow">if</span> (!$this->rs->AtFirstPage()) { <a name="l00205"></a>00205 $this->Render_First(); <a name="l00206"></a>00206 $this->Render_Prev(); <a name="l00207"></a>00207 } <span class="keywordflow">else</span> { <a name="l00208"></a>00208 $this->Render_First(<span class="keyword">false</span>); <a name="l00209"></a>00209 $this->Render_Prev(<span class="keyword">false</span>); <a name="l00210"></a>00210 } <a name="l00211"></a>00211 <span class="keywordflow">if</span> ($this->showPageLinks){ <a name="l00212"></a>00212 $this->Render_PageLinks(); <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <span class="keywordflow">if</span> (!$this->rs->AtLastPage()) { <a name="l00215"></a>00215 $this->Render_Next(); <a name="l00216"></a>00216 $this->Render_Last(); <a name="l00217"></a>00217 } <span class="keywordflow">else</span> { <a name="l00218"></a>00218 $this->Render_Next(<span class="keyword">false</span>); <a name="l00219"></a>00219 $this->Render_Last(<span class="keyword">false</span>); <a name="l00220"></a>00220 } <a name="l00221"></a>00221 $s = ob_get_contents(); <a name="l00222"></a>00222 ob_end_clean(); <a name="l00223"></a>00223 <span class="keywordflow">return</span> $s; <a name="l00224"></a>00224 } <a name="l00225"></a>00225 <a name="l00226"></a>00226 <span class="comment">//-------------------</span> <a name="l00227"></a>00227 <span class="comment">// This is the footer</span> <a name="l00228"></a><a class="code" href="classADODB__Pager.html#5efbd41aa984d61188f30b29968d5ac3">00228</a> function RenderPageCount() <a name="l00229"></a>00229 { <a name="l00230"></a>00230 <span class="keywordflow">if</span> (!$this->db->pageExecuteCountRows) <span class="keywordflow">return</span> ''; <a name="l00231"></a>00231 $lastPage = $this->rs->LastPageNo(); <a name="l00232"></a>00232 <span class="keywordflow">if</span> ($lastPage == -1) $lastPage = 1; <span class="comment">// check for empty rs.</span> <a name="l00233"></a>00233 <span class="keywordflow">if</span> ($this->curr_page > $lastPage) $this->curr_page = 1; <a name="l00234"></a>00234 <span class="keywordflow">return</span> <span class="stringliteral">"<font size=-1>$this->page "</span>.$this->curr_page.<span class="stringliteral">"/"</span>.$lastPage.<span class="stringliteral">"</font>"</span>; <a name="l00235"></a>00235 } <a name="l00236"></a>00236 <a name="l00237"></a>00237 <span class="comment">//-----------------------------------</span> <a name="l00238"></a>00238 <span class="comment">// Call this class to draw everything.</span> <a name="l00239"></a><a class="code" href="classADODB__Pager.html#03bef14c247938371ba59a584e78972a">00239</a> function Render($rows=10) <a name="l00240"></a>00240 { <a name="l00241"></a>00241 global $ADODB_COUNTRECS; <a name="l00242"></a>00242 <a name="l00243"></a>00243 $this->rows = $rows; <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordflow">if</span> ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL; <a name="l00246"></a>00246 <a name="l00247"></a>00247 $savec = $ADODB_COUNTRECS; <a name="l00248"></a>00248 <span class="keywordflow">if</span> ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = <span class="keyword">true</span>; <a name="l00249"></a>00249 <span class="keywordflow">if</span> ($this->cache) <a name="l00250"></a>00250 $rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); <a name="l00251"></a>00251 <span class="keywordflow">else</span> <a name="l00252"></a>00252 $rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page); <a name="l00253"></a>00253 $ADODB_COUNTRECS = $savec; <a name="l00254"></a>00254 <a name="l00255"></a>00255 $this->rs = &$rs; <a name="l00256"></a>00256 <span class="keywordflow">if</span> (!$rs) { <a name="l00257"></a>00257 print <span class="stringliteral">"<h3>Query failed: $this->sql</h3>"</span>; <a name="l00258"></a>00258 <span class="keywordflow">return</span>; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <a name="l00261"></a>00261 <span class="keywordflow">if</span> (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) <a name="l00262"></a>00262 $header = $this->RenderNav(); <a name="l00263"></a>00263 <span class="keywordflow">else</span> <a name="l00264"></a>00264 $header = <span class="stringliteral">"&nbsp;"</span>; <a name="l00265"></a>00265 <a name="l00266"></a>00266 $grid = $this->RenderGrid(); <a name="l00267"></a>00267 $footer = $this->RenderPageCount(); <a name="l00268"></a>00268 <a name="l00269"></a>00269 $this->RenderLayout($header,$grid,$footer); <a name="l00270"></a>00270 <a name="l00271"></a>00271 $rs->Close(); <a name="l00272"></a>00272 $this->rs = <span class="keyword">false</span>; <a name="l00273"></a>00273 } <a name="l00274"></a>00274 <a name="l00275"></a>00275 <span class="comment">//------------------------------------------------------</span> <a name="l00276"></a>00276 <span class="comment">// override this to control overall layout and formating</span> <a name="l00277"></a><a class="code" href="classADODB__Pager.html#282eaa61042f35481e7a0197faa2f4fb">00277</a> function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige') <a name="l00278"></a>00278 { <a name="l00279"></a>00279 echo <span class="stringliteral">"<table "</span>.$attributes.<span class="stringliteral">"><tr><td>"</span>, <a name="l00280"></a>00280 $header, <a name="l00281"></a>00281 <span class="stringliteral">"</td></tr><tr><td>"</span>, <a name="l00282"></a>00282 $grid, <a name="l00283"></a>00283 <span class="stringliteral">"</td></tr><tr><td>"</span>, <a name="l00284"></a>00284 $footer, <a name="l00285"></a>00285 <span class="stringliteral">"</td></tr></table>"</span>; <a name="l00286"></a>00286 } <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <a name="l00289"></a>00289 <a name="l00290"></a>00290 ?> </pre></div><?php include_once '../doc-typo3-funcs.php'; get_footer(); ?>