ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionRecordViewViewdefinition.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/COPage/classes/class.ilPageObject.php");
6
19
23 protected $active = false;
27 protected $table_id;
31 protected $type = 0; // [int] 0 = recordview
35 protected $formtype = 0; // [int] 0 = copage
39 protected static $record_view_cache = array();
43 protected static $instances = array();
44
45
51 public static function getInstance($key) {
52 self::$instances[$key] = new self($key);
53
54 return self::$instances[$key];
55 }
56
57
63 public function removeDclView($table_id) {
64 if (! $table_id) {
65 return false;
66 }
67 global $ilDB;
68
69 $query = "DELETE FROM il_dcl_view WHERE table_id = " . $table_id . " AND type = " . $ilDB->quote(0, "integer") . " AND formtype = "
70 . $ilDB->quote(0, "integer");
71 $ilDB->manipulate($query);
72
73 return true;
74 }
75
76
82 function getParentType() {
83 return "dclf";
84 }
85
86
92 public function setTableId($a_id) {
93 $this->table_id = $a_id;
94 }
95
96
102 public function getTableId() {
103 return $this->table_id;
104 }
105
106
112 public function getType() {
113 return $this->type;
114 }
115
116
122 public function getFormtype() {
123 return $this->formtype;
124 }
125
126
130 public function doRead() {
131 global $ilDB;
132
133 $query = "SELECT * FROM il_dcl_view WHERE table_id = " . $ilDB->quote($this->getId(), "integer");
134 $set = $ilDB->query($query);
135 $rec = $ilDB->fetchAssoc($set);
136
137 $this->setActive(false);
138
139 $this->setTableId($rec["table_id"]);
140 $this->type = $rec["type"];
141 $this->formtype = $rec["formtype"];
142 }
143
144
148 public function create($prevent_page_creation = false) {
149 global $ilDB;
150 $this->setActive(false);
151 $id = $ilDB->nextId("il_dcl_view");
152 $this->setId($id);
153
154 $query = "INSERT INTO il_dcl_view (" . "id" . ", table_id" . ", type" . ", formtype" . " ) VALUES (" . $ilDB->quote($this->getId(), "integer")
155 . "," . $ilDB->quote($this->getTableId(), "integer") . "," . $ilDB->quote($this->getType(), "integer") . ","
156 . $ilDB->quote($this->getFormtype(), "integer") . ")";
157 $ilDB->manipulate($query);
158
159 if (! $prevent_page_creation) {
160 parent::create();
161 }
162 }
163
164
173 public function update($a_validate = true, $a_no_history = false) {
174 //TODO
175 //Page-Object updaten
176 //Es wäre auch möglich direkt in der GUI-Klasse ilPageObject aufzurufen. Falls wir aber bei doCreate,
177 //das Page-Object anlegen, fänd ich es sinnvoll, wenn wir auch hier das PageObject updaten würden.
178 //Andernfalls sämtliche Page-Object-Methoden in der GUI-Klasse aufrufen.
179
180 parent::update($a_validate, $a_no_history);
181
182 return true;
183 }
184
185
195 public static function getIdByTableId($a_table_id) {
196 if (! isset(self::$record_view_cache[$a_table_id])) {
197 global $ilDB;
198 //FIXME die werte bei type und formtype sollten vom constructor genommen werden
199 $query = "SELECT id FROM il_dcl_view" . " WHERE table_id = " . $ilDB->quote($a_table_id, "integer") . " AND type = "
200 . $ilDB->quote(0, "integer") . " and formtype = " . $ilDB->quote(0, "integer");
201 $set = $ilDB->query($query);
202 $row = $ilDB->fetchObject($set);
203
204 self::$record_view_cache[$a_table_id] = $row->id;
205 }
206
207 return self::$record_view_cache[$a_table_id];
208 }
209
210
216 public static function getInstanceByTableId($table_id) {
218
219 return self::getInstance($id);
220 }
221
222
231 public static function getAvailablePlaceholders($a_table_id, $a_verbose = false) {
232 $all = array();
233
234 require_once("./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
235 $objTable = ilDataCollectionCache::getTableCache($a_table_id);
236 $fields = $objTable->getRecordFields();
237 $standardFields = $objTable->getStandardFields();
238
239 foreach ($fields as $field) {
240
241 if (! $a_verbose) {
242 $all[] = "[" . $field->getTitle() . "]";
243
244 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
245 $all[] = '[dclrefln field="' . $field->getTitle() . '"][/dclrefln]';
246 }
247 // SW 14.10.2015 http://www.ilias.de/mantis/view.php?id=16874
248 // if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF) {
249 // $all[] = '[dcliln field="' . $field->getTitle() . '"][/dcliln]';
250 // }
251 } else {
252 $all["[" . $field->getTitle() . "]"] = $field;
253
254 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
255 $all['[dclrefln field="' . $field->getTitle() . '"][/dclrefln]'] = $field;
256 }
257 // SW: 14.10.2015 http://www.ilias.de/mantis/view.php?id=16874
258 // if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF) {
259 // $all['[dcliln field="' . $field->getTitle() . '"][/dcliln]'] = $field;
260 // }
261 }
262 }
263
264 foreach ($standardFields as $field) {
265 $all[] = "[" . $field->getId() . "]";
266 }
267
268 return $all;
269 }
270}
271
272?>
update($a_validate=true, $a_no_history=false)
Update Viewdefinition.
static getAvailablePlaceholders($a_table_id, $a_verbose=false)
Get all placeholders for table id.
create($prevent_page_creation=false)
Create new Viewdefinition.
static getIdByTableId($a_table_id)
Get view definition id by table id.
Class ilPageObject.
setActive($a_active)
set activation
setId($a_id)
set id
global $ilDB