/**
  * @param DOMNode $node
  * @param I2CE_Template $template
  * @param DOMNode $form_node
  * 
  */
 public function processDOMEditable_reportSelect($node, $template, $form_node)
 {
     $mf = I2CE_ModuleFactory::instance();
     if (!$mf->isEnabled('CustomReports-Selector')) {
         return false;
     }
     $template->addHeaderLink("mootools-more.js");
     $template->addHeaderLink("getElementsByClassName-1.0.1.js");
     $template->addHeaderLink("I2CE_ClassValues.js");
     $template->addHeaderLink("I2CE_Window.js");
     $template->addHeaderLink("I2CE_ToggableWindow.js");
     $template->addHeaderLink("I2CE_TreeSelect.js");
     $template->addHeaderLink('Observer.js');
     $template->addHeaderLink('Autocompleter.js');
     $template->addHeaderLink('Autocompleter.css');
     $template->addHeaderLink('I2CE_TreeSelectAutoCompleter.js');
     $template->addHeaderLink("Tree.css");
     $style = 'default';
     if ($form_node->hasAttribute('show')) {
         $style = $this->ensureEditStyle($form_node->getAttribute('show'));
     }
     $styles = array($style);
     if ($style != 'default') {
         $styles[] = 'default';
     }
     foreach ($styles as $style) {
         $edit_path = "meta/reportSelect/{$style}";
         $report_path = "{$edit_path}/reportView";
         if (!$this->optionsHasPath($edit_path) || !is_array($options = $this->getOptionsByPath($edit_path))) {
             continue;
         }
         if (!$this->optionsHasPath($report_path) || !is_scalar($reportView = $this->getOptionsByPath($report_path))) {
             continue;
         }
         $report = false;
         $relationship = false;
         $form = false;
         I2CE::getConfig()->setIfIsSet($report, "/modules/CustomReports/reportViews/{$reportView}/report");
         if (!$report) {
             continue;
         }
         I2CE::getConfig()->setIfIsSet($relationship, "/modules/CustomReports/reports/{$report}/relationship");
         if (!$relationship) {
             continue;
         }
         $form = false;
         $reportform_path = "meta/reportSelect/{$style}/reportform";
         $reportform = 'primary_form';
         if ($this->optionsHasPath($reportform_path)) {
             //we are not using the primary form in the relationship, instead we are using a named form.
             $reportform = $this->getOptionsByPath($reportform_path);
             if ($reportform == 'primary_form') {
                 I2CE::getConfig()->setIfIsSet($form, "/modules/CustomReports/relationships/{$relationship}/form");
             } else {
                 try {
                     $relObj = new I2CE_FormRelationship($relationship);
                 } catch (Exception $e) {
                     continue;
                 }
                 $form = $relObj->getForm($reportform);
             }
         } else {
             //we use the primary form
             I2CE::getConfig()->setIfIsSet($form, "/modules/CustomReports/relationships/{$relationship}/form");
         }
         if (!$form) {
             continue;
         }
         if (!$this->canSelectAnyForm()) {
             $form_path = "meta/form";
             if (!$this->optionsHasPath($form_path) || !is_array($forms = $this->getOptionsByPath($form_path))) {
                 continue;
             }
             if (!in_array($form, $forms)) {
                 continue;
             }
         }
         $printf_path = "meta/display/{$form}/{$style}/printf";
         $printfargs_path = "meta/display/{$form}/{$style}/printf_args";
         if (!$this->optionsHasPath($printf_path) || !is_string($printf = $this->getOptionsByPath($printf_path))) {
             continue;
         }
         if (!$this->optionsHasPath($printfargs_path) || !is_array($printfargs = $this->getOptionsByPath($printfargs_path))) {
             continue;
         }
         if (strlen($printf) == 0) {
             continue;
         }
         if (count($printfargs) == 0) {
             continue;
         }
         ksort($printfargs);
         $disp = $this->_getDisplayValue(null, $style);
         $node->setAttribute('id', $this->getHTMLName());
         $options = array('reportview' => $reportView, 'printf' => $printf, 'printfargs' => $printfargs, 'display' => $disp, 'value' => $this->getDBValue(), 'reportform' => $reportform);
         $no_limits_path = "meta/display/{$form}/{$style}/no_limits";
         if ($this->optionsHasPath($no_limits_path) && $this->getOptionsByPath($no_limits_path)) {
             $options['contentid'] = 'report_results';
         } else {
             $options['contentid'] = 'report_results_with_limits';
         }
         $options['multi_select'] = 1;
         if ($template->addReportSelector($node, $options)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * @param DOMNode $node
  * @param I2CE_Template $template
  * @param DOMNode $form_node
  * 
  */
 public function processDOMEditable_reportSelect($node, $template, $form_node)
 {
     $mf = I2CE_ModuleFactory::instance();
     if (!$mf->isEnabled('CustomReports-Selector')) {
         return false;
     }
     $style = 'default';
     if ($form_node->hasAttribute('show')) {
         //$style = $this->ensureEditStyle($form_node->getAttribute('show'));
         $style = $form_node->getAttribute('show');
     }
     $styles = array($style);
     if ($style != 'default') {
         $styles[] = 'default';
     }
     foreach ($styles as $style) {
         $edit_path = "meta/reportSelect/{$style}";
         $report_path = "{$edit_path}/reportView";
         if (!$this->optionsHasPath($edit_path) || !is_array($options = $this->getOptionsByPath($edit_path))) {
             continue;
         }
         if (!$this->optionsHasPath($report_path) || !is_scalar($reportView = $this->getOptionsByPath($report_path))) {
             continue;
         }
         $report = false;
         $relationship = false;
         $form = false;
         I2CE::getConfig()->setIfIsSet($report, "/modules/CustomReports/reportViews/{$reportView}/report");
         if (!$report) {
             continue;
         }
         I2CE::getConfig()->setIfIsSet($relationship, "/modules/CustomReports/reports/{$report}/relationship");
         if (!$relationship) {
             continue;
         }
         $form = false;
         I2CE::getConfig()->setIfIsSet($form, "/modules/CustomReports/relationships/{$relationship}/form");
         if (!$form) {
             continue;
         }
         if (!$this->canSelectAnyForm()) {
             $form_path = "meta/form";
             if (!$this->optionsHasPath($form_path) || !is_array($forms = $this->getOptionsByPath($form_path))) {
                 continue;
             }
             if (!in_array($form, $forms)) {
                 continue;
             }
         }
         $printf_path = "meta/display/{$form}/{$style}/printf";
         $printfargs_path = "meta/display/{$form}/{$style}/printf_args";
         if (!$this->optionsHasPath($printf_path) || !is_string($printf = $this->getOptionsByPath($printf_path))) {
             continue;
         }
         if (!$this->optionsHasPath($printfargs_path) || !is_array($printfargs = $this->getOptionsByPath($printfargs_path))) {
             continue;
         }
         if (strlen($printf) == 0) {
             continue;
         }
         if (count($printfargs) == 0) {
             continue;
         }
         ksort($printfargs);
         $disp = $this->_getDisplayValue(null, $style);
         $node->setAttribute('id', $this->getHTMLName());
         $options = array('reportview' => $reportView, 'printf' => $printf, 'printfargs' => $printfargs, 'display' => $disp, 'value' => $this->getDBValue());
         if ($this->getOption('required')) {
             $options['allow_clear'] = false;
         }
         $no_limits_path = "meta/display/{$form}/{$style}/no_limits";
         if ($this->optionsHasPath($no_limits_path) && $this->getOptionsByPath($no_limits_path)) {
             $options['contentid'] = 'report_results';
         } else {
             $options['contentid'] = 'report_results_with_limits';
         }
         if ($template->addReportSelector($node, $options)) {
             return true;
         }
     }
     return false;
 }