19 declare(strict_types=1);
42 public function view(): void
46 $this->gui->switchToVisibleMode();
56 $main_tpl = $DIC->ui()->mainTemplate();
58 $path = self::_getSmileyDir();
61 $main_tpl->setOnScreenMessage(
'info', $DIC->language()->txt(
'chat_smilies_dir_not_exists'));
65 $main_tpl->setOnScreenMessage(
'failure', $DIC->language()->txt(
'chat_smilies_dir_not_available'));
85 foreach ($smilies as $smiley) {
86 copy(
"templates/default/images/emoticons/$smiley",
$path .
"/$smiley");
89 self::_insertDefaultValues();
91 $main_tpl->setOnScreenMessage(
'success', $DIC->language()->txt(
'chat_smilies_initialized'));
94 if (!is_writable(
$path)) {
95 $main_tpl->setOnScreenMessage(
'info', $DIC->language()->txt(
'chat_smilies_dir_not_writable'));
103 $path =
'chatroom/smilies';
115 [
"icon_smile.gif",
":)\n:-)\n:smile:"],
116 [
"icon_wink.gif",
";)\n;-)\n:wink:"],
117 [
"icon_laugh.gif",
":D\n:-D\n:laugh:\n:grin:\n:biggrin:"],
118 [
"icon_sad.gif",
":(\n:-(\n:sad:"],
119 [
"icon_shocked.gif",
":o\n:-o\n:shocked:"],
120 [
"icon_tongue.gif",
":p\n:-p\n:tongue:"],
121 [
"icon_cool.gif",
":cool:"],
122 [
"icon_eek.gif",
":eek:"],
123 [
"icon_angry.gif",
":||\n:-||\n:angry:"],
124 [
"icon_flush.gif",
":flush:"],
125 [
"icon_idea.gif",
":idea:"],
126 [
"icon_thumbup.gif",
":thumbup:"],
127 [
"icon_thumbdown.gif",
":thumbdown:"],
130 foreach ($values as $val) {
131 ilChatroomSmilies::_storeSmiley($val[1], $val[0]);
141 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->getRefId())) {
142 $this->
ilias->raiseError(
143 $this->ilLng->txt(
'msg_no_perm_read'),
144 $this->
ilias->error_obj->MESSAGE
148 ilChatroomSmilies::_checkSetup();
150 if (null === $this->form_gui) {
157 'tpl.chatroom_edit_smilies.html',
162 $tpl_smilies->setVariable(
'SMILEY_TABLE', $table);
163 $tpl_smilies->setVariable(
'SMILEY_FORM', $this->form_gui->getHTML());
165 $this->mainTpl->setContent($tpl_smilies->get());
174 if ($this->
http->wrapper()->query()->has(
'_table_nav')) {
175 $this->
ilCtrl->setParameter(
178 $this->
http->wrapper()->query()->retrieve(
'_table_nav', $this->
refinery->kindlyTo()->string())
181 $this->form_gui->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'smiley-uploadSmileyObject'));
185 $sec_l->setTitle($this->ilLng->txt(
'chatroom_add_smiley'));
186 $this->form_gui->addItem($sec_l);
189 $this->ilLng->txt(
'chatroom_image_path'),
190 'chatroom_image_path' 192 $inp->
setSuffixes([
'jpg',
'jpeg',
'png',
'gif',
'svg']);
194 $inp->setRequired(
true);
195 $this->form_gui->addItem($inp);
198 $this->ilLng->txt(
'chatroom_smiley_keywords'),
199 'chatroom_smiley_keywords' 203 $inp->setUseRte(
false);
204 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
205 $this->form_gui->addItem($inp);
208 if ($this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
209 $this->form_gui->addCommandButton(
210 'smiley-uploadSmileyObject',
211 $DIC->language()->txt(
'chatroom_upload_smiley')
224 $this->gui->switchToVisibleMode();
226 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->getRefId())) {
227 $this->
ilias->raiseError(
228 $this->ilLng->txt(
'msg_no_perm_read'),
229 $this->
ilias->error_obj->MESSAGE
235 if (null === $this->form_gui) {
240 'tpl.chatroom_edit_smilies.html',
246 $tpl_form->setVariable(
'SMILEY_FORM', $this->form_gui->getHTML());
248 $this->mainTpl->setContent($tpl_form->get());
257 $smiley = ilChatroomSmilies::_getSmiley($smileyId);
260 'chatroom_smiley_id' => $smiley[
'smiley_id'],
261 'chatroom_smiley_keywords' => $smiley[
'smiley_keywords'],
262 'chatroom_current_smiley_image_path' => $smiley[
'smiley_fullpath'],
273 $this->form_gui->setValuesByArray($form_data);
275 if ($this->
http->wrapper()->query()->has(
'_table_nav')) {
276 $this->
ilCtrl->setParameter(
279 $this->
http->wrapper()->query()->retrieve(
'_table_nav', $this->
refinery->kindlyTo()->string())
283 $this->
ilCtrl->saveParameter($this->gui,
'smiley_id');
284 $this->form_gui->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'smiley-updateSmiliesObject'));
288 $sec_l->setTitle($this->ilLng->txt(
'chatroom_edit_smiley'));
289 $this->form_gui->addItem($sec_l);
292 $this->ilLng->txt(
'chatroom_current_smiley_image_path'),
293 'chatroom_current_smiley_image_path' 296 $inp->
setValue($form_data[
'chatroom_current_smiley_image_path']);
297 $this->form_gui->addItem($inp);
300 $this->ilLng->txt(
'chatroom_image_path'),
301 'chatroom_image_path' 303 $inp->
setSuffixes([
'jpg',
'jpeg',
'png',
'gif',
'svg']);
305 $inp->setRequired(
false);
306 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_image_only_if_changed'));
307 $this->form_gui->addItem($inp);
310 $this->ilLng->txt(
'chatroom_smiley_keywords'),
311 'chatroom_smiley_keywords' 314 $inp->
setValue($form_data[
'chatroom_smiley_keywords']);
315 $inp->setUseRte(
false);
316 $inp->setRequired(
true);
317 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
318 $this->form_gui->addItem($inp);
322 $this->form_gui->addItem($inp);
323 $this->form_gui->addCommandButton(
324 'smiley-updateSmiliesObject',
325 $this->ilLng->txt(
'submit')
327 $this->form_gui->addCommandButton(
'smiley', $this->ilLng->txt(
'cancel'));
338 $this->gui->switchToVisibleMode();
340 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
341 $this->
ilias->raiseError(
342 $this->ilLng->txt(
'msg_no_perm_write'),
343 $this->
ilias->error_obj->MESSAGE
349 $smiley = ilChatroomSmilies::_getSmiley($smileyId);
352 $confirmation->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'smiley'));
353 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
354 $confirmation->setConfirm($this->ilLng->txt(
'confirm'),
'smiley-deleteSmileyObject');
355 $confirmation->setCancel($this->ilLng->txt(
'cancel'),
'smiley');
356 $confirmation->addItem(
357 'chatroom_smiley_id',
358 (
string) $smiley[
'smiley_id'],
359 ilUtil::img($smiley[
'smiley_fullpath'], $smiley[
'smiley_keywords']) .
' ' . $smiley[
'smiley_keywords']
362 $this->mainTpl->setContent($confirmation->getHTML());
367 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
368 $this->
ilias->raiseError(
369 $this->ilLng->txt(
'msg_no_perm_write'),
370 $this->
ilias->error_obj->MESSAGE
375 'chatroom_smiley_id',
379 ilChatroomSmilies::_deleteSmiley($smileyId);
381 $this->
ilCtrl->redirect($this->gui,
'smiley');
384 public function updateSmiliesObject():
void 386 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
387 $this->
ilias->raiseError(
388 $this->ilLng->txt(
'msg_no_perm_write'),
389 $this->
ilias->error_obj->MESSAGE
401 $atLeastOneKeywordGiven = count($keywords) > 0;
403 $isFormValid = $this->form_gui->checkInput();
404 if (!$atLeastOneKeywordGiven || !$isFormValid) {
405 $errorShown = !$isFormValid;
406 if (!$atLeastOneKeywordGiven && !$errorShown) {
407 $this->mainTpl->setOnScreenMessage(
'failure', $this->ilLng->txt(
'form_input_not_valid'));
410 $this->form_gui->setValuesByPost();
417 $data[
'smiley_keywords'] = implode(
"\n", $keywords);
418 $data[
'smiley_id'] = $smileyId;
420 if ($this->
upload->hasUploads() && !$this->
upload->hasBeenProcessed()) {
424 $result = array_values($this->
upload->getResults())[0];
425 if ($result && $result->isOK()) {
426 $this->
upload->moveOneFileTo(
429 \
ILIAS\FileUpload\Location::WEB,
434 $data[
'smiley_path'] = $result->getName();
438 ilChatroomSmilies::_updateSmiley(
$data);
440 $this->mainTpl->setOnScreenMessage(
'success', $this->ilLng->txt(
'saved_successfully'),
true);
441 $this->
ilCtrl->redirect($this->gui,
'smiley');
450 $this->gui->switchToVisibleMode();
452 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
453 $this->
ilias->raiseError(
454 $this->ilLng->txt(
'msg_no_perm_write'),
455 $this->
ilias->error_obj->MESSAGE
461 $this->
refinery->kindlyTo()->listOf(
467 $this->mainTpl->setOnScreenMessage(
'info', $this->ilLng->txt(
'select_one'),
true);
468 $this->
ilCtrl->redirect($this->gui,
'smiley');
471 $smilies = ilChatroomSmilies::_getSmiliesById($ids);
472 if ($smilies === []) {
473 $this->mainTpl->setOnScreenMessage(
'info', $this->ilLng->txt(
'select_one'),
true);
474 $this->
ilCtrl->redirect($this->gui,
'smiley');
478 $confirmation->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'smiley'));
479 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
480 $confirmation->setConfirm($this->ilLng->txt(
'confirm'),
'smiley-confirmedDeleteMultipleObject');
481 $confirmation->setCancel($this->ilLng->txt(
'cancel'),
'smiley');
483 foreach ($smilies as $s) {
484 $confirmation->addItem(
486 (
string) $s[
'smiley_id'],
487 ilUtil::img($s[
'smiley_fullpath'], $s[
'smiley_keywords']) .
' ' . $s[
'smiley_keywords']
491 $this->mainTpl->setContent($confirmation->getHTML());
496 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
497 $this->
ilias->raiseError(
498 $this->ilLng->txt(
'msg_no_perm_write'),
499 $this->
ilias->error_obj->MESSAGE
505 $this->
refinery->kindlyTo()->listOf(
512 $this->
ilCtrl->redirect($this->gui,
'smiley');
515 ilChatroomSmilies::_deleteMultipleSmilies($ids);
517 $this->
ilCtrl->redirect($this->gui,
'smiley');
520 public function uploadSmileyObject():
void 522 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->getRefId())) {
523 $this->
ilias->raiseError(
524 $this->ilLng->txt(
'msg_no_perm_write'),
525 $this->
ilias->error_obj->MESSAGE
533 'chatroom_smiley_keywords',
534 $this->
refinery->kindlyTo()->string(),
539 $atLeastOneKeywordGiven = count($keywords) > 0;
541 $isFormValid = $this->form_gui->checkInput();
542 if (!$atLeastOneKeywordGiven || !$isFormValid) {
543 $errorShown = !$isFormValid;
544 if (!$atLeastOneKeywordGiven && !$errorShown) {
545 $this->mainTpl->setOnScreenMessage(
'failure', $this->ilLng->txt(
'form_input_not_valid'));
548 $this->form_gui->setValuesByPost();
554 $pathinfo = pathinfo($_FILES[
'chatroom_image_path'][
'name']);
555 $target_file = md5(time() . $pathinfo[
'basename']) .
'.' . $pathinfo[
'extension'];
557 if ($this->
upload->hasUploads() && !$this->
upload->hasBeenProcessed()) {
561 $result = array_values($this->
upload->getResults())[0];
562 if ($result && $result->isOK()) {
563 $this->
upload->moveOneFileTo(
566 \
ILIAS\FileUpload\Location::WEB,
571 ilChatroomSmilies::_storeSmiley(implode(
"\n", $keywords), $target_file);
575 $this->mainTpl->setOnScreenMessage(
'success', $this->ilLng->txt(
'saved_successfully'),
true);
576 $this->
ilCtrl->redirect($this->gui,
'smiley');
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
getSmileyFormDataById(int $smileyId)
initSmiliesEditForm(array $form_data)
Class ChatMainBarProvider .
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getRequestValue(string $key, Transformation $trafo, $default=null)
view()
Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table...
ilPropertyFormGUI $form_gui
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
setValue(string $a_value)
static http()
Fetches the global http state from ILIAS.
Class ilChatroomGUIHandler.
static _getExistingSmiliesTable(ilChatroomObjectGUI $a_ref)
header include for all ilias files.
static _prepareKeywords(string $words)
Trims given keywords and returns them in one array.
static _getSmileyDir(bool $withBaseDir=true)
This class represents a text area property in a property form.
static getSmiliesBasePath()
static _insertDefaultValues()
executeDefault(string $requestedMethod)
Class ilChatroomAdminSmileyGUI Provides methods to show, add, edit and delete smilies consisting of i...
showEditSmileyEntryFormObject()
Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.
editSmiliesObject()
Shows existing smilies table Prepares existing smilies table and displays it.
deleteMultipleObject()
Shows confirmation view for deleting multiple smilies Prepares confirmation view for deleting multipl...
showDeleteSmileyFormObject()
Shows DeleteSmileyForm Prepares DeleteSmileyForm and displays it.
confirmedDeleteMultipleObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...