ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDTechnical.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
31include_once 'class.ilMDBase.php';
32
34{
36 {
37 $subs['Format'] = 'meta_format';
38 $subs['Location'] = 'meta_location';
39 if(!$this->getOrCompositeIds())
40 {
41 $subs['Requirement'] = 'meta_requirement';
42 }
43 if(!$this->getRequirementIds())
44 {
45 $subs['OrComposite'] = 'meta_or_composite';
46 }
47
48 return $subs;
49 }
50
51 // Methods for child objects (Format, Location, Requirement OrComposite)
52 function &getFormatIds()
53 {
54 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
55
56 return ilMDFormat::_getIds($this->getRBACId(),$this->getObjId());
57 }
58 function &getFormat($a_format_id)
59 {
60 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
61
62 if(!$a_format_id)
63 {
64 return false;
65 }
66 $for = new ilMDFormat($this,$a_format_id);
67 $for->setMetaId($a_format_id);
68
69 return $for;
70 }
71 function &addFormat()
72 {
73 include_once 'Services/MetaData/classes/class.ilMDFormat.php';
74
75 $for = new ilMDFormat($this->getRBACId(),$this->getObjId(),$this->getObjType());
76
77 return $for;
78 }
79 function &getLocationIds()
80 {
81 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
82
83 return ilMDLocation::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
84 }
85 function &getLocation($a_location_id)
86 {
87 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
88
89 if(!$a_location_id)
90 {
91 return false;
92 }
93 $loc = new ilMDLocation();
94 $loc->setMetaId($a_location_id);
95
96 return $loc;
97 }
98 function &addLocation()
99 {
100 include_once 'Services/MetaData/classes/class.ilMDLocation.php';
101
102 $loc = new ilMDLocation($this->getRBACId(),$this->getObjId(),$this->getObjType());
103 $loc->setParentId($this->getMetaId());
104 $loc->setParentType('meta_technical');
105
106 return $loc;
107 }
109 {
110 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
111
112 return ilMDRequirement::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
113 }
114 function &getRequirement($a_requirement_id)
115 {
116 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
117
118 if(!$a_requirement_id)
119 {
120 return false;
121 }
122 $rec = new ilMDRequirement();
123 $rec->setMetaId($a_requirement_id);
124
125 return $rec;
126 }
127 function &addRequirement()
128 {
129 include_once 'Services/MetaData/classes/class.ilMDRequirement.php';
130
131 $rec = new ilMDRequirement($this->getRBACId(),$this->getObjId(),$this->getObjType());
132 $rec->setParentId($this->getMetaId());
133 $rec->setParentType('meta_technical');
134
135 return $rec;
136 }
138 {
139 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
140
141 return ilMDOrComposite::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
142 }
143 function &getOrComposite($a_or_composite_id)
144 {
145 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
146
147 if(!$a_or_composite_id)
148 {
149 return false;
150 }
151 $orc = new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
152 $orc->setOrCompositeId($a_or_composite_id);
153 $orc->setParentId($this->getMetaId());
154 $orc->setParentType('meta_technical');
155
156 return $orc;
157 }
158 function &addOrComposite()
159 {
160 include_once 'Services/MetaData/classes/class.ilMDOrComposite.php';
161
162 $orc = new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
163 $orc->setParentId($this->getMetaId());
164 $orc->setParentType('meta_technical');
165
166 return $orc;
167 }
168
169 // SET/GET
170 function setSize($a_size)
171 {
172 $this->size = $a_size;
173 }
174 function getSize()
175 {
176 return $this->size;
177 }
178 function setInstallationRemarks($a_val)
179 {
180 $this->installation_remarks = $a_val;
181 }
183 {
184 return $this->installation_remarks;
185 }
187 {
188 if(is_object($lng_obj))
189 {
190 $this->installation_remarks_language =& $lng_obj;
191 }
192 }
194 {
195 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language : false;
196 }
198 {
199 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language->getLanguageCode() : false;
200 }
202 {
203 $this->other_platform_requirements = $a_val;
204 }
206 {
207 return $this->other_platform_requirements;
208 }
210 {
211 if(is_object($lng_obj))
212 {
213 $this->other_platform_requirements_language =& $lng_obj;
214 }
215 }
217 {
218 return is_object($this->other_platform_requirements_language) ? $this->other_platform_requirements_language : false;
219 }
221 {
222 return is_object($this->other_platform_requirements_language)
223 ? $this->other_platform_requirements_language->getLanguageCode()
224 : false;
225 }
226 function setDuration($a_val)
227 {
228 $this->duration = $a_val;
229 }
230 function getDuration()
231 {
232 return $this->duration;
233 }
234
235
236
237 function save()
238 {
239 global $ilDB;
240
241 $fields = $this->__getFields();
242 $fields['meta_technical_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_technical'));
243
244 if($this->db->insert('il_meta_technical',$fields))
245 {
246 $this->setMetaId($next_id);
247 return $this->getMetaId();
248 }
249 return false;
250 }
251
252 function update()
253 {
254 global $ilDB;
255
256 if($this->getMetaId())
257 {
258 if($this->db->update('il_meta_technical',
259 $this->__getFields(),
260 array("meta_technical_id" => array('integer',$this->getMetaId()))))
261 {
262 return true;
263 }
264 }
265 return false;
266 }
267
268 function delete()
269 {
270 global $ilDB;
271
272 if($this->getMetaId())
273 {
274 $query = "DELETE FROM il_meta_technical ".
275 "WHERE meta_technical_id = ".$ilDB->quote($this->getMetaId() ,'integer');
276 $res = $ilDB->manipulate($query);
277
278 foreach($this->getFormatIds() as $id)
279 {
280 $for =& $this->getFormat($id);
281 $for->delete();
282 }
283
284 foreach($this->getLocationIds() as $id)
285 {
286 $loc =& $this->getLocation($id);
287 $loc->delete();
288 }
289 foreach($this->getRequirementIds() as $id)
290 {
291 $req =& $this->getRequirement($id);
292 $req->delete();
293 }
294 foreach($this->getOrCompositeIds() as $id)
295 {
296 $orc =& $this->getOrComposite($id);
297 $orc->delete();
298 }
299
300 return true;
301
302 }
303 return false;
304 }
305
306
307 function __getFields()
308 {
309 return array('rbac_id' => array('integer',$this->getRBACId()),
310 'obj_id' => array('integer',$this->getObjId()),
311 'obj_type' => array('text',$this->getObjType()),
312 't_size' => array('text',$this->getSize()),
313 'ir' => array('text',$this->getInstallationRemarks()),
314 'ir_language' => array('text',$this->getInstallationRemarksLanguageCode()),
315 'opr' => array('text',$this->getOtherPlatformRequirements()),
316 'opr_language' => array('text',$this->getOtherPlatformRequirementsLanguageCode()),
317 'duration' => array('text',$this->getDuration()));
318 }
319
320 function read()
321 {
322 global $ilDB;
323
324 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
325
326 if($this->getMetaId())
327 {
328
329 $query = "SELECT * FROM il_meta_technical ".
330 "WHERE meta_technical_id = ".$ilDB->quote($this->getMetaId() ,'integer')." ";
331
332 $res = $ilDB->query($query);
333 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
334 {
335 $this->setRBACId($row->rbac_id);
336 $this->setObjId($row->obj_id);
337 $this->setObjType($row->obj_type);
338 $this->setSize($row->t_size);
339 $this->setInstallationRemarks($row->ir);
340 $this->setInstallationRemarksLanguage(new ilMDLanguageItem($row->ir_language));
343 $this->setDuration($row->duration);
344 }
345 return true;
346 }
347 return false;
348 }
349
350 /*
351 * XML Export of all meta data
352 * @param object (xml writer) see class.ilMD2XML.php
353 *
354 */
355 function toXML(&$writer)
356 {
357 $writer->xmlStartTag('Technical');
358
359 // Format
360 foreach($this->getFormatIds() as $id)
361 {
362 $for =& $this->getFormat($id);
363 $for->toXML($writer);
364 }
365
366 // Size
367 if(strlen($this->getSize()))
368 {
369 $writer->xmlElement('Size',null,$this->getSize());
370 }
371
372 // Location
373 foreach($this->getLocationIds() as $id)
374 {
375 $loc =& $this->getLocation($id);
376 $loc->toXML($writer);
377 }
378
379 // Requirement
380 foreach($this->getRequirementIds() as $id)
381 {
382 $req =& $this->getRequirement($id);
383 $req->toXML($writer);
384 }
385
386 // OrComposite
387 foreach($this->getOrCompositeIds() as $id)
388 {
389 $orc =& $this->getOrComposite($id);
390 $orc->toXML($writer);
391 }
392
393 // InstallationRemarks
394 if(strlen($this->getInstallationRemarks()))
395 {
396 $writer->xmlElement('InstallationRemarks',
397 array('Language' => $this->getInstallationRemarksLanguageCode()
399 : 'en'),
400 $this->getInstallationRemarks());
401 }
402
403 // OtherPlatformRequirements
404 if(strlen($this->getOtherPlatformRequirements()))
405 {
406 $writer->xmlElement('OtherPlatformRequirements',
407 array('Language' => $this->getOtherPlatformRequirementsLanguageCode()
409 : 'en'),
411 }
412 // Duration
413 if(strlen($this->getDuration()))
414 {
415 $writer->xmlElement('Duration',null,$this->getDuration());
416 }
417
418 $writer->xmlEndTag('Technical');
419
420 }
421 // STATIC
422 static function _getId($a_rbac_id,$a_obj_id)
423 {
424 global $ilDB;
425
426 $query = "SELECT meta_technical_id FROM il_meta_technical ".
427 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
428 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
429
430 $res = $ilDB->query($query);
431 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
432 {
433 return $row->meta_technical_id;
434 }
435 return false;
436 }
437}
438?>
$size
Definition: RandomTest.php:79
An exception for terminatinating execution or to throw for unit testing.
setObjId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
static _getIds($a_rbac_id, $a_obj_id)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type, $a_or_composite_id=0)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type, $a_or_composite_id=0)
& getOtherPlatformRequirementsLanguage()
static _getId($a_rbac_id, $a_obj_id)
& getOrComposite($a_or_composite_id)
& getFormat($a_format_id)
setOtherPlatformRequirementsLanguage(&$lng_obj)
getOtherPlatformRequirementsLanguageCode()
setInstallationRemarksLanguage(&$lng_obj)
setOtherPlatformRequirements($a_val)
& getRequirement($a_requirement_id)
setInstallationRemarks($a_val)
& getLocation($a_location_id)
font size
Definition: langcheck.php:162
global $ilDB