Commit 98f7d682 authored by metzlerd's avatar metzlerd
Browse files

Updated editing links.

parent ada54347
......@@ -45,8 +45,6 @@ class FrxEditor {
$dom->preserveWhiteSpace = TRUE;
$this->frxReport = new FrxReport();
$this->load($report_name, $edit);
$cache = forena_load_cache($this->frxReport->rpt_xml);
if (isset($cache['access'])) $this->access = forena_check_all_access($cache['access']);
}
/**
......@@ -90,7 +88,7 @@ class FrxEditor {
$r_text='';
$dom = $this->dom;
$this->report_name = $report_name = $this->desc['name'];
$this->report_link = 'reports/' . str_replace('/', '.', $report_name);
$this->report_link = 'reports/' . str_replace('/', '.', $this->desc['base_name']);
// Load the latest copy of the report editor
if ($report_name) {
if (isset($_SESSION['forena_report_editor'][$report_name]) && $edit) {
......@@ -102,7 +100,6 @@ class FrxEditor {
$r_text = Frx::File()->contents($filename);
}
}
if (!$r_text) {
$m_path = drupal_get_path('module', 'forena');
$r_text = file_get_contents($m_path . '/default.frx');
......@@ -134,6 +131,9 @@ class FrxEditor {
$this->xpq->registerNamespace('frx', $this->xmlns);
// Make sure document header is reparsed.
$this->frxReport->setReport($this->dom, $this->xpq);
$cache = forena_load_cache($this->frxReport->rpt_xml);
if (isset($cache['access'])) $this->access = forena_check_all_access($cache['access']);
if (!$edit) $this->cache = Frx::File()->getCacheEntry($report_name . '.frx');
return $r_text;
}
......@@ -962,6 +962,7 @@ class FrxEditor {
$content = array(
'#has_data' => $r->blocks_loaded,
'parameter_form' => $r->parameters_form,
'editorLinks' => array('#markup' => $this->editorLinks()),
'links' => $this->documentLinks(),
'content' => array('#markup' => $r->html . $links),
);
......@@ -1055,7 +1056,7 @@ class FrxEditor {
$block_label = (string)$frx['block'] ? $block_name : '#' . $id;
$block_link = str_replace('/', '.', $block_name);
$report_name = str_replace('/', '.' , $this->report_name);
$report_name = str_replace('/', '.' , $this->desc['base_name']);
$b = Frx::RepoMan()->loadBlock($block_name);
$options = array();
if ($context) $options['query'] = $context;
......@@ -1116,6 +1117,20 @@ class FrxEditor {
return $templates;
}
public function editorLinks() {
$o = '';
$report_link = $this->report_link;
if (!$this->edit && user_access('design any report')) {
// Add the block or ID link
$o .= '<div class="forena-editor-links">'
. $this->l_icon("$report_link/edit", 'doc-option-edit.png', 'Edit', Frx::Data()->getContext('parm'));
if (module_exists('locale')) $o .= $this->l_icon("$report_link/translations", 'doc-option-tab.png', 'Translations');
if (!$this->cache->include) $o .= $this->l_icon("$report_link/delete", 'doc-option-remove.png', 'Delete');
$o .= "</div>";
}
return $o;
}
public function documentLinks() {
$doctypes = array_keys(Frx::documentTypes());
$links = array();
......
......@@ -56,15 +56,7 @@ function forena_admin_reports() {
return $output;
}
/**
* Remove the report from the database and file system.
* @param string $report_name
*/
function forena_delete_report($report_name) {
$filepath = $report_name . '.frx';
$do = Frx::File()->delete($filepath);
}
......@@ -276,18 +268,17 @@ function forena_create_trans_form($formid, $form_state, $report_name) {
$filename = '';
$format = '';
$desc = Frx::Menu()->parseURL($report_name);
$name = $desc['name'];
$filename = $desc['filename'];
$base_name = $desc['base_name'];
$format = @$desc['format'];
$form = array();
global $language;
$languages = language_list();
//determine if this is an add new report request
$r = Frx::Editor($name);
$r = Frx::Editor($report_name, FALSE);
$base_name = $r->desc['base_name'];
$title = (string)$r->title;
$lang = @$_GET['language'];
$lang = @$_GET['target_language'];
if ($lang) {
$language = $languages[$lang];
}
......@@ -333,19 +324,19 @@ function forena_create_trans_form($formid, $form_state, $report_name) {
}
function forena_create_trans_form_submit($form, &$form_state) {
global $language;
$language = language_default();
$values = $form_state['values'];
$base_name = $values['base_name'];
$new_name = $values['save_report_language'] . '/' . $base_name;
$r = Frx::Editor($base_name, TRUE);
$link = $r->report_link;
// Determine new fielname
$desc = Frx::Menu()->parseURL($new_name);
$filename = $desc['filename'];
$report_name = $desc['name'];
$r = Frx::Editor($base_name);
// Title and category
$r->setTitle($values['title']);
//determine redirection.
if (Frx::File()->exists($filename, FALSE)) {
......@@ -353,9 +344,14 @@ function forena_create_trans_form_submit($form, &$form_state) {
return;
}
else {
// Title and category
$r->setTitle($values['title']);
$r->update();
$r->rename($new_name);
drupal_set_message(t('Translation, %s has been created. Switch languages to translate.', array('%s' => $values['title'])));
$form_state['redirect']= array( $desc['i_link'] . '/edit/layout');
//$r->cancel();
$r->save();
$form_state['redirect']= $link . '/edit';
}
//if this is a new report then redirect to data blocks
......
ul.forena-doclinks {
margin: 0 0.5em;
display: block;
float: right;
width: 10em;
clear: right;
text-align: right;
}
ul.forena-doclinks li {
list-style: none;
display: inline;
margin-right: 0.5em;
padding-left: 0;
}
.forena-editor-links {
diplay: block;
float: right;
width: 10em;
clear: right;
text-align: right;
}
.forena-editor-links a { text-decoration: none; }
ul.forena-doclinks {
margin-left: 0;
}
......
......@@ -913,6 +913,10 @@ function forena_report($name_in, $parms = NULL, $print = TRUE) {
$desc['time'] = date_format($time, 'Y-m-d H:i:s');
$desc['basepath'] = base_path();
if (!$desc['exists']) {
if($print) {
drupal_not_found();
exit;
}
drupal_set_message(t('Report %s not found', array('%s' => $name_in)), 'error', FALSE);
return '';
}
......@@ -922,7 +926,7 @@ function forena_report($name_in, $parms = NULL, $print = TRUE) {
$report_name = $desc['name'];
// Load dataTable plugin if possible.
//forena_include_data_tables();
$content = Frx::Editor($name_in, $print)->report($parms, $print, FALSE);
$content = Frx::Editor($name_in, FALSE)->report($parms, $print, FALSE);
$m_path = drupal_get_path('module', 'forena');
if ($content) {
......
......@@ -250,7 +250,7 @@ function forena_report_save_submit($form, &$form_state) {
}
function forena_report_preview($report_name) {
$r = Frx::Editor($report_name);
$r = Frx::Editor($report_name, TRUE);
drupal_set_title($r->title);
$content['save'] = drupal_get_form('forena_report_save_form', $report_name);
$content['preview'] = $r->preview();
......@@ -801,12 +801,12 @@ function forena_report_translations($name_in='') {
$modified = format_date(filemtime(Frx::File()->path($i_name . '.frx')));
$r = Frx::Editor($i_name);
$title = $r->title;
$edit = l(t('Edit'), 'reports/' . str_replace('/', '.', $i_link) . '/edit', array('query' => array('language' => $key)));
$edit = '';// l(t('Edit'), 'reports/' . str_replace('/', '.', $i_link) . '/edit', array('query' => array('target_language' => $key)));
}
else {
$modified = '';
$title ='';
$edit = l(t('Add'), 'reports/' . $name_in . '/translate', array('query' => array('language' => $key)));
$edit = l(t('Add'), 'reports/' . $name_in . '/translate', array('query' => array('target_language' => $key)));
}
$data[] = array($language->native, $title, $modified, $edit);
......@@ -1604,4 +1604,12 @@ function forena_report_layout_form_submit($form, &$form_state) {
}
/**
* Remove the report from the database and file system.
* @param string $report_name
*/
function forena_delete_report($report_name) {
$filepath = $report_name . '.frx';
$do = Frx::File()->delete($filepath);
}
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