protected function displayReportControl($contentNode) { parent::displayReportControl($contentNode); if ($this->page instanceof CSD_Page_RapidPro_Base && $this->page->rapidpro instanceof CSD_Interface_RapidPro) { $this->page->rapidpro->set_flow_options($this->page->getTemplate(), $this->page->request('flow'), 'siteContent'); } return true; }
/** * 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; }