Class mr_html_table

Description

MR HTML Table

Used to generate a HTML table with sorting.

Located in /html/table.php (line 51)

mr_readonly
   |
   --mr_html_table
Variable Summary
array $attributes
string $cachekey
mr_html_table_column[] $columns
string $defaultorder
string $defaultsort
string $emptymessage
string $order
array $rows
string $sort
boolean $sortenabled
moodle_url $url
Method Summary
mr_html_table __construct (mr_preferences $preferences,  $url, [string $sort = ''], [int|string $order = SORT_ASC])
mr_html_table add_column (mixed $name, [string $heading = ''], [array $config = array()])
mr_html_table add_column_type (string $type, string $name, [string $heading = ''], [array $config = array()])
mr_html_table add_format (mixed $columns, string $format, mixed $x)
mr_html_table add_row (mixed $row)
boolean cached ()
array extract_data (mixed $row)
mr_html_table_column[] get_columns ([boolean $visible = false])
string get_sql_select ()
string get_sql_sort ()
void save_sortorder ()
mr_html_table set_attributes (array $attributes)
mr_html_table set_cachekey (string $key)
mr_html_table set_emptymessage (string $emptymessage)
mr_html_table set_order (string $order)
mr_html_table set_sort (string $sort)
string __toString ()
Variables
array $attributes = array() (line 67)

Table attributes

  • access: protected
string $cachekey = NULL (line 147)

Cache ID to use

  • access: protected
mr_html_table_column[] $columns = array() (line 74)

Columns

  • access: protected
string $defaultorder (line 116)

The table's default order

  • access: protected
string $defaultsort (line 102)

The table's default sort

  • access: protected
string $emptymessage (line 130)

Message to display when table is empty

  • access: protected
mr_file_export $export (line 140)

Export class

When set through set_export(), then rows are routed to this export class.

  • access: protected
mr_helper $helper (line 161)

Helper model

  • access: protected
string $order (line 109)

Current sort order

  • access: protected
mr_preferences $preferences (line 154)

Preferences model

  • access: protected
mixed $REQUEST_ORDER = 'torder' (line 60)

Sort order request param

  • access: public
mixed $REQUEST_SORT = 'tsort' (line 55)

Sort request param

  • access: public
array $rows = array() (line 81)

Table rows

  • access: protected
string $sort (line 95)

Current sort

  • access: protected
boolean $sortenabled = true (line 88)

Sort enabled flag

  • access: protected
moodle_url $url (line 123)

Base URL

  • access: protected
Methods
Constructor __construct (line 171)

Setup

  • access: public
mr_html_table __construct (mr_preferences $preferences,  $url, [string $sort = ''], [int|string $order = SORT_ASC])
  • mr_preferences $preferences: User preferences
  • moodle_url $url: Base url
  • string $sort: Sorting field
  • int|string $order: Sorting order
add_column (line 434)

Add a table column

  • access: public
mr_html_table add_column (mixed $name, [string $heading = ''], [array $config = array()])
  • mixed $name: Column SQL field name (see mr_html_table_column) OR an instance of mr_html_table_column. If the latter, than $heading and $config are ignored.
  • string $heading: Column heading
  • array $config: Column configuration
add_column_type (line 456)

Add a table column. This method is a shortcut for adding different column types. Types are listed in html/table/column/

  • access: public
mr_html_table add_column_type (string $type, string $name, [string $heading = ''], [array $config = array()])
  • string $type: The column type
  • string $name: Column SQL field name (see mr_html_table_column)
  • string $heading: Column heading
  • array $config: Column configuration
add_format (line 471)

Add column format

  • throws: coding_exception
  • access: public
mr_html_table add_format (mixed $columns, string $format, mixed $x)
  • mixed $columns: Column name(s) to apply the format to
  • string $format: Format name or mr_format_abstract
  • mixed $x: Keep passing params to pass to the format's constructor
add_row (line 494)

Add a row

  • access: public
mr_html_table add_row (mixed $row)
  • mixed $row: Table row of data
cached (line 318)

Is the table cached for this request or not

  • access: public
boolean cached ()
disable_sort (line 410)

Disable sorting

  • access: public
mr_html_table disable_sort ()
extract_data (line 516)

Extract column data from a row while trying to keep everything in the same order as the columns. Generally, don't need to call this method unless you are micro managing an export.

  • access: public
array extract_data (mixed $row)
  • mixed $row: Can be an object, array or html_table_row (if this, then ensure proper cell ordering!)
get_columns (line 335)

Gets all table columns

This will expand dynamic columns and include all of the returned columns into the standard set.

  • access: public
mr_html_table_column[] get_columns ([boolean $visible = false])
  • boolean $visible: Return only columns that are visible to the user
get_sql_select (line 360)

Get select fields from the columns

  • access: public
string get_sql_select ()
get_sql_sort (line 376)

Get sort SQL

  • throws: coding_exception
  • access: public
string get_sql_sort ()
save_sortorder (line 208)

Store sort and weight based on current settings

  • access: protected
void save_sortorder ()
set_attributes (line 256)

Add or override table attributes

  • access: public
mr_html_table set_attributes (array $attributes)
  • array $attributes: An array of attribute/value pairings
set_cachekey (line 308)

Set the cache ID

  • access: public
mr_html_table set_cachekey (string $key)
  • string $key: The key to set
set_emptymessage (line 268)

Set the message for when the table is empty

  • access: public
mr_html_table set_emptymessage (string $emptymessage)
  • string $emptymessage: The message to set
set_export (line 282)

Set the export instance

Table will send all rows to the plugin instead of itself

  • access: public
mr_html_table set_export (mr_file_export $export)
set_order (line 244)

Set the direction of the sorting

  • access: public
mr_html_table set_order (string $order)
  • string $order
set_sort (line 232)

Set the sorting column

  • access: public
mr_html_table set_sort (string $sort)
  • string $sort
__toString (line 199)

Convert this table into a simple string

  • access: public
string __toString ()

Inherited Methods

Inherited From mr_readonly

mr_readonly::__call()

Documentation generated on Thu, 28 Jun 2012 16:33:52 -0700 by phpDocumentor 1.4.3