*/ function smileybutton_install() { /** * * Register hooks for jot_tool and plugin_settings * */ register_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); register_hook('plugin_settings', 'addon/smileybutton/smileybutton.php', 'smileybutton_settings'); register_hook('plugin_settings_post', 'addon/smileybutton/smileybutton.php', 'smileybutton_settings_post'); logger("installed smileybutton"); } function smileybutton_uninstall() { /** * * Delet registered hooks * */ unregister_hook('jot_tool', 'addon/smileybutton/smileybutton.php', 'show_button'); unregister_hook('plugin_settings', 'addon/smileybutton/smileybutton.php', 'smileybutton_settings'); unregister_hook('plugin_settings_post', 'addon/smileybutton/smileybutton.php', 'smileybutton_settings_post'); logger("removed smileybutton"); } function show_button($a, &$b) { /** * * Check if it is a local user and he has enabled smileybutton * */ if(! local_user()) { $nobutton = false; } else { $nobutton = get_pconfig(local_user(), 'smileybutton', 'nobutton'); } /** * * Prepare the Smilie-Arrays * */ /** * * I have copied this from /include/text.php, removed dobles * and some escapes. * */ $texts = array( '<3', '</3', ':-)', ';-)', ':-(', ':-P', ':-X', ':-D', ':-O', '\\\\o/', 'O_o', ":\'(", ":-!", ":-/", ":-[", "8-)", ':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' ); /** * * Call hooks to get aditional smileies from other addons * */ $params = array('texts' => $texts, 'icons' => $icons, 'string' => ""); //changed call_hooks('smilie', $params); /** * * Generate html for smileylist * */ $s = "\t\n"; 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 . "
\n"; /** * * Add css to page * */ $a->page['htmlhead'] .= '' . "\r\n"; /** * * Add the button to the Inputbox * */ if (! $nobutton) { $b = "
\n"; $b .= "\tget_baseurl() . "/addon/smileybutton/icon.gif\" onclick=\"toggle_smileybutton()\" alt=\"smiley\">\n"; $b .= "\t
\n"; } /** * * Write the smileies to an (hidden) div * */ if ($nobutton) { $b .= "\t
\n"; } else { $b .= "\t
\n"; } $b .= $s . "\n"; $b .= "
\n"; /** * * Function to show and hide the smiley-list in the hidden div * */ $b .= "\n"; } /** * * Set the configuration * */ function smileybutton_settings_post($a,$post) { if(! local_user()) return; if($_POST['smileybutton-submit']) set_pconfig(local_user(),'smileybutton','nobutton',intval($_POST['smileybutton'])); } /** * * Add configuration-dialog to form * */ function smileybutton_settings(&$a,&$s) { if(! local_user()) return; /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variable */ $nobutton = get_pconfig(local_user(),'smileybutton','nobutton'); $checked = (($nobutton) ? ' checked="checked" ' : ''); /* Add some HTML to the existing form */ $s .= '
'; $s .= '

Smileybutton settings

'; $s .= '
'; $s .= 'You can hide the button and show the smilies directly.

'; $s .= ''; $s .= ''; $s .= '
'; /* provide a submit button */ $s .= '
'; }