PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » Pager » Bug #7283

proposals to getPerPageSelectBox

Details

Request #7283proposals to getPerPageSelectBox
Submitted2006-04-03 14:11 UTC
Fromkmh496 at kornet dot net
Assignedquipo
StatusClosed
PackagePager
PHP Version5.0.5
OSRH fedora 4
Roadmaps(Not assigned)

Comments

[2006-04-03 14:11 UTC] kmh496 at kornet dot net

Description:
------------
I am using the Pager class to page through results of a data set as you
can see by looking at
http://www.myowndictionary.com/index.php?cfile=dict_pager&old_cfile=skip&browse_todo=1&from_lang=english&to_lang=english

so I have used it frequently.

the pager class has a function called getPagePerSelectBox which allows
you to change the size of the window of the results from the DB query
which are visible.

I have some improvements made externally to the Pager module which the
maintainer may decide to incorporate into this already tight little
package....

1. add a onChange to the select box form element
2. change max value in the select box to not exceed the max number of
elements in the form.

note: i make my own form just for the select box

-----------------1-------------------------
it is helpful to include the following javascript code to send the
select box form automatically when it is changed.

<script type="text/javascript" language=JavaScript>

function submit_setPerPage(f)
{
// another javascript function dead in the water, except for firefox
var check = false;
var new_entrant = 0;
var display_size = 0;
var offset = <?=$offset?>;
display_size = f.setPerPage.selected;
f.setPerPage = f.setPerPage.selected;
if (offset < display_size ) {
new_entrant=1;
} else {
new_entrant = Math.floor(display_size / offset);
}
f.entrant= new_entrant;
// alert('entrant='+new_entrant+' and display_size='+display_size);
f.action = "index.php";
f.submit();
}

however, that doesn't work in windows.

i found in windows machine.

// javascript broken on MSIE
require_once('lib/browser.php');^M
// File name: browser.php
// Author: Gary White
// Last modified: November 10, 2003
$br = new Browser;^M
if ((strpos($br->Platform, "indow")>-1) ||
strpos($br->Name,"MSIE")>-1) {
$selectBox .= "<input type=submit value='change'>  ";
}

I then wrap the select in form tags.
startForm('setPerPage',$bo_table,$wr_id,
$entrant,0,'dict_pager','index.php') ;
// startForm includes common variables in all my forms for me :)
echo $selectBox;
?>  
</form>

------------- 2-----------------------

get $max_from_db_table by issuing a count(*) query externally to the
pager class, but there is a pager method numItems method for the Pager
class which may do the same thing.

$optionArr = array(5,10,15,20,25,30);
foreach ($optionArr as $option) {
if ($option == $items_per_page) {
$max_option = $option;
$selectBox .= "<option value='$option'
selected='selected'>$option</option>";
} else {
$max_option = $option;
$selectBox .= "<option value='$option'>$option</option>";
}
if ( $option >= $max_from_db_table ) break; /// it breaks
when you send more than will fit
/// it would have to start at a non-existing number
}
$selectBox .= "</select>  ";
// javascript broken on my MSIE win2k comptuer
require_once('lib/browser.php');^M
$br = new Browser;^M
if ((strpos($br->Platform, "indow")>-1) ||
strpos($br->Name,"MSIE")>-1) {
$selectBox .= "<input type=submit value='change'>  ";
}
// function getPerPageSelectBox($start=5, $end=30, $step=5,
$showAllData=false, $extraParams=array())
$selectBox = $selectBox_opening . $pager->getPerPageSelectBox(5,
$max_option,5,true);
}

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php