Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
tao_actions_form_AbstractProperty | |
0.00% |
0 / 31 |
|
0.00% |
0 / 6 |
182 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getPropertyInstance | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
initForm | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
isParentProperty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
getGroupTitle | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
20 | |||
getIndex | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | use oat\generis\model\OntologyAwareTrait; |
4 | |
5 | /** |
6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License |
8 | * as published by the Free Software Foundation; under version 2 |
9 | * of the License (non-upgradable). |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | * |
20 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
21 | * (under the project TAO-TRANSFER); |
22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
24 | * |
25 | */ |
26 | |
27 | abstract class tao_actions_form_AbstractProperty extends tao_helpers_form_FormContainer |
28 | { |
29 | use OntologyAwareTrait; |
30 | |
31 | /** |
32 | * @var core_kernel_classes_Property |
33 | */ |
34 | protected $property; |
35 | |
36 | /** |
37 | * @var integer |
38 | */ |
39 | protected $index; |
40 | |
41 | public function __construct( |
42 | core_kernel_classes_Class $clazz, |
43 | core_kernel_classes_Resource $instance = null, |
44 | $options = [], |
45 | $data = [] |
46 | ) { |
47 | $this->property = $this->getProperty($instance); |
48 | return parent::__construct($data, $options); |
49 | } |
50 | |
51 | /** |
52 | * Property bein authored |
53 | * |
54 | * @return core_kernel_classes_Property |
55 | */ |
56 | protected function getPropertyInstance() |
57 | { |
58 | return $this->property; |
59 | } |
60 | |
61 | /** |
62 | * Initialize the form |
63 | * |
64 | * @access protected |
65 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
66 | * @return mixed |
67 | */ |
68 | protected function initForm() |
69 | { |
70 | |
71 | |
72 | (isset($this->options['name'])) ? $name = $this->options['name'] : $name = ''; |
73 | if (empty($name)) { |
74 | $name = 'form_' . (count(self::$forms) + 1); |
75 | } |
76 | unset($this->options['name']); |
77 | |
78 | $this->index = array_key_exists('index', $this->options) ? $this->options['index'] : 1; |
79 | |
80 | $this->form = tao_helpers_form_FormFactory::getForm($name, $this->options); |
81 | } |
82 | |
83 | /** |
84 | * Returns if property is inherited or not for class |
85 | * @return bool |
86 | */ |
87 | protected function isParentProperty() |
88 | { |
89 | return isset($this->options['isParentProperty']) && $this->options['isParentProperty']; |
90 | } |
91 | |
92 | /** |
93 | * Returns html for property |
94 | * @param $property |
95 | * @return string |
96 | */ |
97 | protected function getGroupTitle($property) |
98 | { |
99 | $setupIndexIcon = $this->options['disableIndexChanges'] ? '' : ' <span class="icon-find"></span>'; |
100 | |
101 | if ($this->isParentProperty()) { |
102 | foreach ($property->getDomain()->getIterator() as $domain) { |
103 | $domainLabel[] = $domain->getLabel(); |
104 | } |
105 | |
106 | $groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>' |
107 | . '<span class="property-heading-toolbar">' |
108 | . _dh(implode(' ', $domainLabel)) |
109 | . $setupIndexIcon |
110 | . ' <span class="icon-edit"></span>' |
111 | . '</span>'; |
112 | } else { |
113 | $groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>' |
114 | . '<span class="property-heading-toolbar">' |
115 | . $setupIndexIcon |
116 | . '<span class="icon-edit"></span>' |
117 | . '<span class="icon-bin property-deleter" data-uri=\'' |
118 | . tao_helpers_Display::encodeAttrValue($property->getUri()) . '\'></span>' |
119 | . '</span>'; |
120 | } |
121 | return $groupTitle; |
122 | } |
123 | |
124 | /** |
125 | * @return int |
126 | */ |
127 | protected function getIndex() |
128 | { |
129 | return $this->index; |
130 | } |
131 | } |