| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 /** 20 * Page navigation support class 21 */ 22 class mosPageNav { 23 /** @var int The record number to start dislpaying from */ 24 var $limitstart = null; 25 /** @var int Number of rows to display per page */ 26 var $limit = null; 27 /** @var int Total number of rows */ 28 var $total = null; 29 30 function mosPageNav( $total, $limitstart, $limit ) { 31 $this->total = intval( $total ); 32 $this->limitstart = max( intval($limitstart), 0 ); 33 $this->limit = max( intval($limit), 1 ); 34 if ($this->limit > $this->total) { 35 $this->limitstart = 0; 36 } 37 if (($this->limit-1)*$this->limitstart > $this->total) { 38 $this->limitstart -= $this->limitstart % $this->limit; 39 } 40 } 41 /** 42 * @return string The html for the limit # input box 43 */ 44 function getLimitBox () { 45 $limits = array(); 46 for ($i=5; $i <= 30; $i+=5) { 47 $limits[] = mosHTML::makeOption( "$i" ); 48 } 49 $limits[] = mosHTML::makeOption( "50" ); 50 51 // build the html select list 52 $html = mosHTML::selectList( $limits, 'limit', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 53 'value', 'text', $this->limit ); 54 $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />"; 55 return $html; 56 } 57 /** 58 * Writes the html limit # input box 59 */ 60 function writeLimitBox () { 61 echo mosPageNav::getLimitBox(); 62 } 63 function writePagesCounter() { 64 echo $this->getPagesCounter(); 65 } 66 /** 67 * @return string The html for the pages counter, eg, Results 1-10 of x 68 */ 69 function getPagesCounter() { 70 $html = ''; 71 $from_result = $this->limitstart+1; 72 if ($this->limitstart + $this->limit < $this->total) { 73 $to_result = $this->limitstart + $this->limit; 74 } else { 75 $to_result = $this->total; 76 } 77 if ($this->total > 0) { 78 $html .= sprintf(T_("Results %d to %d of %d"), $from_result, $to_result, $this->total); 79 } else { 80 $html .= T_('No records found.'); 81 } 82 return $html; 83 } 84 /** 85 * Writes the html for the pages counter, eg, Results 1-10 of x 86 */ 87 function writePagesLinks() { 88 echo $this->getPagesLinks(); 89 } 90 /** 91 * @return string The html links for pages, eg, previous, next, 1 2 3 ... x 92 */ 93 function getPagesLinks() { 94 $html = ''; 95 $displayed_pages = 10; 96 $total_pages = ceil( $this->total / $this->limit ); 97 $this_page = ceil( ($this->limitstart+1) / $this->limit ); 98 $start_loop = (floor(($this_page-1)/$displayed_pages))*$displayed_pages+1; 99 if ($start_loop + $displayed_pages - 1 < $total_pages) { 100 $stop_loop = $start_loop + $displayed_pages - 1; 101 } else { 102 $stop_loop = $total_pages; 103 } 104 105 if ($this_page > 1) { 106 $page = ($this_page - 2) * $this->limit; 107 $html .= "\n<a href=\"#beg\" class=\"pagenav\" title=\"".T_('first page')."\" onclick=\"javascript: document.adminForm.limitstart.value=0; document.adminForm.submit();return false;\"><< ".T_('Start')."</a>"; 108 $html .= "\n<a href=\"#prev\" class=\"pagenav\" title=\"".T_('previous page')."\" onclick=\"javascript: document.adminForm.limitstart.value=$page; document.adminForm.submit();return false;\">< ".T_('Previous')."</a>"; 109 } else { 110 $html .= "\n<span class=\"pagenav\"><< ".T_('Start')."</span>"; 111 $html .= "\n<span class=\"pagenav\">< ".T_('Previous')."</span>"; 112 } 113 114 for ($i=$start_loop; $i <= $stop_loop; $i++) { 115 $page = ($i - 1) * $this->limit; 116 if ($i == $this_page) { 117 $html .= "\n<span class=\"pagenav\"> $i </span>"; 118 } else { 119 $html .= "\n<a href=\"#$i\" class=\"pagenav\" onclick=\"javascript: document.adminForm.limitstart.value=$page; document.adminForm.submit();return false;\"><strong>$i</strong></a>"; 120 } 121 } 122 123 if ($this_page < $total_pages) { 124 $page = $this_page * $this->limit; 125 $end_page = ($total_pages-1) * $this->limit; 126 $html .= "\n<a href=\"#next\" class=\"pagenav\" title=\"".T_('next page')."\" onclick=\"javascript: document.adminForm.limitstart.value=$page; document.adminForm.submit();return false;\"> ".T_('Next')." ></a>"; 127 $html .= "\n<a href=\"#end\" class=\"pagenav\" title=\"".T_('end page')."\" onclick=\"javascript: document.adminForm.limitstart.value=$end_page; document.adminForm.submit();return false;\"> ".T_('End')." >></a>"; 128 } else { 129 $html .= "\n<span class=\"pagenav\">".T_('Next')." ></span>"; 130 $html .= "\n<span class=\"pagenav\">".T_('End')." >></span>"; 131 } 132 return $html; 133 } 134 135 function getListFooter() { 136 $html = '<table class="adminlist"><tr><th colspan="3">'; 137 $html .= $this->getPagesLinks(); 138 $html .= '</th></tr><tr>'; 139 $html .= '<td nowrap="true" width="48%" align="right">'.T_('Display #').'</td>'; 140 $html .= '<td>' .$this->getLimitBox() . '</td>'; 141 $html .= '<td nowrap="true" width="48%" align="left">' . $this->getPagesCounter() . '</td>'; 142 $html .= '</tr></table>'; 143 return $html; 144 } 145 /** 146 * @param int The row index 147 * @return int 148 */ 149 function rowNumber( $i ) { 150 return $i + 1 + $this->limitstart; 151 } 152 /** 153 * @param int The row index 154 * @param string The task to fire 155 * @param string The alt text for the icon 156 * @return string 157 */ 158 function orderUpIcon( $i, $condition=true, $task='orderup' ) { 159 if (($i > 0 || ($i+$this->limitstart > 0)) && $condition) { 160 $alt = T_('Move Up'); 161 return '<a href="#reorder" onClick="return listItemTask(\'cb'.$i.'\',\''.$task.'\')" title="'.$alt.'"> 162 <img src="images/uparrow.png" width="12" height="12" border="0" alt="'.$alt.'"> 163 </a>'; 164 } else { 165 return ' '; 166 } 167 } 168 /** 169 * @param int The row index 170 * @param int The number of items in the list 171 * @param string The task to fire 172 * @param string The alt text for the icon 173 * @return string 174 */ 175 function orderDownIcon( $i, $n, $condition=true, $task='orderdown' ) { 176 if (($i < $n-1 || $i+$this->limitstart < $this->total-1) && $condition) { 177 $alt = T_('Move Down'); 178 return '<a href="#reorder" onClick="return listItemTask(\'cb'.$i.'\',\''.$task.'\')" title="'.$alt.'"> 179 <img src="images/downarrow.png" width="12" height="12" border="0" alt="'.$alt.'"> 180 </a>'; 181 } else { 182 return ' '; 183 } 184 } 185 } 186 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |