r32726 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32725‎ | r32726 | r32727 >
Date:20:20, 2 April 2008
Author:aaron
Status:old
Tags:
Comment:
Add showLogExtract() and remove use of FauxRequest hacks
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/includes/SpecialMergeHistory.php (modified) (history)
  • /trunk/phase3/includes/SpecialMovepage.php (modified) (history)
  • /trunk/phase3/includes/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/includes/SpecialUndelete.php (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/SpecialUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUserrights.php
@@ -540,17 +540,7 @@
541541 * @param OutputPage $output OutputPage to use
542542 */
543543 protected function showLogFragment( $user, $output ) {
544 - $viewer = new LogViewer(
545 - new LogReader(
546 - new FauxRequest(
547 - array(
548 - 'type' => 'rights',
549 - 'page' => $user->getUserPage()->getPrefixedText(),
550 - )
551 - )
552 - )
553 - );
554544 $output->addHtml( Xml::element( 'h2', null, LogPage::logName( 'rights' ) . "\n" ) );
555 - $viewer->showList( $output );
 545+ LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage()->getPrefixedText() );
556546 }
557547 }
Index: trunk/phase3/includes/ProtectionForm.php
@@ -374,12 +374,7 @@
375375 function showLogExtract( &$out ) {
376376 # Show relevant lines from the protection log:
377377 $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'protect' ) ) );
378 - $logViewer = new LogViewer(
379 - new LogReader(
380 - new FauxRequest(
381 - array( 'page' => $this->mTitle->getPrefixedText(),
382 - 'type' => 'protect' ) ) ) );
383 - $logViewer->showList( $out );
 378+ LogEventsList::showLogExtract( $out, 'protect', $this->mTitle->getPrefixedText() );
384379 }
385380
386381 }
Index: trunk/phase3/includes/Article.php
@@ -2156,12 +2156,7 @@
21572157 */
21582158 function showLogExtract( $out ) {
21592159 $out->addHtml( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
2160 - $logViewer = new LogViewer(
2161 - new LogReader(
2162 - new FauxRequest(
2163 - array( 'page' => $this->mTitle->getPrefixedText(),
2164 - 'type' => 'delete' ) ) ) );
2165 - $logViewer->showList( $out );
 2160+ LogEventsList::showLogExtract( $out, 'delete', $this->mTitle->getPrefixedText() );
21662161 }
21672162
21682163
Index: trunk/phase3/includes/SpecialRevisiondelete.php
@@ -45,17 +45,10 @@
4646 # does not exist...might be helpful
4747 if( !is_null($page) ) {
4848 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
49 - $logViewer = new LogViewer(
50 - new LogReader(
51 - new FauxRequest(
52 - array( 'page' => $page->getPrefixedText(), 'type' => 'delete' ) ) ) );
53 - $logViewer->showList( $wgOut );
 49+ LogEventsList::showLogExtract( $wgOut, 'delete', $page->getPrefixedText() );
5450 if( $wgUser->isAllowed( 'suppress' ) ){
5551 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
56 - $logViewer = new LogViewer(
57 - new LogReader(
58 - new FauxRequest(
59 - array( 'page' => $page->getPrefixedText(), 'type' => 'suppress' ) ) ) );
 52+ LogEventsList::showLogExtract( $wgOut, 'suppress', $page->getPrefixedText() );
6053 $logViewer->showList( $wgOut );
6154 }
6255 }
Index: trunk/phase3/includes/EditPage.php
@@ -2205,20 +2205,17 @@
22062206 * @param OutputPage $out
22072207 */
22082208 private function showDeletionLog( $out ) {
2209 - $title = $this->mTitle;
2210 - $reader = new LogReader(
2211 - new FauxRequest(
2212 - array(
2213 - 'page' => $title->getPrefixedText(),
2214 - 'type' => 'delete',
2215 - )
2216 - )
2217 - );
2218 - if( $reader->hasRows() ) {
 2209+ global $wgUser;
 2210+ $loglist = new LogEventsList( $wgUser->getSkin() );
 2211+ $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
 2212+ if( $pager->getNumRows() > 0 ) {
22192213 $out->addHtml( '<div id="mw-recreate-deleted-warn">' );
22202214 $out->addWikiMsg( 'recreate-deleted-warn' );
2221 - $viewer = new LogViewer( $reader );
2222 - $viewer->showList( $out );
 2215+ $out->addHTML(
 2216+ $loglist->beginLogEventsList() .
 2217+ $pager->getBody() .
 2218+ $loglist->endLogEventsList()
 2219+ );
22232220 $out->addHtml( '</div>' );
22242221 }
22252222 }
Index: trunk/phase3/includes/SpecialBlockip.php
@@ -400,9 +400,7 @@
401401
402402 function showLogFragment( $out, $title ) {
403403 $out->addHtml( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) );
404 - $request = new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'block' ) );
405 - $viewer = new LogViewer( new LogReader( $request ) );
406 - $viewer->showList( $out );
 404+ LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText() );
