PHP Class Emoji, vanilla

Afficher le fichier Open project: vanilla/vanilla Class Usage Examples

Méthodes publiques

Свойство Type Description
$enabled Setting to true will allow editor to interpret emoji aliases as Html equivalent markup.
$instance The singleton instance of this class.
$ldelim left-side delimiter surrounding emoji, typically a full-colon.
$rdelim right-side delimiter surrounding emoji, typically a full-colon

Protected Properties

Свойство Type Description
$aliases The emoji aliases are an array where each key is an alias and each value is the name of an emoji.
$archive The archive can be used for a couple of purposes. 1. If you want to remove an emoji from the lookup list then you can just move the entry from the $emoji array to the $archive array. 2. If you want to rename an emoji then copy it to the $archive array and then rename it in the $emoji array.
$assetPath The base path where the emoji are located.
$assetPathOriginal If assetPath is modified, this will hold the original path.
$editorList An emoji alias list that represents the emoji that display in an editor drop down. Typically, it is a copy of the alias list.
$emoji ~~~ array ( 'emoji_name' => 'filename.png' ) ~~~
$emojiOriginalUnaccountedFor The original emoji that are not accounted for in the custom set of emoji supplied by plugin, if any. This is useful when merging the custom ones with the original ones, which have different assetPaths.
$errorEmoji This is the emoji name that will represent the error emoji.
$format The sprintf format for emoji with the following parameters. - %1$s: The emoji path. - %2$s: The emoji code.

Méthodes publiques

Méthode Description
buildEmojiPath ( string $emojiName ) : string This method is deprecated. See {@link Emoji::getEmojiPath()}.
getAliases ( ) : array Populate this with any aliases required for plugin, make sure they point to canonical translation, and plugin will add everything to drop down that is listed. To expand, simply define more aliases that corresponded with canonical list.
getArchive ( ) : array Gets the emoji archive.
getAssetPath ( ) : string Gets the asset path location.
getEditorList ( ) : array Get the emoji editor list.
getEmoji ( ) : string | array This is the canonical, e.g., official, list of emoji names along with their associatedwith image file name. For an exhaustive list of emoji names visit http://www.emoji-cheat-sheet.com/ and for the original image files being used, visit https://github.com/taninamdar/Apple-Color-Emoji
getEmojiEditorList ( ) : array
getEmojiPath ( string $emojiName ) : string Provide this method with the official emoji filename and it will return the correct path.
getFormat ( ) : string Gets the emoji format used in {@link Emoji::img()}.
hasEditorList ( ) : boolean Checks whether or not the emoji has an editor list.
img ( string $emoji_path, string $emoji_name ) : string Accept an Emoji path and name, and return the corresponding HTML IMG tag.
instance ( ) : Emoji Get the singleton instance of this class.
setAliases ( array $aliases ) : Emoji Set the aliases array.
setArchive ( array $archive ) : Emoji Set the emoji archive.
setAssetPath ( string $assetPath )
setEditorList ( array $value ) : Emoji Set the list of emoji that can be used by the editor.
setEmoji ( array $emoji ) Sets custom emoji, and saves the original ones that are unaccounted for.
setEmojiEditorList ( array $value ) Set the list of emoji that can be used by the editor.
setFormat ( string $format ) : Emoji Sets the emoji format used in {@link Emoji::img()}.
setFromManifest ( array $manifest, string $assetPath = '' ) Set the emoji from a manifest.
translateToHtml ( string $Text ) : string Translate all emoji aliases to their corresponding Html image tags.

Méthodes protégées

Méthode Description
__construct ( )
checkAliases ( ) Check the alias array and filter out all of the emoji that are not present in the main emoji list.

Method Details

__construct() protected méthode

protected __construct ( )

buildEmojiPath() public méthode

This method is deprecated. See {@link Emoji::getEmojiPath()}.
public buildEmojiPath ( string $emojiName ) : string
$emojiName string
Résultat string

checkAliases() protected méthode

Check the alias array and filter out all of the emoji that are not present in the main emoji list.
protected checkAliases ( )

getAliases() public méthode

Note: some aliases require {@link htmlentities()} filtering, which is done directly before output in the drop down, and while searching for the string to replace in the regex, NOT here. The reason for this is so the alias list does not get littered with characters entity encodings like <, which makes it difficult to immediately know what the aliases do. Also, {@link htmlentities} would have to be revered in areas such as title attributes, which counteracts the usefulness of having it done here.
public getAliases ( ) : array
Résultat array Returns an array of alias to emoji name entries.

getArchive() public méthode

Gets the emoji archive.
public getArchive ( ) : array
Résultat array Returns an array of emoji name to emoji file names representing the emoji archie.

getAssetPath() public méthode

Gets the asset path location.
public getAssetPath ( ) : string
Résultat string The asset path location

getEditorList() public méthode

Get the emoji editor list.
public getEditorList ( ) : array
Résultat array Returns an array of Emojis that can appear in an editor drop down.

getEmoji() public méthode

