X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=smileybutton%2Fsmileybutton.php;h=50a61606831f75da69d328846059c093c1edf9d0;hb=1f4fc0ea897f8e2fd95d3c689382a2404a58c684;hp=d53794b904f8145908d2d28b1a21c62009b7df91;hpb=b2e60b8c61565abf60367f1919ba5ae6b9c0a5fb;p=friendica-addons.git diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php index d53794b9..50a61606 100755 --- a/smileybutton/smileybutton.php +++ b/smileybutton/smileybutton.php @@ -2,68 +2,42 @@ /** * Name: Smileybutton * Description: Adds a smileybutton to the Inputbox - * Version: 0.1 - * Author: Johannes Schwab + * Version: 0.2 + * Author: Johannes Schwab */ function smileybutton_install() { - - /** - * - * Register hooks for jot_tool and plugin_settings - * - */ - + //Register hooks 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 - * - */ - + //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) { + // Disable if theme is quattro + // TODO add style for quattro + if (current_theme() == 'quattro') + return; - /** - * - * 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 - * - */ + // 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 dobles - * and some escapes. + * I have copied this from /include/text.php, removed doubles + * and escaped them. * */ @@ -120,22 +94,12 @@ function show_button($a, &$b) { 'red' ); - /** - * - * Call hooks to get aditional smileies from other addons - * - */ - + // 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"; + //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); @@ -145,139 +109,58 @@ function show_button($a, &$b) { $s .= "\n\t"; } } - $s .= "\t
\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 .= "\t"; - $s .= '
'; - $s .= '

Smileybutton settings

'; - $s .= '
'; + //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; - $s .= 'You can hide the button and show the smilies directly.

'; + $a->page['htmlhead'] .= ''."\r\n"; - $s .= ''; - $s .= ''; - - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; + + //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; }