* Made the sidebar idiot proof, if a message is specified like
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Mon, 8 Aug 2005 13:26:42 +0000 (13:26 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Mon, 8 Aug 2005 13:26:42 +0000 (13:26 +0000)
* ** This message key|Does not exist use
* then the literals are used if the wfMsg() lookup on them fails

includes/GlobalFunctions.php
includes/Skin.php
skins/MonoBook.php

index a0cee45..d3c07c8 100644 (file)
@@ -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 === "&lt;$msg&gt;";
+}
 ?>
index e0f486b..d70e04b 100644 (file)
@@ -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], ' ', '-'),
                                        );
index b192ee7..ca28f92 100644 (file)
@@ -126,7 +126,7 @@ class MonoBookTemplate extends QuickTemplate {
        <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
        <?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
        <div class='portlet' id='p-<?php echo htmlspecialchars($bar) ?>'>
-         <h5><?php $this->msg( $bar ) ?></h5>
+         <h5><?php $out = wfMsg( $bar ); if (wfNoMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
          <div class='pBody'>
            <ul>
            <?php foreach($cont as $key => $val) { ?>