| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
|
* @version $Id: pageNavigation.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $ |
|
| 3 |
* @package Mambo |
* @package Mambo |
| 4 |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
* @author Mambo Foundation Inc see README.php |
| 5 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @copyright Mambo Foundation Inc. |
| 6 |
* Mambo is Free Software |
* See COPYRIGHT.php for copyright notices and details. |
| 7 |
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see |
| 8 |
|
* LICENSE.php |
| 9 |
|
* Mambo is free software; you can redistribute it and/or |
| 10 |
|
* modify it under the terms of the GNU General Public License |
| 11 |
|
* as published by the Free Software Foundation; version 2 of the |
| 12 |
|
* License. |
| 13 |
*/ |
*/ |
| 14 |
|
|
| 15 |
/** ensure this file is being included by a parent file */ |
/** ensure this file is being included by a parent file */ |
| 17 |
|
|
| 18 |
/** |
/** |
| 19 |
* Page navigation support class |
* Page navigation support class |
|
* @package Mambo |
|
| 20 |
*/ |
*/ |
| 21 |
class mosPageNav { |
class mosPageNav { |
| 22 |
/** @var int The record number to start dislpaying from */ |
/** @var int The record number to start dislpaying from */ |
| 28 |
|
|
| 29 |
function mosPageNav( $total, $limitstart, $limit ) { |
function mosPageNav( $total, $limitstart, $limit ) { |
| 30 |
$this->total = intval( $total ); |
$this->total = intval( $total ); |
| 31 |
$this->limitstart = max( $limitstart, 0 ); |
$this->limitstart = max( intval($limitstart), 0 ); |
| 32 |
$this->limit = max( $limit, 0 ); |
$this->limit = max( intval($limit), 0 ); |
| 33 |
} |
} |
| 34 |
/** |
/** |
| 35 |
* Returns the html limit # input box |
* Returns the html limit # input box |
| 36 |
* @param string The basic link to include in the href |
* @param string The basic link to include in the href |
| 37 |
* @return string |
* @return string |
| 38 |
*/ |
*/ |
| 39 |
function getLimitBox ( $link ) { |
function getLimitBox () { |
| 40 |
$limits = array(); |
$limits = array(); |
| 41 |
for ($i=5; $i <= 30; $i+=5) { |
for ($i=5; $i <= 30; $i+=5) { |
| 42 |
$limits[] = mosHTML::makeOption( "$i" ); |
$limits[] = mosHTML::makeOption( "$i" ); |
| 43 |
} |
} |
| 44 |
$limits[] = mosHTML::makeOption( "50" ); |
$limits[] = mosHTML::makeOption( "50" ); |
| 45 |
|
$limits[] = mosHTML::makeOption( "100" ); |
| 46 |
|
$limits[] = mosHTML::makeOption( "500" ); |
| 47 |
|
$limits[] = mosHTML::makeOption( "1000" ); |
| 48 |
|
$limits[] = mosHTML::makeOption( "2500" ); |
| 49 |
|
$limits[] = mosHTML::makeOption( "5000" ); |
| 50 |
|
|
| 51 |
// build the html select list |
// build the html select list |
| 52 |
$link = sefRelToAbs($link.'&limit=\' + this.options[selectedIndex].value + \'&limitstart='.$this->limitstart); |
$html = mosHTML::selectList( $limits, 'limit', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', |
|
return mosHTML::selectList( $limits, 'limit', |
|
|
'class="inputbox" size="1" onchange="document.location.href=\''.$link.'\';"', |
|
| 53 |
'value', 'text', $this->limit ); |
'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 |
* Writes the html limit # input box |
| 73 |
$to_result = $this->total; |
$to_result = $this->total; |
| 74 |
} |
} |
| 75 |
if ($this->total > 0) { |
if ($this->total > 0) { |
| 76 |
$txt .= _PN_RESULTS." $from_result - $to_result "._PN_OF." $this->total"; |
$txt .= sprintf(T_('Results %d - %d of %d'), $from_result, $to_result, $this->total); |
| 77 |
} |
} |
| 78 |
return $txt; |
return $txt; |
| 79 |
} |
} |
| 85 |
$txt = ''; |
$txt = ''; |
| 86 |
$page = $this->limitstart+1; |
$page = $this->limitstart+1; |
| 87 |
if ($this->total > 0) { |
if ($this->total > 0) { |
| 88 |
$txt .= _PN_PAGE." $page "._PN_OF." $this->total"; |
$txt .= sprintf(T_('Page %d of %d'), $page, $this->total); |
| 89 |
} |
} |
| 90 |
return $txt; |
return $txt; |
| 91 |
} |
} |
| 95 |
* @param string The basic link to include in the href |
* @param string The basic link to include in the href |
| 96 |
*/ |
*/ |
| 97 |
function writePagesLinks( $link ) { |
function writePagesLinks( $link ) { |
| 98 |
|
|
| 99 |
|
// clean link - could be better filtered in rewrite |
| 100 |
|
// stops XSS |
| 101 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
| 102 |
|
$iFilter = new InputFilter( null, null, 1, 1 ); |
| 103 |
|
$link = trim( $iFilter->process( $link ) ); |
| 104 |
|
|
| 105 |
|
// Removing task breaks nagivation - temporarily removed for 4.6.2 release |
| 106 |
|
// For more information, See FS#127 |
| 107 |
|
// $link = preg_replace("/(task.*?)&/i", "", $link); |
| 108 |
|
|
| 109 |
$txt = ''; |
$txt = ''; |
| 110 |
|
|
| 111 |
$displayed_pages = 10; |
$displayed_pages = 10; |
| 122 |
|
|
| 123 |
if ($this_page > 1) { |
if ($this_page > 1) { |
| 124 |
$page = ($this_page - 2) * $this->limit; |
$page = ($this_page - 2) * $this->limit; |
| 125 |
$txt .= '<a href="'. sefRelToAbs( "$link&limitstart=0" ) .'" class="pagenav" title="first page"><< '. _PN_START .'</a> '; |
$txt .= '<a href="'. sefRelToAbs( "$link&limitstart=0" ) .'" class="pagenav" title="'.T_('first page').'"><< '. T_('Start') .'</a> '; |
| 126 |
$txt .= '<a href="'. sefRelToAbs( "$link&limitstart=$page" ) .'" class="pagenav" title="previous page">< '. _PN_PREVIOUS .'</a> '; |
$txt .= '<a href="'. sefRelToAbs( "$link&limitstart=$page" ) .'" class="pagenav" title="'.T_('previous page').'">< '. T_('Previous') .'</a> '; |
| 127 |
} else { |
} else { |
| 128 |
$txt .= '<span class="pagenav"><< '. _PN_START .'</span> '; |
$txt .= '<span class="pagenav"><< '. T_('Start') .'</span> '; |
| 129 |
$txt .= '<span class="pagenav">< '. _PN_PREVIOUS .'</span> '; |
$txt .= '<span class="pagenav">< '. T_('Previous') .'</span> '; |
| 130 |
} |
} |
| 131 |
|
|
| 132 |
for ($i=$start_loop; $i <= $stop_loop; $i++) { |
for ($i=$start_loop; $i <= $stop_loop; $i++) { |
| 141 |
if ($this_page < $total_pages) { |
if ($this_page < $total_pages) { |
| 142 |
$page = $this_page * $this->limit; |
$page = $this_page * $this->limit; |
| 143 |
$end_page = ($total_pages-1) * $this->limit; |
$end_page = ($total_pages-1) * $this->limit; |
| 144 |
$txt .= '<a href="'. sefRelToAbs( $link .'&limitstart='. $page ) .' " class="pagenav" title="next page">'. _PN_NEXT .' ></a> '; |
$txt .= '<a href="'. sefRelToAbs( $link .'&limitstart='. $page ) .' " class="pagenav" title="'.T_('next page').'">'. T_('Next') .' ></a> '; |
| 145 |
$txt .= '<a href="'. sefRelToAbs( $link .'&limitstart='. $end_page ) .' " class="pagenav" title="end page">'. _PN_END .' >></a>'; |
$txt .= '<a href="'. sefRelToAbs( $link .'&limitstart='. $end_page ) .' " class="pagenav" title="'.T_('end page').'">'. T_('End') .' >></a>'; |
| 146 |
} else { |
} else { |
| 147 |
$txt .= '<span class="pagenav">'. _PN_NEXT .' ></span> '; |
$txt .= '<span class="pagenav">'. T_('Next') .' ></span> '; |
| 148 |
$txt .= '<span class="pagenav">'. _PN_END .' >></span>'; |
$txt .= '<span class="pagenav">'. T_('End') .' >></span>'; |
| 149 |
} |
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
return $txt; |
return $txt; |
| 154 |
} |
} |
| 155 |
} |
} |