PHP Class Emoji, vanilla

ファイルを表示 Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property 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

Property 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.

Public Methods

Method 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.

Protected Methods

Method 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 method

protected __construct ( )

buildEmojiPath() public method

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

checkAliases() protected method

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

getAliases() public method

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
return array Returns an array of alias to emoji name entries.

getArchive() public method

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

getAssetPath() public method

Gets the asset path location.
public getAssetPath ( ) : string
return string The asset path location

getEditorList() public method

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

getEmoji() public method

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
return string | array File name or full canonical array

getEmojiEditorList() public method

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

getEmojiPath() public method

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.
return string Root-relative path.

getFormat() public method

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

hasEditorList() public method

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

img() public method

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.
return string The html that represents the emoji.

instance() public static method

Get the singleton instance of this class.
public static instance ( ) : Emoji
return Emoji

setAliases() public method

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

setArchive() public method

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

setAssetPath() public method

public setAssetPath ( string $assetPath )
$assetPath string

setEditorList() public method

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

setEmoji() public method

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

setEmojiEditorList() public method

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

setFormat() public method

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

setFromManifest() public method

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 method

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
return 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