Page 1 of 1

emoticonChooser for comments

Posted: Sun Jul 24, 2005 4:07 pm
by n00b
Hi

Is there a way (of course there is I guess ;)) to use the emoticonChooser plugin for the comments? I tried to add the function for (in the first step) one emoticon but it did not work. I have to admit that I'm not quite sure which file to edit. So far I mostly edited the emoticate plugin for testing.

Any hints?

Thx & regards

Re: emoticonChooser for comments

Posted: Sun Jul 24, 2005 4:26 pm
by garvinhicking
Thanks! That was a very good suggestion. I just patched the plugin as version 1.2 and committed it to CVS; it should be available within the next 24 hours.

Regards,
Garvin

Posted: Sun Jul 24, 2005 4:45 pm
by n00b
wooha! THAT was quick! :)

Thx. I'm looking forward to see the diff and the way it was done ;)

Posted: Sun Jul 24, 2005 5:11 pm
by garvinhicking
:)

If you care, here's the diff:

Code: Select all

Index: serendipity_event_emoticonchooser.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_event_emoticonchooser/serendipity_event_emoticonchooser.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- serendipity_event_emoticonchooser.php	8 Jul 2005 13:07:46 -0000	1.11
+++ serendipity_event_emoticonchooser.php	24 Jul 2005 12:23:57 -0000	1.12
@@ -1,4 +1,4 @@
-<?php # $Id: serendipity_event_emoticonchooser.php,v 1.11 2005/07/08 13:07:46 garvinhicking Exp $
+<?php # $Id: serendipity_event_emoticonchooser.php,v 1.12 2005/07/24 12:23:57 garvinhicking Exp $
 
 // Probe for a language include with constants. Still include defines later on, if some constants were missing
 $probelang = dirname(__FILE__) . '/lang_' . $serendipity['lang'] . '.inc.php';
@@ -10,6 +10,7 @@
     case 'de':
         @define('PLUGIN_EVENT_EMOTICONCHOOSER_TITLE', 'Smilie-Auswahlleiste');
         @define('PLUGIN_EVENT_EMOTICONCHOOSER_DESC', 'Zeigt eine Auswahlleiste bei der Erstellung eines Eintrags um Smilies einzufügen. Funktioniert NICHT im WYSIWYG-Editor!');
+        @define('PLUGIN_EVENT_EMOTICONCHOOSER_FRONTEND', 'Smilie-Auswahl für Kommentare anbieten?');
         break;
 
     case 'en':
@@ -17,6 +18,7 @@
     default:
         @define('PLUGIN_EVENT_EMOTICONCHOOSER_TITLE', 'Show Emoticon toolbar');
         @define('PLUGIN_EVENT_EMOTICONCHOOSER_DESC', 'Shows a toolbar to select emoticons to insert into your entry. Does NOT work in the WYSIWYG editor!');
+        @define('PLUGIN_EVENT_EMOTICONCHOOSER_FRONTEND', 'Show emoticon selector for comments?');
         break;
 }
 
@@ -37,18 +39,35 @@
             'smarty'      => '2.6.7',
             'php'         => '4.1.0'
         ));
-        $propbag->add('version',       '1.1');
+        $propbag->add('version',       '1.2');
         $propbag->add('event_hooks',    array(
             'backend_entry_toolbar_extended' => true,
             'backend_entry_toolbar_body' => true,
+            'frontend_comment' => true
         ));
         $propbag->add('groups', array('BACKEND_EDITOR'));
+        $propbag->add('configuration', array('frontend'));
     }
 
     function generate_content(&$title) {
         $title = PLUGIN_EVENT_EMOTICONCHOOSER_TITLE;
     }
 
