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