diff options
author | Marvin Borner | 2018-05-24 00:31:19 +0200 |
---|---|---|
committer | Marvin Borner | 2018-05-24 00:31:19 +0200 |
commit | 85211481260c076ad5e2889b66465495c33429ef (patch) | |
tree | b33c63888f81ff878c514c7c544e3afcf4cfbfd1 /main/app/sprinkles/FormGenerator/src/Element | |
parent | b66a61addb6c8e66cb26fcf74b532d68891267e4 (diff) |
Many fixes, began user feed generator
Diffstat (limited to 'main/app/sprinkles/FormGenerator/src/Element')
8 files changed, 0 insertions, 358 deletions
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Alert.php b/main/app/sprinkles/FormGenerator/src/Element/Alert.php deleted file mode 100644 index 31453d3..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Alert.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Alert input type class. - * Manage the default attributes required to display an alert - * - * @extends BaseInput - */ -class Alert extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "class" => "alert-danger", - "icon" => "fa-ban", - "value" => $this->value, - "name" => $this->name - ], $this->element); - } -} diff --git a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php b/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php deleted file mode 100644 index cf78dc6..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; -use UserFrosting\Sprinkle\Core\Facades\Translator; -use UserFrosting\Sprinkle\Core\Facades\Debug; - -/** - * BaseInput class. - * - * Parse the schema data for a form input element to add the default - * attributes values and transform other attributes. - * @abstract - * @implements InputInterface - */ -abstract class BaseInput implements InputInterface -{ - - /** - * @var String The name of the input. - */ - var $name; - - /** - * @var object The input schema data. - */ - var $element; - - /** - * @var String The input value. - */ - var $value; - - /** - * Constructor. - * - * @access public - * @param String $name - * @param object $element - * @param mixed $value (default: null) - * @return void - */ - public function __construct($name, $element, $value = NULL) { - $this->name = $name; - $this->element = $element; - $this->value = $value; - } - - /** - * parse function. - * - * Return the parsed input attributes - * @access public - * @return void - */ - public function parse() { - $this->applyTransformations(); - return $this->element; - } - - /** - * translateArgValue function. - * - * Translate the value of passed argument using the Translator Facade - * @access public - * @param String $argument - * @return void - */ - public function translateArgValue($argument) { - if (isset($this->element[$argument])) { - $this->element[$argument] = Translator::translate($this->element[$argument]); - } - } - - /** - * getValue function. - * - * Return the value of the current input element. If not value is set in - * `$this->value`, return the default value (from the schema data), if any. - * @access public - * @return string The input current value - */ - public function getValue() { - if (isset($this->value) && $this->value !== NULL) { - return $this->value; - } else if (isset($this->element['default'])) { - return $this->element['default']; - } else { - return ""; - } - } - - /** - * applyTransformations function. - * - * Add defaut attributes to the current input element. Also transform - * attributes values passed from the schema - * @access protected - * @abstract - * @return void - */ - abstract protected function applyTransformations(); -} diff --git a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php b/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php deleted file mode 100644 index 97bfdba..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Checkbox input type class. - * Manage the default attributes required to display a checkbox input - * - * @extends BaseInput - */ -class Checkbox extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "class" => "js-icheck", - "name" => $this->name, - "id" => "field_" . $this->name, - "binary" => TRUE - ], $this->element); - - // We add the check status instead of the value - 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 deleted file mode 100644 index 6f79ecd..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Hidden.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Hidden input type class. - * Manage the default attributes required to display an hidden input type - * - * @extends BaseInput - */ -class Hidden extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "value" => $this->getValue(), - "name" => $this->name, - "id" => "field_" . $this->name - ], $this->element); - } -} diff --git a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php b/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php deleted file mode 100644 index 66225bc..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @copyright Copyright (c) 2017 Louis Charette - * @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License) - */ - -namespace UserFrosting\Sprinkle\FormGenerator\Element; - -/** - * InputInterface - * - * Interface for Form elements classes - */ -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 deleted file mode 100644 index da91fbd..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Select.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Select input type class. - * Manage the default attributes required to display a select input type - * - * @extends BaseInput - */ -class Select extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "class" => "form-control js-select2", - "value" => $this->getValue(), - "name" => $this->name, - "id" => "field_" . $this->name - ], $this->element); - - // Placeholder is required to be in `data-*` for select 2 - // Plus we translate the placeholder - if (isset($this->element["placeholder"])) { - $this->element["data-placeholder"] = $this->element["placeholder"]; - unset($this->element["placeholder"]); - $this->translateArgValue('data-placeholder'); - } - } -} diff --git a/main/app/sprinkles/FormGenerator/src/Element/Text.php b/main/app/sprinkles/FormGenerator/src/Element/Text.php deleted file mode 100644 index 375153d..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Text.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Text input type class. - * Manage the default attributes required to display a text and other html5 input - * - * @extends BaseInput - */ -class Text extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "autocomplete" => "off", - "class" => "form-control", - "value" => $this->getValue(), - "name" => $this->name, - "id" => "field_" . $this->name - ], $this->element); - - // Translate placeholder - $this->translateArgValue('placeholder'); - } -} diff --git a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php b/main/app/sprinkles/FormGenerator/src/Element/Textarea.php deleted file mode 100644 index b2a84f9..0000000 --- a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/** - * UF Form Generator - * - * @link https://github.com/lcharette/UF_FormGenerator - * @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; - -/** - * Textarea input type class. - * Manage the default attributes required to display a textarea input - * - * @extends BaseInput - */ -class Textarea extends BaseInput -{ - - /** - * {@inheritDoc} - */ - protected function applyTransformations() { - $this->element = array_merge([ - "autocomplete" => "off", - "class" => "form-control", - "value" => $this->getValue(), - "name" => $this->name, - "rows" => 3, - "id" => "field_" . $this->name - ], $this->element); - - // Translate placeholder - $this->translateArgValue('placeholder'); - } -} |