ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.arViewFields.php
Go to the documentation of this file.
1<?php
2include_once('./Services/ActiveRecord/Fields/class.arField.php');
3include_once('./Services/ActiveRecord/Views/class.arViewField.php');
4
13
14 const FIELD_CLASS = 'arViewField';
18 protected $fields = array();
22 protected $fields_for_display = NULL;
26 protected $active_record = NULL;
30 protected $txt_prefix = "";
34 protected $created_by_field = NULL;
38 protected $modified_by_field = NULL;
42 protected $creation_date_field = NULL;
46 protected $modification_date_field = NULL;
47
48
52 public function __construct(ActiveRecord $ar) {
53 $this->active_record = $ar;
54 $this->generateFields();
55 }
56
57
61 protected function generateFields() {
62 $fields = $this->active_record->getArFieldList()->getFields();
63 foreach ($fields as $standard_field) {
64 $current_class = get_called_class();
65 $field_class = $current_class::FIELD_CLASS;
69 $field = $field_class::castFromFieldToViewField($standard_field);
70 $this->addField($field);
71 }
72
73 return true;
74 }
75
76
80 public function addField(arViewField $field) {
81 $this->fields[$field->getName()] = $field;
82 }
83
84
88 public function getFields() {
89 return $this->fields;
90 }
91
92
96 public function getPrimaryField() {
97 return $this->getField(arFieldCache::getPrimaryFieldName($this->active_record));
98 }
99
100
104 public function sortFields() {
105 uasort($this->fields, function (arViewField $field_a, arViewField $field_b) {
106 return $field_a->getPosition() > $field_b->getPosition();
107 });
108 }
109
110
114 public function getFieldsForDisplay() {
115 if (!$this->fields_for_display && $this->getFields()) {
116 foreach ($this->getFields() as $field) {
120 if (($field->getVisible() || $field->getPrimary())) {
121 $this->fields_for_display[] = $field;
122 }
123 }
124 }
125
127 }
128
129
135 public function getField($field_name) {
136 return $this->fields[$field_name];
137 }
138
139
143 public function setTxtPrefix($txt_prefix) {
144 $this->txt_prefix = $txt_prefix;
145 foreach ($this->getFields() as $field) {
146 $field->setTxtPrefix($txt_prefix);
147 }
148 }
149
150
154 public function getTxtPrefix() {
155 return $this->txt_prefix;
156 }
157
158
163 $created_by_field->setIsCreatedByField(true);
164 $this->created_by_field = $created_by_field;
165 }
166
167
171 public function getCreatedByField() {
172 if (!$this->created_by_field) {
173 foreach ($this->getFields() as $field) {
177 if ($field->getIsCreatedByField()) {
178 return $this->created_by_field = $field;
179 }
180 }
181 }
182
184 }
185
186
191 $creation_date_field->setIsCreationDateField(true);
192 $this->creation_date_field = $creation_date_field;
193 }
194
195
199 public function getCreationDateField() {
200 if (!$this->creation_date_field) {
201 foreach ($this->getFields() as $field) {
205 if ($field->getIsCreationDateField()) {
206 return $this->creation_date_field = $field;
207 }
208 }
209 }
210
212 }
213
214
219 $modification_date_field->setIsModificationDateField(true);
220 $this->modification_date_field = $modification_date_field;
221 }
222
223
227 public function getModificationDateField() {
228 if (!$this->modification_date_field) {
229 foreach ($this->getFields() as $field) {
233 if ($field->getIsModificationDateField()) {
234 return $this->modification_date_field = $field;
235 }
236 }
237 }
238
240 }
241
242
247 $modified_by_field->setIsModifiedByField(true);
248 $this->modified_by_field = $modified_by_field;
249 }
250
251
255 public function getModifiedByField() {
256 if (!$this->modified_by_field) {
257 foreach ($this->getFields() as $field) {
261 if ($field->getIsModifiedByField()) {
262 return $this->modified_by_field = $field;
263 }
264 }
265 }
266
268 }
269}
Class ActiveRecord.
static getPrimaryFieldName(ActiveRecord $ar)
GUI-Class arViewField.
GUI-Class arViewFields.
setCreatedByField($created_by_field)
setModificationDateField($modification_date_field)
setTxtPrefix($txt_prefix)
__construct(ActiveRecord $ar)
setCreationDateField($creation_date_field)
getField($field_name)
setModifiedByField($modified_by_field)
addField(arViewField $field)
$errors fields
Definition: imgupload.php:48