Automatic pass to convert with php-cs-fixer
This commit is contained in:
@@ -1,85 +1,107 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework;
|
||||
|
||||
/** The definition of a formfield
|
||||
*/
|
||||
/**
|
||||
* The definition of a formfield
|
||||
*/
|
||||
class Formfield
|
||||
{
|
||||
/** The form name
|
||||
*/
|
||||
/**
|
||||
* The form name
|
||||
*/
|
||||
public $formName;
|
||||
/** The name of the field
|
||||
*/
|
||||
/**
|
||||
* The name of the field
|
||||
*/
|
||||
public $name;
|
||||
/** The label of the field
|
||||
*/
|
||||
/**
|
||||
* The label of the field
|
||||
*/
|
||||
public $label;
|
||||
/** The titles of the field
|
||||
*/
|
||||
/**
|
||||
* The titles of the field
|
||||
*/
|
||||
public $titles;
|
||||
/** The defaults values of the field
|
||||
*/
|
||||
/**
|
||||
* The defaults values of the field
|
||||
*/
|
||||
public $defaults;
|
||||
/** The type of the field (text, password, checkbox, select)
|
||||
*/
|
||||
/**
|
||||
* The type of the field (text, password, checkbox, select)
|
||||
*/
|
||||
public $type = "text";
|
||||
/** The state of the field : hidden or show
|
||||
*/
|
||||
/**
|
||||
* The state of the field : hidden or show
|
||||
*/
|
||||
public $hidden = false;
|
||||
/** Allow a help message to be displayed below the field. In case of error,
|
||||
* it is overrided by the error message
|
||||
*/
|
||||
/**
|
||||
* Allow a help message to be displayed below the field. In case of error,
|
||||
* it is overrided by the error message
|
||||
*/
|
||||
public $help;
|
||||
/** Display the placeholder if needed
|
||||
*/
|
||||
/**
|
||||
* Display the placeholder if needed
|
||||
*/
|
||||
public $placeholder = false;
|
||||
/** The multiplicity of selection of the field (available in select only)
|
||||
*/
|
||||
/**
|
||||
* The multiplicity of selection of the field (available in select only)
|
||||
*/
|
||||
public $multiple;
|
||||
/** The name of group for the fields
|
||||
*/
|
||||
/**
|
||||
* The name of group for the fields
|
||||
*/
|
||||
public $group;
|
||||
/** The read-only feature of the field
|
||||
*/
|
||||
/**
|
||||
* The read-only feature of the field
|
||||
*/
|
||||
public $readonly;
|
||||
/** The field is mandatory
|
||||
*/
|
||||
/**
|
||||
* The field is mandatory
|
||||
*/
|
||||
public $mandatory;
|
||||
/** The statut of error of the field
|
||||
*/
|
||||
/**
|
||||
* The statut of error of the field
|
||||
*/
|
||||
public $error;
|
||||
/** Number of rows
|
||||
*/
|
||||
/**
|
||||
* Number of rows
|
||||
*/
|
||||
public $rows;
|
||||
/** Number of columns
|
||||
*/
|
||||
/**
|
||||
* Number of columns
|
||||
*/
|
||||
public $cols;
|
||||
/** The Bootstrap width of the column of titles
|
||||
*/
|
||||
/**
|
||||
* The Bootstrap width of the column of titles
|
||||
*/
|
||||
public $titlewidth = 2;
|
||||
/** The Bootstrap width of the column of fields
|
||||
*/
|
||||
/**
|
||||
* The Bootstrap width of the column of fields
|
||||
*/
|
||||
public $fieldwidth = 10;
|
||||
|
||||
/** When adding a field, the name and the label are the minimum mandatory
|
||||
* @param string $name Name of the field
|
||||
* @param string|null $label Label of the field
|
||||
*/
|
||||
/**
|
||||
* When adding a field, the name and the label are the minimum mandatory
|
||||
* @param string $name Name of the field
|
||||
* @param string|null $label Label of the field
|
||||
*/
|
||||
public function __construct($name, $label = "")
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/** Display really the form
|
||||
*/
|
||||
/**
|
||||
* Display really the form
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
$func = "field" . $this->formTemplate . $this->type;
|
||||
@@ -87,90 +109,100 @@ class Formfield
|
||||
}
|
||||
|
||||
// Setters for all the properties of the class
|
||||
/** Set the type of the field
|
||||
* @param string $val The value of the type of the field
|
||||
*/
|
||||
/**
|
||||
* Set the type of the field
|
||||
* @param string $val The value of the type of the field
|
||||
*/
|
||||
public function type($val)
|
||||
{
|
||||
$this->type = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the hidden of the field
|
||||
* @param string $val The value of the hidden of the field
|
||||
*/
|
||||
/**
|
||||
* Set the hidden of the field
|
||||
* @param string $val The value of the hidden of the field
|
||||
*/
|
||||
public function hidden($val)
|
||||
{
|
||||
$this->hidden = !! $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the help of the field
|
||||
* @param string $val The value of the help of the field
|
||||
*/
|
||||
/**
|
||||
* Set the help of the field
|
||||
* @param string $val The value of the help of the field
|
||||
*/
|
||||
public function help($val)
|
||||
{
|
||||
$this->help = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the placeholder
|
||||
* @param string $val The value of the placeholder
|
||||
*/
|
||||
/**
|
||||
* Set the placeholder
|
||||
* @param string $val The value of the placeholder
|
||||
*/
|
||||
public function placeholder($val)
|
||||
{
|
||||
$this->placeholder = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the multiple
|
||||
* @param string $val The value of the multiple
|
||||
*/
|
||||
/**
|
||||
* Set the multiple
|
||||
* @param string $val The value of the multiple
|
||||
*/
|
||||
public function multiple($val)
|
||||
{
|
||||
$this->multiple = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the group
|
||||
* @param string $val The value of the group
|
||||
*/
|
||||
/**
|
||||
* Set the group
|
||||
* @param string $val The value of the group
|
||||
*/
|
||||
public function group($val)
|
||||
{
|
||||
$this->group = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the readonly
|
||||
* @param string $val The value of the readonly
|
||||
*/
|
||||
/**
|
||||
* Set the readonly
|
||||
* @param string $val The value of the readonly
|
||||
*/
|
||||
public function readonly($val)
|
||||
{
|
||||
$this->readonly = !! $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the mandatory
|
||||
* @param string $val The value of the mandatory
|
||||
*/
|
||||
/**
|
||||
* Set the mandatory
|
||||
* @param string $val The value of the mandatory
|
||||
*/
|
||||
public function mandatory($val)
|
||||
{
|
||||
$this->mandatory = !! $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the rows
|
||||
* @param string $val The value of the rows
|
||||
*/
|
||||
/**
|
||||
* Set the rows
|
||||
* @param string $val The value of the rows
|
||||
*/
|
||||
public function rows($val)
|
||||
{
|
||||
$this->rows = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the cols
|
||||
* @param string $val The value of the cols
|
||||
*/
|
||||
/**
|
||||
* Set the cols
|
||||
* @param string $val The value of the cols
|
||||
*/
|
||||
public function cols($val)
|
||||
{
|
||||
$this->cols = $val;
|
||||
@@ -180,14 +212,15 @@ class Formfield
|
||||
//////////////////////////
|
||||
//// BOOTSTRAP3 ////
|
||||
//////////////////////////
|
||||
/** Return the checkbox defined
|
||||
*/
|
||||
/**
|
||||
* Return the checkbox defined
|
||||
*/
|
||||
private function fieldBootstrap3checkbox()
|
||||
{
|
||||
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
||||
// $this->maxlength
|
||||
if (! is_array($this->titles) || count($this->titles) === 0) {
|
||||
$titles = array("");
|
||||
$titles = [""];
|
||||
} else {
|
||||
$titles = $this->titles;
|
||||
}
|
||||
@@ -326,8 +359,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the hidden field defined
|
||||
*/
|
||||
/**
|
||||
* Return the hidden field defined
|
||||
*/
|
||||
private function fieldBootstrap3hidden()
|
||||
{
|
||||
$res = "";
|
||||
@@ -347,8 +381,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the password field defined
|
||||
*/
|
||||
/**
|
||||
* Return the password field defined
|
||||
*/
|
||||
private function fieldBootstrap3password()
|
||||
{
|
||||
$res = "";
|
||||
@@ -430,8 +465,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the radio field defined
|
||||
*/
|
||||
/**
|
||||
* Return the radio field defined
|
||||
*/
|
||||
private function fieldBootstrap3radio()
|
||||
{
|
||||
$res = "";
|
||||
@@ -469,7 +505,7 @@ class Formfield
|
||||
}
|
||||
$res .= " <div class='col-sm-$this->fieldwidth'>\n";
|
||||
if (is_string($this->defaults)) {
|
||||
$this->defaults = array($this->defaults);
|
||||
$this->defaults = [$this->defaults];
|
||||
}
|
||||
$res .= " <input type='hidden'";
|
||||
$res .= " name='$this->formName" . "[";
|
||||
@@ -531,8 +567,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the checkbox defined
|
||||
*/
|
||||
/**
|
||||
* Return the checkbox defined
|
||||
*/
|
||||
private function fieldBootstrap3select()
|
||||
{
|
||||
// No $this->placeholder $this->maxlength
|
||||
@@ -627,7 +664,7 @@ class Formfield
|
||||
} elseif (
|
||||
isset($this->values) &&
|
||||
is_array($this->values) &&
|
||||
in_array($key, $this->values)
|
||||
in_array($key, $this->values, true)
|
||||
) {
|
||||
$res .= " selected='selected'";
|
||||
}
|
||||
@@ -660,8 +697,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the submit defined
|
||||
*/
|
||||
/**
|
||||
* Return the submit defined
|
||||
*/
|
||||
private function fieldBootstrap3submit()
|
||||
{
|
||||
$res = "";
|
||||
@@ -704,8 +742,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the textarea defined
|
||||
*/
|
||||
/**
|
||||
* Return the textarea defined
|
||||
*/
|
||||
private function fieldBootstrap3textarea()
|
||||
{
|
||||
$res = "";
|
||||
@@ -789,8 +828,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the text defined
|
||||
*/
|
||||
/**
|
||||
* Return the text defined
|
||||
*/
|
||||
private function fieldBootstrap3text()
|
||||
{
|
||||
$res = "";
|
||||
@@ -872,8 +912,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the file defined
|
||||
*/
|
||||
/**
|
||||
* Return the file defined
|
||||
*/
|
||||
private function fieldBootstrap3file()
|
||||
{
|
||||
$res = "";
|
||||
@@ -973,14 +1014,15 @@ class Formfield
|
||||
//////////////////////////
|
||||
//// BOOTSTRAP4 ////
|
||||
//////////////////////////
|
||||
/** Return the checkbox defined
|
||||
*/
|
||||
/**
|
||||
* Return the checkbox defined
|
||||
*/
|
||||
private function fieldBootstrap4checkbox()
|
||||
{
|
||||
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
||||
// $this->maxlength
|
||||
if (! is_array($this->titles) || count($this->titles) === 0) {
|
||||
$this->titles = array("");
|
||||
$this->titles = [""];
|
||||
}
|
||||
$res = "";
|
||||
$res .= "<div class='form-group";
|
||||
@@ -1127,8 +1169,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the hidden field defined
|
||||
*/
|
||||
/**
|
||||
* Return the hidden field defined
|
||||
*/
|
||||
private function fieldBootstrap4hidden()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1148,8 +1191,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the password field defined
|
||||
*/
|
||||
/**
|
||||
* Return the password field defined
|
||||
*/
|
||||
private function fieldBootstrap4password()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1239,8 +1283,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the radio field defined
|
||||
*/
|
||||
/**
|
||||
* Return the radio field defined
|
||||
*/
|
||||
private function fieldBootstrap4radio()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1284,7 +1329,7 @@ class Formfield
|
||||
}
|
||||
$res .= " <div class='col-sm-$this->fieldwidth'>\n";
|
||||
if (is_string($this->defaults)) {
|
||||
$this->defaults = array($this->defaults);
|
||||
$this->defaults = [$this->defaults];
|
||||
}
|
||||
$res .= " <input type='hidden'";
|
||||
$res .= " name='$this->formName" . "[";
|
||||
@@ -1348,8 +1393,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the checkbox defined
|
||||
*/
|
||||
/**
|
||||
* Return the checkbox defined
|
||||
*/
|
||||
private function fieldBootstrap4select()
|
||||
{
|
||||
// No $this->placeholder $this->maxlength
|
||||
@@ -1454,7 +1500,7 @@ class Formfield
|
||||
} elseif (
|
||||
isset($this->values) &&
|
||||
is_array($this->values) &&
|
||||
in_array($key, $this->values)
|
||||
in_array($key, $this->values, true)
|
||||
) {
|
||||
$res .= " selected='selected'";
|
||||
}
|
||||
@@ -1485,8 +1531,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the submit defined
|
||||
*/
|
||||
/**
|
||||
* Return the submit defined
|
||||
*/
|
||||
private function fieldBootstrap4submit()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1529,8 +1576,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the textarea defined
|
||||
*/
|
||||
/**
|
||||
* Return the textarea defined
|
||||
*/
|
||||
private function fieldBootstrap4textarea()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1622,8 +1670,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the text defined
|
||||
*/
|
||||
/**
|
||||
* Return the text defined
|
||||
*/
|
||||
private function fieldBootstrap4text()
|
||||
{
|
||||
$res = "";
|
||||
@@ -1713,8 +1762,9 @@ class Formfield
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Return the file defined
|
||||
*/
|
||||
/**
|
||||
* Return the file defined
|
||||
*/
|
||||
private function fieldBootstrap4file()
|
||||
{
|
||||
$res = "";
|
||||
|
||||
Reference in New Issue
Block a user