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