Commit f45a2748 authored by David Metzler's avatar David Metzler
Browse files

Merge branch '7.x-4.x' of metzlerd@git.drupal.org:project/forena.git into 7.x-4.x

parents d9ac0cec 3a8cbc7c
......@@ -339,14 +339,55 @@ class FrxEditor {
}
/**
* Makes sure specific document types are asserted.
*/
public function ensureDocGen($types) {
$types = array_combine($types, $types);
$doctypes = $this->getDocgen();
$doctypes = array_merge($types, $doctypes);
$this->setDocgen($doctypes);
}
/**
* Gets the array of selected document types or default if they are present.
* @return array
*/
public function getDocgen() {
//build the options and default list
$nodes = $this->simplexml->head->xpath('//frx:doc');
if ($nodes) {
$doctypes = array();
foreach($nodes as $doc) {
$doctypes[] = (string) $doc['type'];
}
}
else {
$doctypes = variable_get('forena_doc_formats', array());
}
// Verify that they are not disabled
$supported_types = array_keys(Frx::documentTypes());
$doctypes = array_intersect($doctypes, $supported_types);
$doctypes = array_combine($doctypes, $doctypes);
return $doctypes;
}
/**
* Set document generation types that apply to this report.
* Enter description here ...
* @param unknown_type $docgenElements
*/
public function setDocgen($docgenElements) {
public function setDocgen($doctypes) {
$docgenElements = array();
if ($selected = array_filter($doctypes)) {
if ($selected) foreach ($selected as $key => $value) {
if ($value) $docgenElements[] = array('type' => $key);
}
}
$dom = $this->dom;
$newDocs = $dom->createElementNS($this->xmlns, 'docgen');
$this->verifyHeaderElements(array('docgen'));
......@@ -354,9 +395,9 @@ class FrxEditor {
$p = $dnode->parentNode;
$p->replaceChild($newDocs, $dnode);
$this->setFrxHeader('docgen', 'doc',
$docgenElements,
array('type'),
NULL,
$docgenElements,
array('type'),
NULL,
'type'
);
}
......
......@@ -40,7 +40,14 @@ class FrxXLSDoc extends FrxDocument {
$tables = $xml->xpath('//table');
$count = 1;
if ($tables) foreach ($tables as $table) {
$output .= '<Worksheet ss:Name="sheet' . ' ' . $count . '">' . "\n";
$sheet_name = @(string)$table['data-caption'];
if(!$sheet_name && @(string)$table->caption){
$sheet_name = (string) $table->caption;
}
if (!$sheet_name) {
$sheet_name = 'sheet' . ' ' . $count;
}
$output .= '<Worksheet ss:Name="' . $sheet_name . '">' . "\n";
$count ++;
$output .= ' <Table>' . "\n";
......
......@@ -579,13 +579,7 @@ function forena_report_format_form_submit($form, &$form_state) {
// Doc gen settings.
if (isset($form['docgen'])) {
$docgen = array();
if ($selected = array_filter(@$values['docgen']['docs'])) {
if ($selected) foreach ($selected as $key => $value) {
if ($value) $docgen[] = array('type' => $key);
}
}
$r->setDocgen($docgen);
$r->setDocgen($values['docgen']['docs']);
}
$r->update();
......
......@@ -10,6 +10,7 @@ class FrxEmailMerge extends FrxRenderer {
public function __construct() {
parent::__construct();
$this->email_input_format = variable_get('forena_email_input_format', filter_default_format());
$this->doc_types = array('email');
}
public function scrapeConfig() {
......
......@@ -24,6 +24,7 @@ class FrxRenderer {
public $dom; // Reports root document node.
public $xpathQuery;
public $input_format = 'full_html';
public $doc_types = array(); // Specify the required document types to use this format.
public function __construct() {
$this->input_format = variable_get('forena_input_format', filter_default_format());
......@@ -132,7 +133,7 @@ class FrxRenderer {
$attrs = $node->attributes();
$id = (string)$attrs['id'];
$tag = $node->getName();
$has_children = TRUE;
// Preprocessing for detecting blank nodes
if (@$settings['stripEmptyElements']) {
$has_children = count($node->children()) > 0;
......@@ -144,9 +145,17 @@ class FrxRenderer {
}
if (!$has_children && !$has_attributes) {
$has_text = trim($this->teng->replace((string)$dom_node->textContent)) !== '';
if (!$has_text) return '';
if (!$has_text) {
return;
}
else {
$has_children = TRUE;
}
}
}
else {
$has_children = count($node->children()) > 0 || trim($dom_node->textContent) !== '';
}
if ((string)$frx['block']) {
$this->blockName = (string)$frx['block'];
......@@ -275,13 +284,18 @@ class FrxRenderer {
}
}
else {
if ($include_root) $o .= $this->teng->replace('<' . $tag . $attr_text . '>', TRUE);
if ($has_children) {
if ($include_root) $o .= $this->teng->replace('<' . $tag . $attr_text . '>', TRUE);
// None found, so render children
foreach ($dom_node->childNodes as $child) {
$this->renderDomNode($child, $o);
// None found, so render children
foreach ($dom_node->childNodes as $child) {
$this->renderDomNode($child, $o);
}
if ($include_root) $o .= '</' . $tag . '>';
}
else {
$o .= $this->teng->replace('<' . $tag . $attr_text . '/>', TRUE);
}
if ($include_root) $o .= '</' . $tag . '>';
}
}
if ($is_data_block && $continue) {
......@@ -626,7 +640,13 @@ class FrxRenderer {
public function columns($xml, $path='/*/*') {
//create an array of columns
if (!is_object($xml)) return array();
$rows = $xml->xpath($path);
// Use xpath if possible otherwise iterate.
if (method_exists($xml, 'xpath')) {
$rows = $xml->xpath($path);
}
else {
$rows = $xml;
}
$column_array = array();
$numeric_columns = array();
foreach ($rows as $columns) {
......
......@@ -12,6 +12,7 @@ class FrxTable extends FrxRenderer {
*/
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);
......@@ -74,6 +75,10 @@ class FrxTable extends FrxRenderer {
$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');
......@@ -91,6 +96,7 @@ class FrxTable extends FrxRenderer {
$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(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment