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

Services/MetaData/classes/class.ilMDLanguage.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 ilMDLanguage extends ilMDBase
00034 {
00035 
00036         function ilMDLanguage($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00037         {
00038                 parent::ilMDBase($a_rbac_id,
00039                                                  $a_obj_id,
00040                                                  $a_obj_type);
00041         }
00042 
00043         // SET/GET
00044         function setLanguage(&$lng_obj)
00045         {
00046                 if(is_object($lng_obj))
00047                 {
00048                         $this->language =& $lng_obj;
00049                 }
00050         }
00051         function &getLanguage()
00052         {
00053                 return is_object($this->language) ? $this->language : false;
00054         }
00055         function getLanguageCode()
00056         {
00057                 return is_object($this->language) ? $this->language->getLanguageCode() : false;
00058         }
00059 
00060         function save()
00061         {
00062                 if($this->db->autoExecute('il_meta_language',
00063                                                                   $this->__getFields(),
00064                                                                   DB_AUTOQUERY_INSERT))
00065                 {
00066                         $this->setMetaId($this->db->getLastInsertId());
00067 
00068                         return $this->getMetaId();
00069                 }
00070                 return false;
00071         }
00072 
00073         function update()
00074         {
00075                 if($this->getMetaId())
00076                 {
00077                         if($this->db->autoExecute('il_meta_language',
00078                                                                           $this->__getFields(),
00079                                                                           DB_AUTOQUERY_UPDATE,
00080                                                                           "meta_language_id = '".$this->getMetaId()."'"))
00081                         {
00082                                 return true;
00083                         }
00084                 }
00085                 return false;
00086         }
00087 
00088         function delete()
00089         {
00090                 if($this->getMetaId())
00091                 {
00092                         $query = "DELETE FROM il_meta_language ".
00093                                 "WHERE meta_language_id = '".$this->getMetaId()."'";
00094                         
00095                         $this->db->query($query);
00096                         
00097                         return true;
00098                 }
00099                 return false;
00100         }
00101                         
00102 
00103         function __getFields()
00104         {
00105                 return array('rbac_id'  => $this->getRBACId(),
00106                                          'obj_id'       => $this->getObjId(),
00107                                          'obj_type'     => ilUtil::prepareDBString($this->getObjType()),
00108                                          'parent_type' => $this->getParentType(),
00109                                          'parent_id' => $this->getParentId(),
00110                                          'language' => $this->getLanguageCode());
00111         }
00112 
00113         function read()
00114         {
00115                 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00116 
00117                 if($this->getMetaId())
00118                 {
00119                         $query = "SELECT * FROM il_meta_language ".
00120                                 "WHERE meta_language_id = '".$this->getMetaId()."'";
00121 
00122                         $res = $this->db->query($query);
00123                         while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00124                         {
00125                                 $this->setRBACId($row->rbac_id);
00126                                 $this->setObjId($row->obj_id);
00127                                 $this->setObjType($row->obj_type);
00128                                 $this->setParentId($row->parent_id);
00129                                 $this->setParentType($row->parent_type);
00130                                 $this->setLanguage(new ilMDLanguageItem($row->language));
00131                         }
00132                 }
00133                 return true;
00134         }
00135                                 
00136         /*
00137          * XML Export of all meta data
00138          * @param object (xml writer) see class.ilMD2XML.php
00139          * 
00140          */
00141         function toXML(&$writer)
00142         {
00143                 $writer->xmlElement('Language',array('Language' => $this->getLanguageCode() ? 
00144                                                                                          $this->getLanguageCode() :
00145                                                                                          'en'),
00146                                                         $this->getLanguage());
00147         }
00148 
00149 
00150         // STATIC
00151         function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00152         {
00153                 global $ilDB;
00154 
00155                 $query = "SELECT meta_language_id FROM il_meta_language ".
00156                         "WHERE rbac_id = '".$a_rbac_id."' ".
00157                         "AND obj_id = '".$a_obj_id."' ".
00158                         "AND parent_id = '".$a_parent_id."' ".
00159                         "AND parent_type = '".$a_parent_type."' ";
00160 
00161                 $res = $ilDB->query($query);
00162                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00163                 {
00164                         $ids[] = $row->meta_language_id;
00165                 }
00166                 return $ids ? $ids : array();
00167         }
00168 }
00169 ?>

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