Selection box added, refill page fixed
authorRoland Häder <roland@mxchange.org>
Sat, 16 Aug 2008 05:43:06 +0000 (05:43 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 16 Aug 2008 05:43:06 +0000 (05:43 +0000)
application/ship-simu/templates/de/code/action_login_money_refill.ctp
inc/classes/main/helper/web/forms/class_WebFormHelper.php

index 84cf84c..f170fbd 100644 (file)
@@ -6,8 +6,7 @@ $helper = WebFormHelper::createWebFormHelper($this, 'refill_form');
 $helper->addFormGroup('refill_form', "Bitte w&auml;hle aus, was du nachbestellen willst und gebe die Menge an.");
 
 // Add sub group
-$helper->addFormSubGroup('refill_type', "Was m&ouml;chstest du nun nachbestellen?");
-$helper->addInputSelectField('type', "Bitte ausw&auml;hlen");
+$helper->addInputSelectField('type', "--- Bitte ausw&auml;hlen ---");
 
 // In-game currencies (if more than default add them here!)
 $helper->addSelectSubOption('currencies', "--- W&auml;hrungen ---");
index 20693f9..ea7f452 100644 (file)
@@ -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("<option name=\"invalid\" disabled=\"disabled\">%s</option>\n",
+                                       $firstEntry
+                               );
+                       } // END - if
+
+                       // Construct the opening select tag
+                       $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
+                               $this->getFormName(),
+                               $selectId,
+                               $selectId,
+                               $firstEntry
+                       );
+
+                       // Open the sub group
+                       $this->openSubGroupByIdContent($selectId, $content);
+               } elseif ($this->getPreviousSubGroupId() != $selectId) {
+                       // Something went wrong!
+                       $this->debugInstance();
+               } else {
+                       // Close the sub group
+                       $this->closePreviousSubGroupByContent("</select>");
+               }
        }
 
        /**
-        * 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("<option name=\"%s\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\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("<option name=\"%s\" class=\"option option_%s\">%s</option>\n",
+                       $optionName,
+                       $optionName,
+                       $optionValue
+               );
+
+               // Add the content to the previously opened sub group
+               $this->addContentToPreviousGroup($content);
        }
 
        /**
@@ -642,6 +725,26 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
        }
 
        /**
+        * 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
         *
         * @return      $isSecured      Wether this form is secured by a CAPTCHA