ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDAnnotation.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 setEntity($a_entity)
37 {
38 $this->entity = $a_entity;
39 }
40 function getEntity()
41 {
42 return $this->entity;
43 }
44 function setDate($a_date)
45 {
46 $this->date = $a_date;
47 }
48 function getDate()
49 {
50 return $this->date;
51 }
52 function setDescription($a_desc)
53 {
54 $this->description = $a_desc;
55 }
56 function getDescription()
57 {
58 return $this->description;
59 }
60 function setDescriptionLanguage($lng_obj)
61 {
62 if(is_object($lng_obj))
63 {
64 $this->description_language =& $lng_obj;
65 }
66 }
68 {
69 return $this->description_language;
70 }
72 {
73 if(is_object($this->description_language))
74 {
75 return $this->description_language->getLanguageCode();
76 }
77 return false;
78 }
79
80 function save()
81 {
82 global $ilDB;
83
84 $fields = $this->__getFields();
85 $fields['meta_annotation_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_annotation'));
86
87 if($this->db->insert('il_meta_annotation',$fields))
88 {
89 $this->setMetaId($next_id);
90 return $this->getMetaId();
91 }
92 return false;
93 }
94
95 function update()
96 {
97 global $ilDB;
98
99 if($this->getMetaId())
100 {
101 if($this->db->update('il_meta_annotation',
102 $this->__getFields(),
103 array("meta_annotation_id" => array('integer',$this->getMetaId()))))
104 {
105 return true;
106 }
107 }
108 return false;
109 }
110
111 function delete()
112 {
113 global $ilDB;
114
115 if($this->getMetaId())
116 {
117 $query = "DELETE FROM il_meta_annotation ".
118 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId() ,'integer');
119 $res = $ilDB->manipulate($query);
120
121 return true;
122 }
123 return false;
124 }
125
126
127 function __getFields()
128 {
129 return array('rbac_id' => array('integer',$this->getRBACId()),
130 'obj_id' => array('integer',$this->getObjId()),
131 'obj_type' => array('text',$this->getObjType()),
132 'entity' => array('clob',$this->getEntity()),
133 'a_date' => array('clob',$this->getDate()),
134 'description' => array('clob',$this->getDescription()),
135 'description_language' => array('text',$this->getDescriptionLanguageCode()));
136 }
137
138 function read()
139 {
140 global $ilDB;
141
142 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
143
144 if($this->getMetaId())
145 {
146 $query = "SELECT * FROM il_meta_annotation ".
147 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId() ,'integer');
148
149 $res = $this->db->query($query);
150 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
151 {
152 $this->setRBACId($row->rbac_id);
153 $this->setObjId($row->obj_id);
154 $this->setObjType($row->obj_type);
155 $this->setEntity($row->entity);
156 $this->setDate($row->a_date);
157 $this->setDescription($row->description);
158 $this->description_language = new ilMDLanguageItem($row->description_language);
159 }
160 }
161 return true;
162 }
163
164 /*
165 * XML Export of all meta data
166 * @param object (xml writer) see class.ilMD2XML.php
167 *
168 */
169 function toXML(&$writer)
170 {
171 $writer->xmlStartTag('Annotation');
172 $writer->xmlElement('Entity',null,$this->getEntity());
173 $writer->xmlElement('Date',null,$this->getDate());
174 $writer->xmlElement('Description',array('Language' => $this->getDescriptionLanguageCode()
176 : 'en'),
177 $this->getDescription());
178 $writer->xmlEndTag('Annotation');
179 }
180
181
182
183 // STATIC
184 static function _getIds($a_rbac_id,$a_obj_id)
185 {
186 global $ilDB;
187
188 $query = "SELECT meta_annotation_id FROM il_meta_annotation ".
189 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
190 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
191
192
193 $res = $ilDB->query($query);
194 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
195 {
196 $ids[] = $row->meta_annotation_id;
197 }
198 return $ids ? $ids : array();
199 }
200}
201?>
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
setDescriptionLanguage($lng_obj)
static _getIds($a_rbac_id, $a_obj_id)
setObjId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
global $ilDB