}
/**
- * 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);
}
/**
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
*