ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDTaxon.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 ilMDTaxon extends ilMDBase
34 {
35  // SET/GET
36  function setTaxon($a_taxon)
37  {
38  $this->taxon = $a_taxon;
39  }
40  function getTaxon()
41  {
42  return $this->taxon;
43  }
44  function setTaxonLanguage(&$lng_obj)
45  {
46  if(is_object($lng_obj))
47  {
48  $this->taxon_language = $lng_obj;
49  }
50  }
51  function &getTaxonLanguage()
52  {
53  return is_object($this->taxon_language) ? $this->taxon_language : false;
54  }
56  {
57  return is_object($this->taxon_language) ? $this->taxon_language->getLanguageCode() : false;
58  }
59  function setTaxonId($a_taxon_id)
60  {
61  $this->taxon_id = $a_taxon_id;
62  }
63  function getTaxonId()
64  {
65  return $this->taxon_id;
66  }
67 
68 
69  function save()
70  {
71  global $ilDB;
72 
73  $fields = $this->__getFields();
74  $fields['meta_taxon_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_taxon'));
75 
76  if($this->db->insert('il_meta_taxon',$fields))
77  {
78  $this->setMetaId($next_id);
79  return $this->getMetaId();
80  }
81  return false;
82  }
83 
84  function update()
85  {
86  global $ilDB;
87 
88  if($this->getMetaId())
89  {
90  if($this->db->update('il_meta_taxon',
91  $this->__getFields(),
92  array("meta_taxon_id" => array('integer',$this->getMetaId()))))
93  {
94  return true;
95  }
96  }
97  return false;
98  }
99 
100  function delete()
101  {
102  global $ilDB;
103 
104  if($this->getMetaId())
105  {
106  $query = "DELETE FROM il_meta_taxon ".
107  "WHERE meta_taxon_id = ".$ilDB->quote($this->getMetaId() ,'integer');
108 
109  $this->db->query($query);
110 
111  return true;
112  }
113  return false;
114  }
115 
116 
117  function __getFields()
118  {
119  return array('rbac_id' => array('integer',$this->getRBACId()),
120  'obj_id' => array('integer',$this->getObjId()),
121  'obj_type' => array('text',$this->getObjType()),
122  'parent_type' => array('text',$this->getParentType()),
123  'parent_id' => array('integer',$this->getParentId()),
124  'taxon' => array('text',$this->getTaxon()),
125  'taxon_language' => array('text',$this->getTaxonLanguageCode()),
126  'taxon_id' => array('text',$this->getTaxonId()));
127  }
128 
129  function read()
130  {
131  global $ilDB;
132 
133  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
134 
135  if($this->getMetaId())
136  {
137  $query = "SELECT * FROM il_meta_taxon ".
138  "WHERE meta_taxon_id = ".$ilDB->quote($this->getMetaId() ,'integer');
139 
140  $res = $this->db->query($query);
141  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
142  {
143  $this->setRBACId($row->rbac_id);
144  $this->setObjId($row->obj_id);
145  $this->setObjType($row->obj_type);
146  $this->setParentId($row->parent_id);
147  $this->setParentType($row->parent_type);
148  $this->setTaxon($row->taxon);
149  $this->taxon_language = new ilMDLanguageItem($row->taxon_language);
150  $this->setTaxonId($row->taxon_id);
151  }
152  }
153  return true;
154  }
155 
156  /*
157  * XML Export of all meta data
158  * @param object (xml writer) see class.ilMD2XML.php
159  *
160  */
161  function toXML(&$writer)
162  {
163  $writer->xmlElement('Taxon',array('Language' => $this->getTaxonLanguageCode()
164  ? $this->getTaxonLanguageCode()
165  : 'en',
166  'Id' => $this->getTaxonId() ?
167  $this->getTaxonId() : ("ID".rand())),
168  $this->getTaxon());
169  }
170 
171 
172  // STATIC
173  static function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
174  {
175  global $ilDB;
176 
177  $query = "SELECT meta_taxon_id FROM il_meta_taxon ".
178  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
179  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
180  "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
181  "AND parent_type = ".$ilDB->quote($a_parent_type ,'text');
182 
183 
184  $res = $ilDB->query($query);
185  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
186  {
187  $ids[] = $row->meta_taxon_id;
188  }
189  return $ids ? $ids : array();
190  }
191 }
192 ?>
setObjType($a_type)
setTaxonLanguage(&$lng_obj)
setTaxon($a_taxon)
setTaxonId($a_taxon_id)
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)
toXML(&$writer)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
global $ilDB
setParentType($a_parent_type)
& getTaxonLanguage()