var $mId, $mTable;
var $mForUpdate;
var $mOldId;
+ var $mRevIdFetched;
/**#@-*/
/**
* @private
*/
function clear() {
+ $this->mDataLoaded = false;
$this->mContentLoaded = false;
+
$this->mCurID = $this->mUser = $this->mCounter = -1; # Not loaded
$this->mRedirectedFrom = $this->mUserText =
$this->mTimestamp = $this->mComment = $this->mFileCache = '';
$this->mCountAdjustment = 0;
$this->mTouched = '19700101000000';
$this->mForUpdate = false;
+ $this->mIsRedirect = false;
+ $this->mRevIdFetched = false;
}
/**
'page_id' => IntVal( $id ) ) );
}
+ /**
+ * Set the general counter, title etc data loaded from
+ * some source.
+ *
+ * @param object $data
+ * @access private
+ */
+ function loadPageData( $data ) {
+ $this->mTitle->mRestrictions = explode( ',', trim( $data->page_restrictions ) );
+ $this->mTitle->mRestrictionsLoaded = true;
+
+ $this->mCounter = $data->page_counter;
+ $this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
+ $this->mIsRedirect = $data->page_is_redirect;
+ $this->mLatest = $data->page_latest;
+
+ $this->mDataLoaded = true;
+ }
+
/**
* Get text of an article from database
* @param int $oldid 0 for whatever the latest revision is
if( $oldid ) {
$revision = Revision::newFromId( $oldid );
if( is_null( $revision ) ) {
+ wfDebug( "$fname failed to retrieve specified revision, id $oldid\n" );
return false;
}
$data = $this->pageDataFromId( $dbr, $revision->getPage() );
if( !$data ) {
+ wfDebug( "$fname failed to get page data linked to revision id $oldid\n" );
return false;
}
$this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title );
+ $this->loadPageData( $data );
} else {
- $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
- $revision = Revision::newFromId( $data->page_latest );
+ if( !$this->mDataLoaded ) {
+ $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
+ if( !$data ) {
+ wfDebug( "$fname failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
+ return false;
+ }
+ $this->loadPageData( $data );
+ }
+ $revision = Revision::newFromId( $this->mLatest );
+ if( is_null( $revision ) ) {
+ wfDebug( "$fname failed to retrieve current page, rev_id $data->page_latest\n" );
+ return false;
+ }
}
# If we got a redirect, follow it (unless we've been told
$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
$this->mTitle = $rt;
$data = $redirData;
+ $this->loadPageData( $data );
$revision = $redirRev;
}
}
}
# Back to the business at hand...
- $this->mCounter = $data->page_counter;
- $this->mTitle->mRestrictions = explode( ',', trim( $data->page_restrictions ) );
- $this->mTitle->mRestrictionsLoaded = true;
- $this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
-
$this->mContent = $revision->getText();
$this->mUser = $revision->getUser();
$this->mComment = $revision->getComment();
$this->mTimestamp = wfTimestamp( TS_MW, $revision->getTimestamp() );
+ $this->mRevIdFetched = $revision->getID();
$this->mContentLoaded = true;
+
return $this->mContent;
}
function isRedirect( $text = false ) {
if ( $text === false ) {
$this->loadContent();
- $titleObj = Title::newFromRedirect( $this->mText );
+ $titleObj = Title::newFromRedirect( $this->fetchRevisionText() );
} else {
$titleObj = Title::newFromRedirect( $text );
}
$this->loadLastEdit();
return $this->mMinorEdit;
}
+
+ function getRevIdFetched() {
+ $this->loadLastEdit();
+ return $this->mRevIdFetched;
+ }
function getContributors($limit = 0, $offset = 0) {
$fname = 'Article::getContributors';
* Best if all done inside a transaction.
*
* @param Database $dbw
- * @return int The newly created page_id key
+ * @param string $restrictions
+ * @return int The newly created page_id key
* @access private
*/
- function insertOn( &$dbw ) {
+ function insertOn( &$dbw, $restrictions = '' ) {
$fname = 'Article::insertOn';
wfProfileIn( $fname );
'page_namespace' => $this->mTitle->getNamespace(),
'page_title' => $this->mTitle->getDBkey(),
'page_counter' => 0,
- 'page_restrictions' => '',
+ 'page_restrictions' => $restrictions,
'page_is_redirect' => 0, # Will set this shortly...
'page_is_new' => 1,
'page_random' => wfRandom(),
* errors at some point.
* @private
*/
- function insertNewArticle( $text, $summary, $isminor, $watchthis ) {
+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false ) {
global $wgOut, $wgUser;
global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
$this->updateRevisionOn( $dbw, $revision, 0 );
Article::onArticleCreate( $this->mTitle );
- RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary );
+ if(!$suppressRC) {
+ RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary );
+ }
if ($watchthis) {
if(!$this->mTitle->userIsWatching()) $this->watch();
* Validate function
*/
function validate() {
- global $wgOut, $wgUser;
+ global $wgOut, $wgUser, $wgRequest, $wgUseValidation;
+
+ if ( !$wgUseValidation ) # Are we using article validation at all?
+ {
+ $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
+ return ;
+ }
+
$wgOut->setRobotpolicy( 'noindex,follow' );
+ $revision = $wgRequest->getVal( 'revision' );
+
+ include_once ( "SpecialValidate.php" ) ; # The "Validation" class
- $wgOut->addWikiText ( "Not implemented yet" ) ;
+ $v = new Validation ;
+ if ( $wgRequest->getVal ( "mode" , "" ) == "list" )
+ $t = $v->showList ( $this ) ;
+ else
+ $t = $v->validatePageForm ( $this , $revision ) ;
+
+ $wgOut->addHTML ( $t ) ;
}
/**
<td align='left'>
<input type='text' size='60' name='wpReasonProtect' id='wpReasonProtect' value=\"" . htmlspecialchars( $reason ) . "\" />
</td>
- </tr>
- <tr>
- <td> </td>
</tr>" );
if($moveonly != '') {
$wgOut->AddHTML( "
<td align='right'>
<input type='checkbox' name='wpMoveOnly' value='1' id='wpMoveOnly' />
</td>
- <td>
+ <td align='left'>
<label for='wpMoveOnly'>{$moveonly}</label>
</td>
</tr> " );
</tr>
</table>
<input type='hidden' name='wpEditToken' value=\"{$token}\" />
-</form>\n" );
+</form>" );
$wgOut->returnToMain( false );
}
<input type='text' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" />
</td>
</tr>
- <tr>
- <td> </td>
- </tr>
<tr>
<td> </td>
<td>
*/
function checkTouched() {
$fname = 'Article::checkTouched';
- $id = $this->getID();
- $dbr =& $this->getDB();
- $s = $dbr->selectRow( 'page', array( 'page_touched', 'page_is_redirect' ),
- array( 'page_id' => $id ), $fname, $this->getSelectOptions() );
- if( $s !== false ) {
- $this->mTouched = wfTimestamp( TS_MW, $s->page_touched );
- return !$s->page_is_redirect;
- } else {
- return false;
+ if( !$this->mDataLoaded ) {
+ $dbr =& $this->getDB();
+ $data = $this->pageDataFromId( $dbr, $this->getId() );
+ if( $data ) {
+ $this->loadPageData( $data );
+ }
}
+ return !$this->mIsRedirect;
}
/**