r97172 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97171‎ | r97172 | r97173 >
Date:16:11, 15 September 2011
Author:dantman
Status:deferred (Comments)
Tags:
Comment:
Start porting HistoryPage to Special:History
Modified paths:
  • /branches/pageoutput/includes/Article.php (modified) (history)
  • /branches/pageoutput/includes/AutoLoader.php (modified) (history)
  • /branches/pageoutput/includes/HistoryPage.php (modified) (history)
  • /branches/pageoutput/includes/SpecialPageFactory.php (modified) (history)
  • /branches/pageoutput/includes/specials/SpecialHistory.php (added) (history)
  • /branches/pageoutput/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: branches/pageoutput/includes/SpecialPageFactory.php
@@ -140,6 +140,7 @@
141141 'Blankpage' => 'SpecialBlankpage',
142142 'Blockme' => 'SpecialBlockme',
143143 'Emailuser' => 'SpecialEmailUser',
 144+ 'History' => 'SpecialHistory',
144145 'Movepage' => 'MovePageForm',
145146 'Mycontributions' => 'SpecialMycontributions',
146147 'Mypage' => 'SpecialMypage',
Index: branches/pageoutput/includes/Article.php
@@ -127,6 +127,14 @@
128128 }
129129
130130 /**
 131+ * Get the WikiPage used here
 132+ * @return WikiPage
 133+ */
 134+ public function getPage() {
 135+ return $this->mPage;
 136+ }
 137+
 138+ /**
131139 * Get the title object of the article
132140 * @return Title object of this page
133141 */
Index: branches/pageoutput/includes/HistoryPage.php
@@ -15,40 +15,34 @@
1616 * history.
1717 *
1818 */
19 -class HistoryPage {
 19+class HistoryPage extends ContextSource {
2020 const DIR_PREV = 0;
2121 const DIR_NEXT = 1;
2222
23 - /** Contains the Article object. Passed on construction. */
24 - private $article;
25 - /** The $article title object. Found on construction. */
26 - private $title;
27 - /** Shortcut to the user Skin object. */
28 - private $skin;
 23+ /** A WikiPage. */
 24+ private $mPage;
2925
3026 /**
3127 * Construct a new HistoryPage.
3228 *
33 - * @param $article Article
 29+ * @param $context RequestContext,Article,PageView
3430 */
35 - function __construct( $article ) {
36 - global $wgUser;
37 - $this->article = $article;
38 - $this->title = $article->getTitle();
39 - $this->skin = $wgUser->getSkin();
 31+ function __construct( $context ) {
 32+ if ( $context instanceof Article || $context instanceof PageView ) {
 33+ $this->mPage = $context->getPage();
 34+ $this->setContext( $context->getContext() );
 35+ } else {
 36+ $this->mPage = WikiPage::factory( $context->getTitle() );
 37+ $this->setContext( $context );
 38+ }
4039 $this->preCacheMessages();
4140 }
4241
43 - /** Get the Article object we are working on. */
 42+ /** For hook compatibility, returns a WikiPage now instead of an Article */
4443 public function getArticle() {
45 - return $this->article;
 44+ return $this->mPage;
4645 }
4746
48 - /** Get the Title object. */
49 - public function getTitle() {
50 - return $this->title;
51 - }
52 -
5347 /**
5448 * As we use the same small set of messages in various methods and that
5549 * they are called often, we call them once and save them in $this->message
@@ -68,52 +62,55 @@
6963 * @return nothing
7064 */
7165 function history() {
72 - global $wgOut, $wgRequest, $wgScript;
 66+ global $wgScript;
7367
 68+ $out = $this->getOutput();
 69+ $request = $this->getRequest();
 70+
7471 /**
7572 * Allow client caching.
7673 */
77 - if ( $wgOut->checkLastModified( $this->article->getTouched() ) )
 74+ if ( $out->checkLastModified( $this->mPage->getTouched() ) )
7875 return; // Client cache fresh and headers sent, nothing more to do.
7976
8077 wfProfileIn( __METHOD__ );
8178
8279 // Setup page variables.
83 - $wgOut->setPageTitle( wfMsg( 'history-title', $this->title->getPrefixedText() ) );
84 - $wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );
85 - $wgOut->setArticleFlag( false );
86 - $wgOut->setArticleRelated( true );
87 - $wgOut->setRobotPolicy( 'noindex,nofollow' );
88 - $wgOut->setSyndicated( true );
89 - $wgOut->setFeedAppendQuery( 'action=history' );
90 - $wgOut->addModules( array( 'mediawiki.legacy.history', 'mediawiki.action.history' ) );
 80+ $out->setPageTitle( wfMsg( 'history-title', $this->getTitle()->getPrefixedText() ) );
 81+ $out->setPageTitleActionText( wfMsg( 'history_short' ) );
 82+ $out->setArticleFlag( false );
 83+ $out->setArticleRelated( true );
 84+ $out->setRobotPolicy( 'noindex,nofollow' );
 85+ $out->setSyndicated( true );
 86+ $out->setFeedAppendQuery( 'action=history' );
 87+ $out->addModules( array( 'mediawiki.legacy.history', 'mediawiki.action.history' ) );
9188
9289 // Creation of a subtitle link pointing to [[Special:Log]]
9390 $logPage = SpecialPage::getTitleFor( 'Log' );
94 - $logLink = $this->skin->link(
 91+ $logLink = Linker::link(
9592 $logPage,
9693 wfMsgHtml( 'viewpagelogs' ),
9794 array(),
98 - array( 'page' => $this->title->getPrefixedText() ),
 95+ array( 'page' => $this->getTitle()->getPrefixedText() ),
9996 array( 'known', 'noclasses' )
10097 );
101 - $wgOut->setSubtitle( $logLink );
 98+ $out->setSubtitle( $logLink );
10299
103100 // Handle atom/RSS feeds.
104 - $feedType = $wgRequest->getVal( 'feed' );
 101+ $feedType = $request->getVal( 'feed' );
105102 if ( $feedType ) {
106103 wfProfileOut( __METHOD__ );
107104 return $this->feed( $feedType );
108105 }
109106
110107 // Fail nicely if article doesn't exist.
111 - if ( !$this->title->exists() ) {
112 - $wgOut->addWikiMsg( 'nohistory' );
 108+ if ( !$this->getTitle()->exists() ) {
 109+ $out->addWikiMsg( 'nohistory' );
113110 # show deletion/move log if there is an entry
114111 LogEventsList::showLogExtract(
115 - $wgOut,
 112+ $out,
116113 array( 'delete', 'move' ),
117 - $this->title->getPrefixedText(),
 114+ $this->getTitle()->getPrefixedText(),
118115 '',
119116 array( 'lim' => 10,
120117 'conds' => array( "log_action != 'revision'" ),
@@ -128,32 +125,32 @@
129126 /**
130127 * Add date selector to quickly get to a certain time
131128 */
132 - $year = $wgRequest->getInt( 'year' );
133 - $month = $wgRequest->getInt( 'month' );
134 - $tagFilter = $wgRequest->getVal( 'tagfilter' );
 129+ $year = $request->getInt( 'year' );
 130+ $month = $request->getInt( 'month' );
 131+ $tagFilter = $request->getVal( 'tagfilter' );
135132 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
136133
137134 /**
138135 * Option to show only revisions that have been (partially) hidden via RevisionDelete
139136 */
140 - if ( $wgRequest->getBool( 'deleted' ) ) {
 137+ if ( $request->getBool( 'deleted' ) ) {
141138 $conds = array( "rev_deleted != '0'" );
142139 } else {
143140 $conds = array();
144141 }
145142 $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ),
146 - 'deleted', 'mw-show-deleted-only', $wgRequest->getBool( 'deleted' ) ) . "\n";
 143+ 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
147144
148145 // Add the general form
149146 $action = htmlspecialchars( $wgScript );
150 - $wgOut->addHTML(
 147+ $out->addHTML(
151148 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
152149 Xml::fieldset(
153150 wfMsg( 'history-fieldset-title' ),
154151 false,
155152 array( 'id' => 'mw-history-search' )
156153 ) .
157 - Html::hidden( 'title', $this->title->getPrefixedDBKey() ) . "\n" .
 154+ Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n" .
158155 Html::hidden( 'action', 'history' ) . "\n" .
159156 Xml::dateMenu( $year, $month ) . '&#160;' .
160157 ( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) .
@@ -162,16 +159,16 @@
163160 '</fieldset></form>'
164161 );
165162
166 - wfRunHooks( 'PageHistoryBeforeList', array( &$this->article ) );
 163+ wfRunHooks( 'PageHistoryBeforeList', array( &$this->mPage ) );
167164
168165 // Create and output the list.
169166 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
170 - $wgOut->addHTML(
 167+ $out->addHTML(
171168 $pager->getNavigationBar() .
172169 $pager->getBody() .
173170 $pager->getNavigationBar()
174171 );
175 - $wgOut->preventClickjacking( $pager->getPreventClickjacking() );
 172+ $out->preventClickjacking( $pager->getPreventClickjacking() );
176173
177174 wfProfileOut( __METHOD__ );
178175 }
@@ -201,7 +198,7 @@
202199 $offsets = array();
203200 }
204201
205 - $page_id = $this->title->getArticleID();
 202+ $page_id = $this->getTitle()->getArticleID();
206203
207204 return $dbr->select( 'revision',
208205 Revision::selectFields(),
@@ -218,21 +215,21 @@
219216 * @param $type String: feed type
220217 */
221218 function feed( $type ) {
222 - global $wgFeedClasses, $wgRequest, $wgFeedLimit;
 219+ global $wgFeedClasses, $wgFeedLimit;
223220 if ( !FeedUtils::checkFeedOutput( $type ) ) {
224221 return;
225222 }
226223
227224 $feed = new $wgFeedClasses[$type](
228 - $this->title->getPrefixedText() . ' - ' .
 225+ $this->getTitle()->getPrefixedText() . ' - ' .
229226 wfMsgForContent( 'history-feed-title' ),
230227 wfMsgForContent( 'history-feed-description' ),
231 - $this->title->getFullUrl( 'action=history' )
 228+ $this->getTitle()->getFullUrl( 'action=history' )
232229 );
233230
234231 // Get a limit on number of feed entries. Provide a sane default
235232 // of 10 if none is defined (but limit to $wgFeedLimit max)
236 - $limit = $wgRequest->getInt( 'limit', 10 );
 233+ $limit = $this->getRequest()->getInt( 'limit', 10 );
237234 if ( $limit > $wgFeedLimit || $limit < 1 ) {
238235 $limit = 10;
239236 }
@@ -251,14 +248,13 @@
252249 }
253250
254251 function feedEmpty() {
255 - global $wgOut;
256252 return new FeedItem(
257253 wfMsgForContent( 'nohistory' ),
258 - $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
259 - $this->title->getFullUrl(),
 254+ $this->getOutput()->parse( wfMsgForContent( 'history-feed-empty' ) ),
 255+ $this->getTitle()->getFullUrl(),
260256 wfTimestamp( TS_MW ),
261257 '',
262 - $this->title->getTalkPage()->getFullUrl()
 258+ $this->getTitle()->getTalkPage()->getFullUrl()
263259 );
264260 }
265261
@@ -272,10 +268,10 @@
273269 */
274270 function feedItem( $row ) {
275271 $rev = new Revision( $row );
276 - $rev->setTitle( $this->title );
 272+ $rev->setTitle( $this->getTitle() );
277273 $text = FeedUtils::formatDiffRow(
278 - $this->title,
279 - $this->title->getPreviousRevisionID( $rev->getId() ),
 274+ $this->getTitle(),
 275+ $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
280276 $rev->getId(),
281277 $rev->getTimestamp(),
282278 $rev->getComment()
@@ -296,10 +292,10 @@
297293 return new FeedItem(
298294 $title,
299295 $text,
300 - $this->title->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
 296+ $this->getTitle()->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
301297 $rev->getTimestamp(),
302298 $rev->getUserText(),
303 - $this->title->getTalkPage()->getFullUrl()
 299+ $this->getTitle()->getTalkPage()->getFullUrl()
304300 );
305301 }
306302 }
@@ -315,20 +311,29 @@
316312 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
317313 parent::__construct();
318314 $this->historyPage = $historyPage;
319 - $this->title = $this->historyPage->getTitle();
320315 $this->tagFilter = $tagFilter;
321316 $this->getDateCond( $year, $month );
322317 $this->conds = $conds;
323318 }
324319
325320 // For hook compatibility...
 321+ // Note that this returns a WikiPage now, some extensions should still work though
326322 function getArticle() {
327323 return $this->historyPage->getArticle();
328324 }
329325
330326 function getTitle() {
331 - return $this->title;
 327+ return $this->historyPage->getTitle();
332328 }
 329+ function getUser() {
 330+ return $this->historyPage->getUser();
 331+ }
 332+ function getLang() {
 333+ return $this->historyPage->getLang();
 334+ }
 335+ function getOutput() {
 336+ return $this->historyPage->getOutput();
 337+ }
333338
334339 function getSqlComment() {
335340 if ( $this->conds ) {
@@ -343,7 +348,7 @@
344349 'tables' => array( 'revision' ),
345350 'fields' => Revision::selectFields(),
346351 'conds' => array_merge(
347 - array( 'rev_page' => $this->title->getArticleID() ),
 352+ array( 'rev_page' => $this->getTitle()->getArticleID() ),
348353 $this->conds ),
349354 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
350355 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
@@ -370,7 +375,7 @@
371376 $firstInList = $this->counter == 1;
372377 $this->counter++;
373378 $s = $this->historyLine( $this->lastRow, $row,
374 - $this->title->getNotificationTimestamp(), $latest, $firstInList );
 379+ $this->getTitle()->getNotificationTimestamp(), $latest, $firstInList );
375380 } else {
376381 $s = '';
377382 }
@@ -384,15 +389,15 @@
385390 * @return string HTML output
386391 */
387392 function getStartBody() {
388 - global $wgScript, $wgUser, $wgOut;
 393+ global $wgScript;
389394 $this->lastRow = false;
390395 $this->counter = 1;
391396 $this->oldIdChecked = 0;
392397
393 - $wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
 398+ $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
394399 $s = Html::openElement( 'form', array( 'action' => $wgScript,
395400 'id' => 'mw-history-compare' ) ) . "\n";
396 - $s .= Html::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n";
 401+ $s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) . "\n";
397402 $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
398403
399404 $s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions' ),
@@ -404,7 +409,7 @@
405410 + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' )
406411 ) . "\n";
407412
408 - if ( $wgUser->isAllowed( 'deleterevision' ) ) {
 413+ if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
409414 $s .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
410415 }
411416 $this->buttons .= '</div>';
@@ -445,7 +450,7 @@
446451 }
447452 $this->counter++;
448453 $s = $this->historyLine( $this->lastRow, $next,
449 - $this->title->getNotificationTimestamp(), $latest, $firstInList );
 454+ $this->getTitle()->getNotificationTimestamp(), $latest, $firstInList );
450455 } else {
451456 $s = '';
452457 }
@@ -489,9 +494,8 @@
490495 function historyLine( $row, $next, $notificationtimestamp = false,
491496 $latest = false, $firstInList = false )
492497 {
493 - global $wgUser, $wgLang;
494498 $rev = new Revision( $row );
495 - $rev->setTitle( $this->title );
 499+ $rev->setTitle( $this->getTitle() );
496500
497501 $curlink = $this->curLink( $rev, $latest );
498502 $lastlink = $this->lastLink( $rev, $next );
@@ -508,7 +512,7 @@
509513
510514 $del = '';
511515 // Show checkboxes for each revision
512 - if ( $wgUser->isAllowed( 'deleterevision' ) ) {
 516+ if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
513517 $this->preventClickjacking();
514518 // If revision was hidden from sysops, disable the checkbox
515519 if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
@@ -519,15 +523,15 @@
520524 array( 'name' => 'ids[' . $rev->getId() . ']' ) );
521525 }
522526 // User can only view deleted revisions...
523 - } elseif ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) {
 527+ } elseif ( $rev->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) {
524528 // If revision was hidden from sysops, disable the link
525529 if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
526 - $cdel = $this->getSkin()->revDeleteLinkDisabled( false );
 530+ $cdel = Linker::revDeleteLinkDisabled( false );
527531 // Otherwise, show the link...
528532 } else {
529533 $query = array( 'type' => 'revision',
530 - 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() );
531 - $del .= $this->getSkin()->revDeleteLink( $query,
 534+ 'target' => $this->getTitle()->getPrefixedDbkey(), 'ids' => $rev->getId() );
 535+ $del .= Linker::revDeleteLink( $query,
532536 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
533537 }
534538 }
@@ -535,12 +539,12 @@
536540 $s .= " $del ";
537541 }
538542
539 - $dirmark = $wgLang->getDirMark();
 543+ $dirmark = $this->getLang()->getDirMark();
