ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExportFileParser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 private string $entity = '';
28 private string $install_id = '';
29 private string $install_url = '';
30 private string $schema_version = '';
31 // currently not used.
32 private array $expfiles = [];
33 private string $current_id = '';
34 protected string $item_xml = "";
35 protected bool $in_export_item = false;
36 protected string $chr_data = "";
37
38 private object $callback_obj;
39 private string $callback_func;
41
46 public function __construct(string $a_file, object $a_callback_obj, string $a_callback_func)
47 {
48 $this->callback_obj = $a_callback_obj;
49 $this->callback_func = $a_callback_func;
50
51 parent::__construct($a_file, true);
52 $this->startParsing();
53 }
54
58 public function setHandlers($a_xml_parser): void
59 {
60 xml_set_element_handler($a_xml_parser, $this->handleBeginTag(...), $this->handleEndTag(...));
61 xml_set_character_data_handler($a_xml_parser, $this->handleCharacterData(...));
62 }
63
67 public function startParsing(): void
68 {
69 parent::startParsing();
70 }
71
72 public function handleBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
73 {
74 if ($this->in_export_item) {
75 $this->export_item_writer->xmlStartTag($a_name, $a_attribs);
76 }
77
78 switch ($a_name) {
79 case "exp:Export":
80 $this->entity = $a_attribs["Entity"];
81 $this->install_id = $a_attribs["InstallationId"];
82 $this->install_url = $a_attribs["InstallationUrl"];
83 $this->schema_version = $a_attribs["SchemaVersion"];
84 break;
85
86 case "exp:ExportItem":
87 $this->in_export_item = true;
88 $this->current_id = $a_attribs["Id"];
89 $this->export_item_writer = new ilXmlWriter();
90 $this->item_xml = "";
91 $this->expfiles[] = array(
92 "component" => $a_attribs["Component"] ?? null,
93 "path" => $a_attribs["Path"] ?? null
94 );
95 break;
96 }
97 }
98
99 public function handleEndTag($a_xml_parser, string $a_name): void
100 {
101 switch ($a_name) {
102 case "exp:ExportItem":
103 $this->in_export_item = false;
105 $this->callback_obj->$cf(
106 $this->entity,
107 $this->schema_version,
108 $this->current_id,
109 $this->export_item_writer->xmlDumpMem(false),
110 $this->install_id,
111 $this->install_url
112 );
113 break;
114 }
115
116 if ($this->in_export_item) {
117 $this->export_item_writer->xmlEndTag($a_name);
118 }
119
120 $this->chr_data = "";
121 }
122
126 public function handleCharacterData($a_xml_parser, string $a_data): void
127 {
128 $this->chr_data .= $a_data;
129 if ($this->in_export_item) {
130 $this->export_item_writer->xmlData($a_data);
131 }
132 }
133}
handleBeginTag($a_xml_parser, string $a_name, array $a_attribs)
handleEndTag($a_xml_parser, string $a_name)
setHandlers($a_xml_parser)
@inheritDoc
__construct(string $a_file, object $a_callback_obj, string $a_callback_func)
ilExportFileParser constructor.
handleCharacterData($a_xml_parser, string $a_data)
End Tag.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc