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