X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fweb%2Fforms%2Fclass_WebFormHelper.php;h=1fffb7af1d9c215d0de1850bce4190ee0bf92aa6;hb=5bf79580029c4f6ee71e6c9e7890169e4b344def;hp=12c01b8d72e9acd4c6389a77c6039f3a9a1b66ed;hpb=d9f03cd847ac073e31b64f5e8d1da8912c160c0b;p=shipsimu.git diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index 12c01b8..1fffb7a 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -33,26 +33,6 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { */ private $formName = ""; - /** - * Wether the group is opened or not - */ - private $groupOpened = false; - - /** - * Wether the sub group is opened or not - */ - private $subGroupOpened = false; - - /** - * Name of the group - */ - private $groupName = ""; - - /** - * Name of the sub group - */ - private $subGroupName = ""; - /** * Wether form tag is enabled (default: true) */ @@ -72,12 +52,6 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("Helper class for HTML forms"); - - // Create unique ID number - $this->generateUniqueId(); } /** @@ -104,6 +78,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // Set form name $helperInstance->setFormName($formName); + // A form-less field may say "false" here... if ($withForm === true) { // Create the form @@ -157,22 +132,25 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { // Open the form and remeber the form name $this->formOpened = true; + + // Add it to the content + $this->addHeaderContent($formContent); } else { // Add the hidden field required to identify safely this form $this->addInputHiddenField('form', $this->getFormName()); // Is a group open? - if ($this->groupOpened === true) { + if ($this->ifGroupOpenedPreviously()) { // Then automatically close it here $this->addFormGroup(); } // END - if // Simply close it $this->formOpened = false; - } - // Add it to the content - $this->addContent($formContent); + // Add it to the content + $this->addFooterContent($formContent); + } } /** @@ -199,7 +177,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it maybe with a "li" tag - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -221,8 +199,8 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * Add a password input tag to the form or throw an exception if it is not * yet opened. The field's name will be set as id. * - * @param $fieldName Input field name - * @param $fieldValue Input default value (default: empty) + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) * @return void * @throws FormClosedException If the form is not yet opened */ @@ -241,15 +219,15 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** * Add a hidden input tag to the form or throw an exception if it is not * yet opened. The field's name will be set as id. * - * @param $fieldName Input field name - * @param $fieldValue Input default value (default: empty) + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) * @return void * @throws FormClosedException If the form is not yet opened */ @@ -267,7 +245,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -305,8 +283,8 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { * Add a checkbox input tag to the form or throw an exception if it is not * yet opened. The field's name will be set as id. * - * @param $fieldName Input field name - * @param $fieldChecked Wether the field is checked (defaut: checked) + * @param $fieldName Input field name + * @param $fieldChecked Wether the field is checked (defaut: checked) * @return void * @throws FormClosedException If the form is not yet opened */ @@ -329,7 +307,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** @@ -354,14 +332,14 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** * Add a reset input tag to the form or throw an exception if it is not * yet opened. The field's name will be set as id. * - * @param $buttonText Text displayed on the button + * @param $buttonText Text displayed on the button * @return void * @throws FormClosedException If the form is not yet opened */ @@ -380,36 +358,36 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { ); // And add it - $this->addContent($inputContent); + $this->addContentToPreviousGroup($inputContent); } /** * Add a form group or close an already opened and open a new one * - * @param $groupName Name of the group or last opened if empty + * @param $groupId Name of the group or last opened if empty * @param $groupText Text including HTML to show above this group * @return void * @throws FormClosedException If no form has been opened before - * @throws EmptyVariableException If $groupName is not set + * @throws EmptyVariableException If $groupId is not set */ - public function addFormGroup ($groupName = "", $groupText = "") { + public function addFormGroup ($groupId = "", $groupText = "") { // Is a form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw exception here - throw new FormClosedException(array($this, $groupName), self::EXCEPTION_CLOSED_FORM); + throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); } // END - if // At least the group name should be set - if ((empty($groupName)) && ($this->groupOpened === false)) { + if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) { // Throw exception here - throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (empty($groupName)) { + throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($groupId)) { // Close the last opened - $groupName = $this->groupName; + $groupId = $this->getPreviousGroupId(); } // Same group to open? - if (($this->groupOpened === false) && ($groupName == $this->groupName)) { + if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) { // Abort here silently return false; } // END - if @@ -418,7 +396,7 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { $content = " \n"; // Is this group opened? - if ($this->groupOpened === false) { + if ($this->ifGroupOpenedPreviously() === false) { // Begin the div/span blocks $content = sprintf("