ILIAS  release_4-3 Revision
 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  $ilDB->manipulate("DELETE FROM il_event_handling");
69  }
70 
74  static function deleteObjectDefinition($a_id)
75  {
76  global $ilDB;
77 
78  $ilDB->manipulateF("DELETE FROM il_object_def WHERE id = %s",
79  array("text"), array($a_id));
80 
81  $ilDB->manipulateF("DELETE FROM il_object_subobj WHERE parent = %s OR subobj = %s",
82  array("text", "text"), array($a_id, $a_id));
83  }
84 
93  function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
94  {
95  global $ilDB;
96 
97  $this->current_tag = $a_name;
98 
99  switch ($a_name)
100  {
101  case 'object':
102 
103  // if attributes are not given, set default (repository only)
104  if($a_attribs["repository"] === NULL)
105  {
106  $a_attribs["repository"] = true;
107  }
108  if($a_attribs["workspace"] === NULL)
109  {
110  $a_attribs["workspace"] = false;
111  }
112 
113  $this->current_object = $a_attribs["id"];
114  $ilDB->manipulateF("INSERT INTO il_object_def (id, class_name, component,location,".
115  "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos,".
116  "default_pres_pos,sideblock,grp,system,export,repository,workspace,administration) VALUES ".
117  "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
118  array("text", "text", "text", "text", "integer", "integer", "text", "integer","integer","integer",
119  "integer","integer","integer","integer", "text", "integer", "integer", "integer", "integer",'integer'),
120  array(
121  $a_attribs["id"],
122  $a_attribs["class_name"],
123  $this->current_component,
124  $this->current_component."/".$a_attribs["dir"],
125  (int) $a_attribs["checkbox"],
126  (int) $a_attribs["inherit"],
127  $a_attribs["translate"],
128  (int) $a_attribs["devmode"],
129  (int) $a_attribs["allow_link"],
130  (int) $a_attribs["allow_copy"],
131  (int) $a_attribs["rbac"],
132  (int) $a_attribs["default_pos"],
133  (int) $a_attribs["default_pres_pos"],
134  (int) $a_attribs["sideblock"],
135  $a_attribs["group"],
136  (int) $a_attribs["system"],
137  (int) $a_attribs["export"],
138  (int) $a_attribs["repository"],
139  (int) $a_attribs["workspace"],
140  (int) $a_attribs['administration']
141  ));
142  break;
143 
144  case "subobj":
145  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
146  array("text", "text", "integer"),
147  array($this->current_object, $a_attribs["id"], (int) $a_attribs["max"]));
148  break;
149 
150  case "parent":
151  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
152  array("text", "text", "integer"),
153  array($a_attribs["id"], $this->current_object, (int) $a_attribs["max"]));
154  break;
155 
156  case "objectgroup":
157  $ilDB->manipulateF("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
158  array("text", "text", "integer"),
159  array($a_attribs["id"], $a_attribs["name"], $a_attribs["default_pres_pos"]));
160  break;
161 
162  case "pluginslot":
163  $this->current_object = $a_attribs["id"];
164  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
165  $ilDB->quote($this->current_component, "text").",".
166  $ilDB->quote($a_attribs["id"], "text").",".
167  $ilDB->quote($a_attribs["name"], "text").")";
168  $ilDB->manipulate($q);
169  break;
170 
171  case "event":
172  $component = $a_attribs["component"];
173  if(!$component)
174  {
175  $component = $this->current_component;
176  }
177  $q = "INSERT INTO il_event_handling (component, type, id) VALUES (".
178  $ilDB->quote($component, "text").",".
179  $ilDB->quote($a_attribs["type"], "text").",".
180  $ilDB->quote($a_attribs["id"], "text").")";
181  $ilDB->manipulate($q);
182  break;
183  }
184  }
185 
193  function handlerEndTag($a_xml_parser,$a_name)
194  {
195  }
196 
197 
205  function handlerCharacterData($a_xml_parser,$a_data)
206  {
207  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
208  $a_data = preg_replace("/\n/","",$a_data);
209  $a_data = preg_replace("/\t+/","",$a_data);
210 
211  if (!empty($a_data))
212  {
213  switch ($this->current_tag)
214  {
215  case '':
216  }
217  }
218  }
219 
220 }