Extension:Nyan

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Nyan

Release status: beta

Implementation Special page
Description embeds nyan cat
Author(s) Dan Keller (pokeswaptalk)
MediaWiki 1.18+
License none specified
Download waiting for gerrit
Added rights

rainbow, which is given to the group cat by default

Check usage and version matrix


this extension is waiting to be put in gerrit for now the code is in the page

Specialnyan.php

<?php
class Specialnyan extends SpecialPage {
        function __construct() {
             parent::__construct( 'nyan', 'rainbow' );
        }
 
        function execute( $par ) {
                global $wgRequest, $wgOut, $wgUser;
 
                if ( !$wgUser->isAllowed( 'rainbow' ) ) {
                        $wgOut->permissionRequired( 'rainbow' );
                        return;
                }
 
                $this->setHeaders();
 
                # Get request data from, e.g.
                $param = $wgRequest->getText('param');
 
                # Do stuff
                # ...
                $output = 'NYANCAT!';
                $wgOut->addHTML('<object data=http://nyan.cat width="800" height="600"> <embed src=http://nyan.cat width="800" height="500"> </embed> Error: Embedded data could not be displayed.' 
                                );
        }
}

nyan.php

<?php
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if (!defined('MEDIAWIKI')) {
        echo <<<EOT
To install my extension, put the following line in LocalSettings.php:
require_once( "\$IP/extensions/nyan/nyan.php" );
EOT;
        exit( 1 );
}
 
$wgExtensionCredits['specialpage'][] = array(
        'path' => __FILE__,
        'name' => 'nyan cat',
        'author' => 'dan keller and creator of nyan cat site',
        'url' => 'http://nyan.cat',
        'descriptionmsg' => 'nyan-desc',
        'version' => '0.0.0',
);
 
 
 
 
 $wgAvailableRights = array ('rainbow');
 $wgGroupPermissions['*']['rainbow'] = false;
 $wgGroupPermissions['cats']['rainbow'] = true;
 
define("NS_NYAN_CAT", 150);
define("NS_NYAN_CAT_TALK", 151);
 
$wgExtraNamespaces[NS_NYAN_CAT] = "Nyan_Cat";
$wgExtraNamespaces[NS_NYAN_CAT_TALK] = "Nyan_Cat_talk";
 
$dir = dirname(__FILE__) . '/';
 
$wgAutoloadClasses['Specialnyan'] = $dir . 'Specialnyan.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgExtensionMessagesFiles['nyan'] = $dir . 'nyan.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
$wgExtensionMessagesFiles['nyanAlias'] = $dir . 'nyan.alias.php'; # Location of an aliases file (Tell MediaWiki to load this file)
$wgSpecialPages['nyan'] = 'Specialnyan'; # Tell MediaWiki about the new special page and its class name

nyan.i18n.php

<?php
/**
 * Internationalisation for myextension
 *
 * @file
 * @ingroup Extensions
 */
$messages = array();
 
/** English
 * @author <your username>
 */
$messages['en'] = array(
        'nyan' => 'nyan', // Ignore
        'nyan-desc' => "embeds nyan cat into a special page",
);
 
/** Message documentation
 * @author <your username>
 */
$messages['qqq'] = array(
        'myextension-desc' => "{{desc}}",
);

nyan.alias.php

<?php
/**
 * Aliases for myextension
 *
 * @file
 * @ingroup Extensions
 */
 
$specialPageAliases = array();
 
/** English
 * @author <your username>
 */
$specialPageAliases['en'] = array(
        'nyan' => array( 'nyan', 'Nyan', 'Nyan Cat', 'Nyan cat', 'nayn' ),
);
 
/** Deutsch
 * @author <your username>
 */
$specialPageAliases['de'] = array(
        'nyan' => array( 'bob', 'robert' ),
);