Commit 01ee6ef2 authored by metzlerd's avatar metzlerd
Browse files

More user interface inmprovements, direct field navigation.

parent 216384cc
......@@ -15,6 +15,7 @@ class FrxEditor {
public $simplexml;
public $title;
public $report_name;
public $report_link;
public $frx_attributes;
public $cache;
public $frxReport;
......@@ -26,6 +27,7 @@ class FrxEditor {
<!ENTITY nbsp "&#160;">
]>';
public $xmlns = 'urn:FrxReports';
private $field_ids;
private $xpq;
......@@ -62,6 +64,7 @@ class FrxEditor {
public function rename($name) {
$old_name = $this->report_name;
$this->report_name = $name;
$this->report_link = 'reports/' . str_replace('/', '.', $name);
unset($_SESSION['forena_report_editor'][$old_name]);
$this->update();
}
......@@ -88,6 +91,7 @@ class FrxEditor {
$r_text='';
$dom = $this->dom;
$this->report_name = $report_name = $this->desc['name'];
$this->report_link = 'reports/' . str_replace('/', '.', $report_name);
// Load the latest copy of the report editor
if ($report_name) {
if (isset($_SESSION['forena_report_editor'][$report_name]) && $edit) {
......@@ -308,6 +312,8 @@ class FrxEditor {
}
/**
* Set document generation types that apply to this report.
* Enter description here ...
......@@ -820,6 +826,7 @@ class FrxEditor {
*/
function report($parms = array(), $print = FALSE, $no_cache=FALSE) {
global $user;
$this->field_ids = array();
$content = array();
$format = $this->desc['format'];
$r = $this->frxReport;
......@@ -853,6 +860,7 @@ class FrxEditor {
if (@$r->cache['per_doctype']) @$cid .= ':' . $format;
$cache = cache_get($cid, 'cache');
if (!$cache || (isset($r->cache['duration']) && $cache->expire < time()) || $no_cache) {
$this->field_ids = array();
$r->render($format);
$time = null;
if (isset($r->cache['duration'])) {
......@@ -883,7 +891,7 @@ class FrxEditor {
$r_link = str_replace('/', '.', $this->report_name);
$parms = $_GET;
unset($parms['q']);
$links = l('Add data', "reports/$r_link/edit/select-data/add-data", array('query' => $parms));
$links = $this->l_icon("reports/$r_link/edit/select-data/add-data", 'doc-option-add.png', 'Add Data', $parms);
}
Frx::Data()->pop();
$content = array(
......@@ -908,8 +916,43 @@ class FrxEditor {
}
public function fieldLink($id, $value) {
$o = '';
if (!isset($this->field_ids[$id])) {
$report_link = $this->report_link;
$image = array(
'path' => url("misc/configure.png"),
'alt' => t('Configure'),
'title' => t('Configure'),
);
$image = theme('image', $image);
$id = urlencode($id);
$o= l($image, "$report_link/edit/edit-field/$id", array('html' => TRUE));
$this->field_ids[$id] = 1;
}
return $o;
}
public function foreachLinks($id='') {
}
public function l_icon($link, $name, $alt, $context=array()) {
$path = drupal_get_path('module', 'forena') . '/icons';
$image = array(
'path' => url("$path/$name"),
'alt' => t($alt),
'title' => t($alt),
);
$image = theme('image', $image);
$options = array('query' => $context, 'html' => TRUE);
return l($image, $link, $options);
}
public function editLinks($frx, $id='', $context = array()) {
public function blockLinks($frx, $id='', $context = array()) {
$o = '';
if ($frx['block']) {
$block_name = (string)$frx['block'];
......@@ -918,10 +961,10 @@ class FrxEditor {
$b = Frx::RepoMan()->loadBlock($block_name);
$options = array();
if ($context) $options['query'] = $context;
$o .= '<div class="forena-edit-links">' . l('Insert Data', "reports/$report_name/edit/select-data/prepend-data/$id") . "</div>";
$o .= '<div class="forena-edit-links">' . $this->l_icon("reports/$report_name/edit/select-data/prepend-data/$id", 'doc-option-add.png', 'Add Data'). "</div>";
$o .= '<div class="forena-edit-links">'
. l($block_name, "reports/$report_name/edit/edit-data/$block_link/$id", $options )
. ' ' . l('Delete', "reports/$report_name/edit/delete-data/$id", $options)
. ' ' . $this->l_icon("reports/$report_name/edit/delete-data/$id", 'doc-option-remove.png', 'Remove Data', $context)
. "</div>";
}
return $o;
......
......@@ -254,6 +254,29 @@ class FrxReport {
return $l;
}
public function getField($id) {
$field = array_fill_keys(array('default', 'link', 'add-query', 'class', 'rel', 'format', 'format-string', 'target'), '');
if ($this->fields) {
$path = 'frx:field[@id="' . $id . '"]';
$formatters = $this->fields->xpath($path);
if ($formatters) {
$formatter = $formatters[0];
//@TODO: Replace the default extraction with something that will get sub elements of the string
$field['default'] = (string)$formatter;
$field['link'] = (string)$formatter['link'];
$field['add-query'] = (string)$formatter['add-query'];
$field['class'] = (string)$formatter['class'];
$field['rel'] = (string)$formatter['rel'];
$field['format'] = (string) $formatter['format'];
$field['format-string'] = (string) $formatter['format-string'];
$field['target'] = (string) $formatter['target'];
}
}
return $field;
}
/*
* Formatter used by the syntax engine to alter data that gets extracted.
* This invokes the field translation
......@@ -335,6 +358,7 @@ class FrxReport {
array('fragment' => $fragment, 'query' => $data, 'attributes' => $attributes, 'absolute' => TRUE)
);
}
if ($this->preview_mode) $value .= Frx::Editor()->fieldLink($key, $value);
return $value;
}
......
......@@ -195,6 +195,16 @@ function forena_menu() {
'type' => MENU_CALLBACK,
);
$items['reports/%/edit/edit-field/%'] = array(
'title' => 'Edit Block',
'file' => 'forena.report.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('forena_report_field_form', 1, 4),
'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',
......
......@@ -499,6 +499,123 @@ function forena_report_delete_confirm_submit($form, &$form_state) {
$form_state['redirect'] = array("reports/$report_name/edit", array('query' => $parms));
}
function forena_report_field_form($form, &$form_state, $report_name, $id) {
$r = Frx::Editor($report_name);
$form['report_name'] = array(
'#type' => 'value',
'#value' => $report_name,
);
$field = $r->frxReport->getField($id);
$form['field'] = array('#tree' => TRUE);
$form['field']['id'] = array(
'#type' => 'value',
'#value' => $id,
);
$form['field']['id_label'] = array(
'#type' => 'item',
'#markup' => $id,
'#title' => t('token'),
);
$form['field']['format'] = array(
'#type' => 'textfield',
'#title' => t('format'),
'#default_value' => $field['format'],
'#size' => 30,
'#autocomplete_path' => 'forena/fields/format/autocomplete',
'#description' => t('Format a date and time field by entering the name of a supported format function. Enter a "*" to see all available formats.')
);
$form['field']['format-string'] = array(
'#type' => 'textfield',
'#title' => t('format-string'),
'#default_value' => $field['format-string'],
'#size' => 30,
'#description' => t('The display type of your format.')
);
$form['field']['link'] = array(
'#type' => 'textfield',
'#title' => t('link'),
'#default_value' => $field['link'],
'#size' => 100,
'#maxlength' => 256,
'#description' => t('Create a link that incorporates this field, e.g "profile/{field_name}" will create a link to this field_name\'s profile. *Note the field must be wrapped in {}.')
);
$form['field']['add-query'] = array(
'#type' => 'checkbox',
'#title' => t('Pass through url parameters'),
'#default_value' => $field['add-query'],
'#description' => t('Automatically pass through url parameters on this link'),
);
$form['field']['rel'] = array(
'#type' => 'textfield',
'#title' => t('rel') ,
'#description' => t('Relationship attribute to apply to the link.'),
'#size' => 100,
'#maxlength' => 256,
'#default_value' => $field['rel'],
);
$form['field']['class'] = array(
'#type' => 'textfield',
'#title' => t('class') ,
'#description' => t('Class applied to be applied to the link.'),
'#size' => 100,
'#maxlength' => 256,
'#default_value' => $field['class'],
);
$form['field']['target'] = array(
'#type' => 'textfield',
'#title' => t('target'),
'#default_value' => $field['target'],
'#size' => 30,
'#description' => t('Link target eg. _BLANK, Targets that begin with "popup" will be opened in a new window using javascript.')
);
$form['field']['default'] = array(
'#type' => 'textfield',
'#title' => t('default value'),
'#default_value' => $field['default'],
'#size' => 30,
'#description' => t('The value to be displayed in the report when no value exists.')
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array('forena_update_cacnel'),
);
return $form;
}
function forena_report_field_form_submit($form, &$form_state) {
$values = $form_state['values'];
$name = $values['report_name'];
$r = Frx::Editor($name);
/*now build the fields*/
$fields = $values['field'];
$r->setFields(array($fields));
$r->update();
$parms = Frx::parms();
$form_state['redirect'] = array("reports/$name/edit", array('query' => $parms));
}
......@@ -141,7 +141,7 @@ class FrxRenderer {
$frx = $node->attributes(FRX_NS);
$tag = $node->getName();
if ($this->frxReport->preview_mode) $o .= Frx::Editor()->editLinks($frx, $id, $context);
if ($this->frxReport->preview_mode) $o .= Frx::Editor()->blockLinks($frx, $id, $context);
if ((string)$frx['block']) {
......@@ -236,7 +236,7 @@ class FrxRenderer {
$r_attr_text .= ' ' . $key . '="' . (string)$value . '"';
}
if ($include_root) $o .= $this->teng->replace('<' . $tag . $r_attr_text . '>');
if ($include_root) $o .= $this->teng->replace('<' . $tag . $r_attr_text . '>', TRUE);
foreach ($dom_node->childNodes as $child) {
$o .= $this->renderDomNode($child);
}
......@@ -255,7 +255,7 @@ class FrxRenderer {
}
}
else {
if ($include_root) $o .= $this->teng->replace('<' . $tag . $attr_text . '>');
if ($include_root) $o .= $this->teng->replace('<' . $tag . $attr_text . '>', TRUE);
// None found, so render children
foreach ($dom_node->childNodes as $child) {
......@@ -280,7 +280,7 @@ class FrxRenderer {
return '';
}
}
$o .= $this->teng->replace($text);
$o .= $node_xml;
}
// Restore link processing.
......
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