Extension:PureWikiDeletion

This is the Pure Wiki Deletion (PWD) extension.

What can this extension do?
Pure wiki deletion will work as follows:

A former version of this article was blanked by [USER NAME/IP] on [DATE]. The reason given for blanking was: [EDIT SUMMARY]. You may view the article's history, edit the last version, or type new article into the white space below.
 * A link to a blank page will show up as a red link. (or orange, or whatever color you want)
 * When a user follows a link to a blank page, the page will behave the same way that deleted pages do now, except there will be an additional message, reading:
 * Blank pages will not show up in searches using Special:Search, random pages using Special:RandomExcludeBlank, or the list of all pages using Special:Allpages. [Note: The functionality relating to Special:Search and Special:Allpages has not yet been implemented.]
 * The URL prefix to a blank page should be listed in robots.txt, and the page will emit "noarchive" and "noindex" and "nofollow" tags, to prevent caching in search engines. [Note: This functionality has not yet been implemented.]

Usage
There are two parser functions, #ifblank and #ifnotblank. Their syntax is as follows: returns true. returns false.

Installation
Add this line to LocalSettings.php:

Edit MediaWiki:Sidebar. There should be a line pertaining to the random page. Delete that line and replace it with:

Go to Special:PopulateBlankedPagesTable. It will automatically populate your blanked pages table with any blanked pages that may exist on your wiki.

Configuration parameters
You can change the style of broken, blank and known links. By default, broken links are a cherry red that is a bit brighter than the shade of red we are accustomed to seeing in broken links. These parameters should be placed in LocalSettings.php:

$wgPWDBlankLinkStyle="color: #FF4500";

SpecialPWD.php
';		$nsForm = $this->namespaceForm( $namespace, $from, $to );

# Is there more? if( $this->including ) { $out2 = ''; } else { if( isset($from) || isset($to) ) { global $wgUser; $out2 = ' ";			} else {				$out2 = $nsForm;			}		}		$wgOut->addHTML( $out2 . $out );	}

/**	 * Show a line of "ABC to DEF" ranges of articles * @param string $inpoint Lower limit of pagenames * @param string $outpout Upper limit of pagenames * @param integer $namespace (Default NS_MAIN) */	function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) { global $wgContLang; $align = $wgContLang->isRtl ? 'left' : 'right'; $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) ); $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) ); // Don't let the length runaway $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength ); $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength );

$queryparams = $namespace ? "namespace=$namespace&" : ''; $special = $this->getTitle; $link = $special->escapeLocalUrl( $queryparams . 'from=' . urlencode($inpoint) . '&to=' . urlencode($outpoint) );

$out = wfMsgHtml( 'alphaindexline',			"$inpointf ",			"  $outpointf"		); return ' '.$out.' '; }

/**	 * @param integer $namespace (Default NS_MAIN) * @param string $from list all pages from this name (default FALSE) * @param string $to list all pages to this name (default FALSE) */	function showChunk( $namespace = NS_MAIN, $from = false, $to = false ) { global $wgOut, $wgUser, $wgContLang, $wgLang;

$sk = $wgUser->getSkin;

$fromList = $this->getNamespaceKeyAndText($namespace, $from); $toList = $this->getNamespaceKeyAndText( $namespace, $to ); $namespaces = $wgContLang->getNamespaces; $align = $wgContLang->isRtl ? 'left' : 'right';

$n = 0;

if ( !$fromList || !$toList ) { $out = wfMsgWikiHtml( 'allpagesbadtitle' ); } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) { // Show errormessage and reset to NS_MAIN $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace ); $namespace = NS_MAIN; } else { list( $namespace, $fromKey, $from ) = $fromList; list( $namespace2, $toKey, $to ) = $toList;

$dbr = wfGetDB( DB_SLAVE ); $conds = array(				'page_namespace' => $namespace,				'page_title >= ' . $dbr->addQuotes( $fromKey )			); if( $toKey !== "" ) { $conds[] = 'page_title <= '. $dbr->addQuotes( $toKey ); }

$res = $dbr->select( 'page',				array( 'page_namespace', 'page_title', 'page_is_redirect' ),				$conds,				__METHOD__,				array( 'ORDER BY' => 'page_title', 'LIMIT'    => $this->maxPerPage + 1, 'USE INDEX' => 'name_title', )			);

if( $res->numRows > 0 ) { $out = ' '; } else { $out = ''; }		}

