ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomXMLWriter Class Reference

Class ilChatroomXMLWriter. More...

+ Inheritance diagram for ilChatroomXMLWriter:
+ Collaboration diagram for ilChatroomXMLWriter:

Public Member Functions

 __construct (ilObjChatroom $chat)
 
 start ()
 
 getXML ()
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Protected Attributes

ilObjChatroom $chat
 
ilChatroom $room
 

Private Member Functions

 exportData ()
 

Detailed Description

Class ilChatroomXMLWriter.

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

Constructor & Destructor Documentation

◆ __construct()

ilChatroomXMLWriter::__construct ( ilObjChatroom  $chat)

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

References $chat, ILIAS\GlobalScreen\Provider\__construct(), and ilChatroom\byObjectId().

30  {
31  $this->chat = $chat;
32 
33  $this->room = ilChatroom::byObjectId($this->chat->getId());
34  if (!$this->room) {
35  $this->room = new ilChatroom();
36  $this->room->setSetting('object_id', $this->chat->getId());
37  }
38 
40  }
Class ilChatroom.
__construct(Container $dic, ilPlugin $plugin)
static byObjectId(int $object_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ exportData()

ilChatroomXMLWriter::exportData ( )
private

Definition at line 66 of file class.ilChatroomXMLWriter.php.

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

66  : void
67  {
68  $privateRooms = $this->room->getPrivateRooms();
69  if (count($privateRooms) > 0) {
70  $this->xmlStartTag('SubRooms');
71  foreach ($privateRooms as $privateRoom) {
72  $this->xmlStartTag('SubRoom');
73  $this->xmlElement('SubRoomId', null, (string) ((int) $privateRoom['proom_id']));
74  $this->xmlElement('Title', null, (string) $privateRoom['title']);
75  $this->xmlElement('Owner', null, (string) ((int) $privateRoom['owner']));
76  $this->xmlElement('Closed', null, (string) ((int) $privateRoom['closed']));
77  $this->xmlElement('Public', null, (string) ((int) $privateRoom['is_public']));
78  $this->xmlElement('CreatedTimestamp', null, (string) ((int) $privateRoom['created']));
79 
80  foreach ($this->room->getPrivilegedUsersForPrivateRoom((int) $privateRoom['proom_id']) as $usrId) {
81  $this->xmlElement('PrivilegedUserId', null, (string) $usrId);
82  }
83 
84  $this->xmlEndTag('SubRoom');
85  }
86  $this->xmlEndTag('SubRooms');
87  }
88 
89  $history = $this->room->getHistory(null, null, null, null, false);
90  if (count($history) > 0) {
91  $this->xmlStartTag('Messages');
92  foreach ($history as $entry) {
93  $this->xmlStartTag('Message');
94  $this->xmlElement('SubRoomId', null, (string) ((int) $entry['sub_room']));
95  $this->xmlElement('Body', null, json_encode($entry['message'], JSON_THROW_ON_ERROR));
96  $this->xmlElement('CreatedTimestamp', null, (string) ((int) $entry['timestamp']));
97  $this->xmlEndTag('Message');
98  }
99  $this->xmlEndTag('Messages');
100  }
101  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilChatroomXMLWriter::getXML ( )

Definition at line 103 of file class.ilChatroomXMLWriter.php.

References ilXmlWriter\xmlDumpMem().

103  : string
104  {
105  // Replace ascii code 11 characters because of problems with xml sax parser
106  return str_replace('', '', $this->xmlDumpMem(false));
107  }
xmlDumpMem(bool $format=true)
Returns xml document from memory.
+ Here is the call graph for this function:

◆ start()

ilChatroomXMLWriter::start ( )

Definition at line 42 of file class.ilChatroomXMLWriter.php.

References exportData(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

42  : void
43  {
44  $this->xmlStartTag('Chatroom');
45 
46  $this->xmlElement('ObjId', null, (string) $this->chat->getId());
47  $this->xmlElement('RoomId', null, (string) $this->room->getRoomId());
48  $this->xmlElement('Title', null, $this->chat->getTitle());
49  $this->xmlElement('Description', null, $this->chat->getDescription());
50  $this->xmlElement('OnlineStatus', null, (string) ((int) $this->room->getSetting('online_status')));
51  $this->xmlElement('AllowAnonymousAccess', null, (string) ((int) $this->room->getSetting('allow_anonymous')));
52  $this->xmlElement('AllowCustomUsernames', null, (string) ((int) $this->room->getSetting('allow_custom_usernames')));
53  $this->xmlElement('EnableHistory', null, (string) ((int) $this->room->getSetting('enable_history')));
54  $this->xmlElement('RestrictHistory', null, (string) ((int) $this->room->getSetting('restrict_history')));
55  $this->xmlElement('PrivateRoomsEnabled', null, (string) ((int) $this->room->getSetting('private_rooms_enabled')));
56  $this->xmlElement('DisplayPastMessages', null, (string) ((int) $this->room->getSetting('display_past_msgs')));
57  $this->xmlElement('AutoGeneratedUsernameSchema', null, (string) $this->room->getSetting('autogen_usernames'));
58 
59  if ($this->room->getRoomId() > 0) {
60  $this->exportData();
61  }
62 
63  $this->xmlEndTag('Chatroom');
64  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

Field Documentation

◆ $chat

ilObjChatroom ilChatroomXMLWriter::$chat
protected

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

Referenced by __construct().

◆ $room

ilChatroom ilChatroomXMLWriter::$room
protected

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


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