ILIAS  eassessment Revision 61809
 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,export) VALUES ".
103  "(%s,%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",'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  (int) $a_attribs['export']));
124  break;
125 
126  case "subobj":
127  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
128  array("text", "text", "integer"),
129  array($this->current_object, $a_attribs["id"], (int) $a_attribs["max"]));
130  break;
131 
132  case "parent":
133  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
134  array("text", "text", "integer"),
135  array($a_attribs["id"], $this->current_object, (int) $a_attribs["max"]));
136  break;
137 
138  case "objectgroup":
139  $ilDB->manipulateF("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
140  array("text", "text", "integer"),
141  array($a_attribs["id"], $a_attribs["name"], $a_attribs["default_pres_pos"]));
142  break;
143 
144  case "pluginslot":
145  $this->current_object = $a_attribs["id"];
146  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
147  $ilDB->quote($this->current_component, "text").",".
148  $ilDB->quote($a_attribs["id"], "text").",".
149  $ilDB->quote($a_attribs["name"], "text").")";
150  $ilDB->manipulate($q);
151  break;
152  }
153  }
154 
162  function handlerEndTag($a_xml_parser,$a_name)
163  {
164  }
165 
166 
174  function handlerCharacterData($a_xml_parser,$a_data)
175  {
176  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
177  $a_data = preg_replace("/\n/","",$a_data);
178  $a_data = preg_replace("/\t+/","",$a_data);
179 
180  if (!empty($a_data))
181  {
182  switch ($this->current_tag)
183  {
184  case '':
185  }
186  }
187  }
188 
189 }