X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=4ede20f3ec6965b245b2de62089ef0990dc5d608;hb=c0d6b5adf924e9dbc90a8d8dcdb1f9178166c883;hp=82891fc7bc565b1909559a958e984cb6d2b5b7f6;hpb=5c033c37c5c22482ca90b63957d7ec969c166325;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Article.php b/includes/Article.php index 82891fc7bc..4ede20f3ec 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -37,6 +37,7 @@ class Article { var $mRevIdFetched; var $mRevision; var $mRedirectUrl; + var $mLatest; /**#@-*/ /** @@ -91,7 +92,7 @@ class Article { } else { return $rt->getFullURL(); } - } + } return $rt; } } @@ -125,6 +126,7 @@ class Article { $this->mIsRedirect = false; $this->mRevIdFetched = 0; $this->mRedirectUrl = false; + $this->mLatest = false; } /** @@ -173,43 +175,29 @@ class Article { return "
$ret
"; } else { $this->loadContent(); - # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page - if ( $this->mTitle->getNamespace() == NS_USER_TALK && - $wgUser->isIP($this->mTitle->getText()) && - $action=='view' - ) { - wfProfileOut( $fname ); - return $this->mContent . "\n" .wfMsg('anontalkpagetext'); - } else { - if($action=='edit') { - if($section!='') { - if($section=='new') { - wfProfileOut( $fname ); - $text=$this->getPreloadedText($preload); - return $text; - } - - # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML - # comments to be stripped as well) - $rv=$this->getSection($this->mContent,$section); + if($action=='edit') { + if($section!='') { + if($section=='new') { wfProfileOut( $fname ); - return $rv; + $text=$this->getPreloadedText($preload); + return $text; } + + # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML + # comments to be stripped as well) + $rv=$this->getSection($this->mContent,$section); + wfProfileOut( $fname ); + return $rv; } - wfProfileOut( $fname ); - return $this->mContent; } + wfProfileOut( $fname ); + return $this->mContent; } } /** * Get the contents of a page from its title and remove includeonly tags * - * TODO FIXME: This is only here because of the inputbox extension and - * should be moved there - * - * @deprecated - * * @param string The title of the page * @return string The contents of the page */ @@ -351,8 +339,6 @@ class Article { * Load the revision (including text) into this object */ function loadContent() { - global $wgOut, $wgRequest; - if ( $this->mContentLoaded ) return; # Query variables :P @@ -423,15 +409,30 @@ class Article { * @param object $data * @access private */ - function loadPageData( $data ) { - $this->mTitle->mArticleID = $data->page_id; - $this->mTitle->loadRestrictions( $data->page_restrictions ); - $this->mTitle->mRestrictionsLoaded = true; + function loadPageData( $data = 'fromdb' ) { + if ( $data === 'fromdb' ) { + $dbr =& $this->getDB(); + $data = $this->pageDataFromId( $dbr, $this->getId() ); + } + + $lc =& LinkCache::singleton(); + if ( $data ) { + $lc->addGoodLinkObj( $data->page_id, $this->mTitle ); - $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->mTitle->mArticleID = $data->page_id; + $this->mTitle->loadRestrictions( $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; + } else { + if ( is_object( $this->mTitle ) ) { + $lc->addBadLinkObj( $this->mTitle ); + } + $this->mTitle->mArticleID = 0; + } $this->mDataLoaded = true; } @@ -482,12 +483,15 @@ class Article { } $revision = Revision::newFromId( $this->mLatest ); if( is_null( $revision ) ) { - wfDebug( "$fname failed to retrieve current page, rev_id $data->page_latest\n" ); + wfDebug( "$fname failed to retrieve current page, rev_id {$data->page_latest}\n" ); return false; } } - $this->mContent = $revision->getText(); + // FIXME: Horrible, horrible! This content-loading interface just plain sucks. + // We should instead work with the Revision object when we need it... + $this->mContent = $revision->userCan( MW_REV_DELETED_TEXT ) ? $revision->getRawText() : ""; + //$this->mContent = $revision->getText(); $this->mUser = $revision->getUser(); $this->mUserText = $revision->getUserText(); @@ -564,9 +568,13 @@ class Article { function getCount() { if ( -1 == $this->mCounter ) { $id = $this->getID(); - $dbr =& wfGetDB( DB_SLAVE ); - $this->mCounter = $dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ), - 'Article::getCount', $this->getSelectOptions() ); + if ( $id == 0 ) { + $this->mCounter = 0; + } else { + $dbr =& wfGetDB( DB_SLAVE ); + $this->mCounter = $dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ), + 'Article::getCount', $this->getSelectOptions() ); + } } return $this->mCounter; } @@ -621,8 +629,6 @@ class Article { * @access private */ function loadLastEdit() { - global $wgOut; - if ( -1 != $this->mUser ) return; @@ -642,7 +648,10 @@ class Article { } function getTimestamp() { - $this->loadLastEdit(); + // Check if the field has been filled by ParserCache::get() + if ( !$this->mTimestamp ) { + $this->loadLastEdit(); + } return wfTimestamp(TS_MW, $this->mTimestamp); } @@ -711,7 +720,7 @@ class Article { * the given title. */ function view() { - global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgContLang; + global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; global $wgUseTrackbacks; $sk = $wgUser->getSkin(); @@ -754,7 +763,7 @@ class Article { wfProfileOut( $fname ); return; } - + if ( empty( $oldid ) && $this->checkTouched() ) { $wgOut->setETag($parserCache->getETag($this, $wgUser)); @@ -816,8 +825,10 @@ class Article { $t = $this->mTitle->getPrefixedText(); if( $oldid ) { $t .= ',oldid='.$oldid; + $text = wfMsg( 'missingarticle', $t ); + } else { + $text = wfMsg( 'noarticletext', $t ); } - $text = wfMsg( 'missingarticle', $t ); } # Another whitelist check in case oldid is altering the title @@ -830,8 +841,23 @@ class Article { # We're looking at an old revision if ( !empty( $oldid ) ) { - $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); - $wgOut->setRobotpolicy( 'noindex,follow' ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); + if( is_null( $this->mRevision ) ) { + // FIXME: This would be a nice place to load the 'no such page' text. + } else { + $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); + if( $this->mRevision->isDeleted( MW_REV_DELETED_TEXT ) ) { + if( !$this->mRevision->userCan( MW_REV_DELETED_TEXT ) ) { + $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) ); + $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); + return; + } else { + $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) ); + // and we are allowed to see... + } + } + } + } } if( !$outputDone ) { @@ -888,15 +914,16 @@ class Article { if( empty( $t ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); } + + # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page + if( $this->mTitle->getNamespace() == NS_USER_TALK && + User::isIP( $this->mTitle->getText() ) ) { + $wgOut->addWikiText( wfMsg('anontalkpagetext') ); + } # 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() - && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) - { + if ( $wgUseRCPatrol && !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) { $wgOut->addHTML( "