From: <gem...@li...> - 2011-09-22 09:24:55
|
Revision: 67 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=67&view=rev Author: mennodekker Date: 2011-09-22 09:24:47 +0000 (Thu, 22 Sep 2011) Log Message: ----------- Added Paths: ----------- tags/1.4.2/library/classes/Gems/Loader.php Removed Paths: ------------- tags/1.4.2/library/classes/Gems/Loader.php Deleted: tags/1.4.2/library/classes/Gems/Loader.php =================================================================== --- tags/1.4.2/library/classes/Gems/Loader.php 2011-09-22 09:17:02 UTC (rev 66) +++ tags/1.4.2/library/classes/Gems/Loader.php 2011-09-22 09:24:47 UTC (rev 67) @@ -1,180 +0,0 @@ -<?php - - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @package Gems - * @subpackage Loader - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * - * @package Gems - * @subpackage Loader - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4 - */ -class Gems_Loader extends Gems_Loader_LoaderAbstract -{ - /** - * - * @var Gems_Events - */ - protected $events; - - /** - * - * @var Gems_Model - */ - protected $models; - - /** - * - * @var Gems_Pdf - */ - protected $pdf; - - /** - * - * @var Gems_Roles - */ - protected $roles; - - /** - * - * @var Gems_Selector - */ - protected $selector; - - /** - * - * @var Gems_Tracker - */ - protected $tracker; - - /** - * - * @var Gems_Util - */ - protected $util; - - /** - * - * @var Gems_Versions - */ - protected $versions; - - /** - * Load project specific menu or general Gems menu otherwise - * - * @param GemsEscort $escort - * @return Gems_Menu - */ - public function createMenu(GemsEscort $escort) - { - return $this->_loadClass('Menu', true, func_get_args()); - } - - /** - * - * @return gems_Events - */ - public function getEvents() - { - return $this->_getClass('events'); - } - - /** - * - * @return Gems_Model - */ - public function getModels() - { - return $this->_getClass('models', 'model'); - } - - /** - * - * @return Gems_Pdf - */ - public function getPdf() - { - return $this->_getClass('pdf'); - } - - /** - * - * @param GemsEscort $escort - * @return Gems_Roles - */ - public function getRoles(GemsEscort $escort) - { - return $this->_getClass('roles', null, array($escort)); - } - - /** - * - * @return Gems_Selector - */ - public function getSelector() - { - return $this->_getClass('selector'); - } - - /** - * - * @return Gems_Tracker_TrackerInterface - */ - public function getTracker() - { - return $this->_getClass('tracker'); - } - - /** - * - * @return Gems_Util - */ - public function getUtil() - { - return $this->_getClass('util'); - } - - /** - * - * @return Gems_Versions - */ - public function getVersions() - { - return $this->_getClass('versions'); - } -} \ No newline at end of file Copied: tags/1.4.2/library/classes/Gems/Loader.php (from rev 66, trunk/library/classes/Gems/Loader.php) =================================================================== --- tags/1.4.2/library/classes/Gems/Loader.php (rev 0) +++ tags/1.4.2/library/classes/Gems/Loader.php 2011-09-22 09:24:47 UTC (rev 67) @@ -0,0 +1,195 @@ +<?php + + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Loader + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * @package Gems + * @subpackage Loader + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4 + */ +class Gems_Loader extends Gems_Loader_LoaderAbstract +{ + /** + * + * @var Gems_Events + */ + protected $events; + + /** + * + * @var Gems_Export + */ + protected $export; + + /** + * + * @var Gems_Model + */ + protected $models; + + /** + * + * @var Gems_Pdf + */ + protected $pdf; + + /** + * + * @var Gems_Roles + */ + protected $roles; + + /** + * + * @var Gems_Selector + */ + protected $selector; + + /** + * + * @var Gems_Tracker + */ + protected $tracker; + + /** + * + * @var Gems_Util + */ + protected $util; + + /** + * + * @var Gems_Versions + */ + protected $versions; + + /** + * Load project specific menu or general Gems menu otherwise + * + * @param GemsEscort $escort + * @return Gems_Menu + */ + public function createMenu(GemsEscort $escort) + { + return $this->_loadClass('Menu', true, func_get_args()); + } + + /** + * + * @return gems_Events + */ + public function getEvents() + { + return $this->_getClass('events'); + } + + /** + * + * @return Gems_Export + */ + public function getExport() + { + return $this->_getClass('export'); + } + + /** + * + * @return Gems_Model + */ + public function getModels() + { + return $this->_getClass('models', 'model'); + } + + /** + * + * @return Gems_Pdf + */ + public function getPdf() + { + return $this->_getClass('pdf'); + } + + /** + * + * @param GemsEscort $escort + * @return Gems_Roles + */ + public function getRoles(GemsEscort $escort) + { + return $this->_getClass('roles', null, array($escort)); + } + + /** + * + * @return Gems_Selector + */ + public function getSelector() + { + return $this->_getClass('selector'); + } + + /** + * + * @return Gems_Tracker_TrackerInterface + */ + public function getTracker() + { + return $this->_getClass('tracker'); + } + + /** + * + * @return Gems_Util + */ + public function getUtil() + { + return $this->_getClass('util'); + } + + /** + * + * @return Gems_Versions + */ + public function getVersions() + { + return $this->_getClass('versions'); + } +} \ 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...> - 2011-09-26 10:08:02
|
Revision: 73 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=73&view=rev Author: mennodekker Date: 2011-09-26 10:07:56 +0000 (Mon, 26 Sep 2011) Log Message: ----------- backported from trunk spss and excel export fixes Modified Paths: -------------- tags/1.4.2/library/classes/Gems/Export/Spss.php tags/1.4.2/library/classes/Gems/View/Helper/Excel.php Modified: tags/1.4.2/library/classes/Gems/Export/Spss.php =================================================================== --- tags/1.4.2/library/classes/Gems/Export/Spss.php 2011-09-26 10:00:57 UTC (rev 72) +++ tags/1.4.2/library/classes/Gems/Export/Spss.php 2011-09-26 10:07:56 UTC (rev 73) @@ -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 @@ -205,7 +206,7 @@ //We should create a model with the transformations we need //think of date translations, numers and strings $answerRow = reset($answers); - $spssModel = new Zsd_Export_ExportModel(); + $spssModel = new Gems_Export_ExportModel(); foreach($answerRow as $key => $value) { $options = array(); $type = $answerModel->get($key,'type'); @@ -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 Modified: tags/1.4.2/library/classes/Gems/View/Helper/Excel.php =================================================================== --- tags/1.4.2/library/classes/Gems/View/Helper/Excel.php 2011-09-26 10:00:57 UTC (rev 72) +++ tags/1.4.2/library/classes/Gems/View/Helper/Excel.php 2011-09-26 10:07:56 UTC (rev 73) @@ -3,7 +3,7 @@ /** * Copyright (c) 2011, Erasmus MC * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -29,7 +29,7 @@ /** * Outputs an array of arrays (or a Zend_Db_Table_Rowset) as a table - * + * * The first 'record' is rendered bold, being the header for the table * * @category Gems @@ -49,25 +49,35 @@ Zend_Controller_Front::getInstance()->unregisterPlugin('ZFDebug_Controller_Plugin_Debug'); } catch (Exception $e) {} $this->view->layout()->setLayout('excel'); + if ($rowset instanceof Gems_FormattedData) { + $rowset->setFormatted(false); + } $rowcnt = 0; foreach ($rowset as $row) { - if ($row instanceof Zend_Db_Table_Row) $row = $row->toArray(); - if (!is_array($row)) $row = (array) $row; + if ($row instanceof Zend_Db_Table_Row) { + $row = $row->toArray(); + } + if (!is_array($row)) { + $row = (array) $row; + } if ($rowcnt == 0) { //Only for the first row: output headers $output = "<table>\r\n"; $output .= "\t<thead>\r\n"; $output .= "\t\t<tr>\r\n"; foreach ($row as $name => $value) { - $output .= "\t\t\t<th>$value</th>\r\n"; + $output .= "\t\t\t<th>$value</th>\r\n"; } $output .= "\t\t</tr>\r\n"; $output .= "\t</thead>\r\n"; $output .= "\t<tbody>\r\n"; - } else { - $output .= "\t\t<tr>\r\n"; + if ($rowset instanceof Gems_FormattedData) { + $rowset->setFormatted(true); + } + } else { + $output .= "\t\t<tr>\r\n"; foreach ($row as $name => $value) { - $output .= "\t\t\t<td>$value</td>\r\n"; + $output .= "\t\t\t<td>$value</td>\r\n"; } $output .= "\t\t</tr>\r\n"; } @@ -76,7 +86,7 @@ if (isset($output)) { $output .= "\t</tbody>\r\n"; $output .= "</table>\r\n"; - return $output; + return $output; } else { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |