diff options
author | Marvin Borner | 2018-05-23 22:23:28 +0200 |
---|---|---|
committer | Marvin Borner | 2018-05-23 22:23:28 +0200 |
commit | b66a61addb6c8e66cb26fcf74b532d68891267e4 (patch) | |
tree | 05e9449ff25bdc98f68105f41923ccb9f6ef5095 /main/app/sprinkles/FormGenerator/src/Element | |
parent | 1d4ef435177a5f9b6d1a289800d933e49be0c550 (diff) |
Refactored code, many fixes and improvements in chat backend+frontend
Diffstat (limited to 'main/app/sprinkles/FormGenerator/src/Element')
8 files changed, 37 insertions, 28 deletions
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Alert.php b/main/app/sprinkles/FormGenerator/src/Element/Alert.php index f848b5c..31453d3 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Alert.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Alert.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Alert extends BaseInput { +class Alert extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "class" => "alert-danger", "icon" => "fa-ban", diff --git a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php b/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php index d892001..cf78dc6 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php +++ b/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\InputInterface; @@ -20,7 +21,8 @@ use UserFrosting\Sprinkle\Core\Facades\Debug; * @abstract * @implements InputInterface */ -abstract class BaseInput implements InputInterface { +abstract class BaseInput implements InputInterface +{ /** * @var String The name of the input. @@ -46,8 +48,7 @@ abstract class BaseInput implements InputInterface { * @param mixed $value (default: null) * @return void */ - public function __construct($name, $element, $value = null) - { + public function __construct($name, $element, $value = NULL) { $this->name = $name; $this->element = $element; $this->value = $value; @@ -60,8 +61,7 @@ abstract class BaseInput implements InputInterface { * @access public * @return void */ - public function parse() - { + public function parse() { $this->applyTransformations(); return $this->element; } @@ -89,7 +89,7 @@ abstract class BaseInput implements InputInterface { * @return string The input current value */ public function getValue() { - if (isset($this->value) && $this->value !== null) { + if (isset($this->value) && $this->value !== NULL) { return $this->value; } else if (isset($this->element['default'])) { return $this->element['default']; diff --git a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php b/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php index 59e6eaf..97bfdba 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,22 +17,22 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Checkbox extends BaseInput { +class Checkbox extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "class" => "js-icheck", "name" => $this->name, "id" => "field_" . $this->name, - "binary" => true + "binary" => TRUE ], $this->element); // We add the check status instead of the value - if ($this->element["binary"] !== false && $this->getValue() == 1) { + if ($this->element["binary"] !== FALSE && $this->getValue() == 1) { $this->element["checked"] = "checked"; } } diff --git a/main/app/sprinkles/FormGenerator/src/Element/Hidden.php b/main/app/sprinkles/FormGenerator/src/Element/Hidden.php index 08c22f7..6f79ecd 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Hidden.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Hidden.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Hidden extends BaseInput { +class Hidden extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "value" => $this->getValue(), "name" => $this->name, diff --git a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php b/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php index 7405109..66225bc 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php +++ b/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; /** @@ -13,7 +14,9 @@ namespace UserFrosting\Sprinkle\FormGenerator\Element; * * Interface for Form elements classes */ -interface InputInterface { - public function __construct($name, $element, $value = null); +interface InputInterface +{ + public function __construct($name, $element, $value = NULL); + public function parse(); } diff --git a/main/app/sprinkles/FormGenerator/src/Element/Select.php b/main/app/sprinkles/FormGenerator/src/Element/Select.php index bb23772..da91fbd 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Select.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Select.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Select extends BaseInput { +class Select extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "class" => "form-control js-select2", "value" => $this->getValue(), diff --git a/main/app/sprinkles/FormGenerator/src/Element/Text.php b/main/app/sprinkles/FormGenerator/src/Element/Text.php index b936fe2..375153d 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Text.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Text.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Text extends BaseInput { +class Text extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "autocomplete" => "off", "class" => "form-control", diff --git a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php b/main/app/sprinkles/FormGenerator/src/Element/Textarea.php index bec3a6c..b2a84f9 100644 --- a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php +++ b/main/app/sprinkles/FormGenerator/src/Element/Textarea.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2017 Louis Charette * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) */ + namespace UserFrosting\Sprinkle\FormGenerator\Element; use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; @@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput; * * @extends BaseInput */ -class Textarea extends BaseInput { +class Textarea extends BaseInput +{ /** * {@inheritDoc} */ - protected function applyTransformations() - { + protected function applyTransformations() { $this->element = array_merge([ "autocomplete" => "off", "class" => "form-control", |