CWIS Developer Documentation
Public Member Functions | List of all members
ItemListUI Class Reference

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...
 

Detailed Description

Class to provide a user interface for displaying a list of items.

Definition at line 13 of file ItemListUI.php.

Constructor & Destructor Documentation

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.

Parameters
string$HeadingHeading text to be printed above list.
array$FieldsAssociative 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$ItemsPerPageMaximum number of items per page.
string$BaseLinkBase URL for current page for any links that need to be constructed.
int$SchemaIdMetadata 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().

Member Function Documentation

ItemListUI::AddActionButton (   $Label,
  $Link,
  $Icon = NULL,
  $DisplayTestFunc = NULL,
  $AdditionalAttributes = array() 
)

Add action "button" to each item in list.

Parameters
string$LabelLabel for button.
string$LinkURL 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$IconName of image file to display before the label. (OPTIONAL, defaults to no image)
callable$DisplayTestFuncFunction 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$AdditionalAttributesAdditional 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.

Parameters
string$LabelLabel for button.
string$LinkURL that button should link to.
string$IconName 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.

Parameters
string$LabelLabel for checkbox.
bool$CheckedIf TRUE, box should currently be checked.
string$VarNameName of variable to submit with form.
string$LinkURL 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.

Parameters
array$ItemsArray 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$TotalItemCountTotal number of items. (OPTIONAL, defaults to number of items passed in)
int$StartingIndexCurrent starting index. (OPTIONAL, defaults to value retrieved from $GET, or zero if no $GET value)
string$TransportMsgText 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.

Parameters
string$NewValueNew message.
Returns
string Current "no items" message.

Definition at line 156 of file ItemListUI.php.

& ItemListUI::TransportUI ( )

Get the transport controls UI component used by the item list.

Returns
object TransportControlsUI object.

Definition at line 169 of file ItemListUI.php.

Referenced by __construct(), and Display().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: