Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ImportForm | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 30 |
|
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 | namespace oat\taoDeliveryRdf\view\form\import; |
| 25 | |
| 26 | use oat\generis\Helper\SystemHelper; |
| 27 | use tao_helpers_form_FormFactory; |
| 28 | |
| 29 | /** |
| 30 | * Import form for RDF |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 34 | * @package taoItems |
| 35 | |
| 36 | */ |
| 37 | class ImportForm extends \tao_helpers_form_FormContainer |
| 38 | { |
| 39 | // --- ASSOCIATIONS --- |
| 40 | |
| 41 | |
| 42 | // --- ATTRIBUTES --- |
| 43 | |
| 44 | // --- OPERATIONS --- |
| 45 | /** |
| 46 | * Short description of method initForm |
| 47 | * |
| 48 | * @access public |
| 49 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 50 | * @return mixed |
| 51 | */ |
| 52 | public function initForm() |
| 53 | { |
| 54 | $this->form = new \tao_helpers_form_xhtml_Form('export'); |
| 55 | $submitElt = tao_helpers_form_FormFactory::getElement('import', 'Free'); |
| 56 | $submitElt->setValue( |
| 57 | '<a href="#" class="form-submitter btn-success small"><span class="icon-import"></span> ' |
| 58 | . __('Import') . '</a>' |
| 59 | ); |
| 60 | |
| 61 | $this->form->setActions([$submitElt], 'bottom'); |
| 62 | $this->form->setActions([], 'top'); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * overriden |
| 67 | * |
| 68 | * @access public |
| 69 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 70 | * @return mixed |
| 71 | */ |
| 72 | public function initElements() |
| 73 | { |
| 74 | |
| 75 | $descElt = tao_helpers_form_FormFactory::getElement('rdf_desc', 'Label'); |
| 76 | $descElt->setValue(__('Please upload a published delivery assembly .')); |
| 77 | $this->form->addElement($descElt); |
| 78 | |
| 79 | //create file upload form box |
| 80 | $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); |
| 81 | $fileElt->setDescription(__("Add the source file.")); |
| 82 | if (isset($_POST['import_sent_rdf'])) { |
| 83 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 84 | } else { |
| 85 | $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', ['message' => ''])); |
| 86 | } |
| 87 | $fileElt->addValidators([ |
| 88 | tao_helpers_form_FormFactory::getValidator( |
| 89 | 'FileMimeType', |
| 90 | [ |
| 91 | 'mimetype' => [ |
| 92 | 'application/zip', |
| 93 | 'application/x-zip', |
| 94 | 'application/x-zip-compressed', |
| 95 | 'application/octet-stream', |
| 96 | ], |
| 97 | 'extension' => [ |
| 98 | 'zip', |
| 99 | ], |
| 100 | ] |
| 101 | ), |
| 102 | tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) |
| 103 | ]); |
| 104 | |
| 105 | $this->form->addElement($fileElt); |
| 106 | $this->form->createGroup('file', __('Upload an assembly'), ['rdf_desc', 'source']); |
| 107 | |
| 108 | $rdfSentElt = tao_helpers_form_FormFactory::getElement('import_sent_rdf', 'Hidden'); |
| 109 | $rdfSentElt->setValue(1); |
| 110 | $this->form->addElement($rdfSentElt); |
| 111 | } |
| 112 | } |