Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| XmlEditForm | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| initForm | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2020 (original work) Open Assessment Technologies SA ; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoQtiTest\models\forms; |
| 24 | |
| 25 | use core_kernel_classes_Resource; |
| 26 | use tao_helpers_form_FormContainer; |
| 27 | use tao_helpers_form_FormFactory; |
| 28 | use tao_helpers_form_xhtml_Form; |
| 29 | use tao_helpers_form_xhtml_TagWrapper; |
| 30 | |
| 31 | class XmlEditForm extends tao_helpers_form_FormContainer |
| 32 | { |
| 33 | public function __construct(core_kernel_classes_Resource $test, string $xmlString, array $options = []) |
| 34 | { |
| 35 | parent::__construct( |
| 36 | [ |
| 37 | 'id' => $test->getUri(), |
| 38 | 'xmlString' => $xmlString |
| 39 | ], |
| 40 | $options |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * {@inheritdoc} |
| 46 | */ |
| 47 | protected function initForm(): void |
| 48 | { |
| 49 | $this->form = new tao_helpers_form_xhtml_Form('test_xml_editor_form'); |
| 50 | |
| 51 | $this->form->setDecorators([ |
| 52 | 'element' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), |
| 53 | 'error' => new tao_helpers_form_xhtml_TagWrapper([ |
| 54 | 'tag' => 'div', |
| 55 | 'cssClass' => 'form-error' |
| 56 | ]) |
| 57 | ]); |
| 58 | |
| 59 | $action = tao_helpers_form_FormFactory::getElement('save', 'Free'); |
| 60 | $action->setValue( |
| 61 | '<a href="#" class="form-submitter btn-success small"><span class="icon-save"></span> ' |
| 62 | . __('Save') . '</a>' |
| 63 | ); |
| 64 | |
| 65 | $this->form->setActions([$action], 'bottom'); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * {@inheritdoc} |
| 70 | */ |
| 71 | protected function initElements(): void |
| 72 | { |
| 73 | $element = tao_helpers_form_FormFactory::getElement('xmlString', 'textarea'); |
| 74 | $element->addAttribute('rows', '20'); |
| 75 | $element->setDescription('XML'); |
| 76 | $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 77 | $this->getForm()->addElement($element); |
| 78 | |
| 79 | $element = tao_helpers_form_FormFactory::getElement('id', 'Hidden'); |
| 80 | $this->getForm()->addElement($element); |
| 81 | } |
| 82 | } |