ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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 $ilDB;
232
233 $fields = $this->__getFields();
234 $fields['meta_technical_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_technical'));
235
236 if ($this->db->insert('il_meta_technical', $fields)) {
237 $this->setMetaId($next_id);
238 return $this->getMetaId();
239 }
240 return false;
241 }
242
243 public function update()
244 {
245 global $ilDB;
246
247 if ($this->getMetaId()) {
248 if ($this->db->update(
249 'il_meta_technical',
250 $this->__getFields(),
251 array("meta_technical_id" => array('integer',$this->getMetaId()))
252 )) {
253 return true;
254 }
255 }
256 return false;
257 }
258
259 public function delete()
260 {
261 global $ilDB;
262
263 if ($this->getMetaId()) {
264 $query = "DELETE FROM il_meta_technical " .
265 "WHERE meta_technical_id = " . $ilDB->quote($this->getMetaId(), 'integer');
266 $res = $ilDB->manipulate($query);
267
268 foreach ($this->getFormatIds() as $id) {
269 $for =&$this->getFormat($id);
270 $for->delete();
271 }
272
273 foreach ($this->getLocationIds() as $id) {
274 $loc =&$this->getLocation($id);
275 $loc->delete();
276 }
277 foreach ($this->getRequirementIds() as $id) {
278 $req =&$this->getRequirement($id);
279 $req->delete();
280 }
281 foreach ($this->getOrCompositeIds() as $id) {
282 $orc =&$this->getOrComposite($id);
283 $orc->delete();
284 }
285
286 return true;
287 }
288 return false;
289 }
290
291
292 public function __getFields()
293 {
294 return array('rbac_id' => array('integer',$this->getRBACId()),
295 'obj_id' => array('integer',$this->getObjId()),
296 'obj_type' => array('text',$this->getObjType()),
297 't_size' => array('text',$this->getSize()),
298 'ir' => array('text',$this->getInstallationRemarks()),
299 'ir_language' => array('text',$this->getInstallationRemarksLanguageCode()),
300 'opr' => array('text',$this->getOtherPlatformRequirements()),
301 'opr_language' => array('text',$this->getOtherPlatformRequirementsLanguageCode()),
302 'duration' => array('text',$this->getDuration()));
303 }
304
305 public function read()
306 {
307 global $ilDB;
308
309 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
310
311 if ($this->getMetaId()) {
312 $query = "SELECT * FROM il_meta_technical " .
313 "WHERE meta_technical_id = " . $ilDB->quote($this->getMetaId(), 'integer') . " ";
314
315 $res = $ilDB->query($query);
316 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
317 $this->setRBACId($row->rbac_id);
318 $this->setObjId($row->obj_id);
319 $this->setObjType($row->obj_type);
320 $this->setSize($row->t_size);
321 $this->setInstallationRemarks($row->ir);
322 $this->setInstallationRemarksLanguage(new ilMDLanguageItem($row->ir_language));
325 $this->setDuration($row->duration);
326 }
327 return true;
328 }
329 return false;
330 }
331
332 /*
333 * XML Export of all meta data
334 * @param object (xml writer) see class.ilMD2XML.php
335 *
336 */
337 public function toXML(&$writer)
338 {
339 $writer->xmlStartTag('Technical');
340
341 // Format
342 foreach ($this->getFormatIds() as $id) {
343 $for =&$this->getFormat($id);
344 $for->toXML($writer);
345 }
346
347 // Size
348 if (strlen($this->getSize())) {
349 $writer->xmlElement('Size', null, $this->getSize());
350 }
351
352 // Location
353 foreach ($this->getLocationIds() as $id) {
354 $loc =&$this->getLocation($id);
355 $loc->toXML($writer);
356 }
357
358 // Requirement
359 foreach ($this->getRequirementIds() as $id) {
360 $req =&$this->getRequirement($id);
361 $req->toXML($writer);
362 }
363
364 // OrComposite
365 foreach ($this->getOrCompositeIds() as $id) {
366 $orc =&$this->getOrComposite($id);
367 $orc->toXML($writer);
368 }
369
370 // InstallationRemarks
371 if (strlen($this->getInstallationRemarks())) {
372 $writer->xmlElement(
373 'InstallationRemarks',
374 array('Language' => $this->getInstallationRemarksLanguageCode()
376 : 'en'),
378 );
379 }
380
381 // OtherPlatformRequirements
382 if (strlen($this->getOtherPlatformRequirements())) {
383 $writer->xmlElement(
384 'OtherPlatformRequirements',
385 array('Language' => $this->getOtherPlatformRequirementsLanguageCode()
387 : 'en'),
389 );
390 }
391 // Duration
392 if (strlen($this->getDuration())) {
393 $writer->xmlElement('Duration', null, $this->getDuration());
394 }
395
396 $writer->xmlEndTag('Technical');
397 }
398 // STATIC
399 public static function _getId($a_rbac_id, $a_obj_id)
400 {
401 global $ilDB;
402
403 $query = "SELECT meta_technical_id FROM il_meta_technical " .
404 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
405 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
406
407 $res = $ilDB->query($query);
408 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
409 return $row->meta_technical_id;
410 }
411 return false;
412 }
413}
$size
Definition: RandomTest.php:84
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)
if(!array_key_exists('StateId', $_REQUEST)) $id
$req
Definition: getUserInfo.php:20
$query
foreach($_POST as $key=> $value) $res
global $ilDB