*/
private $subGroupOpened = false;
+ /**
+ * Name of the group
+ */
+ private $groupName = "";
+
/**
* Name of the sub group
*/
// Is a group open?
if ($this->groupOpened === true) {
// Then automatically close it here
- $this->addFormGroup("", "");
+ $this->addFormGroup();
} // END - if
// Simply close it
/**
* Add a form group or close an already opened and open a new one
*
- * @param $groupName Name of the group
+ * @param $groupName 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
*/
- public function addFormGroup ($groupName, $groupText) {
+ public function addFormGroup ($groupName = "", $groupText = "") {
// Is a form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw exception here
if ((empty($groupName)) && ($this->groupOpened === false)) {
// Throw exception here
throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (empty($groupName)) {
+ // Close the last opened
+ $groupName = $this->groupName;
+ }
+
+ // Same group to open?
+ if (($this->groupOpened === false) && ($groupName == $this->groupName)) {
+ // Abort here silently
+ return false;
} // END - if
// Initialize content with closing div by default
$this->addContent($content);
// Switch the state
+ $this->groupName = $groupName;
$this->groupOpened = true;
} else {
// Is a sub group opened?
if ($this->subGroupOpened === true) {
// Close it here
- $this->addFormSubGroup("", "");
+ $this->addFormSubGroup();
} // END - if
// Add the content
* throws an exception if no group has been opened before or if the sub
* group name is empty.
*
- * @param $subGroupName Name of the group
+ * @param $subGroupName Name of the group or last opened if empty
* @param $subGroupText Text including HTML to show above this group
* @return void
* @throws FormGroupClosedException If no group has been opened before
* @throws EmptyVariableException If $subGroupName is not set
*/
- public function addFormSubGroup ($subGroupName, $subGroupText) {
+ public function addFormSubGroup ($subGroupName = "", $subGroupText = "") {
// Is a group opened?
if ($this->groupOpened === false) {
// Throw exception here
if ((empty($subGroupName)) && ($this->subGroupOpened === false)) {
// Throw exception here
throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } // END - if
+ } elseif (empty($subGroupName)) {
+ // Close the last opened
+ $subGroupName = $this->subGroupName;
+ }
// Initialize content with closing div by default
$content = " </div>\n</div><!-- Sub group- CLOSE //-->";
// Is a group open?
if ($this->groupOpened === true) {
// Then automatically close it here
- $this->addFormGroup("", "");
+ $this->addFormGroup();
} // END - if
// Generate the content
if (($this->formOpened === true) && ($this->formEnabled === true)) {
// Close the form automatically
$this->addFormTag();
- } // END - if
+ } elseif ($this->formEnabled === false) {
+ if ($this->subGroupOpened === true) {
+ // Close sub group
+ $this->addFormSubGroup();
+ } elseif ($this->groupOpened === true) {
+ // Close group
+ $this->addFormGroup();
+ }
+ }
// Send content to template engine
+ //* DEBUG: */ echo __METHOD__.": form=".$this->getFormName().", size=".strlen($this->getContent())."<br />\n";
$this->getTemplateInstance()->assignVariable($this->getFormName(), $this->getContent());
}
$extraInstance = Registry::getRegistry()->getInstance('extra');
// Get a configured instance
- $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName()."_captcha", array($this->getTemplateInstance(), $extraInstance));
+ $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName()."_captcha", array($this, $extraInstance));
// Initiate the CAPTCHA
$captchaInstance->initiateCaptcha();