Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@
"composer sqllint"
],
"fix": "phpcbf"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
15 changes: 15 additions & 0 deletions src/Helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Liquipedia\Extension\TournamentsMenu;

class Helper {

public static function unwrapHtml( string $html ): string {
return substr(
$html,
strlen( '<div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">' ),
-strlen( '</div>' )
);
}

}
13 changes: 3 additions & 10 deletions src/Hooks/MainHookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Liquipedia\Extension\TournamentsMenu\Hooks;

use Liquipedia\Extension\TournamentsMenu\Data;
use Liquipedia\Extension\TournamentsMenu\Helper;
use MediaWiki\Hook\ParserFirstCallInitHook;
use MediaWiki\Hook\SkinBuildSidebarHook;
use Title;
Expand Down Expand Up @@ -70,11 +71,7 @@ public function onSkinBuildSidebar( $skin, &$bar ) {
false
);
if ( strpos( $iconHTML, 'mw-parser-output' ) !== false ) {
$iconHTML = substr(
$iconHTML,
strlen( '<div class="mw-parser-output">' ),
-strlen( '</div>' )
);
$iconHTML = Helper::unwrapHtml( $iconHTML );
}
$text = $iconHTML . ' ' . $text;
}
Expand All @@ -95,11 +92,7 @@ public function onSkinBuildSidebar( $skin, &$bar ) {
false
);
if ( strpos( $iconHTML, 'mw-parser-output' ) !== false ) {
$iconHTML = substr(
$iconHTML,
strlen( '<div class="mw-parser-output">' ),
-strlen( '</div>' )
);
$iconHTML = Helper::unwrapHtml( $iconHTML );
}
$text = $iconHTML . ' ' . $text;
}
Expand Down
12 changes: 2 additions & 10 deletions src/ParserFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ public static function getTournamentsList( $content, $attributes, $parser, $fram
)->getText();
$parserOptions->setOption( 'enableLimitReport', $wasParserReportEnabled );
if ( strpos( $iconHTML, 'mw-parser-output' ) !== false ) {
$iconHTML = substr(
$iconHTML,
strlen( '<div class="mw-parser-output">' ),
-strlen( '</div>' )
);
$iconHTML = Helper::unwrapHtml( $iconHTML );
}
$return .= Parser::stripOuterParagraph( $iconHTML );
}
Expand Down Expand Up @@ -121,11 +117,7 @@ public static function getTournamentsList( $content, $attributes, $parser, $fram
)->getText();
$parserOptions->setOption( 'enableLimitReport', $wasParserReportEnabled );
if ( strpos( $iconHTML, 'mw-parser-output' ) !== false ) {
$iconHTML = substr(
$iconHTML,
strlen( '<div class="mw-parser-output">' ),
-strlen( '</div>' )
);
$iconHTML = Helper::unwrapHtml( $iconHTML );
}
$return .= Parser::stripOuterParagraph( $iconHTML );
}
Expand Down