ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjDefReader.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 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 
35 {
36  function ilObjDefReader($a_path, $a_name, $a_type)
37  {
38  $this->name = $a_name;
39  $this->type = $a_type;
40 //echo "<br>-".$a_path."-".$this->name."-".$this->type."-";
41  parent::ilSaxParser($a_path);
42  }
43 
44  function setHandlers($a_xml_parser)
45  {
46  xml_set_object($a_xml_parser,$this);
47  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
48  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
49  }
50 
54  static function clearTables()
55  {
56  global $ilDB;
57 
58  $ilDB->manipulate("DELETE FROM il_object_def");
59 
60  $ilDB->manipulate("DELETE FROM il_object_subobj");
61 
62  $ilDB->manipulate("DELETE FROM il_object_group");
63 
64  $ilDB->manipulate("DELETE FROM il_pluginslot");
65 
66  $ilDB->manipulate("DELETE FROM il_component");
67  }
68 
72  static function deleteObjectDefinition($a_id)
73  {
74  global $ilDB;
75 
76  $ilDB->manipulateF("DELETE FROM il_object_def WHERE id = %s",
77  array("text"), array($a_id));
78 
79  $ilDB->manipulateF("DELETE FROM il_object_subobj WHERE parent = %s OR subobj = %s",
80  array("text", "text"), array($a_id, $a_id));
81  }
82 
91  function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
92  {
93  global $ilDB;
94 
95  $this->current_tag = $a_name;
96 
97  switch ($a_name)
98  {
99  case 'object':
100 
101  // if attributes are not given, set default (repository only)
102  if($a_attribs["repository"] === NULL)
103  {
104  $a_attribs["repository"] = true;
105  }
106  if($a_attribs["workspace"] === NULL)
107  {
108  $a_attribs["workspace"] = false;
109  }
110 
111  $this->current_object = $a_attribs["id"];
112  $ilDB->manipulateF("INSERT INTO il_object_def (id, class_name, component,location,".
113  "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos,".
114  "default_pres_pos,sideblock,grp,system,export,repository,workspace,administration) VALUES ".
115  "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
116  array("text", "text", "text", "text", "integer", "integer", "text", "integer","integer","integer",
117  "integer","integer","integer","integer", "text", "integer", "integer", "integer", "integer",'integer'),
118  array(
119  $a_attribs["id"],
120  $a_attribs["class_name"],
121  $this->current_component,
122  $this->current_component."/".$a_attribs["dir"],
123  (int) $a_attribs["checkbox"],
124  (int) $a_attribs["inherit"],
125  $a_attribs["translate"],
126  (int) $a_attribs["devmode"],
127  (int) $a_attribs["allow_link"],
128  (int) $a_attribs["allow_copy"],
129  (int) $a_attribs["rbac"],
130  (int) $a_attribs["default_pos"],
131  (int) $a_attribs["default_pres_pos"],
132  (int) $a_attribs["sideblock"],
133  $a_attribs["group"],
134  (int) $a_attribs["system"],
135  (int) $a_attribs["export"],
136  (int) $a_attribs["repository"],
137  (int) $a_attribs["workspace"],
138  (int) $a_attribs['administration']
139  ));
140  break;
141 
142  case "subobj":
143  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
144  array("text", "text", "integer"),
145  array($this->current_object, $a_attribs["id"], (int) $a_attribs["max"]));
146  break;
147 
148  case "parent":
149  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
150  array("text", "text", "integer"),
151  array($a_attribs["id"], $this->current_object, (int) $a_attribs["max"]));
152  break;
153 
154  case "objectgroup":
155  $ilDB->manipulateF("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
156  array("text", "text", "integer"),
157  array($a_attribs["id"], $a_attribs["name"], $a_attribs["default_pres_pos"]));
158  break;
159 
160  case "pluginslot":
161  $this->current_object = $a_attribs["id"];
162  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
163  $ilDB->quote($this->current_component, "text").",".
164  $ilDB->quote($a_attribs["id"], "text").",".
165  $ilDB->quote($a_attribs["name"], "text").")";
166  $ilDB->manipulate($q);
167  break;
168  }
169  }
170 
178  function handlerEndTag($a_xml_parser,$a_name)
179  {
180  }
181 
182 
190  function handlerCharacterData($a_xml_parser,$a_data)
191  {
192  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
193  $a_data = preg_replace("/\n/","",$a_data);
194  $a_data = preg_replace("/\t+/","",$a_data);
195 
196  if (!empty($a_data))
197  {
198  switch ($this->current_tag)
199  {
200  case '':
201  }
202  }
203  }
204 
205 }