]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/helper/web/class_WebFormHelper.php
Comments fixed... ;) And pre/post filters for registrations now supported
[shipsimu.git] / inc / classes / main / helper / web / class_WebFormHelper.php
index 41ad0fd33a7c8075c7e7e0d4c44660410b03b826..d3fecfc48f40545f8f29d0b1b06987f701933cb9 100644 (file)
@@ -55,7 +55,7 @@ class WebFormHelper extends BaseHelper {
        const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0xb03;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -64,7 +64,10 @@ class WebFormHelper extends BaseHelper {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("HTML-Formularhilfsklasse");
+               $this->setObjectDescription("Helper class for HTML forms");
+
+               // Create unique ID number
+               $this->createUniqueID();
        }
 
        /**
@@ -118,9 +121,9 @@ class WebFormHelper extends BaseHelper {
                        // Add HTML code
                        $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s\" method=\"%s\" target=\"%s\"",
                                $formName,
-                               $this->getConfigInstance()->readConfig("form_action"),
-                               $this->getConfigInstance()->readConfig("form_method"),
-                               $this->getConfigInstance()->readConfig("form_target")
+                               $this->getConfigInstance()->readConfig('form_action'),
+                               $this->getConfigInstance()->readConfig('form_method'),
+                               $this->getConfigInstance()->readConfig('form_target')
                        );
 
                        // Is the form id set?
@@ -139,7 +142,7 @@ class WebFormHelper extends BaseHelper {
                        $this->formName = $formName;
                } else {
                        // Add the hidden field required to identify safely this form
-                       $this->addInputHiddenField("form", $this->formName);
+                       $this->addInputHiddenField('form', $this->formName);
 
                        // Is a group open?
                        if ($this->groupOpened === true) {
@@ -161,13 +164,11 @@ class WebFormHelper extends BaseHelper {
         * opened. The field's name will be set as id.
         *
         * @param       $fieldName                      Input field name
-        * @param       $fieldSize                      Input size
-        * @param       $fieldMaxLength         Input max length
         * @param       $fieldValue                     Input default value (default: empty)
         * @return      void
         * @throws      FormClosedException             If the form is not yet opened
         */
-       public function addInputTextField ($fieldName, $fieldSize, $fieldMaxLength, $fieldValue = "") {
+       public function addInputTextField ($fieldName, $fieldValue = "") {
                // Is the form opened?
                if ($this->formOpened === false) {
                        // Throw an exception
@@ -175,8 +176,11 @@ class WebFormHelper extends BaseHelper {
                }
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" size=\"%d\" maxlength=\"%d\" value=\"%s\" />",
-                       $fieldName, $fieldName, $fieldSize, $fieldMaxLength, $fieldValue);
+               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
 
                // And add it maybe with a "li" tag
                $this->addContent($inputContent);
@@ -187,13 +191,11 @@ class WebFormHelper extends BaseHelper {
         * yet opened. The field's name will be set as id.
         *
         * @param       $fieldName                      Input field name
-        * @param       $fieldSize                      Input size
-        * @param       $fieldMaxLength         Input max length
         * @param       $fieldValue                     Input default value (default: empty)
         * @return      void
         * @throws      FormClosedException             If the form is not yet opened
         */
-       public function addInputPasswordField ($fieldName, $fieldSize, $fieldMaxLength, $fieldValue = "") {
+       public function addInputPasswordField ($fieldName, $fieldValue = "") {
                // Is the form opened?
                if ($this->formOpened === false) {
                        // Throw an exception
@@ -201,8 +203,11 @@ class WebFormHelper extends BaseHelper {
                }
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" size=\"%d\" maxlength=\"%d\" value=\"%s\" />",
-                       $fieldName, $fieldName, $fieldSize, $fieldMaxLength, $fieldValue);
+               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+                       $fieldName,
+                       $fieldName,
+                       $fieldValue
+               );
 
                // And add it
                $this->addContent($inputContent);
@@ -517,7 +522,7 @@ class WebFormHelper extends BaseHelper {
         * @return      $required       Wether the email address is required
         */
        public function ifRegisterRequiresEmailVerification () {
-               $required = ($this->getConfigInstance()->readConfig("register_requires_email") == "Y");
+               $required = ($this->getConfigInstance()->readConfig('register_requires_email') == "Y");
                return $required;
        }
 
@@ -527,7 +532,7 @@ class WebFormHelper extends BaseHelper {
         * @return      $required       Wether profile shall be asked
         */
        public function ifRegisterIncludesProfile () {
-               $required = ($this->getConfigInstance()->readConfig("register_includes_profile") == "Y");
+               $required = ($this->getConfigInstance()->readConfig('register_includes_profile') == "Y");
                return $required;
        }
 
@@ -537,10 +542,20 @@ class WebFormHelper extends BaseHelper {
         * @return      $required       Wether personal data shall be asked
         */
        public function ifRegisterIncludesPersonaData () {
-               $required = ($this->getConfigInstance()->readConfig("register_personal_data") == "Y");
+               $required = ($this->getConfigInstance()->readConfig('register_personal_data') == "Y");
                return $required;
        }
 
+       /**
+        * Checks wether email addresses can only be once used
+        *
+        * @return      $isUnique
+        */
+       public function ifEmailMustBeUnique () {
+               $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == "Y");
+               return $isUnique;
+       }
+
        /**
         * Checks wether the specified chat protocol is enabled in this form
         *