Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_models_classes_export_RdfExportForm | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
12 | |||
| 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-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | /** |
| 27 | * Export form for QTI packages |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 31 | */ |
| 32 | class tao_models_classes_export_RdfExportForm extends tao_helpers_form_FormContainer |
| 33 | { |
| 34 | // --- ASSOCIATIONS --- |
| 35 | |
| 36 | |
| 37 | // --- ATTRIBUTES --- |
| 38 | |
| 39 | // --- OPERATIONS --- |
| 40 | /** |
| 41 | * Short description of method initForm |
| 42 | * |
| 43 | * @access public |
| 44 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 45 | * @return mixed |
| 46 | */ |
| 47 | public function initForm() |
| 48 | { |
| 49 | |
| 50 | |
| 51 | $this->form = new tao_helpers_form_xhtml_Form('export'); |
| 52 | |
| 53 | $this->form->setDecorators([ |
| 54 | 'element' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), |
| 55 | 'group' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-group']), |
| 56 | 'error' => new tao_helpers_form_xhtml_TagWrapper([ |
| 57 | 'tag' => 'div', |
| 58 | 'cssClass' => 'form-error ui-state-error ui-corner-all' |
| 59 | ]), |
| 60 | 'actions-bottom' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']), |
| 61 | ]); |
| 62 | |
| 63 | $exportElt = tao_helpers_form_FormFactory::getElement('export', 'Free'); |
| 64 | $exportElt->setValue( |
| 65 | '<a href="#" class="form-submitter btn-success small"><span class="icon-export"></span> ' |
| 66 | . __('Export') . '</a>' |
| 67 | ); |
| 68 | |
| 69 | $this->form->setActions([$exportElt], 'bottom'); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * overriden |
| 74 | * |
| 75 | * @access public |
| 76 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 77 | * @return mixed |
| 78 | */ |
| 79 | public function initElements() |
| 80 | { |
| 81 | |
| 82 | $fileName = ''; |
| 83 | |
| 84 | $instances = []; |
| 85 | if (isset($this->data['instance'])) { |
| 86 | $resource = $this->data['instance']; |
| 87 | } elseif (isset($this->data['class'])) { |
| 88 | $resource = $this->data['class']; |
| 89 | } else { |
| 90 | throw new common_Exception('No class nor instance specified for export'); |
| 91 | } |
| 92 | |
| 93 | $fileName = strtolower(tao_helpers_Display::textCleaner($resource->getLabel(), '*')); |
| 94 | |
| 95 | $hiddenElt = tao_helpers_form_FormFactory::getElement('resource', 'Hidden'); |
| 96 | $hiddenElt->setValue($resource->getUri()); |
| 97 | $this->form->addElement($hiddenElt); |
| 98 | |
| 99 | |
| 100 | $nameElt = tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); |
| 101 | $nameElt->setDescription(__('File name')); |
| 102 | $nameElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 103 | $nameElt->setValue($fileName); |
| 104 | $nameElt->setUnit(".rdf"); |
| 105 | $this->form->addElement($nameElt); |
| 106 | |
| 107 | $instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS); |
| 108 | |
| 109 | $this->form->createGroup('options', '<h3>' . __('Export Metadata as RDF/XML file') . '</h3>', ['filename']); |
| 110 | } |
| 111 | } |