Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 include_once 'class.ilMDBase.php';
00032
00033 class ilMDTaxon extends ilMDBase
00034 {
00035 function ilMDTaxon($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00036 {
00037 parent::ilMDBase($a_rbac_id,
00038 $a_obj_id,
00039 $a_obj_type);
00040 }
00041
00042
00043 function setTaxon($a_taxon)
00044 {
00045 $this->taxon = $a_taxon;
00046 }
00047 function getTaxon()
00048 {
00049 return $this->taxon;
00050 }
00051 function setTaxonLanguage(&$lng_obj)
00052 {
00053 if(is_object($lng_obj))
00054 {
00055 $this->taxon_language = $lng_obj;
00056 }
00057 }
00058 function &getTaxonLanguage()
00059 {
00060 return is_object($this->taxon_language) ? $this->taxon_language : false;
00061 }
00062 function getTaxonLanguageCode()
00063 {
00064 return is_object($this->taxon_language) ? $this->taxon_language->getLanguageCode() : false;
00065 }
00066 function setTaxonId($a_taxon_id)
00067 {
00068 $this->taxon_id = $a_taxon_id;
00069 }
00070 function getTaxonId()
00071 {
00072 return $this->taxon_id;
00073 }
00074
00075
00076 function save()
00077 {
00078 if($this->db->autoExecute('il_meta_taxon',
00079 $this->__getFields(),
00080 DB_AUTOQUERY_INSERT))
00081 {
00082 $this->setMetaId($this->db->getLastInsertId());
00083
00084 return $this->getMetaId();
00085 }
00086 return false;
00087 }
00088
00089 function update()
00090 {
00091 if($this->getMetaId())
00092 {
00093 if($this->db->autoExecute('il_meta_taxon',
00094 $this->__getFields(),
00095 DB_AUTOQUERY_UPDATE,
00096 "meta_taxon_id = '".$this->getMetaId()."'"))
00097 {
00098 return true;
00099 }
00100 }
00101 return false;
00102 }
00103
00104 function delete()
00105 {
00106 if($this->getMetaId())
00107 {
00108 $query = "DELETE FROM il_meta_taxon ".
00109 "WHERE meta_taxon_id = '".$this->getMetaId()."'";
00110
00111 $this->db->query($query);
00112
00113 return true;
00114 }
00115 return false;
00116 }
00117
00118
00119 function __getFields()
00120 {
00121 return array('rbac_id' => $this->getRBACId(),
00122 'obj_id' => $this->getObjId(),
00123 'obj_type' => $this->getObjType(),
00124 'parent_type' => $this->getParentType(),
00125 'parent_id' => $this->getParentId(),
00126 'taxon' => $this->getTaxon(),
00127 'taxon_language' => $this->getTaxonLanguageCode(),
00128 'taxon_id' => $this->getTaxonId());
00129 }
00130
00131 function read()
00132 {
00133 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00134
00135 if($this->getMetaId())
00136 {
00137 $query = "SELECT * FROM il_meta_taxon ".
00138 "WHERE meta_taxon_id = '".$this->getMetaId()."'";
00139
00140 $res = $this->db->query($query);
00141 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00142 {
00143 $this->setRBACId($row->rbac_id);
00144 $this->setObjId($row->obj_id);
00145 $this->setObjType($row->obj_type);
00146 $this->setParentId($row->parent_id);
00147 $this->setParentType($row->parent_type);
00148 $this->setTaxon($row->taxon);
00149 $this->taxon_language = new ilMDLanguageItem($row->taxon_language);
00150 $this->setTaxonId($row->taxon_id);
00151 }
00152 }
00153 return true;
00154 }
00155
00156
00157
00158
00159
00160
00161 function toXML(&$writer)
00162 {
00163 $writer->xmlElement('Taxon',array('Language' => $this->getTaxonLanguageCode()
00164 ? $this->getTaxonLanguageCode()
00165 : 'en',
00166 'Id' => $this->getTaxonId() ?
00167 $this->getTaxonId() : ("ID".rand())),
00168 $this->getTaxon());
00169 }
00170
00171
00172
00173 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00174 {
00175 global $ilDB;
00176
00177 $query = "SELECT meta_taxon_id FROM il_meta_taxon ".
00178 "WHERE rbac_id = '".$a_rbac_id."' ".
00179 "AND obj_id = '".$a_obj_id."' ".
00180 "AND parent_id = '".$a_parent_id."' ".
00181 "AND parent_type = '".$a_parent_type."'";
00182
00183
00184 $res = $ilDB->query($query);
00185 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00186 {
00187 $ids[] = $row->meta_taxon_id;
00188 }
00189 return $ids ? $ids : array();
00190 }
00191 }
00192 ?>