Extension:EmoticonsLite
|
EmoticonsLite Release status: stable |
|
|---|---|
| Implementation | Extended syntax |
| Description | Enable forum-style emoticon (smiley) replacement within MediaWiki. |
| Author(s) | Alex Wollangk (alex@wollangk.com), and Techjar (tecknojar@gmail.com) |
| Last version | 1.0 (7-18-2009) |
| MediaWiki | unknown |
| License | Public domain |
| Download | Source Code |
|
Check usage (experimental) |
|
This extension makes forum-style emoticon (smiley) replacements within MediaWiki. See the list of emoticons below.
This extension is derived from the Emoticons extension!
Contents |
[edit] Installation
[edit] Install
1. Create the file: extensions/EmoticonsLite/EmoticonsLite.php
2. Add the following to the end of: LocalSettings.php
require_once($IP."/extensions/EmoticonsLite/EmoticonsLite.php");
3. Create the page "MediaWiki:Emoticons"
4. Add one line to this page for each emoticon. Each line contains the text to be replaced followed by "//" followed by the text to replace it with.
[edit] Source Code
<?php # Emoticon MediaWiki Extension # Created by Alex Wollangk (alex@wollangk.com), and Techjar (tecknojar@gmail.com) if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is a MediaWiki extension, it is not a valid entry point.' ); } global $wgHooks; global $wgExtensionCredits; $wgExtensionCredits['parserhook'][] = array( 'name' => 'EmoticonsLite', 'status' => 'stable', 'type' => 'hook', 'author' => 'Alex Wollangk, Techjar', 'version' => '1.0', 'update' => '7-18-2009', 'url' => 'http://www.mediawiki.org/wiki/Extension:EmoticonsLite', '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_ireplace( " ".$currEmoticon[ 0 ], $currEmoticon[ 1 ], $text ); } } } } // Always a good practice to let the other hooks have their turn ... whenever it make sense. return true; }
[edit] Sample MediaWiki:Emoticons
Here is a sample list of emoticons:
:D//[[Image:VeryHappy.gif]] :-D//[[Image:VeryHappy.gif]] :grin://[[Image:VeryHappy.gif]] :)//[[Image:Smile.gif]] :-)//[[Image:Smile.gif]] :smile://[[Image:Smile.gif]] :(//[[Image:Sad.gif]] :-(//[[Image:Sad.gif]] :sad://[[Image:Sad.gif]] :o//[[Image:Surprised.gif]] :-o//[[Image:Surprised.gif]] :eek://[[Image:Surprised.gif]] :shock://[[Image:Shocked.gif]] :?//[[Image:Confused.gif]] :-?//[[Image:Confused.gif]] :???://[[Image:Confused.gif]] 8)//[[Image:Cool.gif]] 8-)//[[Image:Cool.gif]] :cool://[[Image:Cool.gif]] :lol://[[Image:Laughing.gif]] :x//[[Image:Mad.gif]] :-x//[[Image:Mad.gif]] :mad://[[Image:Mad.gif]] :P//[[Image:Razz.gif]] :-P//[[Image:Razz.gif]] :razz://[[Image:Razz.gif]] :oops://[[Image:Embarassed.gif]] :cry://[[Image:CryingorVerySad.gif]] :evil://[[Image:EvilorVeryMad.gif]] :twisted://[[Image:TwistedEvil.gif]] :roll://[[Image:RollingEyes.gif]] :wink://[[Image:Wink.gif]] ;)//[[Image:Wink.gif]] ;-)//[[Image:Wink.gif]] :!://[[Image:Exclamation.gif]] :?://[[Image:Question.gif]] :idea://[[Image:Idea.gif]] :arrow://[[Image:Arrow.gif]] :|//[[Image:Neutral.gif]] :-|//[[Image:Neutral.gif]] :neutral://[[Image:Neutral.gif]] :mrgreen://[[Image:Mr.Green.gif]]
[edit] Emoticons vs. EmoticonsLite
In general, Emoticons is better, because it has a parser for <nowiki> tags! EmoticonsLite does not. If you have a very fast server and MediaWiki usually loads quickly, the Emoticons extension is recommended! Otherwise, use this extension.
[edit] More info...
For more info, see Extension:Emoticons!