if ( $this->including ) { $out2 = ''; } else { if( $from == '' ) { // First chunk; no previous link. $prevTitle = null; } else { # Get the last title from previous chunk $dbr = wfGetDB( DB_SLAVE ); $res_prev = $dbr->select(					'page',					'page_title',					array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ),					__METHOD__,					array( 'ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 ) )				);

# Get first title of previous complete chunk if( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) { $pt = $dbr->fetchObject( $res_prev ); $prevTitle = Title::makeTitle( $namespace, $pt->page_title ); } else { # The previous chunk is not complete, need to link to the very first title # available in the database $options = array( 'LIMIT' => 1 ); if ( ! $dbr->implicitOrderby ) { $options['ORDER BY'] = 'page_title'; }					$reallyFirstPage_title = $dbr->selectField( 'page', 'page_title',						array( 'page_namespace' => $namespace ), __METHOD__, $options ); # Show the previous link if it s not the current requested chunk if( $from != $reallyFirstPage_title ) { $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title ); } else { $prevTitle = null; }				}			}

$self = $this->getTitle;

$nsForm = $this->namespaceForm( $namespace, $from, $to ); $out2 = ' ";		}

$wgOut->addHTML( $out2 . $out ); if( isset($prevLink) or isset($nextLink) ) { $wgOut->addHTML( ' ' ); if( isset( $prevLink ) ) { $wgOut->addHTML( $prevLink ); }			if( isset( $prevLink ) && isset( $nextLink ) ) { $wgOut->addHTML( wfMsgExt( 'pipe-separator' , 'escapenoentities' ) ); }			if( isset( $nextLink ) ) { $wgOut->addHTML( $nextLink ); }			$wgOut->addHTML( ' ' );

}

}

/**	 * @param int $ns the namespace of the article * @param string $text the name of the article * @return array( int namespace, string dbkey, string pagename ) or NULL on error * @static (sort of) * @access private */	function getNamespaceKeyAndText($ns, $text) { if ( $text == '' ) return array( $ns, ,  ); # shortcut for common case

$t = Title::makeTitleSafe($ns, $text); if ( $t && $t->isLocal ) { return array( $t->getNamespace, $t->getDBkey,				$t->getText ); } else if ( $t ) { return NULL; }

# try again, in case the problem was an empty pagename $text = preg_replace('/(#|$)/', 'X$1', $text); $t = Title::makeTitleSafe($ns, $text); if ( $t && $t->isLocal ) { return array( $t->getNamespace, ,  ); } else { return NULL; }	} }

class PopulateBlankedPagesTable extends SpecialPage { function __construct { parent::__construct( 'PopulateBlankedPagesTable','pwd' ); wfLoadExtensionMessages('PopulateBlankedPagesTable'); }	function execute( $par ) { global $wgRequest, $wgOut,$wgUser; if ( !$this->userCanExecute($wgUser) ) { $this->displayRestrictionError; return; }		$dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); $page_row=array(			'page_id',		       'page_namespace'		); $result=$dbr->select( 'page', $page_row ); while ($myRow=$dbr->fetchRow($result)){ $myId=$myRow['page_id']; $myNamespace=$myRow['page_namespace']; if ($myNamespace!=NS_FILE){ $myRevision=Revision::loadFromPageId($dbr,$myId); $myText=$myRevision->getRawText; if ($myText==""){ while ($myPrevious=$myRevision->getPrevious){ if ($myPrevious->getRawText==''){ $myRevision=$myPrevious; }						else { break; }					}					$blank_row=array(						'blank_page_id'		=> $myId,						'blank_user_name'							=> $myRevision->getRawUserText,						'blank_timestamp'							=> $myRevision->getTimeStamp,						'blank_summary'							=> $myRevision->getRawComment,						'blank_parent_id'							=> $myRevision->getParentId,					); $checkPresence=$dbr->selectRow('blanked_pages',						'blank_page_id'						,array("blank_page_id" => $myId)); if (!$checkPresence){ $dbw->insert('blanked_pages',$blank_row); }				}			}		}		$output="Done populating blanked_pages table."; $wgOut->addWikiText($output); } }

pwd.css
.PWDBlankLinkStyle { color: #FF4500; }

Development notes
See Extension talk:PWD.