ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjDefReader Class Reference

Component definition reader (reads common tags in module.xml and service.xml files) Name is misleading and should be ilComponentDefReader instead. More...

+ Inheritance diagram for ilObjDefReader:
+ Collaboration diagram for ilObjDefReader:

Public Member Functions

 __construct ($a_path, $a_name, $a_type)
 
 setHandlers ($a_xml_parser)
 
 clearTables ()
 clear the tables More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 Start tag handler. More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 End tag handler. More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 end tag handler More...
 
 setComponentId ($a_component_id)
 Set from module or service reader. More...
 
 getComponentId ()
 Get component id. More...
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Static Public Member Functions

static deleteObjectDefinition ($a_id)
 Delete an object definition (this is currently needed for test cases) More...
 
- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 

Protected Attributes

 $component_id
 
 $readers
 
 $current_reader = null
 
 $in_mail_templates = false
 
 $mail_templates_by_component = array()
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Component definition reader (reads common tags in module.xml and service.xml files) Name is misleading and should be ilComponentDefReader instead.

Reads reads module information of modules.xml files into db

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilObjDefReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjDefReader::__construct (   $a_path,
  $a_name,
  $a_type 
)

Definition at line 31 of file class.ilObjDefReader.php.

References $a_type, and $reader.

32  {
33  // init specialized readers
34  foreach ($this->readers as $k => $reader)
35  {
36  $class = $reader["class"];
37  $class_path = "./setup/classes/class.".$class.".php";
38  include_once($class_path);
39  $this->readers[$k]["reader"] = new $class();
40  }
41 
42  $this->name = $a_name;
43  $this->type = $a_type;
44 //echo "<br>-".$a_path."-".$this->name."-".$this->type."-";
45  parent::__construct($a_path);
46  }
$a_type
Definition: workflow.php:93

Member Function Documentation

◆ clearTables()

ilObjDefReader::clearTables ( )

clear the tables

Definition at line 58 of file class.ilObjDefReader.php.

References $ilDB, and $reader.

59  {
60  global $ilDB;
61 
62  $ilDB->manipulate("DELETE FROM il_object_def");
63 
64  $ilDB->manipulate("DELETE FROM il_object_subobj");
65 
66  $ilDB->manipulate("DELETE FROM il_object_group");
67 
68  $ilDB->manipulate("DELETE FROM il_pluginslot");
69 
70  $ilDB->manipulate("DELETE FROM il_component");
71 
72  $ilDB->manipulate("DELETE FROM il_event_handling");
73 
74  $ilDB->manipulate("DELETE FROM il_object_sub_type");
75 
76  foreach ($this->readers as $k => $reader)
77  {
78  $this->readers[$k]["reader"]->clearTables();
79  }
80  }
global $ilDB

◆ deleteObjectDefinition()

static ilObjDefReader::deleteObjectDefinition (   $a_id)
static

Delete an object definition (this is currently needed for test cases)

Definition at line 85 of file class.ilObjDefReader.php.

References $ilDB, and array.

86  {
87  global $ilDB;
88 
89  $ilDB->manipulateF("DELETE FROM il_object_def WHERE id = %s",
90  array("text"), array($a_id));
91 
92  $ilDB->manipulateF("DELETE FROM il_object_subobj WHERE parent = %s OR subobj = %s",
93  array("text", "text"), array($a_id, $a_id));
94  }
Create styles array
The data for the language used.
global $ilDB

◆ getComponentId()

ilObjDefReader::getComponentId ( )

Get component id.

Returns
type

Definition at line 374 of file class.ilObjDefReader.php.

References $component_id.

Referenced by handlerBeginTag(), and handlerEndTag().

375  {
376  return $this->component_id;
377  }
+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilObjDefReader::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

Start tag handler.

Parameters
ressouceinternal xml_parser_handler
stringelement tag name
arrayelement attributes

Definition at line 103 of file class.ilObjDefReader.php.