540544
541545 $s .= " $link";
542546 $s .= $dirmark;
543547 $s .= " <span class='history-user'>" .
544 - $this->getSkin()->revUserTools( $rev, true ) . "</span>";
 548+ Linker::revUserTools( $rev, true ) . "</span>";
545549 $s .= $dirmark;
546550
547551 if ( $rev->isMinor() ) {
@@ -548,10 +552,10 @@
549553 }
550554
551555 if ( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
552 - $s .= ' ' . $this->getSkin()->formatRevisionSize( $size );
 556+ $s .= ' ' . Linker::formatRevisionSize( $size );
553557 }
554558
555 - $s .= $this->getSkin()->revComment( $rev, false, true );
 559+ $s .= Linker::revComment( $rev, false, true );
556560
557561 if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) {
558562 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
@@ -561,13 +565,13 @@
562566
563567 # Rollback and undo links
564568 if ( !is_null( $next ) && is_object( $next ) ) {
565 - if ( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) {
 569+ if ( $latest && $this->getTitle()->userCan( 'rollback' ) && $this->getTitle()->userCan( 'edit' ) ) {
566570 $this->preventClickjacking();
567571 $tools[] = '<span class="mw-rollback-link">' .
568 - $this->getSkin()->buildRollbackLink( $rev ) . '</span>';
 572+ Linker::buildRollbackLink( $rev ) . '</span>';
569573 }
570574
571 - if ( $this->title->quickUserCan( 'edit' )
 575+ if ( $this->getTitle()->quickUserCan( 'edit' )
572576 && !$rev->isDeleted( Revision::DELETED_TEXT )
573577 && !$next->rev_deleted & Revision::DELETED_TEXT )
574578 {
@@ -575,8 +579,8 @@
576580 $undoTooltip = $latest
577581 ? array( 'title' => wfMsg( 'tooltip-undo' ) )
578582 : array();
579 - $undolink = $this->getSkin()->link(
580 - $this->title,
 583+ $undolink = Linker::link(
 584+ $this->getTitle(),
581585 wfMsgHtml( 'editundo' ),
582586 $undoTooltip,
583587 array(
@@ -591,7 +595,7 @@
592596 }
593597
594598 if ( $tools ) {
595 - $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
 599+ $s .= ' (' . $this->getLang()->pipeList( $tools ) . ')';
596600 }
597601
598602 # Tags
@@ -616,12 +620,11 @@
617621 * @return String
618622 */
619623 function revLink( $rev ) {
620 - global $wgLang;
621 - $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $rev->getTimestamp() ), true );
 624+ $date = $this->getLang()->timeanddate( wfTimestamp( TS_MW, $rev->getTimestamp() ), true );
622625 $date = htmlspecialchars( $date );
623626 if ( $rev->userCan( Revision::DELETED_TEXT ) ) {
624 - $link = $this->getSkin()->link(
625 - $this->title,
 627+ $link = Linker::link(
 628+ $this->getTitle(),
626629 $date,
627630 array(),
628631 array( 'oldid' => $rev->getId() ),
@@ -648,12 +651,12 @@
649652 if ( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
650653 return $cur;
651654 } else {
652 - return $this->getSkin()->link(
653 - $this->title,
 655+ return Linker::link(
 656+ $this->getTitle(),
654657 $cur,
655658 array(),
656659 array(
657 - 'diff' => $this->title->getLatestRevID(),
 660+ 'diff' => $this->getTitle()->getLatestRevID(),
658661 'oldid' => $rev->getId()
659662 ),
660663 array( 'known', 'noclasses' )
@@ -677,8 +680,8 @@
678681 return $last;
679682 } elseif ( $next === 'unknown' ) {
680683 # Next row probably exists but is unknown, use an oldid=prev link
681 - return $this->getSkin()->link(
682 - $this->title,
 684+ return Linker::link(
 685+ $this->getTitle(),
683686 $last,
684687 array(),
685688 array(
@@ -692,8 +695,8 @@
693696 {
694697 return $last;
695698 } else {
696 - return $this->getSkin()->link(
697 - $this->title,
 699+ return Linker::link(
 700+ $this->getTitle(),
698701 $last,
699702 array(),
700703 array(
Index: branches/pageoutput/includes/AutoLoader.php
@@ -773,6 +773,7 @@
774774 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php',
775775 'SpecialGlobalFileUsage' => 'includes/specials/SpecialGlobalFileUsage.php',
776776 'SpecialGlobalTemplateUsage' => 'includes/specials/SpecialGlobalTemplateUsage.php',
 777+ 'SpecialHistory' => 'includes/specials/SpecialHistory.php',
777778 'SpecialImport' => 'includes/specials/SpecialImport.php',
778779 'SpecialListFiles' => 'includes/specials/SpecialListfiles.php',
779780 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
Index: branches/pageoutput/includes/specials/SpecialHistory.php
@@ -0,0 +1,51 @@
 2+<?php
 3+/**
 4+ * Implements Special:History
 5+ *
 6+ * This program is free software; you can redistribute it and/or modify
 7+ * it under the terms of the GNU General Public License as published by
 8+ * the Free Software Foundation; either version 2 of the License, or
 9+ * (at your option) any later version.
 10+ *
 11+ * This program is distributed in the hope that it will be useful,
 12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14+ * GNU General Public License for more details.
 15+ *
 16+ * You should have received a copy of the GNU General Public License along
 17+ * with this program; if not, write to the Free Software Foundation, Inc.,
 18+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 19+ * http://www.gnu.org/copyleft/gpl.html
 20+ *
 21+ * @file
 22+ * @ingroup SpecialPage
 23+ */
 24+
 25+/**
 26+ * Implements Special:History
 27+ *
 28+ * @ingroup SpecialPage
 29+ */
 30+class SpecialHistory extends UnlistedSpecialPage { // XXX: Should this be listed or unlisted?
 31+
 32+ function __construct() {
 33+ parent::__construct( 'History' );
 34+ }
 35+
 36+ function execute( $par ) {
 37+ $title = Title::newFromText( $par );
 38+ if ( $title ) {
 39+ // @fixme Instead of this create a method to create a RequestContext based on another
 40+ $context = new RequestContext;
 41+ $context->setTitle( $title );
 42+ $context->setUser( $this->getUser() );
 43+ $context->setRequest( new FauxRequest( array() ) );
 44+ $context->setOutput( $this->getOutput() );
 45+ $history = new HistoryPage( $context );
 46+ $history->history();
 47+ }
 48+
 49+
 50+ }
 51+
 52+}
Property changes on: branches/pageoutput/includes/specials/SpecialHistory.php
___________________________________________________________________
Added: svn:eol-style
153 + native
Index: branches/pageoutput/languages/messages/MessagesEn.php
@@ -390,6 +390,7 @@
391391 'Fewestrevisions' => array( 'FewestRevisions' ),
392392 'FileDuplicateSearch' => array( 'FileDuplicateSearch' ),
393393 'Filepath' => array( 'FilePath' ),
 394+ 'History' => array( 'History' ),
394395 'Import' => array( 'Import' ),
395396 'Invalidateemail' => array( 'InvalidateEmail' ),
396397 'BlockList' => array( 'BlockList', 'ListBlocks', 'IPBlockList' ),

Comments

#Comment by Dantman (talk | contribs)   16:19, 15 September 2011
  • Committed early because I implemented DerivativeContext inside trunk and want to use it here (that @fixme)
  • The most notable hook user of history seams to be FlaggedRevs, however they use getArticle treating Article as a Page just so they can getTitle, so returning a WikiPage should remain compatible
  • I'm aware that the form outputted outputs for ?title=#####&action=history. Rather than tweaking that to Special:History I want to add a new interface that will let those forms be created abstractly. That way we can dynamically switch between the different form output types depending on if we're a normal Special page, or one that should output an action.

Status & tagging log