Pastakhov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/302655

Change subject: Add WTitle->fullURL() method (v 1.6.11)
......................................................................

Add WTitle->fullURL() method (v 1.6.11)

Also fix fragment params in WTitle->__construct() method

Change-Id: I5b2971628d37c9da796ec27866bc99a77b5a8b19
---
M PhpTagsWiki.json
M extension.json
M includes/WikiWTitle.php
M tests/phpunit/PhpTagsWiki_Test.php
4 files changed, 36 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PhpTagsWiki 
refs/changes/55/302655/1

diff --git a/PhpTagsWiki.json b/PhpTagsWiki.json
index d7f5f68..b8f793c 100644
--- a/PhpTagsWiki.json
+++ b/PhpTagsWiki.json
@@ -198,7 +198,7 @@
                "WTitle": {
                        "class": "WikiWTitle",
                        "METHODS": {
-                               "__construct" : {
+                               "__construct": {
                                        "parameters": [
                                                { "type": "mixed", "name": 
"name" },
                                                { "type": "int", "name": 
"namespace", "default": "NS_MAIN" },
@@ -206,6 +206,13 @@
                                        ],
                                        "return": "WTitle",
                                        "desc": "Returns new WTitle object"
+                               },
+                               "fullUrl": {
+                                       "parameters": [
+                                               { "type": "array", "name": 
"query", "default": "" }
+                                       ],
+                                       "return": "string",
+                                       "desc": "Get a real URL referring to 
this title"
                                }
                        },
                        "PROPERTIES": {
diff --git a/extension.json b/extension.json
index db2cd71..d240498 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "PhpTags Wiki",
-       "version": "1.6.10",
+       "version": "1.6.11",
        "author": "[https://www.mediawiki.org/wiki/User:Pastakhov Pavel 
Astakhov]",
        "url": "https://www.mediawiki.org/wiki/Extension:PhpTags_Wiki";,
        "descriptionmsg": "phptagswiki-desc",
diff --git a/includes/WikiWTitle.php b/includes/WikiWTitle.php
index b85ab6b..afd9c5b 100644
--- a/includes/WikiWTitle.php
+++ b/includes/WikiWTitle.php
@@ -24,7 +24,7 @@
                return $this->p_fullName();
        }
 
-       public function m___construct( $name, $namespace = NS_MAIN ) {
+       public function m___construct( $name, $namespace = NS_MAIN, $fragment = 
'' ) {
                $title = null;
                if ( $name instanceof \PhpTags\GenericObject ) {
                        $value = $name->getValue();
@@ -40,6 +40,9 @@
                }
 
                if ( $title instanceof \Title ) {
+                       if ( $fragment ) {
+                               $title = \Title::makeTitleSafe( 
$title->getNamespace(), $title->getDBkey(), $fragment );
+                       }
                        $this->value = $title;
                        return true;
                }
@@ -47,6 +50,13 @@
                return false;
        }
 
+       public function m_fullUrl( $query = [] ) {
+               $title = $this->value;
+               if ( $title instanceof \Title ) {
+                       return $title->getInternalURL( $query );
+               }
+       }
+
        public static function c_NS_TEXT( $title = null ) {
                if ( false === $title instanceof \Title ) {
                        $title = self::getParserTitle();
diff --git a/tests/phpunit/PhpTagsWiki_Test.php 
b/tests/phpunit/PhpTagsWiki_Test.php
index 649e7e6..a5aea83 100644
--- a/tests/phpunit/PhpTagsWiki_Test.php
+++ b/tests/phpunit/PhpTagsWiki_Test.php
@@ -45,4 +45,20 @@
                                );
        }
 
+       public function testRun_Title_fullUrl_1() {
+               $title = \Title::makeTitleSafe( NS_MAIN, 'Test page' );
+               $this->assertEquals(
+                               Runtime::runSource('$title = new WTitle( "Test 
page" ); echo $title->fullURL();'),
+                               array( $title->getFullURL() )
+                       );
+       }
+
+       public function testRun_Title_fullUrl_2() {
+               $title = \Title::makeTitleSafe( NS_MAIN, 'Test page' );
+               $this->assertEquals(
+                               Runtime::runSource('$title = new WTitle( "Test 
page" ); echo $title->fullURL( ["action"=>"edit"] );'),
+                               array( $title->getFullURL( 
array('action'=>'edit') ) )
+                       );
+       }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/302655
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b2971628d37c9da796ec27866bc99a77b5a8b19
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTagsWiki
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>

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

Reply via email to