# Return the text of this revision
function getContent( $noredir = false )
{
- global $action,$section,$count; # From query string
+ global $wgRequest;
+
+ # Get variables from query string :P
+ $action = $wgRequest->getText( 'action', 'view' );
+ $section = $wgRequest->getText( 'section' );
+
$fname = "Article::getContent";
wfProfileIn( $fname );
# Load the revision (including cur_text) into this object
function loadContent( $noredir = false )
{
- global $wgOut, $wgMwRedir;
- global $oldid, $redirect; # From query
+ global $wgOut, $wgMwRedir, $wgRequest;
+
+ # Query variables :P
+ $oldid = $wgRequest->getVal( 'oldid' );
+ $redirect = $wgRequest->getVal( 'redirect' );
if ( $this->mContentLoaded ) return;
$fname = "Article::loadContent";
function view()
{
- global $wgUser, $wgOut, $wgLang;
- global $oldid, $diff; # From query
+ global $wgUser, $wgOut, $wgLang, $wgRequest;
global $wgLinkCache, $IP, $wgEnableParserCache;
$fname = "Article::view";
wfProfileIn( $fname );
+ # Get variables from query string :P
+ $oldid = $wgRequest->getVal( 'oldid' );
+ $diff = $wgRequest->getVal( 'diff' );
+
$wgOut->setArticleFlag( true );
$wgOut->setRobotpolicy( "index,follow" );
# If we got diff and oldid in the query, we want to see a
# diff page instead of the article.
- if ( isset( $diff ) ) {
+ if ( !is_null( $diff ) ) {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $de = new DifferenceEngine( $oldid, $diff );
+ $de = new DifferenceEngine( intval($oldid), intval($diff) );
$de->showDiffPage();
wfProfileOut( $fname );
return;
}
- if ( !isset( $oldid ) and $this->checkTouched() ) {
+ if ( !is_null( $oldid ) and $this->checkTouched() ) {
if( $wgOut->checkLastModified( $this->mTouched ) ){
return;
} else if ( $this->tryFileCache() ) {
# We're looking at an old revision
- if ( $oldid ) {
+ if ( !empty( $oldid ) ) {
$this->setOldSubtitle();
$wgOut->setRobotpolicy( "noindex,follow" );
}
return $this->protect( "" );
}
+ # UI entry point for page deletion
function delete()
{
- global $wgUser, $wgOut, $wgMessageCache;
- global $wpConfirm, $wpReason, $image, $oldimage;
+ global $wgUser, $wgOut, $wgMessageCache, $wgRequest;
$fname = "Article::delete";
-
+ $confirm = $wgRequest->getBool( 'wpConfirm' ) && $wgRequest->isPosted();
+ $reason = $wgRequest->getText( 'wpReason' );
+
# This code desperately needs to be totally rewritten
+ # Check permissions
if ( ( ! $wgUser->isSysop() ) ) {
$wgOut->sysopRequired();
return;
return;
}
- if ( @$_POST["wpConfirm"] ) {
- $this->doDelete();
+ if ( $confirm ) {
+ $this->doDelete( $reason );
return;
}
$etitle = wfStrencode( $title );
$sql = "SELECT old_text,old_flags FROM old WHERE old_namespace=$ns and old_title='$etitle' ORDER BY inverse_timestamp LIMIT 1";
$res = wfQuery( $sql, DB_READ, $fname );
- if( ($old=wfFetchObject($res)) && !$wpConfirm ) {
+ if( ($old=wfFetchObject($res)) && !$confirm ) {
$skin=$wgUser->getSkin();
$wgOut->addHTML("<B>".wfMsg("historywarning"));
$wgOut->addHTML( $skin->historyLink() ."</B><P>");
# this should not happen, since it is not possible to store an empty, new
# page. Let's insert a standard text in case it does, though
- if($length==0 && !$wpReason) { $wpReason=wfmsg("exblank");}
-
+ if($length == 0 && $reason === "") {
+ $reason = wfMsg("exblank");
+ }
- if($length < 500 && !$wpReason) {
+ if($length < 500 && $reason === "") {
# comment field=255, let's grep the first 150 to have some user
# space left
$text=preg_replace("/\>/",">",$text);
$text=preg_replace("/[\n\r]/","",$text);
if(!$blanked) {
- $wpReason=wfMsg("excontent"). " '".$text;
+ $reason=wfMsg("excontent"). " '".$text;
} else {
- $wpReason=wfMsg("exbeforeblank") . " '".$text;
+ $reason=wfMsg("exbeforeblank") . " '".$text;
}
- if($length>150) { $wpReason .= "..."; } # we've only pasted part of the text
- $wpReason.="'";
+ if($length>150) { $reason .= "..."; } # we've only pasted part of the text
+ $reason.="'";
}
}
- return $this->confirmDelete();
+ return $this->confirmDelete( "", $reason );
}
- function confirmDelete( $par = "" )
+ # Output deletion confirmation dialog
+ function confirmDelete( $par, $reason )
{
global $wgOut;
- global $wpReason;
wfDebug( "Article::confirmDelete\n" );
<form id=\"deleteconfirm\" method=\"post\" action=\"{$formaction}\">
<table border=0><tr><td align=right>
{$delcom}:</td><td align=left>
-<input type=text size=60 name=\"wpReason\" value=\"" . htmlspecialchars( $wpReason ) . "\">
+<input type=text size=60 name=\"wpReason\" value=\"" . htmlspecialchars( $reason ) . "\">
</td></tr><tr><td> </td></tr>
<tr><td align=right>
<input type=checkbox name=\"wpConfirm\" value='1' id=\"wpConfirm\">
$wgOut->returnToMain( false );
}
- function doDelete()
+ # Perform a deletion and output success or failure messages
+ function doDelete( $reason )
{
global $wgOut, $wgUser, $wgLang;
- global $wpReason;
$fname = "Article::doDelete";
wfDebug( "$fname\n" );
}
}
- # Delete the article, returns success
- function doDeleteArticle()
+ # Back-end article deletion
+ # Deletes the article with database consistency, writes logs, purges caches
+ # Returns success
+ function doDeleteArticle( $reason )
{
- global $wgUser, $wgLang, $wgRequest;
+ global $wgUser, $wgLang;
global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
$fname = "Article::doDeleteArticle";
$log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
$art = $this->mTitle->getPrefixedText();
- $wpReason = $wgRequest->getText( "wpReason" );
- $log->addEntry( wfMsg( "deletedarticle", $art ), $wpReason );
+ $log->addEntry( wfMsg( "deletedarticle", $art ), $reason );
# Clear the cached article id so the interface doesn't act like we exist
$this->mTitle->resetArticleID( 0 );
}
function isFileCacheable() {
- global $wgUser, $wgUseFileCache, $wgShowIPinHeader;
- global $action, $oldid, $diff, $redirect, $printable;
+ global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest;
+ extract( $wgRequest->getValues( 'action', 'oldid', 'diff', 'redirect', 'printable' ) );
+
return $wgUseFileCache
and (!$wgShowIPinHeader)
and ($this->getID() != 0)
function wfRecordUpload( $name, $oldver, $size, $desc )
{
global $wgUser, $wgLang, $wgTitle, $wgOut, $wgDeferredUpdateList;
- global $wgUseCopyrightUpload , $wpUploadCopyStatus , $wpUploadSource ;
+ global $wgRequest, $wgUseCopyrightUpload;
+
+ extract( $wgRequest->getValues( 'wpUploadCopyStatus', 'wpUploadSource' ) );
$fname = "wfRecordUpload";
function delete()
{
- global $wgUser, $wgOut;
- global $wpConfirm, $wpReason, $image, $oldimage;
+ global $wgUser, $wgOut, $wgRequest;
+ $confirm = $wgRequest->getBool( 'wpConfirm' );
+ $image = $wgRequest->getVal( 'image' );
+ $oldimage = $wgRequest->getVal( 'oldimage' );
+
# Only sysops can delete images. Previously ordinary users could delete
# old revisions, but this is no longer the case.
if ( !$wgUser->isSysop() ) {
# Better double-check that it hasn't been deleted yet!
$wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
- if ( $image ) {
+ if ( !is_null( $image ) ) {
if ( "" == trim( $image ) ) {
$wgOut->fatalError( wfMsg( "cannotdelete" ) );
return;
}
# Deleting old images doesn't require confirmation
- if ( $oldimage || 1 == $wpConfirm ) {
+ if ( !is_null( $oldimage ) || $confirm ) {
$this->doDelete();
return;
}
- if ( $image ) {
+ if ( !is_null( $image ) ) {
$q = "&image={$image}";
- } else if ( $oldimage ) {
+ } else if ( !is_null( $oldimage ) ) {
$q = "&oldimage={$oldimage}";
}
return $this->confirmDelete( $q );
function doDelete()
{
- global $wgOut, $wgUser, $wgLang;
- global $image, $oldimage, $wpReason;
+ global $wgOut, $wgUser, $wgLang, $wgRequest;
global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
$fname = "Article::doDelete";
- if ( $image ) {
+ $reason = $wgRequest->getVal( 'wpReason' );
+ $image = $wgRequest->getVal( 'image' );
+ $oldimage = $wgRequest->getVal( 'oldimage' );
+
+ if ( !is_null( $image ) ) {
$dest = wfImageDir( $image );
$archive = wfImageDir( $image );
if ( ! unlink( "{$dest}/{$image}" ) ) {
$nt = Title::newFromText( $wgLang->getNsText( Namespace::getImage() ) . ":" . $image );
$article = new Article( $nt );
- $article->doDeleteArticle(); # ignore errors
+ $article->doDeleteArticle( $reason ); # ignore errors
$deleted = $image;
- } else if ( $oldimage ) {
+ } else if ( !is_null( $oldimage ) ) {
# Squid purging
if ( $wgUseSquid ) {
$urlArr = Array(
$deleted = $oldimage;
} else {
- $this->doDeleteArticle(); # ignore errors
+ $this->doDeleteArticle( $reason ); # ignore errors
$deleted = $this->mTitle->getPrefixedText();
}
$wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
function revert()
{
- global $wgOut;
- global $oldimage;
+ global $wgOut, $wgRequest;
global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
+ $oldimage = $wgRequest->getText( 'oldimage' );
+
if ( strlen( $oldimage ) < 16 ) {
$wgOut->unexpectedValueError( "oldimage", $oldimage );
return;
function returnToMain( $auto = true )
{
- global $wgUser, $wgOut, $returnto;
+ global $wgUser, $wgOut, $wgRequest;
+
+ $returnto = $wgRequest->getText( 'returnto' );
$sk = $wgUser->getSkin();
if ( "" == $returnto ) {
$pre_content[$marker] = "<pre>$content</pre>";
}
}
-
- $state = array( $nowiki_content, $hiero_content, $math_content, $pre_content );
+ # Must expand in reverse order, otherwise nested tags will be corrupted
+ $state = array( $pre_content, $math_content, $hiero_content, $nowiki_content );
return $text;
}
/* private */ function handle5Quotes( &$state, $token )
{
+ $s = "";
if ( $state["em"] && $state["strong"] ) {
if ( $state["em"] < $state["strong"] ) {
$s .= "</strong></em>";
$full = "";
$head = array();
$sublevelCount = array();
+ $level = 0;
+ $prevlevel = 0;
foreach( $matches[3] as $headline ) {
+ $numbering = "";
if( $level ) {
$prevlevel = $level;
}
$toclevel -= $prevlevel - $level;
}
# count number of headlines for each level
- $sublevelCount[$level]++;
-
+ @$sublevelCount[$level]++;
if( $doNumberHeadings || $doShowToc ) {
+ $dot = 0;
for( $i = 1; $i <= $level; $i++ ) {
- if( $sublevelCount[$i] ) {
+ if( !empty( $sublevelCount[$i] ) ) {
if( $dot ) {
$numbering .= ".";
}
$refer[$headlineCount] = $canonized_headline;
# count how many in assoc. array so we can track dupes in anchors
- $refers[$canonized_headline]++;
+ @$refers[$canonized_headline]++;
$refcount[$headlineCount]=$refers[$canonized_headline];
# Prepend the number to the heading text
$toc .= $sk->tocLine($anchor,$tocline,$toclevel);
}
if( $showEditLink ) {
+ if ( empty( $head[$headlineCount] ) ) {
+ $head[$headlineCount] = "";
+ }
$head[$headlineCount] .= $sk->editSectionLink($headlineCount+1);
}
}
# give headline the correct <h#> tag
- $head[$headlineCount] .= "<h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">";
+ @$head[$headlineCount] .= "<h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">";
# Add the edit section link
if( $rightClickHack ) {
$head[$headlineCount] = $sk->editSectionScript($headlineCount+1,$head[$headlineCount]);
}
- $numbering = "";
$headlineCount++;
- $dot = 0;
}
if( $doShowToc ) {
$i = 0;
foreach( $blocks as $block ) {
- if( $showEditLink && $headlineCount > 0 && $i == 0 ) {
+ if( $showEditLink && $headlineCount > 0 && $i == 0 && $block != "\n" ) {
# This is the [edit] link that appears for the top block of text when
# section editing is enabled
$full .= $sk->editSectionLink(0);
function getBodyOptions()
{
- global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $oldid, $redirect, $diff,$action;
+ global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
+
+ extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
if ( 0 != $wgTitle->getNamespace() ) {
$a = array( "bgcolor" => "#ffffec" );
}
else $a = array( "bgcolor" => "#FFFFFF" );
- if($wgOut->isArticle() && $wgUser->getOption("editondblclick")
- &&
- (!$wgTitle->isProtected() || $wgUser->isSysop())
-
- ) {
+ if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
+ (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
$t = wfMsg( "editthispage" );
$oid = $red = "";
- if ( $redirect ) { $red = "&redirect={$redirect}"; }
- if ( $oldid && ! isset( $diff ) ) {
+ if ( $redirect ) {
+ $red = "&redirect={$redirect}";
+ }
+ if ( !empty($oldid) && ! isset( $diff ) ) {
$oid = "&oldid={$oldid}";
}
$s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
function pageTitleLinks()
{
- global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval;
+ global $wgOut, $wgTitle, $wgUser, $wgLang, $wgUseApproval, $wgRequest;
+
+ extract( $wgRequest->getValues( 'oldid', 'diff' ) );
+ $action = $wgRequest->getText( 'action' );
$s = $this->printableLink();
if ( wfMsg ( "disclaimers" ) != "-" ) $s .= " | " . $this->makeKnownLink( wfMsg( "disclaimerpage" ), wfMsg( "disclaimers" ) ) ;
function searchForm()
{
- global $search;
+ global $wgRequest;
+
+ $search = $wgRequest->getText( 'search' );;
$s = "<form name='search' class='inline' method=post action=\""
. wfLocalUrl( "" ) . "\">"
function pageStats()
{
- global $wgOut, $wgLang, $wgArticle;
- global $oldid, $diff, $wgDisableCounters;
-
+ global $wgOut, $wgLang, $wgArticle, $wgRequest;
+ global $wgDisableCounters;
+
+ extract( $wgRequest->getValues( 'oldid', 'diff' ) );
if ( ! $wgOut->isArticle() ) { return ""; }
if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
if ( 0 == $wgArticle->getID() ) { return ""; }
function quickBar()
{
- global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
- global $wpPreview, $wgDisableUploads, $wgRemoteUploads;
+ global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
+ global $wgDisableUploads, $wgRemoteUploads;
$fname = "Skin::quickBar";
wfProfileIn( $fname );
+ $action = $wgRequest->getText( 'action' );
+ $wpPreview = $wgRequest->getBool( 'wpPreview' );
$tns=$wgTitle->getNamespace();
$s = "\n<div id='quickbar'>";
function editThisPage()
{
- global $wgOut, $wgTitle, $oldid, $redirect, $diff;
-
+ global $wgOut, $wgTitle, $wgRequest;
+
+ $oldid = $wgRequest->getVal( 'oldid' );
+ $diff = $wgRequest->getVal( 'diff' );
+ $redirect = $wgRequest->getVal( 'redirect' );
+
if ( ! $wgOut->isArticleRelated() ) {
$s = wfMsg( "protectedpage" );
} else {
}
$oid = $red = "";
- if ( $redirect ) { $red = "&redirect={$redirect}"; }
+ if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
if ( $oldid && ! isset( $diff ) ) {
$oid = "&oldid={$oldid}";
}
function deleteThisPage()
{
- global $wgUser, $wgOut, $wgTitle, $diff;
+ global $wgUser, $wgOut, $wgTitle, $wgRequest;
+ $diff = $wgRequest->getVal( 'diff' );
if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
$n = $wgTitle->getPrefixedText();
$t = wfMsg( "deletethispage" );
function protectThisPage()
{
- global $wgUser, $wgOut, $wgTitle, $diff;
+ global $wgUser, $wgOut, $wgTitle, $wgRequest;
+ $diff = $wgRequest->getVal( 'diff' );
if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
$n = $wgTitle->getPrefixedText();
function watchThisPage()
{
- global $wgUser, $wgOut, $wgTitle, $diff;
+ global $wgUser, $wgOut, $wgTitle;
if ( $wgOut->isArticleRelated() ) {
$n = $wgTitle->getPrefixedText();
global $wgOut, $wgLang, $wgTitle, $wgUseNewInterlanguage;
$a = $wgOut->getLanguageLinks();
- # TEST THIS @@@
if ( 0 == count( $a ) ) {
if ( !$wgUseNewInterlanguage ) return "";
$ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
}
function tocIndent($level) {
- return str_repeat( "<div class='tocindent'>\n", $level );
+ return str_repeat( "<div class='tocindent'>\n", $level>0 ? $level : 0 );
}
function tocUnindent($level) {
- return str_repeat( "</div>\n", $level );
+ return str_repeat( "</div>\n", $level>0 ? $level : 0 );
}
# parameter level defines if we are on an indentation level
function searchForm( $label = "" )
{
- global $search;
+ global $wgRequest;
+
+ $search = $wgRequest->getText( 'search' );
$s = "<form id=\"search\" method=\"get\" class=\"inline\" action=\"" .
wfLocalUrlE( "" ) . "\">";
if ( "" != $label ) { $s .= "{$label}: "; }
function useBodyTag()
{
- global $frame;
- return ( "set" != $frame );
+ global $wgRequest;
+ return ( "set" != $wgRequest->getText( 'frame' ) );
}
function qbSetting() { return 0; }
function transformContent( $text )
{
- global $frame, $HTTP_SERVER_VARS;
+ global $wgRequest, $HTTP_SERVER_VARS;
global $wgOut, $wgServer, $wgScript;
+ $frame = $wgRequest->getText( 'frame' );
$qs = $HTTP_SERVER_VARS["QUERY_STRING"];
$qs = wfEscapeHTML( $qs );
function outputPage( &$out ) {
global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgOut;
global $wgScriptPath, $wgStyleSheetPath, $wgLanguageCode, $wgUseNewInterlanguage;
- global $wgOutputEncoding, $wgUseDatabaseMessages, $action, $oldid, $diff;
+ global $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
+
+ $action = $wgRequest->getText( 'action' );
+ $oldid = $wgRequest->getVal( 'oldid' );
+ $diff = $wgRequest->getVal( 'diff' );
$this->initPage();
$tpl = new PHPTAL($this->template . '.pt', 'templates');
if ( 0 != $wgUser->getID() ) {
$name = $wgUser->getName();
} else {
- $name = $_COOKIE["{$wgDBname}UserName"];
+ $name = @$_COOKIE["{$wgDBname}UserName"];
}
}
$pwd = $wgRequest->getText( 'wpPassword' );
# The URL contains $1, which is replaced by the title
function getInterwikiLink( $key )
{
- global $wgMemc, $wgDBname, $title_interwiki_cache;
+ global $wgMemc, $wgDBname;
+ static $title_interwiki_cache = array();
+
$k = "$wgDBname:interwiki:$key";
if( array_key_exists( $k, $title_interwiki_cache ) )
}
wfFreeResult( $res );
} else {
- # TEST THIS @@@
global $wgDBname, $wgMemc;
$key = "$wgDBname:newtalk:ip:{$this->mName}";
$newtalk = $wgMemc->get( $key );
return $this->getGPCText( $_REQUEST, $name, $default );
}
+ function getValues() {
+ $names = func_get_args();
+ $retVal = array();
+ foreach ( $names as $name ) {
+ $value = $this->getVal( $name );
+ if ( !is_null( $value ) ) {
+ $retVal[$name] = $value;
+ }
+ }
+ return $retVal;
+ }
+
function wasPosted() {
return $_SERVER['REQUEST_METHOD'] == 'POST';
}
}
-?>
\ No newline at end of file
+?>
"contextlines" => 5, "contextchars" => 50,
"skin" => 'standard', "math" => 1, "rcdays" => 7, "rclimit" => 50,
"highlightbroken" => 1, "stubthreshold" => 0,
- "previewontop" => 1, "editsection"=>0,"editsectiononrightclick"=>0, "showtoc"=>1,
+ "previewontop" => 1, "editsection"=>1,"editsectiononrightclick"=>0, "showtoc"=>1,
"showtoolbar" =>1,
"date" => 0
);