",
$subGroupId,
$subGroupId,
$subGroupId,
$subGroupText,
$subGroupId
);
// Switch the state and remeber the name
$this->openSubGroupByIdContent($subGroupId, $content);
} else {
// Get previous sub group id
$prevSubGroupId = $this->getPreviousSubGroupId();
// Switch the state
$this->closePreviousSubGroupByContent($content);
// All call it again if sub group name is not empty
if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) {
$this->addFormSubGroup($subGroupId, $subGroupText);
} // END - if
}
}
/**
* Add text surrounded by a span block when there is a group opened before
* or else by a div block.
*
* @param $fieldName Field name
* @param $fieldText Text for the field
* @return void
* @throws FormClosedException If the form is not yet opened
*/
public function addFieldText ($fieldName, $fieldText) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
} // END - if
// Set the block type
$block = "div";
if ($this->ifGroupOpenedPreviously()) $block = "span";
// Generate the content
$inputContent = sprintf(" <%s id=\"%s_text\">
%s
%s>",
$block,
$fieldName,
$fieldText,
$block
);
// And add it
$this->addContentToPreviousGroup($inputContent);
}
/**
* Add text (notes) surrounded by a div block. Still opened groups or sub
* groups will be automatically closed.
*
* @param $noteId Id for this note
* @param $formNotes The form notes we shell addd
* @return void
* @throws FormClosedException If the form is not yet opened
*/
public function addFormNote ($noteId, $formNotes) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
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("
%s
",
$noteId,
$formNotes
);
// And add it
$this->addContentToPreviousGroup($inputContent);
}
/**
* 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 shall be asked
*/
public function ifRegisterIncludesProfile () {
$required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y");
return $required;
}
/**
* Adds a pre-configured CAPTCHA
*
* @return void
*/
public function addCaptcha () {
// Get last executed pre filter
$extraInstance = Registry::getRegistry()->getInstance('extra');
// Get a configured instance
$captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName().'_captcha', array($this, $extraInstance));
// Initiate the CAPTCHA
$captchaInstance->initiateCaptcha();
// Render the CAPTCHA code
$captchaInstance->renderCode();
// Get the content and add it to the helper
$this->addContentToPreviousGroup($captchaInstance->renderContent());
}
/**
* Enables/disables the form tag usage
*
* @param $formEnabled Wether form is enabled or disabled
* @return void
*/
public final function enableForm ($formEnabled = true) {
$this->formEnabled = (bool) $formEnabled;
}
/**
* Setter for form name
*
* @param $formName Name of this form
* @return void
*/
public final function setFormName ($formName) {
$this->formName = (string) $formName;
}
/**
* Getter for form name
*
* @return $formName Name of this form
*/
public final function getFormName () {
return $this->formName;
}
/**
* Checks wether this form is secured by a CAPTCHA
*
* @return $isSecured Wether this form is secured by a CAPTCHA
*/
public function ifFormSecuredWithCaptcha () {
$isSecured = ($this->getConfigInstance()->readConfig($this->getFormName().'_captcha_secured') === "Y");
return $isSecured;
}
/**
* Flushs the content out (not yet secured against open forms, etc.!) or
* close the form automatically
*
* @return void
* @throws FormOpenedException If the form is still open
*/
public function flushContent () {
// Is the form still open?
if (($this->formOpened === true) && ($this->formEnabled === true)) {
// Close the form automatically
$this->addFormTag();
} elseif ($this->formEnabled === false) {
if ($this->ifSubGroupOpenedPreviously()) {
// Close sub group
$this->addFormSubGroup();
} elseif ($this->ifGroupOpenedPreviously()) {
// Close group
$this->addFormGroup();
}
}
// Send content to template engine
//* DEBUG: */ echo __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
\n";
$this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());
}
}
// [EOF]
?>