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