CWIS Developer Documentation
|
Class to provide a user interface for displaying a list of items. More...
Public Member Functions | |
__construct ($Fields, $SchemaId=TransportControlsUI::NO_ITEM_TYPE) | |
Constructor for item list UI class. More... | |
BaseLink ($NewValue=NULL) | |
Get/set base URL for current page, for any links that need to be constructed. More... | |
VariablesToPreserve ($NewValue=NULL) | |
Get/set list of $_GET variables to preserve by adding them to base link whenever it is used. More... | |
GetFullBaseLink () | |
Get full base link, including any variables to preserve. More... | |
Heading ($NewValue=NULL) | |
Get/set heading text to be printed above list. More... | |
ItemsPerPage ($NewValue=NULL) | |
Get/set maximum number of items per page. More... | |
AddTopButton ($Label, $Link, $Icon=NULL) | |
Add "button" above list. More... | |
AddTopCheckbox ($Label, $Checked, $VarName, $Link) | |
Add "checkbox" above list. More... | |
AddActionButton ($Label, $Link, $Icon=NULL, $DisplayTestFunc=NULL, $AdditionalAttributes=array()) | |
Add action "button" to each item in list. More... | |
NoItemsMessage ($NewValue=NULL) | |
Get/set message to display when there are no items to list. More... | |
& | TransportUI () |
Get the transport controls UI component used by the item list. More... | |
Display ($Items, $TotalItemCount=NULL, $StartingIndex=NULL, $TransportMsg=NULL) | |
Print list HTML with specified items. More... | |
Class to provide a user interface for displaying a list of items.
Definition at line 13 of file ItemListUI.php.
ItemListUI::__construct | ( | $Fields, | |
$SchemaId = TransportControlsUI::NO_ITEM_TYPE |
|||
) |
Constructor for item list UI class.
Possible values in the $Fields parameter: AllowHTML - if defined, values from the field will not have HTML characters escaped before the value is displayed DefaultSortField - if defined, will mark field as being the default sort field DefaultToDescendingSort - if defined, will mark field as defaulting to descending (as opposed to ascending) sort order Heading - heading text for field column (if not supplied, the field name is used), Link - URL to which to link the field content (if present, $ID will be replaced with the field ID), MaxLength - maximum length in characters for the field text, NoSorting - if defined, sorting will not be available for the field. ValueFunction - callback that accepts an item and field name, and returns the value to be printed. LinkFunction - callback that accepts an item, and returns the value of the link or FALSE, if no url is to be linked.
array | $Fields | Associative array of associative arrays of information about fields to be displayed, with metadata field IDs or item method names for the index and possible values as above. |
int | $SchemaId | Metadata schema ID for items. (OPTIONAL) |
Definition at line 42 of file ItemListUI.php.
References BaseLink(), TransportControlsUI_Base\DefaultSortField(), MetadataSchema\GetCanonicalFieldIdentifier(), ItemsPerPage(), TransportControlsUI_Base\NO_ITEM_TYPE, and TransportUI().
ItemListUI::AddActionButton | ( | $Label, | |
$Link, | |||
$Icon = NULL , |
|||
$DisplayTestFunc = NULL , |
|||
$AdditionalAttributes = array() |
|||
) |
Add action "button" to each item in list.
string | $Label | Label for button. |
string | $Link | URL that button should link to, with $ID optionally in the string to indicate where the item ID should be inserted, or a function that is passed the item and should return the URL. |
string | $Icon | Name of image file to display before the label. (OPTIONAL, defaults to no image) |
callable | $DisplayTestFunc | Function that is passed the item, and should return TRUE if the buttons should be displayed for that item, and FALSE otherwise. (OPTIONAL, defaults to NULL, which will call "UserCanEdit()" method on item, if available, with current active user (G_User)) |
array | $AdditionalAttributes | Additional attributes to add to the button, with HTML attribute name for the index and attribute value for the value. (OPTIONAL) |
Definition at line 211 of file ItemListUI.php.
ItemListUI::AddTopButton | ( | $Label, | |
$Link, | |||
$Icon = NULL |
|||
) |
Add "button" above list.
string | $Label | Label for button. |
string | $Link | URL that button should link to. |
string | $Icon | Name of image file to display before the label. (OPTIONAL, defaults to no image) |
Definition at line 161 of file ItemListUI.php.
ItemListUI::AddTopCheckbox | ( | $Label, | |
$Checked, | |||
$VarName, | |||
$Link | |||
) |
Add "checkbox" above list.
When the checkbox is changed, the URL provided in $Link is jumped to, with the correct value set for $VarName appended.
string | $Label | Label for checkbox. |
bool | $Checked | If TRUE, box should currently be checked. |
string | $VarName | Name of variable to submit with form. |
string | $Link | URL that form should submit to if box is toggled. If $VarName variable is present in the URL ($_GET) parameters, it will be removed. |
Definition at line 180 of file ItemListUI.php.
ItemListUI::BaseLink | ( | $NewValue = NULL | ) |
Get/set base URL for current page, for any links that need to be constructed.
string | $NewValue | New base URL, with any ampersands encoded as entities (&). (OPTIONAL) |
Definition at line 84 of file ItemListUI.php.
Referenced by __construct().
ItemListUI::Display | ( | $Items, | |
$TotalItemCount = NULL , |
|||
$StartingIndex = NULL , |
|||
$TransportMsg = NULL |
|||
) |
Print list HTML with specified items.
If an array of items objects is passed in, the item IDs in the array index are only used if the objects do not have an Id() method.
array | $Items | Array of item objects or array of associative arrays, with item IDs for the base index and (if an array of arrays) field IDs for the associative array indexes. |
int | $TotalItemCount | Total number of items. (OPTIONAL, defaults to number of items passed in) |
int | $StartingIndex | Current starting index. (OPTIONAL, defaults to value retrieved from $GET, or zero if no $GET value) |
string | $TransportMsg | Text to display on transport control line. (OPTIONAL, defaults to "Items X - Y of Z") |
Definition at line 260 of file ItemListUI.php.
References $Items, GetFullBaseLink(), MetadataSchema\GetPrintableFieldName(), Heading(), StdLib\NeatlyTruncateString(), TransportControlsUI_Base\NO_ITEM_TYPE, PHP, StdLib\Pluralize(), and TransportUI().
ItemListUI::GetFullBaseLink | ( | ) |
Get full base link, including any variables to preserve.
Definition at line 112 of file ItemListUI.php.
References VariablesToPreserve().
Referenced by Display().
ItemListUI::Heading | ( | $NewValue = NULL | ) |
Get/set heading text to be printed above list.
string | $NewValue | New heading text. (OPTIONAL) |
Definition at line 130 of file ItemListUI.php.
Referenced by Display().
ItemListUI::ItemsPerPage | ( | $NewValue = NULL | ) |
Get/set maximum number of items per page.
string | $NewValue | New max number of items per page. (OPTIONAL) |
Definition at line 144 of file ItemListUI.php.
References TransportUI().
Referenced by __construct().
ItemListUI::NoItemsMessage | ( | $NewValue = NULL | ) |
Get/set message to display when there are no items to list.
string | $NewValue | New message. |
Definition at line 228 of file ItemListUI.php.
& ItemListUI::TransportUI | ( | ) |
Get the transport controls UI component used by the item list.
Definition at line 241 of file ItemListUI.php.
Referenced by __construct(), Display(), and ItemsPerPage().
ItemListUI::VariablesToPreserve | ( | $NewValue = NULL | ) |
Get/set list of $_GET variables to preserve by adding them to base link whenever it is used.
array | $NewValue | Array of $_GET variable names. (OPTIONAL) |
Definition at line 99 of file ItemListUI.php.
Referenced by GetFullBaseLink().