Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Model | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| getOptions | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
30 | |||
| 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) 2015 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\helpers\form\elements; |
| 23 | |
| 24 | use oat\tao\model\TaoOntology; |
| 25 | use tao_helpers_form_elements_MultipleElement; |
| 26 | use core_kernel_classes_Property; |
| 27 | use core_kernel_classes_Resource; |
| 28 | use tao_helpers_Uri; |
| 29 | |
| 30 | /** |
| 31 | * Implementation model selector |
| 32 | * |
| 33 | * @abstract |
| 34 | * @package tao |
| 35 | */ |
| 36 | abstract class Model extends tao_helpers_form_elements_MultipleElement |
| 37 | { |
| 38 | public const WIDGET_ID = 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#ModelSelector'; |
| 39 | |
| 40 | /** |
| 41 | * (non-PHPdoc) |
| 42 | * @see tao_helpers_form_elements_MultipleElement::getOptions() |
| 43 | */ |
| 44 | public function getOptions() |
| 45 | { |
| 46 | $statusProperty = new core_kernel_classes_Property(TaoOntology::PROPERTY_ABSTRACT_MODEL_STATUS); |
| 47 | $current = $this->getEvaluatedValue(); |
| 48 | |
| 49 | $options = []; |
| 50 | foreach (parent::getOptions() as $optUri => $optLabel) { |
| 51 | $model = new core_kernel_classes_Resource(tao_helpers_Uri::decode($optUri)); |
| 52 | $status = $model->getOnePropertyValue($statusProperty); |
| 53 | if (!is_null($status)) { |
| 54 | $options[$optUri] = $optLabel; |
| 55 | } elseif ($model->getUri() == $current) { |
| 56 | $options[$optUri] = $optLabel . ' (' . (is_null($status) ? __('unknown') : $status->getLabel()) . ')'; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return $options; |
| 61 | } |
| 62 | } |