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

Fixes

parent f5206f4b
......@@ -744,6 +744,7 @@ class FrxEditor {
$pnode->appendChild($node);
}
$config['block'] = $block_name;
$b = Frx::BlockEditor($block_name, $this->frxReport->block_edit_mode);
$data= $b->data($this->parms);
......@@ -802,7 +803,6 @@ class FrxEditor {
*/
// Set parameters
Frx::Data()->push($parms, 'parm');
// Check for cache data
if ($r->cache) {
$cid = 'forena:report:' . $name . ':' . drupal_http_build_query($parms);
......@@ -835,12 +835,19 @@ class FrxEditor {
else {
$r->render($format);
}
$links = '';
if ($r->preview_mode) {
$r_link = str_replace('/', '.', $this->report_name);
$parms = $_GET;
unset($parms['q']);
$links = l('Add data', "reports/$r_link/edit/select-data", array('query' => $parms));
}
Frx::Data()->pop();
$content = array(
'#has_data' => $r->blocks_loaded,
'parameter_form' => $r->parameters_form,
'links' => $this->documentLinks(),
'content' => array('#markup' => $r->html),
'content' => array('#markup' => $r->html . $links),
);
$o = Frx::Document($format);
if ($o) {
......@@ -869,7 +876,7 @@ class FrxEditor {
$options = array();
if ($context) $options['query'] = $context;
$o = '<div class="forena-edit-links">' . l($block_name, "reports/$report_name/edit/data/$block_link/$id", $options ) . "</div>";
$o = '<div class="forena-edit-links">' . l($block_name, "reports/$report_name/edit/edit-data/$block_link/$id", $options ) . "</div>";
}
return $o;
......
......@@ -84,7 +84,8 @@ class FrxReport {
public function setReport(DOMDocument $dom) {
$this->dom = $dom;
$dom->formatOutput = TRUE;
$rpt_xml = $this->rpt_xml = simplexml_import_dom($dom);
$rpt_xml = $this->rpt_xml = simplexml_import_dom($this->dom->documentElement);
$this->missing_parms = FALSE;
// Load header data
$this->body = $rpt_xml->body;
......@@ -541,7 +542,6 @@ class FrxReport {
}
}
$this->parms = $parms;
$this->missing_parms = $missing_parms;
//$this->parameters_form = $this->parametersForm(array('collapsible' => TRUE));
return $this->missing_parms;
}
......
......@@ -49,15 +49,15 @@ function forena_display_blocks() {
return $content;
}
function forena_data_block_preview($block_name, $parms = array(), $edit=FALSE) {
$o = Frx::Editor('__forena_block_preview__');
$o->cancel();
$o->frxReport->block_edit_mode = $edit;
$o->setEditorParms($parms);
$o->addBlock($block_name);
$o->update();
$content = $o->preview($parms);
//$o->cancel();
$o->cancel();
return $content;
}
......
<?php
require_once 'forena.data.inc';
require_once 'Frx.inc';
/**
......@@ -185,7 +185,7 @@ function forena_menu() {
'file' => 'forena.admin.inc',
);
$items['reports/%/edit/preview'] = array(
$items['reports/%/edit-data/preview'] = array(
'title' => 'Preview',
'page callback' => 'forena_report_preview',
'page arguments' => array(1),
......@@ -196,16 +196,56 @@ function forena_menu() {
);
$items['reports/%/edit/data/%/%'] = array(
$items['reports/%/edit/edit-data/%/%'] = array(
'title' => 'Edit Block',
'file' => 'forena.report.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('forena_report_data_block_form', 1, 4, 5, 'edit'),
'page arguments' => array('forena_report_data_block_form', 1, 4, 5, 'edit-data'),
'access arguments' => array('design any report'),
'description' => 'Add a data block to your report',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/select-data'] = array(
'title' => 'Select Data Block',
'file' => 'forena.report.inc',
'page callback' => 'forena_select_block_list',
'page arguments' => array(1),
'access arguments' => array('design any report'),
'description' => 'Select the data blcok to add',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/select-data/%'] = array(
'title' => 'Select Data Block',
'file' => 'forena.report.inc',
'page callback' => 'forena_select_block_list',
'page arguments' => array(1, 4),
'access arguments' => array('design any report'),
'description' => 'Select the data blcok to add',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/preview-data/%/%'] = array(
'title' => 'Preview Data Block',
'file' => 'forena.report.inc',
'page callback' => 'forena_report_block_preview',
'page arguments' => array(1, 4, 5),
'access arguments' => array('design any report'),
'description' => 'Select the data block to add',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/preview-data/%/%/%'] = array(
'title' => 'Preview Data Block',
'file' => 'forena.report.inc',
'page callback' => 'forena_report_block_preview',
'page arguments' => array(1, 4, 5, 6),
'access arguments' => array('design any report'),
'description' => 'Select the data block to add',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/add-data/%'] = array(
'title' => 'Data',
'file' => 'forena.report.inc',
......@@ -216,6 +256,16 @@ function forena_menu() {
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/add-data/%/%'] = array(
'title' => 'Add Data',
'file' => 'forena.report.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('forena_report_data_block_form', 1, 4, 5),
'access arguments' => array('design any report'),
'description' => 'Edit a data block on the report. ',
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/fields'] = array(
'title' => 'Fields',
'page callback' => 'drupal_get_form',
......
......@@ -140,7 +140,7 @@ function forena_create_report_submit($form, &$form_state) {
$edit = '/edit';
}
else {
$edit = '/edit/data/add';
$edit = '/edit/seletc-data';
}
$form_state['redirect']= $desc['i_link'] . $edit;
......@@ -167,7 +167,9 @@ function forena_report_save_form($form, &$form_state, $report_name) {
'#value' => t('Cancel'),
'#submit' => array('forena_report_save_cancel'),
);
$form_state['redirect'] = "reports/$report_name";
$parms = $_GET;
unset($parms['q']);
$form_state['redirect'] = array("reports/$report_name", array('query' => $parms));
return $form;
}
......@@ -192,7 +194,7 @@ function forena_report_preview($report_name) {
* @param $form_state Array of block type
* @return unknown_type
*/
function forena_report_data_block_form($formid, &$form_state, $report_name, $block_name='', $id='', $action='add') {
function forena_report_data_block_form($formid, &$form_state, $report_name, $block_name='', $id='', $action='add-data') {
$config = array();
$r = Frx::Editor($report_name);
// List of templates
......@@ -218,14 +220,14 @@ function forena_report_data_block_form($formid, &$form_state, $report_name, $blo
'#type' => 'submit',
'#value' => 'Add',
'#submit' => array('forena_report_add_template_submit'),
'#access' => $action=='add',
'#access' => $action=='add-data',
);
$form['update'] = array(
'#type' => 'submit',
'#value' => 'Update',
'#submit' => array('forena_report_edit_template_submit'),
'#access' => $action=='edit',
'#access' => $action=='edit-data',
);
$form['cancel'] = array(
......@@ -275,10 +277,19 @@ function forena_report_data_block_form($formid, &$form_state, $report_name, $blo
// Generate a preview
$parms = $form_state['storage']['parms'];
$r = Frx::Editor('__report_block_preview__');
$r->cancel();
$r->setEditorParms($parms);
$r->addBlock($block_name, $template_class, $config);
$r->update();
$preview = $r->preview($parms);
if (!$preview['#has_data']) {
$path = "reports/$report_name/edit/preview-data/$action/$block_name";
if ($id) $path .= "/$id";
$parms = $_GET;
unset($parms['q']);
$options = array();
if ($parms) $options['query'] = $parms;
drupal_goto("$path", $options);
}
$form['template']['preview']['content'] = $preview['content'];
$r->cancel();
......@@ -318,7 +329,9 @@ function forena_report_edit_template_submit($form, &$form_state){
$r->setEditorParms($parms);
$r->applyTemplate($id, $template_class, $config);
$r->update();
$form_state['redirect'] = "reports/$report_name/edit";
$parms = $_GET;
$unset($parms['q']);
$form_state['redirect'] = array("reports/$report_name/edit", array('query' => $parms));
}
function forena_report_add_template_submit($form, &$form_state) {
......@@ -328,13 +341,17 @@ function forena_report_add_template_submit($form, &$form_state) {
$r->setEditorParms($parms);
Frx::Editor($report_name)->addBlock($block_name, $template_class, (array)$config, $id);
Frx::Editor() ->update();
$form_state['redirect'] = "reports/$report_name/edit";
}
$parms = $_GET;
$unset($parms['q']);
$form_state['redirect'] = array("reports/$report_name/edit", array('query' => $parms));
}
function forena_update_cancel($form, &$form_state) {
extract($form_state['values']);
$form_state['redirect'] = "reports/$report_name/edit";
}
$parms = $_GET;
$unset($parms['q']);
$form_state['redirect'] = array("reports/$report_name/edit", array('query' => $parms));
}
function forena_report_save_cancel($form, &$form_state) {
extract($form_state['values']);
......@@ -342,6 +359,94 @@ function forena_report_save_cancel($form, &$form_state) {
$form_state['redirect'] = 'forena';
}
function forena_select_block_list($report_name, $id='') {
$header = array(t('Block'), t('Access'), t('Keywords'));
$blocks = Frx::DataFile()->userBlocks();
$data=array();
foreach ($blocks as $block_name => $block) {
$blck = str_replace('/', '.', $block_name);
$path = "reports/$report_name/edit/preview-data/add-data/$blck";
// Build the table.
if ($id) $path .= "/$id";
$data[] = array(
l($block_name, $path),
@$block->cache['access'],
@$block->cache['keywords']
);
}
// Theme the table
$content['data_blocks'] = array('#markup' => theme('forena_data_table', array('header' => $header, 'rows' => $data)));
return $content;
}
/**
* Preview the block
* @param unknown $report_name
* @param unknown $block_name
* @param string $id
* @return multitype:string unknown multitype:string unknown multitype:string multitype:string Ambigous <The, string, A, Optional>
*/
function forena_report_block_select_form($form, &$form_state, $report_name, $action, $block_name, $id='') {
$form['action'] = array(
'#type' => 'value',
'#value' => $action,
);
$form['report_name'] = array(
'#type' => 'value',
'#value' => $report_name,
);
$form['block_name'] = array(
'#type' => 'value',
'#value' => $block_name,
);
$form['id'] = array(
'#type' => 'value',
'#value' => $id,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Select'),
);
return $form;
}
function forena_report_block_select_form_submit($form, &$form_state) {
//Instantiate form variables
extract($form_state['values']);
$parms = $_GET;
unset($parms['q']);
$path = "reports/$report_name/edit/$action/$block_name";
if ($id) $path = "$path/$id";
$form_state['redirect'] = array($path, array('query' => $parms));
}
/**
* Page to allow selection of a data block with parameters.
* @param unknown $report_name
* @param unknown $block_name
* @param string $id
* @return Ambigous <unknown, multitype:multitype:NULL Ambigous <string, multitype:multitype:multitype:string multitype:multitype:string unknown > Ambigous <The, boolean, string> >
*/
function forena_report_block_preview($report_name, $action, $block_name, $id='') {
$parms = $_GET;
unset($parms['q']);
$preview = forena_data_block_preview($block_name, $parms);
if (@trim($preview['content']['#markup'])) {
$content['select'] = drupal_get_form('forena_report_block_select_form', $report_name, $action, $block_name, $id);
}
else {
drupal_set_message(t('Sample data is required in order to correctly generate a template. Try changing parameters'), 'warning');
}
$content['preview'] = $preview;
return $content;
}
......@@ -22,8 +22,8 @@ class FrxRenderer {
public function initReportNode(DOMElement $domNode, FrxReport $frxReport) {
$this->dom = $frxReport->dom;
$this->reportDocDomNode = $domNode;
$this->dom = $domNode->ownerDocument;
$this->dataProvider = Frx::Data();
$this->reportDocNode = $node = simplexml_import_dom($domNode);
$this->teng = $frxReport->teng;
......@@ -651,7 +651,7 @@ class FrxRenderer {
}
public function removeChildren(DOMNode $node) {
while (isset($node->firstChild)) {
while (isset($node->firstChild) && $node->firstChild->nodeType < 9) {
$this->removeChildren($node->firstChild);
$node->removeChild($node->firstChild);
}
......
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