. */ require_once('ExportBase.php'); require_once('CFDBExport.php'); require_once('CFDBShortCodeContentParser.php'); class ExportToHtmlTable extends ExportBase implements CFDBExport { /** * @var bool */ static $wroteDefaultHtmlTableStyle = false; var $useBom = false; public function setUseBom($use) { $this->useBom = $use; } /** * Echo a table of submitted form data * @param string $formName * @param array $options * @return void|string returns String when called from a short code, * otherwise echo's output and returns void */ public function export($formName, $options = null) { $this->setOptions($options); $this->setCommonOptions(true); $canDelete = false; $useDT = false; $editMode = false; $printScripts = false; $printStyles = false; if ($options && is_array($options)) { if (isset($options['useDT'])) { $useDT = $options['useDT']; //$this->htmlTableClass = ''; if (isset($options['printScripts'])) { $printScripts = $options['printScripts']; } if (isset($options['printStyles'])) { $printStyles = $options['printStyles']; } if (isset($options['edit'])) { $this->dereferenceOption('edit'); $editMode = 'true' == $this->options['edit'] || 'cells' == $this->options['edit']; } } if (isset($options['canDelete'])) { $canDelete = $options['canDelete']; } } // Security Check if (!$this->isAuthorized()) { $this->assertSecurityErrorMessage(); return; } if ($editMode && !$this->plugin->canUserDoRoleOption('CanChangeSubmitData')) { $editMode = false; } // Headers $this->echoHeaders('Content-Type: text/html; charset=UTF-8'); // Query DB for the data for that form $submitTimeKeyName = 'Submit_Time_Key'; $this->setDataIterator($formName, $submitTimeKeyName); //$this->clearAllOutputBuffers(); // will mess up the admin table view if ($this->isFromShortCode) { ob_start(); if ($this->useBom) { // File encoding UTF-8 Byte Order Mark (BOM) http://wiki.sdn.sap.com/wiki/display/ABAP/Excel+files+-+CSV+format echo chr(239) . chr(187) . chr(191); } } else { if ($this->useBom) { // File encoding UTF-8 Byte Order Mark (BOM) http://wiki.sdn.sap.com/wiki/display/ABAP/Excel+files+-+CSV+format echo chr(239) . chr(187) . chr(191); } if ($printScripts) { $pluginUrl = plugins_url('/', __FILE__); wp_enqueue_script('datatables', $pluginUrl . 'DataTables/media/js/jquery.dataTables.min.js', array('jquery')); wp_print_scripts('datatables'); } if ($printStyles) { $pluginUrl = plugins_url('/', __FILE__); wp_enqueue_style('datatables-demo', $pluginUrl .'DataTables/media/css/demo_table.css'); wp_enqueue_style('jquery-ui.css', $pluginUrl . 'jquery-ui/jquery-ui.css'); wp_print_styles(array('jquery-ui.css', 'datatables-demo')); } } // Break out sections: Before, Content, After $before = ''; $content = ''; $after = ''; if (isset($options['content'])) { $contentParser = new CFDBShortCodeContentParser; list($before, $content, $after) = $contentParser->parseBeforeContentAfter($options['content']); } if ($before) { // Allow for short codes in "before" echo do_shortcode($before); } if ($useDT) { $dtJsOptions = isset($options['dt_options']) ? $options['dt_options'] : '"bJQueryUI": true, "aaSorting": [], "iDisplayLength": -1, "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "' . __('All', 'contact-form-7-to-database-extension') . '"]]'; $i18nUrl = $this->plugin->getDataTableTranslationUrl(); if ($i18nUrl) { if (!empty($dtJsOptions)) { $dtJsOptions .= ','; } $dtJsOptions .= " \"oLanguage\": { \"sUrl\": \"$i18nUrl\" }"; } $dtJsOptions = stripslashes($dtJsOptions); // unescape single quotes when posted via URL ?> htmlTableClass == $this->defaultTableClass && !ExportToHtmlTable::$wroteDefaultHtmlTableStyle) { ?> style) { ?>
dataIterator->getDisplayColumns() as $aCol) { $colDisplayValue = htmlentities($aCol, null, 'UTF-8'); // no HTML injection if ($this->headers && isset($this->headers[$aCol])) { $colDisplayValue = htmlentities($this->headers[$aCol], null, 'UTF-8');; } printf(' | %s | ', $colDisplayValue, $formName, $aCol, $colDisplayValue);
}
?>
---|---|
dataIterator->row['fields_with_file']) && $this->dataIterator->row['fields_with_file'] != null) { $fields_with_file = explode(',', $this->dataIterator->row['fields_with_file']); } foreach ($this->dataIterator->getDisplayColumns() as $aCol) { $cell = $this->rawValueToPresentationValue( $this->dataIterator->row[$aCol], $showLineBreaks, ($fields_with_file && in_array($aCol, $fields_with_file)), $this->dataIterator->row[$submitTimeKeyName], $formName, $aCol); // NOTE: the ID field is used to identify the cell when an edit happens and we save that to the server printf(' | %s | ', $aCol, $submitKey, $aCol, $cell);
}
?>