CWIS Developer Documentation
|
Class to provide a user interface for displaying a list of items. More...
Public Member Functions | |
__construct ($Heading, $Fields, $ItemsPerPage, $BaseLink, $SchemaId=TransportControlsUI::NO_ITEM_TYPE) | |
Constructor for item list UI class. 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 | ( | $Heading, | |
$Fields, | |||
$ItemsPerPage, | |||
$BaseLink, | |||
$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.
string | $Heading | Heading text to be printed above list. |
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 | $ItemsPerPage | Maximum number of items per page. |
string | $BaseLink | Base URL for current page for any links that need to be constructed. |
int | $SchemaId | Metadata schema ID for items. (OPTIONAL) |
Definition at line 46 of file ItemListUI.php.
References TransportControlsUI_Base\DefaultSortField(), MetadataSchema\GetCanonicalFieldIdentifier(), 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 139 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 89 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 108 of file ItemListUI.php.
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 188 of file ItemListUI.php.
References $Items, MetadataSchema\GetPrintableFieldName(), StdLib\NeatlyTruncateString(), TransportControlsUI_Base\NO_ITEM_TYPE, PHP, StdLib\Pluralize(), and TransportUI().
ItemListUI::NoItemsMessage | ( | $NewValue = NULL | ) |
Get/set message to display when there are no items to list.
string | $NewValue | New message. |
Definition at line 156 of file ItemListUI.php.
& ItemListUI::TransportUI | ( | ) |
Get the transport controls UI component used by the item list.
Definition at line 169 of file ItemListUI.php.
Referenced by __construct(), and Display().