* @copyright 2003-2006 Lorenzo Alberton * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version CVS: $Id$ * @link http://pear.php.net/package/Pager */ /** * Two constants used to guess the path- and file-name of the page * when the user doesn't set any other value */ class Pager_HtmlWidgets { var $pager = null; // {{{ constructor function Pager_HtmlWidgets(&$pager) { $this->pager =& $pager; } // }}} // {{{ getPerPageSelectBox() /** * Returns a string with a XHTML SELECT menu, * useful for letting the user choose how many items per page should be * displayed. If parameter useSessions is TRUE, this value is stored in * a session var. The string isn't echoed right now so you can use it * with template engines. * * @param integer $start * @param integer $end * @param integer $step * @param boolean $showAllData If true, perPage is set equal to totalItems. * @param array (or string $optionText for BC reasons) * - 'optionText': text to show in each option. * Use '%d' where you want to see the number of pages selected. * - 'attributes': (html attributes) Tag attributes or * HTML attributes (id="foo" pairs), will be inserted in the * '; } if ($showAllData && $last != $this->pager->_totalItems) { $tmp .= ''; } $tmp .= ''; return $tmp; } // }}} // {{{ getPageSelectBox() /** * Returns a string with a XHTML SELECT menu with the page numbers, * useful as an alternative to the links * * @param array - 'optionText': text to show in each option. * Use '%d' where you want to see the number of pages selected. * - 'autoSubmit': if TRUE, add some js code to submit the * form on the onChange event * @param string $extraAttributes (html attributes) Tag attributes or * HTML attributes (id="foo" pairs), will be inserted in the * pager->_httpMethod == 'GET') { $selector = '\' + '.'this.options[this.selectedIndex].value + \''; if ($this->pager->_append) { $href = '?' . $this->pager->_http_build_query_wrapper($this->pager->_linkData); $href = htmlentities($this->pager->_url). preg_replace( '/(&|&|\?)('.$this->pager->_urlVar.'=)(\d+)/', '\\1\\2'.$selector, htmlentities($href) ); } else { $href = htmlentities($this->pager->_url . str_replace('%d', $selector, $this->pager->_fileName)); } $tmp .= ' onchange="document.location.href=\'' . $href .'\'' . '"'; } elseif ($this->pager->_httpMethod == 'POST') { $tmp .= " onchange='" . $this->pager->_generateFormOnClick($this->pager->_url, $this->pager->_linkData) . "'"; $tmp = preg_replace( '/(input\.name = \"'.$this->pager->_urlVar.'\"; input\.value =) \"(\d+)\";/', '\\1 this.options[this.selectedIndex].value;', $tmp ); } } $tmp .= '>'; $start = 1; $end = $this->pager->numPages(); $selected = $this->pager->getCurrentPageID(); for ($i=$start; $i<=$end; $i++) { $tmp .= '