19 declare(strict_types=1);
31 ?
string &$prev_date_time_presentation,
32 string $message_date_time_presentation,
37 if (
null === $prev_date_time ||
43 $prev_date_time = $message_date_time;
46 if ($prev_date_time_presentation !== $message_date_time_presentation) {
47 $date_string = match ($time_format) {
51 $this->ilUser->getTimeZone()
53 default => $message_date_time->
get(
IL_CAL_FKT_DATE,
'g:ia', $this->ilUser->getTimeZone()),
56 $render_parts[
'MESSAGETIME'] = $date_string;
57 $prev_date_time_presentation = $message_date_time_presentation;
60 if ($render_parts !== []) {
61 $room_tpl->setCurrentBlock(
'datetime_line');
62 foreach ($render_parts as $key => $value) {
63 $room_tpl->setVariable($key, $value);
65 $room_tpl->parseCurrentBlock();
71 $this->
tabs->activateSubTab(
'byday');
75 public function byDay(
bool $export =
false):
void 83 $durationForm = $formFactory->getPeriodForm();
84 $durationForm->setTitle($this->ilLng->txt(
'history_byday_title'));
85 $durationForm->addCommandButton(
'history-byDayExport', $this->ilLng->txt(
'export'));
86 $durationForm->addCommandButton(
'history-byDay', $this->ilLng->txt(
'show'));
87 $durationForm->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'history-byDay'));
90 $submit_request = strtolower($this->
http->request()->getServerParams()[
'REQUEST_METHOD']) ===
'post';
94 if ($submit_request) {
95 if ($durationForm->checkInput()) {
97 $period = $durationForm->getItemByPostVar(
'timeperiod');
100 $from = $period->getStart(),
101 $to = $period->getEnd(),
102 $chat_user->getUserId()
108 $durationForm->setValuesByPost();
117 bool $export =
false,
124 $this->gui->switchToVisibleMode();
128 $roomTpl =
new ilGlobalTemplate(
'tpl.history_export.html',
true,
true,
'components/ILIAS/Chatroom');
130 $roomTpl =
new ilTemplate(
'tpl.history.html',
true,
true,
'components/ILIAS/Chatroom');
137 $time_format = $this->ilUser->getTimeFormat();
139 $num_messages_shown = 0;
140 $prev_date_time_presentation =
null;
141 $prev_date_time =
null;
144 switch ($message[
'message']->type) {
155 $prev_date_time_presentation,
156 $message_date_time_presentation,
160 $roomTpl->setCurrentBlock(
'message_line');
161 $roomTpl->setVariable(
'MESSAGECONTENT', htmlspecialchars($message[
'message']->content, ENT_QUOTES | ENT_SUBSTITUTE,
'utf-8'));
162 $roomTpl->setVariable(
'MESSAGESENDER', htmlspecialchars($message[
'message']->
from->username, ENT_QUOTES | ENT_SUBSTITUTE,
'utf-8'));
163 $roomTpl->parseCurrentBlock();
165 $roomTpl->setCurrentBlock(
'row');
166 $roomTpl->parseCurrentBlock();
168 ++$num_messages_shown;
174 if (!$num_messages_shown) {
175 $roomTpl->setVariable(
'LBL_NO_MESSAGES', $this->ilLng->txt(
'no_messages'));
178 $scope = $this->ilLng->txt(
'main');
184 $unixFrom = $from->getUnixTime();
185 $unixTo = $to->getUnixTime();
187 if ($unixFrom === $unixTo) {
197 $roomTpl->setVariable(
199 sprintf($this->ilLng->txt(
'history_title_general'), $this->gui->getObject()->getTitle()) .
' (' . $date_sub .
')' 211 $roomTpl->setVariable(
'PERIOD_FORM', $durationForm->
getHTML());
213 if ($room && $messages !== []) {
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());
219 $roomTpl->setVariable(
'CHAT',
'');
221 $this->mainTpl->setVariable(
'ADM_CONTENT', $roomTpl->get());
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static array static setUseRelativeDates(bool $a_status)
set use relative dates
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)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
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 useRelativeDates()
static getASCIIFilename(string $a_filename)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
Class ilChatroomGUIHandler.
showMessages(array $messages, ilPropertyFormGUI $durationForm, bool $export=false, ?ilDateTime $from=null, ?ilDateTime $to=null, $room=null)
static byObjectId(int $object_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
executeDefault(string $requestedMethod)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.