ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomXMLParser Class Reference
+ Inheritance diagram for ilChatroomXMLParser:
+ Collaboration diagram for ilChatroomXMLParser:

Public Member Functions

 __construct (protected ilObjChatroom $chat, string $a_xml_data)
 
 setImportInstallId (?string $id)
 
 getImportInstallId ()
 
 setHandlers ($a_xml_parser)
 
 handlerBeginTag (XMLParser $a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag (XMLParser $a_xml_parser, string $a_name)
 
 handlerCharacterData (XMLParser $a_xml_parser, string $a_data)
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Protected Attributes

ilChatroom $room
 
string $cdata = ''
 
bool $in_messages = false
 
string $import_install_id = null
 
int $exportRoomId = 0
 
int $timestamp = 0
 
string $message = ''
 
string $title = ''
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Member Functions

 isSameInstallation ()
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Detailed Description

Definition at line 21 of file class.ilChatroomXMLParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomXMLParser::__construct ( protected ilObjChatroom  $chat,
string  $a_xml_data 
)

Definition at line 32 of file class.ilChatroomXMLParser.php.

33 {
35
36 $room = ilChatroom::byObjectId($this->chat->getId());
37 if ($room !== null) {
38 $this->room = $room;
39 } else {
40 $this->room = new ilChatroom();
41 $this->room->setSetting('object_id', $this->chat->getId());
42 $this->room->save();
43 }
44
45 $this->setXMLContent('<?xml version="1.0" encoding="utf-8"?>' . $a_xml_data);
46 }
Class ilChatroom.
static byObjectId(int $object_id)
setXMLContent(string $a_xml_content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $room, ILIAS\GlobalScreen\Provider\__construct(), ilChatroom\byObjectId(), and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getImportInstallId()

ilChatroomXMLParser::getImportInstallId ( )

Definition at line 53 of file class.ilChatroomXMLParser.php.

53 : ?string
54 {
56 }

References $import_install_id.

Referenced by isSameInstallation().

+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilChatroomXMLParser::handlerBeginTag ( XMLParser  $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
array<string,string>$a_attribs

Definition at line 72 of file class.ilChatroomXMLParser.php.

72 : void
73 {
74 switch ($a_name) {
75 case 'Messages':
76 $this->in_messages = true;
77 break;
78 }
79 }

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilChatroomXMLParser::handlerCharacterData ( XMLParser  $a_xml_parser,
string  $a_data 
)

Definition at line 161 of file class.ilChatroomXMLParser.php.

161 : void
162 {
163 if ($a_data !== "\n") {
164 $this->cdata .= preg_replace("/\t+/", ' ', $a_data);
165 }
166 }

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerEndTag()

ilChatroomXMLParser::handlerEndTag ( XMLParser  $a_xml_parser,
string  $a_name 
)

Definition at line 81 of file class.ilChatroomXMLParser.php.

81 : void
82 {
83 $this->cdata = trim($this->cdata);
84
85 switch ($a_name) {
86 case 'Title':
87 $this->chat->setTitle(ilUtil::stripSlashes($this->cdata));
88 break;
89
90 case 'Description':
91 $this->chat->setDescription(ilUtil::stripSlashes($this->cdata));
92 break;
93
94 case 'OnlineStatus':
95 $this->chat->setOfflineStatus(
96 ((int) $this->cdata) === 0
97 );
98 break;
99
100 case 'AllowAnonymousAccess':
101 $this->room->setSetting('allow_anonymous', (int) $this->cdata);
102 break;
103
104 case 'AllowCustomUsernames':
105 $this->room->setSetting('allow_custom_usernames', (int) $this->cdata);
106 break;
107
108 case 'EnableHistory':
109 $this->room->setSetting('enable_history', (int) $this->cdata);
110 break;
111
112 case 'DisplayPastMessages':
113 $this->room->setSetting('display_past_msgs', (int) $this->cdata);
114 break;
115
116 case 'AutoGeneratedUsernameSchema':
117 $this->room->setSetting('autogen_usernames', ilUtil::stripSlashes($this->cdata));
118 break;
119
120 case 'RoomId':
121 $this->exportRoomId = (int) $this->cdata;
122 break;
123
124 case 'CreatedTimestamp':
125 $this->timestamp = (int) $this->cdata;
126 break;
127
128 case 'Body':
129 $this->message = $this->cdata;
130 break;
131
132 case 'Message':
133 break;
134
135 case 'Messages':
136 if ($this->isSameInstallation()) {
137 $message = json_decode($this->message, true, 512, JSON_THROW_ON_ERROR);
138 if (is_array($message)) {
139 $message['roomId'] = $this->room->getRoomId();
140 $message['timestamp'] = $this->timestamp;
141
142 $this->room->addHistoryEntry($message);
143 }
144 }
145
146 $this->timestamp = 0;
147 $this->in_messages = false;
148 break;
149
150 case 'Chatroom':
151 // Set imported chats to offline
152 $this->chat->setOfflineStatus(true);
153 $this->chat->update();
154 $this->room->save();
155 break;
156 }
157
158 $this->cdata = '';
159 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References $cdata, $message, $timestamp, ILIAS\Repository\int(), isSameInstallation(), and ilUtil\stripSlashes().

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSameInstallation()

ilChatroomXMLParser::isSameInstallation ( )
private

Definition at line 58 of file class.ilChatroomXMLParser.php.

58 : bool
59 {
60 return defined('IL_INST_ID') && IL_INST_ID > 0 && $this->getImportInstallId() == IL_INST_ID;
61 }
const IL_INST_ID
Definition: constants.php:40

References getImportInstallId(), and IL_INST_ID.

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilChatroomXMLParser::setHandlers (   $a_xml_parser)
Parameters
XMLParser | resource$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

Definition at line 63 of file class.ilChatroomXMLParser.php.

63 : void
64 {
65 xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
66 xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
67 }
handlerEndTag(XMLParser $a_xml_parser, string $a_name)
handlerBeginTag(XMLParser $a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData(XMLParser $a_xml_parser, string $a_data)

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

+ Here is the call graph for this function:

◆ setImportInstallId()

ilChatroomXMLParser::setImportInstallId ( ?string  $id)

Definition at line 48 of file class.ilChatroomXMLParser.php.

48 : void
49 {
50 $this->import_install_id = $id;
51 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Field Documentation

◆ $cdata

string ilChatroomXMLParser::$cdata = ''
protected

Definition at line 24 of file class.ilChatroomXMLParser.php.

Referenced by handlerEndTag().

◆ $exportRoomId

int ilChatroomXMLParser::$exportRoomId = 0
protected

Definition at line 27 of file class.ilChatroomXMLParser.php.

◆ $import_install_id

string ilChatroomXMLParser::$import_install_id = null
protected

Definition at line 26 of file class.ilChatroomXMLParser.php.

Referenced by getImportInstallId().

◆ $in_messages

bool ilChatroomXMLParser::$in_messages = false
protected

Definition at line 25 of file class.ilChatroomXMLParser.php.

◆ $message

string ilChatroomXMLParser::$message = ''
protected

Definition at line 29 of file class.ilChatroomXMLParser.php.

Referenced by handlerEndTag().

◆ $room

ilChatroom ilChatroomXMLParser::$room
protected

Definition at line 23 of file class.ilChatroomXMLParser.php.

Referenced by __construct().

◆ $timestamp

int ilChatroomXMLParser::$timestamp = 0
protected

Definition at line 28 of file class.ilChatroomXMLParser.php.

Referenced by handlerEndTag().

◆ $title

string ilChatroomXMLParser::$title = ''
protected

Definition at line 30 of file class.ilChatroomXMLParser.php.


The documentation for this class was generated from the following file: