Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -47,9 +47,12 @@ |
48 | 48 | document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/KHTMLFixes.css">'); |
49 | 49 | } |
50 | 50 | } |
51 | | -// Un-trap us from framesets |
52 | | -if (window.top != window) { |
53 | | - window.top.location = window.location; |
| 51 | + |
| 52 | +if (wgBreakFrames) { |
| 53 | + // Un-trap us from framesets |
| 54 | + if (window.top != window && wgBreakFramesExceptions.indexOf(window.top.location.hostname) == -1) { |
| 55 | + window.top.location = window.location; |
| 56 | + } |
54 | 57 | } |
55 | 58 | |
56 | 59 | // for enhanced RecentChanges |
— | — | @@ -843,6 +846,18 @@ |
844 | 847 | } |
845 | 848 | } |
846 | 849 | |
| 850 | +function redirectToFragment(fragment) { |
| 851 | + if (is_gecko) { |
| 852 | + // Mozilla needs to wait until after load, otherwise the window doesn't scroll |
| 853 | + addOnloadHook(function () { |
| 854 | + if (window.location.hash == "") |
| 855 | + window.location.hash = fragment; |
| 856 | + }); |
| 857 | + } else { |
| 858 | + if (window.location.hash == "") |
| 859 | + window.location.hash = fragment; |
| 860 | + } |
| 861 | +} |
847 | 862 | |
848 | 863 | function runOnloadHook() { |
849 | 864 | // don't run anything below this for non-dom browsers |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -250,7 +250,11 @@ |
251 | 251 | * Enable QueryPage classes to override list formatting |
252 | 252 | * (bug 5485) Show number of intervening revisions in diff view |
253 | 253 | * (bug 8100) Fix XHTML validity in Taiwanese localization |
| 254 | +* Added redirect to section feature. Use it wisely. |
| 255 | +* Added a configuration variable allowing the "break out of framesets" feature |
| 256 | + to be switched on and off ($wgBreakFrames). Off by default. |
254 | 257 | |
| 258 | + |
255 | 259 | == Languages updated == |
256 | 260 | |
257 | 261 | * Bishnupriya Manipuri (bpy) |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -72,6 +72,16 @@ |
73 | 73 | function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); } |
74 | 74 | function addKeyword( $text ) { array_push( $this->mKeywords, $text ); } |
75 | 75 | function addScript( $script ) { $this->mScripts .= $script; } |
| 76 | + |
| 77 | + /** |
| 78 | + * Add a self-contained script tag with the given contents |
| 79 | + * @param string $script JavaScript text, no <script> tags |
| 80 | + */ |
| 81 | + function addInlineScript( $script ) { |
| 82 | + global $wgJsMimeType; |
| 83 | + $this->mScripts .= "<script type=\"$wgJsMimeType\"><!--\n$script\n--></script>"; |
| 84 | + } |
| 85 | + |
76 | 86 | function getScript() { return $this->mScripts; } |
77 | 87 | |
78 | 88 | function setETag($tag) { $this->mETag = $tag; } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -567,6 +567,19 @@ |
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
| 571 | + /** |
| 572 | + * Escape a text fragment, say from a link, for a URL |
| 573 | + */ |
| 574 | + static function escapeFragmentForURL( $fragment ) { |
| 575 | + $fragment = trim( str_replace( ' ', '_', $fragment ), '_' ); |
| 576 | + $fragment = urlencode( Sanitizer::decodeCharReferences( $fragment ) ); |
| 577 | + $replaceArray = array( |
| 578 | + '%3A' => ':', |
| 579 | + '%' => '.' |
| 580 | + ); |
| 581 | + return strtr( $fragment, $replaceArray ); |
| 582 | + } |
| 583 | + |
571 | 584 | #---------------------------------------------------------------------------- |
572 | 585 | # Other stuff |
573 | 586 | #---------------------------------------------------------------------------- |
— | — | @@ -639,12 +652,25 @@ |
640 | 653 | */ |
641 | 654 | function getInterwiki() { return $this->mInterwiki; } |
642 | 655 | /** |
643 | | - * Get the Title fragment (i.e. the bit after the #) |
| 656 | + * Get the Title fragment (i.e. the bit after the #) in text form |
644 | 657 | * @return string |
645 | 658 | * @access public |
646 | 659 | */ |
647 | 660 | function getFragment() { return $this->mFragment; } |
648 | 661 | /** |
| 662 | + * Get the fragment in URL form, including the "#" character if there is one |
| 663 | + * |
| 664 | + * @return string |
| 665 | + * @access public |
| 666 | + */ |
| 667 | + function getFragmentForURL() { |
| 668 | + if ( $this->mFragment == '' ) { |
| 669 | + return ''; |
| 670 | + } else { |
| 671 | + return '#' . Title::escapeFragmentForURL( $this->mFragment ); |
| 672 | + } |
| 673 | + } |
| 674 | + /** |
649 | 675 | * Get the default namespace index, for when there is no namespace |
650 | 676 | * @return int |
651 | 677 | * @access public |
— | — | @@ -803,9 +829,7 @@ |
804 | 830 | } |
805 | 831 | |
806 | 832 | # Finally, add the fragment. |
807 | | - if ( '' != $this->mFragment ) { |
808 | | - $url .= '#' . $this->mFragment; |
809 | | - } |
| 833 | + $url .= $this->getFragmentForURL(); |
810 | 834 | |
811 | 835 | wfRunHooks( 'GetFullURL', array( &$this, &$url, $query ) ); |
812 | 836 | return $url; |
— | — | @@ -1442,41 +1466,41 @@ |
1443 | 1467 | |
1444 | 1468 | # Clean up whitespace |
1445 | 1469 | # |
1446 | | - $t = preg_replace( '/[ _]+/', '_', $this->mDbkeyform ); |
1447 | | - $t = trim( $t, '_' ); |
| 1470 | + $dbkey = preg_replace( '/[ _]+/', '_', $this->mDbkeyform ); |
| 1471 | + $dbkey = trim( $dbkey, '_' ); |
1448 | 1472 | |
1449 | | - if ( '' == $t ) { |
| 1473 | + if ( '' == $dbkey ) { |
1450 | 1474 | return false; |
1451 | 1475 | } |
1452 | 1476 | |
1453 | | - if( false !== strpos( $t, UTF8_REPLACEMENT ) ) { |
| 1477 | + if( false !== strpos( $dbkey, UTF8_REPLACEMENT ) ) { |
1454 | 1478 | # Contained illegal UTF-8 sequences or forbidden Unicode chars. |
1455 | 1479 | return false; |
1456 | 1480 | } |
1457 | 1481 | |
1458 | | - $this->mDbkeyform = $t; |
| 1482 | + $this->mDbkeyform = $dbkey; |
1459 | 1483 | |
1460 | 1484 | # Initial colon indicates main namespace rather than specified default |
1461 | 1485 | # but should not create invalid {ns,title} pairs such as {0,Project:Foo} |
1462 | | - if ( ':' == $t{0} ) { |
| 1486 | + if ( ':' == $dbkey{0} ) { |
1463 | 1487 | $this->mNamespace = NS_MAIN; |
1464 | | - $t = substr( $t, 1 ); # remove the colon but continue processing |
| 1488 | + $dbkey = substr( $dbkey, 1 ); # remove the colon but continue processing |
1465 | 1489 | } |
1466 | 1490 | |
1467 | 1491 | # Namespace or interwiki prefix |
1468 | 1492 | $firstPass = true; |
1469 | 1493 | do { |
1470 | 1494 | $m = array(); |
1471 | | - if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $t, $m ) ) { |
| 1495 | + if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $dbkey, $m ) ) { |
1472 | 1496 | $p = $m[1]; |
1473 | 1497 | $lowerNs = $wgContLang->lc( $p ); |
1474 | 1498 | if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) { |
1475 | 1499 | # Canonical namespace |
1476 | | - $t = $m[2]; |
| 1500 | + $dbkey = $m[2]; |
1477 | 1501 | $this->mNamespace = $ns; |
1478 | 1502 | } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) { |
1479 | 1503 | # Ordinary namespace |
1480 | | - $t = $m[2]; |
| 1504 | + $dbkey = $m[2]; |
1481 | 1505 | $this->mNamespace = $ns; |
1482 | 1506 | } elseif( $this->getInterwikiLink( $p ) ) { |
1483 | 1507 | if( !$firstPass ) { |
— | — | @@ -1486,12 +1510,12 @@ |
1487 | 1511 | } |
1488 | 1512 | |
1489 | 1513 | # Interwiki link |
1490 | | - $t = $m[2]; |
| 1514 | + $dbkey = $m[2]; |
1491 | 1515 | $this->mInterwiki = $wgContLang->lc( $p ); |
1492 | 1516 | |
1493 | 1517 | # Redundant interwiki prefix to the local wiki |
1494 | 1518 | if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) { |
1495 | | - if( $t == '' ) { |
| 1519 | + if( $dbkey == '' ) { |
1496 | 1520 | # Can't have an empty self-link |
1497 | 1521 | return false; |
1498 | 1522 | } |
— | — | @@ -1503,9 +1527,9 @@ |
1504 | 1528 | |
1505 | 1529 | # If there's an initial colon after the interwiki, that also |
1506 | 1530 | # resets the default namespace |
1507 | | - if ( $t !== '' && $t[0] == ':' ) { |
| 1531 | + if ( $dbkey !== '' && $dbkey[0] == ':' ) { |
1508 | 1532 | $this->mNamespace = NS_MAIN; |
1509 | | - $t = substr( $t, 1 ); |
| 1533 | + $dbkey = substr( $dbkey, 1 ); |
1510 | 1534 | } |
1511 | 1535 | } |
1512 | 1536 | # If there's no recognized interwiki or namespace, |
— | — | @@ -1513,25 +1537,24 @@ |
1514 | 1538 | } |
1515 | 1539 | break; |
1516 | 1540 | } while( true ); |
1517 | | - $r = $t; |
1518 | 1541 | |
1519 | 1542 | # We already know that some pages won't be in the database! |
1520 | 1543 | # |
1521 | 1544 | if ( '' != $this->mInterwiki || NS_SPECIAL == $this->mNamespace ) { |
1522 | 1545 | $this->mArticleID = 0; |
1523 | 1546 | } |
1524 | | - $f = strstr( $r, '#' ); |
1525 | | - if ( false !== $f ) { |
1526 | | - $this->mFragment = substr( $f, 1 ); |
1527 | | - $r = substr( $r, 0, strlen( $r ) - strlen( $f ) ); |
| 1547 | + $fragment = strstr( $dbkey, '#' ); |
| 1548 | + if ( false !== $fragment ) { |
| 1549 | + $this->setFragment( $fragment ); |
| 1550 | + $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) ); |
1528 | 1551 | # remove whitespace again: prevents "Foo_bar_#" |
1529 | 1552 | # becoming "Foo_bar_" |
1530 | | - $r = preg_replace( '/_*$/', '', $r ); |
| 1553 | + $dbkey = preg_replace( '/_*$/', '', $dbkey ); |
1531 | 1554 | } |
1532 | 1555 | |
1533 | 1556 | # Reject illegal characters. |
1534 | 1557 | # |
1535 | | - if( preg_match( $rxTc, $r ) ) { |
| 1558 | + if( preg_match( $rxTc, $dbkey ) ) { |
1536 | 1559 | return false; |
1537 | 1560 | } |
1538 | 1561 | |
— | — | @@ -1540,19 +1563,26 @@ |
1541 | 1564 | * often be unreachable due to the way web browsers deal |
1542 | 1565 | * with 'relative' URLs. Forbid them explicitly. |
1543 | 1566 | */ |
1544 | | - if ( strpos( $r, '.' ) !== false && |
1545 | | - ( $r === '.' || $r === '..' || |
1546 | | - strpos( $r, './' ) === 0 || |
1547 | | - strpos( $r, '../' ) === 0 || |
1548 | | - strpos( $r, '/./' ) !== false || |
1549 | | - strpos( $r, '/../' ) !== false ) ) |
| 1567 | + if ( strpos( $dbkey, '.' ) !== false && |
| 1568 | + ( $dbkey === '.' || $dbkey === '..' || |
| 1569 | + strpos( $dbkey, './' ) === 0 || |
| 1570 | + strpos( $dbkey, '../' ) === 0 || |
| 1571 | + strpos( $dbkey, '/./' ) !== false || |
| 1572 | + strpos( $dbkey, '/../' ) !== false ) ) |
1550 | 1573 | { |
1551 | 1574 | return false; |
1552 | 1575 | } |
1553 | 1576 | |
1554 | | - # We shouldn't need to query the DB for the size. |
1555 | | - #$maxSize = $dbr->textFieldSize( 'page', 'page_title' ); |
1556 | | - if ( strlen( $r ) > 255 ) { |
| 1577 | + /** |
| 1578 | + * Limit the size of titles to 255 bytes. |
| 1579 | + * This is typically the size of the underlying database field. |
| 1580 | + * We make an exception for special pages, which don't need to be stored |
| 1581 | + * in the database, and may edge over 255 bytes due to subpage syntax |
| 1582 | + * for long titles, e.g. [[Special:Block/Long name]] |
| 1583 | + */ |
| 1584 | + if ( ( $this->mNamespace != NS_SPECIAL && strlen( $dbkey ) > 255 ) || |
| 1585 | + strlen( $dbkey ) > 512 ) |
| 1586 | + { |
1557 | 1587 | return false; |
1558 | 1588 | } |
1559 | 1589 | |
— | — | @@ -1565,9 +1595,7 @@ |
1566 | 1596 | * site might be case-sensitive. |
1567 | 1597 | */ |
1568 | 1598 | if( $wgCapitalLinks && $this->mInterwiki == '') { |
1569 | | - $t = $wgContLang->ucfirst( $r ); |
1570 | | - } else { |
1571 | | - $t = $r; |
| 1599 | + $dbkey = $wgContLang->ucfirst( $dbkey ); |
1572 | 1600 | } |
1573 | 1601 | |
1574 | 1602 | /** |
— | — | @@ -1575,27 +1603,40 @@ |
1576 | 1604 | * "empty" local links can only be self-links |
1577 | 1605 | * with a fragment identifier. |
1578 | 1606 | */ |
1579 | | - if( $t == '' && |
| 1607 | + if( $dbkey == '' && |
1580 | 1608 | $this->mInterwiki == '' && |
1581 | 1609 | $this->mNamespace != NS_MAIN ) { |
1582 | 1610 | return false; |
1583 | 1611 | } |
1584 | 1612 | |
1585 | 1613 | // Any remaining initial :s are illegal. |
1586 | | - if ( $t !== '' && ':' == $t{0} ) { |
| 1614 | + if ( $dbkey !== '' && ':' == $dbkey{0} ) { |
1587 | 1615 | return false; |
1588 | 1616 | } |
1589 | 1617 | |
1590 | 1618 | # Fill fields |
1591 | | - $this->mDbkeyform = $t; |
1592 | | - $this->mUrlform = wfUrlencode( $t ); |
| 1619 | + $this->mDbkeyform = $dbkey; |
| 1620 | + $this->mUrlform = wfUrlencode( $dbkey ); |
1593 | 1621 | |
1594 | | - $this->mTextform = str_replace( '_', ' ', $t ); |
| 1622 | + $this->mTextform = str_replace( '_', ' ', $dbkey ); |
1595 | 1623 | |
1596 | 1624 | return true; |
1597 | 1625 | } |
1598 | 1626 | |
1599 | 1627 | /** |
| 1628 | + * Set the fragment for this title |
| 1629 | + * This is kind of bad, since except for this rarely-used function, Title objects |
| 1630 | + * are immutable. The reason this is here is because it's better than setting the |
| 1631 | + * members directly, which is what Linker::formatComment was doing previously. |
| 1632 | + * |
| 1633 | + * @param string $fragment text |
| 1634 | + * @access kind of public |
| 1635 | + */ |
| 1636 | + function setFragment( $fragment ) { |
| 1637 | + $this->mFragment = trim( str_replace( '_', ' ', substr( $fragment, 1 ) ), ' ' ); |
| 1638 | + } |
| 1639 | + |
| 1640 | + /** |
1600 | 1641 | * Get a Title object associated with the talk page of this article |
1601 | 1642 | * @return Title the object for the talk page |
1602 | 1643 | * @access public |
Index: trunk/phase3/includes/Xml.php |
— | — | @@ -255,6 +255,33 @@ |
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
| 259 | + * Encode a variable of unknown type to JavaScript. |
| 260 | + * Doesn't support hashtables just yet. |
| 261 | + */ |
| 262 | + public static function encodeJsVar( $value ) { |
| 263 | + if ( is_bool( $value ) ) { |
| 264 | + $s = $value ? 'true' : 'false'; |
| 265 | + } elseif ( is_null( $value ) ) { |
| 266 | + $s = 'null'; |
| 267 | + } elseif ( is_int( $value ) ) { |
| 268 | + $s = $value; |
| 269 | + } elseif ( is_array( $value ) ) { |
| 270 | + $s = '['; |
| 271 | + foreach ( $value as $name => $elt ) { |
| 272 | + if ( $s != '[' ) { |
| 273 | + $s .= ', '; |
| 274 | + } |
| 275 | + $s .= self::encodeJsVar( $elt ); |
| 276 | + } |
| 277 | + $s .= ']'; |
| 278 | + } else { |
| 279 | + $s = '"' . self::escapeJsString( $value ) . '"'; |
| 280 | + } |
| 281 | + return $s; |
| 282 | + } |
| 283 | + |
| 284 | + |
| 285 | + /** |
259 | 286 | * Check if a string is well-formed XML. |
260 | 287 | * Must include the surrounding tag. |
261 | 288 | * |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -213,22 +213,6 @@ |
214 | 214 | $trail = $m[2]; |
215 | 215 | } |
216 | 216 | } |
217 | | - |
218 | | - # Check for anchors, normalize the anchor |
219 | | - |
220 | | - $parts = explode( '#', $u, 2 ); |
221 | | - if ( count( $parts ) == 2 ) { |
222 | | - $anchor = urlencode( Sanitizer::decodeCharReferences( str_replace(' ', '_', $parts[1] ) ) ); |
223 | | - $replacearray = array( |
224 | | - '%3A' => ':', |
225 | | - '%' => '.' |
226 | | - ); |
227 | | - $u = $parts[0] . '#' . |
228 | | - str_replace( array_keys( $replacearray ), |
229 | | - array_values( $replacearray ), |
230 | | - $anchor ); |
231 | | - } |
232 | | - |
233 | 217 | $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>"; |
234 | 218 | |
235 | 219 | wfProfileOut( $fname ); |
— | — | @@ -307,12 +291,7 @@ |
308 | 292 | $text = htmlspecialchars( $nt->getFragment() ); |
309 | 293 | } |
310 | 294 | } |
311 | | - $anchor = urlencode( Sanitizer::decodeCharReferences( str_replace( ' ', '_', $nt->getFragment() ) ) ); |
312 | | - $replacearray = array( |
313 | | - '%3A' => ':', |
314 | | - '%' => '.' |
315 | | - ); |
316 | | - $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor); |
| 295 | + $u .= $nt->getFragmentForURL(); |
317 | 296 | } |
318 | 297 | if ( $text == '' ) { |
319 | 298 | $text = htmlspecialchars( $nt->getPrefixedText() ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2334,4 +2334,18 @@ |
2335 | 2335 | "$IP/maintenance/parserTests.txt", |
2336 | 2336 | ); |
2337 | 2337 | |
| 2338 | +/** |
| 2339 | + * Break out of framesets. This can be used to prevent external sites from |
| 2340 | + * framing your site with ads. |
| 2341 | + */ |
| 2342 | +$wgBreakFrames = false; |
| 2343 | + |
| 2344 | +/** |
| 2345 | + * Break frameset exception list |
| 2346 | + */ |
| 2347 | +$wgBreakFramesExceptions = array( |
| 2348 | + 'babelfish.altavista.com', |
| 2349 | + 'translate.google.com', |
| 2350 | +); |
| 2351 | + |
2338 | 2352 | ?> |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -270,61 +270,62 @@ |
271 | 271 | $out->out( "\n</body></html>" ); |
272 | 272 | } |
273 | 273 | |
274 | | - static function makeGlobalVariablesScript( $data ) { |
275 | | - $r = '<script type= "' . $data['jsmimetype'] . '"> |
276 | | - var skin = "' . Xml::escapeJsString( $data['skinname'] ) . '"; |
277 | | - var stylepath = "' . Xml::escapeJsString( $data['stylepath'] ) . '"; |
| 274 | + static function makeVariablesScript( $data ) { |
| 275 | + global $wgJsMimeType; |
278 | 276 | |
279 | | - var wgArticlePath = "' . Xml::escapeJsString( $data['articlepath'] ) . '"; |
280 | | - var wgScriptPath = "' . Xml::escapeJsString( $data['scriptpath'] ) . '"; |
281 | | - var wgServer = "' . Xml::escapeJsString( $data['serverurl'] ) . '"; |
| 277 | + $r = "<script type= \"$wgJsMimeType\"><!--\n"; |
| 278 | + foreach ( $data as $name => $value ) { |
| 279 | + $encValue = Xml::encodeJsVar( $value ); |
| 280 | + $r .= "var $name = $encValue;\n"; |
| 281 | + } |
| 282 | + $r .= "--></script>\n"; |
282 | 283 | |
283 | | - var wgCanonicalNamespace = "' . Xml::escapeJsString( $data['nscanonical'] ) . '"; |
284 | | - var wgNamespaceNumber = ' . (int)$data['nsnumber'] . '; |
285 | | - var wgPageName = "' . Xml::escapeJsString( $data['titleprefixeddbkey'] ) . '"; |
286 | | - var wgTitle = "' . Xml::escapeJsString( $data['titletext'] ) . '"; |
287 | | - var wgArticleId = ' . (int)$data['articleid'] . '; |
288 | | - var wgCurRevisionId = ' . ( int ) $data['currevisionid'] . '; |
289 | | - var wgIsArticle = ' . ( $data['isarticle'] ? 'true' : 'false' ) . '; |
290 | | - |
291 | | - var wgUserName = ' . ( $data['username'] == NULL ? 'null' : ( '"' . Xml::escapeJsString( $data['username'] ) . '"' ) ) . '; |
292 | | - var wgUserLanguage = "' . Xml::escapeJsString( $data['userlang'] ) . '"; |
293 | | - var wgContentLanguage = "' . Xml::escapeJsString( $data['lang'] ) . '"; |
294 | | - </script> |
295 | | - '; |
296 | | - |
297 | 284 | return $r; |
298 | 285 | } |
299 | 286 | |
300 | | - function getHeadScripts() { |
301 | | - global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion; |
| 287 | + /** |
| 288 | + * Make a <script> tag containing global variables |
| 289 | + * @param array $data Associative array containing one element: |
| 290 | + * skinname => the skin name |
| 291 | + * The odd calling convention is for backwards compatibility |
| 292 | + */ |
| 293 | + static function makeGlobalVariablesScript( $data ) { |
| 294 | + global $wgStylePath, $wgUser; |
302 | 295 | global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; |
303 | 296 | global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle; |
| 297 | + global $wgBreakFrames, $wgBreakFramesExceptions; |
304 | 298 | |
305 | 299 | $ns = $wgTitle->getNamespace(); |
306 | 300 | $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText(); |
307 | 301 | |
308 | 302 | $vars = array( |
309 | | - 'jsmimetype' => $wgJsMimeType, |
310 | | - 'skinname' => $this->getSkinName(), |
| 303 | + 'skin' => $data['skinname'], |
311 | 304 | 'stylepath' => $wgStylePath, |
312 | | - 'articlepath' => $wgArticlePath, |
313 | | - 'scriptpath' => $wgScriptPath, |
314 | | - 'serverurl' => $wgServer, |
315 | | - 'nscanonical' => $nsname, |
316 | | - 'nsnumber' => $wgTitle->getNamespace(), |
317 | | - 'titleprefixeddbkey' => $wgTitle->getPrefixedDBKey(), |
318 | | - 'titletext' => $wgTitle->getText(), |
319 | | - 'articleid' => $wgTitle->getArticleId(), |
320 | | - 'currevisionid' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0, |
321 | | - 'isarticle' => $wgOut->isArticle(), |
322 | | - 'username' => $wgUser->isAnon() ? NULL : $wgUser->getName(), |
323 | | - 'userlang' => $wgLang->getCode(), |
324 | | - 'lang' => $wgContLang->getCode(), |
| 305 | + 'wgArticlePath' => $wgArticlePath, |
| 306 | + 'wgScriptPath' => $wgScriptPath, |
| 307 | + 'wgServer' => $wgServer, |
| 308 | + 'wgCanonicalNamespace' => $nsname, |
| 309 | + 'wgNamespaceNumber' => $wgTitle->getNamespace(), |
| 310 | + 'wgPageName' => $wgTitle->getPrefixedDBKey(), |
| 311 | + 'wgTitle' => $wgTitle->getText(), |
| 312 | + 'wgArticleId' => $wgTitle->getArticleId(), |
| 313 | + 'wgIsArticle' => $wgOut->isArticle(), |
| 314 | + 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), |
| 315 | + 'wgUserLanguage' => $wgLang->getCode(), |
| 316 | + 'wgContentLanguage' => $wgContLang->getCode(), |
| 317 | + 'wgBreakFrames' => $wgBreakFrames, |
| 318 | + 'wgBreakFramesExceptions' => $wgBreakFramesExceptions, |
| 319 | + 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0, |
325 | 320 | ); |
326 | 321 | |
327 | | - $r = self::makeGlobalVariablesScript( $vars ); |
| 322 | + return self::makeVariablesScript( $vars ); |
| 323 | + } |
328 | 324 | |
| 325 | + function getHeadScripts() { |
| 326 | + global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion; |
| 327 | + |
| 328 | + $r = self::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) ); |
| 329 | + |
329 | 330 | $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n"; |
330 | 331 | global $wgUseSiteJs; |
331 | 332 | if ($wgUseSiteJs) { |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -691,6 +691,12 @@ |
692 | 692 | $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); |
693 | 693 | $s = wfMsg( 'redirectedfrom', $redir ); |
694 | 694 | $wgOut->setSubtitle( $s ); |
| 695 | + |
| 696 | + // Set the fragment if one was specified in the redirect |
| 697 | + if ( strval( $this->mTitle->getFragment() ) != '' ) { |
| 698 | + $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() ); |
| 699 | + $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" ); |
| 700 | + } |
695 | 701 | $wasRedirected = true; |
696 | 702 | } |
697 | 703 | } elseif ( !empty( $rdfrom ) ) { |
— | — | @@ -778,7 +784,7 @@ |
779 | 785 | if( !$wasRedirected && $this->isCurrent() ) { |
780 | 786 | $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
781 | 787 | } |
782 | | - $link = $sk->makeLinkObj( $rt ); |
| 788 | + $link = $sk->makeLinkObj( $rt, $rt->getFullText() ); |
783 | 789 | |
784 | 790 | $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT" />' . |
785 | 791 | '<span class="redirectText">'.$link.'</span>' ); |
— | — | @@ -2666,7 +2672,7 @@ |
2667 | 2673 | public static function getRedirectAutosummary( $text ) { |
2668 | 2674 | $rt = Title::newFromRedirect( $text ); |
2669 | 2675 | if( is_object( $rt ) ) |
2670 | | - return wfMsgForContent( 'autoredircomment', $rt->getPrefixedText() ); |
| 2676 | + return wfMsgForContent( 'autoredircomment', $rt->getFullText() ); |
2671 | 2677 | else |
2672 | 2678 | return ''; |
2673 | 2679 | } |