Index: trunk/phase3/includes/specials/SpecialAllmessages.php |
— | — | @@ -29,15 +29,19 @@ |
30 | 30 | |
31 | 31 | $wgMessageCache->loadAllMessages(); |
32 | 32 | |
33 | | - $sortedArray = array_merge( Language::getMessagesFor( 'en' ), $wgMessageCache->getExtensionMessagesFor( 'en' ) ); |
| 33 | + $sortedArray = array_merge( Language::getMessagesFor( 'en' ), |
| 34 | + $wgMessageCache->getExtensionMessagesFor( 'en' ) ); |
34 | 35 | ksort( $sortedArray ); |
| 36 | + |
35 | 37 | $messages = array(); |
36 | | - |
37 | | - foreach ( $sortedArray as $key => $value ) { |
| 38 | + foreach( $sortedArray as $key => $value ) { |
38 | 39 | $messages[$key]['enmsg'] = $value; |
39 | | - $messages[$key]['statmsg'] = wfMsgReal( $key, array(), false, false, false ); // wfMsgNoDbNoTrans doesn't exist |
| 40 | + $messages[$key]['statmsg'] = wfMsgReal( $key, array(), false, false, false ); |
40 | 41 | $messages[$key]['msg'] = wfMsgNoTrans( $key ); |
| 42 | + $sortedArray[$key] = NULL; // trade bytes from $sortedArray to this |
| 43 | + |
41 | 44 | } |
| 45 | + unset($sortedArray); // trade bytes from $sortedArray to this |
42 | 46 | |
43 | 47 | wfProfileOut( __METHOD__ . '-setup' ); |
44 | 48 | |
— | — | @@ -63,13 +67,14 @@ |
64 | 68 | wfProfileOut( __METHOD__ ); |
65 | 69 | } |
66 | 70 | |
67 | | -function wfAllMessagesMakeXml( $messages ) { |
| 71 | +function wfAllMessagesMakeXml( &$messages ) { |
68 | 72 | global $wgLang; |
69 | 73 | $lang = $wgLang->getCode(); |
70 | 74 | $txt = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; |
71 | 75 | $txt .= "<messages lang=\"$lang\">\n"; |
72 | 76 | foreach( $messages as $key => $m ) { |
73 | 77 | $txt .= "\t" . Xml::element( 'message', array( 'name' => $key ), $m['msg'] ) . "\n"; |
| 78 | + $messages[$key] = NULL; // trade bytes |
74 | 79 | } |
75 | 80 | $txt .= "</messages>"; |
76 | 81 | return $txt; |
— | — | @@ -81,7 +86,7 @@ |
82 | 87 | * @return The PHP messages array. |
83 | 88 | * @todo Make suitable for language files. |
84 | 89 | */ |
85 | | -function wfAllMessagesMakePhp( $messages ) { |
| 90 | +function wfAllMessagesMakePhp( &$messages ) { |
86 | 91 | global $wgLang; |
87 | 92 | $txt = "\n\n\$messages = array(\n"; |
88 | 93 | foreach( $messages as $key => $m ) { |
— | — | @@ -94,6 +99,7 @@ |
95 | 100 | $comment = ''; |
96 | 101 | } |
97 | 102 | $txt .= "'$key' => '" . preg_replace( '/(?<!\\\\)\'/', "\'", $m['msg']) . "',$comment\n"; |
| 103 | + $messages[$key] = NULL; // trade bytes |
98 | 104 | } |
99 | 105 | $txt .= ');'; |
100 | 106 | return $txt; |
— | — | @@ -104,7 +110,7 @@ |
105 | 111 | * @param $messages Messages array. |
106 | 112 | * @return The HTML list of messages. |
107 | 113 | */ |
108 | | -function wfAllMessagesMakeHTMLText( $messages ) { |
| 114 | +function wfAllMessagesMakeHTMLText( &$messages ) { |
109 | 115 | global $wgLang, $wgContLang, $wgUser; |
110 | 116 | wfProfileIn( __METHOD__ ); |
111 | 117 | |
— | — | @@ -123,7 +129,8 @@ |
124 | 130 | 'onclick' => 'allmessagesmodified()' |
125 | 131 | ), '' ); |
126 | 132 | |
127 | | - $txt = '<span id="allmessagesfilter" style="display: none;">' . wfMsgHtml( 'allmessagesfilter' ) . " {$input}{$checkbox} " . '</span>'; |
| 133 | + $txt = '<span id="allmessagesfilter" style="display: none;">' . wfMsgHtml( 'allmessagesfilter' ) . |
| 134 | + " {$input}{$checkbox} " . '</span>'; |
128 | 135 | |
129 | 136 | $txt .= ' |
130 | 137 | <table border="1" cellspacing="0" width="100%" id="allmessagestable"> |
— | — | @@ -144,11 +151,14 @@ |
145 | 152 | NS_MEDIAWIKI_TALK => array() |
146 | 153 | ); |
147 | 154 | $dbr = wfGetDB( DB_SLAVE ); |
148 | | - $page = $dbr->tableName( 'page' ); |
149 | | - $sql = "SELECT page_namespace,page_title FROM $page WHERE page_namespace IN (" . NS_MEDIAWIKI . ", " . NS_MEDIAWIKI_TALK . ")"; |
150 | | - $res = $dbr->query( $sql ); |
| 155 | + $res = $dbr->select( 'page', |
| 156 | + array( 'page_namespace', 'page_title' ), |
| 157 | + array( 'page_namespace' => array(NS_MEDIAWIKI,NS_MEDIAWIKI_TALK) ), |
| 158 | + __METHOD__, |
| 159 | + array( 'USE INDEX' => 'name_title' ) |
| 160 | + ); |
151 | 161 | while( $s = $dbr->fetchObject( $res ) ) { |
152 | | - $pageExists[$s->page_namespace][$s->page_title] = true; |
| 162 | + $pageExists[$s->page_namespace][$s->page_title] = 1; |
153 | 163 | } |
154 | 164 | $dbr->freeResult( $res ); |
155 | 165 | wfProfileOut( __METHOD__ . "-check" ); |
— | — | @@ -163,19 +173,21 @@ |
164 | 174 | $title .= '/' . $wgLang->getCode(); |
165 | 175 | } |
166 | 176 | |
167 | | - $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title ); |
168 | | - $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); |
| 177 | + $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title ); |
| 178 | + $talkPage = Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); |
169 | 179 | |
170 | 180 | $changed = ( $m['statmsg'] != $m['msg'] ); |
171 | 181 | $message = htmlspecialchars( $m['statmsg'] ); |
172 | 182 | $mw = htmlspecialchars( $m['msg'] ); |
173 | 183 | |
174 | | - if( isset( $pageExists[NS_MEDIAWIKI][$title] ) ) { |
175 | | - $pageLink = $sk->makeKnownLinkObj( $titleObj, "<span id=\"sp-allmessages-i-$i\">" . htmlspecialchars( $key ) . '</span>' ); |
| 184 | + if( array_key_exists( $title, $pageExists[NS_MEDIAWIKI] ) ) { |
| 185 | + $pageLink = $sk->makeKnownLinkObj( $titleObj, "<span id=\"sp-allmessages-i-$i\">" . |
| 186 | + htmlspecialchars( $key ) . '</span>' ); |
176 | 187 | } else { |
177 | | - $pageLink = $sk->makeBrokenLinkObj( $titleObj, "<span id=\"sp-allmessages-i-$i\">" . htmlspecialchars( $key ) . '</span>' ); |
| 188 | + $pageLink = $sk->makeBrokenLinkObj( $titleObj, "<span id=\"sp-allmessages-i-$i\">" . |
| 189 | + htmlspecialchars( $key ) . '</span>' ); |
178 | 190 | } |
179 | | - if( isset( $pageExists[NS_MEDIAWIKI_TALK][$title] ) ) { |
| 191 | + if( array_key_exists( $title, $pageExists[NS_MEDIAWIKI_TALK] ) ) { |
180 | 192 | $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) ); |
181 | 193 | } else { |
182 | 194 | $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) ); |
— | — | @@ -186,27 +198,28 @@ |
187 | 199 | |
188 | 200 | if( $changed ) { |
189 | 201 | $txt .= " |
190 | | - <tr class=\"orig\" id=\"sp-allmessages-r1-$i\"> |
191 | | - <td rowspan=\"2\"> |
192 | | - $anchor$pageLink<br />$talkLink |
193 | | - </td><td> |
194 | | -$message |
195 | | - </td> |
196 | | - </tr><tr class=\"new\" id=\"sp-allmessages-r2-$i\"> |
197 | | - <td> |
198 | | -$mw |
199 | | - </td> |
200 | | - </tr>"; |
| 202 | + <tr class=\"orig\" id=\"sp-allmessages-r1-$i\"> |
| 203 | + <td rowspan=\"2\"> |
| 204 | + $anchor$pageLink<br />$talkLink |
| 205 | + </td><td> |
| 206 | + $message |
| 207 | + </td> |
| 208 | + </tr><tr class=\"new\" id=\"sp-allmessages-r2-$i\"> |
| 209 | + <td> |
| 210 | + $mw |
| 211 | + </td> |
| 212 | + </tr>"; |
201 | 213 | } else { |
202 | 214 | $txt .= " |
203 | | - <tr class=\"def\" id=\"sp-allmessages-r1-$i\"> |
204 | | - <td> |
205 | | - $anchor$pageLink<br />$talkLink |
206 | | - </td><td> |
207 | | -$mw |
208 | | - </td> |
209 | | - </tr>"; |
| 215 | + <tr class=\"def\" id=\"sp-allmessages-r1-$i\"> |
| 216 | + <td> |
| 217 | + $anchor$pageLink<br />$talkLink |
| 218 | + </td><td> |
| 219 | + $mw |
| 220 | + </td> |
| 221 | + </tr>"; |
210 | 222 | } |
| 223 | + $messages[$key] = NULL; // trade bytes |
211 | 224 | $i++; |
212 | 225 | } |
213 | 226 | $txt .= '</table>'; |