Sitellite Application Framework
Class Tree         Index         All Elements

Class: Pager

Source Location: Program_Root/GUI/Pager.php

Class Overview


Pager is a list paging package (ie. " Previous Page | 1 | 2 | 3 | Next Page >>").


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 46]
Pager is a list paging package (ie. " Previous Page | 1 | 2 | 3 | Next Page >>").

It is very easy to use, and also includes numerous convenience templates that can be built off of or used directly so that very little code or markup is needed.




[ Top ]


Class Variables

$url =

[line 50]

URL prefix for pager links.


Type:   mixed


[ Top ]



Class Methods


constructor Pager [line 103]

Pager Pager( [integer $offset = 0], [integer $limit = 20], [integer $total = 0], [integer $maxPages = 5])

Constructor method.


1 <?php
2
3 loader_import ('saf.GUI.Pager');
4
5 $pg = new Pager (
6 cgi_param ('offset'),
7 10 // limit
8 );
9 if (! $pg->query ('select * from some_table')) {
10 die ($pg->error);
11 }
12
13 $pg->url = '/index/myapp-somelist-action';
14
15 $template = '<!-- use one of the built-in pager templates -->
16 <p id="pager">{spt PAGER_TEMPLATE_PAGE_LIST}</p>
17 {alt #eee #fff}
18 <table border="0" cellpadding="3">
19 {filter ucwords}
20 <tr style="background-color: {alt/next}">
21 <th>#</th>
22 {loop array_keys (get_object_vars (pager.results[0]))}
23 <th>{loop/_value}</th>
24 {end loop}
25 </tr>
26 {end filter}
27 {loop pager.results}
28 <tr style="background-color: {alt/next}">
29 <td>{loop/_index}</td>
30 {loop loop._properties}
31 <td>{loop/_value}</td>
32 {end loop}
33 </tr>
34 {end loop}
35 </table>';
36
37 template_simple_register ('pager', $pg);
38 echo template_simple ($template);
39
40 ? >




Parameters:

integer   $offset  
integer   $limit  
integer   $total  
integer   $maxPages  

[ Top ]

method getInfo [line 126]

array getInfo( )

Calculates the pager info and returns it as an associative array.

Also stores it internally as properties of the object, for use in the included simple templates.




Tags:

return:  hash


[ Top ]

method getPages [line 213]

array getPages( [mixed $max = true])

Creates a two-dimensional array of pages to be displayed. The inner arrays contain the following keys:

  • page (page number)
  • offset (offset of this page)
  • separator (boolean, whether to display a separator next to this page or not)
  • current (boolean, whether this is the currently active page)




[ Top ]

method query [line 274]

array query( string $sql, [mixed $bind = false])

Returns a database query's results, limited by Pager's current $limit and $offset settings. Also sets the $total property and calls getInfo().



Tags:

return:  of objects


Parameters:

string   $sql   sql query
mixed   $bind   bind values

[ Top ]

method setData [line 310]

void setData( array &$data)

This method allows you to set external data instead of using the query() method. Note that you must set $total and call update() yourself after calling this method.



Parameters:

array   &$data   of objects

[ Top ]

method setUrl [line 347]

void setUrl( string $url, mixed 1)

Special setter for the $url property. Accepts a variable number

of arguments, the first of which is the format string (the URL itself with %s as placeholders for values). The arguments to pass to the format string (uses vsprintf() to do so) can be specified in one of three ways:

  • by passing an array as the 2nd parameter
  • by passing an object as the 2nd parameter (which is then cast into an array for you)
  • by passing an arbitrary number of additional parameters separately.
The benefit here is that the arguments are sent through the urlencode() function before being inserted into the URL string, which adds some extra semi-automatic security pour tous.




Parameters:

mixed   1   array or object or a variable number of arguments
string   $url  

[ Top ]

method update [line 198]

array update( )

Alias for getInfo().



Tags:

return:  hash


[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:18:30 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2