class FrxTable in Forena Reports 7.4
Same name and namespace in other branches
- 6.2 templates/FrxTable.inc \FrxTable
- 7.2 templates/FrxTable.inc \FrxTable
- 7.3 templates/FrxTable.inc \FrxTable
@file FrxTable Template that lays out a report in a particular table format.
Hierarchy
- class \FrxRenderer
- class \FrxTable
Expanded class hierarchy of FrxTable
5 string references to 'FrxTable'
- forena_data_block_preview in ./
forena.data.inc - forena_forena_controls in ./
forena.module - Self register controls with forena.
- forena_report_data_block_form in ./
forena.report.inc - A form to preview and add data blocks to an existing report
- FrxEditor::addBlock in ./
FrxEditor.inc - Add a data blcok
- FrxTable::generate in renderers/
FrxTable.inc - Generate the template from the configuration.
File
- renderers/
FrxTable.inc, line 6 - FrxTable Template that lays out a report in a particular table format.
View source
class FrxTable extends FrxRenderer {
public $templateName = 'Simple Table';
/**
* Extract table configuration from the HTML
* @see FrxRenderer::scrapeConfig()
*/
public function scrapeConfig() {
$config = array();
$caption = $this
->extractXPath('*//caption', $this->reportDocDomNode);
$this
->extractTemplateHTML($this->reportDocDomNode, $config, array(
'table',
));
$tds = $this
->extractXPathInnerHTML('*//td', $this->reportDocDomNode, FALSE);
$ths = $this
->extractXPathInnerHTML('*//th', $this->reportDocDomNode, FALSE);
$columns = array_combine($ths, $tds);
$weight = 0;
foreach ($columns as $label => $token) {
$key = trim($token, '{}');
$weight++;
$config['columns'][$key] = array(
'contents' => $token,
'label' => $label,
'include' => 1,
'weight' => $weight,
);
}
return $config;
}
public function generate($xml, &$config) {
$block = @$config['block'];
$id = @$config['id'];
if ($block) {
$id = $this
->idFromBlock($block);
$config['id'] = $id . '_block';
}
$config['class'] = @$config['class'] ? $config['class'] . ' FrxTable' : 'FrxTable';
$div = $this
->blockDiv($config);
// PUt on the header
$this
->removeChildren($div);
if (isset($config['header']['value'])) {
$this
->addFragment($div, $config['header']['value']);
}
// Decide to inlcude columns
$found_columns = $this
->columns($xml);
if (!$found_columns) {
$found_columns = $this
->columns($xml, '/*');
$attrs = array();
}
$include_column = 0;
$weight = 0;
if (!@$config['columns']) {
$include_column = 1;
}
else {
$weight = count($config['columns']);
}
foreach ($found_columns as $column => $label) {
$token = '{' . $column . '}';
if (!isset($config['columns'][$column])) {
$weight++;
$config['columns'][$column] = array(
'contents' => $token,
'include' => $include_column,
'label' => $label,
'weight' => $weight,
);
}
}
$attrs = array(
'foreach' => '*',
);
$table = $this
->setFirstNode($div, 4, 'table');
if (@$config['caption']) {
$this
->setFirstNode($table, 6, 'caption', $config['caption']);
}
$thead = $this
->setFirstNode($table, 6, 'thead');
$throw = $this
->setFirstNode($thead, 8, 'tr');
$tbody = $this
->setFirstNode($table, 6, 'tbody');
$tdrow = $this
->setFirstNode($tbody, 8, 'tr', NULL, array(
'id' => $id,
), $attrs);
if (isset($config['columns'])) {
foreach ($config['columns'] as $key => $col) {
if ($col['include']) {
$this
->addNode($throw, 10, 'th', $col['label']);
$this
->addNode($tdrow, 10, 'td', $col['contents']);
}
}
}
if (isset($config['footer']['value'])) {
$this
->addFragment($div, $config['footer']['value']);
}
}
public function configForm($config) {
// Load header informationi from parent config.
$form = parent::configForm($config);
$this
->weight_sort($config['columns']);
$form['columns'] = array(
'#theme' => 'forena_element_draggable',
'#draggable_id' => 'FrxTable-columns',
);
$form['caption'] = array(
'#type' => 'textfield',
'#title' => t('Caption'),
'#default_value' => @$config['caption'],
);
foreach ($config['columns'] as $key => $col) {
$ctl = array();
$ctl['label'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('Label'),
'#default_value' => $col['label'],
);
$ctl['contents'] = array(
'#type' => 'textfield',
'#size' => '30',
'#title' => t('Data'),
'#default_value' => $col['contents'],
);
$ctl['include'] = array(
'#type' => 'checkbox',
'#title' => t('Include'),
'#default_value' => $col['include'],
);
$ctl['weight'] = array(
"#type" => 'weight',
'#title' => t('Weight'),
"#delta" => 50,
'#default_value' => $col['weight'],
);
$form['columns'][$key] = $ctl;
}
return $form;
}
public function configValidate(&$config) {
parent::configValidate($config);
$this
->weight_sort($config['columns']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | @var FrxReport | |
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public | property | ||
FrxRenderer:: |
public static | function | Helper function for convergint methods to a standard associated array. | |
FrxRenderer:: |
function | Append a textual XHTML fragment to the dom. We do not use the DOMDocumentFragment optioin because they don't properly import namespaces. . | ||
FrxRenderer:: |
function | Add a node to the existing dom element with attributes | ||
FrxRenderer:: |
function | Add a text node to the current dom node. | ||
FrxRenderer:: |
public | function | Puts attributes back in array format prior to rendering. | |
FrxRenderer:: |
public | function | Generate generic div tag. | |
FrxRenderer:: |
public | function | Extract a list of columns from the data context. | |
FrxRenderer:: |
public | function | Generate ajax configuration attributes for use in template configurtion forms. | |
FrxRenderer:: |
public | function | Render a drupal form in a forena template | |
FrxRenderer:: |
public | function | Extract a configuration var removing it from the array | |
FrxRenderer:: |
public | function | Get the textual representations of html for the configuration engine. | |
FrxRenderer:: |
public | function | Get the textual representations of html for the configuration engine. | |
FrxRenderer:: |
public | function | Get the textual representations of html for the configuration engine. | |
FrxRenderer:: |
public | function | Extracts the inner html of all nodes that match a particular xpath expression. | |
FrxRenderer:: |
public | function | Extracts the inner html of all nodes that match a particular xpath expression. | |
FrxRenderer:: |
public | function | Simple function to get id from node. | |
FrxRenderer:: |
public | function | This function is called to give the renderer the current conetxt in report rendering. It makes sure the renderer has the current DOM nodes dom documnent, and other attributes. | |
FrxRenderer:: |
public | function | Return the inside xml of the current node | |
FrxRenderer:: |
public | function | Standard php array containing merged attributes Enter description here ... | |
FrxRenderer:: |
public | function | Rmove all the children of a dom node in the current report. | |
FrxRenderer:: |
public | function | Removes all chidren from the dome node expect those with a tagname specified by the the $tags argurment | |
FrxRenderer:: |
public | function | Default Render action, which simply does normal forena rendering. You can use renderDomNode at any time to generate the default forena rendering methods. | 9 |
FrxRenderer:: |
public | function | ||
FrxRenderer:: |
public | function | Recursive report renderer Walks the nodes rendering the report. | |
FrxRenderer:: |
public | function | Gives the token replaced attributes of a node. | |
FrxRenderer:: |
public | function | A helper function to allow replacement of tokens from inside a renderer wihout needing to understand the object | |
FrxRenderer:: |
public | function | Starting at the current report node, this function removes all child nodes. It aso removes any FRX attributes on the current as well. | |
FrxRenderer:: |
public | function | Set FRX attributes. | |
FrxRenderer:: |
public | function | Sets the first child element to a node and returns it. IF the node | |
FrxRenderer:: |
public | function | Helper funciton for validating text_format type controls. | |
FrxRenderer:: |
public | function | Sort a column list by weight. | |
FrxRenderer:: |
public static | function | ||
FrxRenderer:: |
public | function | Convert XML to key value pairs. This is used in support of graping to get specific key/value pairs in an array format suitable for passing off to php libraries. | |
FrxRenderer:: |
public | function | 2 | |
FrxTable:: |
public | property | ||
FrxTable:: |
public | function |
Returns the section
Enter description here ... Overrides FrxRenderer:: |
|
FrxTable:: |
public | function |
Default configuration validator. Simply validates header and footer attributes. Overrides FrxRenderer:: |
|
FrxTable:: |
public | function |
Generate the template from the configuration. Overrides FrxRenderer:: |
|
FrxTable:: |
public | function |
Extract table configuration from the HTML Overrides FrxRenderer:: |