ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatSmilies Class Reference

Class ilChatSmilies. More...

+ Collaboration diagram for ilChatSmilies:

Static Public Member Functions

static _getSmileyDir ()
static _initial ()
 performs initial setup (db, dirs, default data)
static _checkSetup ()
 checks if smiley folder is available; if not it will try to create folder and performs actions for an initial smiley set
static _getSmilies ()
static _getSmiley ($a_id)
 lookup and return smiley with id throws exception if id is not found
static _getSmiliesById ($ids=array())
static _deleteMultipleSmilies ($ids=array())
static _updateSmiley ($data)
static _getSmiliesBasePath ()
static _deleteSmiley ($a_id)
static _storeSmiley ($keywords, $path)
static _prepareKeywords ($words)
static _parseString ($str)

Static Private Member Functions

static _setupDatabase ()
 create table and sequence
static _insertDefaultValues ()
 insert default smiley set
static _setupFolder ()
 setup directory

Detailed Description

Class ilChatSmilies.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 31 of file class.ilChatSmilies.php.

Member Function Documentation

static ilChatSmilies::_checkSetup ( )
static

checks if smiley folder is available; if not it will try to create folder and performs actions for an initial smiley set

Definition at line 132 of file class.ilChatSmilies.php.

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

Referenced by ilObjChatServerGUI\editSmiliesObject().

{
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 ilChatSmilies::_deleteMultipleSmilies (   $ids = array())
static

Definition at line 261 of file class.ilChatSmilies.php.

References $ilDB, and _getSmiliesById().

Referenced by ilObjChatServerGUI\confirmedDeleteMultipleObject().

{
global $ilDB;
$smilies = self::_getSmiliesById($ids);
if (count($smilies) <= 0)
return;
$sql_parts = array();
foreach($smilies as $s) {
unlink($s["smiley_fullpath"]);
$sql_parts[] = "smiley_id = " . $ilDB->quote($s["smiley_id"],'integer');
}
$ilDB->manipulate("DELETE FROM chat_smilies WHERE " . join(" OR ", $sql_parts) );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_deleteSmiley (   $a_id)
static

Definition at line 308 of file class.ilChatSmilies.php.

References $ilDB, _getSmiley(), and ilUtil\getWebspaceDir().

Referenced by ilObjChatServerGUI\deleteSmileyObject().

{
global $ilDB;
try {
$smiley = self::_getSmiley($a_id);
$path = ilUtil::getWebspaceDir().'/chat/smilies/'.$smiley["smiley_path"];
if (is_file($path))
unlink($path);
$ilDB->manipulateF(
"DELETE FROM chat_smilies
WHERE
smiley_id = %s",
array('integer'),
array($a_id)
);
}
catch(Exception $e) {
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_getSmiley (   $a_id)
static

lookup and return smiley with id throws exception if id is not found

Returns
array

Definition at line 211 of file class.ilChatSmilies.php.

References $ilDB, $res, $result, and ilUtil\getWebspaceDir().

Referenced by _deleteSmiley(), _updateSmiley(), ilObjChatServerGUI\showDeleteSmileyFormObject(), and ilObjChatServerGUI\showEditSmileyEntryFormObject().

{
global $ilDB;
$res = $ilDB->queryF("
SELECT smiley_id, smiley_keywords, smiley_path
FROM chat_smilies
WHERE smiley_id = %s
", array('integer'), array($a_id));
if ($res->numRows()) {
$tmp = $res->fetchRow();
$result = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir().'/chat/smilies/'.$tmp[2]
);
return $result;
}
throw new Exception('smiley with id $a_id not found');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References ilUtil\getWebspaceDir().

Referenced by _checkSetup().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_getSmilies ( )
static
Returns
array

Definition at line 187 of file class.ilChatSmilies.php.

References $ilDB, $res, $result, and ilUtil\getWebspaceDir().

Referenced by ilChatSmiliesGUI\_getExistingSmiliesTable(), and ilObjChatGUI\showUserFrameObject().

{
global $ilDB;
$res = $ilDB->query("SELECT smiley_id, smiley_keywords, smiley_path FROM chat_smilies");
$result = array();
for ($i = 0; $i < $res->numRows(); $i++) {
$tmp = $res->fetchRow();
$result[] = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir().'/chat/smilies/'.$tmp[2]
);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_getSmiliesBasePath ( )
static

Definition at line 304 of file class.ilChatSmilies.php.

References ilUtil\getWebspaceDir().

Referenced by ilObjChatServerGUI\updateSmiliesObject(), and ilObjChatServerGUI\uploadSmileyObject().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_getSmiliesById (   $ids = array())
static

Definition at line 233 of file class.ilChatSmilies.php.

References $ilDB, $res, $result, and ilUtil\getWebspaceDir().

Referenced by _deleteMultipleSmilies(), and ilObjChatServerGUI\deleteMultipleObject().

{
global $ilDB;
if (!count($ids)) return;
$sql = "SELECT smiley_id, smiley_keywords, smiley_path FROM chat_smilies WHERE ";
$sql_parts = array();
foreach($ids as $id) {
$sql_parts[] .= "smiley_id = " . $ilDB->quote($id, "integer");
}
$sql .= join(" OR ", $sql_parts);
$res = $ilDB->query($sql);
$result = array();
for($i = 0; $i < $res->numRows(); $i++) {
$tmp = $res->fetchRow();
$result[] = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir().'/chat/smilies/'.$tmp[2]
);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_initial ( )
static

performs initial setup (db, dirs, default data)

Definition at line 121 of file class.ilChatSmilies.php.

References _insertDefaultValues(), _setupDatabase(), and _setupFolder().

+ Here is the call graph for this function:

static ilChatSmilies::_insertDefaultValues ( )
staticprivate

insert default smiley set

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

References $ilDB, and $row.

Referenced by _checkSetup(), and _initial().

{
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 chat_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 ilChatSmilies::_parseString (   $str)
static

Definition at line 373 of file class.ilChatSmilies.php.

References $ilDB, $q, $row, $tpl, $x, and ilUtil\getHtmlPath().

Referenced by ilChatServerCommunicator\emoticons().

{
global $ilDB;
$q = $ilDB->query(
"SELECT smiley_keywords, smiley_path
FROM chat_smilies"
);
$ar_search = array();
$ar_replace = array();
$ostr = "";
for($i = 0; $i < $q->numRows(); $i++) {
$row = $q->fetchRow();
$keywords = explode("\n", $row[0]);
for ($x = 0; $x < count($keywords); $x++) {
$ar_search[] = $keywords[$x];
$tpl = new ilTemplate("tpl.chat_smiley_line.html", true, true, "Modules/Chat");
$tpl->setVariable("SMILEY_PATH", ilUtil::getHtmlPath(self::_getSmiliesBasePath().$row[1]));
$tpl->setVariable("SMILEY_ALT", urlencode($keywords[$x]));
$tpl->parseCurrentBlock();
$ar_replace[] = $tpl->get();
}
}
$str = str_replace($ar_search, $ar_replace, $str);
return $str;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_prepareKeywords (   $words)
static

Definition at line 348 of file class.ilChatSmilies.php.

Referenced by ilObjChatServerGUI\updateSmiliesObject(), and ilObjChatServerGUI\uploadSmileyObject().

{
$keywordscheck = true;
// check keywords
$keywords_unchecked = explode("\n", $words);
if (count($keywords_unchecked) <= 0)
$keywordscheck = false;
if ($keywordscheck) {
$keywords = array();
foreach($keywords_unchecked as $word) {
if (trim($word))
$keywords[] = trim($word);
}
}
if ($keywordscheck && count($keywords) <= 0)
$keywordscheck = false;
if ($keywordscheck)
return $keywords;
else
return array();
}

+ Here is the caller graph for this function:

static ilChatSmilies::_setupDatabase ( )
staticprivate

create table and sequence

Definition at line 35 of file class.ilChatSmilies.php.

References $ilDB.

Referenced by _initial().

{
global $ilDB;
$fields = array(
'smiley_id' => array(
'type' => 'integer',
'length' => 4,
),
'smiley_keywords' => array(
'type' => 'text',
'length' => 100,
),
'smiley_path' => array(
'type' => 'text',
'length' => 200,
)
);
$ilDB->dropTable("chat_smilies");
$ilDB->dropTable("chat_smilies_seq");
$ilDB->createTable('chat_smilies', $fields);
$ilDB->addPrimaryKey('chat_smilies', array('smiley_id'));
$ilDB->createSequence('chat_smilies');
}

+ Here is the caller graph for this function:

static ilChatSmilies::_setupFolder ( )
staticprivate

setup directory

Definition at line 102 of file class.ilChatSmilies.php.

References ilUtil\getWebspaceDir().

Referenced by _initial().

{
$path = ilUtil::getWebspaceDir().'/chat/smilies';
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatSmilies::_storeSmiley (   $keywords,
  $path 
)
static

Definition at line 330 of file class.ilChatSmilies.php.

References $ilDB, and $row.

Referenced by ilObjChatServerGUI\uploadSmileyObject().

{
global $ilDB;
$stmt = $ilDB->prepare("
INSERT INTO chat_smilies (smiley_id, smiley_keywords, smiley_path)
VALUES (?, ?, ?)",
array(
"integer", "text", "text"
)
);
$row = array(
$ilDB->nextID("chat_smilies"),
$keywords,
$path
);
$stmt->execute($row);
}

+ Here is the caller graph for this function:

static ilChatSmilies::_updateSmiley (   $data)
static

Definition at line 277 of file class.ilChatSmilies.php.

References $data, $ilDB, and _getSmiley().

Referenced by ilObjChatServerGUI\updateSmiliesObject().

{
global $ilDB;
$ilDB->manipulateF(
"UPDATE chat_smilies
SET smiley_keywords = %s
WHERE
smiley_id = %s",
array('text', 'integer'),
array($data["smiley_keywords"], $data["smiley_id"])
);
if ($data["smiley_path"]) {
$sm = self::_getSmiley($data["smiley_id"]);
unlink($sm["smiley_fullpath"]);
$ilDB->manipulateF(
"UPDATE chat_smilies
SET smiley_path = %s
WHERE
smiley_id = %s",
array('text', 'integer'),
array($data["smiley_path"], $data["smiley_id"])
);
}
}

+ 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: