ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMDFormat.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 
32 include_once 'class.ilMDBase.php';
33 
34 class ilMDFormat extends ilMDBase
35 {
36  // SET/GET
37  public function setFormat($a_format)
38  {
39  $this->format = $a_format;
40  }
41  public function getFormat()
42  {
43  return $this->format;
44  }
45 
46  public function save()
47  {
48  global $ilDB;
49 
50  $fields = $this->__getFields();
51  $fields['meta_format_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_format'));
52 
53  if ($this->db->insert('il_meta_format', $fields)) {
54  $this->setMetaId($next_id);
55  return $this->getMetaId();
56  }
57  return false;
58  }
59 
60  public function update()
61  {
62  global $ilDB;
63 
64  if ($this->getMetaId()) {
65  if ($this->db->update(
66  'il_meta_format',
67  $this->__getFields(),
68  array("meta_format_id" => array('integer',$this->getMetaId()))
69  )) {
70  return true;
71  }
72  }
73  return false;
74  }
75 
76  public function delete()
77  {
78  global $ilDB;
79 
80  if ($this->getMetaId()) {
81  $query = "DELETE FROM il_meta_format " .
82  "WHERE meta_format_id = " . $ilDB->quote($this->getMetaId(), 'integer');
83  $res = $ilDB->manipulate($query);
84 
85  return true;
86  }
87  return false;
88  }
89 
90 
91  public function __getFields()
92  {
93  return array('rbac_id' => array('integer',$this->getRBACId()),
94  'obj_id' => array('integer',$this->getObjId()),
95  'obj_type' => array('text',$this->getObjType()),
96  'format' => array('text',$this->getFormat()));
97  }
98 
99  public function read()
100  {
101  global $ilDB;
102 
103  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
104 
105  if ($this->getMetaId()) {
106  $query = "SELECT * FROM il_meta_format " .
107  "WHERE meta_format_id = " . $ilDB->quote($this->getMetaId(), 'integer');
108 
109  $res = $this->db->query($query);
110  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
111  $this->setRBACId($row->rbac_id);
112  $this->setObjId($row->obj_id);
113  $this->setObjType($row->obj_type);
114  $this->setFormat($row->format);
115  }
116  }
117  return true;
118  }
119 
120  /*
121  * XML Export of all meta data
122  * @param object (xml writer) see class.ilMD2XML.php
123  *
124  */
125  public function toXML(&$writer)
126  {
127  if ($this->getFormat()) {
128  $writer->xmlElement('Format', null, $this->getFormat());
129  }
130  }
131 
132 
133  // STATIC
134  public static function _getIds($a_rbac_id, $a_obj_id)
135  {
136  global $ilDB;
137 
138  $query = "SELECT meta_format_id FROM il_meta_format " .
139  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
140  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
141 
142  $res = $ilDB->query($query);
143  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
144  $ids[] = $row->meta_format_id;
145  }
146  return $ids ? $ids : array();
147  }
148 }
toXML(&$writer)
setObjType($a_type)
$format
Definition: metadata.php:141
static _getIds($a_rbac_id, $a_obj_id)
setFormat($a_format)
setMetaId($a_meta_id, $a_read_data=true)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
Create styles array
The data for the language used.
Write to Excel2007 format
global $ilDB