ILIAS  release_8 Revision v8.24
class.ilFolderXmlParser.php
Go to the documentation of this file.
1<?php
2
3declare(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 *****************************************************************************/
24{
27 protected string $cdata = "";
28
29 public function __construct(ilObject $folder, string $xml)
30 {
31 global $DIC;
32
33 $this->error = $DIC["ilErr"];
35 $this->setXMLContent($xml);
36 $this->setFolder($folder);
37 $this->setThrowException(true);
38 }
39
40 public function setFolder(ilObject $folder): void
41 {
42 $this->folder = $folder;
43 }
44
45 public function getFolder(): ilObject
46 {
47 return $this->folder;
48 }
49
53 public function start(): void
54 {
55 $this->startParsing();
56 }
57
58 public function setHandlers($a_xml_parser): void
59 {
60 xml_set_object($a_xml_parser, $this);
61 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
62 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
63 }
64
71 public function handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
72 {
73 switch ($a_name) {
74
75 case 'Folder':
76 case 'Title':
77 case 'Description':
78 break;
79
80 case 'Sorting':
81 case 'Sort':
83 break;
84 }
85 }
86
92 public function handlerEndTag($a_xml_parser, string $a_name): void
93 {
94 $GLOBALS['ilLog']->write(__METHOD__ . ': Called ' . $a_name);
95
96 switch ($a_name) {
97
98 case 'Folder':
99 $this->getFolder()->update();
100 break;
101
102 case 'Title':
103 $this->getFolder()->setTitle($this->trimAndStrip((string) $this->cdata));
104 break;
105
106 case 'Description':
107 $this->getFolder()->setDescription($this->trimAndStrip((string) $this->cdata));
108 break;
109
110 }
111
112 // Reset cdata
113 $this->cdata = '';
114 }
115
121 public function handlerCharacterData($a_xml_parser, string $a_data): void
122 {
123 if ($a_data !== "\n") {
124 // Replace multiple tabs with one space
125 $a_data = preg_replace("/\t+/", " ", $a_data);
126 $this->cdata .= $a_data;
127 }
128 }
129}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
error(string $a_errmsg)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _importContainerSortingSettings(array $attibs, int $obj_id)
sorting import for all container objects
Error Handling & global info handling uses PEAR error class.
XML parser for folder xml.
handlerEndTag($a_xml_parser, string $a_name)
setFolder(ilObject $folder)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
__construct(ilObject $folder, string $xml)
handlerCharacterData($a_xml_parser, string $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setXMLContent(string $a_xml_content)
setThrowException(bool $throw_exception)
startParsing()
stores xml data in array
global $DIC
Definition: feed.php:28
$xml
Definition: metadata.php:351
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc