From: Brion Vibber Date: Wed, 25 Aug 2004 02:13:32 +0000 (+0000) Subject: Show pretty localized log names in Recentchanges instead of Special:Log/upload etc X-Git-Tag: 1.5.0alpha1~2233 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=b025ad54;p=lhc%2Fweb%2Fwiklou.git Show pretty localized log names in Recentchanges instead of Special:Log/upload etc --- diff --git a/includes/LogPage.php b/includes/LogPage.php index 52603564d3..d09d4350f1 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -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', diff --git a/includes/Skin.php b/includes/Skin.php index 79355cbd37..5c1ca0354e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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 ); diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index f2fda400ac..66677dc237 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -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 = "