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 
31 include_once 'class.ilMDBase.php';
32 
33 class ilMDDescription extends ilMDBase
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  if($this->db->autoExecute('il_meta_description',
63  $this->__getFields(),
65  {
66  $this->setMetaId($this->db->getLastInsertId());
67 
68  return $this->getMetaId();
69  }
70  return false;
71  }
72 
73  function update()
74  {
75  global $ilDB;
76 
77  if($this->getMetaId())
78  {
79  if($this->db->autoExecute('il_meta_description',
80  $this->__getFields(),
82  "meta_description_id = ".$ilDB->quote($this->getMetaId())))
83  {
84  return true;
85  }
86  }
87  return false;
88  }
89 
90  function delete()
91  {
92  global $ilDB;
93 
94  if($this->getMetaId())
95  {
96  $query = "DELETE FROM il_meta_description ".
97  "WHERE meta_description_id = ".$ilDB->quote($this->getMetaId());
98 
99  $this->db->query($query);
100 
101  return true;
102  }
103  return false;
104  }
105 
106 
107  function __getFields()
108  {
109  return array('rbac_id' => $this->getRBACId(),
110  'obj_id' => $this->getObjId(),
111  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
112  'parent_type' => $this->getParentType(),
113  'parent_id' => $this->getParentId(),
114  'description' => ilUtil::prepareDBString($this->getDescription()),
115  'description_language' => ilUtil::prepareDBString($this->getDescriptionLanguageCode()));
116  }
117 
118  function read()
119  {
120  global $ilDB;
121 
122  include_once 'Services/Migration/DBUpdate_426/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());
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(ilUtil::stripSlashes($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()),$this->getDescription());
152  }
153 
154 
155  // STATIC
156  function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
157  {
158  global $ilDB;
159 
160  $query = "SELECT meta_description_id FROM il_meta_description ".
161  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
162  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
163  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
164  "AND parent_type = ".$ilDB->quote($a_parent_type)." ".
165  "ORDER BY meta_description_id";
166 
167  $res = $ilDB->query($query);
168  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
169  {
170  $ids[] = $row->meta_description_id;
171  }
172  return $ids ? $ids : array();
173  }
174 }
175 ?>
setObjType($a_type)
setDescription($a_description)
setMetaId($a_meta_id, $a_read_data=true)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
setObjId($a_id)
setRBACId($a_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
setDescriptionLanguage(&$lng_obj)
setParentId($a_id)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
global $ilDB
setParentType($a_parent_type)