Skip to content

Commit

Permalink
Load values of template parameters with <tab> elements
Browse files Browse the repository at this point in the history
Per https://www.mediawiki.org/wiki/Topic:Vz6g8rf7z9p2nlbj

Change-Id: I1422ac26e40bd00dab300de63c9333d7a0497b96
  • Loading branch information
Youri van den Bogert authored and jdforrester committed Aug 31, 2022
1 parent f9fb34e commit 4b1529d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions includes/Tabs.php
Expand Up @@ -54,9 +54,10 @@ public static function init( &$parser ) {
* @param string $input
* @param array $attr
* @param Parser $parser
* @param bool|PPFrame $frame
* @return string
*/
public function renderTab( $input, $attr = [], $parser ) {
public function renderTab( $input, $attr = [], $parser, $frame ) {
$form = $parser->tabsData['tabCount'] === 0 ? $this->insertCSSJS( $parser ) : ''; // init styles, set the return <form> tag as $form.
++$parser->tabsData['tabCount'];
$names = &$parser->tabsData['tabNames'];
Expand Down Expand Up @@ -123,7 +124,7 @@ public function renderTab( $input, $attr = [], $parser ) {
if ( $input === null ) { return ''; // return empty string if the tag is self-closing. This can be used to pre-define tabs for referring to via the index later.
}
$parser->tabsData['nested'] = false; // temporary
$newstr = $parser->recursiveTagParse( $input );
$newstr = $parser->recursiveTagParse( $input, $frame );
$parser->tabsData['nested'] = $nested; // revert
return $form . $container[0] . '<' . $container[2] . $container[3] . ">$newstr</" . $container[2] . '>' . $container[1];
}
Expand Down Expand Up @@ -218,9 +219,10 @@ public function renderBox( $input, &$attr = [], $parser ) {
* @param string $input
* @param array $attr
* @param Parser $parser
* @param bool|PPFrame $frame
* @return string
*/
public function renderTabs( $input, $attr = [], $parser ) {
public function renderTabs( $input, $attr = [], $parser, $frame ) {
if ( !isset( $input ) ) { return ''; // Exit if the tag is self-closing. <tabs> is a container element, so should always have something in it.
}
$form = $parser->tabsData['tabCount'] === 0 ? $this->insertCSSJS( $parser ) : ''; // init styles, set the return <form> tag as $form.
Expand All @@ -244,7 +246,7 @@ public function renderTabs( $input, $attr = [], $parser ) {
$parser->tabsData['labels'] = []; // Reset after previous usage
$parser->tabsData['nested'] = true;
// PARSING
$newstr = $parser->recursiveTagParse( $input );
$newstr = $parser->recursiveTagParse( $input, $frame );
// AND RESETTING (to their original values):
$parser->tabsData['tabNames'] = $tabnames; // reset to the value it had before parsing the nested <tab>s. All nested <tab>s are "forgotten".
$parser->tabsData['nested'] = false; // reset
Expand Down

0 comments on commit 4b1529d

Please sign in to comment.