References $current_reader, $ilDB, array, ActiveRecord\findOrFail(), getComponentId(), ilSCGroups\getInstance(), ilSCTasks\getInstanceByGroupId(), ilMailTemplateService\insertFromXML(), ilLogComponentLevels\updateFromXML(), ilBadgeHandler\updateFromXML(), and ilCronManager\updateFromXML().

104  {
105  global $ilDB;
106 
107  $this->current_tag = $a_name;
108 
109  // check if a special reader needs to be activated
110  if (isset($this->readers[$a_name]))
111  {
112  $this->current_reader = $a_name;
113  }
114 
115  // call special reader
116  if ($this->current_reader != "")
117  {
118  $this->readers[$this->current_reader]["reader"]->handlerBeginTag($a_xml_parser,$a_name,$a_attribs,
119  $this->current_component);
120  }
121  else
122  {
123  // default handling
124  switch ($a_name)
125  {
126  case 'object':
127 
128  // if attributes are not given, set default (repository only)
129  if($a_attribs["repository"] === NULL)
130  {
131  $a_attribs["repository"] = true;
132  }
133  if($a_attribs["workspace"] === NULL)
134  {
135  $a_attribs["workspace"] = false;
136  }
137 
138  $this->current_object = $a_attribs["id"];
139  $ilDB->manipulateF("INSERT INTO il_object_def (id, class_name, component,location,".
140  "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos,".
141  "default_pres_pos,sideblock,grp,system,export,repository,workspace,administration,amet) VALUES ".
142  "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
143  array("text", "text", "text", "text", "integer", "integer", "text", "integer","integer","integer",
144  "integer","integer","integer","integer", "text", "integer", "integer", "integer", "integer",'integer','integer'),
145  array(
146  $a_attribs["id"],
147  $a_attribs["class_name"],
148  $this->current_component,
149  $this->current_component."/".$a_attribs["dir"],
150  (int) $a_attribs["checkbox"],
151  (int) $a_attribs["inherit"],
152  $a_attribs["translate"],
153  (int) $a_attribs["devmode"],
154  (int) $a_attribs["allow_link"],
155  (int) $a_attribs["allow_copy"],
156  (int) $a_attribs["rbac"],
157  (int) $a_attribs["default_pos"],
158  (int) $a_attribs["default_pres_pos"],
159  (int) $a_attribs["sideblock"],
160  $a_attribs["group"],
161  (int) $a_attribs["system"],
162  (int) $a_attribs["export"],
163  (int) $a_attribs["repository"],
164  (int) $a_attribs["workspace"],
165  (int) $a_attribs['administration'],
166  (int) $a_attribs['amet']
167  ));
168  break;
169 
170  case "subobj":
171  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
172  array("text", "text", "integer"),
173  array($this->current_object, $a_attribs["id"], (int) $a_attribs["max"]));
174  break;
175 
176  case "parent":
177  $ilDB->manipulateF("INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
178  array("text", "text", "integer"),
179  array($a_attribs["id"], $this->current_object, (int) $a_attribs["max"]));
180  break;
181 
182  case "objectgroup":
183  $ilDB->manipulateF("INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
184  array("text", "text", "integer"),
185  array($a_attribs["id"], $a_attribs["name"], $a_attribs["default_pres_pos"]));
186  break;
187 
188  case "pluginslot":
189  $this->current_object = $a_attribs["id"];
190  $q = "INSERT INTO il_pluginslot (component, id, name) VALUES (".
191  $ilDB->quote($this->current_component, "text").",".
192  $ilDB->quote($a_attribs["id"], "text").",".
193  $ilDB->quote($a_attribs["name"], "text").")";
194  $ilDB->manipulate($q);
195  break;
196 
197  case "event":
198  $component = $a_attribs["component"];
199  if(!$component)
200  {
201  $component = $this->current_component;
202  }
203  $q = "INSERT INTO il_event_handling (component, type, id) VALUES (".
204  $ilDB->quote($component, "text").",".
205  $ilDB->quote($a_attribs["type"], "text").",".
206  $ilDB->quote($a_attribs["id"], "text").")";
207  $ilDB->manipulate($q);
208  break;
209 
210  case "cron":
211  $component = $a_attribs["component"];
212  if(!$component)
213  {
214  $component = $this->current_component;
215  }
216  include_once "Services/Cron/classes/class.ilCronManager.php";
217  ilCronManager::updateFromXML($component, $a_attribs["id"], $a_attribs["class"], $a_attribs["path"]);
218  $this->has_cron[$component][] = $a_attribs["id"];
219  break;
220 
221  case 'mailtemplates':
222  $this->in_mail_templates = true;
223  break;
224 
225  case 'context':
226  if(!$this->in_mail_templates)
227  {
228  break;
229  }
230 
231  $component = $a_attribs['component'];
232  if(!$component)
233  {
234  $component = $this->current_component;
235  }
236 
237  require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
239  $component,
240  $a_attribs['id'],
241  $a_attribs['class'],
242  $a_attribs['path']
243  );
244  $this->mail_templates_by_component[$component][] = $a_attribs["id"];
245  break;
246 
247  case "sub_type":
248  $ilDB->manipulate("INSERT INTO il_object_sub_type ".
249  "(obj_type, sub_type, amet) VALUES (".
250  $ilDB->quote($this->current_object, "text").",".
251  $ilDB->quote($a_attribs["id"], "text").",".
252  $ilDB->quote($a_attribs["amet"], "integer").
253  ")");
254  break;
255 
256  case 'systemcheck':
257 
258  include_once './Services/SystemCheck/classes/class.ilSCGroups.php';
259  ilSCGroups::getInstance()->updateFromComponentDefinition($this->getComponentId());
260  break;
261 
262  case 'systemcheck_task':
263  include_once './Services/SystemCheck/classes/class.ilSCGroups.php';
264  $group_id = ilSCGroups::getInstance()->lookupGroupByComponentId($this->getComponentId());
265 
266  include_once './Services/SystemCheck/classes/class.ilSCTasks.php';
267  $tasks = ilSCTasks::getInstanceByGroupId($group_id);
268  $tasks->updateFromComponentDefinition($a_attribs['identifier']);
269  break;
270 
271  case "secure_path":
272  require_once('./Services/WebAccessChecker/classes/class.ilWACSecurePath.php');
273  try {
274  $ilWACSecurePath = ilWACSecurePath::findOrFail($a_attribs["path"]);
275  } catch (arException $e) {
276  $ilWACSecurePath = new ilWACSecurePath();
277  $ilWACSecurePath->setPath($a_attribs["path"]);
278  $ilWACSecurePath->create();
279  }
280  $ilWACSecurePath->setCheckingClass($a_attribs["checking-class"]);
281  $ilWACSecurePath->setInSecFolder((bool)$a_attribs["in-sec-folder"]);
282  $ilWACSecurePath->setComponentDirectory(dirname($this->xml_file));
283  $ilWACSecurePath->update();
284  break;
285 
286  case 'logging':
287  include_once './Services/Logging/classes/class.ilLogComponentLevels.php';
289  break;
290 
291  case 'badges':
292  include_once "Services/Badge/classes/class.ilBadgeHandler.php";
294  $this->has_badges[] = $this->getComponentId();
295  break;
296  }
297  }
298  }
static updateFromXML($a_component, $a_id, $a_class, $a_path=null)
Process data from module.xml/service.xml.
static insertFromXML($a_component, $a_id, $a_class, $a_path)
static updateFromXML($a_component_id)
Import component definition.
Class ilWACSecurePath.
static updateFromXML($a_component_id)
type $ilDB
getComponentId()
Get component id.
static findOrFail($primary_key, array $add_constructor_args=array())
Tries to find the object and throws an Exception if object is not found, instead of returning null...
static getInstance()
Get singleton instance.
static getInstanceByGroupId($a_group_id)
Get singleton instance.
Create styles array
The data for the language used.
Class arException.
global $ilDB
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilObjDefReader::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

