r10409 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10408‎ | r10409 | r10410 >
Date:13:27, 8 August 2005
Author:avar
Status:old
Tags:
Comment:
* 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
Modified paths:
  • /branches/REL1_5/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_5/phase3/includes/Skin.php (modified) (history)
  • /branches/REL1_5/phase3/skins/MonoBook.php (modified) (history)

Diff [purge]

Index: branches/REL1_5/phase3/skins/MonoBook.php
@@ -126,7 +126,7 @@
127127 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
128128 <?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
129129 <div class='portlet' id='p-<?php echo htmlspecialchars($bar) ?>'>
130 - <h5><?php $this->msg( $bar ) ?></h5>
 130+ <h5><?php $out = wfMsg( $bar ); if (wfNoMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
131131 <div class='pBody'>
132132 <ul>
133133 <?php foreach($cont as $key => $val) { ?>
Index: branches/REL1_5/phase3/includes/GlobalFunctions.php
@@ -1347,4 +1347,16 @@
13481348 }
13491349 }
13501350
 1351+/**
 1352+ * Since wfMsg() and co suck, they don't return false if the message key they
 1353+ * looked up didn't exist but a XHTML string, this function checks for the
 1354+ * nonexistance of messages by looking at wfMsg() output
 1355+ *
 1356+ * @param $msg The message key looked up
 1357+ * @param $wfMsgOut The output of wfMsg*()
 1358+ * @return bool
 1359+ */
 1360+function wfNoMsg( $msg, $wfMsgOut ) {
 1361+ return $wfMsgOut === "&lt;$msg&gt;";
 1362+}
13511363 ?>
Index: branches/REL1_5/phase3/includes/Skin.php
@@ -1316,8 +1316,12 @@
13171317 $link = wfMsgForContent( $line[0] );
13181318 if ($link == '-')
13191319 continue;
 1320+ if (wfNoMsg($line[1], $text = wfMsg($line[1])))
 1321+ $text = $line[1];
 1322+ if (wfNoMsg($line[0], $link))
 1323+ $link = $line[0];
13201324 $bar[$heading][] = array(
1321 - 'text' => wfMsg( $line[1] ),
 1325+ 'text' => $text,
13221326 'href' => $this->makeInternalOrExternalUrl( $link ),
13231327 'id' => 'n-' . strtr($line[1], ' ', '-'),
13241328 );

Status & tagging log