/** * Process a result row. * @param array $row * @param int $row_num The current row number when processing results. If there was a result limit, it starts the count from the beginning of the * result offset. Othwerwise, it starts counting form zero. * @param DOMNode $contentNode. Default to null. A node to append the result onto */ protected function processResultRow($row, $row_num, $contentNode = null) { parent::processResultRow($row, $row_num, $contentNode); $per_page = (int) $this->defaultOptions['limit_per_page']; if ($per_page < 1) { //check it is not bad, if so make it something reasonable -- in fact make it the default per page in I2CE_CustomReport_Display $per_page = 100; } $page = (int) $this->defaultOptions['limit_page']; //$page = (int) $this->page->request('limit_page'); if ($page < 1) { $page = 1; } $appendCount = $row_num - ($page - 1) * $per_page; $field_args = array(); foreach ($this->page->getActionFields() as $field) { $field_args[] = $row->{$field}; } $actionNodes = $this->page->getActionNode($field_args); if (!is_array($actionNodes)) { $actionNodes = array($actionNodes); } foreach ($actionNodes as $actionNode) { $cellNode = $this->template->appendFileByName("customReports_table_data_cell.html", "td", "report_row", $appendCount, null, true); if (!$cellNode instanceof DOMNode) { I2CE::raiseError("Could not add data cell to table"); return false; } $this->template->appendNode($actionNode, $cellNode); } return true; }
/** * Display the report * @param DOMNode $contentNode The DOM node we wish to display into. If null, we do not do any of the DOM processing stuff, do * not call the report display controls, limits etc. It will however still call processResults with a DOMNode of null * @param boolean $processResults Defaults to true meaning we run through the results. If false, we do not process results. * @param mixed $controls. If null (default), we display all the report controsl. If string or an array of string, we only display the indicated controls * @returns boolean. true on sucess */ public function display($contentNode, $processResults = true, $controls = null) { if (!$this->selectid || !$this->printf || !is_array($this->printf_args) || count($this->printf_args) == 0) { return false; } return parent::display($contentNode, $processResults, $controls); }
/** * Process the results * @param array $results_data * @param DOMNode $contentNode * @return boolean */ protected function processResults($results_data, $contentNode = null) { if (parent::processResults($results_data, $contentNode)) { $links = $this->template->query("descendant::span[@name='report_data' and starts-with(.,'link:')]", $contentNode); $link_len = $links->length; if ($link_len > 0) { for ($i = 0; $i < $link_len; $i++) { $link_node = $links->item($i); $link_data = explode(':', $link_node->nodeValue, 3); if (count($link_data) == 3) { $anchor = $this->template->createElement("a", array("href" => $link_data[1]), $link_data[2]); $link_node->replaceChild($anchor, $link_node->firstChild); } } } return true; } return false; }
public function getDisplayFieldsData() { $data = parent::getDisplayFieldsData(); if (!array_key_exists('primary_form+id', $data)) { $data['primary_form+id'] = array('header' => 'Person ID', 'link' => false, 'target' => false, 'link_append' => false, 'link_type' => false); } if (!array_key_exists('primary_form+csd_uuid', $data)) { $data['primary_form+csd_uuid'] = array('header' => 'CSD EnitityID', 'link' => false, 'target' => false, 'link_append' => false, 'link_type' => false); } return $data; }
/** * Adds any controls for this display to the content node. * @param DOMNode $contentNode * @returns boolean; */ protected function displayReportControl($contentNode) { parent::displayReportControl($contentNode); $avail_fields = $this->getReportViewDisplayedFields(false, array('')); $js = "function validateCrossTabOptions() {\n\tvar ct_values = {'" . self::CROSSTAB_LEFT . "':0, '" . self::CROSSTAB_TOP . "':0};\n"; $field_table = $this->template->getElementById("form_field_list", $contentNode); if (!$field_table instanceof DOMNode) { I2CE::raiseError("Unable to find form_field_list id in DOM"); return false; } $field_count = 0; foreach ($avail_fields as $reportformfield => $data) { if (!$data || !is_array($data)) { continue; } $current_value = null; if (array_key_exists('displayFieldsTab', $this->defaultOptions) && array_key_exists($reportformfield, $this->defaultOptions['displayFieldsTab'])) { $current_value = $this->defaultOptions['displayFieldsTab'][$reportformfield]; } $field_count++; $tr = $this->template->createElement("tr", array("class" => "even")); $attr = array("type" => "radio", "name" => "displayFieldsTab:{$reportformfield}", "onchange" => "validateCrossTabOptions();"); $td = $this->template->createElement("td", array(), $data['header']); $tr->appendChild($td); $td_left = $this->template->createElement("td", array("style" => "text-align: center; vertical-align: middle;")); $attr["value"] = self::CROSSTAB_LEFT; if ($current_value === null ? $field_count == 1 : $current_value == self::CROSSTAB_LEFT) { $attr["checked"] = "checked"; } $radio_left = $this->template->createElement("input", $attr); $td_left->appendChild($radio_left); $tr->appendChild($td_left); $td_top = $this->template->createElement("td", array("style" => "text-align: center; vertical-align: middle;")); unset($attr["checked"]); $attr["value"] = self::CROSSTAB_TOP; if ($current_value === null ? $field_count == 2 : $current_value == self::CROSSTAB_TOP) { $attr["checked"] = "checked"; } $radio_top = $this->template->createElement("input", $attr); $td_top->appendChild($radio_top); $tr->appendChild($td_top); $td_none = $this->template->createElement("td", array("style" => "text-align: center; vertical-align: middle;")); $attr["value"] = self::CROSSTAB_NONE; unset($attr["checked"]); if ($current_value === null ? $field_count > 2 : $current_value == self::CROSSTAB_NONE) { $attr["checked"] = "checked"; } $radio_none = $this->template->createElement("input", $attr); $td_none->appendChild($radio_none); $tr->appendChild($td_none); $field_table->appendChild($tr); $js .= "\tct_values[ \$('limit_form').getElement('input[name=displayFieldsTab:{$reportformfield}]:checked').value ]++;\n"; } $js .= "\tif ( ct_values['" . self::CROSSTAB_LEFT . "'] < 1 || ct_values['" . self::CROSSTAB_TOP . "'] < 1 ) {\n\t\t\$('CrossTab_submit').hide();\n\t\t\$('CrossTab_error').show();\n\t} else {\n\t\t\$('CrossTab_error').hide();\n\t\t\$('CrossTab_submit').show();\n\t}\n}\n"; //$js .= "\tfor ( i in ct_values ) { alert( i+' '+ct_values[i] ); }\n\treturn true;\n}\n"; $this->template->addHeaderLink('mootools-core.js'); $this->template->addHeaderText($js, 'script', true); return true; }