• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/MetaData/classes/class.ilMDKeyword.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00031 include_once 'class.ilMDBase.php';
00032 
00033 class ilMDKeyword extends ilMDBase
00034 {
00035         function ilMDKeyword($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         // SET/GET
00043         function setKeyword($a_keyword)
00044         {
00045                 $this->keyword = $a_keyword;
00046         }
00047         function getKeyword()
00048         {
00049                 return $this->keyword;
00050         }
00051         function setKeywordLanguage(&$lng_obj)
00052         {
00053                 if(is_object($lng_obj))
00054                 {
00055                         $this->keyword_language = $lng_obj;
00056                 }
00057         }
00058         function &getKeywordLanguage()
00059         {
00060                 return is_object($this->keyword_language) ? $this->keyword_language : false;
00061         }
00062         function getKeywordLanguageCode()
00063         {
00064                 return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() : false;
00065         }
00066 
00067         function save()
00068         {
00069                 if($this->db->autoExecute('il_meta_keyword',
00070                                                                   $this->__getFields(),
00071                                                                   DB_AUTOQUERY_INSERT))
00072                 {
00073                         $this->setMetaId($this->db->getLastInsertId());
00074 
00075                         return $this->getMetaId();
00076                 }
00077                 return false;
00078         }
00079 
00080         function update()
00081         {
00082                 if($this->getMetaId())
00083                 {
00084                         if($this->db->autoExecute('il_meta_keyword',
00085                                                                           $this->__getFields(),
00086                                                                           DB_AUTOQUERY_UPDATE,
00087                                                                           "meta_keyword_id = '".$this->getMetaId()."'"))
00088                         {
00089                                 return true;
00090                         }
00091                 }
00092                 return false;
00093         }
00094 
00095         function delete()
00096         {
00097                 if($this->getMetaId())
00098                 {
00099                         $query = "DELETE FROM il_meta_keyword ".
00100                                 "WHERE meta_keyword_id = '".$this->getMetaId()."'";
00101                         
00102                         $this->db->query($query);
00103                         
00104                         return true;
00105                 }
00106                 return false;
00107         }
00108                         
00109 
00110         function __getFields()
00111         {
00112                 return array('rbac_id'  => $this->getRBACId(),
00113                                          'obj_id'       => $this->getObjId(),
00114                                          'obj_type'     => $this->getObjType(),
00115                                          'parent_type' => $this->getParentType(),
00116                                          'parent_id' => $this->getParentId(),
00117                                          'keyword'      => $this->getKeyword(),
00118                                          'keyword_language' => $this->getKeywordLanguageCode());
00119         }
00120 
00121         function read()
00122         {
00123                 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00124 
00125                 if($this->getMetaId())
00126                 {
00127                         $query = "SELECT * FROM il_meta_keyword ".
00128                                 "WHERE meta_keyword_id = '".$this->getMetaId()."'";
00129 
00130                         $res = $this->db->query($query);
00131                         while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00132                         {
00133                                 $this->setRBACId($row->rbac_id);
00134                                 $this->setObjId($row->obj_id);
00135                                 $this->setObjType($row->obj_type);
00136                                 $this->setParentId($row->parent_id);
00137                                 $this->setParentType($row->parent_type);
00138                                 $this->setKeyword($row->keyword);
00139                                 $this->setKeywordLanguage( new ilMDLanguageItem($row->keyword_language));
00140                         }
00141                 }
00142                 return true;
00143         }
00144                                 
00145         /*
00146          * XML Export of all meta data
00147          * @param object (xml writer) see class.ilMD2XML.php
00148          * 
00149          */
00150         function toXML(&$writer)
00151         {
00152                 $writer->xmlElement('Keyword',array('Language' => $this->getKeywordLanguageCode() ?
00153                                                                                         $this->getKeywordLanguageCode() :
00154                                                                                         'en'),
00155                                                         $this->getKeyword());
00156         }
00157 
00158 
00159         // STATIC
00160         function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00161         {
00162                 global $ilDB;
00163 
00164                 $query = "SELECT meta_keyword_id FROM il_meta_keyword ".
00165                         "WHERE rbac_id = '".$a_rbac_id."' ".
00166                         "AND obj_id = '".$a_obj_id."' ".
00167                         "AND parent_id = '".$a_parent_id."' ".
00168                         "AND parent_type = '".$a_parent_type ."' ".
00169                         "ORDER BY meta_keyword_id ";
00170 
00171                 $res = $ilDB->query($query);
00172                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00173                 {
00174                         $ids[] = $row->meta_keyword_id;
00175                 }
00176                 return $ids ? $ids : array();
00177         }
00178 }
00179 ?>

Generated on Fri Dec 13 2013 13:52:11 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1