ILIAS  Release_4_0_x_branch Revision 61816
 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  $this->current_object = $a_attribs["id"];
101  $ilDB->manipulateF("INSERT INTO il_object_def (id, class_name, component,location,".
102  "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos,default_pres_pos,sideblock,grp,system) VALUES ".
103  "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
104  array("text", "text", "text", "text", "integer", "integer", "text", "integer","integer","integer",
105  "integer","integer","integer","integer", "text", "integer"),
106  array(
107  $a_attribs["id"],
108  $a_attribs["class_name"],
109  $this->current_component,
110  $this->current_component."/".$a_attribs["dir"],
111  (int) $a_attribs["checkbox"],
112  (int) $a_attribs["inherit"],
113  $a_attribs["translate"],
114  (int) $a_attribs["devmode"],
115  (int) $a_attribs["allow_link"],
116  (int) $a_attribs["allow_copy"],
117  (int) $a_attribs["rbac"],
118  (int) $a_attribs["default_pos"],
119  (int) $a_attribs["default_pres_pos"],
120  (int) $a_attribs["sideblock"],
121  $a_attribs["group"],
122  (int) $a_attribs["system"]));
123  break;
124 
125  case "subobj":
126  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
127  array("text", "text", "integer"),
128  array($this->current_object, $a_attribs["id"], (int) $a_attribs["max"]));
129  break;
130 
131  case "parent":
132  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
133  array("text", "text", "integer"),
134  array($a_attribs["id"], $this->current_object, (int) $a_attribs["max"]));
135  break;
136 
137  case "objectgroup":
138  $ilDB->manipulateF("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
139  array("text", "text", "integer"),
140  array($a_attribs["id"], $a_attribs["name"], $a_attribs["default_pres_pos"]));
141  break;
142 
143  case "pluginslot":
144  $this->current_object = $a_attribs["id"];
145  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
146  $ilDB->quote($this->current_component, "text").",".
147  $ilDB->quote($a_attribs["id"], "text").",".
148  $ilDB->quote($a_attribs["name"], "text").")";
149  $ilDB->manipulate($q);
150  break;
151  }
152  }
153 
161  function handlerEndTag($a_xml_parser,$a_name)
162  {
163  }
164 
165 
173  function handlerCharacterData($a_xml_parser,$a_data)
174  {
175  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
176  $a_data = preg_replace("/\n/","",$a_data);
177  $a_data = preg_replace("/\t+/","",$a_data);
178 
179  if (!empty($a_data))
180  {
181  switch ($this->current_tag)
182  {
183  case '':
184  }
185  }
186  }
187 
188 }