CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

Parameters

  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 44 of file ItemListUI.php.

References MetadataSchema\GetCanonicalFieldIdentifier(), and TransportControlsUI_Base\NO_ITEM_TYPE.

## Member Function Documentation

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

Add action "button" to each item in list.

Parameters

  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 101 of file ItemListUI.php.

ItemListUI::AddTopButton | ( |  | $Label,
|  |  | $Link,
|  |  | $Icon = `NULL`
| ) |  |

Add "button" above list.

Parameters

  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 76 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 | $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 141 of file ItemListUI.php.

References $Items, TransportControlsUI_Base\DefaultSortField(), MetadataSchema\GetPrintableFieldName(), TransportControlsUI_Base\NO_ITEM_TYPE, PHP, and StdLib\Pluralize().

ItemListUI::NoItemsMessage | ( |  | $NewValue = `NULL` | ) |

Get/set message to display when there are no items to list.

Parameters

  string | $NewValue | New message.

Returns
  string Current "no items" message.

Definition at line 118 of file ItemListUI.php.

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

- interface/default/objects/ItemListUI.php