|
From: <gem...@li...> - 2011-09-27 14:44:03
|
Revision: 81
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=81&view=rev
Author: matijsdejong
Date: 2011-09-27 14:43:57 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------
- added documentation to ModelAbstract and JoinModel
- fix in JoinModel for warning when join is not on strings
- cleanup of menu use / pdf upload in SurveyMaintenanceAction.php
Modified Paths:
--------------
trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php
trunk/library/classes/MUtil/Model/JoinModel.php
trunk/library/classes/MUtil/Model/ModelAbstract.php
Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php
===================================================================
--- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-09-27 13:00:35 UTC (rev 80)
+++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-09-27 14:43:57 UTC (rev 81)
@@ -44,7 +44,7 @@
* @license New BSD License
* @since Class available since version 1.0
*/
-class Gems_Default_SurveyMaintenanceAction extends Gems_Controller_BrowseEditAction implements Gems_Menu_ParameterSourceInterface
+class Gems_Default_SurveyMaintenanceAction extends Gems_Controller_BrowseEditAction
{
public $autoFilter = true;
@@ -55,12 +55,6 @@
public $sortKey = array('gsu_survey_name' => SORT_ASC);
/**
- *
- * @var array
- */
- protected $data = array();
-
- /**
* Adds columns from the model to the bridge that creates the browse table.
*
* Adds a button column to the model, if such a button exists in the model.
@@ -93,8 +87,7 @@
*/
protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false)
{
- //MUtil_Echo::r($data, __CLASS__ . '->' . __FUNCTION__);
- $data = array_merge($model->loadFirst(), $data);
+ // MUtil_Echo::track($data);
// Prepare variables
$currentId = $data['gsu_id_survey'];
@@ -381,15 +374,6 @@
return MUtil_Html::raw(strip_tags($value));
}
- public function getMenuParameter($name, $default)
- {
- if (isset($this->data[$name])) {
- return $this->data[$name];
- } else {
- return $default;
- }
- }
-
public function getTrackCount($currentId)
{
$singleTrack = ($this->escort instanceof Gems_Project_Tracks_SingleTrackInterface) ? $this->escort->getTrackId() : null;
@@ -440,8 +424,6 @@
$source = $this->menu->getParameterSource();
$source->offsetSet('gsu_has_pdf', $data['gsu_survey_pdf'] ? 1 : 0);
$source->offsetSet(MUtil_Model::REQUEST_ID, $data['gsu_id_survey']);
- $this->data['gsu_has_pdf'] = $data['gsu_survey_pdf'] ? 1 : 0;
- $this->data[MUtil_Model::REQUEST_ID] = $data['gsu_id_survey'];
return $this;
}
@@ -470,7 +452,7 @@
$this->html[] = $table;
if ($this->escort->hasPrivilege('pr.project.questions')) {
- $this->addSnippet('SurveyQuestionsSnippet', 'surveyId', $this->data[MUtil_Model::REQUEST_ID]);
+ $this->addSnippet('SurveyQuestionsSnippet', 'surveyId', $this->_getIdParam());
}
}
}
\ No newline at end of file
Modified: trunk/library/classes/MUtil/Model/JoinModel.php
===================================================================
--- trunk/library/classes/MUtil/Model/JoinModel.php 2011-09-27 13:00:35 UTC (rev 80)
+++ trunk/library/classes/MUtil/Model/JoinModel.php 2011-09-27 14:43:57 UTC (rev 81)
@@ -27,11 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
- * @author Matijs de Jong <mj...@ma...>
- * @since 1.0
- * @version 1.1
- * @package MUtil
+ * @package MUtil
* @subpackage Model
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id$
*/
/**
@@ -42,9 +43,11 @@
* but you can override this when calling save() and delete().
*
*
- * @author Matijs de Jong <mj...@ma...>
- * @package MUtil
+ * @package MUtil
* @subpackage Model
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.0
*/
class MUtil_Model_JoinModel extends MUtil_Model_DatabaseModelAbstract
{
@@ -230,6 +233,14 @@
return $select;
}
+ /**
+ * Save a single model item.
+ *
+ * @param array $newValues The values to store for a single model item.
+ * @param array $filter If the filter contains old key values these are used
+ * to decide on update versus insert.
+ * @return array The values as they are after saving (they may change).
+ */
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
if (null === $saveTables) {
@@ -245,13 +256,14 @@
foreach ($saveTables as $table_name) {
// Gotta repeat this every time, as keys may be set later
foreach ($this->_joinFields as $source => $target) {
- if (! (isset($newValues[$target]) && $newValues[$target])) {
- if (! (isset($newValues[$source]) && $newValues[$source])) {
+ // Use is_string as $target and $target can be e.g. a Zend_Db_Expr() object
+ if (! (is_string($target) && isset($newValues[$target]) && $newValues[$target])) {
+ if (! (is_string($source) && isset($newValues[$source]) && $newValues[$source])) {
continue;
}
$newValues[$target] = $newValues[$source];
- } elseif (! (isset($newValues[$source]) && $newValues[$source])) {
+ } elseif (! (is_string($source) && isset($newValues[$source]) && $newValues[$source])) {
$newValues[$source] = $newValues[$target];
}
}
Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php
===================================================================
--- trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-09-27 13:00:35 UTC (rev 80)
+++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-09-27 14:43:57 UTC (rev 81)
@@ -834,6 +834,18 @@
return $this;
}
+ /**
+ * Reset the processing / display order for getItemsOrdered().
+ *
+ * Model items are displayed in the order they are first set() by the code.
+ * Using this functions resets this list and allows you to start over
+ * and determine the display order by the order you set() the items from
+ * now on.
+ *
+ * @see getItemsOrdered()
+ *
+ * @return MUtil_Model_ModelAbstract (continuation pattern)
+ */
public function resetOrder()
{
$this->_model_order = null;
@@ -845,7 +857,7 @@
*
* @param array $newValues The values to store for a single model item.
* @param array $filter If the filter contains old key values these are used
- * te decide on update versus insert.
+ * to decide on update versus insert.
* @return array The values as they are after saving (they may change).
*/
abstract public function save(array $newValues, array $filter = null);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|