public function displayArgs($mainNode, $transient_options, $action)
 {
     if (!parent::displayArgs($mainNode, $transient_options, $action)) {
         return false;
     }
     $selected = array($this->getField('get_all_fields') ? 1 : 0);
     $this->template->selectOptionsImmediate('get_all_fields', $selected, $mainNode);
     $selected = array($this->getField('use_cache') ? 1 : 0);
     $this->template->selectOptionsImmediate('use_cache', $selected, $mainNode);
     $selected = array($this->getField('use_display_fields') ? 1 : 0);
     $this->template->selectOptionsImmediate('use_display_fields', $selected, $mainNode);
     $transform = '';
     if (($transformNode = $this->storage->traverse("transform", false, false)) instanceof I2CE_MagicDataNode) {
         $transform = $transformNode->getValue();
     }
     $is_file = is_string($transform) && strlen($transform) > 0 && $transform[0] == '@';
     $is_upload = is_string($transform) && strlen($transform) > 0 && $transform[0] != '@';
     if (($selectNode = $this->template->getElementByName('select', 0, $mainNode)) instanceof DOMElement) {
         $options = $this->getXSLTS();
         if ($is_file) {
             if (($doSelectNode = $this->template->getElementByName('do_select', 0, $mainNode)) instanceof DOMElement) {
                 $doSelectNode->setAttribute('checked', 'checked');
             }
             $selected = substr($transform, 1);
         } else {
             $selected = false;
         }
         foreach ($options as $option) {
             $attrs = array('value' => $option);
             if ($option == $selected) {
                 $attrs['selected'] = 'selected';
             }
             $selectNode->appendChild($this->template->createElement('option', $attrs, $option));
         }
         if ($selected) {
             $this->template->setDisplayDataImmediate('has_transform', 1, $mainNode);
             $this->template->setDisplayDataImmediate('transform_link', 'file/' . $selected, $mainNode);
         } else {
             $this->template->setDisplayDataImmediate('has_transform', 0, $mainNode);
         }
     }
     if ($is_upload) {
         if (($doSelectNode = $this->template->getElementByName('do_upload', 0, $mainNode)) instanceof DOMElement) {
             $doSelectNode->setAttribute('checked', 'checked');
         }
         $this->template->setDisplayDataImmediate('has_download', 1, $mainNode);
         $this->template->setDisplayDataImmediate('download_link', "magicDataBrowser/download/" . $this->storage->getPath(false) . "/transform", $mainNode);
     } else {
         $this->template->setDisplayDataImmediate('has_download', 0, $mainNode);
     }
     $this->renameInputs(array('use_display_fields', 'get_all_fields', 'use_cache', 'do_select', 'do_upload', 'select', 'upload', 'do_erase'), $mainNode);
     if (($formfieldsChild = $this->getChild('fields', true)) instanceof I2CE_Swiss && ($formfieldsNode = $this->template->getElementById('fields', $mainNode)) instanceof DOMNode) {
         $formfieldsChild->addAjaxLink('fields_link', 'fields_container', 'fields_ajax', $formfieldsNode, $action, $transient_options);
     }
     return true;
 }
 public function displayArgs($mainNode, $transient_options, $action)
 {
     if (!parent::displayArgs($mainNode, $transient_options, $action)) {
         return false;
     }
     $selected = array($this->getField('use_cache') ? 1 : 0);
     $this->template->selectOptionsImmediate('use_cache', $selected, $mainNode);
     $selected = array($this->getField('segment_style'));
     $this->template->selectOptionsImmediate('segment_style', $selected, $mainNode);
     $selected = array(array_search($this->getField('segment_break'), self::$breaks));
     $this->template->selectOptionsImmediate('segment_break', $selected, $mainNode);
     $formats = I2CE::getConfig()->getAsArray("/modules/PrintedFormsODT/unoconv/conversions");
     $format = $this->getField('format');
     if (($formatNode = $this->template->getElementByName('format', 0, $mainNode)) instanceof DOMNode) {
         foreach ($formats as $f => $data) {
             if (!array_key_exists('ext', $data) || !$data['ext']) {
                 continue;
             }
             $attrs = array('value' => $f);
             if ($format == $f) {
                 $attrs['selected'] = 'selected';
             }
             $formatNode->appendChild($this->template->createElement('option', $attrs, $data['ext']));
         }
     }
     $export_option = '';
     if (I2CE_MagicDataNode::checkKey($format)) {
         $this->storage->setIfIsSet($export_option, "export_options/{$format}");
     }
     $this->template->setDisplayDataImmediate('export_options', $export_option);
     $this->template->setDisplayDataImmediate('connection', $this->getField('connection'));
     $this->template->setDisplayDataImmediate('tmp_dir', $this->getField('tmp_dir'));
     $file = $this->getField('template_file');
     $content = '';
     $this->storage->setIfIsSet($content, 'template_upload/content');
     $is_upload = is_string($content) && strlen($content) > 0;
     //upload takes precedence
     $is_file = is_string($file) && strlen($file) > 0 && !$is_upload;
     if (($selectNode = $this->template->getElementByName('select', 0, $mainNode)) instanceof DOMElement) {
         $options = $this->getODTTemplates();
         $selected = false;
         if ($is_file) {
             if (($doSelectNode = $this->template->getElementByName('do_select', 0, $mainNode)) instanceof DOMElement) {
                 $doSelectNode->setAttribute('checked', 'checked');
             }
             $selected = $file;
         }
         foreach ($options as $option) {
             $attrs = array('value' => $option);
             if ($option == $selected) {
                 $attrs['selected'] = 'selected';
             }
             $selectNode->appendChild($this->template->createElement('option', $attrs, $option));
         }
         if ($file) {
             $this->template->setDisplayDataImmediate('has_template', 1, $mainNode);
             $this->template->setDisplayDataImmediate('template_link', 'file/' . $file, $mainNode);
         } else {
             $this->template->setDisplayDataImmediate('has_template', 0, $mainNode);
         }
     }
     if ($is_upload) {
         if (($doSelectNode = $this->template->getElementByName('do_upload', 0, $mainNode)) instanceof DOMElement) {
             $doSelectNode->setAttribute('checked', 'checked');
         }
         $this->template->setDisplayDataImmediate('has_download', 1, $mainNode);
         $this->template->setDisplayDataImmediate('download_link', "magicDataBrowser/download/" . $this->storage->getPath(false) . "/template_upload/content", $mainNode);
     } else {
         $this->template->setDisplayDataImmediate('has_download', 0, $mainNode);
     }
     if (($relNode = $this->template->getElementByName('header_relationship', 0, $mainNode)) instanceof DOMNode) {
         $relationships = I2CE::getConfig()->getKeys("/modules/CustomReports/relationships");
         $selected_rel = $this->getField('header_relationship');
         foreach ($relationships as $relationship) {
             $attrs = array('value' => $relationship);
             if ($relationship == $selected_rel) {
                 $attrs['selected'] = 'selected';
             }
             $title = false;
             if (I2CE::getConfig()->setIfIsSet($title, "/modules/CustomReports/relationships/{$relationship}/display_name")) {
                 $attrs['title'] = $title;
             }
             $relNode->appendChild($this->template->createElement('option', $attrs, $relationship));
         }
         if ($selected_rel) {
             $this->template->setDisplayDataImmediate('has_header_relationship', 1, $mainNode);
             $this->template->setDisplayDataImmediate('header_relationship_link', "CustomReports/edit/relationships/" . $selected_rel, $mainNode);
         } else {
             $this->template->setDisplayDataImmediate('has_header_relationship', 0, $mainNode);
         }
     }
     $this->renameInputs(array('use_cache', 'do_select', 'do_upload', 'select', 'upload', 'connection', 'tmp_dir', 'format', 'export_options', 'segment_style', 'segment_break', 'header_relationship'), $mainNode);
     if (($formfieldsChild = $this->getChild('required', true)) instanceof I2CE_Swiss && ($formfieldsNode = $this->template->getElementById('fields', $mainNode)) instanceof DOMNode) {
         $formfieldsChild->addAjaxLink('fields_link', 'fields_contents', 'fields_ajax', $formfieldsNode, $action, $transient_options);
     }
     return true;
 }