- 0.1.0 (26/7/2013)
A sample emoji module for Zend Framework 2
1.😁 Hello World to 😄 Hello World
2.😁 Hello World to #1f601# Hello World (You can save it to MySQL < 5.5)
3.#1f601# Hello World to 😁 Hello World
4.😁 Hello World to <span class="emoji emoji1f601"></span> Hello World
5.#1f601# Hello World to <span class="emoji emoji1f601"></span> Hello World
Add this project in your composer.json:
"require": { "atans/emoji-module": "dev-master" }
Running this command
$ php composer.phar update```php
<?php
return array(
'modules' => array(
// ...
'EmojiModule',
),
);
```
Call
emojimodule_emoji_servicein a controllerpublicfunctionindexAction() { $emojiService = $this->getServiceLocator()->get('emojimodule_emoji_service'); $text = "\xF0\x9F\x98\x81 Hello World"; $variables = $emojiService->encode($text); // Output: #1f601# Hello World (You can save it to MySQL now)// Variables restore to unified$unified = $emojiService->decode($variables); // Output: \xF0\x9F\x98\x81 Hello World// Variables to Html$variablesToHtml = $emojiService->variablesToHtml($variables); // Output: <span class="emoji emoji1f601"></span> Hello World// Unified to html$unifiedToHtml = $emojiService->unifiedToHtml($unified); // Output: <span class="emoji emoji1f601"></span> Hello Worldreturnarray( 'unifiedToHtml' => $unifiedToHtml, ); }
View
copy
https://raw.github.com/iamcal/php-emoji/master/emoji.cssandhttps://github.com/iamcal/php-emoji/blob/master/emoji.pngto '/public/css/'<?php// application/index/index/index.phtml$this->headLink()->appendStylesheet($this->basePath() . '/public/css/emoji.css'); ?><?phpecho echo $unifiedToHtml?>
View Helper
<?php// application/index/index/index.phtmlecho$this->emoji()->unifiedToHtml('😁 Hello World') // Output: <span class="emoji emoji1f601"></span> Hello World?>
