Code merged from ship-simu repository
[mailer.git] / inc / classes / main / helper / web / forms / class_WebFormHelper.php
index a188251b5cd84215b1e2c94e55a4ef4beb77a3c1..1fffb7af1d9c215d0de1850bce4190ee0bf92aa6 100644 (file)
@@ -378,7 +378,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                } // END - if
 
                // At least the group name should be set
-               if ((empty($groupId)) && (!$this->ifGroupOpenedPreviously())) {
+               if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) {
                        // Throw exception here
                        throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (empty($groupId)) {
@@ -387,7 +387,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                }
 
                // Same group to open?
-               if ((!$this->ifGroupOpenedPreviously()) && ($groupId == $this->getPreviousGroupId())) {
+               if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) {
                        // Abort here silently
                        return false;
                } // END - if
@@ -396,7 +396,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                $content = "    </div>\n</div><!-- Group - CLOSE //-->";
 
                // Is this group opened?
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // Begin the div/span blocks
                        $content = sprintf("<!-- Group %s - OPEN //-->
 <div class=\"group_box\" id=\"%s_group_box\">
@@ -412,7 +412,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Switch the state
-                       $this->openGroupByIdContent($groupId, $content);
+                       $this->openGroupByIdContent($groupId, $content, "div");
                } else {
                        // Is a sub group opened?
                        if ($this->ifSubGroupOpenedPreviously()) {
@@ -426,7 +426,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        // Switch the state
                        $this->closePreviousGroupByContent($content);
 
-                       // All call it again if the group name is not empty
+                       // All call it again if group name is not empty
                        if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
                                //* DEBUG: */ echo $groupId."/".$prevGroupId."<br />\n";
                                $this->addFormGroup($groupId, $groupText);
@@ -436,8 +436,8 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
 
        /**
         * Add a form sub group or close an already opened and open a new one or
-        * throws an exception if no group has been opened before or if the sub
-        * group name is empty.
+        * throws an exception if no group has been opened before or if sub group
+        * name is empty.
         *
         * @param       $subGroupId             Name of the group or last opened if empty
         * @param       $subGroupText   Text including HTML to show above this group
@@ -447,13 +447,13 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addFormSubGroup ($subGroupId = "", $subGroupText = "") {
                // Is a group opened?
-               if (!$this->ifGroupOpenedPreviously()) {
+               if ($this->ifGroupOpenedPreviously() === false) {
                        // Throw exception here
                        throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
                } // END - if
 
                // At least the sub group name should be set
-               if ((empty($subGroupId)) && (!$this->ifSubGroupOpenedPreviously())) {
+               if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) {
                        // Throw exception here
                        throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (empty($subGroupId)) {
@@ -462,7 +462,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                }
 
                // Same sub group to open?
-               if ((!$this->ifSubGroupOpenedPreviously()) && ($subGroupId == $this->getPreviousSubGroupId())) {
+               if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) {
                        // Abort here silently
                        return false;
                } // END - if
@@ -471,7 +471,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                $content = "    </div>\n</div><!-- Sub group- CLOSE //-->";
 
                // Is this group opened?
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Begin the span block
                        $content = sprintf("<!-- Sub group %s - OPEN //-->
 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
@@ -487,7 +487,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Switch the state and remeber the name
-                       $this->openSubGroupByIdContent($subGroupId, $content);
+                       $this->openSubGroupByIdContent($subGroupId, $content, "div");
                } else {
                        // Get previous sub group id
                        $prevSubGroupId = $this->getPreviousSubGroupId();
@@ -552,12 +552,6 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM);
                } // END - if
 
-               // Is a group open?
-               if ($this->ifGroupOpenedPreviously()) {
-                       // Then automatically close it here
-                       $this->addFormGroup();
-               } // END - if
-
                // Generate the content
                $inputContent = sprintf("       <div id=\"form_note_%s\">
                %s
@@ -587,7 +581,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                } // END - if
 
                // Shall we close or open the sub group?
-               if ((!$this->ifSubGroupOpenedPreviously()) && ($this->getPreviousSubGroupId() !== $selectId)) {
+               if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) {
                        // Initialize first entry (which might be non-selectable if content is provided
                        if (!empty($firstEntry)) {
                                // Add selection around it
@@ -605,10 +599,10 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
                        );
 
                        // Open the sub group
-                       $this->openSubGroupByIdContent($selectId, $content);
+                       $this->openSubGroupByIdContent($selectId, $content, "select");
                } elseif ($this->getPreviousSubGroupId() != $selectId) {
                        // Something went wrong!
-                       $this->debugInstance();
+                       $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
                } else {
                        // Close the sub group
                        $this->closePreviousSubGroupByContent("</select>");
@@ -628,7 +622,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addSelectSubOption ($subName, $subValue) {
                // Is there a sub group (shall be a selection box!)
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception here
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if
@@ -656,7 +650,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate {
         */
        public function addSelectOption ($optionName, $optionValue) {
                // Is there a sub group (shall be a selection box!)
-               if (!$this->ifSubGroupOpenedPreviously()) {
+               if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception here
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
                } // END - if