http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73976

Revision: 73976
Author:   hashar
Date:     2010-09-29 19:51:48 +0000 (Wed, 29 Sep 2010)

Log Message:
-----------
Implements bug 24343 "localurl discards section id".
* parser hook 'linkurl' which use Title::getLinkUrl()
* very basic tests for the Title class

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/parser/CoreParserFunctions.php
    trunk/phase3/languages/messages/MessagesEn.php
    trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2010-09-29 19:26:32 UTC (rev 73975)
+++ trunk/phase3/RELEASE-NOTES  2010-09-29 19:51:48 UTC (rev 73976)
@@ -167,6 +167,7 @@
   limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]]
 * Special:Version now displays whether a SQLite database supports full-text
   search.
+* (bug 24343) New parser hook {{linkurl:}}, same as {{localurl:}} with fragment
 
 === Bug fixes in 1.17 ===
 * (bug 17560) Half-broken deletion moved image files to deletion archive

Modified: trunk/phase3/includes/parser/CoreParserFunctions.php
===================================================================
--- trunk/phase3/includes/parser/CoreParserFunctions.php        2010-09-29 
19:26:32 UTC (rev 73975)
+++ trunk/phase3/includes/parser/CoreParserFunctions.php        2010-09-29 
19:51:48 UTC (rev 73976)
@@ -31,6 +31,7 @@
                $parser->setFunctionHook( 'localurle',        array( __CLASS__, 
'localurle'        ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullurl',          array( __CLASS__, 
'fullurl'          ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullurle',         array( __CLASS__, 
'fullurle'         ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'linkurl',          array( __CLASS__, 
'linkurl'          ), SFH_NO_HASH );
                $parser->setFunctionHook( 'formatnum',        array( __CLASS__, 
'formatnum'        ), SFH_NO_HASH );
                $parser->setFunctionHook( 'grammar',          array( __CLASS__, 
'grammar'          ), SFH_NO_HASH );
                $parser->setFunctionHook( 'gender',           array( __CLASS__, 
'gender'           ), SFH_NO_HASH );
@@ -194,6 +195,7 @@
        static function localurle( $parser, $s = '', $arg = null ) { return 
self::urlFunction( 'escapeLocalURL', $s, $arg ); }
        static function fullurl( $parser, $s = '', $arg = null ) { return 
self::urlFunction( 'getFullURL', $s, $arg ); }
        static function fullurle( $parser, $s = '', $arg = null ) { return 
self::urlFunction( 'escapeFullURL', $s, $arg ); }
+       static function linkurl( $parser, $s = '', $arg = null ) { return 
self::urlFunction( 'getLinkUrl', $s, $arg ); }
 
        static function urlFunction( $func, $s = '', $arg = null ) {
                $title = Title::newFromText( $s );

Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php      2010-09-29 19:26:32 UTC 
(rev 73975)
+++ trunk/phase3/languages/messages/MessagesEn.php      2010-09-29 19:51:48 UTC 
(rev 73976)
@@ -295,6 +295,7 @@
        'nse'                    => array( 0,    'NSE:'                   ),
        'localurl'               => array( 0,    'LOCALURL:'              ),
        'localurle'              => array( 0,    'LOCALURLE:'             ),
+       'linkurl'                => array( 0,    'LINKURL:'               ),
        'articlepath'            => array( 0,    'ARTICLEPATH'            ),
        'server'                 => array( 0,    'SERVER'                 ),
        'servername'             => array( 0,    'SERVERNAME'             ),

Modified: trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php
===================================================================
--- trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php       
2010-09-29 19:26:32 UTC (rev 73975)
+++ trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php       
2010-09-29 19:51:48 UTC (rev 73976)
@@ -1,6 +1,10 @@
 <?php
 
 class TitleTest extends PHPUnit_Framework_TestCase {
+       function setUp() {
+               global $wgContLang;
+               $wgContLang = Language::factory( 'en' );
+       }
 
        function testLegalChars() {
                $titlechars = Title::legalChars();
@@ -14,4 +18,24 @@
                        }
                }
        }
+
+       /**
+        * Test originally wrote to investigate bug 24343
+        * FIXME : some tests might fail depending on local settings.
+        */
+       function testGetURLS() {
+               global $wgArticlePath, $wgScript;
+       
+               $title = Title::newFromText( 'User:Bob#section' );
+       
+               $this->assertEquals( "$wgScript/User:Bob", 
$title->getLocalURL(),
+                       'Title::getLocalURL() does NOT have fragment' );
+               $this->assertEquals( "$wgScript/User:Bob", 
$title->escapeLocalURL(),
+                       'Title::escapeLocalURL() does NOT have fragment' );
+               $this->assertEquals( "$wgScript/User:Bob#section", 
$title->getLinkURL(),
+                       'Title::getLinkURL() does have fragment' );
+               
+               #$this->assertEquals( 'toto', $title->getFullURL()     );
+               #$this->assertEquals( 'toto', $title->escapeFullURL()  );
+       }
 }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to