jenkins-bot has submitted this change and it was merged.
Change subject: add static property WPage::$DEFAULT_SORT_KEY (v 1.4.0 needs
2.8.4)
......................................................................
add static property WPage::$DEFAULT_SORT_KEY (v 1.4.0 needs 2.8.4)
* fix object's static properties and constants v 2.8.0
* add WTitle properties subjectNsNumber and talkNsNumber
Change-Id: I065b67516e7546f67e3ef5b1721c20a864e464d0
---
M PhpTagsWiki.php
M includes/WikiWCategory.php
M includes/WikiWPage.php
M includes/WikiWStats.php
M includes/WikiWTitle.php
M tests/parser/PhpTagsWikiTests.txt
6 files changed, 80 insertions(+), 27 deletions(-)
Approvals:
Pastakhov: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PhpTagsWiki.php b/PhpTagsWiki.php
index 204567a..43ec904 100644
--- a/PhpTagsWiki.php
+++ b/PhpTagsWiki.php
@@ -19,7 +19,7 @@
die( 'ERROR: The <a
href="https://www.mediawiki.org/wiki/Extension:PhpTags">extension PhpTags</a>
must be installed for the extension PhpTags Wiki to run!' );
}
-$needVersion = '2.6.2';
+$needVersion = '2.8.4';
if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) {
die(
'<b>Error:</b> This version of extension PhpTags Wiki needs <a
href="https://www.mediawiki.org/wiki/Extension:PhpTags">PhpTags</a> ' .
$needVersion . ' or later.
@@ -33,7 +33,7 @@
);
}
-define( 'PHPTAGS_WIKI_VERSION' , '1.3.0' );
+define( 'PHPTAGS_WIKI_VERSION' , '1.4.0' );
// Register this extension on Special:Version
$wgExtensionCredits['phptags'][] = array(
diff --git a/includes/WikiWCategory.php b/includes/WikiWCategory.php
index 24464ba..d809517 100644
--- a/includes/WikiWCategory.php
+++ b/includes/WikiWCategory.php
@@ -35,11 +35,11 @@
if ( $category instanceof \Category ) {
$dbkey = $category->getTitle()->getPrefixedDBkey();
if ( isset( self::$cache[$dbkey] ) ) {
- $this->value =& self::$cache[$dbkey];
+ $this->value = self::$cache[$dbkey];
} else {
\PhpTags\Runtime::incrementExpensiveFunctionCount(
"{$this->name}::__construct()" );
- self::$cache[$dbkey] =& $category;
- $this->value =& $category;
+ self::$cache[$dbkey] = $category;
+ $this->value = $category;
}
return true;
}
diff --git a/includes/WikiWPage.php b/includes/WikiWPage.php
index e1b8f49..a7845ab 100644
--- a/includes/WikiWPage.php
+++ b/includes/WikiWPage.php
@@ -12,13 +12,13 @@
$this->value['name'] = $name;
}
- public static function c_ID() {
+ public static function q_ID() {
$parser = \PhpTags\Runtime::getParser();
$pageid = $parser->getTitle()->getArticleID();
return $pageid;
}
- public static function c_TITLE() {
+ public static function q_TITLE() {
return \PhpTags\Hooks::getObjectWithValue(
'WTitle',
\PhpTags\Runtime::getParser()->getTitle()
@@ -32,5 +32,15 @@
}
+ public static function q_DEFAULT_SORT_KEY() {
+ $parser = \PhpTags\Runtime::getParser();
+ return $parser->getCustomDefaultSort();
+ }
+
+ public static function d_DEFAULT_SORT_KEY( $value ) {
+ $parser = \PhpTags\Runtime::getParser();
+ return $parser->setDefaultSort( (string)$value );
+ }
+
}
diff --git a/includes/WikiWStats.php b/includes/WikiWStats.php
index 8526cb0..0b381ae 100644
--- a/includes/WikiWStats.php
+++ b/includes/WikiWStats.php
@@ -15,7 +15,7 @@
*
*/
- public static function c_ACTIVE_USERS() {
+ public static function q_ACTIVE_USERS() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::activeUsers();
@@ -23,7 +23,7 @@
return $value;
}
- public static function c_ADMINS() {
+ public static function q_ADMINS() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::numberingroup( 'sysop' );
@@ -31,7 +31,7 @@
return $value;
}
- public static function c_ARTICLES() {
+ public static function q_ARTICLES() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::articles();
@@ -39,7 +39,7 @@
return $value;
}
- public static function c_EDITS() {
+ public static function q_EDITS() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::edits();
@@ -47,7 +47,7 @@
return $value;
}
- public static function c_FILES() {
+ public static function q_FILES() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::images();
@@ -55,7 +55,7 @@
return $value;
}
- public static function c_PAGES() {
+ public static function q_PAGES() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::pages();
@@ -63,7 +63,7 @@
return $value;
}
- public static function c_USERS() {
+ public static function q_USERS() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::users();
@@ -71,7 +71,7 @@
return $value;
}
- public static function c_VIEWS() {
+ public static function q_VIEWS() {
static $value = false;
if ( $value === false ) {
$value = $GLOBALS['wgDisableCounters'] ?
(int)\SiteStats::views() : null;
@@ -79,7 +79,7 @@
return $value;
}
- public static function c_JOBS() {
+ public static function q_JOBS() {
static $value = false;
if ( $value === false ) {
$value = (int)\SiteStats::jobs();
diff --git a/includes/WikiWTitle.php b/includes/WikiWTitle.php
index 0ca9d89..f5d37d0 100644
--- a/includes/WikiWTitle.php
+++ b/includes/WikiWTitle.php
@@ -86,11 +86,27 @@
return $title->getSubjectNsText();
}
+ public static function c_SUBJECT_NS_NUMBER( $objectName, $title = null
) {
+ if ( false === $title instanceof \Title ) {
+ $title = \PhpTags\Runtime::getParser()->getTitle();
+ }
+ $namespace = $title->getNamespace();
+ return \MWNamespace::getSubject( $namespace );
+ }
+
public static function c_TALK_NS_TEXT( $objectName, $title = null ) {
if ( false === $title instanceof \Title ) {
$title = \PhpTags\Runtime::getParser()->getTitle();
}
return $title->getTalkNsText();
+ }
+
+ public static function c_TALK_NS_NUMBER( $objectName, $title = null ) {
+ if ( false === $title instanceof \Title ) {
+ $title = \PhpTags\Runtime::getParser()->getTitle();
+ }
+ $namespace = $title->getNamespace();
+ return \MWNamespace::getTalk( $namespace );
}
public static function c_IS_CONTENT_PAGE( $objectName, $title = null ) {
@@ -142,10 +158,18 @@
return self::c_SUBJECT_NS_TEXT( $this->name, $this->value );
}
+ public function p_subjectNsNumber() {
+ return self::c_SUBJECT_NS_NUMBER( $this->name, $this->value );
+ }
+
public function p_talkNsText() {
return self::c_TALK_NS_TEXT( $this->name, $this->value );
}
+ public function p_talkNsNumber() {
+ return self::c_TALK_NS_NUMBER( $this->name, $this->value );
+ }
+
public function p_isContentPage() {
return self::c_IS_CONTENT_PAGE( $this->name, $this->value );
}
diff --git a/tests/parser/PhpTagsWikiTests.txt
b/tests/parser/PhpTagsWikiTests.txt
index ebf9598..a755723 100644
--- a/tests/parser/PhpTagsWikiTests.txt
+++ b/tests/parser/PhpTagsWikiTests.txt
@@ -22,30 +22,39 @@
[[Category:Test categories]]
!! endarticle
+!! article
+Test default sort key
+!! text
+{{#phptag: echo WPage::$DEFAULT_SORT_KEY === false ? 'false' : 'true'; }}
+{{#phptag: WPage::$DEFAULT_SORT_KEY = 'Sort key page'; }}
+[[Category:Test pages]]
+{{#phptag: echo WPage::$DEFAULT_SORT_KEY === false ? 'false' : 'true'; }}
+!! endarticle
+
!! test
-WStats::USERS
+WStats::$USERS
!! input
-<phptag> echo WStats::USERS > 0 ? 'true' : 'false'; </phptag>
+<phptag> echo WStats::$USERS > 0 ? 'true' : 'false'; </phptag>
!! result
<p>true
</p>
!! end
!! test
-WStats::PAGES
+WStats::$PAGES
!! input
-<phptag> echo WStats::PAGES > 0 ? 'true' : 'false'; </phptag>
+<phptag> echo WStats::$PAGES > 0 ? 'true' : 'false'; </phptag>
!! result
<p>true
</p>
!! end
!! test
-WPage::TITLE
+WPage::$TITLE
!! options
title=[[User:Ævar Arnfjörð Bjarmason]]
!! input
-{{#phptag: WPage::TITLE }}
+{{#phptag: WPage::$TITLE }}
!! result
<p>User:Ævar Arnfjörð Bjarmason
</p>
@@ -53,20 +62,20 @@
!! test
-WPage::TITLE->name
+WPage::$TITLE->name
!! options
title=[[User:Ævar Arnfjörð Bjarmason]]
!! input
-{{#phptag: WPage::TITLE->name }}
+{{#phptag: WPage::$TITLE->name }}
!! result
<p>Ævar Arnfjörð Bjarmason
</p>
!! end
!! test
-WPage::TITLE->talkNsText
+WPage::$TITLE->talkNsText
!! input
-{{#phptag: WPage::TITLE->talkNsText }}
+{{#phptag: WPage::$TITLE->talkNsText }}
!! result
<p>Talk
</p>
@@ -80,7 +89,7 @@
echo $c->pageCount;
</phptag>
!! result
-<p>3
+<p>4
</p>
!! end
@@ -95,3 +104,13 @@
<p>1
</p>
!! end
+
+!! test
+Test default sort key
+!! input
+{{:Test default sort key}}
+!! result
+<p>false
+true
+</p>
+!! end
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/150477
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I065b67516e7546f67e3ef5b1721c20a864e464d0
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/PhpTagsWiki
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits