ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomSmileyTask Class Reference

Class ilChatroomSmileyTask Provides methods to show, add, edit and delete smilies consisting of icon and keywords. More...

+ Inheritance diagram for ilChatroomSmileyTask:
+ Collaboration diagram for ilChatroomSmileyTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor Sets $this->gui.
 executeDefault ($method)
 Default execute command.
 view ()
 Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table of existing smilies.
 showEditSmileyEntryFormObject ()
 Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.
 deleteSmileyObject ()
 Deletes a smiley by $_REQUEST["chatroom_smiley_id"] ilRbacSystem $rbacsystem ilCtrl2 $ilCtrl.
 editSmiliesObject ()
 Shows existing smilies table Prepares existing smilies table and displays it.
 updateSmiliesObject ()
 Updates a smiley and/or its keywords Updates a smiley icon and/or its keywords by $_REQUEST["chatroom_smiley_id"] and gets keywords from $_REQUEST["chatroom_smiley_keywords"].
 initSmiliesForm ()
 Initializes smilies form and returns it.
 initSmiliesEditForm ($form_data)
 Initializes SmiliesEditForm and returns it.
 uploadSmileyObject ()
 Uploads and stores a new smiley with keywords from $_REQUEST["chatroom_smiley_keywords"] ilRbacSystem $rbacsystem ilCtrl2 $ilCtrl.

Static Public Member Functions

static _getSmileyDir ()
static _checkSetup ()

Static Private Member Functions

static _insertDefaultValues ()
static _setupFolder ()
 setup directory

Private Attributes

 $gui

Detailed Description

Class ilChatroomSmileyTask Provides methods to show, add, edit and delete smilies consisting of icon and keywords.

Author
Andreas Kordosz akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilChatroomSmileyTask.php.

Constructor & Destructor Documentation

ilChatroomSmileyTask::__construct ( ilChatroomObjectGUI  $gui)

Constructor Sets $this->gui.

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomTaskHandler.

Definition at line 22 of file class.ilChatroomSmileyTask.php.

References $gui.

{
$this->gui = $gui;
}

Member Function Documentation

static ilChatroomSmileyTask::_checkSetup ( )
static

Definition at line 567 of file class.ilChatroomSmileyTask.php.

References $lng, $path, _getSmileyDir(), _insertDefaultValues(), ilUtil\makeDirParents(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

Referenced by editSmiliesObject(), and view().

{
global $lng;
if(!is_dir($path))
{
ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_exists'));
if(!is_dir($path))
{
ilUtil::sendFailure($lng->txt('chat_smilies_dir_not_available'));
return false;
}
else
{
$smilies = array
(
"icon_smile.gif",
"icon_wink.gif",
"icon_laugh.gif",
"icon_sad.gif",
"icon_shocked.gif",
"icon_tongue.gif",
"icon_cool.gif",
"icon_eek.gif",
"icon_angry.gif",
"icon_flush.gif",
"icon_idea.gif",
"icon_thumbup.gif",
"icon_thumbdown.gif",
);
foreach($smilies as $smiley)
{
copy("templates/default/images/emoticons/$smiley", $path . "/$smiley");
}
ilUtil::sendSuccess($lng->txt('chat_smilies_initialized'));
}
}
if(!is_writable($path))
{
ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_writable'));
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmileyTask::_getSmileyDir ( )
static
Returns
string path to smilies

Definition at line 562 of file class.ilChatroomSmileyTask.php.

References ilUtil\getWebspaceDir().

Referenced by _checkSetup(), and _setupFolder().

{
return ilUtil::getWebspaceDir() . '/chatroom/smilies';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmileyTask::_insertDefaultValues ( )
staticprivate

Definition at line 509 of file class.ilChatroomSmileyTask.php.

References $ilDB, and $row.

Referenced by _checkSetup().

{
global $ilDB;
$values = array(
array("icon_smile.gif", ":)\n:-)\n:smile:"),
array("icon_wink.gif", ";)\n;-)\n:wink:"),
array("icon_laugh.gif", ":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
array("icon_sad.gif", ":(\n:-(\n:sad:"),
array("icon_shocked.gif", ":o\n:-o\n:shocked:"),
array("icon_tongue.gif", ":p\n:-p\n:tongue:"),
array("icon_cool.gif", ":cool:"),
array("icon_eek.gif", ":eek:"),
array("icon_angry.gif", ":||\n:-||\n:angry:"),
array("icon_flush.gif", ":flush:"),
array("icon_idea.gif", ":idea:"),
array("icon_thumbup.gif", ":thumbup:"),
array("icon_thumbdown.gif", ":thumbdown:"),
);
$stmt = $ilDB->prepare("
INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path)
VALUES (?, ?, ?)",
array("integer", "text", "text")
);
foreach($values as $val)
{
$row = array(
$ilDB->nextID("chat_smilies"),
$val[1],
$val[0]
);
$stmt->execute($row);
}
}

+ Here is the caller graph for this function:

static ilChatroomSmileyTask::_setupFolder ( )
staticprivate

setup directory

Definition at line 549 of file class.ilChatroomSmileyTask.php.

References $path, and _getSmileyDir().

{
if(!is_dir($path))
{
mkdir($path, 0755, true);
}
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::deleteSmileyObject ( )

Deletes a smiley by $_REQUEST["chatroom_smiley_id"] ilRbacSystem $rbacsystem ilCtrl2 $ilCtrl.

Definition at line 139 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $ilCtrl, $lng, and ilChatroomSmilies\_deleteSmiley().

{
global $rbacsystem, $ilCtrl, $lng;
if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
{
$this->ilias->raiseError(
$lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
);
}
include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
$ilCtrl->redirect($this->gui, "smiley");
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::editSmiliesObject ( )

Shows existing smilies table Prepares existing smilies table and displays it.

ilRbacSystem $rbacsystem ilLanguage $lng ilTemplate $tpl

Definition at line 164 of file class.ilChatroomSmileyTask.php.

References $lng, $tpl, _checkSetup(), ilChatroomSmiliesGUI\_getExistingSmiliesTable(), and initSmiliesForm().

Referenced by view().

{
global $rbacsystem, $lng, $tpl;
if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
{
$this->ilias->raiseError(
$lng->txt('msg_no_perm_read'), $this->gui->ilias->error_obj->MESSAGE
);
}
include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
if(!$this->form_gui)
{
$form = $this->initSmiliesForm();
}
else
{
$form = $this->form_gui;
}
include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
$tpl_smilies = new ilTemplate(
"tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
);
$tpl_smilies->setVariable("SMILEY_TABLE", $table);
$tpl_smilies->setVariable("SMILEY_FORM", $form->getHtml());
$tpl->setContent($tpl_smilies->get());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomSmileyTask::executeDefault (   $method)

Default execute command.

Calls view method.

Parameters
string$method

Reimplemented from ilChatroomTaskHandler.

Definition at line 32 of file class.ilChatroomSmileyTask.php.

References view().

{
//include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
//ilChatroomSmilies::_initial();
$this->view();
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::initSmiliesEditForm (   $form_data)

Initializes SmiliesEditForm and returns it.

ilCtrl2 $ilCtrl ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 397 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $ilCtrl, $lng, ilFormPropertyGUI\setRequired(), ilChatroomSmiliesCurrentSmileyFormElement\setValue(), and ilTextAreaInputGUI\setValue().

Referenced by showEditSmileyEntryFormObject().

{
global $ilCtrl, $lng;
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
$this->form_gui = new ilPropertyFormGUI();
$this->form_gui->setValuesByArray($form_data);
$table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
$ilCtrl->saveParameter($this->gui, 'smiley_id');
$this->form_gui->setFormAction(
$ilCtrl->getFormAction($this->gui, 'smiley-updateSmiliesObject') . $table_nav
);
$sec_l = new ilFormSectionHeaderGUI();
$sec_l->setTitle($lng->txt('chatroom_edit_smiley'));
$this->form_gui->addItem($sec_l);
include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
$lng->txt('chatroom_current_smiley_image_path'),
'chatroom_current_smiley_image_path'
);
$inp->setValue($form_data['chatroom_current_smiley_image_path']);
$this->form_gui->addItem($inp);
$inp = new ilImageFileInputGUI(
$lng->txt('chatroom_image_path'), 'chatroom_image_path'
);
$inp->setRequired(false);
$inp->setInfo($lng->txt('chatroom_smiley_image_only_if_changed'));
$this->form_gui->addItem($inp);
$inp = new ilTextAreaInputGUI(
$lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
);
$inp->setValue($form_data['chatroom_smiley_keywords']);
$inp->setUseRte(false);
$inp->setRequired(true);
$inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
$this->form_gui->addItem($inp);
$inp = new ilHiddenInputGUI('chatroom_smiley_id');
$this->form_gui->addItem($inp);
$this->form_gui->addCommandButton(
'smiley-updateSmiliesObject', $lng->txt('submit')
);
$this->form_gui->addCommandButton('smiley', $lng->txt('cancel'));
return $this->form_gui;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomSmileyTask::initSmiliesForm ( )

Initializes smilies form and returns it.

ilCtrl2 $ilCtrl ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 267 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $ilCtrl, $lng, and ilFormPropertyGUI\setRequired().

Referenced by editSmiliesObject(), and uploadSmileyObject().

{
global $ilCtrl, $lng;
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
$this->form_gui = new ilPropertyFormGUI();
$table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
$this->form_gui->setFormAction(
$ilCtrl->getFormAction($this->gui, 'smiley-uploadSmileyObject') . $table_nav
);
// chat server settings
$sec_l = new ilFormSectionHeaderGUI();
$sec_l->setTitle($lng->txt('chatroom_add_smiley'));
$this->form_gui->addItem($sec_l);
$inp = new ilImageFileInputGUI(
$lng->txt('chatroom_image_path'), 'chatroom_image_path'
);
$inp->setRequired(true);
$this->form_gui->addItem($inp);
$inp = new ilTextAreaInputGUI(
$lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
);
$inp->setRequired(true);
$inp->setUseRte(false);
$inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
$this->form_gui->addItem($inp);
$this->form_gui->addCommandButton(
'smiley-uploadSmileyObject', $lng->txt('chatroom_upload_smiley')
);
return $this->form_gui;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomSmileyTask::showEditSmileyEntryFormObject ( )

Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.

ilRbacSystem $rbacsystem ilTemplate $tpl

Definition at line 63 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $lng, $tpl, ilChatroomSmilies\_getSmiley(), and initSmiliesEditForm().

{
global $rbacsystem, $tpl, $lng;
$this->gui->switchToVisibleMode();
if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
{
$this->ilias->raiseError(
$lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE
);
}
include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
$smiley = ilChatroomSmilies::_getSmiley($_REQUEST["smiley_id"]);
$form_data = array(
"chatroom_smiley_id" => $smiley["smiley_id"],
"chatroom_smiley_keywords" => $smiley["smiley_keywords"],
"chatroom_current_smiley_image_path" => $smiley["smiley_fullpath"],
);
$form = $this->initSmiliesEditForm($form_data);
$tpl_form = new ilTemplate(
"tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
);
$tpl_form->setVariable("SMILEY_FORM", $form->getHTML());
$tpl->setContent($tpl_form->get());
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::updateSmiliesObject ( )

Updates a smiley and/or its keywords Updates a smiley icon and/or its keywords by $_REQUEST["chatroom_smiley_id"] and gets keywords from $_REQUEST["chatroom_smiley_keywords"].

ilRbacSystem $rbacsystem ilCtrl2 $ilCtrl

Definition at line 208 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $ilCtrl, $lng, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), ilChatroomSmilies\_updateSmiley(), ilUtil\sendFailure(), ilUtil\stripSlashes(), and view().

{
global $rbacsystem, $ilCtrl, $tpl, $lng;
if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
{
$this->ilias->raiseError(
$lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
);
}
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
$this->form_gui = new ilPropertyFormGUI();
// $this->initSmiliesEditForm();
include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
);
$keywordscheck = count($keywords) > 0;
if(!$this->form_gui->checkInput() || !$keywordscheck)
{
$tpl->setContent($this->form_gui->getHtml());
ilUtil::sendFailure('test', true);
return $this->view();
}
else
{
$data = array();
$data["smiley_keywords"] = join("\n", $keywords);
$data["smiley_id"] = $_REQUEST["smiley_id"];
if($_FILES["chatroom_image_path"])
{
move_uploaded_file(
$_FILES["chatroom_image_path"]["tmp_name"],
$_FILES["chatroom_image_path"]["name"]
);
$data["smiley_path"] = $_FILES["chatroom_image_path"]["name"];
}
}
$ilCtrl->redirect($this->gui, "smiley");
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::uploadSmileyObject ( )

Uploads and stores a new smiley with keywords from $_REQUEST["chatroom_smiley_keywords"] ilRbacSystem $rbacsystem ilCtrl2 $ilCtrl.

Definition at line 464 of file class.ilChatroomSmileyTask.php.

References $_REQUEST, $ilCtrl, $lng, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), ilChatroomSmilies\_storeSmiley(), initSmiliesForm(), ilUtil\stripSlashes(), and view().

{
global $rbacsystem, $ilCtrl, $tpl, $lng;
if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
{
$this->ilias->raiseError(
$lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
);
}
$this->initSmiliesForm();
include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
//$this->form_gui = new ilPropertyFormGUI();
$this->form_gui->setValuesByPost();
ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
);
$keywordscheck = count($keywords) > 0;
if(!$this->form_gui->checkInput())
{
$tpl->setContent($this->form_gui->getHtml());
return $this->view();
}
$pathinfo = pathinfo($_FILES["chatroom_image_path"]["name"]);
$target_file = md5(time() + $pathinfo['basename']) . "." . $pathinfo['extension'];
move_uploaded_file(
$_FILES["chatroom_image_path"]["tmp_name"],
);
ilChatroomSmilies::_storeSmiley(join("\n", $keywords), $target_file);
$ilCtrl->redirect($this->gui, "smiley");
}

+ Here is the call graph for this function:

ilChatroomSmileyTask::view ( )

Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table of existing smilies.

Definition at line 44 of file class.ilChatroomSmileyTask.php.

References _checkSetup(), ilChatroom\checkUserPermissions(), and editSmiliesObject().

Referenced by executeDefault(), updateSmiliesObject(), and uploadSmileyObject().

{
include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
$this->gui->switchToVisibleMode();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatroomSmileyTask::$gui
private

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

Referenced by __construct().


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