# the rest of the page we're on.
if( $globalTitle ) {
global $wgOut;
- if ( $rt->getInterwiki() != '' ) {
+ if ( $rt->getInterwiki() != '' && $rt->isLocal() ) {
$wgOut->redirect( $rt->getFullURL() ) ;
return false;
}
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
# If we have been passed an &rcid= parameter, we want to give the user a
# chance to mark this new article as patrolled.
- if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->getID() != 0 &&
+ if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->isLoggedIn() &&
( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) )
{
$wgOut->addHTML( wfMsg ( 'markaspatrolledlink',
else { $redir = 0; }
$now = wfTimestampNow();
- $won = wfInvertTimestamp( $now );
wfSeedRandom();
$rand = wfRandom();
- $isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
+ $isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
$mungedText = $text;
$flags = Revision::compressRevisionText( $mungedText );
'rev_timestamp' => $dbw->timestamp($now),
'rev_minor_edit' => $isminor,
'rev_user_text' => $wgUser->getName(),
- 'inverse_timestamp' => $won,
), $fname );
$this->mTitle->resetArticleID( $newid );
$good = true;
if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; }
- if ( $minor && $wgUser->getID() ) { $me2 = 1; } else { $me2 = 0; }
+ if ( $minor && $wgUser->isLoggedIn() ) { $me2 = 1; } else { $me2 = 0; }
if ( $this->isRedirect( $text ) ) {
# Remove all content but redirect
# This could be done by reconstructing the redirect from a title given by
$this->mCountAdjustment = $this->isCountable( $text )
- $this->isCountable( $oldtext );
$now = wfTimestampNow();
- $won = wfInvertTimestamp( $now );
$mungedText = $text;
$flags = Revision::compressRevisionText( $mungedText );
'rev_user' => $wgUser->getID(),
'rev_user_text' => $wgUser->getName(),
'rev_timestamp' => $dbw->timestamp( $now ),
- 'inverse_timestamp' => $won
), $fname
);
$wgEnotif->NotifyOnPageChange( $wgUser->getID(), $this->mTitle->getDBkey(), $this->mTitle->getNamespace(),$now, $summary, $me2, $oldid );
}
- /**
- * Validate article
- * @todo document this function a bit more
- */
- function validate () {
- global $wgOut, $wgUseValidation;
- if( $wgUseValidation ) {
- require_once ( 'SpecialValidate.php' ) ;
- $wgOut->setPagetitle( wfMsg( 'validate' ) . ': ' . $this->mTitle->getPrefixedText() );
- $wgOut->setRobotpolicy( 'noindex,follow' );
- if( $this->mTitle->getNamespace() != 0 ) {
- $wgOut->addHTML( wfMsg( 'val_validate_article_namespace_only' ) );
- return;
- }
- $v = new Validation;
- $v->validate_form( $this->mTitle->getDBkey() );
- } else {
- $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
- }
- }
-
/**
* Mark this particular edit as patrolled
*/
$wgOut->errorpage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
return;
}
- if ( $wgUser->getID() == 0 )
+ if ( $wgUser->isAnon() )
{
$wgOut->loginToUse();
return;
global $wgUser, $wgOut;
- if ( 0 == $wgUser->getID() ) {
+ if ( $wgUser->isAnon() ) {
$wgOut->errorpage( 'watchnologin', 'watchnologintext' );
return;
}
global $wgUser, $wgOut;
- if ( 0 == $wgUser->getID() ) {
+ if ( $wgUser->isAnon() ) {
$wgOut->errorpage( 'watchnologin', 'watchnologintext' );
return;
}
return;
}
- $confirm = $wgRequest->getBool( 'wpConfirmProtect' ) && $wgRequest->wasPosted();
+ $confirm = $wgRequest->getBool( 'wpConfirmProtect' ) &&
+ $wgRequest->wasPosted() &&
+ $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
$moveonly = $wgRequest->getBool( 'wpMoveOnly' );
$reason = $wgRequest->getText( 'wpReasonProtect' );
* Output protection confirmation dialog
*/
function confirmProtect( $par, $reason, $limit = 'sysop' ) {
- global $wgOut;
+ global $wgOut, $wgUser;
wfDebug( "Article::confirmProtect\n" );
}
$confirm = htmlspecialchars( wfMsg( 'confirm' ) );
+ $token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( "
<form id='protectconfirm' method='post' action=\"{$formaction}\">
</td>
</tr>
</table>
+ <input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
$wgOut->returnToMain( false );
function delete() {
global $wgUser, $wgOut, $wgMessageCache, $wgRequest;
$fname = 'Article::delete';
- $confirm = $wgRequest->getBool( 'wpConfirm' ) && $wgRequest->wasPosted();
+ $confirm = $wgRequest->getBool( 'wpConfirm' ) &&
+ $wgRequest->wasPosted() &&
+ $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
$reason = $wgRequest->getText( 'wpReason' );
# This code desperately needs to be totally rewritten
'page_namespace' => $ns,
'page_title' => $title,
'rev_page = page_id'
- ), $fname, $this->getSelectOptions( array( 'ORDER BY' => 'inverse_timestamp' ) )
+ ), $fname, $this->getSelectOptions( array( 'ORDER BY' => 'rev_timestamp DESC' ) )
);
if( $dbr->numRows( $revisions ) > 1 && !$confirm ) {
* Output deletion confirmation dialog
*/
function confirmDelete( $par, $reason ) {
- global $wgOut;
+ global $wgOut, $wgUser;
wfDebug( "Article::confirmDelete\n" );
$confirm = htmlspecialchars( wfMsg( 'confirm' ) );
$check = htmlspecialchars( wfMsg( 'confirmcheck' ) );
$delcom = htmlspecialchars( wfMsg( 'deletecomment' ) );
+ $token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML( "
<form id='deleteconfirm' method='post' action=\"{$formaction}\">
</td>
</tr>
</table>
+ <input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
$wgOut->returnToMain( false );
$wgOut->readOnlyPage( $this->getContent( true ) );
return;
}
+ if( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ),
+ array( $this->mTitle->getPrefixedText(),
+ $wgRequest->getVal( 'from' ) ) ) ) {
+ $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) );
+ $wgOut->addWikiText( wfMsg( 'sessionfailure' ) );
+ return;
+ }
$dbw =& wfGetDB( DB_MASTER );
# Enhanced rollback, marks edits rc_bot=1
return $wgUseFileCache
and (!$wgShowIPinHeader)
and ($this->getID() != 0)
- and ($wgUser->getId() == 0)
+ and ($wgUser->isAnon())
and (!$wgUser->getNewtalk())
and ($this->mTitle->getNamespace() != NS_SPECIAL )
and (empty( $action ) || $action == 'view')
$ns = $this->mTitle->getNamespace();
$dbkey = $this->mTitle->getDBkey();
$encDbKey = $dbw->strencode( $dbkey );
- $timestamp = wfTimestampNow();
+ $timestamp = $dbw->timestamp();
# insert new text
$dbw->insert( 'text', array(
'old_text' => $text,
'rev_user' => $wgUser->getID(),
'rev_user_text' => $wgUser->getName(),
'rev_timestamp' => $timestamp,
- 'inverse_timestamp' => wfInvertTimestamp( $timestamp ),
'rev_minor_edit' => intval($minor) ),
$fname );
wfProfileOut( $fname );
/**
* Info about this page
+ * Called for ?action=info when $wgAllowPageInfo is on.
+ *
+ * @access public
*/
function info() {
- global $wgUser, $wgTitle, $wgOut, $wgAllowPageInfo;
+ global $wgLang, $wgOut, $wgAllowPageInfo;
$fname = 'Article::info';
-wfDebugDieBacktrace( 'This function is apparently not called by any other PHP file and might be obsolete.' );
-
if ( !$wgAllowPageInfo ) {
$wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
return;
}
- $dbr =& $this->getDB();
-
- $basenamespace = $wgTitle->getNamespace() & (~1);
- $cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace );
- $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace );
- $wl_clause = array( 'wl_title' => $wgTitle->getDBkey(), 'wl_namespace' => $basenamespace );
- $fullTitle = $wgTitle->makeName($basenamespace, $wgTitle->getDBKey());
- $wgOut->setPagetitle( $fullTitle );
+ $page = $this->mTitle->getSubjectPage();
+
+ $wgOut->setPagetitle( $page->getPrefixedText() );
$wgOut->setSubtitle( wfMsg( 'infosubtitle' ));
# first, see if the page exists at all.
- $exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname, $this->getSelectOptions() );
- if ($exists < 1) {
+ $exists = $page->getArticleId() != 0;
+ if( !$exists ) {
$wgOut->addHTML( wfMsg('noarticletext') );
} else {
- $numwatchers = $dbr->selectField( 'watchlist', 'COUNT(*)', $wl_clause, $fname,
+ $dbr =& $this->getDB( DB_SLAVE );
+ $wl_clause = array(
+ 'wl_title' => $page->getDBkey(),
+ 'wl_namespace' => $page->getNamespace() );
+ $numwatchers = $dbr->selectField(
+ 'watchlist',
+ 'COUNT(*)',
+ $wl_clause,
+ $fname,
$this->getSelectOptions() );
- $wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $numwatchers) . '</li>' );
- $old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname, $this->getSelectOptions() );
- $wgOut->addHTML( "<li>" . wfMsg('numedits', $old + 1) . '</li>');
- # to find number of distinct authors, we need to do some
- # funny stuff because of the cur/old table split:
- # - first, find the name of the 'cur' author
- # - then, find the number of *other* authors in 'old'
-
- # find 'cur' author
- $cur_author = $dbr->selectField( 'cur', 'cur_user_text', $cur_clause, $fname,
- $this->getSelectOptions() );
-
- # find number of 'old' authors excluding 'cur' author
- $authors = $dbr->selectField( 'old', 'COUNT(DISTINCT old_user_text)',
- $old_clause + array( 'old_user_text<>' . $dbr->addQuotes( $cur_author ) ), $fname,
- $this->getSelectOptions() ) + 1;
-
- # now for the Talk page ...
- $cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace+1 );
- $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace+1 );
-
- # does it exist?
- $exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname, $this->getSelectOptions() );
-
- # number of edits
- if ($exists > 0) {
- $old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname, $this->getSelectOptions() );
- $wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $old + 1) . '</li>');
+ $pageInfo = $this->pageCountInfo( $page );
+ $talkInfo = $this->pageCountInfo( $page->getTalkPage() );
+
+ $wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' );
+ $wgOut->addHTML( "<li>" . wfMsg('numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>');
+ if( $talkInfo ) {
+ $wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>');
}
- $wgOut->addHTML( '<li>' . wfMsg("numauthors", $authors) . '</li>' );
-
- # number of authors
- if ($exists > 0) {
- $cur_author = $dbr->selectField( 'cur', 'cur_user_text', $cur_clause, $fname,
- $this->getSelectOptions() );
- $authors = $dbr->selectField( 'cur', 'COUNT(DISTINCT old_user_text)',
- $old_clause + array( 'old_user_text<>' . $dbr->addQuotes( $cur_author ) ),
- $fname, $this->getSelectOptions() );
-
- $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $authors) . '</li></ul>' );
+ $wgOut->addHTML( '<li>' . wfMsg("numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' );
+ if( $talkInfo ) {
+ $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' );
}
+ $wgOut->addHTML( '</ul>' );
+
}
}
+
+ /**
+ * Return the total number of edits and number of unique editors
+ * on a given page. If page does not exist, returns false.
+ *
+ * @param Title $title
+ * @return array
+ * @access private
+ */
+ function pageCountInfo( $title ) {
+ $id = $title->getArticleId();
+ if( $id == 0 ) {
+ return false;
+ }
+
+ $dbr =& $this->getDB( DB_SLAVE );
+
+ $rev_clause = array( 'rev_page' => $id );
+ $fname = 'Article::pageCountInfo';
+
+ $edits = $dbr->selectField(
+ 'revision',
+ 'COUNT(rev_page)',
+ $rev_clause,
+ $fname,
+ $this->getSelectOptions() );
+
+ $authors = $dbr->selectField(
+ 'revision',
+ 'COUNT(DISTINCT rev_user_text)',
+ $rev_clause,
+ $fname,
+ $this->getSelectOptions() );
+
+ return array( 'edits' => $edits, 'authors' => $authors );
+ }
}
/**