+    function introspect_config_item($name, &$propbag)
+    {
+        switch($name) {
+            case 'frontend':
+                $propbag->add('type',        'boolean');
+                $propbag->add('name',        PLUGIN_EVENT_EMOTICONCHOOSER_FRONTEND);
+                $propbag->add('description', '');
+                $propbag->add('default',     false);
+                return true;
+                break;
+        }
+        return false;
+    }
+
+
     function event_hook($event, &$bag, &$eventData) {
         global $serendipity;
 
@@ -59,12 +78,28 @@
         $hooks = &$bag->get('event_hooks');
         if (isset($hooks[$event])) {
             switch($event) {
+                case 'frontend_comment':
+                    if (serendipity_db_bool($this->get_config('frontend', false)) === false) {
+                        break;
+                    }
+                    $txtarea = 'serendipity_commentform_comment';
+                    $func    = 'comment';
+                    $style   = '';
+                
                 case 'backend_entry_toolbar_extended':
-                    $txtarea = 'extended';
+                    if (!isset($txtarea)) {
+                        $txtarea = 'serendipity[extended]';
+                        $func    = 'extended';
+                    }
 
                 case 'backend_entry_toolbar_body':
                     if (!isset($txtarea)) {
-                        $txtarea = 'body';
+                        $txtarea = 'serendipity[body]';
+                        $func    = 'body';
+                    }
+
+                    if (!isset($style)) {
+                        $style = 'text-align: right; margin-top: 5px';
                     }
 
                     $i = 1;
@@ -78,8 +113,8 @@
                     }
 ?>
 <script type="text/javascript">
-function use_emoticon_<?php echo $txtarea; ?>(img) {
-    txtarea = document.getElementById('serendipity[<?php echo $txtarea; ?>]');
+function use_emoticon_<?php echo $func; ?>(img) {
+    txtarea = document.getElementById('<?php echo $txtarea; ?>');
     if (txtarea.createTextRange && txtarea.caretPos) {
         caretPos = txtarea.caretPos;
         caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + ' ' + img + ' ' : caretPos.text + ' ' + img + ' ';
@@ -92,9 +127,9 @@
 }
 </script>
 <?php
-                    echo '<div style="text-align: right; margin-top: 5px">';
+                    echo '<div id="serendipity_emoticonchooser" style="' . $style . '">';
                     foreach($unique as $value => $key) {
-                        echo '<a href="javascript:use_emoticon_' . $txtarea . '(\'' . addslashes($key) . '\')" title="' . $key . '"><img src="'. $value .'" style="border: 0px" /></a> ';
+                        echo '<a href="javascript:use_emoticon_' . $func . '(\'' . addslashes($key) . '\')" title="' . $key . '"><img src="'. $value .'" style="border: 0px" /></a> ';
                         if ($i++ % 10 == 0) {
                             echo '<br />';
                         }

Regards,
Garvin

Posted: Sun Jul 24, 2005 5:37 pm
by n00b
Works great!

You can see it in action here.

Posted: Sun Jul 24, 2005 6:06 pm
by garvinhicking
I'd suggest you to put the emoticate plugin BEFORE the spamblock plugin, so that the smilies are shown directly below the comment entry box :)

Regards,
Garvin

Posted: Sun Jul 24, 2005 6:19 pm
by n00b
Like this? :)

Emoticon

Posted: Sat Nov 05, 2005 10:08 pm
by kj
Hi, I would like to use this function of emoticon choice to people who comment. How can I do this ? Where should I paste the Garvin's note? In which plug in should I use? thanks for your help.

Re: Emoticon

Posted: Sun Nov 06, 2005 8:05 am
by JWalker
kj wrote:Hi, I would like to use this function of emoticon choice to people who comment. How can I do this ? Where should I paste the Garvin's note? In which plug in should I use? thanks for your help.
Did you try to install serendipity_event_emoticonchooser plugin ? It is here in CVS or in additional_plugins.tgz.

Ivan

Posted: Sun Nov 06, 2005 7:33 pm
by Guest
Dear Ivan,

Yes I installed the below plugin in the event plugin.
But this does not change anything..
Maybe my setting (yes, no) is not correct ?

---------------------------------------------------------------
Name Markup: Emoticate
Description Convert standard emoticons into graphic images

Entry Body
Apply markup to Entry Body Yes No
Extended Body
Apply markup to Extended Body Yes No
Comment
Apply markup to Comment Yes No
HTML Nugget
Apply markup to HTML Nugget Yes No



:'( :-) :| :-O :-( 8-) :-D
:-P ;-)
-------------------------------------------

Kind regards,

Posted: Sun Nov 06, 2005 9:03 pm
by garvinhicking
Guest,

Ivan is speaking of the EMOTICONCHOOSER plugin, not of the "Markup: Emoticate" plugin! Both are two different plugins!

Regards,
Garvin

Emoticonchooser

Posted: Sun Nov 06, 2005 10:42 pm
by Kj
Garvin, Ivan,

Sorry for not understanding well.
Where is this emoticon chooser?
Is it something I have to install from somewhere?

In fact, I have problem of having an image of emoticons. I read another topic in the forum that I should take off link to/from, which I do not have it. Now, I have the following event plug ins.
I do not know why images do not show images at all...

-------------------------------------
Title Permissions
Markup: Serendipity

Apply basic serendipity markup to entry text

Links manager - Shows your favorite links in the sidebar.

Announce entries

Send notification of new entries to online services
Markup: Track exits

Track clicks on external URLs
Fix common XHTML errors

This plugin corrects common issues with XHTML markup in entries. It assists in keeping your blog XHTML compliant.
Creative Commons License

Choose and display a creative commons license for your content
Statistics

Adds a link to interesting statistics in your entries panel, including a visitors counter
Markup: Emoticate

Thank you and kind regards,

KJ

Re: Emoticonchooser

Posted: Sun Nov 06, 2005 10:50 pm
by garvinhicking
You need to first install the "Spartacus" Event plugin. This will give you new plugins from our online repository. When you have installed that, install a new plugin and you'll see the emoticonchooser plugin now!

Or you can download it from here: http://cvs.sourceforge.net/viewcvs.py/p ... onchooser/

HTH,
Garvin

Emoticonchooser

Posted: Sun Nov 06, 2005 11:03 pm
by Kj
Garvin,

Fantastic, now I can see emoticon in the comments!!
Thank you so much.

K :P