Documentation

ItemList
in package
implements ArrayAccess uses ArrayAccessHelper

This class provides a standard way of displaying lists for SMF.

Table of Contents

Interfaces

ArrayAccess

Properties

$additional_rows  : array<string|int, mixed>
$form  : array<string|int, mixed>
$headers  : array<string|int, mixed>
$id  : string
$items_per_page  : int
$javascript  : string
$no_items_align  : string
$no_items_label  : string
$num_columns  : int
$page_index  : string
$rows  : array<string|int, mixed>
$sort  : array<string|int, mixed>
$start  : int
$start_var_name  : string
$title  : string
$total_num_items  : int
$width  : string
$db_sort  : string
$items  : array<string|int, mixed>
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
Create a new list.
load()  : self
Static wrapper for constructor.
offsetExists()  : bool
Checks whether a property has been set when object is accessed as an array.
offsetGet()  : mixed
Gets properties when object is accessed as an array.
offsetSet()  : void
Sets properties when object is accessed as an array.
offsetUnset()  : void
Unsets properties when object is accessed as an array.
buildAdditionalRows()  : void
A list can sometimes need a few extra rows above and below.
buildForm()  : void
In case there's a form, share it with the template context.
buildHeaders()  : void
Builds the table headers for this list.
buildPageIndex()  : void
Creates the page index, if necessary.
buildRows()  : void
Builds the table rows for the list items.
checkOptions()  : bool
Checks whether $options provides enough data to make a list.
getItems()  : void
Gets the list items from the database.
setBasics()  : void
Handles some list properties that can be set directly from the options.
setSort()  : void
Figure out the sort.
setStartAndItemsPerPage()  : void
Figures out $this->start and $this->items_per_page.

Properties

$additional_rows

public array<string|int, mixed> $additional_rows = []

Additional rows to wrap around this lis.

$form

public array<string|int, mixed> $form

Info about the HTML form for this list.

$headers

public array<string|int, mixed> $headers = []

Table headers.

$id

public string $id

The list's identifier string.

$items_per_page

public int $items_per_page = 0

How many items to put on each page of the list.

$javascript

public string $javascript

Any JavaScript to add for this list.

$no_items_align

public string $no_items_align

CSS class for the empty list message. E.g.: 'centertext', 'lefttext', etc.

$no_items_label

public string $no_items_label

Message to show when the list is empty.

$num_columns

public int $num_columns

The number of columns in this list.

$page_index

public string $page_index

The page index for navigating this list.

$rows

public array<string|int, mixed> $rows = []

Table rows for the items in the list.

$sort

public array<string|int, mixed> $sort = []

Info about how this list is sorted.

$start

public int $start = 0

Where the current page of the list begins.

$start_var_name

public string $start_var_name = 'start'

URL parameter that indicates where to start current page of the list.

$title

public string $title

The title of this list. Optional.

$total_num_items

public int $total_num_items

How many items are in the entire list.

$width

public string $width

CSS width for the table. Optional.

$db_sort

protected string $db_sort = '1=1'

Value for the ORDER BY clause.

$items

protected array<string|int, mixed> $items = []

The items retrieved from the database.

$options

protected array<string|int, mixed> $options = []

The list options passed to the constructor.

Methods

__construct()

Create a new list.

public __construct(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

An array of options for the list - 'id', 'columns', 'items_per_page', 'get_count', etc.

load()

Static wrapper for constructor.

public static load(array<string|int, mixed> $options) : self
Parameters
$options : array<string|int, mixed>

Same as for the constructor.

Return values
self

An instance of this class.

offsetExists()

Checks whether a property has been set when object is accessed as an array.

public offsetExists(mixed $prop) : bool
Parameters
$prop : mixed

The property name.

Return values
bool

offsetGet()

Gets properties when object is accessed as an array.

public & offsetGet(mixed $prop) : mixed
Parameters
$prop : mixed

The property name.

Return values
mixed

A reference to the property.

offsetSet()

Sets properties when object is accessed as an array.

public offsetSet(mixed $prop, mixed $value) : void
Parameters
$prop : mixed

The property name.

$value : mixed

The value to set.

offsetUnset()

Unsets properties when object is accessed as an array.

public offsetUnset(mixed $prop) : void
Parameters
$prop : mixed

The property name.

buildAdditionalRows()

A list can sometimes need a few extra rows above and below.

protected buildAdditionalRows() : void

buildForm()

In case there's a form, share it with the template context.

protected buildForm() : void

buildHeaders()

Builds the table headers for this list.

protected buildHeaders() : void

buildPageIndex()

Creates the page index, if necessary.

protected buildPageIndex() : void

buildRows()

Builds the table rows for the list items.

protected buildRows() : void

checkOptions()

Checks whether $options provides enough data to make a list.

protected checkOptions(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>

Same as for the constructor.

Return values
bool

Whether we can build a list with this data.

getItems()

Gets the list items from the database.

protected getItems() : void

setBasics()

Handles some list properties that can be set directly from the options.

protected setBasics() : void

setSort()

Figure out the sort.

protected setSort() : void

setStartAndItemsPerPage()

Figures out $this->start and $this->items_per_page.

protected setStartAndItemsPerPage() : void

If $this->items_per_page > 0, also figures out $this->total_num_items.


        
On this page

Search results