/**
  * Process results
  * @param array $results_data an array of results.  indices are 'results' and MDB2 Buffered result and 'num_results' the
  * number of results.  (these values may be false on failure)
  * @param DOMNode $contentNode.  Default to null a node to append the results onto
  */
 protected function processResults($results_data, $contentNode = null)
 {
     $this->preProcessResults();
     parent::processResults($results_data, $contentNode);
     $this->postProcessResults();
     if (count($this->data['table']['rows']) < 1) {
         $this->sendError();
     } else {
         $this->sendData();
     }
 }
 /**
  * Process results
  * @param array $results_data an array of results.  indices are 'results' and MDB2 Buffered result and 'num_results' the
  * number of results.  (these values may be false on failure)
  * @param DOMNode $contentNode.  Default to null a node to append the results onto
  */
 protected function processResults($results_data, $contentNode = null)
 {
     if ($this->page->request_exists('flash_data')) {
         require_once I2CE::getFileSearch()->search('MAANI_CHART_FILES', 'charts.php');
         if (substr($this->defaultOptions['displayFieldsType'], 0, 7) == 'one_row') {
             $this->preProcessResultsOneRow();
         } else {
             $this->preProcessResultsMultiRow();
         }
         parent::processResults($results_data, $contentNode);
         if (!array_key_exists('num_results', $results_data) || $results_data['num_results'] == 0) {
             // Nothing was found so just show a message instead of
             // the confusing default report.
             unset($this->chart['chart_data']);
             unset($this->chart['draw']['print']);
             $this->chart['chart_rect']['x'] = 1000;
             $this->chart['chart_rect']['y'] = 1000;
             $this->chart['legend_rect']['x'] = 1000;
             $this->chart['legend_rect']['y'] = 1000;
             $message = "Error!";
             I2CE::getConfig()->setIfIsSet($message, "/modules/CustomReports/displays/PieChart/error_message");
             $msg_arr = explode("\n", wordwrap($message, 40));
             $start_y = 25;
             foreach ($msg_arr as $num => $msg_line) {
                 $this->chart['draw']['error' . $num] = array('color' => '000000', 'size' => 25, 'type' => 'text', 'text' => $msg_line, 'height' => 100, 'width' => 500, 'x' => 25, 'y' => $start_y);
                 $start_y += 25;
             }
             $this->SendChartData();
         }
         if (substr($this->defaultOptions['displayFieldsType'], 0, 7) == 'one_row') {
             $this->postProcessResultsOneRow();
         } else {
             $this->postProcessResultsMultiRow();
         }
         $this->setupHeightWidth();
         $this->SendChartData();
     } else {
         // I don't think this ever gets called anymore?  Can it just be removed?
         I2CE::raiseError("I don't think this should be called this way anymore.  It's being added to display() instead.");
         //just make a reference to the chart
         $i2ce_config = I2CE::getConfig();
         $license = '';
         $license = $i2ce_config->setIfIsSet($license, 'modules/maani-charts/license');
         //$results_data will be false b/c we called parent::display($contentNode,false) in display() above
         if (!$contentNode instanceof DOMNode) {
             return false;
         }
         $this->template->addHeaderLink('swfobject.js');
         $flashDataURL = 'index.php/file/charts.swf?library_path=index.php/file/charts_library';
         if ($license) {
             $flashDataURL .= '&license=' . $license;
         }
         $save_req = "flash_data&" . file_get_contents("php://input") . "&" . $_SERVER['QUERY_STRING'];
         $req_key = md5($save_req);
         $_SESSION['req_query'][$req_key] = $save_req;
         $flashDataURL .= '&php_source=' . urlencode("index.php/CustomReports/show/{$this->view}/{$this->display}?req_query=" . $req_key);
         $js = "\tif(window.addEvent) { window.addEvent('domready', function() { swfobject.embedSWF('{$flashDataURL}', \n\t\t'{$report_results}', '{$this->defaultOptions['flash_width']}', " . " '{$this->defaultOptions['flash_height']}', '9.0.0' ,'expressInstall.swf',  \n\t\t" . " {}, \n\t\t{quality: 'high', bgcolor:'{$this->defaultOptions['flash_bgcolor']}',wmode:'opaque'}\n\t); } ); } ";
         $this->template->addHeaderLink('mootools-core.js');
         $this->template->addHeaderText($js, 'script', true);
         //add this to a new script node.
         return true;
     }
 }
 /**
  * Process results
  * @param array $results_data an array of results.  indices are 'results' and MDB2 Buffered result and 'num_results' the
  * number of results.  (these values may be false on failure)
  * @param DOMNode $contentNode.  Default to null a node to append the results onto
  */
 protected function processResults($results_data, $contentNode = null)
 {
     $this->pivots = $this->getPivots();
     //add int the header fields to the table
     if (!$results_data['num_results']) {
         $this->noData($contentNode);
         return true;
     }
     $tableContainerNode = $this->template->appendFileByNode("customReports_table.html", 'div', $contentNode);
     //add the report table shell
     if (!$tableContainerNode instanceof DOMNode) {
         I2CE::raiseError("Could not add table container template");
         return false;
     }
     $this->template->setAttribute("id", $this->getReportPrefix() . 'report_pager_display', "report_pager_display");
     $this->doJumper($results_data['num_results'], $tableContainerNode);
     $reportBodyNode = $this->template->getElementById('report_body', $tableContainerNode);
     if (!$reportBodyNode instanceof DOMNode) {
         I2CE::raiseError("Could not find report body");
         return false;
     }
     $this->doHeaderRow($tableContainerNode);
     $this->template->setDisplayDataImmediate('num_results', $results_data['num_results'], $tableContainerNode);
     return parent::processResults($results_data, $reportBodyNode);
 }