00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00032 include_once 'class.ilMDBase.php';
00033
00034 class ilMD extends ilMDBase
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 function ilMD($a_rbac_id,$a_obj_id,$a_type)
00051 {
00052 parent::ilMDBase($a_rbac_id,$a_obj_id,$a_type);
00053 }
00054
00055 function &getGeneral()
00056 {
00057 include_once 'Services/MetaData/classes/class.ilMDGeneral.php';
00058
00059 if($id = ilMDGeneral::_getId($this->getRBACId(),$this->getObjId()))
00060 {
00061 $gen =& new ilMDGeneral();
00062 $gen->setMetaId($id);
00063
00064 return $gen;
00065 }
00066 return false;
00067 }
00068 function &addGeneral()
00069 {
00070 include_once 'Services/MetaData/classes/class.ilMDGeneral.php';
00071
00072 $gen =& new ilMDGeneral($this->getRBACId(),$this->getObjId(),$this->getObjType());
00073
00074 return $gen;
00075 }
00076
00077
00078 function &getLifecycle()
00079 {
00080 include_once 'Services/MetaData/classes/class.ilMDLifecycle.php';
00081
00082 if($id = ilMDLifecycle::_getId($this->getRBACId(),$this->getObjId()))
00083 {
00084 $lif =& new ilMDLifecycle();
00085 $lif->setMetaId($id);
00086
00087 return $lif;
00088 }
00089 return false;
00090 }
00091 function &addLifecycle()
00092 {
00093 include_once 'Services/MetaData/classes/class.ilMDLifecycle.php';
00094
00095 $lif =& new ilMDLifecycle($this->getRBACId(),$this->getObjId(),$this->getObjType());
00096
00097 return $lif;
00098 }
00099
00100 function &getMetaMetadata()
00101 {
00102 include_once 'Services/MetaData/classes/class.ilMDMetaMetadata.php';
00103
00104 if($id = ilMDMetaMetadata::_getId($this->getRBACId(),$this->getObjId()))
00105 {
00106 $met =& new ilMDMetaMetadata();
00107 $met->setMetaId($id);
00108
00109 return $met;
00110 }
00111 return false;
00112 }
00113 function &addMetaMetadata()
00114 {
00115 include_once 'Services/MetaData/classes/class.ilMDMetaMetadata.php';
00116
00117 $met =& new ilMDMetaMetadata($this->getRBACId(),$this->getObjId(),$this->getObjType());
00118
00119 return $met;
00120 }
00121
00122 function &getTechnical()
00123 {
00124 include_once 'Services/MetaData/classes/class.ilMDTechnical.php';
00125
00126 if($id = ilMDTechnical::_getId($this->getRBACId(),$this->getObjId()))
00127 {
00128 $tec =& new ilMDTechnical();
00129 $tec->setMetaId($id);
00130
00131 return $tec;
00132 }
00133 return false;
00134 }
00135 function &addTechnical()
00136 {
00137 include_once 'Services/MetaData/classes/class.ilMDTechnical.php';
00138
00139 $tec =& new ilMDTechnical($this->getRBACId(),$this->getObjId(),$this->getObjType());
00140
00141 return $tec;
00142 }
00143
00144 function &getEducational()
00145 {
00146 include_once 'Services/MetaData/classes/class.ilMDEducational.php';
00147
00148 if($id = ilMDEducational::_getId($this->getRBACId(),$this->getObjId()))
00149 {
00150 $edu =& new ilMDEducational();
00151 $edu->setMetaId($id);
00152
00153 return $edu;
00154 }
00155 return false;
00156 }
00157 function &addEducational()
00158 {
00159 include_once 'Services/MetaData/classes/class.ilMDEducational.php';
00160
00161 $edu =& new ilMDEducational($this->getRBACId(),$this->getObjId(),$this->getObjType());
00162
00163 return $edu;
00164 }
00165 function &getRights()
00166 {
00167 include_once 'Services/MetaData/classes/class.ilMDRights.php';
00168
00169 if($id = ilMDRights::_getId($this->getRBACId(),$this->getObjId()))
00170 {
00171 $rig =& new ilMDRights();
00172 $rig->setMetaId($id);
00173
00174 return $rig;
00175 }
00176 return false;
00177 }
00178 function &addRights()
00179 {
00180 include_once 'Services/MetaData/classes/class.ilMDRights.php';
00181
00182 $rig =& new ilMDRights($this->getRBACId(),$this->getObjId(),$this->getObjType());
00183
00184 return $rig;
00185 }
00186
00187 function &getRelationIds()
00188 {
00189 include_once 'Services/MetaData/classes/class.ilMDRelation.php';
00190
00191 return ilMDRelation::_getIds($this->getRBACId(),$this->getObjId());
00192 }
00193 function &getRelation($a_relation_id)
00194 {
00195 include_once 'Services/MetaData/classes/class.ilMDRelation.php';
00196
00197 if(!$a_relation_id)
00198 {
00199 return false;
00200 }
00201
00202 $rel =& new ilMDRelation();
00203 $rel->setMetaId($a_relation_id);
00204
00205 return $rel;
00206 }
00207 function &addRelation()
00208 {
00209 include_once 'Services/MetaData/classes/class.ilMDRelation.php';
00210
00211 $rel =& new ilMDRelation($this->getRBACId(),$this->getObjId(),$this->getObjType());
00212
00213 return $rel;
00214 }
00215
00216
00217 function &getAnnotationIds()
00218 {
00219 include_once 'Services/MetaData/classes/class.ilMDAnnotation.php';
00220
00221 return ilMDAnnotation::_getIds($this->getRBACId(),$this->getObjId());
00222 }
00223 function &getAnnotation($a_annotation_id)
00224 {
00225 if(!$a_annotation_id)
00226 {
00227 return false;
00228 }
00229 include_once 'Services/MetaData/classes/class.ilMDAnnotation.php';
00230
00231 $ann =& new ilMDAnnotation();
00232 $ann->setMetaId($a_annotation_id);
00233
00234 return $ann;
00235 }
00236 function &addAnnotation()
00237 {
00238 include_once 'Services/MetaData/classes/class.ilMDAnnotation.php';
00239
00240 $ann =& new ilMDAnnotation($this->getRBACId(),$this->getObjId(),$this->getObjType());
00241
00242 return $ann;
00243 }
00244
00245 function &getClassificationIds()
00246 {
00247 include_once 'Services/MetaData/classes/class.ilMDClassification.php';
00248
00249 return ilMDClassification::_getIds($this->getRBACId(),$this->getObjId());
00250 }
00251 function &getClassification($a_classification_id)
00252 {
00253 if(!$a_classification_id)
00254 {
00255 return false;
00256 }
00257
00258 include_once 'Services/MetaData/classes/class.ilMDClassification.php';
00259
00260 $cla =& new ilMDClassification();
00261 $cla->setMetaId($a_classification_id);
00262
00263 return $cla;
00264 }
00265 function &addClassification()
00266 {
00267 include_once 'Services/MetaData/classes/class.ilMDClassification.php';
00268
00269 $cla =& new ilMDClassification($this->getRBACId(),$this->getObjId(),$this->getObjType());
00270
00271 return $cla;
00272 }
00273
00274
00275
00276
00277
00278
00279 function toXML(&$writer)
00280 {
00281 $writer->xmlStartTag('MetaData');
00282
00283
00284 if(is_object($gen =& $this->getGeneral()))
00285 {
00286 $gen->setExportMode($this->getExportMode());
00287 $gen->toXML($writer);
00288 }
00289 else
00290 {
00291
00292 include_once 'Services/MetaData/classes/class.ilMDGeneral.php';
00293 $gen = new ilMDGeneral($this->getRBACId(),$this->getObjId());
00294 $gen->setExportMode($this->getExportMode());
00295 $gen->toXML($writer);
00296 }
00297
00298
00299
00300 if(is_object($lif =& $this->getLifecycle()))
00301 {
00302 $lif->toXML($writer);
00303 }
00304
00305
00306 if(is_object($met =& $this->getMetaMetadata()))
00307 {
00308 $met->toXML($writer);
00309 }
00310
00311
00312 if(is_object($tec =& $this->getTechnical()))
00313 {
00314 $tec->toXML($writer);
00315 }
00316
00317
00318 if(is_object($edu =& $this->getEducational()))
00319 {
00320 $edu->toXML($writer);
00321 }
00322
00323
00324 if(is_object($rig =& $this->getRights()))
00325 {
00326 $rig->toXML($writer);
00327 }
00328
00329
00330 foreach($this->getRelationIds() as $id)
00331 {
00332 $rel =& $this->getRelation($id);
00333 $rel->toXML($writer);
00334 }
00335
00336
00337 foreach($this->getAnnotationIds() as $id)
00338 {
00339 $ann =& $this->getAnnotation($id);
00340 $ann->toXML($writer);
00341 }
00342
00343
00344 foreach($this->getClassificationIds() as $id)
00345 {
00346 $cla =& $this->getClassification($id);
00347 $cla->toXML($writer);
00348 }
00349
00350 $writer->xmlEndTag('MetaData');
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 function &cloneMD($a_rbac_id,$a_obj_id,$a_obj_type)
00362 {
00363 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
00364
00365
00366
00367 $md2xml = new ilMD2XML($this->getRBACId(),$this->getObjId(),$this->getObjType());
00368 $md2xml->startExport();
00369
00370
00371 switch($a_obj_type)
00372 {
00373 default:
00374 include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
00375
00376 $mdxmlcopier =& new ilMDXMLCopier($md2xml->getXML(),$a_rbac_id,$a_obj_id,$a_obj_type);
00377 break;
00378 }
00379 $mdxmlcopier->startParsing();
00380
00381 return $mdxmlcopier->getMDObject();
00382 }
00383
00384 function deleteAll()
00385 {
00386 $tables = array('il_meta_annotation',
00387 'il_meta_classification',
00388 'il_meta_contribute',
00389 'il_meta_description',
00390 'il_meta_educational',
00391 'il_meta_entity',
00392 'il_meta_format',
00393 'il_meta_general',
00394 'il_meta_identifier',
00395 'il_meta_identifier_',
00396 'il_meta_keyword',
00397 'il_meta_language',
00398 'il_meta_lifecycle',
00399 'il_meta_location',
00400 'il_meta_meta_data',
00401 'il_meta_relation',
00402 'il_meta_requirement',
00403 'il_meta_rights',
00404 'il_meta_taxon',
00405 'il_meta_taxon_path',
00406 'il_meta_technical',
00407 'il_meta_typical_age_range');
00408
00409 foreach($tables as $table)
00410 {
00411 $query = "DELETE FROM ".$table." ".
00412 "WHERE rbac_id = '".$this->getRBACId()."' ".
00413 "AND obj_id = '".$this->getObjId()."'";
00414
00415 $this->db->query($query);
00416 }
00417
00418 return true;
00419 }
00420
00421 }
00422 ?>