This is the canonical, e.g., official, list of emoji names along with their associatedwith image file name. For an exhaustive list of emoji names visit http://www.emoji-cheat-sheet.com/ and for the original image files being used, visit https://github.com/taninamdar/Apple-Color-Emoji
public getEmoji ( ) : string | array
Résultat string | array File name or full canonical array

getEmojiEditorList() public méthode

public getEmojiEditorList ( ) : array
Résultat array List of Emojis that will appear in the editor.

getEmojiPath() public méthode

Provide this method with the official emoji filename and it will return the correct path.
public getEmojiPath ( string $emojiName ) : string
$emojiName string File name of emoji icon.
Résultat string Root-relative path.

getFormat() public méthode

Gets the emoji format used in {@link Emoji::img()}.
public getFormat ( ) : string
Résultat string Returns the current emoji format.

hasEditorList() public méthode

Checks whether or not the emoji has an editor list.
public hasEditorList ( ) : boolean
Résultat boolean Returns true if there is an editor list or false otherwise.

img() public méthode

Accept an Emoji path and name, and return the corresponding HTML IMG tag.
public img ( string $emoji_path, string $emoji_name ) : string
$emoji_path string The full path to Emoji file.
$emoji_name string The name given to Emoji.
Résultat string The html that represents the emoji.

instance() public static méthode

Get the singleton instance of this class.
public static instance ( ) : Emoji
Résultat Emoji

setAliases() public méthode

Set the aliases array.
public setAliases ( array $aliases ) : Emoji
$aliases array The new aliases array.
Résultat Emoji Returns $this for fluent calls.

setArchive() public méthode

Set the emoji archive.
public setArchive ( array $archive ) : Emoji
$archive array
Résultat Emoji Returns $this for fluent calls.

setAssetPath() public méthode

public setAssetPath ( string $assetPath )
$assetPath string

setEditorList() public méthode

Set the list of emoji that can be used by the editor.
public setEditorList ( array $value ) : Emoji
$value array The new editor list.
Résultat Emoji Returns $this for fluent calls.

setEmoji() public méthode

Sets custom emoji, and saves the original ones that are unaccounted for.
public setEmoji ( array $emoji )
$emoji array

setEmojiEditorList() public méthode

Set the list of emoji that can be used by the editor.
public setEmojiEditorList ( array $value )
$value array The new editor list.

setFormat() public méthode

Sets the emoji format used in {@link Emoji::img()}.
public setFormat ( string $format ) : Emoji
$format string
Résultat Emoji Returns $this for fluent calls.

setFromManifest() public méthode

Set the emoji from a manifest.
public setFromManifest ( array $manifest, string $assetPath = '' )
$manifest array An emoji manifest with the following keys: - emoji: An array in the form: name => filename (ex. ['smile' => 'smile.png']) - aliases (optional): An array of emoji short forms: alias => emojiName (ex. [':)' => 'smile']) - editor (optional): An array of emoji that will display in the editor: emojiName (ex: [smile,..]) - format (optional): The string format of the emoji replacement.
$assetPath string The asset path root to all of the emoji files.

translateToHtml() public méthode

Thanks to punbb 1.3.5 (GPL License) for function, which was largely inspired from their do_smilies function.
public translateToHtml ( string $Text ) : string
$Text string The actual user-submitted post
Résultat string Return the emoji-formatted post

Property Details

$aliases protected_oe property

The emoji aliases are an array where each key is an alias and each value is the name of an emoji.
protected $aliases

$archive protected_oe property

The archive can be used for a couple of purposes. 1. If you want to remove an emoji from the lookup list then you can just move the entry from the $emoji array to the $archive array. 2. If you want to rename an emoji then copy it to the $archive array and then rename it in the $emoji array.
protected $archive

$assetPath protected_oe property

The base path where the emoji are located.
protected $assetPath

$assetPathOriginal protected_oe property

If assetPath is modified, this will hold the original path.
protected $assetPathOriginal

$editorList protected_oe property

An emoji alias list that represents the emoji that display in an editor drop down. Typically, it is a copy of the alias list.
protected $editorList

$emoji protected_oe property

~~~ array ( 'emoji_name' => 'filename.png' ) ~~~
protected $emoji

$emojiOriginalUnaccountedFor protected_oe property

The original emoji that are not accounted for in the custom set of emoji supplied by plugin, if any. This is useful when merging the custom ones with the original ones, which have different assetPaths.
protected $emojiOriginalUnaccountedFor

$enabled public_oe property

Setting to true will allow editor to interpret emoji aliases as Html equivalent markup.
public $enabled

$errorEmoji protected_oe property

This is the emoji name that will represent the error emoji.
protected $errorEmoji

$format protected_oe property

The sprintf format for emoji with the following parameters. - %1$s: The emoji path. - %2$s: The emoji code.
protected $format

$instance public_oe static_oe property

The singleton instance of this class.
public static $instance

$ldelim public_oe property

left-side delimiter surrounding emoji, typically a full-colon.
public $ldelim

$rdelim public_oe property

right-side delimiter surrounding emoji, typically a full-colon
public $rdelim