X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPageHistory.php;h=b1cf41f0de08cfca59b99cd58509b965bde54e39;hb=eaaf62fbdc21c1b43440e18f3874f31bd7ab12d8;hp=9b5ded009c0e26fcc911ad4c32ff8a27c5d82084;hpb=c12ded86607c0b0f3159284175bae29bf36b1b7e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 9b5ded009c..b1cf41f0de 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -3,14 +3,8 @@ * Page history * * Split off from Article.php and Skin.php, 2003-12-22 - * @package MediaWiki */ -include_once ( "SpecialValidate.php" ); - -define("DIR_PREV", 0); -define("DIR_NEXT", 1); - /** * This class handles printing the history page for an article. In order to * be efficient, it uses timestamps rather than offsets for paging, to avoid @@ -19,14 +13,16 @@ define("DIR_NEXT", 1); * Construct it by passing in an Article, and call $h->history() to print the * history. * - * @package MediaWiki */ - class PageHistory { + const DIR_PREV = 0; + const DIR_NEXT = 1; + var $mArticle, $mTitle, $mSkin; var $lastdate; var $linesonpage; var $mNotificationTimestamp; + var $mLatestId = null; /** * Construct a new PageHistory. @@ -34,7 +30,7 @@ class PageHistory { * @param Article $article * @returns nothing */ - function PageHistory($article) { + function __construct($article) { global $wgUser; $this->mArticle =& $article; @@ -49,8 +45,7 @@ class PageHistory { * @returns nothing */ function history() { - global $wgUser, $wgOut, $wgLang, $wgShowUpdatedMarker, $wgRequest, - $wgTitle, $wgUseValidation; + global $wgOut, $wgRequest, $wgTitle; /* * Allow client caching. @@ -67,132 +62,95 @@ class PageHistory { * Setup page variables. */ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); - $wgOut->setSubtitle( wfMsg( 'revhistory' ) ); $wgOut->setArticleFlag( false ); $wgOut->setArticleRelated( true ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); + $wgOut->setSyndicated( true ); - /* - * Fail if article doesn't exist. - */ - $id = $this->mTitle->getArticleID(); - if( $id == 0 ) { - $wgOut->addWikiText( 'nohistory' ); - wfProfileOut( $fname ); - return; - } + $logPage = SpecialPage::getTitleFor( 'Log' ); + $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() ); - /* - * Extract limit, the number of revisions to show, and - * offset, the timestamp to begin at, from the URL. - */ - $limit = $wgRequest->getInt('limit', 50); - $offset = $wgRequest->getText('offset'); - - /* Offset must be an integral. */ - if (!strlen($offset) || !preg_match("/^[0-9]+$/", $offset)) - $offset = 0; - - /* - * "go=last" means to jump to the last history page. - */ - if (($gowhere = $wgRequest->getText("go")) !== NULL) { - switch ($gowhere) { - case "first": - if (($lastid = $this->getLastOffsetForPaging($id, $limit)) === NULL) - break; - $gourl = $wgTitle->getLocalURL("action=history&limit={$limit}&offset={$lastid}"); - break; - default: - $gourl = NULL; - } + $subtitle = wfMsgHtml( 'revhistory' ) . '
' . $logLink; + $wgOut->setSubtitle( $subtitle ); - if (!is_null($gourl)) { - $wgOut->redirect($gourl); - return; - } + $feedType = $wgRequest->getVal( 'feed' ); + if( $feedType ) { + wfProfileOut( $fname ); + return $this->feed( $feedType ); } /* - * Fetch revisions. - * - * If the user clicked "previous", we retrieve the revisions backwards, - * then reverse them. This is to avoid needing to know the timestamp of - * previous revisions when generating the URL. - */ - $direction = $this->getDirection(); - $revisions = $this->fetchRevisions($limit, $offset, $direction); - $navbar = $this->makeNavbar($revisions, $offset, $limit, $direction); - - /* - * We fetch one more revision than needed to get the timestamp of the - * one after this page (and to know if it exists). - * - * linesonpage stores the actual number of lines. - */ - if (count($revisions) < $limit + 1) - $this->linesonpage = count($revisions); - else - $this->linesonpage = count($revisions) - 1; - - /* Un-reverse revisions */ - if ($direction == DIR_PREV) - $revisions = array_reverse($revisions); - - /* - * Print the top navbar. + * Fail if article doesn't exist. */ - $s = $navbar; - $s .= $this->beginHistoryList(); - $counter = 1; + if( !$this->mTitle->exists() ) { + $wgOut->addWikiText( wfMsg( 'nohistory' ) ); + wfProfileOut( $fname ); + return; + } + /* - * Print each revision, excluding the one-past-the-end, if any. + * "go=first" means to jump to the last (earliest) history page. + * This is deprecated, it no longer appears in the user interface */ - foreach (array_slice($revisions, 0, $limit) as $i => $line) { - $first = !$i && $offset == 0; - $next = isset( $revisions[$i + 1] ) ? $revisions[$i + 1 ] : null; - $s .= $this->historyLine($line, $next, $counter, $this->getNotificationTimestamp(), $first); - $counter++; + if ( $wgRequest->getText("go") == 'first' ) { + $limit = $wgRequest->getInt( 'limit', 50 ); + $wgOut->redirect( $wgTitle->getLocalURL( "action=history&limit={$limit}&dir=prev" ) ); + return; } + + wfRunHooks( 'PageHistoryBeforeList', array( &$this->mArticle ) ); - /* - * End navbar. - */ - $s .= $this->endHistoryList(); - $s .= $navbar; - - /* - * Article validation line. + /** + * Do the list */ - if ($wgUseValidation) - $s .= "

" . Validation::link2statistics ( $this->mArticle ) . "

" ; - - $wgOut->addHTML( $s ); + $pager = new PageHistoryPager( $this ); + $this->linesonpage = $pager->getNumRows(); + $wgOut->addHTML( + $pager->getNavigationBar() . + $this->beginHistoryList() . + $pager->getBody() . + $this->endHistoryList() . + $pager->getNavigationBar() + ); wfProfileOut( $fname ); } + /** @todo document */ function beginHistoryList() { global $wgTitle; $this->lastdate = ''; - $s = '

' . wfMsg( 'histlegend' ) . '

'; + $s = wfMsgExt( 'histlegend', array( 'parse') ); $s .= '
'; $prefixedkey = htmlspecialchars($wgTitle->getPrefixedDbKey()); + + // The following line is SUPPOSED to have double-quotes around the + // $prefixedkey variable, because htmlspecialchars() doesn't escape + // single-quotes. + // + // On at least two occasions people have changed it to single-quotes, + // which creates invalid HTML and incorrect display of the resulting + // link. + // + // Please do not break this a third time. Thank you for your kind + // consideration and cooperation. + // $s .= "\n"; + $s .= $this->submitButton(); - $s .= '