Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_form_RemoteList | |
0.00% |
0 / 23 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| createTextBoxElement | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2020 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | class tao_actions_form_RemoteList extends tao_helpers_form_FormContainer |
| 26 | { |
| 27 | public const FIELD_NAME = 'name'; |
| 28 | public const FIELD_SOURCE_URL = 'source'; |
| 29 | public const FIELD_ITEM_LABEL_PATH = 'label_path'; |
| 30 | public const FIELD_ITEM_URI_PATH = 'uri_path'; |
| 31 | public const FIELD_DEPENDENCY_ITEM_URI_PATH = 'dependency_uri_path'; |
| 32 | |
| 33 | public const IS_LISTS_DEPENDENCY_ENABLED = 'isListsDependencyEnabled'; |
| 34 | |
| 35 | /** |
| 36 | * Short description of method initForm |
| 37 | * |
| 38 | * @access public |
| 39 | * @return mixed |
| 40 | * @throws common_Exception |
| 41 | */ |
| 42 | public function initForm() |
| 43 | { |
| 44 | $this->form = tao_helpers_form_FormFactory::getForm('list'); |
| 45 | |
| 46 | $addElt = tao_helpers_form_FormFactory::getElement('add', 'Free'); |
| 47 | |
| 48 | $addElt->setValue( |
| 49 | '<a href="#" class="form-submitter btn-success small"><span class="icon-add"></span> ' |
| 50 | . __('Add') . '</a>' |
| 51 | ); |
| 52 | $this->form->setActions([$addElt], 'bottom'); |
| 53 | $this->form->setActions([], 'top'); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @access public |
| 58 | * @throws common_Exception |
| 59 | */ |
| 60 | public function initElements() |
| 61 | { |
| 62 | $this->createTextBoxElement(self::FIELD_NAME, __('Name')); |
| 63 | $this->createTextBoxElement(self::FIELD_SOURCE_URL, __('Data source URI')); |
| 64 | $this->createTextBoxElement(self::FIELD_ITEM_LABEL_PATH, __('Label Path')); |
| 65 | $this->createTextBoxElement(self::FIELD_ITEM_URI_PATH, __('URI Path')); |
| 66 | |
| 67 | if (($this->options[self::IS_LISTS_DEPENDENCY_ENABLED] ?? false)) { |
| 68 | $this->createTextBoxElement( |
| 69 | self::FIELD_DEPENDENCY_ITEM_URI_PATH, |
| 70 | __('Dependency URI Path'), |
| 71 | false |
| 72 | ); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @throws common_Exception |
| 78 | */ |
| 79 | private function createTextBoxElement(string $name, string $label, bool $addNotEmptyValidator = true): void |
| 80 | { |
| 81 | $element = tao_helpers_form_FormFactory::getElement($name, 'Textbox'); |
| 82 | $element->setDescription($label); |
| 83 | |
| 84 | if ($addNotEmptyValidator) { |
| 85 | $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 86 | } |
| 87 | |
| 88 | $this->form->addElement($element); |
| 89 | } |
| 90 | } |