ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFolderXmlParser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
30 protected string $cdata = "";
31
32 public function __construct(ilObject $folder, string $xml)
33 {
34 global $DIC;
35
36 $this->error = $DIC["ilErr"];
38 $this->setXMLContent($xml);
39 $this->setFolder($folder);
40 $this->setThrowException(true);
41 }
42
43 public function setFolder(ilObject $folder): void
44 {
45 $this->folder = $folder;
46 }
47
48 public function getFolder(): ilObject
49 {
50 return $this->folder;
51 }
52
56 public function start(): void
57 {
58 $this->startParsing();
59 }
60
61 public function setHandlers($a_xml_parser): void
62 {
63 xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
64 xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
65 }
66
73 public function handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
74 {
75 switch ($a_name) {
76 case 'Folder':
77 case 'Title':
78 case 'Description':
79 break;
80
81 case 'Sorting':
82 case 'Sort':
84 break;
85 }
86 }
87
93 public function handlerEndTag($a_xml_parser, string $a_name): void
94 {
95 $GLOBALS['ilLog']->write(__METHOD__ . ': Called ' . $a_name);
96
97 switch ($a_name) {
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 // Reset cdata
112 $this->cdata = '';
113 }
114
120 public function handlerCharacterData($a_xml_parser, string $a_data): void
121 {
122 if ($a_data !== "\n") {
123 // Replace multiple tabs with one space
124 $a_data = preg_replace("/\t+/", " ", $a_data);
125 $this->cdata .= $a_data;
126 }
127 }
128}
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.
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)
Class ilObject Basic functions for all objects.
setXMLContent(string $a_xml_content)
setThrowException(bool $throw_exception)
startParsing()
stores xml data in array
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54