Smileys
in package
implements
ActionInterface
uses
ActionTrait, 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 : static
Methods
- add() : void
- Add a smiley, that's right.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- edit() : void
- Add, remove, edit smileys.
- editIcon() : void
- Handles editing message icons
- editSets() : void
- List, add, remove, modify smileys sets.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- getConfigVars() : array<string|int, mixed>
- Gets the configuration variables for this admin area.
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- install() : void
- Install a smiley set.
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple 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() : static
- Static wrapper for constructor.
- setOrder() : void
- Allows to edit smileys order.
- settings() : void
- Handles modifying smileys settings.
- subActionProvider() : null|array<string|int, mixed>
- Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- createDir() : void
- findSmileysDir() : void
- Sets self::$smileys_dir and self::$smileys_dir_found.
- getKnownSmileySets() : void
- Populates self::$smiley_sets with info about known smiley sets.
- import() : void
- Imports new smileys from an existing directory into the database.
- moveImageIntoPlace() : array<string|int, mixed>
- resetCache() : void
- sanitizeFileName() : string
- sanitizeString() : string
- Sanitizes the string and trims unnecessary whitespace.
- saveSets() : void
- Saves the list of known smiley sets
- 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 static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
Methods
add()
Add a smiley, that's right.
public
add() : void
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
edit()
Add, remove, edit smileys.
public
edit() : void
editIcon()
Handles editing message icons
public
editIcon() : void
editSets()
List, add, remove, modify smileys sets.
public
editSets() : void
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
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.
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceinstall()
Install a smiley set.
public
install() : void
isAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boollist_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() : static
Return values
static —An instance of this class.
setOrder()
Allows to edit smileys order.
public
setOrder() : void
settings()
Handles modifying smileys settings.
public
settings() : void
subActionProvider()
Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
public
static subActionProvider([null|string $sa = null ][, bool $return_config = false ][, string|null $activity = null ]) : null|array<string|int, mixed>
Parameters
- $sa : null|string = null
- $return_config : bool = false
- $activity : string|null = null
Return values
null|array<string|int, mixed>__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
createDir()
protected
createDir(string $dir, string $name) : void
Parameters
- $dir : string
-
The directory to create
- $name : string
-
The name of the set
findSmileysDir()
Sets self::$smileys_dir and self::$smileys_dir_found.
protected
static findSmileysDir() : void
getKnownSmileySets()
Populates self::$smiley_sets with info about known smiley sets.
protected
static getKnownSmileySets() : void
import()
Imports new smileys from an existing directory into the database.
protected
import(string $smileyPath[, bool $create = false ]) : void
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
-
The desired name of the file
- $tmp_name : string
-
The temporary name of the file
- $destination_dirs : array<string|int, mixed>
-
An array of one or more directories to move this image to
Return values
array<string|int, mixed> —An array of information about the files that were moved
resetCache()
protected
static resetCache() : void
sanitizeFileName()
protected
static sanitizeFileName(string $string) : string
Parameters
- $string : string
Return values
stringsanitizeString()
Sanitizes the string and trims unnecessary whitespace.
protected
static sanitizeString(string $string) : string
Parameters
- $string : string
-
The string to sanitize.
Return values
string —The sanitized string.
saveSets()
Saves the list of known smiley sets
protected
static saveSets() : void
validateImage()
protected
validateImage(string $name, string $tmp_name) : bool
Parameters
- $name : string
-
The desired name for the file
- $tmp_name : string
-
The temporary name for the file
Return values
bool —Whether this is a valid image file