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