* Maintainer: Hypolite Petovan */ use Friendica\Core\Hook; use Friendica\DI; function smileybutton_install() { //Register hooks Hook::register('jot_tool', 'addon/smileybutton/smileybutton.php', 'smileybutton_jot_tool'); } function smileybutton_jot_tool(string &$body) { // this plugin may have smilies mobile devices do not have, disable for mobile by uncommenting return below if (DI::mode()->isMobile() || DI::mode()->isMobile()) { // return; } $texts = [ '<3', '</3', ':-)', ';-)', ':-(', ':-P', ':-X', ':-D', ':-O', '\\\\o/', 'O_o', ':\'(', ':-!', ':-/', ':-[', '8-)', ':beer', ':coffee', ':facepalm', ':like', ':dislike', '~friendica', 'red#', ]; $icons = [ '<3', '</3', ':-)', ';-)', ':-(', ':-P', ':-X', ':-D', ':-O', '\\o/', 'O_o', ':\'(', ':-!', ':-/', ':-[', '8-)', ':beer', ':coffee', ':facepalm', ':like', ':dislike', '~friendica', 'red' ]; // Call hooks to get aditional smileies from other addons $params = ['texts' => $texts, 'icons' => $icons, 'string' => '']; //changed Hook::callAll('smilie', $params); //Generate html for smiley list $s = '
'; for ($x = 0; $x < count($params['texts']); $x++) { $icon = $params['icons'][$x]; $s .= '' . $icon . ''; if (($x + 1) % (floor(sqrt(count($params['texts']))) + 1) == 0) { $s .= '
'; } } $s .= ''; //Add css to header $css_file = __DIR__ . '/view/' . DI::appHelper()->getCurrentTheme() . '.css'; if (!file_exists($css_file)) { $css_file = __DIR__ . '/view/default.css'; } DI::page()->registerStylesheet($css_file); //Get the correct image for the theme $image = 'addon/smileybutton/view/' . DI::appHelper()->getCurrentTheme() . '.png'; if (!file_exists($image)) { $image = 'addon/smileybutton/view/default.png'; } $image_url = DI::baseUrl() . '/' . $image; //Add the hmtl and script to the page $body .= <<< EOT
$s
EOT; }