Show pretty localized log names in Recentchanges instead of Special:Log/upload etc

This commit is contained in:
Brion Vibber 2004-08-25 02:13:32 +00:00
parent c2836e08e1
commit b025ad54c6
3 changed files with 52 additions and 16 deletions

View file

@ -66,6 +66,39 @@ class LogPage {
return true;
}
/* static */ function &validTypes() {
static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload' );
return $types;
}
/* static */ function isLogType( $type ) {
return in_array( $type, LogPage::validTypes() );
}
/* static */ function logName( $type ) {
static $typeText = array(
'' => 'log',
'block' => 'blocklogpage',
'protect' => 'protectlogpage',
'rights' => 'bureaucratlog',
'delete' => 'dellogpage',
'upload' => 'uploadlogpage',
);
return str_replace( '_', ' ', wfMsg( $typeText[$type] ) );
}
/* static */ function logHeader( $type ) {
static $headerText = array(
'' => 'alllogstext',
'block' => 'blocklogtext',
'protect' => 'protectlogtext',
'rights' => '',
'delete' => 'dellogpagetext',
'upload' => 'uploadlogpagetext'
);
return wfMsg( $headerText[$type] );
}
/* static */ function actionText( $type, $action, $titleLink ) {
static $actions = array(
'block/block' => 'blocklogentry',

View file

@ -2334,6 +2334,11 @@ class Skin {
$msg = ( $rc_type == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
$s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
$this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
} elseif( $rc_namespace == NS_SPECIAL && preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
# Log updates, etc
$logtype = $matches[1];
$logname = LogPage::logName( $logtype );
$s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
} else {
# Diff link
if ( $rc_type == RC_NEW || $rc_type == RC_LOG ) {
@ -2445,6 +2450,11 @@ class Skin {
$msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
$clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
$this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
} elseif( $rc_namespace == NS_SPECIAL && preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
# Log updates, etc
$logtype = $matches[1];
$logname = LogPage::logName( $logtype );
$clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
} else {
$clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
}
@ -2537,7 +2547,10 @@ class Skin {
direct link to the section in the autocomment.
Main author: Erik Moeller (moeller@scireview.de)
*/
function formatComment($comment, &$title)
# Note: there's not always a title to pass to this function.
# Since you can't set a default parameter for a reference, I've turned it
# temporarily to a value pass. Should be adjusted further. --brion
function formatComment($comment, $title = NULL)
{
global $wgLang;
$comment = htmlspecialchars( $comment );

View file

@ -141,15 +141,6 @@ class LogReader {
class LogViewer {
var $reader, $skin;
var $typeText = array(
'' => array( 'log', 'alllogstext' ),
'block' => array( 'blocklogpage', 'blocklogtext' ),
'protect' => array( 'protectlogpage', 'protectlogtext' ),
'rights' => array( 'bureaucratlog', '' ),
'delete' => array( 'dellogpage', 'dellogpagetext' ),
'upload' => array( 'uploadlogpage', 'uploadlogpagetext' )
);
function LogViewer( &$reader ) {
global $wgUser;
@ -202,10 +193,9 @@ class LogViewer {
function showHeader( &$out ) {
$type = $this->reader->queryType();
if( isset( $this->typeText[$type] ) ) {
list( $title, $headertext ) = $this->typeText[$type];
$out->setPageTitle( str_replace( '_', ' ', wfMsg( $title ) ) );
$out->addWikiText( wfMsg( $headertext ) );
if( LogPage::isLogType( $type ) ) {
$out->setPageTitle( LogPage::logName( $type ) );
$out->addWikiText( LogPage::logHeader( $type ) );
}
}
@ -225,8 +215,8 @@ class LogViewer {
function getTypeMenu() {
$out = "<select name='type'>\n";
foreach( $this->typeText as $type => $msg ) {
$text = htmlspecialchars( str_replace( '_', ' ', wfMsg( $msg[0] ) ) );
foreach( LogPage::validTypes() as $type ) {
$text = htmlspecialchars( LogPage::logName( $type ) );
$selected = ($type == $this->reader->queryType()) ? ' selected="selected"' : '';
$out .= "<option value=\"$type\"$selected>$text</option>\n";
}