ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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;
24
28 protected $table_id;
32 protected $type = 0; // [int] 0 = recordview
36 protected $formtype = 0; // [int] 0 = copage
40 protected static $record_view_cache = array();
44 protected static $instances = array();
45
46
52 public static function getInstance($key) {
53 // if (!isset(self::$instances[$key])) {
54// var_dump($key); // FSX
55 self::$instances[$key] = new self($key);
56
57 // }
58
59 return self::$instances[$key];
60 }
61
62
68 function getParentType() {
69 return "dclf";
70 }
71
72
78 public function setTableId($a_id) {
79 $this->table_id = $a_id;
80 }
81
82
88 public function getTableId() {
89 return $this->table_id;
90 }
91
92
98 public function getType() {
99 return $this->type;
100 }
101
102
108 public function getFormtype() {
109 return $this->formtype;
110 }
111
112
116 public function doRead() {
117 global $ilDB;
118
119 $query = "SELECT * FROM il_dcl_view WHERE table_id = " . $ilDB->quote($this->getId(), "integer");
120 $set = $ilDB->query($query);
121 $rec = $ilDB->fetchAssoc($set);
122
123 $this->setActive(false);
124
125 $this->setTableId($rec["table_id"]);
126 $this->type = $rec["type"];
127 $this->formtype = $rec["formtype"];
128 }
129
130
134 public function create($prevent_page_creation = false) {
135 global $ilDB;
136 $this->setActive(false);
137 $id = $ilDB->nextId("il_dcl_view");
138 $this->setId($id);
139
140 $query = "INSERT INTO il_dcl_view (" . "id" . ", table_id" . ", type" . ", formtype" . " ) VALUES (" . $ilDB->quote($this->getId(), "integer")
141 . "," . $ilDB->quote($this->getTableId(), "integer") . "," . $ilDB->quote($this->getType(), "integer") . ","
142 . $ilDB->quote($this->getFormtype(), "integer") . ")";
143 $ilDB->manipulate($query);
144
145 if (!$prevent_page_creation) {
146 parent::create();
147 }
148 }
149
150
159 public function update($a_validate = true, $a_no_history = false) {
160 //TODO
161 //Page-Object updaten
162 //Es wäre auch möglich direkt in der GUI-Klasse ilPageObject aufzurufen. Falls wir aber bei doCreate,
163 //das Page-Object anlegen, fänd ich es sinnvoll, wenn wir auch hier das PageObject updaten würden.
164 //Andernfalls sämtliche Page-Object-Methoden in der GUI-Klasse aufrufen.
165
166 parent::update($a_validate, $a_no_history);
167
168 return true;
169 }
170
171
181 public static function getIdByTableId($a_table_id) {
182 if (!isset(self::$record_view_cache[$a_table_id])) {
183 global $ilDB;
184 //FIXME die werte bei type und formtype sollten vom constructor genommen werden
185 $set = $ilDB->query("SELECT id FROM il_dcl_view" . " WHERE table_id = " . $ilDB->quote($a_table_id, "integer") . " AND type = "
186 . $ilDB->quote(0, "integer") . " and formtype = " . $ilDB->quote(0, "integer"));
187 $row = $ilDB->fetchObject($set);
188
189 self::$record_view_cache[$a_table_id] = $row->id;
190 }
191
192 return self::$record_view_cache[$a_table_id];
193 }
194
195
201 public static function getInstanceByTableId($table_id) {
203
204 return self::getInstance($id);
205 }
206
207
216 public static function getAvailablePlaceholders($a_table_id, $a_verbose = false) {
217 $all = array();
218
219 require_once("./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
220 $objTable = ilDataCollectionCache::getTableCache($a_table_id);
221 $fields = $objTable->getRecordFields();
222 $standardFields = $objTable->getStandardFields();
223
224 foreach ($fields as $field) {
225
226 if (!$a_verbose) {
227 $all[] = "[" . $field->getTitle() . "]";
228
229 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
230 $all[] = '[dclrefln field="' . $field->getTitle() . '"][/dclrefln]';
231 }
232
233 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF) {
234 $all[] = '[dcliln field="' . $field->getTitle() . '"][/dcliln]';
235 }
236 } else {
237 $all["[" . $field->getTitle() . "]"] = $field;
238
239 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
240 $all['[dclrefln field="' . $field->getTitle() . '"][/dclrefln]'] = $field;
241 }
242
243 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF) {
244 $all['[dcliln field="' . $field->getTitle() . '"][/dcliln]'] = $field;
245 }
246 }
247 }
248
249 foreach ($standardFields as $field) {
250 $all[] = "[" . $field->getId() . "]";
251 }
252
253 return $all;
254 }
255}
256
257?>
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