Skip to content

Commit

Permalink
Added more support v0.2
Browse files Browse the repository at this point in the history
Changed version number to 0.2
+ added mb_encode_numericentry to convert characters to decimal for
easier matching. (PHP 4.0.6)
* changed regex to add support for 4 character entities.
+ added range for new emojis.

Signed-off-by: sicommnend <sicommnend@users.noreply.github.com>
  • Loading branch information
sicommnend committed Mar 22, 2016
1 parent 0205012 commit 3d1034b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions install.xml
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>NEND:emojione</id>
<version>0.1</version>
<version>0.2</version>
<file name="$sourcedir/Subs.php">
<operation>
<search position="after"><![CDATA[ if (!empty($modSettings['autoLinkUrls']))
Expand All @@ -16,12 +16,13 @@
$no_autolink_area = true;
}]]></search>
<add><![CDATA[ //Beginning of EmojiOne support
preg_match_all('/&#([0-9]{6});/', $data, $matches, PREG_PATTERN_ORDER);
$data = mb_encode_numericentity ($data, array (0x1F000, 0x1F9FF, 0, 0x1F9FF,0x02600, 0x027FF, 0, 0x027FF), 'UTF-8');
preg_match_all('/&#([0-9]{4,6});/', $data, $matches, PREG_PATTERN_ORDER);
if (!empty($matches[0])) {
$replaces = array();
foreach ($matches[0] as $match => $dec) {
$int = substr($dec,2,-1);
if ($int >= 127344 && $int <= 128709) {
if ($int >= 126976 && $int <= 129535 || $int >= 9728 && $int <= 10239) {
$hex = dechex($int);
$replaces[$dec] = '<img src="http://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.1/assets/svg/'.$hex.'.svg" alt="'.$dec.'" class="smiley" />';
}
Expand Down
2 changes: 1 addition & 1 deletion package-info.xml
Expand Up @@ -3,7 +3,7 @@
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>NEND:emojione</id>
<name>Emoji One</name>
<version>0.1</version>
<version>0.2</version>
<type>modification</type>
<install>
<readme parsebbc="true">license.txt</readme>
Expand Down

0 comments on commit 3d1034b

Please sign in to comment.