UltrasonicNXT has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/101223


Change subject: Add $wgChatWikiText
......................................................................

Add $wgChatWikiText

Default true, whether or not to parse messages through the MediaWiki
WikiText parser.
Also clean up some variable names in MediaWikiChat::parseMessage

Change-Id: I9a492c03d083046b42b547ccd6d24c2b49565bfb
---
M MediaWikiChat.php
M MediaWikiChatClass.php
2 files changed, 27 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiChat 
refs/changes/23/101223/1

diff --git a/MediaWikiChat.php b/MediaWikiChat.php
index 5a055fd..ae5a72e 100644
--- a/MediaWikiChat.php
+++ b/MediaWikiChat.php
@@ -61,6 +61,7 @@
 // Config vars
 $wgChatKicks = false; // allow 'kicking' of users?
 $wgChatSocialAvatars = true; // use SocialProfile avatars?
+$wgChatWikiText = true; // allow the use of wikitext in chat?
 
 // Hooks
 $wgHooks['ParserBeforeInternalParse'][] = 
'MediaWikiChatHooks::onParserBeforeInternalParse';
diff --git a/MediaWikiChatClass.php b/MediaWikiChatClass.php
index 6e548db..2c5013c 100644
--- a/MediaWikiChatClass.php
+++ b/MediaWikiChatClass.php
@@ -152,13 +152,15 @@
         * @return String
         */
        static function parseMessage( $message ) {
-               $s2 = wfMessage( 'smileys' )->plain();
-               $sm2 = explode( '* ', $s2 );
+               global $wgChatWikiText;
+
+               $rawSmileyData = wfMessage( 'smileys' )->plain();
+               $smileyData = explode( '* ', $rawSmileyData );
 
                $smileys = array();
 
-               if ( is_array( $sm2 ) ) {
-                       foreach ( $sm2 as $line ) {
+               if ( is_array( $smileyData ) ) {
+                       foreach ( $smileyData as $line ) {
                                $bits = explode( ' ', $line );
 
                                if ( count( $bits ) > 1 ) {
@@ -186,28 +188,31 @@
 
                $message = trim( $message );
 
-               $message = str_ireplace( '[[File:', '[[:File:', $message );
+               $message = str_ireplace( '[[File:', '[[:File:', $message ); // 
prevent users showing huge local images in chat
                $message = str_ireplace( '[[!File:', '[[File:', $message );
 
-               $message = "MWCHAT $message";
+               if ( $wgChatWikiText ) {
+                       $message = "MWCHAT $message"; // flag to show the 
parser this is a chat message
 
-               $opts = new ParserOptions();
-               $opts->setEditSection( false );
-               $opts->setExternalLinkTarget( '_blank' );
-               $opts->setAllowSpecialInclusion( false );
-               $opts->setAllowExternalImages( false );
+                       $opts = new ParserOptions();
+                       $opts->setEditSection( false );
+                       $opts->setExternalLinkTarget( '_blank' );
+                       $opts->setAllowSpecialInclusion( false );
+                       $opts->setAllowExternalImages( false );
 
-               $parser = new Parser();
-               $parseOut = $parser->parse(
-                       $message,
-                       SpecialPage::getTitleFor( 'Chat' ),
-                       $opts
-               );
+                       $parser = new Parser();
+                       $parseOut = $parser->parse(
+                               $message,
+                               SpecialPage::getTitleFor( 'Chat' ),
+                               $opts
+                       );
 
-               $text = $parseOut->getText();
-               $text = str_replace( 'MWCHAT', '', $text );
-               $text = ltrim( $text );
-               return $text;
+                       $message = $parseOut->getText();
+                       $message = str_replace( 'MWCHAT', '', $message );
+                       $message = ltrim( $message );
+               }
+
+               return $message;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/101223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a492c03d083046b42b547ccd6d24c2b49565bfb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiChat
Gerrit-Branch: master
Gerrit-Owner: UltrasonicNXT <adamr_car...@btinternet.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to