From: <gem...@li...> - 2012-05-24 13:29:11
|
Revision: 700 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=700&view=rev Author: matijsdejong Date: 2012-05-24 13:29:00 +0000 (Thu, 24 May 2012) Log Message: ----------- Real fix for 695: the problem was in teh double application of a dateFormat with a formatFunction (disable everywhere) and a default value that use a different date format than the storageFormat. Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyAction.php trunk/library/classes/Gems/Default/TrackAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/FormattedData.php trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php trunk/library/classes/MUtil/View/Helper/Exhibitor.php Modified: trunk/library/classes/Gems/Default/SurveyAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-24 13:29:00 UTC (rev 700) @@ -190,10 +190,14 @@ //$model->resetOrder(); $model->set('gsu_survey_name', 'label', $this->_('Survey')); $model->set('ggp_name', 'label', $this->_('By'), 'elementClass', 'Exhibitor'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', - 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', - 'formatFunction', $this->util->getTranslated()->formatDateNa); + $model->set('gtr_date_start', 'label', $this->_('From'), + 'dateFormat', 'dd-MM-yyyy', + 'tdClass', 'date', + 'formatFunction', $this->util->getTranslated()->formatDate); + $model->set('gtr_date_until', 'label', $this->_('Until'), + 'dateFormat', 'dd-MM-yyyy', + 'tdClass', 'date', + 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; } Modified: trunk/library/classes/Gems/Default/TrackAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackAction.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/TrackAction.php 2012-05-24 13:29:00 UTC (rev 700) @@ -327,9 +327,9 @@ //$model->resetOrder(); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #'), 'tdClass', 'centerAlign', 'thClass', 'centerAlign'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -209,9 +209,9 @@ 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); Modified: trunk/library/classes/Gems/FormattedData.php =================================================================== --- trunk/library/classes/Gems/FormattedData.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/FormattedData.php 2012-05-24 13:29:00 UTC (rev 700) @@ -109,13 +109,12 @@ } } - if ($dateFormat = $model->get($name, 'dateFormat')) { - $storageFormat = $model->get($name, 'storageFormat'); - $result = MUtil_Date::format($result, $dateFormat, $storageFormat); - } if ($callback = $model->get($name, 'formatFunction')) { $result = call_user_func($callback, $result); + } elseif ($dateFormat = $model->get($name, 'dateFormat')) { + $storageFormat = $model->get($name, 'storageFormat'); + $result = MUtil_Date::format($result, $dateFormat, $storageFormat); } if ($function = $model->get($name, 'itemDisplay')) { Modified: trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -150,9 +150,9 @@ $model->set('gr2t_track_info', 'label', $this->_('Description')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); @@ -267,11 +267,11 @@ $filter['gr2o_id_organization'] = $this->organizationId; $this->formData = $this->getModel()->loadNew(null, $filter); - } else { parent::loadFormData(); } + MUtil_Echo::track($this->formData); if (! array_key_exists(self::TRACKFIELDS_ID, $this->formData)) { if ($this->trackEngine) { $this->formData[self::TRACKFIELDS_ID] = $this->trackEngine->getFieldsData($this->respondentTrackId); Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -1,10 +1,9 @@ <?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 @@ -15,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 @@ -26,8 +25,8 @@ * 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 Tracker * @author Matijs de Jong <mj...@ma...> @@ -38,9 +37,9 @@ /** * Displays the assignments of a track to a respondent. - * - * This code contains some display options for excluding or marking a single track - * and for processing the passed parameters identifying the respondent and the + * + * This code contains some display options for excluding or marking a single track + * and for processing the passed parameters identifying the respondent and the * optional single track. * * @package Gems @@ -62,68 +61,68 @@ /** * Optional, when true current item is not shown, when false the current row is marked as the currentRow. - * + * * @var boolean */ protected $excludeCurrent = false; - + /** * @var Zend_Db_Adapter_Abstract */ protected $db; - + /** * Required - * + * * @var Gems_Loader */ protected $loader; - + /** * Optional, required when using $trackEngine or $trackId only * * @var int Organization Id */ protected $organizationId; - + /** * Optional, required when using $trackEngine or $trackId only * * @var int Patient Id */ protected $patientId; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set * * @var Gems_Tracker_RespondentTrack */ protected $respondentTrack; - + /** * * @var int Respondent Track Id */ protected $respondentTrackId; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set - * + * * $trackEngine and TrackId need $patientId and $organizationId to be set as well - * + * * @var Gems_Tracker_Engine_TrackEngineInterface */ protected $trackEngine; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set * * $trackEngine and TrackId need $patientId and $organizationId to be set as well - * + * * @var int Track Id */ protected $trackId; - + /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. @@ -134,7 +133,7 @@ { return $this->db && $this->loader && parent::checkRegistryRequestsAnswers(); } - + /** * Creates the model * @@ -143,20 +142,20 @@ protected function createModel() { $model = $this->loader->getTracker()->getRespondentTrackModel(); - + $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gr2t_track_info', 'label', $this->_('Description'), 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); - + return $model; } - + /** * Create the snippets content * @@ -168,19 +167,19 @@ public function getHtmlOutput(Zend_View_Abstract $view) { $seq = $this->getHtmlSequence(); - + $seq->h3($this->getTitle()); - + $table = parent::getHtmlOutput($view); $this->applyHtmlAttributes($table); - + $seq->append($table); - + return $seq; } abstract protected function getTitle(); - + /** * The place to check if the data set in the snippet is valid * to generate the snippet. @@ -206,7 +205,7 @@ if ((! $this->trackId) && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } - + // Check if a sufficient set of data is there if (! ($this->trackId || $this->patientId || $this->organizationId)) { // Now we really need $this->respondentTrack @@ -219,7 +218,7 @@ } } } - + if (! $this->trackId) { $this->trackId = $this->respondentTrack->getTrackId(); } @@ -229,9 +228,9 @@ if (! $this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } - + // MUtil_Echo::track($this->trackId, $this->patientId, $this->organizationId, $this->respondentTrackId); - + return parent::hasHtmlOutput(); } @@ -241,15 +240,15 @@ * @param MUtil_Model_ModelAbstract $model */ protected function processFilterAndSort(MUtil_Model_ModelAbstract $model) - { + { if ($this->request) { $this->processSortOnly($model); } - + $filter['gtr_id_track'] = $this->trackId; $filter['gr2o_patient_nr'] = $this->patientId; $filter['gr2o_id_organization'] = $this->organizationId; - + if ($this->excludeCurrent) { $filter[] = $this->db->quoteInto('gr2t_id_respondent_track != ?', $this->respondentTrackId); } Modified: trunk/library/classes/MUtil/Model/TableBridgeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -89,7 +89,9 @@ $value = MUtil_Lazy::offsetGet($multi, $value); } - if ($format = $this->model->get($name, 'dateFormat')) { + if ($function = $this->model->get($name, 'formatFunction')) { + $value = MUtil_Lazy::call($function, $value); + } elseif ($format = $this->model->get($name, 'dateFormat')) { if (is_callable($format)) { $value = MUtil_Lazy::call($format, $value); } else { @@ -97,10 +99,6 @@ } } - if ($function = $this->model->get($name, 'formatFunction')) { - $value = MUtil_Lazy::call($function, $value); - } - if ($marker = $this->model->get($name, 'markCallback')) { $value = MUtil_Lazy::call($marker, $value); } Modified: trunk/library/classes/MUtil/View/Helper/Exhibitor.php =================================================================== --- trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-05-24 13:29:00 UTC (rev 700) @@ -1,47 +1,47 @@ <?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. - */ - /** - * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * 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 MUtil * @subpackage View + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: FormSelectHtml.php 203 2012-01-01t 12:51:32Z matijs $ */ /** - * - * @author Matijs de Jong - * @package MUtil + * + * @package MUtil * @subpackage View + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_View_Helper_Exhibitor extends Zend_View_Helper_FormElement { @@ -80,18 +80,16 @@ } } - if (isset($attribs['dateFormat'])) { + if (isset($attribs['formatFunction'])) { + $callback = $attribs['formatFunction']; + $result = call_user_func($callback, $result); + } elseif (isset($attribs['dateFormat'])) { $dateFormat = $attribs['dateFormat']; $storageFormat = isset($attribs['storageFormat']) ? $attribs['storageFormat'] : null; $result = MUtil_Date::format($result, $dateFormat, $storageFormat); } - if (isset($attribs['formatFunction'])) { - $callback = $attribs['formatFunction']; - $result = call_user_func($callback, $result); - } - if (isset($attribs['itemDisplay'])) { $function = $attribs['itemDisplay']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |