X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fhelper%2Fhtml%2Fforms%2Fclass_HtmlFormHelper.php;h=7143ff88bb43d3bb05993a081c248282e9280898;hb=2218902056efcf9a2c66fe7c24995e066bd7cd11;hp=9273cdf2055b408a56e848df39b116bd536fec65;hpb=78c80d535ab3e108f8c89f2aae9ebe02270e4d63;p=core.git
diff --git a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php
index 9273cdf2..7143ff88 100644
--- a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php
+++ b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php
@@ -4,8 +4,8 @@ namespace Org\Mxchange\CoreFramework\Helper;
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
@@ -83,7 +83,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $withForm Whether include the form tag
* @return $helperInstance A preparedf instance of this helper
*/
- public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) {
+ public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, string $formId = NULL, bool $withForm = true) {
// Get new instance
$helperInstance = new HtmlFormHelper();
@@ -91,7 +91,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
$helperInstance->setTemplateInstance($templateInstance);
// Is the form id not set?
- if ($formId === false) {
+ if (is_null($formId)) {
// Use form id from form name
$formId = $formName;
} // END - if
@@ -121,12 +121,12 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @throws InvalidFormNameException If the form name is invalid ( = false)
* @todo Add some unique PIN here to bypass problems with some browser and/or extensions
*/
- public function addFormTag ($formName = false, $formId = false) {
+ public function addFormTag (string $formName = NULL, string $formId = NULL) {
// When the form is not yet opened at least form name must be valid
- if (($this->formOpened === false) && ($formName === false)) {
+ if (($this->formOpened === false) && (is_null($formName))) {
// Thrown an exception
throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
- } // END - if
+ }
// Close the form is default
$formContent = '';
@@ -177,7 +177,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputTextField ($fieldName, $fieldValue = '') {
+ public function addInputTextField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -202,7 +202,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $fieldName Input field name
* @return void
*/
- public function addInputTextFieldWithDefault ($fieldName) {
+ public function addInputTextFieldWithDefault (string $fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue." \n";
@@ -220,7 +220,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputPasswordField ($fieldName, $fieldValue = '') {
+ public function addInputPasswordField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -248,7 +248,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputHiddenField ($fieldName, $fieldValue = '') {
+ public function addInputHiddenField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -271,7 +271,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $fieldName Input field name
* @return void
*/
- public function addInputHiddenFieldWithDefault ($fieldName) {
+ public function addInputHiddenFieldWithDefault (string $fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue." \n";
@@ -287,7 +287,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $prefix Prefix for configuration without trailing _
* @return void
*/
- public function addInputHiddenConfiguredField ($fieldName, $prefix) {
+ public function addInputHiddenConfiguredField (string $fieldName, string $prefix) {
// Get the value from instance
$fieldValue = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry("{$prefix}_{$fieldName}");
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue." \n";
@@ -305,7 +305,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputCheckboxField ($fieldName, $fieldChecked = true) {
+ public function addInputCheckboxField (string $fieldName, bool $fieldChecked = true) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -313,8 +313,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
} // END - if
// Set whether the check box is checked...
- $checked = ' checked="checked"';
- if ($fieldChecked === false) $checked = ' ';
+ $checked = ($fieldChecked ? ' checked="checked"' : ' ');
// Generate the content
$inputContent = sprintf('',
@@ -336,7 +335,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputResetButton ($buttonText) {
+ public function addInputResetButton (string $buttonText) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -361,7 +360,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputSubmitButton ($buttonText) {
+ public function addInputSubmitButton (string $buttonText) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -388,7 +387,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @throws FormClosedException If no form has been opened before
* @throws InvalidArgumentException If $groupId is not set
*/
- public function addFormGroup ($groupId = '', $groupText = '') {
+ public function addFormGroup (string $groupId = '', string $groupText = '') {
// Is a form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw exception here
@@ -460,7 +459,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @throws FormFormClosedException If no group has been opened before
* @throws InvalidArgumentException If $subGroupId is not set
*/
- public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
+ public function addFormSubGroup (string $subGroupId = '', string $subGroupText = '') {
// Is a group opened?
if ($this->ifGroupOpenedPreviously() === false) {
// Throw exception here
@@ -523,7 +522,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addFieldLabel ($fieldName, $fieldText, $fieldTitle = '') {
+ public function addFieldLabel (string $fieldName, string $fieldText, string $fieldTitle = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -562,7 +561,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addFormNote ($noteId, $formNotes) {
+ public function addFormNote (string $noteId, string $formNotes) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -590,7 +589,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputSelectField ($selectId, $firstEntry) {
+ public function addInputSelectField (string $selectId, string $firstEntry) {
// Is the form group opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
@@ -637,7 +636,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
* @todo Add checking if sub option is already added
*/
- public function addSelectSubOption ($subName, $subValue) {
+ public function addSelectSubOption (string $subName, string $subValue) {
// Is there a sub group (shall be a selection box!)
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
@@ -665,7 +664,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
* @todo Add checking if sub option is already added
*/
- public function addSelectOption ($optionName, $optionValue) {
+ public function addSelectOption (string $optionName, string $optionValue) {
// Is there a sub group (shall be a selection box!)
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
@@ -719,8 +718,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $formEnabled Whether form is enabled or disabled
* @return void
*/
- public final function enableForm ($formEnabled = true) {
- $this->formEnabled = (bool) $formEnabled;
+ public final function enableForm (bool $formEnabled = true) {
+ $this->formEnabled = $formEnabled;
}
/**
@@ -729,8 +728,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $formName Name of this form
* @return void
*/
- public final function setFormName ($formName) {
- $this->formName = (string) $formName;
+ public final function setFormName (string $formName) {
+ $this->formName = $formName;
}
/**
@@ -748,8 +747,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @param $formId Id of this form
* @return void
*/
- public final function setFormId ($formId) {
- $this->formId = (string) $formId;
+ public final function setFormId (string $formId) {
+ $this->formId = $formId;
}
/**
@@ -826,7 +825,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
*
* @return $required Whether the specified chat protocol is enabled
*/
- public function ifChatEnabled ($chatProtocol) {
+ public function ifChatEnabled (string $chatProtocol) {
$required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
return $required;
}
@@ -907,7 +906,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return $isUnconfirmed Whether the user account is unconfirmed
*/
public function ifUserAccountUnconfirmed () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed'));
return $isUnconfirmed;
}
@@ -917,7 +916,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return $isUnconfirmed Whether the user account is locked
*/
public function ifUserAccountLocked () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked'));
return $isUnconfirmed;
}
@@ -927,7 +926,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
* @return $isUnconfirmed Whether the user account is a guest
*/
public function ifUserAccountGuest () {
- $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
+ $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
return $isUnconfirmed;
}