ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMD.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
32include_once 'class.ilMDBase.php';
33
34class ilMD extends ilMDBase
35{
36 /*
37 * meta elements
38 *
39 */
40
41 public function &getGeneral()
42 {
43 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDGeneral.php';
44
45 if ($id = ilMDGeneral::_getId($this->getRBACId(), $this->getObjId())) {
46 $gen = new ilMDGeneral();
47 $gen->setMetaId($id);
48
49 return $gen;
50 }
51 return false;
52 }
53 public function &addGeneral()
54 {
55 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDGeneral.php';
56
57 $gen = new ilMDGeneral($this->getRBACId(), $this->getObjId(), $this->getObjType());
58
59 return $gen;
60 }
61
62
63 public function &getLifecycle()
64 {
65 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLifecycle.php';
66
67 if ($id = ilMDLifecycle::_getId($this->getRBACId(), $this->getObjId())) {
68 $lif = new ilMDLifecycle();
69 $lif->setMetaId($id);
70
71 return $lif;
72 }
73 return false;
74 }
75 public function &addLifecycle()
76 {
77 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLifecycle.php';
78
79 $lif = new ilMDLifecycle($this->getRBACId(), $this->getObjId(), $this->getObjType());
80
81 return $lif;
82 }
83
84 public function &getMetaMetadata()
85 {
86 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDMetaMetadata.php';
87
88 if ($id = ilMDMetaMetadata::_getId($this->getRBACId(), $this->getObjId())) {
89 $met = new ilMDMetaMetadata();
90 $met->setMetaId($id);
91
92 return $met;
93 }
94 return false;
95 }
96 public function &addMetaMetadata()
97 {
98 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDMetaMetadata.php';
99
100 $met = new ilMDMetaMetadata($this->getRBACId(), $this->getObjId(), $this->getObjType());
101
102 return $met;
103 }
104
105 public function &getTechnical()
106 {
107 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTechnical.php';
108
109 if ($id = ilMDTechnical::_getId($this->getRBACId(), $this->getObjId())) {
110 $tec = new ilMDTechnical();
111 $tec->setMetaId($id);
112
113 return $tec;
114 }
115 return false;
116 }
117 public function &addTechnical()
118 {
119 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTechnical.php';
120
121 $tec = new ilMDTechnical($this->getRBACId(), $this->getObjId(), $this->getObjType());
122
123 return $tec;
124 }
125
126 public function &getEducational()
127 {
128 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDEducational.php';
129
130 if ($id = ilMDEducational::_getId($this->getRBACId(), $this->getObjId())) {
131 $edu = new ilMDEducational();
132 $edu->setMetaId($id);
133
134 return $edu;
135 }
136 return false;
137 }
138 public function &addEducational()
139 {
140 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDEducational.php';
141
142 $edu = new ilMDEducational($this->getRBACId(), $this->getObjId(), $this->getObjType());
143
144 return $edu;
145 }
146 public function &getRights()
147 {
148 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRights.php';
149
150 if ($id = ilMDRights::_getId($this->getRBACId(), $this->getObjId())) {
151 $rig = new ilMDRights();
152 $rig->setMetaId($id);
153
154 return $rig;
155 }
156 return false;
157 }
158 public function &addRights()
159 {
160 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRights.php';
161
162 $rig = new ilMDRights($this->getRBACId(), $this->getObjId(), $this->getObjType());
163
164 return $rig;
165 }
166
167 public function &getRelationIds()
168 {
169 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
170
171 return ilMDRelation::_getIds($this->getRBACId(), $this->getObjId());
172 }
173 public function &getRelation($a_relation_id)
174 {
175 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
176
177 if (!$a_relation_id) {
178 return false;
179 }
180
181 $rel = new ilMDRelation();
182 $rel->setMetaId($a_relation_id);
183
184 return $rel;
185 }
186 public function &addRelation()
187 {
188 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
189
190 $rel = new ilMDRelation($this->getRBACId(), $this->getObjId(), $this->getObjType());
191
192 return $rel;
193 }
194
195
196 public function &getAnnotationIds()
197 {
198 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
199
200 return ilMDAnnotation::_getIds($this->getRBACId(), $this->getObjId());
201 }
202 public function &getAnnotation($a_annotation_id)
203 {
204 if (!$a_annotation_id) {
205 return false;
206 }
207 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
208
209 $ann = new ilMDAnnotation();
210 $ann->setMetaId($a_annotation_id);
211
212 return $ann;
213 }
214 public function &addAnnotation()
215 {
216 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
217
218 $ann = new ilMDAnnotation($this->getRBACId(), $this->getObjId(), $this->getObjType());
219
220 return $ann;
221 }
222
223 public function &getClassificationIds()
224 {
225 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
226
227 return ilMDClassification::_getIds($this->getRBACId(), $this->getObjId());
228 }
229 public function &getClassification($a_classification_id)
230 {
231 if (!$a_classification_id) {
232 return false;
233 }
234
235 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
236
237 $cla = new ilMDClassification();
238 $cla->setMetaId($a_classification_id);
239
240 return $cla;
241 }
242 public function &addClassification()
243 {
244 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
245
246 $cla = new ilMDClassification($this->getRBACId(), $this->getObjId(), $this->getObjType());
247
248 return $cla;
249 }
250
251 /*
252 * XML Export of all meta data
253 * @param object (xml writer) see class.ilMD2XML.php
254 *
255 */
256 public function toXML(&$writer)
257 {
258 $writer->xmlStartTag('Migration/DBUpdate_426');
259
260 // General
261 if (is_object($gen = &$this->getGeneral())) {
262 $gen->toXML($writer);
263 }
264
265 // Lifecycle
266 if (is_object($lif = &$this->getLifecycle())) {
267 $lif->toXML($writer);
268 }
269
270 // Meta-Metadata
271 if (is_object($met = &$this->getMetaMetadata())) {
272 $met->toXML($writer);
273 }
274
275 // Technical
276 if (is_object($tec = &$this->getTechnical())) {
277 $tec->toXML($writer);
278 }
279
280 // Educational
281 if (is_object($edu = &$this->getEducational())) {
282 $edu->toXML($writer);
283 }
284
285 // Rights
286 if (is_object($rig = &$this->getRights())) {
287 $rig->toXML($writer);
288 }
289
290 // Relations
291 foreach ($this->getRelationIds() as $id) {
292 $rel = &$this->getRelation($id);
293 $rel->toXML($writer);
294 }
295
296 // Annotations
297 foreach ($this->getAnnotationIds() as $id) {
298 $ann = &$this->getAnnotation($id);
299 $ann->toXML($writer);
300 }
301
302 // Classification
303 foreach ($this->getClassificationIds() as $id) {
304 $cla = &$this->getClassification($id);
305 $cla->toXML($writer);
306 }
307
308 $writer->xmlEndTag('Migration/DBUpdate_426');
309 }
310
311 public function deleteAll()
312 {
313 global $ilDB;
314
315 $tables = array('il_meta_annotation',
316 'il_meta_classification',
317 'il_meta_contribute',
318 'il_meta_description',
319 'il_meta_educational',
320 'il_meta_entity',
321 'il_meta_format',
322 'il_meta_general',
323 'il_meta_identifier',
324 'il_meta_identifier_',
325 'il_meta_keyword',
326 'il_meta_language',
327 'il_meta_lifecycle',
328 'il_meta_location',
329 'il_meta_meta_data',
330 'il_meta_relation',
331 'il_meta_requirement',
332 'il_meta_rights',
333 'il_meta_taxon',
334 'il_meta_taxon_path',
335 'il_meta_technical',
336 'il_meta_typical_age_range');
337
338 foreach ($tables as $table) {
339 $query = "DELETE FROM " . $table . " " .
340 "WHERE rbac_id = " . $ilDB->quote($this->getRBACId()) . " " .
341 "AND obj_id = " . $ilDB->quote($this->getObjId());
342 $res = $ilDB->query($query);
343 }
344
345 return true;
346 }
347 public function _deleteAllByType($a_type)
348 {
349 global $ilDB;
350
351 $tables = array('il_meta_annotation',
352 'il_meta_classification',
353 'il_meta_contribute',
354 'il_meta_description',
355 'il_meta_educational',
356 'il_meta_entity',
357 'il_meta_format',
358 'il_meta_general',
359 'il_meta_identifier',
360 'il_meta_identifier_',
361 'il_meta_keyword',
362 'il_meta_language',
363 'il_meta_lifecycle',
364 'il_meta_location',
365 'il_meta_meta_data',
366 'il_meta_relation',
367 'il_meta_requirement',
368 'il_meta_rights',
369 'il_meta_taxon',
370 'il_meta_taxon_path',
371 'il_meta_technical',
372 'il_meta_typical_age_range');
373
374 foreach ($tables as $table) {
375 $query = "DELETE FROM " . $table . " " .
376 "WHERE obj_type = " . $ilDB->quote($a_type) . " ";
377 $res = $ilDB->query($query);
378 }
379
380 return true;
381 }
382}
An exception for terminatinating execution or to throw for unit testing.
static _getIds($a_rbac_id, $a_obj_id)
static _getIds($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getIds($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
& getLifecycle()
Definition: class.ilMD.php:63
& addAnnotation()
Definition: class.ilMD.php:214
toXML(&$writer)
Definition: class.ilMD.php:256
& addClassification()
Definition: class.ilMD.php:242
& addEducational()
Definition: class.ilMD.php:138
& getAnnotationIds()
Definition: class.ilMD.php:196
& getRelationIds()
Definition: class.ilMD.php:167
& addRights()
Definition: class.ilMD.php:158
& getClassificationIds()
Definition: class.ilMD.php:223
& addGeneral()
Definition: class.ilMD.php:53
& getGeneral()
Definition: class.ilMD.php:41
& getClassification($a_classification_id)
Definition: class.ilMD.php:229
& addTechnical()
Definition: class.ilMD.php:117
& addMetaMetadata()
Definition: class.ilMD.php:96
_deleteAllByType($a_type)
Definition: class.ilMD.php:347
& addLifecycle()
Definition: class.ilMD.php:75
& getEducational()
Definition: class.ilMD.php:126
& getRights()
Definition: class.ilMD.php:146
& getTechnical()
Definition: class.ilMD.php:105
deleteAll()
Definition: class.ilMD.php:311
& getMetaMetadata()
Definition: class.ilMD.php:84
& addRelation()
Definition: class.ilMD.php:186
& getRelation($a_relation_id)
Definition: class.ilMD.php:173
& getAnnotation($a_annotation_id)
Definition: class.ilMD.php:202
$query
foreach($_POST as $key=> $value) $res
global $ilDB