*/ use Friendica\Core\Addon; function smileybutton_install() { //Register hooks Addon::registerHook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); logger("installed smileybutton"); } function smileybutton_uninstall() { //Delet registered hooks Addon::unregisterHook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); logger("removed smileybutton"); } function show_button($a, &$b) { // Disable if theme is quattro // TODO add style for quattro if (current_theme() == 'quattro') return; // Disable for mobile because most mobiles have a smiley key for ther own if ($a->is_mobile || $a->is_tablet) return; /** * * I have copied this from /include/text.php, removed doubles * and escaped them. * */ $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 Addon::callHooks('smilie', $params); //Generate html for smiley list $s = "\n\t"; for($x = 0; $x < count($params['texts']); $x ++) { $icon = $params['icons'][$x]; $icon = str_replace('/>', 'onclick="smileybutton_addsmiley(\'' . $params['texts'][$x] . '\')"/>', $icon); $icon = str_replace('class="smiley"', 'class="smiley_preview"', $icon); $s .= ""; if (($x+1) % (sqrt(count($params['texts']))+1) == 0) { $s .= "\n\t"; } } $s .= "\t
" . $icon . "
"; //Add css to header $css_file = 'addon/smileybutton/view/'.current_theme().'.css'; if (! file_exists($css_file)) $css_file = 'addon/smileybutton/view/default.css'; $css_url = $a->get_baseurl().'/'.$css_file; $a->page['htmlhead'] .= ''."\r\n"; //Get the correct image for the theme $image = 'addon/smileybutton/view/'.current_theme().'.png'; if (! file_exists($image)) $image = 'addon/smileybutton/view/default.png'; $image_url = $a->get_baseurl().'/'.$image; //Add the hmtl and script to the page $b = <<< EOT
smiley
EOT; }