diff --git a/smileybutton/icon.gif b/smileybutton/icon.gif new file mode 100644 index 000000000..e3fe6a55c Binary files /dev/null and b/smileybutton/icon.gif differ diff --git a/smileybutton/smileybutton.css b/smileybutton/smileybutton.css new file mode 100755 index 000000000..bb84030f8 --- /dev/null +++ b/smileybutton/smileybutton.css @@ -0,0 +1,14 @@ + + + +#smileybutton-enable-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#smileybutton-checkbox { + float: left; +} + + diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php new file mode 100755 index 000000000..d6520a75b --- /dev/null +++ b/smileybutton/smileybutton.php @@ -0,0 +1,254 @@ + + */ + + +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()) + return; + + $active = get_pconfig(local_user(), 'smileybutton', 'enable'); + + if(! $active) + return; + + /** + * + * Prepare the Smilie-Arrays + * + */ + + /** + * + * I have copied this from /include/text.php and removed dobles + * + */ + + $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('smiley', $params); + + + /** + * + * Generate html for smileylist + * + */ + + $s = "\t"; + for($x = 0; $x < count($params['texts']); $x ++) { + $icon = $params['icons'][$x]; + $icon = str_replace('/>', 'onclick="smileybutton_addsmiley(\'' . $params['texts'][$x] . '\')"/>', $icon); + $s .= $icon . ' '; + if ($x != 0 && $x % 10 == 0) { + $s .= "
\n\t"; + } + } + + /** + * + * Add the button to the Inputbox + * + */ + + $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 + * + */ + + $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','enable',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 */ + + $enabled = get_pconfig(local_user(),'smileybutton','enable'); + + $checked = (($enabled) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

Smileybutton settings

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