ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilChatroomXMLWriter Class Reference

Class ilChatroomXMLWriter. More...

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

Public Member Functions

 __construct (ilObjChatroom $chat)
 ilChatroomXMLWriter constructor. More...
 
 start ()
 
 getXML ()
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr public More...
 

Protected Attributes

 $chat
 
 $room
 

Private Member Functions

 exportData ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Detailed Description

Class ilChatroomXMLWriter.

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

Constructor & Destructor Documentation

◆ __construct()

ilChatroomXMLWriter::__construct ( ilObjChatroom  $chat)

ilChatroomXMLWriter constructor.

Parameters
ilObjChatroom$chat

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

References $chat, and ilChatroom\byObjectId().

27  {
28  $this->chat = $chat;
29 
30  $this->room = ilChatroom::byObjectId($this->chat->getId());
31  if (!$this->room) {
32  $this->room = new ilChatroom();
33  $this->room->setSetting('object_id', $this->chat->getId());
34  }
35 
36  parent::__construct();
37  }
Class ilChatroom.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ Here is the call graph for this function:

Member Function Documentation

◆ exportData()

ilChatroomXMLWriter::exportData ( )
private

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

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

Referenced by start().

70  {
71  $privateRooms = $this->room->getPrivateRooms();
72  if (count($privateRooms) > 0) {
73  $this->xmlStartTag('SubRooms', null);
74  foreach ($privateRooms as $privateRoom) {
75  $this->xmlStartTag('SubRoom', null);
76  $this->xmlElement('SubRoomId', null, (int) $privateRoom['proom_id']);
77  $this->xmlElement('Title', null, $privateRoom['title']);
78  $this->xmlElement('Owner', null, (int) $privateRoom['owner']);
79  $this->xmlElement('Closed', null, (int) $privateRoom['closed']);
80  $this->xmlElement('Public', null, (int) $privateRoom['is_public']);
81  $this->xmlElement('CreatedTimestamp', null, (int) $privateRoom['created']);
82 
83  foreach ($this->room->getPrivilegedUsersForPrivateRoom((int) $privateRoom['proom_id']) as $usrId) {
84  $this->xmlElement('PrivilegedUserId', null, $usrId);
85  }
86 
87  $this->xmlEndTag('SubRoom');
88  }
89  $this->xmlEndTag('SubRooms');
90  }
91 
92  $history = $this->room->getHistory(null, null, null, null, false);
93  if (count($history) > 0) {
94  $this->xmlStartTag('Messages', null);
95  foreach ($history as $entry) {
96  $this->xmlStartTag('Message', null);
97  $this->xmlElement('SubRoomId', null, (int) $entry['sub_room']);
98  $this->xmlElement('Body', null, json_encode($entry['message']));
99  $this->xmlElement('CreatedTimestamp', null, (int) $entry['timestamp']);
100  $this->xmlEndTag('Message');
101  }
102  $this->xmlEndTag('Messages');
103  }
104  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
xmlElement($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 ( )
Returns
string

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

References ilXmlWriter\xmlDumpMem().

110  {
111  // Replace ascii code 11 characters because of problems with xml sax parser
112  return str_replace('', '', $this->xmlDumpMem(false));
113  }
xmlDumpMem($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().

43  {
44  $this->xmlStartTag('Chatroom', null);
45 
46  $this->xmlElement('ObjId', null, (int) $this->chat->getId());
47  $this->xmlElement('RoomId', null, (int) $this->room->getRoomId());
48  $this->xmlElement('Title', null, $this->chat->getTitle());
49  $this->xmlElement('Description', null, $this->chat->getDescription());
50  $this->xmlElement('OnlineStatus', null, (int) $this->room->getSetting('online_status'));
51  $this->xmlElement('AllowAnonymousAccess', null, (int) $this->room->getSetting('allow_anonymous'));
52  $this->xmlElement('AllowCustomUsernames', null, (int) $this->room->getSetting('allow_custom_usernames'));
53  $this->xmlElement('EnableHistory', null, (int) $this->room->getSetting('enable_history'));
54  $this->xmlElement('RestrictHistory', null, (int) $this->room->getSetting('restrict_history'));
55  $this->xmlElement('PrivateRoomsEnabled', null, (int) $this->room->getSetting('private_rooms_enabled'));
56  $this->xmlElement('DisplayPastMessages', null, (int) $this->room->getSetting('display_past_msgs'));
57  $this->xmlElement('AutoGeneratedUsernameSchema', null, $this->room->getSetting('autogen_usernames'));
58 
59  if ((int) $this->room->getRoomId() > 0) {
60  $this->exportData();
61  }
62 
63  $this->xmlEndTag('Chatroom');
64  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
xmlElement($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

ilChatroomXMLWriter::$chat
protected

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

Referenced by __construct().

◆ $room

ilChatroomXMLWriter::$room
protected

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


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