407405 }
408406
409407 /**
Index: trunk/phase3/includes/SpecialUpload.php
@@ -1662,19 +1662,17 @@
16631663 * @param string filename
16641664 */
16651665 private function showDeletionLog( $out, $filename ) {
1666 - $reader = new LogReader(
1667 - new FauxRequest(
1668 - array(
1669 - 'page' => $filename,
1670 - 'type' => 'delete',
1671 - )
1672 - )
1673 - );
1674 - if( $reader->hasRows() ) {
 1666+ global $wgUser;
 1667+ $loglist = new LogEventsList( $wgUser->getSkin() );
 1668+ $pager = new LogPager( $loglist, 'delete', false, $filename );
 1669+ if( $pager->getNumRows() > 0 ) {
16751670 $out->addHtml( '<div id="mw-upload-deleted-warn">' );
16761671 $out->addWikiMsg( 'upload-wasdeleted' );
1677 - $viewer = new LogViewer( $reader );
1678 - $viewer->showList( $out );
 1672+ $out->addHTML(
 1673+ $loglist->beginLogEventsList() .
 1674+ $pager->getBody() .
 1675+ $loglist->endLogEventsList()
 1676+ );
16791677 $out->addHtml( '</div>' );
16801678 }
16811679 }
Index: trunk/phase3/includes/LogEventsList.php
@@ -318,6 +318,29 @@
319319 }
320320
321321 /**
 322+ * Quick function to show a short log extract
 323+ * @param OutputPage $out
 324+ * @param string $type
 325+ * @param string $page
 326+ */
 327+ public static function showLogExtract( $out, $type='', $page='', $user='' ) {
 328+ global $wgUser;
 329+ # Insert list of top 50 or so items
 330+ $loglist = new LogEventsList( $wgUser->getSkin() );
 331+ $pager = new LogPager( $loglist, $type, $user, $page, '' );
 332+ $logBody = $pager->getBody();
 333+ if( $logBody ) {
 334+ $out->addHTML(
 335+ $loglist->beginLogEventsList() .
 336+ $logBody .
 337+ $loglist->endLogEventsList()
 338+ );
 339+ } else {
 340+ $out->addWikiMsg( 'logempty' );
 341+ }
 342+ }
 343+
 344+ /**
322345 * SQL clause to skip forbidden log types for this user
323346 * @param Database $db
324347 * @returns mixed (string or false)
@@ -355,7 +378,7 @@
356379 * @param string $pattern
357380 * @param array $conds
358381 */
359 - function __construct( $loglist, $type, $user, $title, $pattern, $conds = array() ) {
 382+ function __construct( $loglist, $type='', $user='', $title='', $pattern='', $conds = array() ) {
360383 parent::__construct();
361384 $this->mConds = $conds;
362385
Index: trunk/phase3/includes/SpecialMovepage.php
@@ -345,9 +345,7 @@
346346
347347 function showLogFragment( $title, &$out ) {
348348 $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'move' ) ) );
349 - $request = new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'move' ) );
350 - $viewer = new LogViewer( new LogReader( $request ) );
351 - $viewer->showList( $out );
 349+ LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() );
352350 }
353351
354352 }
Index: trunk/phase3/includes/SpecialUndelete.php
@@ -956,17 +956,7 @@
957957
958958 # Show relevant lines from the deletion log:
959959 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) . "\n" );
960 - $logViewer = new LogViewer(
961 - new LogReader(
962 - new FauxRequest(
963 - array(
964 - 'page' => $this->mTargetObj->getPrefixedText(),
965 - 'type' => 'delete'
966 - )
967 - )
968 - ), LogViewer::NO_ACTION_LINK
969 - );
970 - $logViewer->showList( $wgOut );
 960+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTargetObj->getPrefixedText() );
971961
972962 if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
973963 # Format the user-visible controls (comment field, submission button)
Index: trunk/phase3/includes/FileDeleteForm.php
@@ -179,17 +179,7 @@
180180 private function showLogEntries() {
181181 global $wgOut;
182182 $wgOut->addHtml( '<h2>' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
183 - $reader = new LogViewer(
184 - new LogReader(
185 - new FauxRequest(
186 - array(
187 - 'type' => 'delete',
188 - 'page' => $this->title->getPrefixedText(),
189 - )
190 - )
191 - )
192 - );
193 - $reader->showList( $wgOut );
 183+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->title->getPrefixedText() );
194184 }
195185
196186 /**
Index: trunk/phase3/includes/SpecialMergeHistory.php
@@ -205,14 +205,8 @@
206206
207207 # Show relevant lines from the deletion log:
208208 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'merge' ) ) . "</h2>\n" );
209 - $logViewer = new LogViewer(
210 - new LogReader(
211 - new FauxRequest(
212 - array( 'page' => $this->mTargetObj->getPrefixedText(),
213 - 'type' => 'merge' ) ) ) );
214 - $logViewer->showList( $wgOut );
 209+ LogEventsList::showLogExtract( $wgOut, 'merge', $this->mTargetObj->getPrefixedText() );
215210
216 - # Slip in the hidden controls here
217211 # When we submit, go by page ID to avoid some nasty but unlikely collisions.
218212 # Such would happen if a page was renamed after the form loaded, but before submit
219213 $misc = Xml::hidden( 'targetID', $this->mTargetObj->getArticleID() );

Status & tagging log