ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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 {
47 $gen = new ilMDGeneral();
48 $gen->setMetaId($id);
49
50 return $gen;
51 }
52 return false;
53 }
54 function &addGeneral()
55 {
56 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDGeneral.php';
57
58 $gen = new ilMDGeneral($this->getRBACId(),$this->getObjId(),$this->getObjType());
59
60 return $gen;
61 }
62
63
64 function &getLifecycle()
65 {
66 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLifecycle.php';
67
68 if($id = ilMDLifecycle::_getId($this->getRBACId(),$this->getObjId()))
69 {
70 $lif = new ilMDLifecycle();
71 $lif->setMetaId($id);
72
73 return $lif;
74 }
75 return false;
76 }
77 function &addLifecycle()
78 {
79 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLifecycle.php';
80
81 $lif = new ilMDLifecycle($this->getRBACId(),$this->getObjId(),$this->getObjType());
82
83 return $lif;
84 }
85
86 function &getMetaMetadata()
87 {
88 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDMetaMetadata.php';
89
90 if($id = ilMDMetaMetadata::_getId($this->getRBACId(),$this->getObjId()))
91 {
92 $met = new ilMDMetaMetadata();
93 $met->setMetaId($id);
94
95 return $met;
96 }
97 return false;
98 }
99 function &addMetaMetadata()
100 {
101 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDMetaMetadata.php';
102
103 $met = new ilMDMetaMetadata($this->getRBACId(),$this->getObjId(),$this->getObjType());
104
105 return $met;
106 }
107
108 function &getTechnical()
109 {
110 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTechnical.php';
111
112 if($id = ilMDTechnical::_getId($this->getRBACId(),$this->getObjId()))
113 {
114 $tec = new ilMDTechnical();
115 $tec->setMetaId($id);
116
117 return $tec;
118 }
119 return false;
120 }
121 function &addTechnical()
122 {
123 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTechnical.php';
124
125 $tec = new ilMDTechnical($this->getRBACId(),$this->getObjId(),$this->getObjType());
126
127 return $tec;
128 }
129
130 function &getEducational()
131 {
132 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDEducational.php';
133
134 if($id = ilMDEducational::_getId($this->getRBACId(),$this->getObjId()))
135 {
136 $edu = new ilMDEducational();
137 $edu->setMetaId($id);
138
139 return $edu;
140 }
141 return false;
142 }
143 function &addEducational()
144 {
145 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDEducational.php';
146
147 $edu = new ilMDEducational($this->getRBACId(),$this->getObjId(),$this->getObjType());
148
149 return $edu;
150 }
151 function &getRights()
152 {
153 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRights.php';
154
155 if($id = ilMDRights::_getId($this->getRBACId(),$this->getObjId()))
156 {
157 $rig = new ilMDRights();
158 $rig->setMetaId($id);
159
160 return $rig;
161 }
162 return false;
163 }
164 function &addRights()
165 {
166 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRights.php';
167
168 $rig = new ilMDRights($this->getRBACId(),$this->getObjId(),$this->getObjType());
169
170 return $rig;
171 }
172
173 function &getRelationIds()
174 {
175 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
176
177 return ilMDRelation::_getIds($this->getRBACId(),$this->getObjId());
178 }
179 function &getRelation($a_relation_id)
180 {
181 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
182
183 if(!$a_relation_id)
184 {
185 return false;
186 }
187
188 $rel = new ilMDRelation();
189 $rel->setMetaId($a_relation_id);
190
191 return $rel;
192 }
193 function &addRelation()
194 {
195 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRelation.php';
196
197 $rel = new ilMDRelation($this->getRBACId(),$this->getObjId(),$this->getObjType());
198
199 return $rel;
200 }
201
202
204 {
205 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
206
207 return ilMDAnnotation::_getIds($this->getRBACId(),$this->getObjId());
208 }
209 function &getAnnotation($a_annotation_id)
210 {
211 if(!$a_annotation_id)
212 {
213 return false;
214 }
215 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
216
217 $ann = new ilMDAnnotation();
218 $ann->setMetaId($a_annotation_id);
219
220 return $ann;
221 }
222 function &addAnnotation()
223 {
224 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDAnnotation.php';
225
226 $ann = new ilMDAnnotation($this->getRBACId(),$this->getObjId(),$this->getObjType());
227
228 return $ann;
229 }
230
232 {
233 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
234
235 return ilMDClassification::_getIds($this->getRBACId(),$this->getObjId());
236 }
237 function &getClassification($a_classification_id)
238 {
239 if(!$a_classification_id)
240 {
241 return false;
242 }
243
244 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
245
246 $cla = new ilMDClassification();
247 $cla->setMetaId($a_classification_id);
248
249 return $cla;
250 }
252 {
253 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDClassification.php';
254
255 $cla = new ilMDClassification($this->getRBACId(),$this->getObjId(),$this->getObjType());
256
257 return $cla;
258 }
259
260 /*
261 * XML Export of all meta data
262 * @param object (xml writer) see class.ilMD2XML.php
263 *
264 */
265 function toXML(&$writer)
266 {
267 $writer->xmlStartTag('Migration/DBUpdate_426');
268
269 // General
270 if(is_object($gen =& $this->getGeneral()))
271 {
272 $gen->toXML($writer);
273 }
274
275 // Lifecycle
276 if(is_object($lif =& $this->getLifecycle()))
277 {
278 $lif->toXML($writer);
279 }
280
281 // Meta-Metadata
282 if(is_object($met =& $this->getMetaMetadata()))
283 {
284 $met->toXML($writer);
285 }
286
287 // Technical
288 if(is_object($tec =& $this->getTechnical()))
289 {
290 $tec->toXML($writer);
291 }
292
293 // Educational
294 if(is_object($edu =& $this->getEducational()))
295 {
296 $edu->toXML($writer);
297 }
298
299 // Rights
300 if(is_object($rig =& $this->getRights()))
301 {
302 $rig->toXML($writer);
303 }
304
305 // Relations
306 foreach($this->getRelationIds() as $id)
307 {
308 $rel =& $this->getRelation($id);
309 $rel->toXML($writer);
310 }
311
312 // Annotations
313 foreach($this->getAnnotationIds() as $id)
314 {
315 $ann =& $this->getAnnotation($id);
316 $ann->toXML($writer);
317 }
318
319 // Classification
320 foreach($this->getClassificationIds() as $id)
321 {
322 $cla =& $this->getClassification($id);
323 $cla->toXML($writer);
324 }
325
326 $writer->xmlEndTag('Migration/DBUpdate_426');
327 }
328
329 function deleteAll()
330 {
331 global $ilDB;
332
333 $tables = array('il_meta_annotation',
334 'il_meta_classification',
335 'il_meta_contribute',
336 'il_meta_description',
337 'il_meta_educational',
338 'il_meta_entity',
339 'il_meta_format',
340 'il_meta_general',
341 'il_meta_identifier',
342 'il_meta_identifier_',
343 'il_meta_keyword',
344 'il_meta_language',
345 'il_meta_lifecycle',
346 'il_meta_location',
347 'il_meta_meta_data',
348 'il_meta_relation',
349 'il_meta_requirement',
350 'il_meta_rights',
351 'il_meta_taxon',
352 'il_meta_taxon_path',
353 'il_meta_technical',
354 'il_meta_typical_age_range');
355
356 foreach($tables as $table)
357 {
358 $query = "DELETE FROM ".$table." ".
359 "WHERE rbac_id = ".$ilDB->quote($this->getRBACId())." ".
360 "AND obj_id = ".$ilDB->quote($this->getObjId());
361 $res = $ilDB->query($query);
362 }
363
364 return true;
365 }
367 {
368 global $ilDB;
369
370 $tables = array('il_meta_annotation',
371 'il_meta_classification',
372 'il_meta_contribute',
373 'il_meta_description',
374 'il_meta_educational',
375 'il_meta_entity',
376 'il_meta_format',
377 'il_meta_general',
378 'il_meta_identifier',
379 'il_meta_identifier_',
380 'il_meta_keyword',
381 'il_meta_language',
382 'il_meta_lifecycle',
383 'il_meta_location',
384 'il_meta_meta_data',
385 'il_meta_relation',
386 'il_meta_requirement',
387 'il_meta_rights',
388 'il_meta_taxon',
389 'il_meta_taxon_path',
390 'il_meta_technical',
391 'il_meta_typical_age_range');
392
393 foreach($tables as $table)
394 {
395 $query = "DELETE FROM ".$table." ".
396 "WHERE obj_type = ".$ilDB->quote($a_type)." ";
397 $res = $ilDB->query($query);
398 }
399
400 return true;
401 }
402}
403?>
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:64
& addAnnotation()
Definition: class.ilMD.php:222
toXML(&$writer)
Definition: class.ilMD.php:265
& addClassification()
Definition: class.ilMD.php:251
& addEducational()
Definition: class.ilMD.php:143
& getAnnotationIds()
Definition: class.ilMD.php:203
& getRelationIds()
Definition: class.ilMD.php:173
& addRights()
Definition: class.ilMD.php:164
& getClassificationIds()
Definition: class.ilMD.php:231
& addGeneral()
Definition: class.ilMD.php:54
& getGeneral()
Definition: class.ilMD.php:41
& getClassification($a_classification_id)
Definition: class.ilMD.php:237
& addTechnical()
Definition: class.ilMD.php:121
& addMetaMetadata()
Definition: class.ilMD.php:99
_deleteAllByType($a_type)
Definition: class.ilMD.php:366
& addLifecycle()
Definition: class.ilMD.php:77
& getEducational()
Definition: class.ilMD.php:130
& getRights()
Definition: class.ilMD.php:151
& getTechnical()
Definition: class.ilMD.php:108
deleteAll()
Definition: class.ilMD.php:329
& getMetaMetadata()
Definition: class.ilMD.php:86
& addRelation()
Definition: class.ilMD.php:193
& getRelation($a_relation_id)
Definition: class.ilMD.php:179
& getAnnotation($a_annotation_id)
Definition: class.ilMD.php:209
global $ilDB
$a_type
Definition: workflow.php:93