33 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
37 $this->gui->switchToVisibleMode();
48 $path = self::_getSmileyDir();
74 foreach ($smilies as $smiley) {
75 copy(
"templates/default/images/emoticons/$smiley",
$path .
"/$smiley");
78 self::_insertDefaultValues();
80 ilUtil::sendSuccess($DIC->language()->txt(
'chat_smilies_initialized'));
84 if (!is_writable(
$path)) {
97 $path =
'chatroom/smilies';
109 array(
"icon_smile.gif",
":)\n:-)\n:smile:"),
110 array(
"icon_wink.gif",
";)\n;-)\n:wink:"),
111 array(
"icon_laugh.gif",
":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
112 array(
"icon_sad.gif",
":(\n:-(\n:sad:"),
113 array(
"icon_shocked.gif",
":o\n:-o\n:shocked:"),
114 array(
"icon_tongue.gif",
":p\n:-p\n:tongue:"),
115 array(
"icon_cool.gif",
":cool:"),
116 array(
"icon_eek.gif",
":eek:"),
117 array(
"icon_angry.gif",
":||\n:-||\n:angry:"),
118 array(
"icon_flush.gif",
":flush:"),
119 array(
"icon_idea.gif",
":idea:"),
120 array(
"icon_thumbup.gif",
":thumbup:"),
121 array(
"icon_thumbdown.gif",
":thumbdown:"),
124 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
126 ilChatroomSmilies::_storeSmiley($val[1], $val[0]);
136 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->ref_id)) {
137 $this->
ilias->raiseError(
138 $this->ilLng->txt(
'msg_no_perm_read'),
139 $this->gui->ilias->error_obj->MESSAGE
143 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
145 ilChatroomSmilies::_checkSetup();
147 if (!$this->form_gui) {
153 include_once
"Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
158 "tpl.chatroom_edit_smilies.html",
163 $tpl_smilies->setVariable(
"SMILEY_TABLE",
$table);
164 $tpl_smilies->setVariable(
"SMILEY_FORM",
$form->getHtml());
166 $this->mainTpl->setContent($tpl_smilies->get());
175 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
179 $table_nav = $_REQUEST[
"_table_nav"] ?
"&_table_nav=" . $_REQUEST[
"_table_nav"] :
"";
180 $this->form_gui->setFormAction(
187 $sec_l->setTitle($this->ilLng->txt(
'chatroom_add_smiley'));
188 $this->form_gui->addItem($sec_l);
191 $this->ilLng->txt(
'chatroom_image_path'),
192 'chatroom_image_path' 194 $inp->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif",
"svg"));
196 $inp->setRequired(
true);
197 $this->form_gui->addItem($inp);
200 $this->ilLng->txt(
'chatroom_smiley_keywords'),
201 'chatroom_smiley_keywords' 205 $inp->setUseRte(
false);
206 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
207 $this->form_gui->addItem($inp);
208 $this->form_gui->addCommandButton(
209 'smiley-uploadSmileyObject',
210 $this->ilLng->txt(
'chatroom_upload_smiley')
222 $this->gui->switchToVisibleMode();
224 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->ref_id)) {
225 $this->
ilias->raiseError(
226 $this->ilLng->txt(
'msg_no_perm_read'),
227 $this->
ilias->error_obj->MESSAGE
231 if (!$this->form_gui) {
238 "tpl.chatroom_edit_smilies.html",
244 $tpl_form->setVariable(
"SMILEY_FORM",
$form->getHTML());
246 $this->mainTpl->setContent($tpl_form->get());
256 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
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'],
274 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
278 $this->form_gui->setValuesByArray($form_data);
280 $table_nav = $_REQUEST[
"_table_nav"] ?
"&_table_nav=" . $_REQUEST[
"_table_nav"] :
"";
284 $this->form_gui->setFormAction(
290 $sec_l->setTitle($this->ilLng->txt(
'chatroom_edit_smiley'));
291 $this->form_gui->addItem($sec_l);
293 include_once
"Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
296 $this->ilLng->txt(
'chatroom_current_smiley_image_path'),
297 'chatroom_current_smiley_image_path' 300 $inp->
setValue($form_data[
'chatroom_current_smiley_image_path']);
301 $this->form_gui->addItem($inp);
304 $this->ilLng->txt(
'chatroom_image_path'),
305 'chatroom_image_path' 307 $inp->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif",
"svg"));
309 $inp->setRequired(
false);
310 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_image_only_if_changed'));
311 $this->form_gui->addItem($inp);
314 $this->ilLng->txt(
'chatroom_smiley_keywords'),
315 'chatroom_smiley_keywords' 318 $inp->
setValue($form_data[
'chatroom_smiley_keywords']);
319 $inp->setUseRte(
false);
320 $inp->setRequired(
true);
321 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
322 $this->form_gui->addItem($inp);
326 $this->form_gui->addItem($inp);
327 $this->form_gui->addCommandButton(
328 'smiley-updateSmiliesObject',
329 $this->ilLng->txt(
'submit')
331 $this->form_gui->addCommandButton(
'smiley', $this->ilLng->txt(
'cancel'));
341 $this->gui->switchToVisibleMode();
343 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
344 $this->
ilias->raiseError(
345 $this->ilLng->txt(
'msg_no_perm_write'),
346 $this->
ilias->error_obj->MESSAGE
350 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
351 $smiley = ilChatroomSmilies::_getSmiley((
int) $_REQUEST[
'smiley_id']);
353 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
356 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
357 $confirmation->addButton($this->ilLng->txt(
'confirm'),
'smiley-deleteSmileyObject');
358 $confirmation->addButton($this->ilLng->txt(
'cancel'),
'smiley');
359 $confirmation->addItem(
'chatroom_smiley_id', $smiley[
'smiley_id'],
ilUtil::img($smiley[
'smiley_fullpath'], $smiley[
'smiley_keywords']) .
' ' . $smiley[
'smiley_keywords']);
361 $this->mainTpl->setContent($confirmation->getHTML());
369 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
370 $this->
ilias->raiseError(
371 $this->ilLng->txt(
'msg_no_perm_write'),
372 $this->
ilias->error_obj->MESSAGE
376 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
378 ilChatroomSmilies::_deleteSmiley($_REQUEST[
"chatroom_smiley_id"]);
388 public function updateSmiliesObject()
390 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
391 $this->
ilias->raiseError(
392 $this->ilLng->txt(
'msg_no_perm_write'),
393 $this->
ilias->error_obj->MESSAGE
399 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
404 $atLeastOneKeywordGiven = count($keywords) > 0;
406 if (!($isFormValid = $this->form_gui->checkInput()) || !$atLeastOneKeywordGiven) {
411 $this->form_gui->setValuesByPost();
417 $data[
"smiley_keywords"] = join(
"\n", $keywords);
418 $data[
"smiley_id"] = (int) $_REQUEST[
'smiley_id'];
420 if ($this->upload->hasUploads() && !$this->upload->hasBeenProcessed()) {
421 $this->upload->process();
424 $result = array_values($this->upload->getResults())[0];
426 $this->upload->moveOneFileTo(
429 \
ILIAS\FileUpload\Location::WEB,
438 \ilChatroomSmilies::_updateSmiley(
$data);
440 \ilUtil::sendSuccess($this->ilLng->txt(
'saved_successfully'),
true);
450 $this->gui->switchToVisibleMode();
452 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
453 $this->
ilias->raiseError(
454 $this->ilLng->txt(
'msg_no_perm_write'),
455 $this->
ilias->error_obj->MESSAGE
459 $items = (array) $_REQUEST[
'smiley_id'];
460 if (count($items) == 0) {
465 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
466 $smilies = ilChatroomSmilies::_getSmiliesById($items);
467 if (count($smilies) == 0) {
472 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
475 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
476 $confirmation->addButton($this->ilLng->txt(
'confirm'),
'smiley-confirmedDeleteMultipleObject');
477 $confirmation->addButton($this->ilLng->txt(
'cancel'),
'smiley');
479 foreach ($smilies as
$s) {
480 $confirmation->addItem(
'sel_ids[]', $s[
'smiley_id'],
ilUtil::img($s[
'smiley_fullpath'], $s[
'smiley_keywords']) .
' ' . $s[
'smiley_keywords']);
483 $this->mainTpl->setContent($confirmation->getHTML());
491 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
492 $this->
ilias->raiseError(
493 $this->ilLng->txt(
'msg_no_perm_write'),
494 $this->
ilias->error_obj->MESSAGE
498 $parts =
$_POST[
"sel_ids"];
499 if (count($parts) == 0) {
503 include_once
"Modules/Chatroom/classes/class.ilChatroomSmilies.php";
504 ilChatroomSmilies::_deleteMultipleSmilies($parts);
513 public function uploadSmileyObject()
515 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
516 $this->
ilias->raiseError(
517 $this->ilLng->txt(
'msg_no_perm_write'),
518 $this->
ilias->error_obj->MESSAGE
524 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
529 $atLeastOneKeywordGiven = count($keywords) > 0;
531 if (!($isFormValid = $this->form_gui->checkInput()) || !$atLeastOneKeywordGiven) {
536 $this->form_gui->setValuesByPost();
538 return $this->
view();
541 $pathinfo = pathinfo($_FILES[
"chatroom_image_path"][
"name"]);
542 $target_file = md5(time() + $pathinfo[
'basename']) .
"." . $pathinfo[
'extension'];
544 if ($this->upload->hasUploads() && !$this->upload->hasBeenProcessed()) {
545 $this->upload->process();
548 $result = array_values($this->upload->getResults())[0];
550 $this->upload->moveOneFileTo(
553 \
ILIAS\FileUpload\Location::WEB,
558 ilChatroomSmilies::_storeSmiley(join(
"\n", $keywords), $target_file);
562 \ilUtil::sendSuccess($this->ilLng->txt(
'saved_successfully'),
true);
deleteSmileyObject()
Deletes a smiley by $_REQUEST["chatroom_smiley_id"].
static makeDirParents($a_dir)
Create a new directory and all parent directories.
This class provides processing control methods.
static _getExistingSmiliesTable($a_ref)
Constructor public.
static _getSmileyDir($withBaseDir=true)
view()
Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table...
setValue($a_value)
Set Value.
initSmiliesForm()
Initializes smilies form and returns it.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
initSmiliesEditForm($form_data)
Initializes SmiliesEditForm and returns it.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
if(isset($_POST['submit'])) $form
Class ilChatroomGUIHandler.
special template class to simplify handling of ITX/PEAR
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getSmileyFormDataById($smileyId)
saveParameter($a_obj, $a_parameter)
Set parameters that should be passed in every form and link of a gui class.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
static getSmiliesBasePath()
Returns smilies basepath.
static _insertDefaultValues()
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
Class ilChatroomSmileyGUI Provides methods to show, add, edit and delete smilies consisting of icon a...
showEditSmileyEntryFormObject()
Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.
editSmiliesObject()
Shows existing smilies table Prepares existing smilies table and displays it.
if(empty($password)) $table
executeDefault($requestedMethod)
{}
deleteMultipleObject()
Shows confirmation view for deleting multiple smilies Prepares confirmation view for deleting multipl...
showDeleteSmileyFormObject()
Shows DeleteSmileyForm Prepares DeleteSmileyForm and displays it.
static getWebspaceDir($mode="filesystem")
get webspace directory
confirmedDeleteMultipleObject()
Deletes multiple smilies by $_REQUEST["sel_ids"].
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
Confirmation screen class.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.