ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMD5295Description.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.ilMD5295Base.php';
32
34{
35 // SET/GET
36 public function setDescription($a_description)
37 {
38 $this->description = $a_description;
39 }
40 public function getDescription()
41 {
42 return $this->description;
43 }
44 public function setDescriptionLanguage(&$lng_obj)
45 {
46 if (is_object($lng_obj)) {
47 $this->description_language = $lng_obj;
48 }
49 }
50 public function &getDescriptionLanguage()
51 {
52 return is_object($this->description_language) ? $this->description_language : false;
53 }
55 {
56 return is_object($this->description_language) ? $this->description_language->getLanguageCode() : false;
57 }
58
59 public function save()
60 {
61 global $DIC;
62
63 $ilDB = $DIC['ilDB'];
64
65 $fields = $this->__getFields();
66 $fields['meta_description_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_description'));
67
68 if ($this->db->insert('il_meta_description', $fields)) {
69 $this->setMetaId($next_id);
70 return $this->getMetaId();
71 }
72 return false;
73 }
74
75 public function update()
76 {
77 global $DIC;
78
79 $ilDB = $DIC['ilDB'];
80
81 if ($this->getMetaId()) {
82 if ($this->db->update(
83 'il_meta_description',
84 $this->__getFields(),
85 array("meta_description_id" => array('integer',$this->getMetaId()))
86 )) {
87 return true;
88 }
89 }
90 return false;
91 }
92
93 public function delete()
94 {
95 global $DIC;
96
97 $ilDB = $DIC['ilDB'];
98
99 if ($this->getMetaId()) {
100 $query = "DELETE FROM il_meta_description " .
101 "WHERE meta_description_id = " . $ilDB->quote($this->getMetaId(), 'integer');
102 $res = $ilDB->manipulate($query);
103
104 return true;
105 }
106 return false;
107 }
108
109
110 public function __getFields()
111 {
112 return array('rbac_id' => array('integer',$this->getRBACId()),
113 'obj_id' => array('integer',$this->getObjId()),
114 'obj_type' => array('text',$this->getObjType()),
115 'parent_type' => array('text',$this->getParentType()),
116 'parent_id' => array('integer',$this->getParentId()),
117 'description' => array('clob',$this->getDescription()),
118 'description_language' => array('text',$this->getDescriptionLanguageCode()));
119 }
120
121 public function read()
122 {
123 global $DIC;
124
125 $ilDB = $DIC['ilDB'];
126
127 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295LanguageItem.php';
128
129 if ($this->getMetaId()) {
130 $query = "SELECT * FROM il_meta_description " .
131 "WHERE meta_description_id = " . $ilDB->quote($this->getMetaId(), 'integer');
132
133 $res = $this->db->query($query);
134 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
135 $this->setRBACId($row->rbac_id);
136 $this->setObjId($row->obj_id);
137 $this->setObjType($row->obj_type);
138 $this->setParentId($row->parent_id);
139 $this->setParentType($row->parent_type);
140 $this->setDescription($row->description);
141 $this->setDescriptionLanguage(new ilMD5295LanguageItem($row->description_language));
142 }
143 }
144 return true;
145 }
146
147 /*
148 * XML Export of all meta data
149 * @param object (xml writer) see class.ilMD52952XML.php
150 *
151 */
152 public function toXML(&$writer)
153 {
154 $writer->xmlElement(
155 'Description',
156 array('Language' => $this->getDescriptionLanguageCode() ?
158 'en'),
159 $this->getDescription()
160 );
161 }
162
163
164 // STATIC
165 public static function _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
166 {
167 global $DIC;
168
169 $ilDB = $DIC['ilDB'];
170
171 $query = "SELECT meta_description_id FROM il_meta_description " .
172 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id) . " " .
173 "AND obj_id = " . $ilDB->quote($a_obj_id) . " " .
174 "AND parent_id = " . $ilDB->quote($a_parent_id) . " " .
175 "AND parent_type = " . $ilDB->quote($a_parent_type) . " " .
176 "ORDER BY meta_description_id";
177
178 $res = $ilDB->query($query);
179 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
180 $ids[] = $row->meta_description_id;
181 }
182 return $ids ? $ids : array();
183 }
184}
An exception for terminatinating execution or to throw for unit testing.
setParentType($a_parent_type)
setMetaId($a_meta_id, $a_read_data=true)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46