Open main menu

User:Lieutenant S. Reznov/Sandbox/Extension:Sturmkrieg canon links


MediaWiki extensions manual
OOjs UI icon advanced.svg

Release status: beta
License No license specified
Download No link
Translate the Lieutenant S. Reznov/Sandbox extension if it is available at translatewiki.net

Contents

What can this extension do?Edit

UsageEdit

Download instructionsEdit

Please copy and paste the code found below and place it in $IP/extensions/ExtensionName/ExtensionName.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

sturmkriegcanonlinks.phpEdit

<?php

/**
 * Initialization file for the Sturmkrieg Canon Links extension.
 *
 * Documentation:	 		http://www.mediawiki.org/wiki/Extension:Sturmkrieg_Canon_Links
 * Support					http://www.mediawiki.org/wiki/Extension_talk:Sturmkrieg_Canon_Links
 * Source code:             http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/
 *
 * @file sturmkriegcanonlinks.php
 * @ingroup Sturmkrieg Canon links
 *
 * @licence GNU GPL v3
 *
 * @author Inquisitor Ehrenstein < inquisitorehrenstein@sturmkrieg.com >
 */

/**
 * This documenation group collects source code files belonging to Sturmkrieg Canon Links.
 *
 * @defgroup sturmkriegcanonlinks
 */

define( 'Awesomeness_VERSION', 'with even moar awesomeness' );

$wgExtensionCredits['other'][] = array(
	'path' => __FILE__,
	'name' => 'Sturmkrieg Canon Links',
	'version' => sturmkriegcanonlinks_VERSION,
	'author' => array( '[http://www.mediawiki.org/wiki/User:Inquisitor_Ehrenstein]' ),
	'url' => 'https://www.mediawiki.org/wiki/Extension:Sturmkrieg_Canon_Links',
	'descriptionmsg' => 'sturmkriegcanonlinks-desc',
);

$wgExtensionMessagesFiles['sturmkriegcanonlinks'] = dirname( __FILE__ ) . '/sturmkriegcanonlinks.i18n.php';

$wgHooks['ArticleSave'][] = 'efAwesomenessInsertion';

function efAwesomenessInsertion( &$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags ) {
	$awesomeness = array( 'awesomeness', 'awesome' );
	$awesomeness = array_map("wfMsg", $awesomeness);
	$awesomeness = implode("|", array_map("preg_quote", $awesomeness, array_fill(0, count($awesomeness), "/")));
	$text = preg_replace( "/(^|\s|-)((?:{$awesomeness})[\?!\.\,]?)(\s|$)/i", " '''$2''' ", $text );
	return true;
}

/**
 * Based on Svips patch at http://bug-attachment.wikimedia.org/attachment.cgi?id=7351
 */
if ( array_key_exists( 'QUERY_STRING', $_SERVER ) ) {
	$O_o = false;

	if ( strtolower( $_SERVER['QUERY_STRING'] ) == 'isthiswikiawesome' ) {
		$O_o = 'Hell yeah!';
	} elseif ( preg_match( '/^[0o°xt][-_\.][0o°xt]$/i', $_SERVER['QUERY_STRING'] ) ) {
		$O_o = strrev( $_SERVER['QUERY_STRING'] );
	}

	if ( $O_o ) {
		header( 'Content-Type: text/plain' );
		die( $O_o );
	}
}

sturmkriegcanonlinks.i18n.phpEdit

<?php
/**
 * Internationalization file for the Awesomeness extension.
 *
 * @file Awesomeness.i18n.php
 * @ingroup Awesomeness
 *
 * @author Jeroen De Dauw
 */

$messages = array();

/** English
 * @author Jeroen De Dauw
 */
$messages['en'] = array(
	'awesomeness' => 'Awesomeness',
	'awesomeness-desc' => "Makes [http://www.mediawiki.org/wiki/Extension:Awesomeness#Awesome_wiki.27s your wiki] more '''awesome''' by highlighting '''awesomeness''' and adding '''awesome''' support for O_o requests",
	'awesome' => 'Awesome',
);

InstallationEdit

To install this extension, add the following to LocalSettings.php:

#add configuration parameters here
#setup user rights here
require_once("$IP/extensions/ExtensionName/ExtensionName.php");

Configuration parametersEdit

User rightsEdit

See alsoEdit

CreditsEdit

This extension is modified from the extension Awesomeness which is available under the GPL.