Index: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessage.i18n.php |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for Interactive block message extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** |
| 13 | + * English |
| 14 | + * @author Petr Bena |
| 15 | + */ |
| 16 | +$messages['en'] = array( |
| 17 | + // Description |
| 18 | + 'interactiveblockmessage-desc' => 'Creates new magic word <nowiki>{{userblocked}}</nowiki> which if on userspace indicates if user is blocked or not.', |
| 19 | +); |
| 20 | + |
| 21 | +/** Message documentation (Message documentation) |
| 22 | + * @author Petr Bena |
| 23 | + */ |
| 24 | +$messages['qqq'] = array( |
| 25 | + 'interactiveblockmessage-desc' => '{{desc}}', |
| 26 | +); |
Property changes on: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessage.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 27 | + native |
Index: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessage.php |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Insert a new magic word |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Petr Bena <benapetr@gmail.com> |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + echo "This is a part of mediawiki and can't be started separately"; |
| 15 | + die(); |
| 16 | +} |
| 17 | + |
| 18 | +$wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
| 19 | + 'path' => __FILE__, |
| 20 | + 'name' => 'Interactive block message', |
| 21 | + 'version' => '1.0.0', |
| 22 | + 'author' => array( 'Petr Bena' ), |
| 23 | + 'descriptionmsg' => 'interactiveblockmessage-desc', |
| 24 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:InteractiveBlockMessage', |
| 25 | +); |
| 26 | + |
| 27 | +$dir = dirname( __FILE__ ); |
| 28 | + |
| 29 | +$wgAutoloadClasses['InteractiveBlockMessage'] = "$dir/InteractiveBlockMessage.php"; |
| 30 | +$wgAutoloadClasses['InteractiveBlockMessageHooks'] = "$dir/InteractiveBlockMessageHooks.php"; |
| 31 | + |
| 32 | +$wgExtensionMessagesFiles['InteractiveBlockMessage'] = "$dir/InteractiveBlockMessage.i18n.php"; |
| 33 | + |
| 34 | + |
| 35 | +$wgHooks['LanguageGetMagic'][] = 'InteractiveBlockMessageHooks::magicWordVar'; |
| 36 | +$wgHooks['MagicWordwgVariableIDs'][] = 'InteractiveBlockMessageHooks::magicWordSet'; |
| 37 | +$wgHooks['ParserGetVariableValueSwitch'][] = 'InteractiveBlockMessageHooks::parserGetVariable'; |
Property changes on: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 38 | + native |
Index: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php |
— | — | @@ -0,0 +1,61 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Hooks for Interactive block message |
| 6 | + * |
| 7 | + * @group Extensions |
| 8 | + */ |
| 9 | +class InteractiveBlockMessageHooks { |
| 10 | + /** |
| 11 | + * @param $magicWords array |
| 12 | + * @param $ln string (language) |
| 13 | + * @return bool |
| 14 | + */ |
| 15 | + public static function magicWordVar( array &$magicWords, $ln ) { |
| 16 | + $magicWords['userblocked'] = array( 0, 'userblocked' ); |
| 17 | + return true; |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * @param $vars array |
| 22 | + * @return bool |
| 23 | + */ |
| 24 | + public static function magicWordSet( &$vars ) { |
| 25 | + $vars[] = 'userblocked'; |
| 26 | + return true; |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @param $parser Parser |
| 31 | + * @param $varCache ?? |
| 32 | + * @param $index ?? |
| 33 | + * @param $ret string? |
| 34 | + * @return bool |
| 35 | + */ |
| 36 | + public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) { |
| 37 | + if ( $index != 'userblocked' ) { |
| 38 | + return true; |
| 39 | + } |
| 40 | + |
| 41 | + if ( $parser->getTitle()->getNamespace() != NS_USER && $parser->getTitle()->getNamespace() != NS_USER_TALK ) { |
| 42 | + $ret = 'unknown'; |
| 43 | + return true; |
| 44 | + } |
| 45 | + |
| 46 | + $user = User::newFromName( $parser->getTitle()->getBaseText() ); |
| 47 | + if ($user instanceof User) { |
| 48 | + if ($user->isBlocked()) { |
| 49 | + $ret = 'true'; |
| 50 | + return true; |
| 51 | + } else { |
| 52 | + $ret = 'false'; |
| 53 | + return true; |
| 54 | + } |
| 55 | + } else { |
| 56 | + $ret = 'unknown'; |
| 57 | + return true; |
| 58 | + } |
| 59 | + $ret = 'unknown'; |
| 60 | + return true; |
| 61 | + } |
| 62 | +} |
Property changes on: branches/REL1_18/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 63 | + native |