Commit a15caf28 authored by metzlerd's avatar metzlerd
Browse files

Added the ability to set css styles within the report.

parent 6df3d912
......@@ -398,6 +398,26 @@ class FrxEditor {
}
}
/*
* Set CSS Style Data
* @param $menu_data array of key values for menu options.
*/
public function setStyle($css) {
$dom = $this->dom;
//$this->verifyHeaderElements(array('menu'));
$head = $dom->getElementsByTagName('head')->item(0);
$nodes = $dom->getElementsByTagName('style');
$style = $dom->createElement('style');
$style->appendChild(new DOMText($css));
if ($nodes->length==0) {
$head->appendChild($style);
}
else {
$head->replaceChild($style, $nodes->item(0));
}
}
public function removeParm($id) {
$dom = $this->dom;
$xpq = $this->xpq;
......
......@@ -383,6 +383,7 @@ function forena_layout_form($form, $form_state, $report_name) {
$category = $r->getCategory();
$menu = $r->getMenu();
$body = $r->simplexml->body->asXML();
$css = @(string)$r->simplexml->head->style;
$form = array();
......@@ -414,7 +415,6 @@ function forena_layout_form($form, $form_state, $report_name) {
'#type' => 'text_format',
'#title' => t('Body'),
'#default_value' => $body,
'#rows' => 25,
'#format' => variable_get('forena_input_format', filter_default_format())
);
......@@ -472,6 +472,21 @@ function forena_layout_form($form, $form_state, $report_name) {
'#options' => $menu_options,
);
$form['style'] = array(
'#type' => 'fieldset',
'#title' => t('CSS Styles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['style']['css'] = array(
'#type' => 'textarea',
'#default_value' => $css,
'#description' => t('Specify small css snipets that can be used in the reports.'),
'#rows' => 10,
'#cols' => 80,
);
$form['buttons']['save'] = array(
'#type' => 'submit',
'#value' => 'Save',
......@@ -545,6 +560,8 @@ function forena_layout_form_submit($form, &$form_state) {
// Body
$r->setBody($values['body']['value']);
// CSS
$r->setStyle($values['css']);
// If there are no frx attributes in the body then replace them with the old values.
$frx_nodes = $r->simplexml->xpath('body//*[@frx:*]');
if (!$frx_nodes) {
......
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