ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPluginReader.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Xml/classes/class.ilSaxParser.php");
5 
16 {
17  public function __construct($a_path, $a_ctype, $a_cname, $a_slot_id, $a_pname)
18  {
19  parent::__construct($a_path);
20 
21  $this->ctype = $a_ctype;
22  $this->cname = $a_cname;
23  $this->slot_id = $a_slot_id;
24  $this->pname = $a_pname;
25  }
26 
30  public function clearEvents()
31  {
32  global $DIC;
33  $ilDB = $DIC->database();
34 
35  $component = "Plugins/" . $this->pname;
36  $ilDB->manipulate("DELETE FROM il_event_handling WHERE component = " . $ilDB->quote($component, 'text'));
37  }
38 
39 
40  public function startParsing()
41  {
42  if ($this->getInputType() == 'file') {
43  if (!file_exists($this->xml_file)) {
44  // not every plugin has a plugin.xml yet
45  return;
46  }
47  }
48  parent::startParsing();
49  }
50 
51  public function setHandlers($a_xml_parser)
52  {
53  xml_set_object($a_xml_parser, $this);
54  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
55  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
56  }
57 
66  public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
67  {
68  global $DIC;
69  $ilDB = $DIC->database();
70 
71  switch ($a_name) {
72  // base plugin info is still read from the plugin.php
73  case 'plugin_tag_analyzed_in_future':
74 
75  // check whether record exists
76  $q = "SELECT * FROM il_plugin WHERE " .
77  " component_type = " . $ilDB->quote($this->ctype, "text") .
78  " AND component_name = " . $ilDB->quote($this->cname, "text") .
79  " AND slot_id = " . $ilDB->quote($this->slot_id, "text") .
80  " AND name = " . $ilDB->quote($this->pname, "text");
81  $set = $ilDB->query($q);
82  if ($ilDB->numRows($set) == 0) {
83  $q = "INSERT INTO il_plugin (component_type,component_name,slot_id," .
84  "name, id, last_update_version, current_version, ilias_min_version," .
85  " ilias_max_version, active) VALUES " .
86  "(" . $ilDB->quote($this->ctype, "text") . "," .
87  $ilDB->quote($this->cname, "text") . "," .
88  $ilDB->quote($this->slot_id, "text") . "," .
89  $ilDB->quote($this->pname, "text") . "," .
90  $ilDB->quote($a_attribs["id"], "text") . "," .
91  $ilDB->quote("0.0.0", "text") . "," .
92  $ilDB->quote($a_attribs["version"], "text") . "," .
93  $ilDB->quote($a_attribs["ilias_min_version"], "text") . "," .
94  $ilDB->quote($a_attribs["ilias_max_version"], "text") . "," .
95  $ilDB->quote(0, "integer") . ")";
96  $ilDB->manipulate($q);
97  } else {
98  $q = "UPDATE il_plugin SET " .
99  " id = " . $ilDB->quote($a_attribs["id"], "text") . "," .
100  " current_version = " . $ilDB->quote($a_attribs["version"], "text") . "," .
101  " ilias_min_version = " . $ilDB->quote($a_attribs["ilias_min_version"], "text") . "," .
102  " ilias_max_version = " . $ilDB->quote($a_attribs["ilias_max_version"], "text") .
103  " WHERE " .
104  " component_type = " . $ilDB->quote($this->ctype, "text") .
105  " AND component_name = " . $ilDB->quote($this->cname, "text") .
106  " AND slot_id = " . $ilDB->quote($this->slot_id, "text") .
107  " AND name = " . $ilDB->quote($this->pname, "text");
108  $ilDB->manipulate($q);
109  }
110  break;
111 
112  case "event":
113  $component = "Plugins/" . $this->pname;
114  $q = "INSERT INTO il_event_handling (component, type, id) VALUES (" .
115  $ilDB->quote($component, "text") . "," .
116  $ilDB->quote($a_attribs["type"], "text") . "," .
117  $ilDB->quote($a_attribs["id"], "text") . ")";
118  $ilDB->manipulate($q);
119  break;
120  }
121  }
122 
130  public function handlerEndTag($a_xml_parser, $a_name)
131  {
132  }
133 
134 
142  public function handlerCharacterData($a_xml_parser, $a_data)
143  {
144  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
145  $a_data = preg_replace("/\n/", "", $a_data);
146  $a_data = preg_replace("/\t+/", "", $a_data);
147 
148  if (!empty($a_data)) {
149  switch ($this->current_tag) {
150  case '':
151  }
152  }
153  }
154 }
global $DIC
Definition: saml.php:7
setHandlers($a_xml_parser)
__construct($a_path, $a_ctype, $a_cname, $a_slot_id, $a_pname)
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
handlerEndTag($a_xml_parser, $a_name)
end tag handler
clearEvents()
Delete the event listeneing information.
handlerCharacterData($a_xml_parser, $a_data)
end tag handler
global $ilDB
Class ilPluginReader.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
start tag handler