PLATFORM-11770 pvxcode - render utility#11
Open
slayful wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a “utility framework” rendering mode for PvXCode so that [build] / [skill] BBCode can be emitted as <fandom-util.PvxCode ... /> tags (instead of legacy HTML), gated by configuration and re-run through the parser for ParserTagHookHandler processing.
Changes:
- Extended
parseGwbbcode()with autilityModeflag and introducedparseGwbbcodeUtility()to route[build]/[skill]to utility-mode callbacks. - Added utility-mode replacement helpers that emit
<fandom-util.PvxCode ... />tags. - Updated the parser hook (
PvXCode::parserRender) to enable/disable legacy ResourceLoader modules and to re-parse output in utility mode.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
gwbbcode/gwbbcode.inc.php |
Adds utility-mode parsing path and callbacks that emit Utility Framework placeholder tags. |
classes/PvXCode.php |
Adds config-gated utility mode and re-parses output so utility tags are processed by the parser. |
Comments suppressed due to low confidence (2)
gwbbcode/gwbbcode.inc.php:2391
- This comment block describes the feature gate as
$wgPvxCodeUtility/$wgEnableUtilityFramework, but there is no$wgPvxCodeUtilityusage in this repo and the actual gate inclasses/PvXCode.phpreads config keys (PvxCodeUtilityandFandomConfigNames::EnableUtilityFramework). To avoid confusion, update the comment to use the same configuration mechanism/name used by the code.
* UTILITY-FRAMEWORK MODE REPLACEMENT FUNCTIONS
*
* When $wgPvxCodeUtility (and $wgEnableUtilityFramework) are on, [build] and
* [skill] bbcode is rendered as <fandom-util.PvxCode .../> tags that the
* Fandom\GameUtility\ParserTagHookHandler turns into a placeholder for the
* @fandom-utility/pvx-code Utility Framework package.
gwbbcode/gwbbcode.inc.php:2464
skill_replace_utility()always emits a<fandom-util.PvxCode ... />tag, even when the skill name is not valid. The legacyskill_replace()returns the original text whengws_skill_id()fails; in utility mode this change can turn invalid/typoed skill names into utility placeholders instead of leaving the bbcode untouched. Consider validating withgws_skill_id()(and returning the original match when invalid) to preserve legacy behavior.
function skill_replace_utility( $reg ): string {
[ , , $name ] = $reg;
$name = html_safe_decode( $name );
return gwbbcode_utility_tag( [ 'skill' => $name ] );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
46
to
+53
| /** | ||
| * Prepares the page and then replaces gwBBCode with HTML | ||
| * This function is directly called by: extension\classes\PvXCode.php | ||
| * @param $text | ||
| * @param bool $build_name | ||
| * @param string $text | ||
| * @param string|false $build_name | ||
| * @param bool $utilityMode When true, builds and skills are rendered as | ||
| * <fandom-util.PvxCode ...> tags via {@see parseGwbbcodeUtility} instead of | ||
| * the legacy HTML pipeline. |
Comment on lines
+126
to
+128
| if ( !empty( $build_name ) && !preg_match( '#(\[build[^\]]*?) name="[^\]"]+"#isS', $text ) ) { | ||
| $text = preg_replace( '#(\[build )#is', "\\1name=\"$build_name\" ", $text ); | ||
| } |
Comment on lines
+2424
to
+2426
| $prof = gws_build_profession( $att ); | ||
| $primary = $prof !== false ? $prof['professions'] : ''; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.