var $mId, $mTable;
var $mForUpdate;
var $mOldId;
+ var $mRevIdFetched;
/**#@-*/
/**
$this->mTouched = '19700101000000';
$this->mForUpdate = false;
$this->mIsRedirect = false;
+ $this->mRevIdFetched = 0;
}
/**
$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';
if ( !is_null( $diff ) ) {
require_once( 'DifferenceEngine.php' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+
$de = new DifferenceEngine( $oldid, $diff, $rcid );
+ // DifferenceEngine directly fetched the revision:
+ $this->mRevIdFetched = $de->mNewid;
$de->showDiffPage();
+
if( $diff == 0 ) {
# Run view updates for current revision only
$this->viewUpdates();
$wgOut->addWikiText( $text );
}
}
- $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ /* title may have been set from the cache */
+ $t = $wgOut->getPageTitle();
+ if( empty( $t ) ) {
+ $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->isLoggedIn() &&
* 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;
$ttl = $this->mTitle->getDBkey();
$text = $this->preSaveTransform( $text );
$isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
+ $now = wfTimestampNow();
$dbw =& wfGetDB( DB_MASTER );
$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();
$text = $this->preSaveTransform( $text );
$dbw =& wfGetDB( DB_MASTER );
+ $now = wfTimestampNow();
# Update article, but only if changed.
# It's important that we either rollback or complete, otherwise an attacker could
# overwrite cur entries by sending precisely timed user aborts. Random bored users
# could conceivably have the same effect, especially if cur is locked for long periods.
- if( $wgDBtransactions ) {
- $dbw->query( 'BEGIN', $fname );
- } else {
+ if( !$wgDBtransactions ) {
$userAbort = ignore_user_abort( true );
}
$oldtext = $this->getContent( true );
+ $lastRevision = 0;
if ( 0 != strcmp( $text, $oldtext ) ) {
$this->mCountAdjustment = $this->isCountable( $text )
} else {
# Update recentchanges and purge cache and whatnot
$bot = (int)($wgUser->isBot() || $forceBot);
- RecentChange::notifyEdit( $now, $this->mTitle, $me2, $wgUser, $summary,
+ RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
$lastRevision, $this->getTimestamp(), $bot );
Article::onArticleEdit( $this->mTitle );
}
}
- if( $wgDBtransactions ) {
- $dbw->query( 'COMMIT', $fname );
- } else {
+ if( !$wgDBtransactions ) {
ignore_user_abort( $userAbort );
}
array_push( $wgPostCommitUpdateList, $u );
}
- $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $me2, $now, $summary, $lastRevision );
+ $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
}
return $good;
}
include_once ( "SpecialValidate.php" ) ; # The "Validation" class
$v = new Validation ;
- $t = $v->validatePageForm ( $this , $revision ) ;
-/* $a = $v->getTopicList () ;
- $t = "" ;
- foreach ( $a AS $x => $y ) {
- $t .= $x . " : " . $y->val_comment . " (1-" . $y->val_value . ")<br>" ;
- }
- $t .= "Revision {$revision}" ;*/
+ 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>
return array( 'edits' => $edits, 'authors' => $authors );
}
+
+ /**
+ * Return a list of templates used by this article.
+ * Uses the links table to find the templates
+ *
+ * @return array
+ */
+ function getUsedTemplates() {
+ $result = array();
+ $id = $this->mTitle->getArticleID();
+
+ $db =& wfGetDB( DB_SLAVE );
+ $page = $db->tableName( 'page' );
+ $links = $db->tableName( 'links' );
+ $sql = "SELECT page_title ".
+ "FROM $page,$links WHERE l_to=page_id AND l_from={$id} and page_namespace=".NS_TEMPLATE;
+ $res = $db->query( $sql, "Article:getUsedTemplates" );
+ if ( false !== $res ) {
+ if ( $db->numRows( $res ) ) {
+ while ( $row = $db->fetchObject( $res ) ) {
+ $result[] = $row->page_title;
+ }
+ }
+ }
+ $db->freeResult( $res );
+ return $result;
+ }
+
+
}