X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=smileybutton%2Fsmileybutton.php;h=593eed8b0912c6b6484379d53dbafc34feb43e99;hb=8237e3cc692aca686b95bf4c1628d420e9227816;hp=d8c1533024704673b0ce5534d9d475e427912b4b;hpb=be1342fe5dee55f30f4c83d2da5cdc4f5bc46b16;p=friendica-addons.git diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php index d8c15330..593eed8b 100644 --- a/smileybutton/smileybutton.php +++ b/smileybutton/smileybutton.php @@ -5,29 +5,30 @@ * Version: 0.2 * Author: Johannes Schwab */ - +use Friendica\Core\Hook; +use Friendica\Core\Logger; function smileybutton_install() { - //Register hooks - register_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); - - logger("installed smileybutton"); + //Register hooks + Hook::register('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); + + Logger::log("installed smileybutton"); } function smileybutton_uninstall() { //Delet registered hooks - unregister_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); + Hook::unregister('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); - logger("removed smileybutton"); + Logger::log("removed smileybutton"); } -function show_button($a, &$b) { +function show_button(Friendica\App $a, &$b) { // Disable if theme is quattro // TODO add style for quattro - if (current_theme() == 'quattro') + if ($a->getCurrentTheme() == 'quattro') return; // Disable for mobile because most mobiles have a smiley key for ther own @@ -41,62 +42,62 @@ function show_button($a, &$b) { * */ - $texts = array( - '<3', - '</3', - ':-)', - ';-)', - ':-(', - ':-P', - ':-X', - ':-D', - ':-O', - '\\\\o/', - 'O_o', - ":\'(", - ":-!", - ":-/", - ":-[", + $texts = [ + '<3', + '</3', + ':-)', + ';-)', + ':-(', + ':-P', + ':-X', + ':-D', + ':-O', + '\\\\o/', + 'O_o', + ":\'(", + ":-!", + ":-/", + ":-[", "8-)", - ':beer', - ':coffee', + ':beer', + ':coffee', ':facepalm', ':like', ':dislike', '~friendica', 'red#' - ); - - $icons = array( - '<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 = array('texts' => $texts, 'icons' => $icons, 'string' => ""); //changed - call_hooks('smilie', $params); + $params = ['texts' => $texts, 'icons' => $icons, 'string' => ""]; //changed + Hook::callAll('smilie', $params); //Generate html for smiley list $s = "\n\t"; @@ -112,19 +113,19 @@ function show_button($a, &$b) { $s .= "\t
"; //Add css to header - $css_file = 'addon/smileybutton/view/'.current_theme().'.css'; - if (! file_exists($css_file)) + $css_file = 'addon/smileybutton/view/' . $a->getCurrentTheme() . '.css'; + if (! file_exists($css_file)) $css_file = 'addon/smileybutton/view/default.css'; - $css_url = $a->get_baseurl().'/'.$css_file; + $css_url = $a->getBaseURL().'/'.$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/' . $a->getCurrentTheme() . '.png'; + if (! file_exists($image)) $image = 'addon/smileybutton/view/default.png'; - $image_url = $a->get_baseurl().'/'.$image; + $image_url = $a->getBaseURL().'/'.$image; //Add the hmtl and script to the page $b = <<< EOT