From: <gem...@li...> - 2011-09-26 10:01:03
|
Revision: 72 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=72&view=rev Author: mennodekker Date: 2011-09-26 10:00:57 +0000 (Mon, 26 Sep 2011) Log Message: ----------- Fixing spss variable names and line breaks in text fields Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2011-09-23 07:57:42 UTC (rev 71) +++ trunk/library/classes/Gems/Export/Spss.php 2011-09-26 10:00:57 UTC (rev 72) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -125,8 +124,10 @@ $answerRow = reset($answers); $labels = array(); $types = array(); + $fixedNames = array(); $questions = $survey->getQuestionList($language); foreach($answerRow as $key => $value) { + $fixedNames[$key] = $this->fixName($key); $options = array(); $type = $answerModel->get($key,'type'); switch ($type) { @@ -166,18 +167,18 @@ if (isset($questions[$key])) { $labels[$key] = $questions[$key]; } - $response->appendBody("\n " . $key . ' '. $type); + $response->appendBody("\n " . $fixedNames[$key] . ' '. $type); } $response->appendBody(".\nCACHE.\nEXECUTE.\n"); $response->appendBody("\n*Define variable labels.\n"); foreach($labels as $key => $label) { - $response->appendBody("VARIABLE LABELS " . $key . ' "' . $label . '".' . "\n"); + $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . ' "' . $label . '".' . "\n"); } $response->appendBody("\n*Define value labels.\n"); foreach($answerRow as $key => $value) { if($options = $answerModel->get($key, 'multiOptions')) { - $response->appendBody('VALUE LABELS ' . $key); + $response->appendBody('VALUE LABELS ' . $fixedNames[$key]); foreach($options as $option=>$label) { if($types[$key]=='F') { //Numeric @@ -263,8 +264,25 @@ * @return string */ public function formatString($input) { - $output = str_replace("'", "''", $input); + $output = strip_tags($input); + $output = str_replace(array("'", "\r", "\n"), array("''", ' ', ' '), $output); $output = "'" . $output . "'"; return $output; } + + /** + * Make sure the $input fieldname is correct for usage in SPSS + * + * Should start with alphanum, and contain no spaces + * + * @param string $input + * @return string + */ + public function fixName($input) { + if (!preg_match ("/^([a-z]|[A-Z])+.*$/", $input)) { + $input = "q_" . $input; + } + $input = str_replace(array(" ","-",":",";","!","/","\\","'"), array("_","_hyph_","_dd_","_dc_","_excl_","_fs_","_bs_",'_qu_'), $input); + return $input; + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-12 08:30:22
|
Revision: 830 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=830&view=rev Author: mennodekker Date: 2012-07-12 08:30:11 +0000 (Thu, 12 Jul 2012) Log Message: ----------- Fixed 543: IE will not download spss export dev: content-type set tot text/plain and some reformatting Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2012-07-10 12:19:28 UTC (rev 829) +++ trunk/library/classes/Gems/Export/Spss.php 2012-07-12 08:30:11 UTC (rev 830) @@ -47,10 +47,31 @@ */ class Gems_Export_Spss extends Gems_Export_ExportAbstract { + /** + * Set response headers and clean output + * + * @param string $filename + * @return Zend_Controller_Response_Abstract + */ + private function _doHeaders($filename) + { + $controller = $this->export->controller; + $controller->getHelper('layout')->disableLayout(); + $controller->getHelper('viewRenderer')->setNoRender(true); + $response = $controller->getResponse(); + $response->clearAllHeaders(); + $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"') + ->setHeader('Content-type', 'text/plain; charset=UTF-8') + ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') + ->setHeader('Pragma', 'public'); + + return $response; + } + public function getDefaults() { - return array('file'=>'data'); + return array('file' => 'data'); } public function getFormElements(&$form, &$data) @@ -58,8 +79,7 @@ $element = new Zend_Form_Element_Radio('file'); $element->setLabel($this->_('Which file')); $element->setMultiOptions(array('syntax' => $this->_('syntax'), - 'data' => $this->_('data'))); - + 'data' => $this->_('data'))); $elements[] = $element; $element = new MUtil_Form_Element_Exhibitor('help'); @@ -96,17 +116,9 @@ if (isset($options['file'])) { if ($options['file'] == 'syntax') { - $controller = $this->export->controller; - $controller->getHelper('layout')->disableLayout(); - $controller->getHelper('viewRenderer')->setNoRender(true); - $response = $controller->getResponse(); $filename = $survey->getName() . '.sps'; $filenameDat = $survey->getName() . '.dat'; - $response->clearHeaders(); - $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"') - ->setHeader('Content-type', 'text/comma-separated-values; charset=UTF-8') - ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->setHeader('Pragma', 'public'); + $response = $this->_doHeaders($filename); //first output our script $response->appendBody( @@ -121,15 +133,15 @@ /FIRSTCASE=1 /IMPORTCASE=ALL /VARIABLES="); - $answerRow = reset($answers); - $labels = array(); - $types = array(); + $answerRow = reset($answers); + $labels = array(); + $types = array(); $fixedNames = array(); - $questions = $survey->getQuestionList($language); - foreach($answerRow as $key => $value) { + $questions = $survey->getQuestionList($language); + foreach ($answerRow as $key => $value) { $fixedNames[$key] = $this->fixName($key); - $options = array(); - $type = $answerModel->get($key,'type'); + $options = array(); + $type = $answerModel->get($key, 'type'); switch ($type) { case MUtil_Model::TYPE_DATE: $type = 'SDATE10'; @@ -142,74 +154,66 @@ case MUtil_Model::TYPE_NUMERIC: $defaultSize = 5; - $type = 'F'; + $type = 'F'; break; //When no type set... assume string case MUtil_Model::TYPE_STRING: default: $defaultSize = 64; - $type = 'A'; + $type = 'A'; break; } $types[$key] = $type; if ($type == 'A' || $type == 'F') { - $size = $answerModel->get($key,'size'); + $size = $answerModel->get($key, 'size'); if (is_null($size)) { $size = $defaultSize; } if ($type == 'A') { $type = $type . $size; } else { - $type = $type . $size . '.' . ($size-1); //decimal + $type = $type . $size . '.' . ($size - 1); //decimal } } if (isset($questions[$key])) { $labels[$key] = $questions[$key]; } - $response->appendBody("\n " . $fixedNames[$key] . ' '. $type); + $response->appendBody("\n " . $fixedNames[$key] . ' ' . $type); } $response->appendBody(".\nCACHE.\nEXECUTE.\n"); $response->appendBody("\n*Define variable labels.\n"); - foreach($labels as $key => $label) { + foreach ($labels as $key => $label) { $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . ' "' . $label . '".' . "\n"); } $response->appendBody("\n*Define value labels.\n"); - foreach($answerRow as $key => $value) { - if($options = $answerModel->get($key, 'multiOptions')) { + foreach ($answerRow as $key => $value) { + if ($options = $answerModel->get($key, 'multiOptions')) { $response->appendBody('VALUE LABELS ' . $fixedNames[$key]); - foreach($options as $option=>$label) { - if($types[$key]=='F') { + foreach ($options as $option => $label) { + if ($types[$key] == 'F') { //Numeric $response->appendBody("\n" . $option . ' ' . '"' . $label . '"'); } else { //String - $response->appendBody("\n" . '"' .$option . '" ' . '"' . $label . '"'); + $response->appendBody("\n" . '"' . $option . '" ' . '"' . $label . '"'); } } $response->appendBody(".\n\n"); } } } else { - $controller = $this->export->controller; - $controller->getHelper('layout')->disableLayout(); - $controller->getHelper('viewRenderer')->setNoRender(true); - $response = $controller->getResponse(); - $filename = $survey->getName() . '.dat'; - $response->clearHeaders(); - $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"') - ->setHeader('Content-type', 'text/comma-separated-values; charset=UTF-8') - ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->setHeader('Pragma', 'public'); + $filename = $survey->getName() . '.dat'; + $response = $this->_doHeaders($filename); //We should create a model with the transformations we need //think of date translations, numers and strings $answerRow = reset($answers); $spssModel = new Gems_Export_ExportModel(); - foreach($answerRow as $key => $value) { + foreach ($answerRow as $key => $value) { $options = array(); - $type = $answerModel->get($key,'type'); + $type = $answerModel->get($key, 'type'); switch ($type) { case MUtil_Model::TYPE_DATE: $options['storageFormat'] = 'yyyy-MM-dd'; @@ -232,20 +236,20 @@ //When no type set... assume string case MUtil_Model::TYPE_STRING: default: - $type = MUtil_Model::TYPE_STRING; + $type = MUtil_Model::TYPE_STRING; $options['formatFunction'] = $this->formatString; break; } - $options['type'] = $type; + $options['type'] = $type; $spssModel->set($key, $options); } //Now apply the model to the answers $answers = new Gems_FormattedData($answers, $spssModel); //And output the data - foreach($answers as $answerRow) { + foreach ($answers as $answerRow) { $resultRow = implode(',', $answerRow); - $response->appendBody($resultRow ."\n"); + $response->appendBody($resultRow . "\n"); } } } @@ -263,7 +267,8 @@ * @param type $input * @return string */ - public function formatString($input) { + public function formatString($input) + { $output = strip_tags($input); $output = str_replace(array("'", "\r", "\n"), array("''", ' ', ' '), $output); $output = "'" . $output . "'"; @@ -278,11 +283,12 @@ * @param string $input * @return string */ - public function fixName($input) { - if (!preg_match ("/^([a-z]|[A-Z])+.*$/", $input)) { - $input = "q_" . $input; + public function fixName($input) + { + if (!preg_match("/^([a-z]|[A-Z])+.*$/", $input)) { + $input = "q_" . $input; } - $input = str_replace(array(" ","-",":",";","!","/","\\","'"), array("_","_hyph_","_dd_","_dc_","_excl_","_fs_","_bs_",'_qu_'), $input); + $input = str_replace(array(" ", "-", ":", ";", "!", "/", "\\", "'"), array("_", "_hyph_", "_dd_", "_dc_", "_excl_", "_fs_", "_bs_", '_qu_'), $input); return $input; } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-12 14:13:26
|
Revision: 835 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=835&view=rev Author: mennodekker Date: 2012-07-12 14:13:16 +0000 (Thu, 12 Jul 2012) Log Message: ----------- Fixed #543: IE will not download spss export dev: needed $replace=true in setHeader method to get the headers right Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2012-07-12 13:10:26 UTC (rev 834) +++ trunk/library/classes/Gems/Export/Spss.php 2012-07-12 14:13:16 UTC (rev 835) @@ -61,10 +61,10 @@ $response = $controller->getResponse(); $response->clearAllHeaders(); - $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"') - ->setHeader('Content-type', 'text/plain; charset=UTF-8') - ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->setHeader('Pragma', 'public'); + $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"', true) + ->setHeader('Content-type', 'text/plain; charset=UTF-8', true) + ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) + ->setHeader('Pragma', 'public', true); return $response; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-09-06 14:26:32
|
Revision: 932 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=932&view=rev Author: mennodekker Date: 2012-09-06 14:26:23 +0000 (Thu, 06 Sep 2012) Log Message: ----------- Improved SPSS export by cleaning html from value and variable labels Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2012-09-06 13:34:32 UTC (rev 931) +++ trunk/library/classes/Gems/Export/Spss.php 2012-09-06 14:26:23 UTC (rev 932) @@ -184,7 +184,8 @@ $response->appendBody(".\nCACHE.\nEXECUTE.\n"); $response->appendBody("\n*Define variable labels.\n"); foreach ($labels as $key => $label) { - $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . ' "' . $label . '".' . "\n"); + $label = $this->formatString($label); + $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . " " . $label . "." . "\n"); } $response->appendBody("\n*Define value labels.\n"); @@ -192,12 +193,13 @@ if ($options = $answerModel->get($key, 'multiOptions')) { $response->appendBody('VALUE LABELS ' . $fixedNames[$key]); foreach ($options as $option => $label) { + $label = $this->formatString($label); if ($types[$key] == 'F') { //Numeric - $response->appendBody("\n" . $option . ' ' . '"' . $label . '"'); + $response->appendBody("\n" . $option . ' ' . $label); } else { //String - $response->appendBody("\n" . '"' . $option . '" ' . '"' . $label . '"'); + $response->appendBody("\n" . '"' . $option . '" ' . $label); } } $response->appendBody(".\n\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-27 11:08:53
|
Revision: 1043 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1043&view=rev Author: mennodekker Date: 2012-11-27 11:08:46 +0000 (Tue, 27 Nov 2012) Log Message: ----------- Allow better fieldsize for SPSS export depending on answermodel Added help for SPSS export General SPSS export cleanup Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2012-11-27 09:50:46 UTC (rev 1042) +++ trunk/library/classes/Gems/Export/Spss.php 2012-11-27 11:08:46 UTC (rev 1043) @@ -48,6 +48,22 @@ class Gems_Export_Spss extends Gems_Export_ExportAbstract { /** + * When no other size available in the answermodel, this will be used + * for the size of alphanumeric types + * + * @var int + */ + public $defaultAlphaSize = 64; + + /** + * When no other size available in the answermodel, this will be used + * for the size of numeric types + * + * @var int + */ + public $defaultNumericSize = 5; + + /** * Set response headers and clean output * * @param string $filename @@ -78,12 +94,13 @@ { $element = new Zend_Form_Element_Radio('file'); $element->setLabel($this->_('Which file')); - $element->setMultiOptions(array('syntax' => $this->_('syntax'), - 'data' => $this->_('data'))); + $element->setMultiOptions(array( + 'syntax' => $this->_('syntax'), + 'data' => $this->_('data'))); $elements[] = $element; - $element = new MUtil_Form_Element_Exhibitor('help'); - $element->setValue($this->_('Some help for this export')); + $element = new MUtil_Form_Element_Exhibitor('help'); + $element->setValue($this->_('You need both a syntax and a data file. After downloading, open the syntax file in SPSS and modify the line /FILE="filename.dat" to include the full path to your data file. Then choose Run -> All to execute the syntax.')); $elements[] = $element; return $elements; @@ -116,13 +133,97 @@ if (isset($options['file'])) { if ($options['file'] == 'syntax') { - $filename = $survey->getName() . '.sps'; - $filenameDat = $survey->getName() . '.dat'; - $response = $this->_doHeaders($filename); + $this->handleExportSyntax($data, $survey, $answers, $answerModel, $language); + } else { + $this->handleExportData($data, $survey, $answers, $answerModel, $language); + } + } + } - //first output our script - $response->appendBody( - "SET UNICODE=ON. + /** + * This method handles the export with the given options for a syntax file + * + * The method takes care of rendering the right script by using $this->export->controller to + * access the controller object. + * + * @param array $data The formdata + * @param Gems_Tracker_Survey $survey The survey object we are exporting + * @param array $answers The array of answers + * @param MUtil_Model_ModelAbstract $answerModel The modified answermodel that includes info about extra attributes + * @param string $language The language used / to use for the export + */ + public function handeExportData($data, $survey, $answers, $answerModel, $language) + { + $filename = $survey->getName() . '.dat'; + $response = $this->_doHeaders($filename); + + //We should create a model with the transformations we need + //think of date translations, numers and strings + $answerRow = reset($answers); + $spssModel = new Gems_Export_ExportModel(); + foreach ($answerRow as $key => $value) { + $options = array(); + $type = $answerModel->get($key, 'type'); + switch ($type) { + case MUtil_Model::TYPE_DATE: + $options['storageFormat'] = 'yyyy-MM-dd'; + $options['dateFormat'] = 'yyyy-MM-dd'; + break; + + case MUtil_Model::TYPE_DATETIME: + $options['storageFormat'] = 'yyyy-MM-dd HH:mm:ss'; + $options['dateFormat'] = 'dd-MM-yyyy HH:mm:ss'; + break; + + case MUtil_Model::TYPE_TIME: + $options['storageFormat'] = 'HH:mm:ss'; + $options['dateFormat'] = 'HH:mm:ss'; + break; + + case MUtil_Model::TYPE_NUMERIC: + break; + + //When no type set... assume string + case MUtil_Model::TYPE_STRING: + default: + $type = MUtil_Model::TYPE_STRING; + $options['formatFunction'] = $this->formatString; + break; + } + $options['type'] = $type; + $spssModel->set($key, $options); + } + //Now apply the model to the answers + $answers = new Gems_FormattedData($answers, $spssModel); + + //And output the data + foreach ($answers as $answerRow) { + $resultRow = implode(',', $answerRow); + $response->appendBody($resultRow . "\n"); + } + } + + /** + * This method handles the export with the given options for a syntax file + * + * The method takes care of rendering the right script by using $this->export->controller to + * access the controller object. + * + * @param array $data The formdata + * @param Gems_Tracker_Survey $survey The survey object we are exporting + * @param array $answers The array of answers + * @param MUtil_Model_ModelAbstract $answerModel The modified answermodel that includes info about extra attributes + * @param string $language The language used / to use for the export + */ + protected function handleExportSyntax($data, $survey, $answers, $answerModel, $language) + { + $filename = $survey->getName() . '.sps'; + $filenameDat = $survey->getName() . '.dat'; + $response = $this->_doHeaders($filename); + + //first output our script + $response->appendBody( + "SET UNICODE=ON. GET DATA /TYPE=TXT /FILE=\"" . $filenameDat . "\" @@ -133,126 +234,79 @@ /FIRSTCASE=1 /IMPORTCASE=ALL /VARIABLES="); - $answerRow = reset($answers); - $labels = array(); - $types = array(); - $fixedNames = array(); - $questions = $survey->getQuestionList($language); - foreach ($answerRow as $key => $value) { - $fixedNames[$key] = $this->fixName($key); - $options = array(); - $type = $answerModel->get($key, 'type'); - switch ($type) { - case MUtil_Model::TYPE_DATE: - $type = 'SDATE10'; - break; + $answerRow = reset($answers); + $labels = array(); + $types = array(); + $fixedNames = array(); + $questions = $survey->getQuestionList($language); + foreach ($answerRow as $key => $value) { + $fixedNames[$key] = $this->fixName($key); + $options = array(); + $type = $answerModel->get($key, 'type'); + switch ($type) { + case MUtil_Model::TYPE_DATE: + $type = 'SDATE10'; + break; - case MUtil_Model::TYPE_DATETIME: - case MUtil_Model::TYPE_TIME: - $type = 'DATETIME23'; - break; + case MUtil_Model::TYPE_DATETIME: + case MUtil_Model::TYPE_TIME: + $type = 'DATETIME23'; + break; - case MUtil_Model::TYPE_NUMERIC: - $defaultSize = 5; - $type = 'F'; - break; + case MUtil_Model::TYPE_NUMERIC: + $defaultSize = $this->defaultNumericSize; + $type = 'F'; + break; - //When no type set... assume string - case MUtil_Model::TYPE_STRING: - default: - $defaultSize = 64; - $type = 'A'; - break; + //When no type set... assume string + case MUtil_Model::TYPE_STRING: + default: + $defaultSize = $this->defaultAlphaSize; + $type = 'A'; + break; + } + $types[$key] = $type; + if ($type == 'A' || $type == 'F') { + $size = $answerModel->get($key, 'maxlength'); // This comes from db when available + if (is_null($size)) { + $size = $answerModel->get($key, 'size'); // This is the display width + if ($is_null($size)) { + $size = $defaultSize; // We just don't know, make it the default } - $types[$key] = $type; - if ($type == 'A' || $type == 'F') { - $size = $answerModel->get($key, 'size'); - if (is_null($size)) { - $size = $defaultSize; - } - if ($type == 'A') { - $type = $type . $size; - } else { - $type = $type . $size . '.' . ($size - 1); //decimal - } - } - if (isset($questions[$key])) { - $labels[$key] = $questions[$key]; - } - $response->appendBody("\n " . $fixedNames[$key] . ' ' . $type); } - $response->appendBody(".\nCACHE.\nEXECUTE.\n"); - $response->appendBody("\n*Define variable labels.\n"); - foreach ($labels as $key => $label) { - $label = $this->formatString($label); - $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . " " . $label . "." . "\n"); + if ($type == 'A') { + $type = $type . $size; + } else { + $type = $type . $size . '.' . ($size - 1); //decimal } + } + if (isset($questions[$key])) { + $labels[$key] = $questions[$key]; + } + $response->appendBody("\n " . $fixedNames[$key] . ' ' . $type); + } + $response->appendBody(".\nCACHE.\nEXECUTE.\n"); + $response->appendBody("\n*Define variable labels.\n"); + foreach ($labels as $key => $label) { + $label = $this->formatString($label); + $response->appendBody("VARIABLE LABELS " . $fixedNames[$key] . " " . $label . "." . "\n"); + } - $response->appendBody("\n*Define value labels.\n"); - foreach ($answerRow as $key => $value) { - if ($options = $answerModel->get($key, 'multiOptions')) { - $response->appendBody('VALUE LABELS ' . $fixedNames[$key]); - foreach ($options as $option => $label) { - $label = $this->formatString($label); - if ($types[$key] == 'F') { - //Numeric - $response->appendBody("\n" . $option . ' ' . $label); - } else { - //String - $response->appendBody("\n" . '"' . $option . '" ' . $label); - } - } - $response->appendBody(".\n\n"); + $response->appendBody("\n*Define value labels.\n"); + foreach ($answerRow as $key => $value) { + if ($options = $answerModel->get($key, 'multiOptions')) { + $response->appendBody('VALUE LABELS ' . $fixedNames[$key]); + foreach ($options as $option => $label) { + $label = $this->formatString($label); + if ($types[$key] == 'F') { + //Numeric + $response->appendBody("\n" . $option . ' ' . $label); + } else { + //String + $response->appendBody("\n" . '"' . $option . '" ' . $label); } } - } else { - $filename = $survey->getName() . '.dat'; - $response = $this->_doHeaders($filename); - - //We should create a model with the transformations we need - //think of date translations, numers and strings - $answerRow = reset($answers); - $spssModel = new Gems_Export_ExportModel(); - foreach ($answerRow as $key => $value) { - $options = array(); - $type = $answerModel->get($key, 'type'); - switch ($type) { - case MUtil_Model::TYPE_DATE: - $options['storageFormat'] = 'yyyy-MM-dd'; - $options['dateFormat'] = 'yyyy-MM-dd'; - break; - - case MUtil_Model::TYPE_DATETIME: - $options['storageFormat'] = 'yyyy-MM-dd HH:mm:ss'; - $options['dateFormat'] = 'dd-MM-yyyy HH:mm:ss'; - break; - - case MUtil_Model::TYPE_TIME: - $options['storageFormat'] = 'HH:mm:ss'; - $options['dateFormat'] = 'HH:mm:ss'; - break; - - case MUtil_Model::TYPE_NUMERIC: - break; - - //When no type set... assume string - case MUtil_Model::TYPE_STRING: - default: - $type = MUtil_Model::TYPE_STRING; - $options['formatFunction'] = $this->formatString; - break; - } - $options['type'] = $type; - $spssModel->set($key, $options); - } - //Now apply the model to the answers - $answers = new Gems_FormattedData($answers, $spssModel); - - //And output the data - foreach ($answers as $answerRow) { - $resultRow = implode(',', $answerRow); - $response->appendBody($resultRow . "\n"); - } + $response->appendBody(".\n\n"); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-29 08:20:21
|
Revision: 1122 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1122&view=rev Author: mennodekker Date: 2013-01-29 08:20:15 +0000 (Tue, 29 Jan 2013) Log Message: ----------- Fixed typo in spss export Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2013-01-24 17:23:36 UTC (rev 1121) +++ trunk/library/classes/Gems/Export/Spss.php 2013-01-29 08:20:15 UTC (rev 1122) @@ -270,7 +270,7 @@ $size = $answerModel->get($key, 'maxlength'); // This comes from db when available if (is_null($size)) { $size = $answerModel->get($key, 'size'); // This is the display width - if ($is_null($size)) { + if (is_null($size)) { $size = $defaultSize; // We just don't know, make it the default } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-31 15:05:12
|
Revision: 1130 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1130&view=rev Author: mennodekker Date: 2013-01-31 15:05:05 +0000 (Thu, 31 Jan 2013) Log Message: ----------- And another typo in spss export Modified Paths: -------------- trunk/library/classes/Gems/Export/Spss.php Modified: trunk/library/classes/Gems/Export/Spss.php =================================================================== --- trunk/library/classes/Gems/Export/Spss.php 2013-01-31 14:36:17 UTC (rev 1129) +++ trunk/library/classes/Gems/Export/Spss.php 2013-01-31 15:05:05 UTC (rev 1130) @@ -152,7 +152,7 @@ * @param MUtil_Model_ModelAbstract $answerModel The modified answermodel that includes info about extra attributes * @param string $language The language used / to use for the export */ - public function handeExportData($data, $survey, $answers, $answerModel, $language) + public function handleExportData($data, $survey, $answers, $answerModel, $language) { $filename = $survey->getName() . '.dat'; $response = $this->_doHeaders($filename); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |