Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ExportForm | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
42 | |||
| 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 (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoDeliveryRdf\view\form\export; |
| 23 | |
| 24 | /** |
| 25 | * Export form for assemblies |
| 26 | * |
| 27 | * @access public |
| 28 | * @author Joel Bout, <joel.bout@tudor.lu> |
| 29 | * @package taoDelivery |
| 30 | */ |
| 31 | class ExportForm extends \tao_helpers_form_FormContainer |
| 32 | { |
| 33 | /** |
| 34 | * (non-PHPdoc) |
| 35 | * @see tao_helpers_form_FormContainer::initForm() |
| 36 | */ |
| 37 | public function initForm() |
| 38 | { |
| 39 | $this->form = new \tao_helpers_form_xhtml_Form('export'); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * (non-PHPdoc) |
| 44 | * @see tao_helpers_form_FormContainer::initElements() |
| 45 | */ |
| 46 | public function initElements() |
| 47 | { |
| 48 | |
| 49 | $fileName = ''; |
| 50 | $instances = []; |
| 51 | if (isset($this->data['instance'])) { |
| 52 | $instance = $this->data['instance']; |
| 53 | if ($instance instanceof \core_kernel_classes_Resource) { |
| 54 | $instances[$instance->getUri()] = $instance->getLabel(); |
| 55 | } |
| 56 | } elseif (isset($this->data['class'])) { |
| 57 | $class = $this->data['class']; |
| 58 | if ($class instanceof \core_kernel_classes_Class) { |
| 59 | foreach ($class->getInstances() as $instance) { |
| 60 | $instances[$instance->getUri()] = $instance->getLabel(); |
| 61 | } |
| 62 | } |
| 63 | } else { |
| 64 | throw new \common_Exception('No class nor instance specified for export'); |
| 65 | } |
| 66 | $instances = \tao_helpers_Uri::encodeArray($instances, \tao_helpers_Uri::ENCODE_ARRAY_KEYS); |
| 67 | |
| 68 | $descElt = \tao_helpers_form_FormFactory::getElement('desc', 'Label'); |
| 69 | $descElt->setValue(__('Enables you to export a published delivery')); |
| 70 | $this->form->addElement($descElt); |
| 71 | |
| 72 | $instanceElt = \tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox'); |
| 73 | $instanceElt->setDescription(__('Delivery')); |
| 74 | $instanceElt->setAttribute('checkAll', true); |
| 75 | $instanceElt->setOptions($instances); |
| 76 | $instanceElt->setValue(current(array_keys($instances))); |
| 77 | |
| 78 | $this->form->addElement($instanceElt); |
| 79 | |
| 80 | |
| 81 | $this->form->createGroup('options', __('Export Options'), ['desc', 'exportInstance']); |
| 82 | } |
| 83 | } |