Smileys
in package
implements
ActionInterface
Uses
BackwardCompatibility
This class takes care of all administration of smileys.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $allowed_extenions : array<string|int, mixed>
- $allowed_mime_types : array<string|int, mixed>
- $illegal_files : array<string|int, mixed>
- $smiley_sets : array<string|int, mixed>
- $smileys_dir : string
- $smileys_dir_found : bool
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- add() : mixed
- Add a smiley, that's right.
- addSmiley() : void
- Backward compatibility wrapper for the addsmiley sub-action.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- edit() : mixed
- Add, remove, edit smileys.
- editIcon() : mixed
- Handles editing message icons
- editMessageIcons() : void
- Backward compatibility wrapper for the editsets sub-action.
- editSets() : mixed
- List, add, remove, modify smileys sets.
- editSmileyOrder() : void
- Backward compatibility wrapper for the setorder sub-action.
- editSmileys() : void
- Backward compatibility wrapper for the editsmileys sub-action.
- editSmileySettings() : void|array<string|int, mixed>
- Backward compatibility wrapper for the settings sub-action.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- getConfigVars() : array<string|int, mixed>
- Gets the configuration variables for this admin area.
- install() : mixed
- Install a smiley set.
- installSmileySet() : void
- Backward compatibility wrapper for the install sub-action.
- list_getMessageIcons() : array<string|int, mixed>
- Callback function for SMF\ItemList().
- list_getNumSmileys() : int
- Callback function for SMF\ItemList().
- list_getNumSmileySets() : int
- Callback function for SMF\ItemList().
- list_getSmileys() : array<string|int, mixed>
- Callback function for SMF\ItemList().
- list_getSmileySets() : array<string|int, mixed>
- Callback function for SMF\ItemList().
- load() : object
- Static wrapper for constructor.
- setOrder() : mixed
- Allows to edit smileys order.
- settings() : void
- Handles modifying smileys settings.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- createDir() : mixed
- findSmileysDir() : mixed
- Sets self::$smileys_dir and self::$smileys_dir_found.
- getKnownSmileySets() : mixed
- Populates self::$smiley_sets with info about known smiley sets.
- import() : mixed
- Imports new smileys from an existing directory into the database.
- moveImageIntoPlace() : array<string|int, mixed>
- resetCache() : void
- sanitizeFileName() : string
- sanitizeString() : string
- saveSets() : mixed
- validateImage() : bool
Properties
$allowed_extenions
public
static array<string|int, mixed>
$allowed_extenions
= ['gif', 'png', 'jpg', 'jpeg', 'tiff', 'svg']
Allowed file extensions for smiley images.
$allowed_mime_types
public
static array<string|int, mixed>
$allowed_mime_types
= ['image/gif', 'image/png', 'image/jpeg', 'image/tiff', 'image/svg+xml']
Allowed MIME types for smiley images.
$illegal_files
public
static array<string|int, mixed>
$illegal_files
= ['con', 'com1', 'com2', 'com3', 'com4', 'prn', 'aux', 'lpt1', '.htaccess', 'index.php']
Forbidden file names. Uploading a smiley image with one of these names will give a fatal error.
$smiley_sets
public
static array<string|int, mixed>
$smiley_sets
= []
Info about all known smiley sets.
$smileys_dir
public
static string
$smileys_dir
Path to the base smileys directory. All smiley sets have subdirectories inside this directory.
$smileys_dir_found
public
static bool
$smileys_dir_found
Whether the base smileys directory exists in the file system.
$subaction
public
string
$subaction
= 'editsets'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['editsets' => 'editSets', 'import' => 'editSets', 'modifyset' => 'editSets', 'addsmiley' => 'add', 'editsmileys' => 'edit', 'modifysmiley' => 'edit', 'setorder' => 'setOrder', 'install' => 'install', 'editicon' => 'editIcon', 'editicons' => 'editIcon', 'settings' => 'settings']
Available sub-actions.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'ManageSmileys', 'list_getSmileySets' => 'list_getSmileySets', 'list_getNumSmileySets' => 'list_getNumSmileySets', 'list_getSmileys' => 'list_getSmileys', 'list_getNumSmileys' => 'list_getNumSmileys', 'list_getMessageIcons' => 'list_getMessageIcons', 'addSmiley' => 'AddSmiley', 'editSmileys' => 'EditSmileys', 'editSmileyOrder' => 'EditSmileyOrder', 'installSmileySet' => 'InstallSmileySet', 'editMessageIcons' => 'EditMessageIcons']]
BackwardCompatibility settings for this class.
Methods
add()
Add a smiley, that's right.
public
add() : mixed
addSmiley()
Backward compatibility wrapper for the addsmiley sub-action.
public
static addSmiley() : void
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
edit()
Add, remove, edit smileys.
public
edit() : mixed
editIcon()
Handles editing message icons
public
editIcon() : mixed
editMessageIcons()
Backward compatibility wrapper for the editsets sub-action.
public
static editMessageIcons() : void
editSets()
List, add, remove, modify smileys sets.
public
editSets() : mixed
editSmileyOrder()
Backward compatibility wrapper for the setorder sub-action.
public
static editSmileyOrder() : void
editSmileys()
Backward compatibility wrapper for the editsmileys sub-action.
public
static editSmileys() : void
editSmileySettings()
Backward compatibility wrapper for the settings sub-action.
public
editSmileySettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
- $return_config : bool = false
-
Whether to return the config_vars array.
Return values
void|array<string|int, mixed> —Returns nothing or returns the config_vars array.
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
getConfigVars()
Gets the configuration variables for this admin area.
public
static getConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —$config_vars for the news area.
install()
Install a smiley set.
public
install() : mixed
installSmileySet()
Backward compatibility wrapper for the install sub-action.
public
static installSmileySet() : void
list_getMessageIcons()
Callback function for SMF\ItemList().
public
static list_getMessageIcons(int $start, int $items_per_page, string $sort) : array<string|int, mixed>
Parameters
- $start : int
-
The item to start with (not used here)
- $items_per_page : int
-
The number of items to display per page (not used here)
- $sort : string
-
A string indicating how to sort the items (not used here)
Return values
array<string|int, mixed> —An array of information about message icons
list_getNumSmileys()
Callback function for SMF\ItemList().
public
static list_getNumSmileys() : int
Return values
int —The number of smileys
list_getNumSmileySets()
Callback function for SMF\ItemList().
public
static list_getNumSmileySets() : int
Tags
Return values
int —The total number of known smiley sets
list_getSmileys()
Callback function for SMF\ItemList().
public
static list_getSmileys(int $start, int $items_per_page, string $sort) : array<string|int, mixed>
Parameters
- $start : int
-
The item to start with (not used here)
- $items_per_page : int
-
The number of items to show per page (not used here)
- $sort : string
-
A string indicating how to sort the results
Return values
array<string|int, mixed> —An array of info about the smileys
list_getSmileySets()
Callback function for SMF\ItemList().
public
static list_getSmileySets(int $start, int $items_per_page, string $sort) : array<string|int, mixed>
Parameters
- $start : int
-
The item to start with (not used here)
- $items_per_page : int
-
The number of items to show per page (not used here)
- $sort : string
-
A string indicating how to sort the results
Tags
Return values
array<string|int, mixed> —An array of info about the smiley sets
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
setOrder()
Allows to edit smileys order.
public
setOrder() : mixed
settings()
Handles modifying smileys settings.
public
settings() : void
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
createDir()
protected
createDir(mixed $dir, mixed $name) : mixed
Parameters
- $dir : mixed
- $name : mixed
findSmileysDir()
Sets self::$smileys_dir and self::$smileys_dir_found.
protected
static findSmileysDir() : mixed
getKnownSmileySets()
Populates self::$smiley_sets with info about known smiley sets.
protected
static getKnownSmileySets() : mixed
import()
Imports new smileys from an existing directory into the database.
protected
import(string $smileyPath[, bool $create = false ]) : mixed
Parameters
- $smileyPath : string
-
The path to the directory to import smileys from
- $create : bool = false
-
Whether or not to make brand new smileys for files that don't match any existing smileys
moveImageIntoPlace()
protected
moveImageIntoPlace(string $name, string $tmp_name, array<string|int, mixed> $destination_dirs) : array<string|int, mixed>
Parameters
- $name : string
- $tmp_name : string
- $destination_dirs : array<string|int, mixed>
Return values
array<string|int, mixed>resetCache()
protected
static resetCache() : void
sanitizeFileName()
protected
static sanitizeFileName(string $string) : string
Parameters
- $string : string
Return values
stringsanitizeString()
protected
static sanitizeString(string $string) : string
Parameters
- $string : string
Return values
stringsaveSets()
protected
static saveSets() : mixed
validateImage()
protected
validateImage(string $name, string $tmp_name) : bool
Parameters
- $name : string
- $tmp_name : string