Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -206,7 +206,8 @@ |
207 | 207 | {{NAMESPACE}} relative to correct title. |
208 | 208 | * (bug 30485 and bug 33434) Style rules for wikitable are now more specific and |
209 | 209 | prevent inheritance to nested tables which caused various issues |
210 | | - |
| 210 | +* (bug 32686) Tooltip on links to non-existing pages are now always in user's |
| 211 | + language |
211 | 212 | |
212 | 213 | === API changes in 1.19 === |
213 | 214 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |
Index: trunk/phase3/includes/parser/LinkHolderArray.php |
— | — | @@ -363,7 +363,8 @@ |
364 | 364 | if ( $colours[$pdbk] == 'new' ) { |
365 | 365 | $linkCache->addBadLinkObj( $title ); |
366 | 366 | $output->addLink( $title, 0 ); |
367 | | - $type = array( 'broken' ); |
| 367 | + $type = array( 'broken', |
| 368 | + 'language' => $this->parent->getOptions()->getUserLangObj() ); |
368 | 369 | } else { |
369 | 370 | if ( $colours[$pdbk] != '' ) { |
370 | 371 | $attribs['class'] = $colours[$pdbk]; |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -154,15 +154,20 @@ |
155 | 155 | * @param $query array The query string to append to the URL |
156 | 156 | * you're linking to, in key => value array form. Query keys and values |
157 | 157 | * will be URL-encoded. |
158 | | - * @param $options string|array String or array of strings: |
159 | | - * 'known': Page is known to exist, so don't check if it does. |
160 | | - * 'broken': Page is known not to exist, so don't check if it does. |
161 | | - * 'noclasses': Don't add any classes automatically (includes "new", |
| 158 | + * @param $options string|array String or array: |
| 159 | + * - Either with numerical index and following values: |
| 160 | + * - 'known': Page is known to exist, so don't check if it does. |
| 161 | + * - 'broken': Page is known not to exist, so don't check if it does. |
| 162 | + * - 'noclasses': Don't add any classes automatically (includes "new", |
162 | 163 | * "stub", "mw-redirect", "extiw"). Only use the class attribute |
163 | 164 | * provided, if any, so you get a simple blue link with no funny i- |
164 | 165 | * cons. |
165 | | - * 'forcearticlepath': Use the article path always, even with a querystring. |
| 166 | + * - 'forcearticlepath': Use the article path always, even with a querystring. |
166 | 167 | * Has compatibility issues on some setups, so avoid wherever possible. |
| 168 | + * - Or with following indexes: |
| 169 | + * - 'language': the value of that index is the language to use; currently |
| 170 | + * only used for the tooltip when linking to a page that doesn't exist |
| 171 | + * (since 1.19) |
167 | 172 | * @return string HTML <a> attribute |
168 | 173 | */ |
169 | 174 | public static function link( |
— | — | @@ -189,7 +194,7 @@ |
190 | 195 | |
191 | 196 | # If we don't know whether the page exists, let's find out. |
192 | 197 | wfProfileIn( __METHOD__ . '-checkPageExistence' ); |
193 | | - if ( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) { |
| 198 | + if ( !in_array( 'known', $options, true ) && !in_array( 'broken', $options, true ) ) { |
194 | 199 | if ( $target->isKnown() ) { |
195 | 200 | $options[] = 'known'; |
196 | 201 | } else { |
— | — | @@ -199,14 +204,14 @@ |
200 | 205 | wfProfileOut( __METHOD__ . '-checkPageExistence' ); |
201 | 206 | |
202 | 207 | $oldquery = array(); |
203 | | - if ( in_array( "forcearticlepath", $options ) && $query ) { |
| 208 | + if ( in_array( 'forcearticlepath', $options, true ) && $query ) { |
204 | 209 | $oldquery = $query; |
205 | 210 | $query = array(); |
206 | 211 | } |
207 | 212 | |
208 | 213 | # Note: we want the href attribute first, for prettiness. |
209 | 214 | $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) ); |
210 | | - if ( in_array( 'forcearticlepath', $options ) && $oldquery ) { |
| 215 | + if ( in_array( 'forcearticlepath', $options, true ) && $oldquery ) { |
211 | 216 | $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) ); |
212 | 217 | } |
213 | 218 | |
— | — | @@ -246,7 +251,7 @@ |
247 | 252 | wfProfileIn( __METHOD__ ); |
248 | 253 | # We don't want to include fragments for broken links, because they |
249 | 254 | # generally make no sense. |
250 | | - if ( in_array( 'broken', $options ) && $target->mFragment !== '' ) { |
| 255 | + if ( in_array( 'broken', $options, true ) && $target->mFragment !== '' ) { |
251 | 256 | $target = clone $target; |
252 | 257 | $target->mFragment = ''; |
253 | 258 | } |
— | — | @@ -254,7 +259,7 @@ |
255 | 260 | # If it's a broken link, add the appropriate query pieces, unless |
256 | 261 | # there's already an action specified, or unless 'edit' makes no sense |
257 | 262 | # (i.e., for a nonexistent special page). |
258 | | - if ( in_array( 'broken', $options ) && empty( $query['action'] ) |
| 263 | + if ( in_array( 'broken', $options, true ) && empty( $query['action'] ) |
259 | 264 | && !$target->isSpecialPage() ) { |
260 | 265 | $query['action'] = 'edit'; |
261 | 266 | $query['redlink'] = '1'; |
— | — | @@ -274,24 +279,22 @@ |
275 | 280 | * @return array |
276 | 281 | */ |
277 | 282 | private static function linkAttribs( $target, $attribs, $options ) { |
| 283 | + global $wgUser; |
| 284 | + |
278 | 285 | wfProfileIn( __METHOD__ ); |
279 | | - global $wgUser; |
| 286 | + |
280 | 287 | $defaults = array(); |
281 | 288 | |
282 | | - if ( !in_array( 'noclasses', $options ) ) { |
| 289 | + if ( !in_array( 'noclasses', $options, true ) ) { |
283 | 290 | wfProfileIn( __METHOD__ . '-getClasses' ); |
284 | 291 | # Now build the classes. |
285 | 292 | $classes = array(); |
286 | 293 | |
287 | | - if ( in_array( 'broken', $options ) ) { |
288 | | - $classes[] = 'new'; |
289 | | - } |
290 | | - |
291 | 294 | if ( $target->isExternal() ) { |
292 | 295 | $classes[] = 'extiw'; |
293 | | - } |
294 | | - |
295 | | - if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387) |
| 296 | + } elseif ( in_array( 'broken', $options, true ) ) { |
| 297 | + $classes[] = 'new'; |
| 298 | + } else { # Avoid useless calls to LinkCache (see r50387) |
296 | 299 | $colour = self::getLinkColour( $target, $wgUser->getStubThreshold() ); |
297 | 300 | if ( $colour !== '' ) { |
298 | 301 | $classes[] = $colour; # mw-redirect or stub |
— | — | @@ -307,10 +310,14 @@ |
308 | 311 | if ( $target->getPrefixedText() == '' ) { |
309 | 312 | # A link like [[#Foo]]. This used to mean an empty title |
310 | 313 | # attribute, but that's silly. Just don't output a title. |
311 | | - } elseif ( in_array( 'known', $options ) ) { |
| 314 | + } elseif ( in_array( 'known', $options, true ) ) { |
312 | 315 | $defaults['title'] = $target->getPrefixedText(); |
313 | 316 | } else { |
314 | | - $defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() ); |
| 317 | + $msg = wfMessage( 'red-link-title', $target->getPrefixedText() ); |
| 318 | + if ( isset( $options['language'] ) ) { |
| 319 | + $msg->inLanguage( $options['language'] ); |
| 320 | + } |
| 321 | + $defaults['title'] = $msg->text(); |
315 | 322 | } |
316 | 323 | |
317 | 324 | # Finally, merge the custom attribs with the default ones, and iterate |