Remove all the {{{ and }}} folding

This commit is contained in:
2022-11-25 20:34:27 +01:00
parent b723f47a44
commit 2d6df0d5f0
35 changed files with 0 additions and 1124 deletions

View File

@@ -66,14 +66,11 @@ class Form
* @param string|null $formName The form name
*/
public function __construct ($formName = "form")
// {{{
{
$this->formName = $formName;
}
// }}}
// The setters of the properties
// {{{
/** Set the debug level
* @param integer $val The debug value
*/
@@ -161,14 +158,12 @@ class Form
$this->formTemplate = $formTemplate;
return $this;
}
// }}}
/** The private method to log if the $this->loggingCallable is defined
* @param integer $prio The priority of the message
* @param string $msg The message to store
*/
private function loggingCallable ($prio, $msg)
// {{{
{
if (! is_callable ($this->loggingCallable))
return;
@@ -177,7 +172,6 @@ class Form
$base = $this->loggingBasemsg. " ";
call_user_func ($this->loggingCallable, $prio, $base.$msg);
}
// }}}
/** Save the array of fields into the structure.
* Available :
@@ -208,29 +202,24 @@ class Form
* @param array $fields The fields to be displayed
*/
public function fields ($fields)
// {{{
{
$this->fields = $fields;
}
// }}}
/** Add a field to the form. For the details of a field, see the description
* in fields method
* @param object $field The field to add
*/
public function addfield ($field)
// {{{
{
$this->fields[] = $field;
}
// }}}
/** Return the values provided by the user. Test the CSRF before continue
* NEVER read the values from $_POST in your codes or CSRF will not be
* checked
*/
public function values ()
// {{{
{
$values = array ();
if ($this->method === "post")
@@ -286,7 +275,6 @@ class Form
return $values;
}
// }}}
/** Return the fields in HTML code. If $values is provided, use it in place
* of default values. In case of select boxes, $values are the selected
@@ -300,7 +288,6 @@ class Form
*/
public function printHTML ($method = 'post', $values = NULL,
$errors = array())
// {{{
{
if (count ($this->fields) === 0)
{
@@ -425,13 +412,11 @@ class Form
$res .= "</form>\n";
return $res;
}
// }}}
/** Check the token from the user
* @param string $tokenFromUser The value form the user's token
*/
public function checkToken ($tokenFromUser)
// {{{
{
$csrf = new Csrf ();
$csrf->field = $this->csrfField;
@@ -439,18 +424,15 @@ class Form
// problem. If there is no problem, it delete the token
$csrf->checkThenDeleteToken ($tokenFromUser);
}
// }}}
/** Return the token generated in form
*/
public function getToken ()
// {{{
{
if ($this->csrfToken === "")
$this->createToken ();
return $this->csrfToken;
}
// }}}
/** Check if the parameters are correct with the defined fields
* Need the session !
@@ -460,7 +442,6 @@ class Form
* @return array containing the errors
*/
public function verify ($values, $fields=array ())
// {{{
{
if (count ($fields) === 0)
{
@@ -479,7 +460,6 @@ class Form
}
return $errors;
}
// }}}
/** If there is at least one error reported in $errors, save the old values
* and the errors in the session, and redirect to the provided url.
@@ -501,7 +481,6 @@ class Form
$route->redirect ("/admin/space/");
*/
public function redirectIfError ($values, $errors, $route, $url = "")
// {{{
{
$this->saveValuesErrors ($values, $errors);
if ($url === "")
@@ -509,7 +488,6 @@ class Form
if (count ($errors)) $route->redirect ($url);
$this->saveValuesErrorsReset ();
}
// }}}
/** Save the values and errors to be displayed in the next page if the session
* is available
@@ -518,7 +496,6 @@ class Form
* @param array|null $errors The errors detected by a verify
*/
public function saveValuesErrors ($values, $errors=array ())
// {{{
{
if (isset ($_SESSION))
{
@@ -526,18 +503,15 @@ class Form
$_SESSION["domframework"]["form"][$this->formName]["errors"] = $errors;
}
}
// }}}
/** Reset the saved values to provide a clean form next page
* Need the session to work
*/
public function saveValuesErrorsReset ()
// {{{
{
unset ($_SESSION["domframework"]["form"][$this->formName]["values"]);
unset ($_SESSION["domframework"]["form"][$this->formName]["errors"]);
}
// }}}
/** Get the stored values if there is one. If there is no stored values,
* return the values provided as parameter
@@ -545,7 +519,6 @@ class Form
* @return array The values to use
*/
public function getOldValues ($values)
// {{{
{
if (isset ($_SESSION["domframework"]["form"][$this->formName]["values"]))
{
@@ -554,7 +527,6 @@ class Form
}
return $values;
}
// }}}
/** Get the stored errors if there is one. If there is no sorted errors,
* return the errors provided as parameter
@@ -562,7 +534,6 @@ class Form
* @return array The errors to use
*/
public function getOldErrors ($errors)
// {{{
{
if (isset ($_SESSION["domframework"]["form"][$this->formName]["errors"]))
{
@@ -571,7 +542,6 @@ class Form
}
return $errors;
}
// }}}
/** Convert Date received in one format to another.
* If the provided string is not corresponding to the format, don't change
@@ -583,7 +553,6 @@ class Form
* @return string
*/
public function convertDate ($inputDate, $inputFormat, $outputFormat)
// {{{
{
$date = \DateTime::CreateFromFormat ($inputFormat, $inputDate);
if ($date === false)
@@ -593,5 +562,4 @@ class Form
return $inputDate;
return $date->format ($outputFormat);
}
// }}}
}