Moodle  2.2.1
http://www.collinsharper.com
flexible_table Class Reference
Inheritance diagram for flexible_table:

Public Member Functions

 __construct ($uniqueid)
 flexible_table ($uniqueid)
 is_downloading ($download=null, $filename='', $sheettitle='')
 export_class_instance ($exportclass=null)
 is_downloadable ($downloadable=null)
 show_download_buttons_at ($showat)
 sortable ($bool, $defaultcolumn=NULL, $defaultorder=SORT_ASC)
 no_sorting ($column)
 is_sortable ($column=null)
 collapsible ($bool)
 pageable ($bool)
 initialbars ($bool)
 pagesize ($perpage, $total)
 set_control_variables ($variables)
 set_attribute ($attribute, $value)
 column_suppress ($column)
 column_class ($column, $classname)
 column_style ($column, $property, $value)
 column_style_all ($property, $value)
 define_baseurl ($url)
 define_columns ($columns)
 define_headers ($headers)
 setup ()
 get_sql_sort ()
 get_sort_columns ()
 get_page_start ()
 get_page_size ()
 get_sql_where ()
 add_data_keyed ($rowwithkeys, $classname= '')
 add_separator ()
 add_data ($row, $classname= '')
 finish_output ($closeexportclassdoc=true)
 wrap_html_start ()
 wrap_html_finish ()
 format_row ($row)
 col_fullname ($row)
 other_cols ($column, $row)
 format_text ($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL)
 print_html ()
 get_initial_first ()
 get_initial_last ()
 print_initials_bar ()
 print_nothing_to_display ()
 get_row_from_keyed ($rowwithkeys)
 get_download_menu ()
 download_buttons ()
 start_output ()
 print_row ($row, $classname= '')
 finish_html ()
 print_headers ()
 start_html ()
 make_styles_string ($styles)

Static Public Member Functions

static get_sort_for_table ($uniqueid)
static construct_order_by ($cols)

Data Fields

 $uniqueid = NULL
 $attributes = array()
 $headers = array()
 $columns = array()
 $column_style = array()
 $column_class = array()
 $column_suppress = array()
 $column_nosort = array('userpic')
 $setup = false
 $sess = NULL
 $baseurl = NULL
 $request = array()
 $is_collapsible = false
 $is_sortable = false
 $use_pages = false
 $use_initials = false
 $maxsortkeys = 2
 $pagesize = 30
 $currpage = 0
 $totalrows = 0
 $sort_default_column = NULL
 $sort_default_order = SORT_ASC
 $showdownloadbuttonsat = array(TABLE_P_TOP)
 $useridfield = 'id'
 $download = ''
 $downloadable = false
 $defaultdownloadformat = 'csv'
 $started_output = false
 $exportclass = null

Protected Member Functions

 print_one_initials_bar ($alpha, $current, $class, $title, $urlvar)
 show_hide_link ($column, $index)
 sort_icon ($isprimary, $order)
 sort_order_name ($isprimary, $order)
 sort_link ($text, $column, $isprimary, $order)

Detailed Description

Definition at line 53 of file tablelib.php.


Constructor & Destructor Documentation

__construct ( uniqueid)

Constructor

Parameters:
int$uniqueidall tables have to have a unique id, this is used as a key when storing table properties like sort order in the session.

Reimplemented in table_sql, and quiz_report_statistics_question_table.

Definition at line 122 of file tablelib.php.

Here is the caller graph for this function:


Member Function Documentation

add_data ( row,
classname = '' 
)

This method actually directly echoes the row passed to it now or adds it to the download. If this is the first row and start_output has not already been called this method also calls start_output to open the table or send headers for the downloaded. Can be used as before. print_html now calls finish_html to close table.

Parameters:
array$rowa numerically keyed row of data to add to the table.
string$classnameCSS class name to add to this row's tr tag.
Returns:
bool success.

Definition at line 653 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

add_data_keyed ( rowwithkeys,
classname = '' 
)

Add a row of data to the table. This function takes an array with column names as keys. It ignores any elements with keys that are not defined as columns. It puts in empty strings into the row when there is no element in the passed array corresponding to a column in the table. It puts the row elements in the proper order.

Parameters:
$rowwithkeysarray
string$classnameCSS class name to add to this row's tr tag.

Definition at line 628 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Add a seperator line to table.

Definition at line 635 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

col_fullname ( row)

Fullname is treated as a special columname in tablelib and should always be treated the same as the fullname of a user. $this->useridfield if the userid field is not expected to be id then you need to override $this->useridfield to point at the correct field for the user id.

Reimplemented in quiz_attempt_report_table.

Definition at line 734 of file tablelib.php.

Here is the call graph for this function:

collapsible ( bool)

Sets the is_collapsible variable to the given boolean.

Parameters:
bool$bool
Returns:
void

Definition at line 256 of file tablelib.php.

Here is the caller graph for this function:

column_class ( column,
classname 
)

Sets the given $column index to the given $classname in $this->column_class.

Parameters:
int$column
string$classname
Returns:
void

Definition at line 336 of file tablelib.php.

Here is the caller graph for this function:

column_style ( column,
property,
value 
)

Sets the given $column index and $property index to the given $value in $this->column_style.

Parameters:
int$column
string$property
mixed$value
Returns:
void

Definition at line 349 of file tablelib.php.

Here is the caller graph for this function:

column_style_all ( property,
value 
)

Sets all columns' $propertys to the given $value in $this->column_style.

Parameters:
int$property
string$value
Returns:
void

Definition at line 361 of file tablelib.php.

Here is the call graph for this function:

column_suppress ( column)

What this method does is set the column so that if the same data appears in consecutive rows, then it is not repeated.

For example, in the quiz overview report, the fullname column is set to be suppressed, so that when one student has made multiple attempts, their name is only printed in the row for their first attempt.

Parameters:
int$columnthe index of a column.

Definition at line 324 of file tablelib.php.

Here is the caller graph for this function:

static construct_order_by ( cols) [static]

Prepare an an order by clause from the list of columns to be sorted.

Parameters:
array$colscolumn name => SORT_ASC or SORT_DESC
Returns:
SQL fragment that can be used in an ORDER BY clause.

Definition at line 523 of file tablelib.php.

Here is the caller graph for this function:

define_baseurl ( url)

Sets $this->baseurl.

Parameters:
moodle_url | string$urlthe url with params needed to call up this page

Definition at line 371 of file tablelib.php.

Here is the caller graph for this function:

define_columns ( columns)
Parameters:
array$columnsan array of identifying names for columns. If columns are sorted then column names must correspond to a field in sql.

Definition at line 379 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

define_headers ( headers)
Parameters:
array$headersnumerical keyed array of displayed string titles for each column.

Definition at line 397 of file tablelib.php.

Here is the caller graph for this function:

This function is not part of the public api.

Definition at line 926 of file tablelib.php.

Here is the call graph for this function:

export_class_instance ( exportclass = null)

Get, and optionally set, the export class.

Parameters:
$exportclass(optional) if passed, set the table to use this export class.
Returns:
table_default_export_format_parent the export class in use (after any set).

Definition at line 174 of file tablelib.php.

Here is the caller graph for this function:

This function is not part of the public api.

Definition at line 1010 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

finish_output ( closeexportclassdoc = true)

You should call this to finish outputting the table data after adding data to the table with add_data or add_data_keyed.

Definition at line 677 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

flexible_table ( uniqueid)

Backwards-compatible constructor, so that legacy code subclassing flexible_table does not break.

Deprecated:
since Moodle 2.0. Will be removed in Moodle 2.1.

Definition at line 139 of file tablelib.php.

Here is the call graph for this function:

format_row ( row)
Parameters:
array$rowrow of data from db used to make one row of the table.
Returns:
array one row for the table, added using add_data_keyed method.

Definition at line 709 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

format_text ( text,
format = FORMAT_MOODLE,
options = NULL,
courseid = NULL 
)

Used from col_* functions when text is to be displayed. Does the right thing - either converts text to html or strips any html tags depending on if we are downloading and what is the download type. Params are the same as format_text function in weblib.php but some default options are changed.

Definition at line 764 of file tablelib.php.

Here is the call graph for this function:

This function is not part of the public api.

Definition at line 910 of file tablelib.php.

This function is not part of the public api.

Returns:
string initial of first name we are currently filtering by

Definition at line 803 of file tablelib.php.

This function is not part of the public api.

Returns:
string initial of last name we are currently filtering by

Definition at line 815 of file tablelib.php.

Returns:
int the pagesize for LIMIT clause of SQL

Definition at line 585 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
int the offset for LIMIT clause of SQL

Definition at line 575 of file tablelib.php.

Here is the call graph for this function:

get_row_from_keyed ( rowwithkeys)

This function is not part of the public api.

Definition at line 893 of file tablelib.php.

Here is the caller graph for this function:

Get the columns to sort by, in the form required by construct_order_by().

Returns:
array column name => SORT_... constant.

Reimplemented in quiz_attempt_report_table.

Definition at line 548 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_sort_for_table ( uniqueid) [static]

Get the order by clause from the session, for the table with id $uniqueid.

Parameters:
string$uniqueidthe identifier for a table.
Returns:
SQL fragment that can be used in an ORDER BY clause.

Definition at line 504 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
SQL fragment that can be used in an ORDER BY clause.

Definition at line 540 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
string sql to add to where statement.

Definition at line 595 of file tablelib.php.

Here is the caller graph for this function:

initialbars ( bool)

Sets the use_initials variable to the given boolean.

Parameters:
bool$bool
Returns:
void

Definition at line 274 of file tablelib.php.

Here is the caller graph for this function:

is_downloadable ( downloadable = null)

Probably don't need to call this directly. Calling is_downloading with a param automatically sets table as downloadable.

Parameters:
bool$downloadableoptional param to set whether data from table is downloadable. If ommitted this function can be used to get current state of table.
Returns:
bool whether table data is set to be downloadable.

Definition at line 198 of file tablelib.php.

Here is the caller graph for this function:

is_downloading ( download = null,
filename = '',
sheettitle = '' 
)

Call this to pass the download type. Use : $download = optional_param('download', '', PARAM_ALPHA); To get the download type. We assume that if you call this function with params that this table's data is downloadable, so we call is_downloadable for you (even if the param is '', which means no download this time. Also you can call this method with no params to get the current set download type.

Parameters:
string$downloaddownload type. One of csv, tsv, xhtml, ods, etc
string$filenamefilename for downloads without file extension.
string$sheettitletitle for downloaded data.
Returns:
string download type. One of csv, tsv, xhtml, ods, etc

Definition at line 158 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

is_sortable ( column = null)

Is the column sortable?

Parameters:
stringcolumn name, null means table
Returns:
bool

Definition at line 241 of file tablelib.php.

Here is the caller graph for this function:

make_styles_string ( styles)

This function is not part of the public api.

Parameters:
array$stylesCSS-property => value
Returns:
string values suitably to go in a style="" attribute in HTML.

Definition at line 1221 of file tablelib.php.

no_sorting ( column)

Do not sort using this column

Parameters:
stringcolumn name

Definition at line 232 of file tablelib.php.

other_cols ( column,
row 
)

You can override this method in a child class. See the description of build_table which calls this method.

Reimplemented in quiz_report_overview_table, and quiz_report_responses_table.

Definition at line 753 of file tablelib.php.

Here is the caller graph for this function:

pageable ( bool)

Sets the use_pages variable to the given boolean.

Parameters:
bool$bool
Returns:
void

Definition at line 265 of file tablelib.php.

pagesize ( perpage,
total 
)

Sets the pagesize variable to the given integer, the totalrows variable to the given integer, and the use_pages variable to true.

Parameters:
int$perpage
int$total
Returns:
void

Definition at line 285 of file tablelib.php.

Here is the caller graph for this function:

This function is not part of the public api.

Definition at line 1061 of file tablelib.php.

Here is the call graph for this function:

This method is deprecated although the old api is still supported.

Deprecated:
1.9.2 - Jun 2, 2008

Definition at line 792 of file tablelib.php.

This function is not part of the public api.

Definition at line 854 of file tablelib.php.

This function is not part of the public api.

Definition at line 883 of file tablelib.php.

print_one_initials_bar ( alpha,
current,
class,
title,
urlvar 
) [protected]

Helper function, used by print_initials_bar() to output one initial bar.

Parameters:
array$alphaof letters in the alphabet.
string$currentthe currently selected letter.
string$classclass name to add to this initial bar.
string$titlethe name to put in front of this initial bar.
string$urlvarURL parameter name for this initial.

Definition at line 831 of file tablelib.php.

Here is the call graph for this function:

print_row ( row,
classname = '' 
)

This function is not part of the public api.

Definition at line 960 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_attribute ( attribute,
value 
)

Gives the given $value to the $attribute index of $this->attributes.

Parameters:
string$attribute
mixed$value
Returns:
void

Definition at line 311 of file tablelib.php.

Here is the caller graph for this function:

set_control_variables ( variables)

Assigns each given variable in the array to the corresponding index in the request class variable.

Parameters:
array$variables
Returns:
void

Definition at line 297 of file tablelib.php.

setup ( )

Must be called after table is defined. Use methods above first. Cannot use functions below till after calling this method.

Returns:
type?

Definition at line 406 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

show_download_buttons_at ( showat)

Where to show download buttons.

Parameters:
array$showatarray of postions in which to show download buttons. Containing TABLE_P_TOP and/or TABLE_P_BOTTOM

Definition at line 210 of file tablelib.php.

show_hide_link ( column,
index 
) [protected]

Generate the HTML for the collapse/uncollapse icon. This is a helper method used by print_headers().

Parameters:
string$columnthe column name, index into various names.
int$indexnumerical index of the column.
Returns:
string HTML fragment.

Definition at line 1041 of file tablelib.php.

Here is the call graph for this function:

sort_icon ( isprimary,
order 
) [protected]

Generate the HTML for the sort icon. This is a helper method used by sort_link().

Parameters:
bool$isprimarywhether an icon is needed (it is only needed for the primary sort column.)
int$orderSORT_ASC or SORT_DESC
Returns:
string HTML fragment.

Definition at line 1142 of file tablelib.php.

Here is the call graph for this function:

sort_link ( text,
column,
isprimary,
order 
) [protected]

Generate the HTML for the sort link. This is a helper method used by print_headers().

Parameters:
string$textthe text for the link.
string$columnthe column name, may be a fake column like 'firstname' or a real one.
bool$isprimarywhether the is column is the current primary sort column.
int$orderSORT_ASC or SORT_DESC
Returns:
string HTML fragment.

Definition at line 1181 of file tablelib.php.

Here is the call graph for this function:

sort_order_name ( isprimary,
order 
) [protected]

Generate the correct tool tip for changing the sort order. This is a helper method used by sort_link().

Parameters:
bool$isprimarywhether the is column is the current primary sort column.
int$orderSORT_ASC or SORT_DESC
Returns:
string the correct title.

Definition at line 1165 of file tablelib.php.

sortable ( bool,
defaultcolumn = NULL,
defaultorder = SORT_ASC 
)

Sets the is_sortable variable to the given boolean, sort_default_column to the given string, and the sort_default_order to the given integer.

Parameters:
bool$bool
string$defaultcolumn
int$defaultorder
Returns:
void

Definition at line 222 of file tablelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

This function is not part of the public api.

Definition at line 1192 of file tablelib.php.

Here is the call graph for this function:

This function is not part of the public api. You don't normally need to call this. It is called automatically when needed when you start adding data to the table.

Definition at line 946 of file tablelib.php.

Here is the caller graph for this function:

Hook that can be overridden in child classes to wrap a table in a form for example. Called only when there is data to display and not downloading.

Reimplemented in quiz_attempt_report_table, and quiz_report_statistics_table.

Definition at line 701 of file tablelib.php.

Hook that can be overridden in child classes to wrap a table in a form for example. Called only when there is data to display and not downloading.

Reimplemented in quiz_attempt_report_table, and quiz_report_statistics_table.

Definition at line 693 of file tablelib.php.


Field Documentation

Definition at line 56 of file tablelib.php.

$baseurl = NULL

Definition at line 65 of file tablelib.php.

Definition at line 60 of file tablelib.php.

$column_nosort = array('userpic')

Definition at line 62 of file tablelib.php.

Definition at line 59 of file tablelib.php.

Definition at line 61 of file tablelib.php.

$columns = array()

Definition at line 58 of file tablelib.php.

$currpage = 0

Definition at line 75 of file tablelib.php.

$defaultdownloadformat = 'csv'

Definition at line 108 of file tablelib.php.

$download = ''

Definition at line 96 of file tablelib.php.

$downloadable = false

Definition at line 102 of file tablelib.php.

$exportclass = null

Definition at line 115 of file tablelib.php.

$headers = array()

Definition at line 57 of file tablelib.php.

$is_collapsible = false

Reimplemented in table_sql.

Definition at line 68 of file tablelib.php.

$is_sortable = false

Reimplemented in table_sql.

Definition at line 69 of file tablelib.php.

$maxsortkeys = 2

Definition at line 73 of file tablelib.php.

$pagesize = 30

Definition at line 74 of file tablelib.php.

$request = array()

Definition at line 66 of file tablelib.php.

$sess = NULL

Definition at line 64 of file tablelib.php.

$setup = false

Definition at line 63 of file tablelib.php.

$showdownloadbuttonsat = array(TABLE_P_TOP)

Array of positions in which to display download controls.

Definition at line 83 of file tablelib.php.

$sort_default_column = NULL

Definition at line 77 of file tablelib.php.

$sort_default_order = SORT_ASC

Definition at line 78 of file tablelib.php.

$started_output = false

Definition at line 113 of file tablelib.php.

$totalrows = 0

Definition at line 76 of file tablelib.php.

$uniqueid = NULL

Definition at line 55 of file tablelib.php.

$use_initials = false

Definition at line 71 of file tablelib.php.

$use_pages = false

Definition at line 70 of file tablelib.php.

$useridfield = 'id'

Reimplemented in quiz_attempt_report_table.

Definition at line 89 of file tablelib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations