ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDLanguage.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 ilMDLanguage extends ilMDBase
34 {
35  // SET/GET
36  function setLanguage(&$lng_obj)
37  {
38  if(is_object($lng_obj))
39  {
40  $this->language =& $lng_obj;
41  }
42  }
43  function &getLanguage()
44  {
45  return is_object($this->language) ? $this->language : false;
46  }
47  function getLanguageCode()
48  {
49  return is_object($this->language) ? $this->language->getLanguageCode() : false;
50  }
51 
52  function save()
53  {
54  if($this->db->autoExecute('il_meta_language',
55  $this->__getFields(),
57  {
58  $this->setMetaId($this->db->getLastInsertId());
59 
60  return $this->getMetaId();
61  }
62  return false;
63  }
64 
65  function update()
66  {
67  global $ilDB;
68 
69  if($this->getMetaId())
70  {
71  if($this->db->autoExecute('il_meta_language',
72  $this->__getFields(),
74  "meta_language_id = ".$ilDB->quote($this->getMetaId())))
75  {
76  return true;
77  }
78  }
79  return false;
80  }
81 
82  function delete()
83  {
84  global $ilDB;
85 
86  if($this->getMetaId())
87  {
88  $query = "DELETE FROM il_meta_language ".
89  "WHERE meta_language_id = ".$ilDB->quote($this->getMetaId());
90 
91  $this->db->query($query);
92 
93  return true;
94  }
95  return false;
96  }
97 
98 
99  function __getFields()
100  {
101  return array('rbac_id' => $this->getRBACId(),
102  'obj_id' => $this->getObjId(),
103  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
104  'parent_type' => $this->getParentType(),
105  'parent_id' => $this->getParentId(),
106  'language' => ilUtil::prepareDBString($this->getLanguageCode()));
107  }
108 
109  function read()
110  {
111  global $ilDB;
112 
113  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
114 
115  if($this->getMetaId())
116  {
117  $query = "SELECT * FROM il_meta_language ".
118  "WHERE meta_language_id = ".$ilDB->quote($this->getMetaId());
119 
120  $res = $this->db->query($query);
121  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
122  {
123  $this->setRBACId($row->rbac_id);
124  $this->setObjId($row->obj_id);
125  $this->setObjType($row->obj_type);
126  $this->setParentId($row->parent_id);
127  $this->setParentType($row->parent_type);
128  $this->setLanguage(new ilMDLanguageItem($row->language));
129  }
130  }
131  return true;
132  }
133 
134  /*
135  * XML Export of all meta data
136  * @param object (xml writer) see class.ilMD2XML.php
137  *
138  */
139  function toXML(&$writer)
140  {
141  $writer->xmlElement('Language',array('Language' => $this->getLanguageCode()),$this->getLanguage());
142  }
143 
144 
145  // STATIC
146  function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
147  {
148  global $ilDB;
149 
150  $query = "SELECT meta_language_id FROM il_meta_language ".
151  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
152  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
153  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
154  "AND parent_type = ".$ilDB->quote($a_parent_type);
155 
156  $res = $ilDB->query($query);
157  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
158  {
159  $ids[] = $row->meta_language_id;
160  }
161  return $ids ? $ids : array();
162  }
163 }
164 ?>
setObjType($a_type)
setLanguage(&$lng_obj)
setMetaId($a_meta_id, $a_read_data=true)
setObjId($a_id)
setRBACId($a_id)
Create styles array
The data for the language used.
setParentId($a_id)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
global $ilDB
setParentType($a_parent_type)