From 4bb299cbce4cc0dffe3f9cda30e12c4cad3b2279 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 17 May 2008 00:08:31 +0000 Subject: [PATCH] *Add ImagePageFileHistoryLine hook *Tweak hook doc order *Mark flagged file versions in hist *Remove $dbr field *Tweak file histories to be more compact --- docs/hooks.txt | 16 +++++++---- includes/ImagePage.php | 63 ++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index b0720bcd7e..6d4d621d12 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -652,11 +652,6 @@ $result: User permissions error to add. If none, return true. 'getUserPermissionsErrorsExpensive': Absolutely the same, but is called only if expensive checks are enabled. -'ImageOpenShowImageInlineBefore': Call potential extension just before showing - the image on an image page -$imagePage: ImagePage object ($this) -$output: $wgOut - 'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki image insertion. You can skip the default logic entirely by returning false, or just modify a few things using call-by-reference. @@ -670,6 +665,17 @@ $output: $wgOut &$time: Timestamp of file in 'YYYYMMDDHHIISS' string form, or false for current &$res: Final HTML output, used if you return false + +'ImageOpenShowImageInlineBefore': Call potential extension just before showing + the image on an image page +$imagePage: ImagePage object ($this) +$output: $wgOut + +'ImagePageFileHistoryLine': called when a file history line is contructed +$file: the file +$line: the HTML of the history line +$css: the line CSS class + 'InitPreferencesForm': called at the end of PreferencesForm's constructor $form: the PreferencesForm $request: the web request to initialized from diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 8dfcff5dec..705cf2243b 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -564,8 +564,8 @@ EOT $list = new ImageHistoryList( $sk, $this->current ); $file = $this->current; $dims = $file->getDimensionsString(); - $s = $list->beginImageHistoryList() . - $list->imageHistoryLine( true, $file ); + $s = $list->beginImageHistoryList(); + $s .= $list->imageHistoryLine( true, $file ); // old image versions $hist = $this->img->getHistory(); foreach( $hist as $file ) { @@ -737,18 +737,9 @@ class ImageHistoryList { public function beginImageHistoryList() { global $wgOut, $wgUser; - $deleteColumn = $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deleterevision' ); return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) ) . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) ) - . Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n" - . '' - . ( $this->img->isLocal() && $deleteColumn ? '' : '' ) - . '' . wfMsgHtml( 'filehist-datetime' ) . '' - . '' . wfMsgHtml( 'filehist-user' ) . '' - . '' . wfMsgHtml( 'filehist-dimensions' ) . '' - . '' . wfMsgHtml( 'filehist-filesize' ) . '' - . '' . wfMsgHtml( 'filehist-comment' ) . '' - . "\n"; + . Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"; } public function endImageHistoryList() { @@ -768,23 +759,22 @@ class ImageHistoryList { $sha1 = $file->getSha1(); $local = $this->img->isLocal(); - $row = ''; + $row = $css = ''; // Deletion link if( $local && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deleterevision') ) ) { - $row .= ''; # Link to remove from history if( $wgUser->isAllowed( 'delete' ) ) { $q = array(); $q[] = 'action=delete'; if( !$iscur ) $q[] = 'oldimage=' . urlencode( $img ); - $row .= $this->skin->makeKnownLinkObj( + $row .= '' . $this->skin->makeKnownLinkObj( $this->title, wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ), implode( '&', $q ) ); - $row .= '
'; + $row .= ''; } # Link to hide content if( $wgUser->isAllowed( 'deleterevision' ) ) { @@ -802,9 +792,8 @@ class ImageHistoryList { if( $file->isDeleted(File::DELETED_RESTRICTED) ) $del = "$del"; } - $row .= "$del"; + $row .= "$del"; } - $row .= ''; } // Reversion link/current indicator @@ -827,7 +816,7 @@ class ImageHistoryList { $row .= ''; // Date/time and image link - $row .= ''; + $row .= ""; if( !$file->userCan(File::DELETED_FILE) ) { # Don't link to unviewable files $row .= '' . $wgLang->timeAndDate( $timestamp, true ) . ''; @@ -839,15 +828,19 @@ class ImageHistoryList { $row .= ''.$url.''; } else { $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img ); - $row .= Xml::element( 'a', - array( 'href' => $url ), - $wgLang->timeAndDate( $timestamp, true ) ); + $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) ); } - $row .= ''; + $row .= ""; + + // Image dimensions + $row .= ' ' . htmlspecialchars( $dims ); + + // File size + $row .= " (" . $this->skin->formatSize( $size ) . ')'; // Uploading user - $row .= ''; + $row .= ''; if( $local ) { // Hide deleted usernames if( $file->isDeleted(File::DELETED_USER) ) @@ -858,20 +851,18 @@ class ImageHistoryList { } else { $row .= htmlspecialchars( $usertext ); } - $row .= ''; - - // Image dimensions - $row .= '' . htmlspecialchars( $dims ) . ''; - - // File size - $row .= '' . $this->skin->formatSize( $size ) . ''; // Don't show deleted descriptions - if ( $file->isDeleted(File::DELETED_COMMENT) ) - $row .= '' . wfMsgHtml('rev-deleted-comment') . ''; - else - $row .= '' . $this->skin->commentBlock( $description, $this->title ) . ''; + if ( $file->isDeleted(File::DELETED_COMMENT) ) { + $row .= ' ' . wfMsgHtml('rev-deleted-comment') . ''; + } else { + $row .= ' ' . $this->skin->commentBlock( $description, $this->title ); + } + $row .= ''; - return "{$row}\n"; + wfRunHooks( 'ImagePageFileHistoryLine', array( &$file, &$row, &$css ) ); + $tagCSS = $css ? " class='$css'" : ""; + + return "{$row}\n"; } } -- 2.20.1