Xataface HTML Reports Module 0.2
HTML Reports Module for Xataface
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Attributes
XfHtmlReportBuilder Class Reference

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.

Detailed Description

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.


Member Function Documentation

_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.

Parameters:
array&$groupDataThe 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$groupFieldsArray of arrays of group fields.
array$summaryFieldsArray 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.

Parameters:
array$recordsArray of Dataface_Record objects upon which the aggregate expression is to be calculated.
string$expressionThe expression to be evaluated. E.g. sum(subtotal)
Returns:
mixed Depending on the field type of the parameter may return a string of a date, an integer, or a double.

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.

Parameters:
array&$groupDataThe group data node structure.
Returns:
array Array of Dataface_Record objects.

Definition at line 451 of file XfHtmlReportBuilder.class.php.

fillReport ( root,
record,
el,
basePath = '',
contextParams = null 
)

Fills the report given a specific root record.

Parameters:
Dataface_Record$rootThe root record that this report is being filled from.
mixed$recordEither a Dataface_Record or Dataface_RelatedRecord object that is the subject of the current row.
simple_html_domDOM element of the template.
Returns:
string The filled HTML content of the report.

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.

Parameters:
array$recordsList of Dataface_Record objects upon which the report is to be filled.
string$templateThe template to fill.
boolean$headersAndFootersWhether to process headers and footers in the template.
boolean$asTableWhether to produce a table report.
Returns:
string The processed 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.

Parameters:
Dataface_Record$recordThe record containing the data for the report.
string$templateThe template for the report.
boolean$strictWhether to throw compile exceptions in cases where fields or relationships cannot be found.
Returns:
string The filled report.

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.

Parameters:
array$recordsList of Dataface_Record objects to include in the table.
string$templateThe template which includes the fields to be used in this report.
boolean$headersAndFootersWhether to group report and include summary totals.
Returns:
string The completed HTML report.

Definition at line 244 of file XfHtmlReportBuilder.class.php.

static getFields ( el) [static]

Parses out the fields from macros in a given DOM element.

Parameters:
simple_html_domThe dom element whose inner text is being checked for macros.
Returns:
array(string) List of field names that were found in the element as 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.

Parameters:
Dataface_Record$recordThe record that is subject of this calculation.
array$fieldsList of field names to group by.
Returns:
string The key.

Definition at line 225 of file XfHtmlReportBuilder.class.php.

static getSummaryFields ( el) [static]

Parses out summary fields from macros in a given DOM element.

Parameters:
simple_html_domThe dom element whose inner text is being checked for macros.
Returns:
array(string) List of summary fields in the form func(field_name).

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).

See also:
$SUMMARY_FUNCTIONS For array of function names that may be used.
Parameters:
string$expressionThe aggregate function expression.
Returns:
array Data structure with the component parts of the 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.

Parameters:
array&$groupDataThe 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.

Parameters:
Dataface_Table$tableThe table against which the template is to be compiled.
string$templateThe template that is being analysed.
Exceptions:
Exception(code=XfHtmlReportBuilder::COMPILE_ERROR)if there is a problem.

Definition at line 688 of file XfHtmlReportBuilder.class.php.


Field Documentation

$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.


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