ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilManifestParser.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /******************************************************************************
6  *
7  * This file is part of ILIAS, a powerful learning management system.
8  *
9  * ILIAS is licensed with the GPL-3.0, you should have received a copy
10  * of said license along with the source code.
11  *
12  * If this is not the case or you just want to try ILIAS, you'll find
13  * us at:
14  * https://www.ilias.de
15  * https://github.com/ILIAS-eLearning
16  *
17  *****************************************************************************/
23 {
24  protected string $chr_data = '';
25  protected string $target_release = '';
26  protected string $title = '';
27  protected string $main_entity = '';
28  protected string $install_id = '';
29  protected string $install_url = '';
30  protected array $expfiles = array();
31  protected array $expsets = array();
32 
33  public function __construct(string $a_file)
34  {
35  parent::__construct($a_file, true);
36  $this->startParsing();
37  }
38 
39  final public function setInstallId(string $a_val): void
40  {
41  $this->install_id = $a_val;
42  }
43 
44  final public function getInstallId(): string
45  {
46  return $this->install_id;
47  }
48 
49  final public function setInstallUrl(string $a_val): void
50  {
51  $this->install_url = $a_val;
52  }
53 
54  final public function getInstallUrl(): string
55  {
56  return $this->install_url;
57  }
58 
59  public function setMainEntity(string $a_val): void
60  {
61  $this->main_entity = $a_val;
62  }
63 
64  public function getMainEntity(): string
65  {
66  return $this->main_entity;
67  }
68 
69  public function setTitle(string $a_val): void
70  {
71  $this->title = $a_val;
72  }
73 
74  public function getTitle(): string
75  {
76  return $this->title;
77  }
78 
79  /*
80  public function setTargetRelease(string $a_val): void
81  {
82  $this->target_release = $a_val;
83  }*/
84 
85 
86  /*
87  public function getTargetRelease(): string
88  {
89  return $this->target_release;
90  }*/
91 
92  public function getExportFiles(): array
93  {
94  return $this->expfiles;
95  }
96 
97  public function getExportSets(): array
98  {
99  return $this->expsets;
100  }
101 
108  public function setHandlers($a_xml_parser): void
109  {
110  xml_set_object($a_xml_parser, $this);
111  xml_set_element_handler($a_xml_parser, 'handleBeginTag', 'handleEndTag');
112  xml_set_character_data_handler($a_xml_parser, 'handleCharacterData');
113  }
114 
118  public function handleBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
119  {
120  switch ($a_name) {
121  case "Manifest":
122  $this->setInstallId($a_attribs["InstallationId"]);
123  $this->setInstallUrl($a_attribs["InstallationUrl"]);
124  $this->setTitle($a_attribs["Title"]);
125  //$this->setTargetRelease($a_attribs["TargetRelease"]);
126  $this->setMainEntity($a_attribs["MainEntity"]);
127  break;
128 
129  case "ExportFile":
130  $this->expfiles[] = array("component" => $a_attribs["Component"],
131  "path" => $a_attribs["Path"]
132  );
133  break;
134 
135  case "ExportSet":
136  $this->expsets[] = array(
137  'path' => $a_attribs['Path'],
138  'type' => $a_attribs['Type']
139  );
140  break;
141  }
142  }
143 
147  public function handleEndTag($a_xml_parser, string $a_name): void
148  {
149  $this->chr_data = "";
150  }
151 
155  public function handleCharacterData($a_xml_parser, string $a_data): void
156  {
157  //$a_data = str_replace("<","&lt;",$a_data);
158  //$a_data = str_replace(">","&gt;",$a_data);
159  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
160  //$a_data = preg_replace("/\n/","",$a_data);
161  //$a_data = preg_replace("/\t+/","",$a_data);
162 
163  $this->chr_data .= $a_data;
164  }
165 }
setHandlers($a_xml_parser)
Set event handlers.
startParsing()
stores xml data in array
handleBeginTag($a_xml_parser, string $a_name, array $a_attribs)
Begin Tag.
setInstallId(string $a_val)
handleCharacterData($a_xml_parser, string $a_data)
End Tag.
setMainEntity(string $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handleEndTag($a_xml_parser, string $a_name)
End Tag.
Manifest parser for ILIAS standard export files.
__construct(Container $dic, ilPlugin $plugin)
setInstallUrl(string $a_val)
__construct(string $a_file)