ILIAS  Release_3_10_x_branch Revision 61812
 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-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 
35 {
36  function ilObjDefReader($a_path, $a_name, $a_type)
37  {
38  $this->name = $a_name;
39  $this->type = $a_type;
40 //echo "-".$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  $q = "DELETE FROM il_object_def";
59  $ilDB->query($q);
60 
61  $q = "DELETE FROM il_object_subobj";
62  $ilDB->query($q);
63 
64  $q = "DELETE FROM il_object_group";
65  $ilDB->query($q);
66 
67  $q = "DELETE FROM il_pluginslot";
68  $ilDB->query($q);
69 
70  $q = "DELETE FROM il_component";
71  $ilDB->query($q);
72  }
73 
82  function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
83  {
84  global $ilDB;
85 
86  $this->current_tag = $a_name;
87 
88  switch ($a_name)
89  {
90  case 'object':
91  $this->current_object = $a_attribs["id"];
92  $q = "REPLACE INTO il_object_def (id, class_name, component,location,".
93  "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos,default_pres_pos,sideblock,grp,system) VALUES (".
94  $ilDB->quote($a_attribs["id"]).",".
95  $ilDB->quote($a_attribs["class_name"]).",".
96  $ilDB->quote($this->current_component).",".
97  $ilDB->quote($this->current_component."/".$a_attribs["dir"]).",".
98  $ilDB->quote((int) $a_attribs["checkbox"]).",".
99  $ilDB->quote((int) $a_attribs["inherit"]).",".
100  $ilDB->quote($a_attribs["translate"]).",".
101  $ilDB->quote((int) $a_attribs["devmode"]).",".
102  $ilDB->quote((int) $a_attribs["allow_link"]).",".
103  $ilDB->quote((int) $a_attribs["allow_copy"]).",".
104  $ilDB->quote((int) $a_attribs["rbac"]).",".
105  $ilDB->quote((int) $a_attribs["default_pos"]).",".
106  $ilDB->quote((int) $a_attribs["default_pres_pos"]).",".
107  $ilDB->quote((int) $a_attribs["sideblock"]).",".
108  $ilDB->quote($a_attribs["group"]).",".
109  $ilDB->quote((int) $a_attribs["system"]).")";
110  $ilDB->query($q);
111  break;
112 
113  case "subobj":
114  $ilDB->query("INSERT INTO il_object_subobj (parent, subobj, max) VALUES (".
115  $ilDB->quote($this->current_object).",".
116  $ilDB->quote($a_attribs["id"]).",".
117  $ilDB->quote($a_attribs["max"]).")");
118  break;
119 
120  case "parent":
121  $ilDB->query("INSERT INTO il_object_subobj (parent, subobj, max) VALUES (".
122  $ilDB->quote($a_attribs["id"]).",".
123  $ilDB->quote($this->current_object).",".
124  $ilDB->quote($a_attribs["max"]).")");
125  break;
126 
127  case "objectgroup":
128  $ilDB->query("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (".
129  $ilDB->quote($a_attribs["id"]).",".
130  $ilDB->quote($a_attribs["name"]).",".
131  $ilDB->quote($a_attribs["default_pres_pos"]).
132  ")");
133  break;
134 
135  case "pluginslot":
136  $this->current_object = $a_attribs["id"];
137  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
138  $ilDB->quote($this->current_component).",".
139  $ilDB->quote($a_attribs["id"]).",".
140  $ilDB->quote($a_attribs["name"]).")";
141  $ilDB->query($q);
142  break;
143  }
144  }
145 
153  function handlerEndTag($a_xml_parser,$a_name)
154  {
155  }
156 
157 
165  function handlerCharacterData($a_xml_parser,$a_data)
166  {
167  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
168  $a_data = preg_replace("/\n/","",$a_data);
169  $a_data = preg_replace("/\t+/","",$a_data);
170 
171  if (!empty($a_data))
172  {
173  switch ($this->current_tag)
174  {
175  case '':
176  }
177  }
178  }
179 
180 }