From: Ævar Arnfjörð Bjarmason Date: Mon, 8 Aug 2005 13:26:42 +0000 (+0000) Subject: * Made the sidebar idiot proof, if a message is specified like X-Git-Tag: 1.6.0~2047 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=1651479b90b467d966d518258979534b576ee35d;p=lhc%2Fweb%2Fwiklou.git * Made the sidebar idiot proof, if a message is specified like * ** This message key|Does not exist use * then the literals are used if the wfMsg() lookup on them fails --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a0cee454e9..d3c07c88e0 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1358,4 +1358,16 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { } } +/** + * Since wfMsg() and co suck, they don't return false if the message key they + * looked up didn't exist but a XHTML string, this function checks for the + * nonexistance of messages by looking at wfMsg() output + * + * @param $msg The message key looked up + * @param $wfMsgOut The output of wfMsg*() + * @return bool + */ +function wfNoMsg( $msg, $wfMsgOut ) { + return $wfMsgOut === "<$msg>"; +} ?> diff --git a/includes/Skin.php b/includes/Skin.php index e0f486b0f2..d70e04b5d6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1321,8 +1321,12 @@ END; $link = wfMsgForContent( $line[0] ); if ($link == '-') continue; + if (wfNoMsg($line[1], $text = wfMsg($line[1]))) + $text = $line[1]; + if (wfNoMsg($line[0], $link)) + $link = $line[0]; $bar[$heading][] = array( - 'text' => wfMsg( $line[1] ), + 'text' => $text, 'href' => $this->makeInternalOrExternalUrl( $link ), 'id' => 'n-' . strtr($line[1], ' ', '-'), ); diff --git a/skins/MonoBook.php b/skins/MonoBook.php index b192ee7dab..ca28f92c8d 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -126,7 +126,7 @@ class MonoBookTemplate extends QuickTemplate { data['sidebar'] as $bar => $cont) { ?>
-
msg( $bar ) ?>
+
    $val) { ?>