*Add ImagePageFileHistoryLine hook
*Tweak hook doc order *Mark flagged file versions in hist *Remove $dbr field *Tweak file histories to be more compact
This commit is contained in:
parent
cd4adc78a3
commit
4bb299cbce
2 changed files with 38 additions and 41 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
. '<tr><td></td>'
|
||||
. ( $this->img->isLocal() && $deleteColumn ? '<td></td>' : '' )
|
||||
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
|
||||
. '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
|
||||
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
|
||||
. '<th class="mw-imagepage-filesize">' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
|
||||
. '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
|
||||
. "</tr>\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 .= '<td>';
|
||||
# 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 .= '<td>' . $this->skin->makeKnownLinkObj(
|
||||
$this->title,
|
||||
wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
|
||||
implode( '&', $q )
|
||||
);
|
||||
$row .= '<br/>';
|
||||
$row .= '</td>';
|
||||
}
|
||||
# Link to hide content
|
||||
if( $wgUser->isAllowed( 'deleterevision' ) ) {
|
||||
|
|
@ -802,9 +792,8 @@ class ImageHistoryList {
|
|||
if( $file->isDeleted(File::DELETED_RESTRICTED) )
|
||||
$del = "<strong>$del</strong>";
|
||||
}
|
||||
$row .= "<tt><small>$del</small></tt>";
|
||||
$row .= "<td style='white-space: nowrap;'><tt><small>$del</small></tt></td>";
|
||||
}
|
||||
$row .= '</td>';
|
||||
}
|
||||
|
||||
// Reversion link/current indicator
|
||||
|
|
@ -827,7 +816,7 @@ class ImageHistoryList {
|
|||
$row .= '</td>';
|
||||
|
||||
// Date/time and image link
|
||||
$row .= '<td>';
|
||||
$row .= "<td style='white-space: nowrap;'>";
|
||||
if( !$file->userCan(File::DELETED_FILE) ) {
|
||||
# Don't link to unviewable files
|
||||
$row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
|
||||
|
|
@ -839,15 +828,19 @@ class ImageHistoryList {
|
|||
$row .= '<span class="history-deleted">'.$url.'</span>';
|
||||
} 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 .= '</td>';
|
||||
$row .= "</td><td>";
|
||||
|
||||
// Image dimensions
|
||||
$row .= ' ' . htmlspecialchars( $dims );
|
||||
|
||||
// File size
|
||||
$row .= " <span style='white-space: nowrap;'>(" . $this->skin->formatSize( $size ) . ')</span>';
|
||||
|
||||
// Uploading user
|
||||
$row .= '<td>';
|
||||
$row .= '</td><td>';
|
||||
if( $local ) {
|
||||
// Hide deleted usernames
|
||||
if( $file->isDeleted(File::DELETED_USER) )
|
||||
|
|
@ -858,20 +851,18 @@ class ImageHistoryList {
|
|||
} else {
|
||||
$row .= htmlspecialchars( $usertext );
|
||||
}
|
||||
$row .= '</td>';
|
||||
|
||||
// Image dimensions
|
||||
$row .= '<td>' . htmlspecialchars( $dims ) . '</td>';
|
||||
|
||||
// File size
|
||||
$row .= '<td class="mw-imagepage-filesize">' . $this->skin->formatSize( $size ) . '</td>';
|
||||
|
||||
// Don't show deleted descriptions
|
||||
if ( $file->isDeleted(File::DELETED_COMMENT) )
|
||||
$row .= '<td><span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span></td>';
|
||||
else
|
||||
$row .= '<td>' . $this->skin->commentBlock( $description, $this->title ) . '</td>';
|
||||
if ( $file->isDeleted(File::DELETED_COMMENT) ) {
|
||||
$row .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
|
||||
} else {
|
||||
$row .= ' ' . $this->skin->commentBlock( $description, $this->title );
|
||||
}
|
||||
$row .= '</td>';
|
||||
|
||||
return "<tr>{$row}</tr>\n";
|
||||
wfRunHooks( 'ImagePageFileHistoryLine', array( &$file, &$row, &$css ) );
|
||||
$tagCSS = $css ? " class='$css'" : "";
|
||||
|
||||
return "<tr{$tagCSS}>{$row}</tr>\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue