Andrew's Web Libraries (AWL)
|
Public Member Functions | |
__construct ( $title="") | |
AddColumn ( $field, $header="", $align="", $format="", $sql="", $class="", $datatype="", $hook=null) | |
AddHidden ( $field, $sql="") | |
SetTitle ( $new_title) | |
Title ( $new_title=null) | |
SetTranslatable ( $column_list) | |
SetSubTitle ( $sub_title) | |
SetDiv ( $open_div, $close_div) | |
SetJoins ( $join_list) | |
SetUnion ( $union_select) | |
SetWhere ( $where_clause) | |
SetDistinct ( $distinct) | |
SetLimit ( $limit_n) | |
SetOffset ( $offset_n) | |
MoreWhere ( $operator, $more_where) | |
AndWhere ( $more_where) | |
OrWhere ( $more_where) | |
AddGrouping ( $field, $browser_array_key=0) | |
AddOrder ( $field, $direction, $browser_array_key=0, $secondary=0) | |
ForceOrder ( $field, $direction) | |
SetOrdering ( $default_fld=null, $default_dir='A', $browser_array_key=0) | |
AddTotal ( $column_name, $total_function=false) | |
GetTotal ( $column_name) | |
RowFormat ( $beginrow, $closerow, $rowargs) | |
ExtraRowFormat ( $beginrow, $closerow, $rowargs) | |
DoQuery () | |
AddRow ( $column_values) | |
MatchedRow ( $column, $value, $function) | |
ValueReplacement ($matches) | |
Render ( $title_tag=null, $subtitle_tag=null) | |
Definition at line 174 of file classBrowser.php.
Browser::__construct | ( | $title = "" | ) |
The Browser class constructor
string | $title | A title for the browser (optional). |
Definition at line 214 of file classBrowser.php.
Browser::AddColumn | ( | $field, | |
$header = "" , |
|||
$align = "" , |
|||
$format = "" , |
|||
$sql = "" , |
|||
$class = "" , |
|||
$datatype = "" , |
|||
$hook = null |
|||
) |
Add a column to the Browser.
This constructs a new BrowserColumn, appending it to the array of columns in this Browser.
Note that if the $format parameter starts with '
' the format will replace the column format, otherwise it will be used within '
...' tags.
string | $field | The name of the field. |
string | $header | A column header for the field. |
string | $align | An alignment for column values. |
string | $format | A sprintf format for displaying column values. |
string | $sql | An SQL fragment for calculating the value. |
string | $class | A CSS class to apply to the cells of this column. |
string | $hook | The name of a global function which will preprocess the column value |
The hook function should be defined as follows: function hookfunction( $column_value, $column_name, $database_row ) { ... return $value; }
Definition at line 260 of file classBrowser.php.
Browser::AddHidden | ( | $field, | |
$sql = "" |
|||
) |
Add a hidden column - one that is present in the SQL result, but for which there is no column displayed.
This can be useful for including a value in (e.g.) clickable links or title attributes which is not actually displayed as a visible column.
string | $field | The name of the field. |
string | $sql | An SQL fragment to calculate the field, if it is calculated. |
Definition at line 275 of file classBrowser.php.
Browser::AddOrder | ( | $field, | |
$direction, | |||
$browser_array_key = 0 , |
|||
$secondary = 0 |
|||
) |
Add an ordering to the browser widget.
The ordering can be overridden by GET parameters which will be rendered into the column headers so that a user can click on the column headers to control the actual order.
string | $field | The name of the field to be ordered by. |
string | $direction | A for Ascending, otherwise it will be descending order. |
string | $browser_array_key | Use this to distinguish between multiple browser widgets on the same page. Leave it empty if you only have a single browser instance. |
string | $secondary | Use this to indicate a default secondary order which shouldn't interfere with the default primary order. |
Definition at line 474 of file classBrowser.php.
Browser::AddTotal | ( | $column_name, | |
$total_function = false |
|||
) |
Mark a column as something to be totalled. You can also specify the name of a function which may modify the value before the actual totalling.
The callback function will be called with each row, with the first argument being the entire record object and the second argument being only the column being totalled. The callback should return a number, to be added to the total.
string | $column_name | The name of the column to be totalled. |
string | $total_function | The name of the callback function. |
Definition at line 557 of file classBrowser.php.
Browser::AndWhere | ( | $more_where | ) |
Add an OR ... to the SQL Where clause
string | $more_where | The extra part of the where clause |
Definition at line 436 of file classBrowser.php.
Browser::DoQuery | ( | ) |
This method is used to build and execute the database query.
You need not call this method, since Browser::Render() will call it for you if you have not done so at that point.
Definition at line 643 of file classBrowser.php.
Browser::ExtraRowFormat | ( | $beginrow, | |
$closerow, | |||
$rowargs | |||
) |
Set the format for an extra output row.
Like Browser::RowFormat(), but used for formatting additional / extra rows created with Browser::AddRow(). Defaults to the format set with Browser::RowFormat() if unset.
string | $beginrow | The new printf format for the start of the extra row. |
string | $closerow | The new string for the close of the extra row. |
string | $rowargs | ... The row arguments which will be sprintf'd into the $beginrow format for each extra row |
Definition at line 622 of file classBrowser.php.
Browser::ForceOrder | ( | $field, | |
$direction | |||
) |
Force a particular ordering onto the browser widget.
string | $field | The name of the field to be ordered by. |
string | $direction | A for Ascending, otherwise it will be descending order. |
Definition at line 508 of file classBrowser.php.
Browser::GetTotal | ( | $column_name | ) |
Retrieve the total from a totalled column
string | $column_name | The name of the column to be totalled. |
Definition at line 570 of file classBrowser.php.
Browser::MatchedRow | ( | $column, | |
$value, | |||
$function | |||
) |
Replace a row where $column = $value with an extra arbitrary row, returned from calling $function
string | $column | The name of a column to match |
string | $value | The value to match in the column |
string | $function | The name of the function to call for the matched row |
Definition at line 685 of file classBrowser.php.
Browser::MoreWhere | ( | $operator, | |
$more_where | |||
) |
Add an [operator] ... to the SQL Where clause
You will generally want to call OrWhere or AndWhere rather than this function, but hey: who am I to tell you how to code!
string | $operator | The operator to combine with previous where clause parts. |
string | $more_where | The extra part of the where clause |
Definition at line 423 of file classBrowser.php.
Browser::OrWhere | ( | $more_where | ) |
Add an OR ... to the SQL Where clause
string | $more_where | The extra part of the where clause |
Definition at line 445 of file classBrowser.php.
Browser::Render | ( | $title_tag = null , |
|
$subtitle_tag = null |
|||
) |
This method is used to render the browser as HTML. If the query has not yet been executed then this will call DoQuery to do so.
The browser (including the title) will be displayed in a div with id="browser" so that you can style '#browser tr.header', '#browser tr.totals' and so forth.
string | $title_tag | The tag to use around the browser title (default 'h1') |
@TODO: We should deprecate this approach in favour of simply doing the ValueReplacement on field names
Definition at line 730 of file classBrowser.php.
Browser::RowFormat | ( | $beginrow, | |
$closerow, | |||
$rowargs | |||
) |
Set the format for an output row.
The row format is set as an sprintf format string for the start of the row, and a plain text string for the close of the row. Subsequent arguments are interpreted as names of fields, the values of which will be sprintf'd into the beginrow string for each row.
Some special field names exist beginning with the '#' character which have 'magic' functionality, including '#even' which will insert '0' for even rows and '1' for odd rows, allowing a nice colour alternation if the beginrow format refers to it like: 'class="r%d"' so that even rows will become 'class="r0"' and odd rows will be 'class="r1"'.
At present only '#even' exists, although other magic values may be defined in future.
string | $beginrow | The new printf format for the start of the row. |
string | $closerow | The new string for the close of the row. |
string | $rowargs | ... The row arguments which will be sprintf'd into the $beginrow format for each row |
Definition at line 597 of file classBrowser.php.
Browser::SetDistinct | ( | $distinct | ) |
Set the SQL DISTINCT clause to a specific value.
The whole clause (except the keyword) needs to be supplied
string | $distinct | The whole clause, after 'DISTINCT' |
Definition at line 388 of file classBrowser.php.
Browser::SetDiv | ( | $open_div, | |
$close_div | |||
) |
Set a div for wrapping the browse.
string | $open_div | The HTML to open the div |
string | $close_div | The HTML to open the div |
Definition at line 339 of file classBrowser.php.
Browser::SetJoins | ( | $join_list | ) |
Set the tables and joins for the SQL.
For a single table this should just contain the name of that table, but for multiple tables it should be the full content of the SQL 'FROM ...' clause (excluding the actual 'FROM' keyword).
string | $join_list |
Definition at line 353 of file classBrowser.php.
Browser::SetLimit | ( | $limit_n | ) |
Set the SQL LIMIT clause to a specific value.
Only the limit number should be supplied.
int | $limit_n | A number of rows to limit the SQL selection to |
Definition at line 399 of file classBrowser.php.
Browser::SetOffset | ( | $offset_n | ) |
Set the SQL OFFSET clause to a specific value.
Only the offset number
int | $offset_n | A number of rows to offset the SQL selection to, based from the start of the results. |
Definition at line 410 of file classBrowser.php.
Browser::SetOrdering | ( | $default_fld = null , |
|
$default_dir = 'A' , |
|||
$browser_array_key = 0 |
|||
) |
Set up the ordering for the browser. Generally you should call this with the first parameter set as a field to order by default. Call with the second parameter set to 'D' or 'DESCEND' if you want to reverse the default order.
Definition at line 535 of file classBrowser.php.
Browser::SetSubTitle | ( | $sub_title | ) |
Set a Sub Title for the browse.
string | $sub_title | The sub title string |
Definition at line 329 of file classBrowser.php.
Browser::SetTitle | ( | $new_title | ) |
Set the Title for the browse.
This can also be set in the constructor but if you create a template Browser and then clone it in a loop you may want to assign a different Title for each instance.
string | $new_title | The new title for the browser |
Definition at line 289 of file classBrowser.php.
Browser::SetTranslatable | ( | $column_list | ) |
Set the named columns to be translatable
array | $column_list | The list of columns which are translatable |
Definition at line 311 of file classBrowser.php.
Browser::SetUnion | ( | $union_select | ) |
Set a Union SQL statement.
In rare cases this might be useful. It's currently a fairly simple hack which requires you to put an entire valid (& matching) UNION subclause (although without the UNION keyword).
string | $union_select |
Definition at line 366 of file classBrowser.php.
Browser::SetWhere | ( | $where_clause | ) |
Set the SQL Where clause to a specific value.
The WHERE keyword should not be included.
string | $where_clause | A valide SQL WHERE ... clause. |
Definition at line 377 of file classBrowser.php.
Browser::Title | ( | $new_title = null | ) |
Accessor for the Title for the browse, which could set the title also.
string | $new_title | The new title for the browser |
Definition at line 300 of file classBrowser.php.
Browser::ValueReplacement | ( | $matches | ) |
Return values from the current row for replacing into a template.
This is used to return values from the current row, so they can be inserted into a row template. It is used as a callback function for preg_replace_callback.
array | of string $matches An array containing a field name as offset 1 |
Definition at line 701 of file classBrowser.php.