Skip to content

Commit e64193b

Browse files
committed
PLATFORM-10084 Upgrade extension PvXCode to MW 1.43
1 parent dbd3f3b commit e64193b

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

PvXCode.hooks.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use MediaWiki\MediaWikiServices;
4+
use MediaWiki\Parser\Parser;
5+
36
/**
47
* Curse Inc.
58
* PvX Code
@@ -18,9 +21,8 @@
1821
class PvXCodeHooks {
1922
/**
2023
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
21-
* @param Parser &$parser
24+
* @param \MediaWiki\Parser\Parser &$parser
2225
* @return true
23-
* @throws MWException
2426
*/
2527
public static function onParserFirstCallInit( Parser &$parser ): bool {
2628
// Calls PvXCode.php within the classes folder
@@ -33,10 +35,13 @@ public static function onParserFirstCallInit( Parser &$parser ): bool {
3335
* Include the third party gwbbcode library on extension regiation.
3436
* @return void
3537
*/
36-
public static function onRegistration() {
38+
public static function onRegistration(): void {
3739
// Retrieve config settings from localSettings.php -
38-
// probably a better way of doing this via "use MediaWiki\MediaWikiServices;"
39-
global $wgServer, $wgScriptPath, $wgExtensionAssetsPath;
40+
$config = MediaWikiServices::getInstance()->getMainConfig();
41+
$wgServer = $config->get( 'Server' );
42+
$wgScriptPath = $config->get( 'ScriptPath' );
43+
$wgExtensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
44+
4045

4146
// Local file path for includes
4247
define( 'GWBBCODE_ROOT', __DIR__ . '/gwbbcode' );
@@ -53,6 +58,6 @@ public static function onRegistration() {
5358
define( 'GW_WIKI_PAGE_URL', 'https://wiki.guildwars.com/wiki' );
5459

5560
// Load main script
56-
require_once( GWBBCODE_ROOT . '/gwbbcode.inc.php' );
61+
require_once GWBBCODE_ROOT . '/gwbbcode.inc.php';
5762
}
5863
}

classes/PvXCode.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
3+
use MediaWiki\Parser\Parser;
4+
use MediaWiki\Title\TitleValue;
5+
26
/**
37
* Curse Inc.
48
* PvX Code
@@ -11,7 +15,6 @@
1115
* @link https://gitlab.com/hydrawiki
1216
*
1317
*/
14-
1518
class PvXCode {
1619
/**
1720
* Parser Renderer
@@ -22,8 +25,8 @@ class PvXCode {
2225
* @return array|string|string[]|null
2326
*/
2427
public static function parserRender( string $input, array $args, Parser $parser, string $frame ) {
25-
$parser->getOutput()->addModuleStyles( 'ext.PvXCode.css' );
26-
$parser->getOutput()->addModules( 'ext.PvXCode.js' );
28+
$parser->getOutput()->addModuleStyles( [ 'ext.PvXCode.css' ] );
29+
$parser->getOutput()->addModules( [ 'ext.PvXCode.js' ] );
2730
$title = TitleValue::newFromPage( $parser->getPage() );
2831
$text = $title->getText();
2932

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
},
5252
"callback": "PvXCodeHooks::onRegistration",
5353
"manifest_version": 1
54-
}
54+
}

gwbbcode/gwbbcode.inc.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* All images, skill names and descriptions are (C) ArenaNet.
1919
***************************************************************************/
2020

21-
require_once( GWBBCODE_ROOT . '/constants.inc.php' );
21+
require_once GWBBCODE_ROOT . '/constants.inc.php';
2222

2323
/***************************************************************************
2424
* GLOBALS
@@ -39,7 +39,6 @@
3939
}
4040
$pvp_to_pve_skill_list = load( SKILLIDSPVP_PATH );
4141

42-
4342
/***************************************************************************
4443
* MAIN FUNCTION
4544
***************************************************************************/
@@ -261,10 +260,9 @@ function skill_name_replace( $reg ) {
261260
}
262261

263262
// Handle the difference between [[shock] and [shock]
264-
if ( $noicon )
263+
if ( $noicon ) {
265264
// PHP note: Use of double quotes replaces variables inside with their values
266265
// PHP note: Use of single quotes shows the variable names like JS would.
267-
{
268266
return "[skill noicon$attr$show]" . $name . '[/skill]';
269267
} else {
270268
return "[skill$attr]" . $name . '[/skill]';
@@ -318,7 +316,6 @@ function build_replace( $reg ) {
318316
$secondary_display_name = 'Any';
319317
}
320318

321-
322319
// Attributes
323320
$attributes = '';
324321
foreach ( $attr_list_raw as $attribute_name => $attribute_value ) {
@@ -334,7 +331,6 @@ function build_replace( $reg ) {
334331
$attributes = preg_replace( '/\s*\\+\s*/', ' + ', $attributes );
335332
$skills = str_replace( '[skill', '[skill ' . $att, $skills );
336333

337-
338334
// Build description
339335
$desc = preg_match( '|desc=\\"([^"]+)\\"|', $att, $reg ) ? $reg[1] : '';
340336
$desc = empty( $desc ) ? '' : ( $desc . '<br/>' );
@@ -579,8 +575,8 @@ function build_replace( $reg ) {
579575
arsort( $attr_primary );
580576
foreach ( $attr_runes as $attr => $rune ) {
581577
if ( $rune < 3 ) {
582-
$attr_primary[$attr] --;
583-
$attr_runes[$attr] ++;
578+
$attr_primary[$attr]--;
579+
$attr_runes[$attr]++;
584580
break;
585581
}
586582
}
@@ -1557,7 +1553,7 @@ function add_strength( $desc, &$extra_desc, $attr_list, $type ) {
15571553
if ( isset( $attr_list['Strength'] ) && $attr_list['Strength'] > 0 && strpos( $type, 'Attack' ) !== false ) {
15581554
// Strength does not stack with skills with inherent armor penetration
15591555
if ( preg_match( '@[Tt]his (attack|axe attack) has ([0-9]+)% armor penetration@', $desc, $reg ) ) {
1560-
if ( $reg[2] < $attr_list['Strength'] ) {
1556+
if ( $reg[2] < $attr_list['Strength'] ) {
15611557
$extra_desc =
15621558
'This attack skill has <b>' . $attr_list['Strength'] .
15631559
'</b>% armor penetration. Its inherent armor penetration is overwritten.';
@@ -1906,7 +1902,7 @@ function load( $filename ) {
19061902
if ( !file_exists( $filename ) ) {
19071903
return false;
19081904
} else {
1909-
return require( $filename );
1905+
return require $filename;
19101906
}
19111907
}
19121908

@@ -2336,5 +2332,3 @@ function bin_to_template( $bin ) {
23362332

23372333
return $ret;
23382334
}
2339-
2340-
?>

specials/SpecialPvXConvert.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use MediaWiki\SpecialPage\SpecialPage;
4+
35
/**
46
* Curse Inc.
57
* PvX Code
@@ -29,7 +31,6 @@ public function __construct() {
2931
*
3032
* @param $par - Not used, but expected to be there by mediawiki.
3133
* @return void - echos to page.
32-
* @throws MWException
3334
*/
3435
public function execute( $par = null ) {
3536
$request = $this->getRequest();

specials/SpecialPvXDecode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use MediaWiki\SpecialPage\SpecialPage;
34

45
/**
56
* Curse Inc.
@@ -24,14 +25,13 @@ class SpecialPvXDecode extends SpecialPage {
2425
public function __construct() {
2526
parent::__construct( 'PvXDecode' );
2627

27-
require_once( GWBBCODE_ROOT . '/gwbbcode.inc.php' );
28+
require_once GWBBCODE_ROOT . '/gwbbcode.inc.php';
2829
}
2930

3031
/**
3132
* Main Execute for the Specil Page
3233
* @param $par - Not used, but expected to be there by mediawiki.
3334
* @return void - echos to page.
34-
* @throws MWException
3535
*/
3636
public function execute( $par = null ) {
3737
$request = $this->getRequest();
@@ -84,4 +84,4 @@ protected function getGroupName(): string {
8484
// Change to display in a different category on Special:SpecialPages.
8585
return 'pvx';
8686
}
87-
}
87+
}

specials/SpecialPvXDownloadTemplate.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use MediaWiki\SpecialPage\SpecialPage;
4+
25
/**
36
* Curse Inc.
47
* PvX Code

0 commit comments

Comments
 (0)