Topic on Extension talk:Header Tabs

Is $wgHeaderTabsGenerateTabTocs = true; not working ?

1
Megajoule (talkcontribs)

MediaWiki 1.35.0, HeaderTabs 2.0

Solution : change that in HeaderTabs\includes\HeaderTabs.php

133 		$s = 0;
134 
135 		$titleCount= array() ;
183                 $tocparser = clone $parser;
184 				$tabtocraw = $tocparser->internalParse( $content );
185 				$tocpattern = '%<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang=".+?" dir="ltr"><h2 id="mw-toc-heading">.+?</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>' . "\n+" . '(<ul>' . "\n+" . '.+?</ul>)' . "\n+" . '</div>' . "\n+" . '%ms';
186 				if ( preg_match( $tocpattern, $tabtocraw, $tabtocmatches ) === 1 ) {
187 					wfDebugLog( 'headertabs', __METHOD__ . ': generated toc for tab' );
188 					$tabtocraw = $tabtocmatches[0];
189 					$tabtoc = $tabtocraw;
190 
191 					if ($parser->mOptions->getNumberHeadings () == true) {             
192 						$itempattern = '/<li class="toclevel-[0-9]+"><a href="(#[^"]+)"><span class="tocnumber">[0-9.]+<\/span> <span class="toctext">(<span><span>[0-9.]+<\/span>([^<]+)<\/span>[^<]+)<\/span><\/a>/';                   
193 					} else {
194 						$itempattern = '/<li class="toclevel-[0-9]+"><a href="(#[^"]+)"><span class="tocnumber">[0-9.]+<\/span> <span class="toctext">(<span>([^<]+)<\/span>[^<]+)<\/span><\/a>/';   
195 					}
196 
197 					if ( preg_match_all( $itempattern, $tabtocraw, $tabtocitemmatches, PREG_SET_ORDER ) > 0 ) {
198 						foreach ( $tabtocitemmatches as $match ) {
199 							$newitem = $match[0];
200 							if ( count( $matches ) == 4 ) {
201 								$titleLink = str_replace("&#160;", "_", trim( $match[3] )); // remplacement des espaces insécables
202 								$titleLink = '#' .str_replace(" ", "_", $titleLink );
203 								if (array_key_exists($titleLink, $titleCount)) { 
204 									$titleCount[$titleLink] = $titleCount[$titleLink] + 1;
205 									$titleLink = $titleLink . "_" . $titleCount[$titleLink];
206 								} else {
207 									$titleCount[$titleLink] = 1;
208 								}
209 								$newitem = str_replace( $match[1], $titleLink, $newitem );
210 								$newitem = str_replace( $match[2], trim( $match[3] ), $newitem );
211 							}
212 							$tabtoc = str_replace( $match[0], $newitem, $tabtoc );
213 						}
214 						$content = $tabtoc . $content;
215 					}
216 				}