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
00031 include_once 'class.ilMDBase.php';
00032
00033 class ilMDTechnical extends ilMDBase
00034 {
00035 function ilMDTechnical($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00036 {
00037 parent::ilMDBase($a_rbac_id,
00038 $a_obj_id,
00039 $a_obj_type);
00040 }
00041
00042 function getPossibleSubelements()
00043 {
00044 $subs['Format'] = 'meta_format';
00045 $subs['Location'] = 'meta_location';
00046 if(!$this->getOrCompositeIds())
00047 {
00048 $subs['Requirement'] = 'meta_requirement';
00049 }
00050 if(!$this->getRequirementIds())
00051 {
00052 $subs['OrComposite'] = 'meta_or_composite';
00053 }
00054
00055 return $subs;
00056 }
00057
00058
00059 function &getFormatIds()
00060 {
00061 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
00062
00063 return ilMDFormat::_getIds($this->getRBACId(),$this->getObjId());
00064 }
00065 function &getFormat($a_format_id)
00066 {
00067 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
00068
00069 if(!$a_format_id)
00070 {
00071 return false;
00072 }
00073 $for =& new ilMDFormat($this,$a_format_id);
00074 $for->setMetaId($a_format_id);
00075
00076 return $for;
00077 }
00078 function &addFormat()
00079 {
00080 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
00081
00082 $for =& new ilMDFormat($this->getRBACId(),$this->getObjId(),$this->getObjType());
00083
00084 return $for;
00085 }
00086 function &getLocationIds()
00087 {
00088 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
00089
00090 return ilMDLocation::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
00091 }
00092 function &getLocation($a_location_id)
00093 {
00094 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
00095
00096 if(!$a_location_id)
00097 {
00098 return false;
00099 }
00100 $loc =& new ilMDLocation();
00101 $loc->setMetaId($a_location_id);
00102
00103 return $loc;
00104 }
00105 function &addLocation()
00106 {
00107 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
00108
00109 $loc =& new ilMDLocation($this->getRBACId(),$this->getObjId(),$this->getObjType());
00110 $loc->setParentId($this->getMetaId());
00111 $loc->setParentType('meta_technical');
00112
00113 return $loc;
00114 }
00115 function &getRequirementIds()
00116 {
00117 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
00118
00119 return ilMDRequirement::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
00120 }
00121 function &getRequirement($a_requirement_id)
00122 {
00123 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
00124
00125 if(!$a_requirement_id)
00126 {
00127 return false;
00128 }
00129 $rec =& new ilMDRequirement();
00130 $rec->setMetaId($a_requirement_id);
00131
00132 return $rec;
00133 }
00134 function &addRequirement()
00135 {
00136 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
00137
00138 $rec =& new ilMDRequirement($this->getRBACId(),$this->getObjId(),$this->getObjType());
00139 $rec->setParentId($this->getMetaId());
00140 $rec->setParentType('meta_technical');
00141
00142 return $rec;
00143 }
00144 function &getOrCompositeIds()
00145 {
00146 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
00147
00148 return ilMDOrComposite::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
00149 }
00150 function &getOrComposite($a_or_composite_id)
00151 {
00152 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
00153
00154 if(!$a_or_composite_id)
00155 {
00156 return false;
00157 }
00158 $orc =& new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
00159 $orc->setOrCompositeId($a_or_composite_id);
00160 $orc->setParentId($this->getMetaId());
00161 $orc->setParentType('meta_technical');
00162
00163 return $orc;
00164 }
00165 function &addOrComposite()
00166 {
00167 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
00168
00169 $orc =& new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
00170 $orc->setParentId($this->getMetaId());
00171 $orc->setParentType('meta_technical');
00172
00173 return $orc;
00174 }
00175
00176
00177 function setSize($a_size)
00178 {
00179 $this->size = $a_size;
00180 }
00181 function getSize()
00182 {
00183 return $this->size;
00184 }
00185 function setInstallationRemarks($a_val)
00186 {
00187 $this->installation_remarks = $a_val;
00188 }
00189 function getInstallationRemarks()
00190 {
00191 return $this->installation_remarks;
00192 }
00193 function setInstallationRemarksLanguage(&$lng_obj)
00194 {
00195 if(is_object($lng_obj))
00196 {
00197 $this->installation_remarks_language =& $lng_obj;
00198 }
00199 }
00200 function &getInstallationRemarksLanguage()
00201 {
00202 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language : false;
00203 }
00204 function getInstallationRemarksLanguageCode()
00205 {
00206 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language->getLanguageCode() : false;
00207 }
00208 function setOtherPlatformRequirements($a_val)
00209 {
00210 $this->other_platform_requirements = $a_val;
00211 }
00212 function getOtherPlatformRequirements()
00213 {
00214 return $this->other_platform_requirements;
00215 }
00216 function setOtherPlatformRequirementsLanguage(&$lng_obj)
00217 {
00218 if(is_object($lng_obj))
00219 {
00220 $this->other_platform_requirements_language =& $lng_obj;
00221 }
00222 }
00223 function &getOtherPlatformRequirementsLanguage()
00224 {
00225 return is_object($this->other_platform_requirements_language) ? $this->other_platform_requirements_language : false;
00226 }
00227 function getOtherPlatformRequirementsLanguageCode()
00228 {
00229 return is_object($this->other_platform_requirements_language)
00230 ? $this->other_platform_requirements_language->getLanguageCode()
00231 : false;
00232 }
00233 function setDuration($a_val)
00234 {
00235 $this->duration = $a_val;
00236 }
00237 function getDuration()
00238 {
00239 return $this->duration;
00240 }
00241
00242
00243
00244 function save()
00245 {
00246 if($this->db->autoExecute('il_meta_technical',
00247 $this->__getFields(),
00248 DB_AUTOQUERY_INSERT))
00249 {
00250 $this->setMetaId($this->db->getLastInsertId());
00251
00252 return $this->getMetaId();
00253 }
00254
00255 return false;
00256 }
00257
00258 function update()
00259 {
00260 if($this->getMetaId())
00261 {
00262 if($this->db->autoExecute('il_meta_technical',
00263 $this->__getFields(),
00264 DB_AUTOQUERY_UPDATE,
00265 "meta_technical_id = '".$this->getMetaId()."'"))
00266 {
00267 return true;
00268 }
00269 }
00270 return false;
00271 }
00272
00273 function delete()
00274 {
00275 if($this->getMetaId())
00276 {
00277 $query = "DELETE FROM il_meta_technical ".
00278 "WHERE meta_technical_id = '".$this->getMetaId()."'";
00279
00280 $this->db->query($query);
00281
00282 foreach($this->getFormatIds() as $id)
00283 {
00284 $for =& $this->getFormat($id);
00285 $for->delete();
00286 }
00287
00288 foreach($this->getLocationIds() as $id)
00289 {
00290 $loc =& $this->getLocation($id);
00291 $loc->delete();
00292 }
00293 foreach($this->getRequirementIds() as $id)
00294 {
00295 $req =& $this->getRequirement($id);
00296 $req->delete();
00297 }
00298 foreach($this->getOrCompositeIds() as $id)
00299 {
00300 $orc =& $this->getOrComposite($id);
00301 $orc->delete();
00302 }
00303
00304 return true;
00305
00306 }
00307 return false;
00308 }
00309
00310
00311 function __getFields()
00312 {
00313 return array('rbac_id' => $this->getRBACId(),
00314 'obj_id' => $this->getObjId(),
00315 'obj_type' => $this->getObjType(),
00316 'size' => $this->getSize(),
00317 'installation_remarks' => $this->getInstallationRemarks(),
00318 'installation_remarks_language' => $this->getInstallationRemarksLanguageCode(),
00319 'other_platform_requirements' => $this->getOtherPlatformRequirements(),
00320 'other_platform_requirements_language' => $this->getOtherPlatformRequirementsLanguageCode(),
00321 'duration' => $this->getDuration());
00322 }
00323
00324 function read()
00325 {
00326 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00327
00328 if($this->getMetaId())
00329 {
00330
00331 $query = "SELECT * FROM il_meta_technical ".
00332 "WHERE meta_technical_id = '".$this->getMetaId()."'";
00333
00334
00335 $res = $this->db->query($query);
00336 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00337 {
00338 $this->setRBACId($row->rbac_id);
00339 $this->setObjId($row->obj_id);
00340 $this->setObjType($row->obj_type);
00341 $this->setSize($row->size);
00342 $this->setInstallationRemarks($row->installation_remarks);
00343 $this->setInstallationRemarksLanguage(new ilMDLanguageItem($row->installation_remarks_language));
00344 $this->setOtherPlatformRequirements($row->other_platform_requirements);
00345 $this->setOtherPlatformRequirementsLanguage(new ilMDLanguageItem($row->other_platform_requirements_language));
00346 $this->setDuration($row->duration);
00347 }
00348 return true;
00349 }
00350 return false;
00351 }
00352
00353
00354
00355
00356
00357
00358 function toXML(&$writer)
00359 {
00360 $writer->xmlStartTag('Technical');
00361
00362
00363 foreach($this->getFormatIds() as $id)
00364 {
00365 $for =& $this->getFormat($id);
00366 $for->toXML($writer);
00367 }
00368
00369
00370 if(strlen($this->getSize()))
00371 {
00372 $writer->xmlElement('Size',null,$this->getSize());
00373 }
00374
00375
00376 foreach($this->getLocationIds() as $id)
00377 {
00378 $loc =& $this->getLocation($id);
00379 $loc->toXML($writer);
00380 }
00381
00382
00383 foreach($this->getRequirementIds() as $id)
00384 {
00385 $req =& $this->getRequirement($id);
00386 $req->toXML($writer);
00387 }
00388
00389
00390 foreach($this->getOrCompositeIds() as $id)
00391 {
00392 $orc =& $this->getOrComposite($id);
00393 $orc->toXML($writer);
00394 }
00395
00396
00397 if(strlen($this->getInstallationRemarks()))
00398 {
00399 $writer->xmlElement('InstallationRemarks',
00400 array('Language' => $this->getInstallationRemarksLanguageCode()
00401 ? $this->getInstallationRemarksLanguageCode()
00402 : 'en'),
00403 $this->getInstallationRemarks());
00404 }
00405
00406
00407 if(strlen($this->getOtherPlatformRequirements()))
00408 {
00409 $writer->xmlElement('OtherPlatformRequirements',
00410 array('Language' => $this->getOtherPlatformRequirementsLanguageCode()
00411 ? $this->getOtherPlatformRequirementsLanguageCode()
00412 : 'en'),
00413 $this->getOtherPlatformRequirements());
00414 }
00415
00416 if(strlen($this->getDuration()))
00417 {
00418 $writer->xmlElement('Duration',null,$this->getDuration());
00419 }
00420
00421 $writer->xmlEndTag('Technical');
00422
00423 }
00424
00425 function _getId($a_rbac_id,$a_obj_id)
00426 {
00427 global $ilDB;
00428
00429 $query = "SELECT meta_technical_id FROM il_meta_technical ".
00430 "WHERE rbac_id = '".$a_rbac_id."' ".
00431 "AND obj_id = '".$a_obj_id."'";
00432
00433 $res = $ilDB->query($query);
00434 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00435 {
00436 return $row->meta_technical_id;
00437 }
00438 return false;
00439 }
00440 }
00441 ?>