ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCOPageDefinitionProcessor.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 2021 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
8 {
9  protected \ilDBInterface $db;
10  protected ?string $component = null;
11  protected ?string $type = null;
12 
13  public function __construct(\ilDBInterface $db)
14  {
15  $this->db = $db;
16  }
17 
18  public function purge(): void
19  {
20  $this->db->manipulate("DELETE FROM copg_pc_def");
21  $this->db->manipulate("DELETE FROM copg_pobj_def");
22  }
23 
24  public function beginComponent(string $component, string $type): void
25  {
26  $this->component = $component;
27  $this->type = $type;
28  }
29 
30  public function endComponent(string $component, string $type): void
31  {
32  $this->component = null;
33  $this->type = null;
34  }
35 
36  public function beginTag(string $name, array $attributes): void
37  {
38  switch ($name) {
39  case "pagecontent":
40  $this->db->manipulate("INSERT INTO copg_pc_def " .
41  "(pc_type, name, component, directory, int_links, style_classes, xsl, def_enabled, top_item, order_nr) VALUES (" .
42  $this->db->quote($attributes["pc_type"], "text") . "," .
43  $this->db->quote($attributes["name"], "text") . "," .
44  $this->db->quote($this->type . "/" . $this->component, "text") . "," .
45  $this->db->quote($attributes["directory"], "text") . "," .
46  $this->db->quote($attributes["int_links"], "integer") . "," .
47  $this->db->quote($attributes["style_classes"], "integer") . "," .
48  $this->db->quote($attributes["xsl"], "integer") . "," .
49  $this->db->quote($attributes["def_enabled"], "integer") . "," .
50  $this->db->quote($attributes["top_item"], "integer") . "," .
51  $this->db->quote($attributes["order_nr"], "integer") .
52  ")");
53  break;
54 
55  case "pageobject":
56  $this->db->manipulate("INSERT INTO copg_pobj_def " .
57  "(parent_type, class_name, component, directory) VALUES (" .
58  $this->db->quote($attributes["parent_type"], "text") . "," .
59  $this->db->quote($attributes["class_name"], "text") . "," .
60  $this->db->quote($this->type . "/" . $this->component, "text") . "," .
61  $this->db->quote($attributes["directory"], "text") .
62  ")");
63  break;
64  }
65  }
66 
67  public function endTag(string $name): void
68  {
69  }
70 }
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends. ...
$attributes
Definition: metadata.php:248
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i.e.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
if($format !==null) $name
Definition: metadata.php:247
endTag(string $name)
This is called when a tag ends in the context of the given component.