Xataface HTML Reports Module 0.2
HTML Reports Module for Xataface
|
The report builder class that handles the merging of a template with a dataset to produce a report. More...
Public Member Functions | |
fillReport ($root, $record, $el, $basePath='', $contextParams=null) | |
Fills the report given a specific root record. | |
_replace_expressions ($matches) | |
_replace_summary_fields ($matches) | |
Internal function used by preg_replace_callback to replace summary macros. | |
Static Public Member Functions | |
static | getFields ($el) |
Parses out the fields from macros in a given DOM element. | |
static | getSummaryFields ($el) |
Parses out summary fields from macros in a given DOM element. | |
static | display ($record, $key, $displayMethod='htmlValue') |
static | set ($record, $key, $value, $strval=null) |
static | printGroupData (&$groupData, $groupFields, $summaryFields, $groupHeaders, $groupFooters, $template, $asTable) |
Prints the grouped data. | |
static | getGroupKey (Dataface_Record $record, $fields) |
Generates a group key for a record based on a list of fields to group by. Records whose values are the same for the fields listed will have equivalent group keys. | |
static | fillReportTable ($records, $template, $headersAndFooters=true) |
Fills a report in table mode. Table mode simply produces a 2-dimensional table where the columns are the fields that appear in the template, in the order that they appear. The template itself is only used to define which fields should appear in the table in this case. | |
static | fillReportMultiple ($records, $template, $headersAndFooters=true, $asTable=false) |
Fills a report for multiple records at once. | |
static | isDelegateField (Dataface_Table $table, $fieldname) |
static | extractRecordsFromGroupData (&$groupData) |
Exracts all of the records of a particular node in a group data tree. This includes all records in all child nodes as well. | |
static | compileGroupData (&$groupData, $groupFields, $summaryFields) |
Compiles a group data tree so that its aggregate summary totals are filled. | |
static | evaluateAggregateExpression (array $records, $expression) |
Evaluates an aggregate expression given a list of records. | |
static | parseExpression ($expression) |
Parses a summary field expression. E.g. sum(subtotal) or count(user_id). | |
static | fillReportSingle (Dataface_Record $record, $template, $strict=false) |
Fills a repord for a single record. | |
static | validateTemplate (Dataface_Table $table, $template) |
Validates a given template against a specified table to ensure that there are no errors. If there is a problem, an exception with code COMPILE_ERROR will be thrown. Otherwise it will just pass without incident. | |
Data Fields | |
const | COMPILE_ERROR = 501 |
Static Public Attributes | |
static | $SUMMARY_FUNCTIONS = array('sum','min','max','count') |
static | $ALLOWED_EXPRESSION_FUNCTIONS |
Protected Attributes | |
$strict = false | |
A flag to indicate whether compile errors should be thrown if fields or relationships of the template cannot be found. |
The report builder class that handles the merging of a template with a dataset to produce a report.
Definition at line 28 of file XfHtmlReportBuilder.class.php.
_replace_expressions | ( | $ | matches | ) |
Definition at line 852 of file XfHtmlReportBuilder.class.php.
_replace_summary_fields | ( | $ | matches | ) |
Internal function used by preg_replace_callback to replace summary macros.
Definition at line 944 of file XfHtmlReportBuilder.class.php.
static compileGroupData | ( | &$ | groupData, |
$ | groupFields, | ||
$ | summaryFields | ||
) | [static] |
Compiles a group data tree so that its aggregate summary totals are filled.
array | &$groupData | The data structure for the group. This is a tree where each node contains the following properties: array( 'summaryRecord' => <Dataface_Record> // Dataface_Record to hold the data for the headers // and footers. 'sections' => <array> // (Optional) Array of child nodes. 'records' => <array> // (Optional - only in leaf nodes) // array or records in this node. 'level' => <int> // The level 0, 1, 2, etc.. of this node |
array | $groupFields | Array of arrays of group fields. |
array | $summaryFields | Array of arrays of summary fields. |
Definition at line 485 of file XfHtmlReportBuilder.class.php.
static display | ( | $ | record, |
$ | key, | ||
$ | displayMethod = 'htmlValue' |
||
) | [static] |
Definition at line 143 of file XfHtmlReportBuilder.class.php.
static evaluateAggregateExpression | ( | array $ | records, |
$ | expression | ||
) | [static] |
Evaluates an aggregate expression given a list of records.
array | $records | Array of Dataface_Record objects upon which the aggregate expression is to be calculated. |
string | $expression | The expression to be evaluated. E.g. sum(subtotal) |
Definition at line 527 of file XfHtmlReportBuilder.class.php.
static extractRecordsFromGroupData | ( | &$ | groupData | ) | [static] |
Exracts all of the records of a particular node in a group data tree. This includes all records in all child nodes as well.
array | &$groupData | The group data node structure. |
Definition at line 451 of file XfHtmlReportBuilder.class.php.
fillReport | ( | $ | root, |
$ | record, | ||
$ | el, | ||
$ | basePath = '' , |
||
$ | contextParams = null |
||
) |
Fills the report given a specific root record.
Dataface_Record | $root | The root record that this report is being filled from. |
mixed | $record | Either a Dataface_Record or Dataface_RelatedRecord object that is the subject of the current row. |
simple_html_dom | DOM element of the template. |
Definition at line 703 of file XfHtmlReportBuilder.class.php.
static fillReportMultiple | ( | $ | records, |
$ | template, | ||
$ | headersAndFooters = true , |
||
$ | asTable = false |
||
) | [static] |
Fills a report for multiple records at once.
array | $records | List of Dataface_Record objects upon which the report is to be filled. |
string | $template | The template to fill. |
boolean | $headersAndFooters | Whether to process headers and footers in the template. |
boolean | $asTable | Whether to produce a table report. |
Definition at line 258 of file XfHtmlReportBuilder.class.php.
static fillReportSingle | ( | Dataface_Record $ | record, |
$ | template, | ||
$ | strict = false |
||
) | [static] |
Fills a repord for a single record.
Dataface_Record | $record | The record containing the data for the report. |
string | $template | The template for the report. |
boolean | $strict | Whether to throw compile exceptions in cases where fields or relationships cannot be found. |
Definition at line 664 of file XfHtmlReportBuilder.class.php.
static fillReportTable | ( | $ | records, |
$ | template, | ||
$ | headersAndFooters = true |
||
) | [static] |
Fills a report in table mode. Table mode simply produces a 2-dimensional table where the columns are the fields that appear in the template, in the order that they appear. The template itself is only used to define which fields should appear in the table in this case.
array | $records | List of Dataface_Record objects to include in the table. |
string | $template | The template which includes the fields to be used in this report. |
boolean | $headersAndFooters | Whether to group report and include summary totals. |
Definition at line 244 of file XfHtmlReportBuilder.class.php.
static getFields | ( | $ | el | ) | [static] |
Parses out the fields from macros in a given DOM element.
simple_html_dom | The dom element whose inner text is being checked for macros. |
Definition at line 115 of file XfHtmlReportBuilder.class.php.
static getGroupKey | ( | Dataface_Record $ | record, |
$ | fields | ||
) | [static] |
Generates a group key for a record based on a list of fields to group by. Records whose values are the same for the fields listed will have equivalent group keys.
Dataface_Record | $record | The record that is subject of this calculation. |
array | $fields | List of field names to group by. |
Definition at line 225 of file XfHtmlReportBuilder.class.php.
static getSummaryFields | ( | $ | el | ) | [static] |
Parses out summary fields from macros in a given DOM element.
simple_html_dom | The dom element whose inner text is being checked for macros. |
Definition at line 131 of file XfHtmlReportBuilder.class.php.
static isDelegateField | ( | Dataface_Table $ | table, |
$ | fieldname | ||
) | [static] |
Definition at line 431 of file XfHtmlReportBuilder.class.php.
static parseExpression | ( | $ | expression | ) | [static] |
Parses a summary field expression. E.g. sum(subtotal) or count(user_id).
string | $expression | The aggregate function expression. |
array( 'opt' => <string> // The operation. e.g. sum, max, count, etc... 'field'=> <string> // The name of the field used as a parameter to the function. )
Definition at line 643 of file XfHtmlReportBuilder.class.php.
static printGroupData | ( | &$ | groupData, |
$ | groupFields, | ||
$ | summaryFields, | ||
$ | groupHeaders, | ||
$ | groupFooters, | ||
$ | template, | ||
$ | asTable | ||
) | [static] |
Prints the grouped data.
array | &$groupData | The data structure group data that stores the report structure. |
array(array(string)) | $groupFields The array of group fields corresponding to each level of grouping. | |
array(array(string)) | $summaryFields The array of summary fields corresponding to each level of grouping. | |
array(simple_html_dom) | $groupHeaders Array of DOM elements representing the group headers. | |
array(simple_html_dom) | $groupFooters Array of DOM elements representing the group footers. |
Definition at line 188 of file XfHtmlReportBuilder.class.php.
static set | ( | $ | record, |
$ | key, | ||
$ | value, | ||
$ | strval = null |
||
) | [static] |
Definition at line 167 of file XfHtmlReportBuilder.class.php.
static validateTemplate | ( | Dataface_Table $ | table, |
$ | template | ||
) | [static] |
Validates a given template against a specified table to ensure that there are no errors. If there is a problem, an exception with code COMPILE_ERROR will be thrown. Otherwise it will just pass without incident.
Dataface_Table | $table | The table against which the template is to be compiled. |
string | $template | The template that is being analysed. |
Exception(code=XfHtmlReportBuilder::COMPILE_ERROR) | if there is a problem. |
Definition at line 688 of file XfHtmlReportBuilder.class.php.
$ALLOWED_EXPRESSION_FUNCTIONS [static] |
Definition at line 32 of file XfHtmlReportBuilder.class.php.
$strict = false [protected] |
A flag to indicate whether compile errors should be thrown if fields or relationships of the template cannot be found.
Definition at line 107 of file XfHtmlReportBuilder.class.php.
$SUMMARY_FUNCTIONS = array('sum','min','max','count') [static] |
Definition at line 31 of file XfHtmlReportBuilder.class.php.
const COMPILE_ERROR = 501 |
Definition at line 30 of file XfHtmlReportBuilder.class.php.