ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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, \ilDBInterface $db=null)
 
 setHandlers ($a_xml_parser)
 
 clearTables ()
 clear the tables More...
 
 deleteObjectDefinition ($a_id)
 Delete an object definition (this is currently needed for test cases) 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...
 

Protected Attributes

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

Additional Inherited Members

- 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...
 
- 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,
\ilDBInterface  $db = null 
)

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

References $a_type, $db, $ilDB, $reader, and ILIAS\GlobalScreen\Provider\__construct().

37  {
38  if ($db !== null) {
39  $this->db = $db;
40  } else {
41  global $ilDB;
42  $this->db = $ilDB;
43  }
44  // init specialized readers
45  foreach ($this->readers as $k => $reader) {
46  $class = $reader["class"];
47  $this->readers[$k]["reader"] = new $class($this->db);
48  }
49 
50  $this->name = $a_name;
51  $this->type = $a_type;
52 
53  parent::__construct($a_path);
54  }
$a_type
Definition: workflow.php:92
__construct(Container $dic, ilPlugin $plugin)
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ clearTables()

ilObjDefReader::clearTables ( )

clear the tables

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

References $reader.

67  {
68  $this->db->manipulate("DELETE FROM il_object_def");
69 
70  $this->db->manipulate("DELETE FROM il_object_subobj");
71 
72  $this->db->manipulate("DELETE FROM il_object_group");
73 
74  $this->db->manipulate("DELETE FROM il_pluginslot");
75 
76  $this->db->manipulate("DELETE FROM il_component");
77 
78  // Keep the plugin listeners in the table
79  // This avoids reading them in the setup
80  // ilPluginReader is called in the plugin administration
81  $this->db->manipulate("DELETE FROM il_event_handling WHERE component NOT LIKE 'Plugins/%'");
82 
83  $this->db->manipulate("DELETE FROM il_object_sub_type");
84 
85  foreach ($this->readers as $k => $reader) {
86  $this->readers[$k]["reader"]->clearTables();
87  }
88  }

◆ deleteObjectDefinition()

ilObjDefReader::deleteObjectDefinition (   $a_id)

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

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

94  {
95  $this->db->manipulateF(
96  "DELETE FROM il_object_def WHERE id = %s",
97  array("text"),
98  array($a_id)
99  );
100 
101  $this->db->manipulateF(
102  "DELETE FROM il_object_subobj WHERE parent = %s OR subobj = %s",
103  array("text", "text"),
104  array($a_id, $a_id)
105  );
106  }

◆ getComponentId()

ilObjDefReader::getComponentId ( )

Get component id.

Returns
type

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

References $component_id.

Referenced by handlerBeginTag(), and handlerEndTag().

386  {
387  return $this->component_id;
388  }
+ 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 115 of file class.ilObjDefReader.php.

References $current_reader, Vendor\Package\$e, ActiveRecord\findOrFail(), getComponentId(), ilSCGroups\getInstance(), ilSCTasks\getInstanceByGroupId(), ilMailTemplateContextService\insertFromXML(), ilLogComponentLevels\updateFromXML(), ilPDFCompInstaller\updateFromXML(), ilBadgeHandler\updateFromXML(), and ilCronManager\updateFromXML().

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

361  {
362  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
363  $a_data = preg_replace("/\n/", "", $a_data);
364  $a_data = preg_replace("/\t+/", "", $a_data);
365 
366  if (!empty($a_data)) {
367  switch ($this->current_tag) {
368  case '':
369  }
370  }
371  }

◆ handlerEndTag()

ilObjDefReader::handlerEndTag (   $a_xml_parser,
  $a_name 
)

End tag handler.

Parameters
objectinternal xml_parser_handler
stringelement tag name

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

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

326  {
327  // call special reader
328  if ($this->current_reader != "") {
329  $this->readers[$this->current_reader]["reader"]->handlerEndTag($a_xml_parser, $a_name);
330  } else {
331  if ($a_name == "module" || $a_name == "service") {
333  $this->current_component,
334  ($this->has_cron[$this->current_component] ?? [])
335  );
336 
337  ilMailTemplateContextService::clearFromXml($this->current_component, ($this->mail_templates_by_component[$this->current_component] ?? []));
338 
339  if (!in_array($this->getComponentId(), ($this->has_badges ?? []))) {
340  include_once "Services/Badge/classes/class.ilBadgeHandler.php";
341  ilBadgeHandler::clearFromXml($this->getComponentId());
342  }
343  }
344  }
345 
346  // check if a special reader needs to be activated
347  if (isset($this->readers[$a_name])) {
348  $this->current_reader = null;
349  }
350  }
getComponentId()
Get component id.
static clearFromXml($a_component, array $a_new_templates)
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 376 of file class.ilObjDefReader.php.

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

377  {
378  $this->component_id = $a_component_id;
379  }
+ Here is the caller graph for this function:

◆ setHandlers()

ilObjDefReader::setHandlers (   $a_xml_parser)

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

57  {
58  xml_set_object($a_xml_parser, $this);
59  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
60  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
61  }

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().

◆ $db

ilObjDefReader::$db
protected

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

Referenced by __construct().

◆ $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 34 of file class.ilObjDefReader.php.

◆ $readers

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

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


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