ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilChatroomHistoryGUI Class Reference
+ Inheritance diagram for ilChatroomHistoryGUI:
+ Collaboration diagram for ilChatroomHistoryGUI:

Public Member Functions

 byDayExport ()
 
 executeDefault (string $requestedMethod)
 
- Public Member Functions inherited from ilChatroomGUIHandler
 execute (string $method)
 
 executeDefault (string $requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 
 hasPermission (string $permission)
 

Private Member Functions

 renderDateTimeInformation ( $room_tpl, ?ilDateTime &$prev_date_time, ilDateTime $message_date_time, ilDate $message_date, ?string &$prev_date_time_presentation, string $message_date_time_presentation, string $time_format)
 
 showMessages (array $messages, ilPropertyFormGUI $durationForm, bool $export=false, ?ilDateTime $from=null, ?ilDateTime $to=null, $room=null)
 

Additional Inherited Members

- Protected Member Functions inherited from ilChatroomGUIHandler
 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
 sendJSONResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 sendResponse (string $content, string $type)
 Sends a response and exits the php process. More...
 
- Protected Attributes inherited from ilChatroomGUIHandler
ilObjUser $ilUser
 
ilCtrlInterface $ilCtrl
 
ilLanguage $ilLng
 
Filesystem $webDirectory
 
ilObjectService $obj_service
 
FileUpload $upload
 
ilRbacSystem $rbacsystem
 
ilGlobalTemplateInterface $mainTpl
 
ILIAS $ilias
 
ilNavigationHistory $navigationHistory
 
ilTree $tree
 
ilTabsGUI $tabs
 
UIFactory $uiFactory
 
UIRenderer $uiRenderer
 
GlobalHttpState $http
 
Refinery $refinery
 

Detailed Description

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

Member Function Documentation

◆ byDayExport()

ilChatroomHistoryGUI::byDayExport ( )

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

References $messages, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ILIAS\FileDelivery\http(), null, showMessages(), and ILIAS\Repository\tabs().

69  : void
70  {
71  $this->tabs->activateSubTab('byday');
72  $this->byDay(true);
73  }
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomHistoryGUI::executeDefault ( string  $requestedMethod)

Definition at line 224 of file class.ilChatroomHistoryGUI.php.

224  : void
225  {
226  $this->byDay();
227  }

◆ renderDateTimeInformation()

ilChatroomHistoryGUI::renderDateTimeInformation (   $room_tpl,
?ilDateTime $prev_date_time,
ilDateTime  $message_date_time,
ilDate  $message_date,
?string &  $prev_date_time_presentation,
string  $message_date_time_presentation,
string  $time_format 
)
private
Parameters
ilTemplate | ilGlobalTemplate$room_tpl

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

References ilDatePresentation\formatDate(), ilDateTime\get(), IL_CAL_FKT_DATE, IL_CAL_UNIX, null, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by showMessages().

34  : void {
35  $render_parts = [];
36 
37  if (null === $prev_date_time ||
38  date('d', $prev_date_time->get(IL_CAL_UNIX)) !== date('d', $message_date_time->get(IL_CAL_UNIX)) ||
39  date('m', $prev_date_time->get(IL_CAL_UNIX)) !== date('m', $message_date_time->get(IL_CAL_UNIX)) ||
40  date('Y', $prev_date_time->get(IL_CAL_UNIX)) !== date('Y', $message_date_time->get(IL_CAL_UNIX))
41  ) {
42  $render_parts['MESSAGEDATE'] = ilDatePresentation::formatDate($message_date);
43  $prev_date_time = $message_date_time;
44  }
45 
46  if ($prev_date_time_presentation !== $message_date_time_presentation) {
47  $date_string = match ($time_format) {
48  (string) ilCalendarSettings::TIME_FORMAT_24 => $message_date_time->get(
50  'H:i',
51  $this->ilUser->getTimeZone()
52  ),
53  default => $message_date_time->get(IL_CAL_FKT_DATE, 'g:ia', $this->ilUser->getTimeZone()),
54  };
55 
56  $render_parts['MESSAGETIME'] = $date_string;
57  $prev_date_time_presentation = $message_date_time_presentation;
58  }
59 
60  if ($render_parts !== []) {
61  $room_tpl->setCurrentBlock('datetime_line');
62  foreach ($render_parts as $key => $value) {
63  $room_tpl->setVariable($key, $value);
64  }
65  $room_tpl->parseCurrentBlock();
66  }
67  }
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
const IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_CAL_FKT_DATE
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMessages()

ilChatroomHistoryGUI::showMessages ( array  $messages,
ilPropertyFormGUI  $durationForm,
bool  $export = false,
?ilDateTime  $from = null,
?ilDateTime  $to = null,
  $room = null 
)
private

Definition at line 114 of file class.ilChatroomHistoryGUI.php.

References $message, $scope, ilUtil\deliverData(), ilDatePresentation\formatDate(), ilDatePresentation\formatPeriod(), ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from(), ilFileUtils\getASCIIFilename(), ilPropertyFormGUI\getHTML(), IL_CAL_UNIX, ilLinkifyUtil\initLinkify(), null, ilChatroomGUIHandler\redirectIfNoPermission(), renderDateTimeInformation(), ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

Referenced by byDayExport().

121  : void {
122  $this->redirectIfNoPermission('read');
123 
124  $this->gui->switchToVisibleMode();
125 
126  // should be able to grep templates
127  if ($export) {
128  $roomTpl = new ilGlobalTemplate('tpl.history_export.html', true, true, 'components/ILIAS/Chatroom');
129  } else {
130  $roomTpl = new ilTemplate('tpl.history.html', true, true, 'components/ILIAS/Chatroom');
131  }
132 
133  if ($export) {
135  }
136 
137  $time_format = $this->ilUser->getTimeFormat();
138 
139  $num_messages_shown = 0;
140  $prev_date_time_presentation = null;
141  $prev_date_time = null;
142  if ($export) {
143  foreach ($messages as $message) {
144  switch ($message['message']->type) {
145  case 'message':
146  $message_date = new ilDate($message['timestamp'], IL_CAL_UNIX);
147  $message_date_time = new ilDateTime($message['timestamp'], IL_CAL_UNIX);
148  $message_date_time_presentation = ilDatePresentation::formatDate($message_date_time);
149 
151  $roomTpl,
152  $prev_date_time,
153  $message_date_time,
154  $message_date,
155  $prev_date_time_presentation,
156  $message_date_time_presentation,
157  $time_format
158  );
159 
160  $roomTpl->setCurrentBlock('message_line');
161  $roomTpl->setVariable('MESSAGECONTENT', htmlspecialchars($message['message']->content, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8')); // oops... it is a message? ^^
162  $roomTpl->setVariable('MESSAGESENDER', htmlspecialchars($message['message']->from->username, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8'));
163  $roomTpl->parseCurrentBlock();
164 
165  $roomTpl->setCurrentBlock('row');
166  $roomTpl->parseCurrentBlock();
167 
168  ++$num_messages_shown;
169  break;
170  }
171  }
172  }
173 
174  if (!$num_messages_shown) {
175  $roomTpl->setVariable('LBL_NO_MESSAGES', $this->ilLng->txt('no_messages'));
176  }
177 
178  $scope = $this->ilLng->txt('main');
179 
180  $prevUseRelDates = ilDatePresentation::useRelativeDates();
182 
183  if ($from instanceof ilDateTime && $to instanceof ilDateTime) {
184  $unixFrom = $from->getUnixTime();
185  $unixTo = $to->getUnixTime();
186 
187  if ($unixFrom === $unixTo) {
188  $message_date = new ilDate($unixFrom, IL_CAL_UNIX);
189  $date_sub = ilDatePresentation::formatDate($message_date);
190  } else {
191  $date1 = new ilDate($unixFrom, IL_CAL_UNIX);
192  $date2 = new ilDate($unixTo, IL_CAL_UNIX);
193  $date_sub = ilDatePresentation::formatPeriod($date1, $date2);
194  }
195  ilDatePresentation::setUseRelativeDates($prevUseRelDates);
196 
197  $roomTpl->setVariable(
198  'ROOM_TITLE',
199  sprintf($this->ilLng->txt('history_title_general'), $this->gui->getObject()->getTitle()) . ' (' . $date_sub . ')'
200  );
201  }
202 
203  if ($export) {
205  $roomTpl->get(),
207  'text/html'
208  );
209  }
210 
211  $roomTpl->setVariable('PERIOD_FORM', $durationForm->getHTML());
212 
213  if ($room && $messages !== []) {
214  ilLinkifyUtil::initLinkify($this->mainTpl);
215  $this->mainTpl->addJavaScript('assets/js/socket.io.min.js');
216  $this->mainTpl->addJavaScript('assets/js/Chatroom.min.js');
217  $roomTpl->setVariable('CHAT', (new ilChatroomViewGUI($this->gui))->readOnlyChatWindow($room, array_column($messages, 'message'))->get());
218  } else {
219  $roomTpl->setVariable('CHAT', '');
220  }
221  $this->mainTpl->setVariable('ADM_CONTENT', $roomTpl->get());
222  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
$scope
Definition: ltiregstart.php:47
special template class to simplify handling of ITX/PEAR
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
static initLinkify(?ilGlobalTemplateInterface $a_tpl=null)
Class ilChatroomViewGUI.
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
const IL_CAL_UNIX
renderDateTimeInformation( $room_tpl, ?ilDateTime &$prev_date_time, ilDateTime $message_date_time, ilDate $message_date, ?string &$prev_date_time_presentation, string $message_date_time_presentation, string $time_format)
static getASCIIFilename(string $a_filename)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$messages
Definition: xapiexit.php:21
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$message
Definition: xapiexit.php:31
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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