Extension talk:Emoticons

Why this Extension was created
I was tasked with setting up a Wiki for a small business. They were currently using phpBB, but for training info and guidelines a forum was just too cumbersome. I knew about MediaWiki and since I was asked to set up something "like Wikipedia", it quickly came to mind. The one thing I worried about was that the smileys people were used to in the forums would not be available in the Wiki.

I started by getting MediaWiki installed since the lack of smileys was bothersome, but unlikely to prevent the Wiki from being useful. Next I put in the RandomText extension for a random "quote" on the main page.

I then searched for an emoticon extension for as long as my attention span would allow. (I think managed to search for a whole fifteen minutes: A new record for me.) After that I gave up and decided to write my own...

...This is the first extension I have attempted with MediaWiki. Any stylistic variation from standard MediaWiki extension coding practices is just the way things go. If it really bugs you, fix it. Anyone who wants to use, modify or mutilate this code beyond recognition is free to do so, just don't blame it on me. If this extension causes your server to burst into flames and run screaming through the data center, I cannot be held responsible. I check my email quite regularly, so if anyone has any questions feel free to drop me a line, but since I have two jobs, a family and more pets than I care to admit I can't promise I'll be able to respond in short order.

User:LudoErgoSum

Does not appear to work in 1.10.1
On version 1.11 I got the following error: "Detected bug in an extension! Hook fnEmoticons failed to return a value; should return true to continue hook processing or false to abort." Mediawiki apparently now requires a return value of true for continue or false for cancel.

Adding "return true" between line 67 and line 68 (just before the last curly brace) seemed to fix the problem for me.

Can't get it to work
In most recent version it gives a 500 internal server error.

return true fix doesn't work

Return true; definitely needed in extension.
* MediaWiki: 1.11.0 * PHP: 5.2.0 (apache2handler) * MySQL: 5.0.45

under this setup, adding return true; before the last } made it work fine.

headers already sent by (output started at /.../extensions/emoticons.php:1)
I used the code from the main page that included the "return true" statement at the end and I got this error.
 * MediaWiki: 1.11.1

The main page also included this information before the code: If you have MediaWiki 1.11 or higher, you must change the 2nd to last line on this file! I have no idea what this means. I believe it is referring to the "return true" statement but I'm not sure.

Any ideas what is wrong?

Use the Mediawiki:Emoticons page for viewing purposes also
If you look at the parsed configuration page it doesn't look very suitable for using it as a description page for the authors to see which emoticons are available.

So for our wiki I replaced the line

$emoticonList = explode( "\n", $emoticonListArticle->mContent );

by the following

so that I can use some tags like nowiki or table to format the list so that it is viewable also.

The example

would show (imagine a suitable icon image) something like this:

and can still be parsed by the extension.

Depending on the tags you want to use in the definition lines you could add further strings to the emSearch array. Lines without the // separator (i.e. the table lines in the example above) don't need to be removed as they are ignored already by the unchanged extension. --Wolverine 16:43, 2 January 2008 (UTC)

UNIQ errors in MediaWiki 1.12.0
This extension causes UNIQ errors. As seen in the example below.

UNIQ3cb085dc58727e57-nowiki-00000000-QINU.

Someone might want to update it so that it can work in the latest version.

-Augrunt 03:18, 22 March 2008 (UTC)

MediaWiki 1.12.0 Problems
Any idea when they will be fixed so I can start using this great extension again?


 * It works for my end. Try this: --74.130.36.17 23:37, 20 April 2008 (UTC)

 'Emoticons',        'status' => 'stable',        'type' => 'hook',        'author' => 'Alex Wollangk (alex@wollangk.com)',        'version' => '1.0',        'update' => '2-20-2007',        'url' => 'http://www.mediawiki.org/wiki/Extension:Emoticons',        'description' => 'Enable forum-style emoticon (smiley) replacement within MediaWiki.', ); $wgHooks['ParserAfterStrip'][] = 'fnEmoticons'; // The callback function for replacing emoticons with image tags function fnEmoticons( &$parser, &$text, &$strip_state ) { global $action; // Access the global "action" variable // Only do the replacement if the action is not edit or history if(               $action !== 'edit'                && $action !== 'history'                && $action !== 'delete'                && $action !== 'watch'                && strpos( $parser->mTitle->mPrefixedText, 'Special:' ) === false                && $parser->mTitle->mNamespace !== 8        ) {               // Get the list of emoticons from the "MediaWiki:Emoticons" article. $title = Title::makeTitle( 8, 'Emoticons' ); $emoticonListArticle = new Article( $title ); $emoticonListArticle->getContent; // If the content successfully loaded, do the replacement if( $emoticonListArticle->mContentLoaded ) {                       $emoticonList = explode( "\n", $emoticonListArticle->mContent ); foreach( $emoticonList as $index => $emoticon ) {                               $currEmoticon = explode( "//", $emoticon, 2 ); if( count($currEmoticon) == 2 ) {                                       // start by trimming the search value $currEmoticon[ 0 ] = trim( $currEmoticon[ 0 ] ); // if the string begins with, lop it off if( substr( $currEmoticon[ 0 ], 0, 6 ) == ' ' ) {                                               $currEmoticon[ 0 ] = trim( substr( $currEmoticon[ 0 ], 6 ) ); }                                       // trim the replacement value $currEmoticon[ 1 ] = trim( $currEmoticon[ 1 ] ); // and finally perform the replacement $text = str_replace( $currEmoticon[ 0 ], $currEmoticon[ 1 ], $text ); }                       }                }        }  // this extension will work on MediaWiki 1.11.0 when you remove the "//" from the next line! return true; }
 * 1) Emoticon MediaWiki Extension
 * 2) Created by Alex Wollangk (alex@wollangk.com)

MediaWiki 1.12 fix
Completely rewrited and optimized original code. Now it works for MW 1.12: --Aik099 18:33, 22 May 2008 (UTC)

limiting use to talk pages?
It would seem that it should be possible to limit this so that it is active on talk pages only, and not busily mangling actual article text. I presume that the section:

needs to be followed with the one added statement:

Does this look reasonable? --Carlb 15:59, 12 November 2008 (UTC)

Error
Well i suppose for the people that need it will look for this anyway but just for good style require_once( "extensions/emoticons.php" ); should be require_once( "$IP/extensions/emoticons.php" ); -- Deo Favente

Image / Media Substitution - unwanted
Apparently, this extension will replace things like this too:

(:D found)

I tried to figure it out myself, but my limited php skills didn't help.

Any ideas?

--212.23.224.72 14:01, 31 March 2009 (UTC)


 * Yes, this exact situation is discussed (together with a solution) on the extension page: Extension:Emoticons. :-) -Stelio 18:41, 1 April 2009 (UTC)


 * I should READ these things ;-) Cheers!
 * --Abonhote 06:58, 2 April 2009 (UTC)

Links
Hi everybody, I'm from the Oncyclopedia and we had installed this extension. It worked good.. A bit too good: Some links (like "Special:Statistics" for example) aren't usable now, because the extension recognizes the :S in the link and automatically replaces Statistics with   (But with the right image, of course). How do we fix this? Greets, Vsotvep 19:54, 2 May 2009 (UTC)
 * Ow whatever, found it already. Thanks anyways :P 77.169.36.17 20:11, 2 May 2009 (UTC)

No replacements on my site
www.wiki365.info I have just installed and I am running this extension on my mediawiki version 1.13.4, i am unable to get the replacements after creating the MediaWiki:Emoticons page.