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