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