From: Roland Häder Date: Sat, 16 Aug 2008 05:43:06 +0000 (+0000) Subject: Selection box added, refill page fixed X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=5db7219f63e257943e11d0ef20cb75c7514d769d Selection box added, refill page fixed --- diff --git a/application/ship-simu/templates/de/code/action_login_money_refill.ctp b/application/ship-simu/templates/de/code/action_login_money_refill.ctp index 84cf84c..f170fbd 100644 --- a/application/ship-simu/templates/de/code/action_login_money_refill.ctp +++ b/application/ship-simu/templates/de/code/action_login_money_refill.ctp @@ -6,8 +6,7 @@ $helper = WebFormHelper::createWebFormHelper($this, 'refill_form'); $helper->addFormGroup('refill_form', "Bitte wähle aus, was du nachbestellen willst und gebe die Menge an."); // Add sub group -$helper->addFormSubGroup('refill_type', "Was möchstest du nun nachbestellen?"); -$helper->addInputSelectField('type', "Bitte auswählen"); +$helper->addInputSelectField('type', "--- Bitte auswählen ---"); // In-game currencies (if more than default add them here!) $helper->addSelectSubOption('currencies', "--- Währungen ---"); diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index 20693f9..ea7f452 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -571,23 +571,106 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { } /** - * Checks wether the registration requires a valid email address + * Adds a selection box as a sub group to the form. Do not box this into + * another sub group. Sub-sub groups are not (yet) supported. * - * @return $required Wether the email address is required + * @param $selectId Id of the selection box + * @param $firstEntry Content to be added as first non-selectable entry + * @return void + * @throws FormClosedException If the form is not yet opened */ - public function ifRegisterRequiresEmailVerification () { - $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); - return $required; + public function addInputSelectField ($selectId, $firstEntry) { + // Is the form group opened? + if (($this->formOpened === false) && ($this->formEnabled === true)) { + // Throw an exception + throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Shall we close or open the sub group? + if ((!$this->ifSubGroupOpenedPreviously()) && ($this->getPreviousSubGroupId() !== $selectId)) { + // Initialize first entry (which might be non-selectable if content is provided + if (!empty($firstEntry)) { + // Add selection around it + $firstEntry = sprintf("\n", + $firstEntry + ); + } // END - if + + // Construct the opening select tag + $content = sprintf(""); + } } /** - * Checks wether profile data shall be asked + * Adds a non-selectable sub option to a previously added selection box. + * This method does *not* validate if there is already a sub option added + * with the same name. We need to finish this here! * - * @return $required Wether profile shall be asked + * @param $subName Name of the sub action + * @param $subValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added */ - public function ifRegisterIncludesProfile () { - $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); - return $required; + public function addSelectSubOption ($subName, $subValue) { + // Is there a sub group (shall be a selection box!) + if (!$this->ifSubGroupOpenedPreviously()) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $subName, + $subName, + $subValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a selectable option to a previously added selection box. This method + * does *not* validate if there is already a sub option added with the same + * name. We need to finish this here! + * + * @param $optionName Name of the sub action + * @param $optionValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectOption ($optionName, $optionValue) { + // Is there a sub group (shall be a selection box!) + if (!$this->ifSubGroupOpenedPreviously()) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $optionName, + $optionName, + $optionValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); } /** @@ -641,6 +724,26 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { return $this->formName; } + /** + * Checks wether the registration requires a valid email address + * + * @return $required Wether the email address is required + */ + public function ifRegisterRequiresEmailVerification () { + $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y"); + return $required; + } + + /** + * Checks wether profile data shall be asked + * + * @return $required Wether profile data shall be asked + */ + public function ifRegisterIncludesProfile () { + $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y"); + return $required; + } + /** * Checks wether this form is secured by a CAPTCHA *