ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilChatroomSmilies Class Reference

Class ilChatroomSmilies. More...

+ Collaboration diagram for ilChatroomSmilies:

Static Public Member Functions

static _initial ()
 Performs initial setup (db, dirs, default data) More...
 
static _checkSetup ()
 Checks if smiley folder is available; if not it will try to create folder and performs actions for an initial smiley set. More...
 
static _getSmileyDir ()
 Path to smilies. More...
 
static _deleteMultipleSmilies ($ids=array())
 Deletes multiple smilies by given id array. More...
 
static _getSmiliesBasePath ()
 Returns smilies basepath. More...
 
static _prepareKeywords ($words)
 Trims given keywords and returns them in one array. More...
 

Static Private Member Functions

static _setupFolder ()
 Setup directory. More...
 

Detailed Description

Class ilChatroomSmilies.

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

Definition at line 10 of file class.ilChatroomSmilies.php.

Member Function Documentation

◆ _checkSetup()

static ilChatroomSmilies::_checkSetup ( )
static

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

Returns
boolean

Definition at line 117 of file class.ilChatroomSmilies.php.

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

Referenced by ilChatroomAdminSmileyGUI\editSmiliesObject().

118  {
119  global $lng;
120 
121  $path = self::_getSmileyDir();
122 
123  if(!is_dir($path))
124  {
125  ilUtil::sendInfo($lng->txt('chatroom_smilies_dir_not_exists'));
127 
128  if(!is_dir($path))
129  {
130  ilUtil::sendFailure($lng->txt('chatroom_smilies_dir_not_available'));
131  return false;
132  }
133  else
134  {
135  $smilies = array(
136  "icon_smile.gif",
137  "icon_wink.gif",
138  "icon_laugh.gif",
139  "icon_sad.gif",
140  "icon_shocked.gif",
141  "icon_tongue.gif",
142  "icon_cool.gif",
143  "icon_eek.gif",
144  "icon_angry.gif",
145  "icon_flush.gif",
146  "icon_idea.gif",
147  "icon_thumbup.gif",
148  "icon_thumbdown.gif",
149  );
150 
151  foreach($smilies as $smiley)
152  {
153  copy("templates/default/images/emoticons/$smiley", $path . "/$smiley");
154  }
155 
156  self::_insertDefaultValues();
157  ilUtil::sendSuccess($lng->txt('chatroom_smilies_initialized'));
158  }
159  }
160 
161  if(!is_writable($path))
162  {
163  ilUtil::sendInfo($lng->txt('chatroom_smilies_dir_not_writable'));
164  }
165 
166  return true;
167  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$path
Definition: aliased.php:25
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteMultipleSmilies()

static ilChatroomSmilies::_deleteMultipleSmilies (   $ids = array())
static

Deletes multiple smilies by given id array.

ilDBInterface $ilDB

Parameters
array$ids

Definition at line 210 of file class.ilChatroomSmilies.php.

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

Referenced by ilChatroomAdminSmileyGUI\updateSmiliesObject().

211  {
212  global $ilDB;
213 
214  $smilies = self::_getSmiliesById($ids);
215 
216  if(count($smilies) <= 0)
217  return;
218 
219  $sql_parts = array();
220 
221  foreach($smilies as $s)
222  {
223  unlink($s["smiley_fullpath"]);
224  $sql_parts[] = "smiley_id = " . $ilDB->quote($s["smiley_id"], 'integer');
225  }
226 
227  $ilDB->manipulate("DELETE FROM chatroom_smilies WHERE " . implode(" OR ", $sql_parts));
228  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSmileyDir()

static ilChatroomSmilies::_getSmileyDir ( )
static

Path to smilies.

Returns
string

Definition at line 173 of file class.ilChatroomSmilies.php.

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

174  {
175  return ilUtil::getWebspaceDir() . '/chatroom/smilies';
176  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ _getSmiliesBasePath()

static ilChatroomSmilies::_getSmiliesBasePath ( )
static

Returns smilies basepath.

Returns
string

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

References $ilDB, $path, $row, array, and ilUtil\getWebspaceDir().

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

349  {
350  return ilUtil::getWebspaceDir() . '/chatroom/smilies/';
351  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initial()

static ilChatroomSmilies::_initial ( )
static

Performs initial setup (db, dirs, default data)

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

References $ilDB, $row, and array.

16  {
17  self::_setupDatabase();
18  self::_insertDefaultValues();
19  self::_setupFolder();
20  }

◆ _prepareKeywords()

static ilChatroomSmilies::_prepareKeywords (   $words)
static

Trims given keywords and returns them in one array.

Parameters
string$words
Returns
array

Definition at line 418 of file class.ilChatroomSmilies.php.

References array.

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

419  {
420  $keywordscheck = true;
421 
422  // check keywords
423  $keywords_unchecked = explode("\n", $words);
424  if(count($keywords_unchecked) <= 0)
425  $keywordscheck = false;
426 
427  if($keywordscheck)
428  {
429  $keywords = array();
430 
431  foreach($keywords_unchecked as $word)
432  {
433  if(trim($word))
434  $keywords[] = trim($word);
435  }
436  }
437 
438  if($keywordscheck && count($keywords) <= 0)
439  $keywordscheck = false;
440 
441  if($keywordscheck)
442  return $keywords;
443  else
444  return array();
445  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _setupFolder()

static ilChatroomSmilies::_setupFolder ( )
staticprivate

Setup directory.

Definition at line 101 of file class.ilChatroomSmilies.php.

References $path, and ilUtil\getWebspaceDir().

102  {
103  $path = ilUtil::getWebspaceDir() . '/chatroom/smilies';
104 
105  if(!is_dir($path))
106  {
107  mkdir($path, 0755, true);
108  }
109  }
$path
Definition: aliased.php:25
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

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