Extension:Emoticons: Difference between revisions
Content deleted Content added
LudoErgoSum (talk | contribs) |
m cleanup |
||
(112 intermediate revisions by 36 users not shown) | |||
Line 1: | Line 1: | ||
<languages /> |
|||
{{Extension |
|||
{{BlueSpiceExtensionInfobox|templatemode= |
|||
|name = Emoticons Extension |
|||
|status = |
|status = |
||
| |
| = |
||
|type2 = |
|||
|author = [[User:LudoErgoSum|Alex Wollangk]] ([mailto:alex@wollangk.com alex@wollangk.com]) |
|||
|hook1 = OutputPageBeforeHTML |
|||
|version = 1.0 |
|||
| |
| = |
||
|newhook1 = |
|||
|description = Enable forum-style emoticon (smiley) replacement within MediaWiki. |
|||
|newhook2 = |
|||
|username = |
|||
|author = [[User:Mglaser|Markus Glaser]], [[User:LudoErgoSum|Alex Wollangk]] ([mailto:alex@wollangk.com alex@wollangk.com]) and [[User:Techjar|Techjar]] ([mailto:tecknojar@gmail.com tecknojar@gmail.com]) |
|||
|description = <translate><!--T:1--> Enable forum-style emoticon (smiley) replacement within MediaWiki.</translate> |
|||
|image = BlueSpice Mediawiki Extension Emoticons.png |
|||
|imagesize = 300 |
|||
|php = |
|||
|needs-updatephp = |
|||
|composer = |
|||
|table1 = |
|||
|table2 = |
|||
|license = |
|||
|download = {{WikimediaDownload|BlueSpiceEmoticons|phab=EBTE}} |
|||
|readme = |
|||
|changelog = |
|||
|example = |
|||
|namespace = |
|||
|parameters = |
|||
|tags = |
|||
|rights = |
|||
|compatibility = |
|||
|bugzilla = |
|||
|phabricator = |
|||
|vagrant-role = |
|||
|introduction = |
|||
|screenshots = |
|||
|usage = |
|||
}} |
}} |
||
<translate><!--T:10--> This extension makes forum-style [[w:Emoticon|emoticon]] (smiley) replacements within MediaWiki.</translate> |
|||
==Introduction== |
|||
<translate><!--T:11--> See the list of [[<tvar name=1>#Default emoticons</tvar>|default emoticons]] below.</translate> |
|||
<translate> |
|||
I was tasked with setting up a Wiki for a small business. They were currently using [http://www.phpbb.com/ 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 [http://www.wikipedia.org/ 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. |
|||
== Requirements == <!--T:12--> |
|||
<!--T:13--> |
|||
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 [http://meta.wikimedia.org/wiki/RandomText RandomText] extension for a random "quote" on the main page. |
|||
Emoticons requires <tvar name=1>{{ll|Extension:BlueSpiceFoundation|BlueSpiceFoundation}}</tvar> and <tvar name=2>{{ll|Extension:ExtJSBase|ExtJSBase}}</tvar>. |
|||
==Installation== <!--T:4--> |
|||
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. |
|||
</translate> |
|||
{{ExtensionInstall |
|||
==Installation== |
|||
|registration=required |
|||
}} |
|||
1. Create the file: |
|||
===extensions/emoticons.php=== |
|||
<pre><nowiki> |
|||
<?php |
|||
# Emoticon MediaWiki Extension |
|||
# Created by Alex Wollangk (alex@wollangk.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' => 'Emoticons', |
|||
'status' => 'Stable', |
|||
'type' => 'hook', |
|||
'author' => 'Alex Wollangk (alex@wollangk.com)', |
|||
'version' => '1.0', |
|||
'update' => '2-20-2007', |
|||
'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 ); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
?> |
|||
</nowiki></pre> |
|||
2. Add the following to the end of: (right above the "?>" at the end) |
|||
===LocalSettings.php=== |
|||
<pre><nowiki> |
|||
require_once( "extensions/emoticons.php" ); |
|||
</nowiki></pre> |
|||
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. |
|||
<translate> |
|||
===Sample MediaWiki:Emoticons=== |
|||
== Default emoticons == <!--T:14--> |
|||
<!--T:7--> |
|||
Here is the page I ended up creating: |
|||
The following emoticons are defined by default: |
|||
</translate> |
|||
<pre> |
<pre> |
||
<nowiki>:-)</nowiki> smile.png smiling |
|||
:D//[[Image:VeryHappy.gif]] |
|||
<nowiki>:-( </nowiki> sad.png sad |
|||
:-D//[[Image:VeryHappy.gif]] |
|||
<nowiki>:-|</nowiki> neutral.png neutral, sceptical |
|||
:grin://[[Image:VeryHappy.gif]] |
|||
<nowiki>:-@</nowiki> angry.png angry, annoyed |
|||
:)//[[Image:Smile.gif]] |
|||
<nowiki>;-)</nowiki> wink.png winking, ironic |
|||
:-)//[[Image:Smile.gif]] |
|||
<nowiki>:-D</nowiki> smile-big.png laughing |
|||
:smile://[[Image:Smile.gif]] |
|||
<nowiki>:-/</nowiki> thinking.png thinking |
|||
:(//[[Image:Sad.gif]] |
|||
<nowiki>:-X</nowiki> shut-mouth.png sealed lips |
|||
:-(//[[Image:Sad.gif]] |
|||
<nowiki>:'( </nowiki> crying.png crying |
|||
:sad://[[Image:Sad.gif]] |
|||
<nowiki>:-O</nowiki> shock.png shocked, surprised |
|||
:o//[[Image:Surprised.gif]] |
|||
<nowiki>:-S</nowiki> confused.png undecided, confused |
|||
:-o//[[Image:Surprised.gif]] |
|||
<nowiki>8-)</nowiki> laugh.png laughing |
|||
:eek://[[Image:Surprised.gif]] |
|||
<nowiki>:lol:</nowiki> glasses-cool.png cool, sunglasses |
|||
:shock://[[Image:Shocked.gif]] |
|||
<nowiki>(:|</nowiki> yawn.png yawning |
|||
:?//[[Image:Confused.gif]] |
|||
<nowiki>:good:</nowiki> good.png good, thumbs up |
|||
:-?//[[Image:Confused.gif]] |
|||
<nowiki>:bad:</nowiki> bad.png bad, thumbs down |
|||
:???://[[Image:Confused.gif]] |
|||
<nowiki>:-[</nowiki> embarrassed.png embarrassed, blushing |
|||
8)//[[Image:Cool.gif]] |
|||
<nowiki>[-X</nowiki> shame.png ashamed |
|||
8-)//[[Image:Cool.gif]] |
|||
</pre> |
|||
: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]] |
|||
</nowiki></pre> |
|||
<translate> |
|||
After saving this file I viewed it and all the images showed up as links I could use to upload the appropriate image. |
|||
==External links== <!--T:9--> |
|||
</translate> |
|||
* <translate><!--T:15--> Helpdesk: [<tvar name=url>https://en.wiki.bluespice.com/wiki/Reference:BlueSpiceEmoticons</tvar> Emoticons]</translate> |
|||
{{BlueSpiceExtensionFooter}} |
|||
==Notice== |
|||
[[Category:Image extensions{{#translation:}}]] |
|||
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. |
Latest revision as of 10:57, 2 April 2023
Emoticons Release status: stable |
|
---|---|
Description | Enable forum-style emoticon (smiley) replacement within MediaWiki. |
Author(s) | Markus Glaser, Alex Wollangk (alex@wollangk.com) and Techjar (tecknojar@gmail.com) |
Maintainer(s) | Hallo Welt! GmbH |
Latest version | 4.3 |
Compatibility policy | For every MediaWiki release that is a Long Term Support release there is a corresponding branch in the extension. |
MediaWiki | 1.39 (LTS) |
Composer | bluespice/emoticons |
License | GNU General Public License 3.0 only |
Download | |
Quarterly downloads | 6 (Ranked 128th) |
Translate the Emoticons extension if it is available at translatewiki.net | |
Community Forum |
This extension makes forum-style emoticon (smiley) replacements within MediaWiki.
See the list of default emoticons below.
Requirements[edit]
Emoticons requires BlueSpiceFoundation and ExtJSBase .
Installation[edit]
- Download and move the extracted
Emoticons
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Emoticons - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Emoticons' );
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Default emoticons[edit]
The following emoticons are defined by default:
:-) smile.png smiling :-( sad.png sad :-| neutral.png neutral, sceptical :-@ angry.png angry, annoyed ;-) wink.png winking, ironic :-D smile-big.png laughing :-/ thinking.png thinking :-X shut-mouth.png sealed lips :'( crying.png crying :-O shock.png shocked, surprised :-S confused.png undecided, confused 8-) laugh.png laughing :lol: glasses-cool.png cool, sunglasses (:| yawn.png yawning :good: good.png good, thumbs up :bad: bad.png bad, thumbs down :-[ embarrassed.png embarrassed, blushing [-X shame.png ashamed
External links[edit]
- Helpdesk: Emoticons