r82583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82582‎ | r82583 | r82584 >
Date:23:47, 21 February 2011
Author:yaron
Status:deferred
Tags:
Comment:
Simplified (handling for MW < 1.16 isn't necessary); added fix for tabs with forward slash in their name
Modified paths:
  • /trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php (modified) (history)

Diff [purge]

Index: trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php
@@ -32,36 +32,24 @@
3333
3434 $tabs = array();
3535
36 - $v = explode( '.', $wgVersion );
37 - if ( $v[0] > 1 || ( $v[0] == 1 && $v[1] >= 16 ) ) {
38 - $parts = preg_split( '/(<h1.*?class="mw-headline".*?<\/h1>)/', $aboveandbelow[0], - 1, PREG_SPLIT_DELIM_CAPTURE );
39 - array_shift( $parts ); // don't need above part anyway
 36+ $parts = preg_split( '/(<h1.*?class="mw-headline".*?<\/h1>)/', $aboveandbelow[0], - 1, PREG_SPLIT_DELIM_CAPTURE );
 37+ array_shift( $parts ); // don't need above part anyway
4038
41 - for ( $i = 0; $i < ( count( $parts ) / 2 ); $i++ )
42 - {
43 - preg_match( '/id="(.*?)"/', $parts[$i * 2], $matches );
44 - $tabid = $matches[1];
 39+ for ( $i = 0; $i < ( count( $parts ) / 2 ); $i++ ) {
 40+ preg_match( '/id="(.*?)"/', $parts[$i * 2], $matches );
 41+ // Forward slashes in tab IDs cause a problem
 42+ // in the jQuery UI tabs() function - just
 43+ // replace them with an underline.
 44+ $tabid = str_replace('/', '_', $matches[1]);
4545
46 - preg_match( '/<span.*?class="mw-headline".*?>\s*(.*?)\s*<\/h1>/', $parts[$i * 2], $matches );
47 - $tabtitle = $matches[1];
 46+ preg_match( '/<span.*?class="mw-headline".*?>\s*(.*?)\s*<\/h1>/', $parts[$i * 2], $matches );
 47+ $tabtitle = $matches[1];
4848
49 - array_push( $tabs, array(
50 - 'tabid' => $tabid,
51 - 'title' => $tabtitle,
52 - 'tabcontent' => $parts[$i * 2 + 1]
53 - ) );
54 - }
55 - } else {
56 - $parts = preg_split( '/<a name="(.*?)"><\/a><h1>.*?<span class="mw-headline">\s*(.*?)\s*<\/span><\/h1>/', $aboveandbelow[0], - 1, PREG_SPLIT_DELIM_CAPTURE );
57 - array_shift( $parts ); // don't need above part anyway
58 -
59 - for ( $i = 0; $i < ( count( $parts ) / 3 ); $i++ ) {
60 - array_push( $tabs, array(
61 - 'tabid' => $parts[$i * 3],
62 - 'title' => $parts[$i * 3 + 1],
63 - 'tabcontent' => $parts[$i * 3 + 2]
64 - ) );
65 - }
 49+ array_push( $tabs, array(
 50+ 'tabid' => $tabid,
 51+ 'title' => $tabtitle,
 52+ 'tabcontent' => $parts[$i * 2 + 1]
 53+ ) );
6654 }
6755
6856 $tabhtml = '<div id="headertabs">';

Follow-up revisions

RevisionCommit summaryAuthorDate
r90863Follow-up to r82583 - this time, an actual fix (I think) for slashes in tab n...yaron23:36, 26 June 2011

Status & tagging log