Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_models_classes_import_RdfImportForm | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 17 |
|
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-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | use oat\generis\Helper\SystemHelper; |
| 26 | |
| 27 | /** |
| 28 | * Import form for RDF |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 32 | */ |
| 33 | class tao_models_classes_import_RdfImportForm extends tao_helpers_form_FormContainer |
| 34 | { |
| 35 | // --- ASSOCIATIONS --- |
| 36 | |
| 37 | |
| 38 | // --- ATTRIBUTES --- |
| 39 | |
| 40 | // --- OPERATIONS --- |
| 41 | /** |
| 42 | * Short description of method initForm |
| 43 | * |
| 44 | * @access public |
| 45 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 46 | * @return mixed |
| 47 | */ |
| 48 | public function initForm() |
| 49 | { |
| 50 | $this->form = new tao_helpers_form_xhtml_Form('export'); |
| 51 | $submitElt = tao_helpers_form_FormFactory::getElement('import', 'Free'); |
| 52 | $submitElt->setValue( |
| 53 | '<a href="#" class="form-submitter btn-success small"><span class="icon-import"></span> ' |
| 54 | . __('Import') . '</a>' |
| 55 | ); |
| 56 | |
| 57 | $this->form->setActions([$submitElt], 'bottom'); |
| 58 | $this->form->setActions([], 'top'); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * overriden |
| 63 | * |
| 64 | * @access public |
| 65 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 66 | * @return mixed |
| 67 | */ |
| 68 | public function initElements() |
| 69 | { |
| 70 | //create file upload form box |
| 71 | $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); |
| 72 | $fileElt->setDescription(__("Add an RDF/XML file")); |
| 73 | if (isset($_POST['import_sent_rdf'])) { |
| 74 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 75 | } else { |
| 76 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', ['message' => ''])); |
| 77 | } |
| 78 | $fileElt->addValidators([ |
| 79 | tao_helpers_form_FormFactory::getValidator( |
| 80 | 'FileMimeType', |
| 81 | ['mimetype' => ['text/xml', 'application/rdf+xml', 'application/xml'], 'extension' => ['rdf', 'rdfs']] |
| 82 | ), |
| 83 | tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) |
| 84 | ]); |
| 85 | |
| 86 | $this->form->addElement($fileElt); |
| 87 | $this->form->createGroup('file', __('Import Metadata from RDF file'), ['source']); |
| 88 | |
| 89 | $rdfSentElt = tao_helpers_form_FormFactory::getElement('import_sent_rdf', 'Hidden'); |
| 90 | $rdfSentElt->setValue(1); |
| 91 | $this->form->addElement($rdfSentElt); |
| 92 | } |
| 93 | } |