MediaWiki Implementation

From Geohashing
Revision as of 23:17, 18 November 2009 by 203.186.108.130 (talk) (The Code)

Note: Version 1.01 of geohashes.php is currently installed on this wiki, as well as Variables.php.

A MediaWiki extension to allow us to handle Geohashes a little nicer and more automatically. Any questions to the talk page here, although I would appreciate a poke on my talk page also.

Note that the whole algorithm is not fully implemented, because those on IRC said that templates could do the rest.

--Edgemaster 21:39, 23 May 2008 (UTC)

Cool site goodluck :) <a href=" http://www.playlist.com/blog/entry/12464438787 ">young lolita sluts</a> 8))) <a href=" http://www.playlist.com/blog/entry/12464437763 ">sex underage bbs preteen illegal very young virgin pedo lolis videos</a> 62348 <a href=" http://www.playlist.com/blog/entry/12464439043 ">home lolita nymphet</a> halg <a href=" http://www.playlist.com/blog/entry/12464440323 ">lolitas angels nude moldels</a> 8-O <a href=" http://www.playlist.com/blog/entry/12464437507 ">teen lolita pictures</a> 7890 <a href=" http://www.playlist.com/blog/entry/12464439811 ">lolita preteen girls pictures</a> cneqsy <a href=" http://www.playlist.com/blog/entry/12464436995 ">little lolitas f.cking</a> =)) <a href=" http://www.playlist.com/blog/entry/12464438019 ">lolita forum</a> >:-PP <a href=" http://www.playlist.com/blog/entry/12464435971 ">alfa-top cp lolita illegal porn</a> 2147 <a href=" http://www.playlist.com/blog/entry/12464438531 ">bbs board preteen, pedo lolitas</a> 9099

I'm happy very good site <a href=" http://www.playlist.com/blog/entry/12464544003 ">art lolita bbs </a> 8-]] <a href=" http://www.playlist.com/blog/entry/12464542467 ">very young models lolitas preteen</a> 352496 <a href=" http://www.playlist.com/blog/entry/12464544259 ">cp top lolita preten </a> eqbm <a href=" http://www.playlist.com/blog/entry/12464544771 ">lolita ranchi bbs</a> 8)) <a href=" http://www.playlist.com/blog/entry/12464542211 ">lolita preteen pantyhose</a> 8O <a href=" http://www.playlist.com/blog/entry/12464544515 ">lolitasexparty pics</a> 51119 <a href=" http://www.playlist.com/blog/entry/12464542979 ">preteen lolita board forum bbs</a>  :OOO <a href=" http://www.playlist.com/blog/entry/12464540931 ">pedo porn underage lolita kds bbs rompl</a>  %-))) <a href=" http://www.playlist.com/blog/entry/12464540419 ">lolitas semi nude photos</a> tpurt <a href=" http://www.playlist.com/blog/entry/12464543235 ">young child lolitas</a> 872

In-wiki Usage

This extension adds two new parser functions: {{#md5}} and {{#dow}}.

#md5

md5s a string, optionally splitting into halves and decimalising.

{{#md5:string|halve|decimal}}

Parameters:

  • string: the string to md5
  • halve: (optional) splits the hash into two, as required by The Algorithm. 0 = do not half, 1 = first half, 2 = 2nd half. Defaults to 0.
  • decimal: (optional) converts the half to decimal if set. Defaults to 0, requires halve to be set to 1 or 2!

Examples:

  • {{#md5:testing testing!}}: f9da4c546dff04d46e1fab3ca0456b42
  • {{#md5:2005-05-26-10458.68}}: db9318c2259923d08b672cb305440f97
  • {{#md5:2005-05-26-10458.68|0}}: db9318c2259923d08b672cb305440f97
  • {{#md5:2005-05-26-10458.68|1}}: db9318c2259923d
  • {{#md5:2005-05-26-10458.68|2}}: 8b672cb305440f9
  • {{#md5:2005-05-26-10458.68|1|1}}: 0.857713267707
  • {{#md5:2005-05-26-10458.68|2|1}}: 0.54454306955928

#dow

Fetches the opening Dow Index for a date from the irc.peeron.com service.

{{#dow:year|month|day}}

Parameters:

  • year: 4 digit year
  • month: month (1 or 2 digits are acceptable)
  • day: day (1 or 2 digits are acceptable)

The only validation done is to check the values are non-null. If any of the 3 are null (or all of the 3), then today's date will be used instead. (Always requires the colon to produce a result)

Examples:

  • {{#dow:}}: 38140.26
  • {{#dow:2005|05|26}}: 10458.68
  • These will fail:
    • (lack of data) {{#dow:1854|05|26}}:
    • (bad syntax) {{#dow}}: {{#dow}}



Variables Extension too plz

Installing

Copy this into a file called $mediwikipath/extensions/Variables/Variables.php:

<?php

if ( !defined( 'MEDIAWIKI' ) ) {
    die( 'This file is a MediaWiki extension, it is not a valid entry point' );
}

$wgExtensionFunctions[] = 'wfSetupVariables';

$wgExtensionCredits['parserhook'][] = array(
	'name' => 'Variables',
	'url' => 'http://www.mediawiki.org/wiki/Extension:VariablesExtension',
	'author' => 'Rob Adams',
	'description' => 'Define page-scoped variables'
);

$wgHooks['LanguageGetMagic'][]       = 'wfVariablesLanguageGetMagic';

class ExtVariables {
    var $mVariables;

    function vardefine( &$parser, $expr = '', $value = '' ) {
	$this->mVariables[$expr] = $value;
	return '';
    }

    function varf( &$parser, $expr = '' ) {
	return $this->mVariables[$expr];
    }
}

function wfSetupVariables() {
    global $wgParser, $wgMessageCache, $wgExtVariables, $wgMessageCache, $wgHooks;

    $wgExtVariables = new ExtVariables;

    $wgParser->setFunctionHook( 'vardefine', array( &$wgExtVariables, 'vardefine' ) );
    $wgParser->setFunctionHook( 'var', array( &$wgExtVariables, 'varf' ) );
}

function wfVariablesLanguageGetMagic( &$magicWords, $langCode = 0 ) {
	require_once( dirname( __FILE__ ) . '/Variables.i18n.php' );
	foreach( efVariablesWords( $langCode ) as $word => $trans )
		$magicWords[$word] = $trans;
	return true;
}

Copy this into a file called $mediwikipath/extensions/Variables/Variables.i18n.php:


<?php

/**
 * Get translated magic words, if available
 *
 * @param string $lang Language code
 * @return array
 */
function efVariablesWords( $lang ) {
	$words = array();

	/**
	 * English
	 */
	$words['en'] = array(
		'var' 		=> array( 0, 'var' ),
		'vardefine' 	=> array( 0, 'vardefine' ),
	);

	# English is used as a fallback, and the English synonyms are
	# used if a translation has not been provided for a given word
	return ( $lang == 'en' || !isset( $words[$lang] ) )
		? $words['en']
		: array_merge( $words['en'], $words[$lang] );
}

Then add

require_once( "$IP/extensions/Variables/Variables.php" );

to the end of LocalSettings.php.