From: <gem...@li...> - 2012-01-06 10:22:41
|
Revision: 400 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=400&view=rev Author: michieltcs Date: 2012-01-06 10:22:34 +0000 (Fri, 06 Jan 2012) Log Message: ----------- Pass to initItems() and addItems() Modified Paths: -------------- trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php trunk/library/snippets/Organization/OrganizationEditSnippet.php Modified: trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-05 12:48:04 UTC (rev 399) +++ trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-06 10:22:34 UTC (rev 400) @@ -157,10 +157,10 @@ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model) { //Get all elements in the model if not already done - $this->initItems(); + $this->initItems($model); //And any remaining item - $this->addItems($bridge, $this->_items); + $this->addItems($bridge, $model, $this->_items); } /** @@ -171,22 +171,23 @@ * * @return void */ - protected function addItems(MUtil_Model_FormBridge $bridge, $element1) + protected function addItems(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, $element1) { $args = func_get_args(); - if (count($args)<2) { - throw new Gems_Exception_Coding('Use at least 2 arguments, first the bridge and then one or more idividual items'); + if (count($args) < 3) { + throw new Gems_Exception_Coding('Use at least 3 arguments; bridge, model and then one or more individual items'); } $bridge = array_shift($args); + $model = array_shift($args); $elements = MUtil_Ra::flatten($args); //Remove the elements from the _items variable $this->_items = array_diff($this->_items, $elements); - + //And add them to the bridge foreach($elements as $name) { - if ($label = $this->model->get($name, 'label')) { + if ($label = $model->get($name, 'label')) { $bridge->add($name); } else { $bridge->addHidden($name); @@ -361,10 +362,10 @@ /** * Initialize the _items variable to hold all items from the model */ - protected function initItems() + protected function initItems(MUtil_Model_ModelAbstract $model) { if (is_null($this->_items)) { - $this->_items = $this->model->getItemsOrdered(); + $this->_items = $model->getItemsOrdered(); } } Modified: trunk/library/snippets/Organization/OrganizationEditSnippet.php =================================================================== --- trunk/library/snippets/Organization/OrganizationEditSnippet.php 2012-01-05 12:48:04 UTC (rev 399) +++ trunk/library/snippets/Organization/OrganizationEditSnippet.php 2012-01-06 10:22:34 UTC (rev 400) @@ -64,7 +64,7 @@ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model) { //Get all elements in the model if not already done - $this->initItems(); + $this->initItems($model); //Create our tab structure first check if tab already exists to allow extension if (!($bridge->getTab('general'))) { @@ -72,17 +72,17 @@ } //Need the first two together for validation $bridge->addHtml('org')->b($this->_('Organization')); - $this->addItems($bridge, 'gor_name', 'gor_id_organization', 'gor_location', 'gor_url', 'gor_active'); + $this->addItems($bridge, $model, 'gor_name', 'gor_id_organization', 'gor_location', 'gor_url', 'gor_active'); $bridge->addHtml('contact')->b($this->_('Contact')); $bridge->addHtml('contact_desc')->i($this->_('The contact details for this organization, used for emailing.')); - $this->addItems($bridge, 'gor_contact_name', 'gor_contact_email'); + $this->addItems($bridge, $model, 'gor_contact_name', 'gor_contact_email'); $bridge->addHtml('general_other')->b($this->_('Other')); - $this->addItems($bridge, 'gor_iso_lang', 'gor_code', 'gor_has_respondents'); + $this->addItems($bridge, $model, 'gor_iso_lang', 'gor_code', 'gor_has_respondents'); if (!($bridge->getTab('email'))) { $bridge->addTab('email', 'value', $this->_('Email') . ' & ' . $this->_('Token')); } - $this->addItems($bridge, 'gor_welcome', 'gor_signature'); + $this->addItems($bridge, $model, 'gor_welcome', 'gor_signature'); if (!($bridge->getTab('access'))) { $bridge->addTab('access', 'value', $this->_('Access')); @@ -94,7 +94,7 @@ unset($multiOptions[$this->formData['gor_id_organization']]); $model->set('gor_accessible_by', 'multiOptions', $multiOptions); } - $this->addItems($bridge, 'gor_has_login', 'gor_add_respondents', 'gor_respondent_group', 'gor_accessible_by'); + $this->addItems($bridge, $model, 'gor_has_login', 'gor_add_respondents', 'gor_respondent_group', 'gor_accessible_by'); //Show what organizations we can access if (isset($this->formData['gor_id_organization']) && !empty($this->formData['gor_id_organization'])) { @@ -106,7 +106,7 @@ $bridge->addExhibitor('allowed', 'value', $display, 'label', $this->_('Can access')); } - $this->addItems($bridge, 'gor_user_class'); + $this->addItems($bridge, $model, 'gor_user_class'); if (isset($this->formData['gor_user_class']) && !empty($this->formData['gor_user_class'])) { $class = $this->formData['gor_user_class'] . 'Definition'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |