User:Leucosticte/Code graveyard

public static function wikipediaLink( $dummy, $target, &$html, &$customAttribs, &$query,		&$options, &$ret ) { global $wgLocalStyle, $wgRemoteStyle, $wgPureWikiDeletionInEffect , $wgTitle, $wgRequest, $wgInterwikiExistenceBrokenLinkStyle, $wgInterwikiExistenceExcludeNamespaced; $options[] = 'broken'; $customAttribs['class'] = 'new'; #$ret = Html::rawElement ( 'a', array ( 'href' => $target->getFullURL, 'class' => 'new' ),		#	$target->getPrefixedDBKey ); return true; if ( $wgTitle->getNamespace == -1 ) { return true; }

if ( isset( $query['action'] ) && $query['action'] == 'history' ) { return true; }

if ( $wgRequest->getText( 'action' ) == 'history' ) { return true; }

$itIsBlank = false;

// If it's an external link, see if it leads to Wikipedia, and // if so, whether that page exists on Wikipedia if ( $target->isExternal ) { $interwikiURL = wfMsgExt( 'rped-wikipedia-url','parsemag'); $dbr = wfGetDB( DB_SLAVE ); $title = $target->getDBkey ;

if ( strpos ( $title, ':' ) && $wgInterwikiExistenceExcludeNamespaced ) { return true; }

$interwikiPrefix = $target->getInterwiki ; $result = $dbr->selectRow(				'interwiki',				'iw_prefix',				array( "iw_url" => $interwikiURL , "iw_prefix" => $interwikiPrefix )			);

if ( !$result ) { return true; }

$result = $dbr->selectRow(				'iwe_page',				'iwe_page_id',				array( "iwe_page_title" => $title )			); if ( !$result ) { $query['action'] = "edit"; $customAttribs['style'] = $wgInterwikiExistenceBrokenLinkStyle; }			return true; }		// Return immediately if we know it's existent on the local wiki if ( in_array( 'known', $options ) ) { if ( !isset( $query['action'] ) && !isset( $query['curid'] ) ) { $customAttribs['style'] = $wgLocalStyle; }

if ( !isset( $wgPureWikiDeletionInEffect ) || $wgPureWikiDeletionInEffect != true ) { return true; }

$dbr = wfGetDB( DB_SLAVE );

/*$myRevision=Revision::loadFromTitle($dbr,$target); if ($myRevision->getRawText!=''){*/ $id = $target->getArticleID; $result = $dbr->selectRow(				'blanked_page',				'blank_page_id',				array( "blank_page_id" => $id )			); if ( !$result ) { return true; }

$itIsBlank = true; }

// If it doesn't exist on the local wiki, then see if it exists on the // remote wiki (Wikipedia) if ( in_array( 'broken', $options ) || $itIsBlank == true ) { $title = $target->getPrefixedText ; $fragment = htmlentities($target->getFragmentForURL);

for ( $thiscount = 0; $thiscount < strlen( $title ); $thiscount++ ) { if ( substr( $title, $thiscount, 1 ) == ' ' ) { $title = substr_replace( $title, '_', $thiscount, 1 ); }			}			$dbr = wfGetDB( DB_SLAVE ); $result = $dbr->selectRow(				'iwe_page',				'iwe_page_id',				array( "iwe_page_title" => $title )			); if ( !$result ) { return true; } else { $newTitle = $target->getPrefixedURL ; #$title = urlencode ( $title ); $url = wfMsgExt( 'rped-wikipedia-url','parsemag', $newTitle );

// The page that we'll link to $text = ''. $text. '';

if ( $wgRemoteStyle != '' ) { $customAttribs['style'] = $wgRemoteStyle; }			}		}		return true; }

// Get the deleted and restored articles $deleteUrl = $url. $wgInterwikiExistenceApiDeleteArgs; $deleteUrl = str_replace ( '$1', $result->up_value, $newUrl ); $deleteTitles = InterwikiExistence::InterwikiExistenceApiPull ( $url ); if ( $deleteTitles == INTERWIKIEXISTENCE_NORETRIEVE || $deleteTitles ==			INTERWIKIEXISTENCE_NODECODE ) { return true; }		$apiPull = $apiPull['query']['logevents'];

$result = $dbr->selectrow( 'iwe_page', array ( 'iwe_page_title', $field ), $cond ); $resultArray = array;

foreach ( $apiPull['query'][$submodule] as $apiPullElement ) { if ( !$firstElement ) { $cond .= " AND "; }			$cond .= "iwe_page_title='". $apiPullElement['title']. "'";		}

foreach ( $apiPull['query'][$submodule] as $apiPullElement ) {

$upsert[] = array (				'iwe_page_title' => $apiPullElement['title'],				$iwepField => $apiPullElement['timestamp']			); }		// Update iwe_page table $dbw->upsert ( 'iwe_page', $upsert, array ( 'iwe_page_title' ), $upsert );

if ( in_array ( array ( 'title' => $title ), $apiPull['query'][$submodule] ) ) { $cleanTimestamp = InterwikiExistenceHooks::removeUndesirables (					$apiPull['query'][$submodule]['timestamp'] ); $dbw->update ( 'iwe_page', array ( $iwepField => $cleanTimestamp ),					array ( 'iwe_page_title' => $title )				); } else { $insertArray[] = array (					'iwe_page_title' => $title,					$iwepField => $cleanTimestamp				); } if ( !$wgInterwikiExistenceRecursionInProgress && substr ( $title, 0, strlen ( $wgInterwikiExistencePrefix ) + 1 ) == $wgInterwikiExistencePrefix . ':' ) $encodedTitle = $dbr->strencode ( substr ( $title, strlen ( $wgInterwikiExistencePrefix ) + 1, strlen ( $title ) - $wgInterwikiExistencePrefix ) ); $ret = Html::rawElement ( 'a', array ( 'href' => $target->getFullURL, 'class' => 'new' ),			       $title );

hile ( $a = strpos ( $propValue, '' ) ) { $b = strpos ( $propValue, '', $a + 1 ); $propValue = substr ( $propValue, 0, $a - 1 ). $substr ( $propValue,                               $b + 1, strlen ( $propValue ) - 1 ); }

<?php /** * Countdown MediaWiki extension. * * Adds tag and parser function * * Written by Leucosticte * https://www.mediawiki.org/wiki/User:Leucosticte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup Extensions */

if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( 1 ); }

$wgHooks['ParserFirstCallInit'][] = "Countdown::SetupCountdownParserFunction"; $wgExtensionFunctions[] = "Countdown::CountdownExtension"; $wgExtensionCredits['parserhook'][] = array(               'version'     => '1.3',                'name'        => 'Countdown',                'author'      => array('Peter Strömberg', 'Paul Grinberg'),                'email'       => 'pez@pezius.com, gri6507 at yahoo dot com',                'url'         => 'http://www.mediawiki.org/wiki/Extension:Countdown',                'description' => 'adds and  '                        . 'parser function'                ); $wgExtensionMessagesFiles['Countdown'] = dirname( __FILE__ ). '/Countdown.i18n.php';

class Countdown { public static function SetupCountdownParserFunction( &$parser ) { $parser->setFunctionHook( "countdown", "Countdown::renderCountdownParserFunction" ); }

public static function CountdownExtension { global $wgParser; $wgParser->setHook( "countdown", "Countdown::renderCountdown" ); }

public static function renderCountdownParserFunction ( $parser, $date = , $format =  ) { $key = str_replace ( 'UTC', '', $date ); $newTime = DateTime::createFromFormat ( 'm/d/Y g:i A O', $date ); $format = " "; $input=$format; $argv=array; global $wgCountdown; $localDebug = 0;
 * Days: 
 * Hours: 
 * Minutes: 
 * Seconds: 

$name = uniqid('countdown'); $targetTime = "12/24/2007 7:00 PM UTC-0500"; foreach ($argv as $key => $value) { switch ($key) { case 'name': $name = $value; break; case 'time': $targetTime = $value; break; default : wfDebug( __METHOD__.": Requested '$key ==> $value'\n" ); break; }       }

if ($localDebug) { wfDebug( __METHOD__.": input is '$input'\n\n" ); }

$counter = << var $name = new countdown("$name"); $name.Name = "$name"; $name.TargetDate = "$targetTime"; $name.Setup END;

$counter .= $parser->mStripState->unstripGeneral($parser->recursiveTagParse(ereg_replace('<([DHMS])>',                   '\1 ',$input)));

$javascript = << /*     Author:         Robert Hashemian (http://www.hashemian.com/) Modified by:   Munsifali Rashid (http://www.munit.co.uk/) Modified by:   Peter Strömberg (http://halowiki.net/wiki/User:PEZ) */ function countdown(obj) { this.obj               = obj; this.Name              = "clock"; this.TargetDate        = "12/31/2020 5:00 AM UTC+0100"; this.CountActive       = true; this.Calcage           = cd_Calcage; this.CountBack         = cd_CountBack; this.Setup             = cd_Setup; } function cd_Calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString; if (s.length < 2) s = "0" + s; return (s); } function cd_CountBack(secs) { try { document.getElementById(this.Name + "_D").innerHTML = this.Calcage(secs,86400,100000); } catch(e) {}; try { document.getElementById(this.Name + "_H").innerHTML = this.Calcage(secs,3600,24); } catch(e) {}; try { document.getElementById(this.Name + "_M").innerHTML = this.Calcage(secs,60,60); } catch(e) {}; try { document.getElementById(this.Name + "_S").innerHTML = this.Calcage(secs,1,60); } catch(e) {}; if (this.CountActive) setTimeout(this.obj +".CountBack(" + (secs-1) + ")", 990); } function cd_Setup { var ddiff      = new Date((new Date(this.TargetDate)) - (new Date)); this.CountBack(Math.floor(ddiff.valueOf / 1000)); } END; $output = ''; if ($wgCountdown != 1) { $output .= $javascript; $wgCountdown = 1; }       $output .= $counter;

return $output;


 * 1) return $format;

return Countdown::renderCountdown( $format, array, $parser ); return Countdown::renderCountdown( $format, array ( 'time' => $date ), $parser ); }

public static function renderCountdown($input, $argv, $parser) { global $wgCountdown; $localDebug = 0; $input = " "; $argv = array; $name = uniqid('countdown'); $targetTime = "12/24/2007 7:00 PM UTC-0500";
 * Days: 
 * Hours: 
 * Minutes: 
 * Seconds: 

foreach ($argv as $key => $value) { switch ($key) { case 'name': $name = $value; break; case 'time': $targetTime = $value; break; default : wfDebug( __METHOD__.": Requested '$key ==> $value'\n" ); break; }       }

if ($localDebug) { wfDebug( __METHOD__.": input is '$input'\n\n" ); }

$counter = << var $name = new countdown("$name"); $name.Name = "$name"; $name.TargetDate = "$targetTime"; $name.Setup END;

$counter .= $parser->mStripState->unstripGeneral($parser->recursiveTagParse(ereg_replace('<([DHMS])>',                   '<span id="' . $name . '_\1">\1 ',$input)));

$javascript = <<<END

<script type="text/javascript"> /*     Author:         Robert Hashemian (http://www.hashemian.com/) Modified by:   Munsifali Rashid (http://www.munit.co.uk/) Modified by:   Peter Strömberg (http://halowiki.net/wiki/User:PEZ) */ function countdown(obj) { this.obj               = obj; this.Name              = "clock"; this.TargetDate        = "12/31/2020 5:00 AM UTC+0100"; this.CountActive       = true; this.Calcage           = cd_Calcage; this.CountBack         = cd_CountBack; this.Setup             = cd_Setup; } function cd_Calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString; if (s.length < 2) s = "0" + s; return (s); } function cd_CountBack(secs) { try { document.getElementById(this.Name + "_D").innerHTML = this.Calcage(secs,86400,100000); } catch(e) {}; try { document.getElementById(this.Name + "_H").innerHTML = this.Calcage(secs,3600,24); } catch(e) {}; try { document.getElementById(this.Name + "_M").innerHTML = this.Calcage(secs,60,60); } catch(e) {}; try { document.getElementById(this.Name + "_S").innerHTML = this.Calcage(secs,1,60); } catch(e) {}; if (this.CountActive) setTimeout(this.obj +".CountBack(" + (secs-1) + ")", 990); } function cd_Setup { var ddiff      = new Date((new Date(this.TargetDate)) - (new Date)); this.CountBack(Math.floor(ddiff.valueOf / 1000)); } END; $output = ''; if ($wgCountdown != 1) { $output .= $javascript; $wgCountdown = 1; }       $output .= $counter;

return $output; } }

if ( $rejected ) { $randomId = $ids[array_rand ( $ids )]; if ( !in_array ( $randomId, $returnArr ) ) { $returnArr[] = $randomId; $rejected = false; }                       }

if ( $replace ) { $output = str_replace ( $replace, $title->getFullText, $output ); }

// Renders public static function renderSetBpdProp( $parser, $key = , $value =  ) { global $wgBedellPenDragonTitleReplace; if ( $key == '' ) { return; }               $key = 'bpd_'. $key; $title = $parser->getTitle; $titleName = $title->getFullText; str_replace ( $wgBedellPenDragonTitleReplace, $titleName, $value ); $parser->getOutput->setProperty ( $key, $value ); return ''; }