silverorange Code


Swat.SwatPagination
/Swat/SwatPagination.php at line 18

Class SwatPagination

SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatPagination

public class SwatPagination
extends SwatControl

A widget to allow navigation between paged data

SwatPagination pages start at page 1, not page 0.

Copyright:
2004-2007 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Field Summary
final mixed

NEXT

Display part constant for the displaying 'next' link.

final mixed

PAGES

Display part constant for displaying a list of pages close to the current page.

final mixed

POSITION

Display part constant for displaying a textual description of the current position.

final mixed

PREV

Display part constant for displaying the 'previous' link.

protected integer

$current_page

The current page number.

integer

$current_record

The index of the first record being displayed on the current page.

integer

$display_parts

Displayed pagination parts.

string

$link

The URI linked by this pagination widget.

string

$next_label

The text label displayed in the Next link.

protected integer

$next_page

The next page to display.

integer

$page_size

The number of records displayed on a page.

protected integer

$prev_page

The previous page to display.

string

$previous_label

The text label displayed in the Previous link.

protected integer

$total_pages

The total number of pages in the record set.

integer

$total_records

The total number of records that are available for display.

Constructor Summary

SwatPagination(string id)

Creates a new pagination widget.

Method Summary
private void

calculatePages()

Calculates page totals.

void

display()

Displays this pagination widget.

protected void

displayNext()

Displays the next page link.

protected void

displayPages()

Displays a smart list of pages.

protected void

displayPosition()

Displays the current page position.

protected void

displayPrev()

Displays the previous page link.

protected array

getCSSClassNames()

Gets the array of CSS classes that are applied to this pagination widget.

integer

getCurrentPage()

Get the current page that is displayed.

protected string

getLink()

Gets the base link for all page links.

string

getResultsMessage(mixed unit, mixed unit_plural, $unit_plural string)

Gets a human readable summary of the current state of this pagination widget.

void

setCurrentPage(integer page)

Set the current page that is displayed.

Methods inherited from Swat.SwatControl
addMessage, getNote, printWidgetTree
Methods inherited from Swat.SwatWidget
addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer
Methods inherited from Swat.SwatUIObject
addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible

Field Detail

/Swat/SwatPagination.php at line 25

NEXT

public final mixed NEXT = 1

Display part constant for the displaying 'next' link


/Swat/SwatPagination.php at line 42

PAGES

public final mixed PAGES = 8

Display part constant for displaying a list of pages close to the current page


/Swat/SwatPagination.php at line 36

POSITION

public final mixed POSITION = 4

Display part constant for displaying a textual description of the current position


/Swat/SwatPagination.php at line 30

PREV

public final mixed PREV = 2

Display part constant for displaying the 'previous' link


/Swat/SwatPagination.php at line 141

current_page

protected integer $current_page = 1

The current page number


/Swat/SwatPagination.php at line 76

current_record

public integer $current_record

The index of the first record being displayed on the current page


/Swat/SwatPagination.php at line 117

display_parts

public integer $display_parts

Displayed pagination parts

The display parts property is a bitwise combination of the SwatPagination::PREV, SwatPagination::NEXT, SwatPagination::PAGES and SwatPagination::POSITION constants.

For example, to show a pagination widget with just next and previous links use the following:

<?php
$pagination
->display_parts SwatPagination::PREV |
    
SwatPagination::NEXT;
?>

Defaults to SwatPagination::POSITION | SwatPagination::NEXT | SwatPagination::PREV | SwatPagination::PAGES.


/Swat/SwatPagination.php at line 55
public string $link = null

The URI linked by this pagination widget

The first sprintf placeholder (%s) in the URI will be replaced with the current page number. For example: "mydir/page%s".


/Swat/SwatPagination.php at line 85

next_label

public string $next_label

The text label displayed in the Next link

Defaults to "Next »".


/Swat/SwatPagination.php at line 127

next_page

protected integer $next_page

The next page to display


/Swat/SwatPagination.php at line 62

page_size

public integer $page_size = 20

The number of records displayed on a page


/Swat/SwatPagination.php at line 134

prev_page

protected integer $prev_page

The previous page to display


/Swat/SwatPagination.php at line 94

previous_label

public string $previous_label

The text label displayed in the Previous link

Defaults to "« Previous".


/Swat/SwatPagination.php at line 150

total_pages

protected integer $total_pages

The total number of pages in the record set

This is not the number of records in the record set.


/Swat/SwatPagination.php at line 69

total_records

public integer $total_records

The total number of records that are available for display


Constructor Detail

/Swat/SwatPagination.php at line 162

SwatPagination

public SwatPagination(string id)

Creates a new pagination widget

Parameters:
id - a non-visible unique id for this widget.
See Also:
SwatWidget::__construct()

Method Detail

/Swat/SwatPagination.php at line 460

calculatePages

private void calculatePages()

Calculates page totals

Sets the internal total_pages, next_page and prev_page properties.


/Swat/SwatPagination.php at line 230

display

public void display()

Displays this pagination widget


/Swat/SwatPagination.php at line 341

displayNext

protected void displayNext()

Displays the next page link


/Swat/SwatPagination.php at line 367

displayPages

protected void displayPages()

Displays a smart list of pages


/Swat/SwatPagination.php at line 324

displayPosition

protected void displayPosition()

Displays the current page position

i.e. "1 of 3"


/Swat/SwatPagination.php at line 297

displayPrev

protected void displayPrev()

Displays the previous page link


/Swat/SwatPagination.php at line 445

getCSSClassNames

protected array getCSSClassNames()

Gets the array of CSS classes that are applied to this pagination widget

Returns:
the array of CSS classes that are applied to this pagination widget.
See Also:
SwatUIObject::getCSSClassString()

/Swat/SwatPagination.php at line 286

getCurrentPage

public integer getCurrentPage()

Get the current page that is displayed

Returns:
The current page being displayed.

/Swat/SwatPagination.php at line 430

getLink

protected string getLink()

Gets the base link for all page links

Returns:
the base link for all pages.

/Swat/SwatPagination.php at line 195

getResultsMessage

public string getResultsMessage(mixed unit, mixed unit_plural, $unit_plural string)

Gets a human readable summary of the current state of this pagination widget

Parameters:
string - optional. The type of unit being returned. By default this is 'record'.
string - optional. The plural version of the $unit parameter. By default this is 'records'.
Returns:
a human readable summary of the current state of this pagination widget.

/Swat/SwatPagination.php at line 271

setCurrentPage

public void setCurrentPage(integer page)

Set the current page that is displayed

Calculates the current_record properties.

Parameters:
page - The current page being displayed.

silverorange Code