X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=1f30e8797f5b1f2a6d0347b267f15204a82e5570;hb=7a605cce46eb688dfb697487a1b1d300bef4361c;hp=d373093973512f3623a933438eec93d7ff3a30b0;hpb=156176548d9fcfa667419bdce0e57171ec4591e6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Article.php b/includes/Article.php index d373093973..1f30e8797f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -727,6 +727,11 @@ class Article { global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; global $wgDefaultRobotPolicy; + # Let the parser know if this is the printable version + if( $wgOut->isPrintable() ) { + $wgOut->parserOptions()->setIsPrintable( true ); + } + wfProfileIn( __METHOD__ ); # Get variables from query string @@ -737,7 +742,7 @@ class Article { global $wgUseETag; if( $wgUseETag ) { $parserCache = ParserCache::singleton(); - $wgOut->setETag( $parserCache->getETag($this,$wgUser) ); + $wgOut->setETag( $parserCache->getETag($this, $wgOut->parserOptions()) ); } # Is is client cached? if( $wgOut->checkLastModified( $this->getTouched() ) ) { @@ -787,10 +792,10 @@ class Article { # Allow admins to see deleted content if explicitly requested $delId = $diff ? $diff : $oldid; - $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $delId ); + $unhide = $wgRequest->getInt('unhide') == 1 + && $wgUser->matchEditToken( $wgRequest->getVal('token'), $delId ); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. - if( !is_null( $diff ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); @@ -860,9 +865,17 @@ class Article { } } + # Allow a specific header on talk pages, like [[MediaWiki:Talkpagetext]] + if( $this->mTitle->isTalkPage() ) { + $msg = wfMsgNoTrans( 'talkpageheader' ); + if ( $msg !== '-' && !wfEmptyMsg( 'talkpageheader', $msg ) ) { + $wgOut->wrapWikiMsg( "
\n$1
", array( 'talkpageheader' ) ); + } + } + $outputDone = false; wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$pcache ) ); - if( $pcache && $wgOut->tryParserCache( $this, $wgUser ) ) { + if( $pcache && $wgOut->tryParserCache( $this ) ) { // Ensure that UI elements requiring revision ID have // the correct version information. $wgOut->setRevisionId( $this->mLatest ); @@ -870,9 +883,9 @@ class Article { } # Fetch content and check for errors if( !$outputDone ) { - # If the article does not exist and was deleted, show the log + # If the article does not exist and was deleted/moved, show the log if( $this->getID() == 0 ) { - $this->showDeletionLog(); + $this->showLogs(); } $text = $this->getContent(); // For now, check also for ID until getContent actually returns @@ -924,22 +937,35 @@ class Article { 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 ); + $this->setOldSubtitle( $oldid ); # Allow admins to see deleted content if explicitly requested if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { - if( !$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT) ) { - $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-permission' ); + // If the user is not allowed to see it... + if( !$this->mRevision->userCan(Revision::DELETED_TEXT) ) { + $wgOut->wrapWikiMsg( "\n", + 'rev-deleted-text-permission' ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); wfProfileOut( __METHOD__ ); return; + // If the user needs to confirm that they want to see it... + } else if( !$unhide ) { + # Give explanation and add a link to view the revision... + $link = $this->mTitle->getFullUrl( "oldid={$oldid}". + '&unhide=1&token='.urlencode( $wgUser->editToken($oldid) ) ); + $wgOut->wrapWikiMsg( "\n", + array('rev-deleted-text-unhide',$link) ); + $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); + wfProfileOut( __METHOD__ ); + return; + // We are allowed to see... } else { - $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-view' ); - // and we are allowed to see... + $wgOut->wrapWikiMsg( "\n", + 'rev-deleted-text-view' ); } } // Is this the current revision and otherwise cacheable? Try the parser cache... if( $oldid === $this->getLatest() && $this->useParserCache( false ) - && $wgOut->tryParserCache( $this, $wgUser ) ) + && $wgOut->tryParserCache( $this ) ) { $outputDone = true; } @@ -1036,14 +1062,14 @@ class Article { wfProfileOut( __METHOD__ ); } - protected function showDeletionLog() { + protected function showLogs() { global $wgUser, $wgOut; $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut ); - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() ); + $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() ); if( $pager->getNumRows() > 0 ) { $pager->mLimit = 10; $wgOut->addHTML( '
' ); - $wgOut->addWikiMsg( 'deleted-notice' ); + $wgOut->addWikiMsg( 'moveddeleted-notice' ); $wgOut->addHTML( $loglist->beginLogEventsList() . $pager->getBody() . @@ -1052,9 +1078,9 @@ class Article { if( $pager->getNumRows() > 10 ) { $wgOut->addHTML( $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Log' ), - wfMsgHtml( 'deletelog-fulllog' ), + wfMsgHtml( 'log-fulllog' ), array(), - array( 'type' => 'delete', 'page' => $this->mTitle->getPrefixedText() ) + array( 'page' => $this->mTitle->getPrefixedText() ) ) ); } $wgOut->addHTML( '
' ); @@ -1113,7 +1139,7 @@ class Article { . $sk->makeLinkObj( $rt, htmlspecialchars( $rt->getFullText() ) ); } } - return '#REDIRECT' . + return '#REDIRECT ' . ''.$link.''; } @@ -1148,7 +1174,7 @@ class Article { } public function deletetrackback() { - global $wgUser, $wgRequest, $wgOut, $wgTitle; + global $wgUser, $wgRequest, $wgOut; if( !$wgUser->matchEditToken($wgRequest->getVal('token')) ) { $wgOut->addWikiMsg( 'sessionfailure' ); return; @@ -1654,7 +1680,6 @@ class Article { $dbw->rollback(); } else { global $wgUseRCPatrol; - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user) ); # Update recentchanges if( !( $flags & EDIT_SUPPRESS_RC ) ) { # Mark as patrolled if the user can do so @@ -1669,6 +1694,8 @@ class Article { PatrolLog::record( $rc, true ); } } + # Notify extensions of a new edit + wfRunHooks( 'NewRevisionFromEditComplete', array(&$this, $revision, $baseRevId, $user) ); $user->incEditCount(); $dbw->commit(); } @@ -1735,7 +1762,6 @@ class Article { # Update the page record with revision data $this->updateRevisionOn( $dbw, $revision, 0 ); - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $user) ); # Update recentchanges if( !( $flags & EDIT_SUPPRESS_RC ) ) { global $wgUseRCPatrol, $wgUseNPPatrol; @@ -1749,6 +1775,8 @@ class Article { PatrolLog::record( $rc, true ); } } + # Notify extensions of a new page edit + wfRunHooks( 'NewRevisionFromEditComplete', array(&$this, $revision, false, $user) ); $user->incEditCount(); $dbw->commit(); @@ -1771,7 +1799,7 @@ class Article { $status->value['revision'] = $revision; wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status ) ); + $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) ); wfProfileOut( __METHOD__ ); return $status; @@ -2159,18 +2187,16 @@ class Article { // Find out if there was only one contributor // Only scan the last 20 revisions - $limit = 20; $res = $dbw->select( 'revision', 'rev_user_text', - array( 'rev_page' => $this->getID() ), __METHOD__, - array( 'LIMIT' => $limit ) + array( 'rev_page' => $this->getID(), 'rev_deleted & '.Revision::DELETED_USER.'=0' ), + __METHOD__, + array( 'LIMIT' => 20 ) ); if( $res === false ) // This page has no revisions, which is very weird return false; - if( $res->numRows() > 1 ) - $hasHistory = true; - else - $hasHistory = false; + + $hasHistory = ( $res->numRows() > 1 ); $row = $dbw->fetchObject( $res ); $onlyAuthor = $row->rev_user_text; // Try to find a second contributor @@ -2387,10 +2413,10 @@ class Article { if( $wgUser->isAllowed( 'suppressrevision' ) ) { $suppress = " - " . + " . Xml::checkLabel( wfMsg( 'revdelete-suppress' ), 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) . - " + " "; } else { $suppress = ''; @@ -2916,8 +2942,11 @@ class Article { # Save it to the parser cache if( $wgEnableParserCache ) { + $popts = new ParserOptions; + $popts->setTidy( true ); + $popts->enableLimitReport(); $parserCache = ParserCache::singleton(); - $parserCache->save( $editInfo->output, $this, $wgUser ); + $parserCache->save( $editInfo->output, $this, $popts ); } # Update the links tables @@ -3310,6 +3339,8 @@ class Article { $user = User::newFromName( $title->getText(), false ); $user->setNewtalk( false ); } + # Image redirects + RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title ); } /** @@ -3408,7 +3439,7 @@ class Article { * @param $title Title object * @return array */ - protected function pageCountInfo( $title ) { + public function pageCountInfo( $title ) { $id = $title->getArticleId(); if( $id == 0 ) { return false; @@ -3538,7 +3569,7 @@ class Article { * @param $cache Boolean */ public function outputWikiText( $text, $cache = true ) { - global $wgParser, $wgUser, $wgOut, $wgEnableParserCache, $wgUseFileCache; + global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache; $popts = $wgOut->parserOptions(); $popts->setTidy(true); @@ -3549,7 +3580,7 @@ class Article { $popts->enableLimitReport( false ); if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) { $parserCache = ParserCache::singleton(); - $parserCache->save( $parserOutput, $this, $wgUser ); + $parserCache->save( $parserOutput, $this, $popts ); } // Make sure file cache is not used on uncacheable content. // Output that has magic words in it can still use the parser cache