PHP Класс Emoji, vanilla

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
__construct ( )
checkAliases ( ) Check the alias array and filter out all of the emoji that are not present in the main emoji list.

Описание методов

__construct() защищенный Метод

protected __construct ( )

buildEmojiPath() публичный Метод

This method is deprecated. See {@link Emoji::getEmojiPath()}.
public buildEmojiPath ( string $emojiName ) : string
$emojiName string
Результат string

checkAliases() защищенный Метод

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

getAliases() публичный Метод

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
Результат array Returns an array of alias to emoji name entries.

getArchive() публичный Метод

Gets the emoji archive.
public getArchive ( ) : array
Результат array Returns an array of emoji name to emoji file names representing the emoji archie.

getAssetPath() публичный Метод

Gets the asset path location.
public getAssetPath ( ) : string
Результат string The asset path location

getEditorList() публичный Метод

Get the emoji editor list.
public getEditorList ( ) : array
Результат array Returns an array of Emojis that can appear in an editor drop down.

getEmoji() публичный Метод

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
Результат string | array File name or full canonical array

getEmojiEditorList() публичный Метод

public getEmojiEditorList ( ) : array
Результат array List of Emojis that will appear in the editor.

getEmojiPath() публичный Метод

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.
Результат string Root-relative path.

getFormat() публичный Метод

Gets the emoji format used in {@link Emoji::img()}.
public getFormat ( ) : string
Результат string Returns the current emoji format.

hasEditorList() публичный Метод

Checks whether or not the emoji has an editor list.
public hasEditorList ( ) : boolean
Результат boolean Returns true if there is an editor list or false otherwise.

img() публичный Метод

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.
Результат string The html that represents the emoji.

instance() публичный статический Метод

Get the singleton instance of this class.
public static instance ( ) : Emoji
Результат Emoji

setAliases() публичный Метод

Set the aliases array.
public setAliases ( array $aliases ) : Emoji
$aliases array The new aliases array.
Результат Emoji Returns $this for fluent calls.

setArchive() публичный Метод

Set the emoji archive.
public setArchive ( array $archive ) : Emoji
$archive array
Результат Emoji Returns $this for fluent calls.

setAssetPath() публичный Метод

public setAssetPath ( string $assetPath )
$assetPath string

setEditorList() публичный Метод

Set the list of emoji that can be used by the editor.
public setEditorList ( array $value ) : Emoji
$value array The new editor list.
Результат Emoji Returns $this for fluent calls.

setEmoji() публичный Метод

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

setEmojiEditorList() публичный Метод

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

setFormat() публичный Метод

Sets the emoji format used in {@link Emoji::img()}.
public setFormat ( string $format ) : Emoji
$format string
Результат Emoji Returns $this for fluent calls.

setFromManifest() публичный Метод

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() публичный Метод

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
Результат string Return the emoji-formatted post

Описание свойств

$aliases защищенное свойство

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

$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.
protected $archive

$assetPath защищенное свойство

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

$assetPathOriginal защищенное свойство

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

$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.
protected $editorList

$emoji защищенное свойство

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

$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.
protected $emojiOriginalUnaccountedFor

$enabled публичное свойство

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

$errorEmoji защищенное свойство

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

$format защищенное свойство

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

$instance публичное статическое свойство

The singleton instance of this class.
public static $instance

$ldelim публичное свойство

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

$rdelim публичное свойство

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