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