Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 32 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| MetadataExporterForm | |
0.00% |
0 / 32 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 9 |
|
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) 2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoQtiItem\model\Export; |
| 23 | |
| 24 | class MetadataExporterForm extends \tao_helpers_form_FormContainer |
| 25 | { |
| 26 | /** |
| 27 | * Create a form |
| 28 | * |
| 29 | * @throws \Exception |
| 30 | * @throws \common_Exception |
| 31 | */ |
| 32 | public function initForm() |
| 33 | { |
| 34 | $this->form = new \tao_helpers_form_xhtml_Form('export'); |
| 35 | |
| 36 | $this->form->setDecorators([ |
| 37 | 'element' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), |
| 38 | 'group' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-group']), |
| 39 | 'error' => new \tao_helpers_form_xhtml_TagWrapper([ |
| 40 | 'tag' => 'div', |
| 41 | 'cssClass' => 'form-error ui-state-error ui-corner-all', |
| 42 | ]), |
| 43 | 'actions-bottom' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']), |
| 44 | 'actions-top' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']) |
| 45 | ]); |
| 46 | |
| 47 | $hiddenClassElt = \tao_helpers_form_FormFactory::getElement('xml_desc', 'Hidden'); |
| 48 | $hiddenClassElt->setValue(null); |
| 49 | $this->form->addElement($hiddenClassElt); |
| 50 | $hiddenClassElt = \tao_helpers_form_FormFactory::getElement('exportInstance', 'Hidden'); |
| 51 | $hiddenClassElt->setValue(null); |
| 52 | $this->form->addElement($hiddenClassElt); |
| 53 | |
| 54 | $exportElt = \tao_helpers_form_FormFactory::getElement('export', 'Free'); |
| 55 | $exportElt->setValue( |
| 56 | '<a href="#" class="form-submitter btn-success small"><span class="icon-export"></span> ' |
| 57 | . __('Export metadata') . '</a>' |
| 58 | ); |
| 59 | $this->form->setActions([$exportElt], 'bottom'); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Init filename field |
| 64 | * |
| 65 | * @throws \common_Exception |
| 66 | */ |
| 67 | public function initElements() |
| 68 | { |
| 69 | $date = new \DateTime(); |
| 70 | $filename = 'metadata-' . $date->format('ymd'); |
| 71 | |
| 72 | $nameElt = \tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); |
| 73 | $nameElt->setDescription(__('File name')); |
| 74 | $nameElt->setValue($filename); |
| 75 | $nameElt->setUnit(".csv"); |
| 76 | $nameElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 77 | $this->form->addElement($nameElt); |
| 78 | |
| 79 | $this->form->createGroup('options', __('Export metadata item'), ['xml_desc', 'filename', 'exportInstance']); |
| 80 | } |
| 81 | } |