/** * @param $atts array of short code attributes * @return string JSON. See ExportToJson.php */ public function handleShortcode($atts) { if (isset($atts['form'])) { $atts['html'] = true; $atts['fromshortcode'] = true; require_once 'ExportToJson.php'; $export = new ExportToJson(); return $export->export($atts['form'], $atts); } }
/** * @param $atts array of short code attributes * @param $content string inner content of short code * @return string JSON. See ExportToJson.php */ public function handleShortcode($atts, $content = null) { if (isset($atts['form'])) { $atts = $this->decodeAttributes($atts); $atts['content'] = $content; $atts['html'] = true; $atts['fromshortcode'] = true; require_once 'ExportToJson.php'; $export = new ExportToJson(); return $export->export($atts['form'], $atts); } return ''; }
static function export($formName, $encoding, $options) { switch ($encoding) { case 'HTML': require_once 'ExportToHtmlTable.php'; $exporter = new ExportToHtmlTable(); $exporter->export($formName, $options); break; case 'HTMLBOM': // IQY callback require_once 'ExportToHtmlTable.php'; $exporter = new ExportToHtmlTable(); $exporter->setUseBom(true); $exporter->export($formName, $options); break; case 'DT': require_once 'ExportToHtmlTable.php'; if (!is_array($options)) { $options = array(); } $options['useDT'] = true; if (!isset($options['printScripts'])) { $options['printScripts'] = true; } if (!isset($options['printStyles'])) { $options['printStyles'] = 'true'; } $exporter = new ExportToHtmlTable(); $exporter->export($formName, $options); break; case 'HTMLTemplate': require_once 'ExportToHtmlTemplate.php'; $exporter = new ExportToHtmlTemplate(); $exporter->export($formName, $options); break; case 'IQY': require_once 'ExportToIqy.php'; $exporter = new ExportToIqy(); $exporter->export($formName, $options); break; case 'CSVUTF8BOM': $options['unbuffered'] = 'true'; require_once 'ExportToCsvUtf8.php'; $exporter = new ExportToCsvUtf8(); $exporter->setUseBom(true); $exporter->export($formName, $options); break; case 'TSVUTF16LEBOM': $options['unbuffered'] = 'true'; require_once 'ExportToCsvUtf16le.php'; $exporter = new ExportToCsvUtf16le(); $exporter->export($formName, $options); break; case 'GLD': require_once 'ExportToGoogleLiveData.php'; $exporter = new ExportToGoogleLiveData(); $exporter->export($formName, $options); break; case 'GSS': $options['unbuffered'] = 'true'; require_once 'ExportToGoogleSS.php'; $exporter = new ExportToGoogleSS(); $exporter->export($formName, $options); break; case 'JSON': require_once 'ExportToJson.php'; $exporter = new ExportToJson(); $exporter->export($formName, $options); break; case 'VALUE': require_once 'ExportToValue.php'; $exporter = new ExportToValue(); $exporter->export($formName, $options); break; case 'COUNT': require_once 'ExportToValue.php'; if (!is_array($options)) { $options = array(); } $options['function'] = 'count'; unset($options['show']); unset($options['hide']); $exporter = new ExportToValue(); $exporter->export($formName, $options); break; case 'CSVSJIS': require_once 'ExportToCsvUtf8.php'; $exporter = new ExportToCsvUtf8(); $exporter->setUseBom(false); $exporter->setUseShiftJIS(true); $exporter->export($formName, $options); break; case 'RSS': require_once 'ExportToRSS.php'; $exporter = new ExportToRSS(); $exporter->export($formName, $options); break; case 'ENTRY': require_once 'ExportEntry.php'; $exporter = new ExportEntry(); $exporter->export($formName, $options); break; case 'CSVUTF8': default: require_once 'ExportToCsvUtf8.php'; $exporter = new ExportToCsvUtf8(); $exporter->setUseBom(false); $exporter->export($formName, $options); break; } }
public function test_SortByDateField_desc_format() { $options = array(); $options['trans'] = 'SortByDateField(date,DESC,m/d/Y)'; $exp = new ExportToJson(); ob_start(); $exp->export('Form', $options); $text = ob_get_contents(); $stuff = json_decode($text); $idx = 0; $this->assertTrue(is_array($stuff)); $this->assertEquals('C', $stuff[$idx++]->name); $this->assertEquals('B', $stuff[$idx++]->name); $this->assertEquals('A', $stuff[$idx++]->name); }
public function test_hide() { $options = array(); $options['trans'] = 'misc=strtoupper(misc)'; $options['orderby'] = 'misc DESC'; $options['hide'] = 'misc,Submitted'; $exp = new ExportToJson(); ob_start(); $exp->export('Ages', $options); $text = ob_get_contents(); $stuff = json_decode($text); $this->assertTrue(is_array($stuff)); $this->assertFalse(isset($stuff[0]->misc)); $this->assertFalse(isset($stuff[0]->Submitted)); $this->assertEquals('d', $stuff[0]->name); $this->assertEquals('.99999', $stuff[0]->age); }
public function testSometimesAddNewFieldInTransformEntry2() { $options = array(); $options['trans'] = 'sometimesNewFields2'; $exp = new ExportToJson(); ob_start(); $exp->export('form', $options); $text = ob_get_contents(); $stuff = json_decode($text); $idx = 0; $this->assertTrue(is_array($stuff)); $this->assertEquals('1', $stuff[$idx]->a); $this->assertEquals('2', $stuff[$idx]->b); // todo: should be first following line, not second //$this->assertEquals('', $stuff[$idx]->c); $this->assertFalse(isset($stuff[$idx]->c)); ++$idx; $this->assertEquals('20', $stuff[$idx]->a); $this->assertEquals('30', $stuff[$idx]->b); // todo: should be first following line, not second // $this->assertEquals('50', $stuff[$idx]->c); $this->assertFalse(isset($stuff[$idx]->c)); }
public function test_str_replace_with_blank() { $options = array(); $options['trans'] = 'misc2=str_replace(x,,misc)'; $exp = new ExportToJson(); ob_start(); $exp->export('Ages', $options); $text = ob_get_contents(); $stuff = json_decode($text); $this->assertTrue(is_array($stuff)); foreach ($stuff as $entry) { $this->assertEquals(str_replace('x', '', $entry->misc), $entry->misc2); } }