Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ZipExportForm | |
0.00% |
0 / 33 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 14 |
|
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) 2014 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoMediaManager\model; |
| 24 | |
| 25 | /** |
| 26 | * Service methods to manage the Media |
| 27 | * |
| 28 | * @access public |
| 29 | * @author Antoine Robin, <antoine.robin@vesperiagroup.com> |
| 30 | * @package taoMediaManager |
| 31 | */ |
| 32 | class ZipExportForm extends \tao_helpers_form_FormContainer |
| 33 | { |
| 34 | public function initForm() |
| 35 | { |
| 36 | |
| 37 | |
| 38 | $this->form = new \tao_helpers_form_xhtml_Form('export'); |
| 39 | |
| 40 | $this->form->setDecorators([ |
| 41 | 'element' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), |
| 42 | 'group' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-group']), |
| 43 | 'error' => new \tao_helpers_form_xhtml_TagWrapper([ |
| 44 | 'tag' => 'div', |
| 45 | 'cssClass' => 'form-error ui-state-error ui-corner-all', |
| 46 | ]), |
| 47 | 'actions-bottom' => new \tao_helpers_form_xhtml_TagWrapper([ |
| 48 | 'tag' => 'div', |
| 49 | 'cssClass' => 'form-toolbar', |
| 50 | ]), |
| 51 | ]); |
| 52 | |
| 53 | $exportElt = \tao_helpers_form_FormFactory::getElement('export', 'Free'); |
| 54 | $exportElt->setValue( |
| 55 | '<a href="#" class="form-submitter btn-success small"><span class="icon-export"></span> ' |
| 56 | . __('Export') . '</a>' |
| 57 | ); |
| 58 | |
| 59 | $this->form->setActions([$exportElt], 'bottom'); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | public function initElements() |
| 64 | { |
| 65 | if (isset($this->data['resource'])) { |
| 66 | $resource = $this->data['resource']; |
| 67 | } else { |
| 68 | throw new \common_Exception('No class nor instance specified for export'); |
| 69 | } |
| 70 | |
| 71 | $fileName = strtolower(\tao_helpers_Display::textCleaner($resource->getLabel(), '*')); |
| 72 | |
| 73 | $hiddenElt = \tao_helpers_form_FormFactory::getElement('resource', 'Hidden'); |
| 74 | $hiddenElt->setValue($resource->getUri()); |
| 75 | $this->form->addElement($hiddenElt); |
| 76 | |
| 77 | |
| 78 | $nameElt = \tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); |
| 79 | $nameElt->setDescription(__('File name')); |
| 80 | $nameElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 81 | $nameElt->setValue($fileName); |
| 82 | $nameElt->setUnit(".zip"); |
| 83 | $this->form->addElement($nameElt); |
| 84 | |
| 85 | $this->form->createGroup('options', __('Export Media as Zip file'), ['filename']); |
| 86 | } |
| 87 | } |