end tag handler

Parameters
ressouceinternal xml_parser_handler
stringdata private

Definition at line 347 of file class.ilObjDefReader.php.

348  {
349  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
350  $a_data = preg_replace("/\n/","",$a_data);
351  $a_data = preg_replace("/\t+/","",$a_data);
352 
353  if (!empty($a_data))
354  {
355  switch ($this->current_tag)
356  {
357  case '':
358  }
359  }
360  }

◆ handlerEndTag()

ilObjDefReader::handlerEndTag (   $a_xml_parser,
  $a_name 
)

End tag handler.

Parameters
objectinternal xml_parser_handler
stringelement tag name

Definition at line 306 of file class.ilObjDefReader.php.

References $current_reader, array, ilMailTemplateService\clearFromXml(), ilCronManager\clearFromXML(), and getComponentId().

307  {
308  // call special reader
309  if ($this->current_reader != "")
310  {
311  $this->readers[$this->current_reader]["reader"]->handlerEndTag($a_xml_parser,$a_name);
312  }
313  else
314  {
315  if($a_name == "module" || $a_name == "service")
316  {
317  include_once "Services/Cron/classes/class.ilCronManager.php";
318  ilCronManager::clearFromXML($this->current_component,
319  (array)$this->has_cron[$this->current_component]);
320 
321  require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
322  ilMailTemplateService::clearFromXml($this->current_component, (array)$this->mail_templates_by_component[$this->current_component]);
323 
324  if(!in_array($this->getComponentId(), (array)$this->has_badges))
325  {
326  include_once "Services/Badge/classes/class.ilBadgeHandler.php";
327  ilBadgeHandler::clearFromXml($this->getComponentId());
328  }
329  }
330  }
331 
332  // check if a special reader needs to be activated
333  if (isset($this->readers[$a_name]))
334  {
335  $this->current_reader = null;
336  }
337  }
static clearFromXml($a_component, array $a_new_templates)
getComponentId()
Get component id.
Create styles array
The data for the language used.
static clearFromXML($a_component, array $a_xml_job_ids)
Clear job data.
+ Here is the call graph for this function:

◆ setComponentId()

ilObjDefReader::setComponentId (   $a_component_id)

Set from module or service reader.

Definition at line 365 of file class.ilObjDefReader.php.

Referenced by ilServiceReader\handlerBeginTag(), and ilModuleReader\handlerBeginTag().

366  {
367  $this->component_id = $a_component_id;
368  }
+ Here is the caller graph for this function:

◆ setHandlers()

ilObjDefReader::setHandlers (   $a_xml_parser)

Definition at line 48 of file class.ilObjDefReader.php.

49  {
50  xml_set_object($a_xml_parser,$this);
51  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
52  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
53  }

Field Documentation

◆ $component_id

ilObjDefReader::$component_id
protected

Definition at line 17 of file class.ilObjDefReader.php.

Referenced by getComponentId().

◆ $current_reader

ilObjDefReader::$current_reader = null
protected

Definition at line 22 of file class.ilObjDefReader.php.

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $in_mail_templates

ilObjDefReader::$in_mail_templates = false
protected

Definition at line 24 of file class.ilObjDefReader.php.

◆ $mail_templates_by_component

ilObjDefReader::$mail_templates_by_component = array()
protected

Definition at line 29 of file class.ilObjDefReader.php.

◆ $readers

ilObjDefReader::$readers
protected
Initial value:
"copage" => array("class" => "ilCOPageDefReader")
)

Definition at line 19 of file class.ilObjDefReader.php.


The documentation for this class was generated from the following file: