- /**
- * Theoretically we could defer these whole insert and update
- * functions for after display, but that's taking a big leap
- * of faith, and we want to be able to report database
- * errors at some point.
- * @access private
- */
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) {
- global $wgOut, $wgUser, $wgUseSquid;
-
- $fname = 'Article::insertNewArticle';
- wfProfileIn( $fname );
-
- if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text,
- &$summary, &$isminor, &$watchthis, NULL ) ) ) {
- wfDebug( "$fname: ArticleSave hook aborted save!\n" );
- wfProfileOut( $fname );
- return false;
- }
-
- $this->mGoodAdjustment = (int)$this->isCountable( $text );
- $this->mTotalAdjustment = 1;
-
- $ns = $this->mTitle->getNamespace();
- $ttl = $this->mTitle->getDBkey();
-
- # If this is a comment, add the summary as headline
- if($comment && $summary!="") {
- $text="== {$summary} ==\n\n".$text;
- }
- $text = $this->preSaveTransform( $text );
-
- /* Silently ignore minoredit if not allowed */
- $isminor = $isminor && $wgUser->isAllowed('minoredit');
- $now = wfTimestampNow();
-
- $dbw =& wfGetDB( DB_MASTER );
-
- # Add the page record; stake our claim on this title!
- $newid = $this->insertOn( $dbw );
-
- # Save the revision text...
- $revision = new Revision( array(
- 'page' => $newid,
- 'comment' => $summary,
- 'minor_edit' => $isminor,
- 'text' => $text
- ) );
- $revisionId = $revision->insertOn( $dbw );
-
- $this->mTitle->resetArticleID( $newid );
-
- # Update the page record with revision data
- $this->updateRevisionOn( $dbw, $revision, 0 );
-
- Article::onArticleCreate( $this->mTitle );
- if(!$suppressRC) {
- require_once( 'RecentChange.php' );
- RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default',
- '', strlen( $text ), $revisionId );
- }
-
- if ($watchthis) {
- if(!$this->mTitle->userIsWatching()) $this->watch();
- } else {
- if ( $this->mTitle->userIsWatching() ) {
- $this->unwatch();
- }
- }
-
- # The talk page isn't in the regular link tables, so we need to update manually:
- $talkns = $ns ^ 1; # talk -> normal; normal -> talk
- $dbw->update( 'page',
- array( 'page_touched' => $dbw->timestamp($now) ),
- array( 'page_namespace' => $talkns,
- 'page_title' => $ttl ),
- $fname );
-
- # standard deferred updates
- $this->editUpdates( $text, $summary, $isminor, $now, $revisionId );
-
- $oldid = 0; # new article
- $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
-
- wfRunHooks( 'ArticleInsertComplete', array( &$this, &$wgUser, $text,
- $summary, $isminor,
- $watchthis, NULL ) );
- wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text,
- $summary, $isminor,
- $watchthis, NULL ) );
- wfProfileOut( $fname );
- }
-
- function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
- $this->replaceSection( $section, $text, $summary, $edittime );
- }
-