Yaron Koren has submitted this change and it was merged.

Change subject: Renamed global vars from $ht to $wgHeaderTabs prefix
......................................................................


Renamed global vars from $ht to $wgHeaderTabs prefix

Needed for extension.json setup; plus it's the standard convention

Change-Id: I4e1601a846f7089456bc2f1cb10c1c65d1c610a9
---
M HeaderTabs.hooks.php
M HeaderTabs.php
M HeaderTabs_body.php
M skins/ext.headertabs.core.js
4 files changed, 51 insertions(+), 48 deletions(-)

Approvals:
  Yaron Koren: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/HeaderTabs.hooks.php b/HeaderTabs.hooks.php
index 7ee6f71..d6bd16c 100644
--- a/HeaderTabs.hooks.php
+++ b/HeaderTabs.hooks.php
@@ -25,7 +25,7 @@
         * on the cuurrent page, and exits if not.
         */
        public static function replaceFirstLevelHeaders( &$parser, &$text ) {
-               global $htAutomaticNamespaces;
+               global $wgHeaderTabsAutomaticNamespaces;
 
                // Remove spans added if "auto-number headings" is enabled.
                $simplifiedText = preg_replace( '/\<span 
class="mw-headline-number"\>\d*\<\/span\>/', '', $text );
@@ -34,7 +34,7 @@
                // if we don't have a stop point, then bail out
                $aboveandbelow = explode( '<div id="nomoretabs"></div>', 
$simplifiedText, 2 );
                if ( count( $aboveandbelow ) <= 1 ) {
-                       if ( in_array( $parser->getTitle()->getNamespace(), 
$htAutomaticNamespaces ) ) {
+                       if ( in_array( $parser->getTitle()->getNamespace(), 
$wgHeaderTabsAutomaticNamespaces ) ) {
                                // We'll act as if the end of article is
                                // nomoretabs.
                                $aboveandbelow[] = '';
@@ -47,10 +47,10 @@
        }
 
        public static function addConfigVarsToJS( &$vars ) {
-               global $htUseHistory, $htEditTabLink;
+               global $wgHeaderTabsUseHistory, $wgHeaderTabsEditTabLink;
 
-               $vars['htUseHistory'] = $htUseHistory;
-               $vars['htEditTabLink'] = $htEditTabLink;
+               $vars['wgHeaderTabsUseHistory'] = $wgHeaderTabsUseHistory;
+               $vars['wgHeaderTabsEditTabLink'] = $wgHeaderTabsEditTabLink;
 
                return true;
        }
@@ -60,15 +60,15 @@
         * @return bool
         */
        public static function addHTMLHeader( &$out ) {
-               global $htScriptPath, $htStyle;
+               global $wgHeaderTabsScriptPath, $wgHeaderTabsStyle;
 
                //! @todo we might be able to only load our js and styles if we 
are rendering tabs, speeding up pages that don't use it? but what about cached 
pages? (2011-12-12, ofb)
 
                $out->addModules( 'ext.headertabs' );
 
                // Add the CSS file for the specified style.
-               if ( !empty( $htStyle ) && $htStyle !== 'jquery' ) {
-                       $styleFile = $htScriptPath . '/skins/ext.headertabs.' . 
$htStyle . '.css';
+               if ( !empty( $wgHeaderTabsStyle ) && $wgHeaderTabsStyle !== 
'jquery' ) {
+                       $styleFile = $wgHeaderTabsScriptPath . 
'/skins/ext.headertabs.' . $wgHeaderTabsStyle . '.css';
                        $out->addExtensionStyle( $styleFile );
                }
 
@@ -76,8 +76,8 @@
        }
 
        static function setGlobalJSVariables( &$vars ) {
-               global $htTabIndexes;
-               $vars['htTabIndexes'] = $htTabIndexes;
+               global $wgHeaderTabsTabIndexes;
+               $vars['wgHeaderTabsTabIndexes'] = $wgHeaderTabsTabIndexes;
                return true;
        }
 }
diff --git a/HeaderTabs.php b/HeaderTabs.php
index 47d7e89..5b2bfbd 100644
--- a/HeaderTabs.php
+++ b/HeaderTabs.php
@@ -10,9 +10,7 @@
  * @author Olivier Finlay Beaton
  */
 
-$htScriptPath = $wgScriptPath . '/extensions/HeaderTabs';
-
-$dir = dirname( __FILE__ );
+if ( !defined( 'MEDIAWIKI' ) ) die();
 
 $wgExtensionCredits['parserhook'][] = array(
        'path' => __FILE__,
@@ -23,8 +21,10 @@
        'url' => 'https://www.mediawiki.org/wiki/Extension:Header_Tabs'
 );
 
+$dir = dirname( __FILE__ );
+
 // Translations
-$wgMessagesDirs['HeaderTabs'] = __DIR__ . '/i18n';
+$wgMessagesDirs['HeaderTabs'] = $dir . '/i18n';
 $wgExtensionMessagesFiles['HeaderTabs'] = $dir . '/HeaderTabs.i18n.php';
 
 //! @todo implement in tab parsing code instead... but problems like nowiki 
(2011-12-12, ofb)
@@ -35,17 +35,18 @@
 $wgExtensionMessagesFiles['HeaderTabsMagic'] = $dir . 
'/HeaderTabs.i18n.magic.php';
 
 // Config
-$htUseHistory = true;
-$htRenderSingleTab = false;
-$htAutomaticNamespaces = array();
-$htDefaultFirstTab = false;
-$htDisableDefaultToc = true;
-$htGenerateTabTocs = false;
-$htStyle = 'large';
-$htEditTabLink = true;
+$wgHeaderTabsScriptPath = $wgScripPath . "/extensions/HeaderTabs";
+$wgHeaderTabsUseHistory = true;
+$wgHeaderTabsRenderSingleTab = false;
+$wgHeaderTabsAutomaticNamespaces = array();
+$wgHeaderTabsDefaultFirstTab = false;
+$wgHeaderTabsDisableDefaultToc = true;
+$wgHeaderTabsGenerateTabTocs = false;
+$wgHeaderTabsStyle = 'large';
+$wgHeaderTabsEditTabLink = true;
 
 // Other variables
-$htTabIndexes = array();
+$wgHeaderTabsTabIndexes = array();
 
 // Extension:Configure
 if ( isset( $wgConfigureAdditionalExtensions ) && is_array( 
$wgConfigureAdditionalExtensions ) ) {
@@ -57,17 +58,17 @@
        $wgConfigureAdditionalExtensions[] = array(
                        'name' => 'HeaderTabs',
                        'settings' => array(
-                                       'htUseHistory' => 'bool',
-                                       'htRenderSingleTab' => 'bool',
-                                       'htAutomaticNamespaces' => 'array',
-                                       'htDefaultFirstTab' => 'string',
-                                       'htDisableDefaultToc' => 'bool',
-                                       'htGenerateTabTocs' => 'bool',
-                                       'htStyle' => 'string',
-                                       'htEditTabLink' => 'bool',
+                                       'wgHeaderTabsUseHistory' => 'bool',
+                                       'wgHeaderTabsRenderSingleTab' => 'bool',
+                                       'wgHeaderTabsAutomaticNamespaces' => 
'array',
+                                       'wgHeaderTabsDefaultFirstTab' => 
'string',
+                                       'wgHeaderTabsDisableDefaultToc' => 
'bool',
+                                       'wgHeaderTabsGenerateTabTocs' => 'bool',
+                                       'wgHeaderTabsStyle' => 'string',
+                                       'wgHeaderTabsEditTabLink' => 'bool',
                                ),
                        'array' => array(
-                                       'htAutomaticNamespaces' => 'simple',
+                                       'wgHeaderTabsAutomaticNamespaces' => 
'simple',
                                ),
                        'schema' => false,
                        'url' => 
'https://www.mediawiki.org/wiki/Extension:Header_Tabs',
diff --git a/HeaderTabs_body.php b/HeaderTabs_body.php
index dde7e8e..1a64a19 100644
--- a/HeaderTabs_body.php
+++ b/HeaderTabs_body.php
@@ -19,8 +19,10 @@
 
        public static function replaceFirstLevelHeaders( &$parser, &$text, 
$aboveandbelow ) {
                global $wgVersion;
-               global $htRenderSingleTab, $htDefaultFirstTab, 
$htDisableDefaultToc, $htGenerateTabTocs, $htStyle, $htEditTabLink;
-               global $htTabIndexes;
+               global $wgHeaderTabsRenderSingleTab, 
$wgHeaderTabsDefaultFirstTab,
+                       $wgHeaderTabsDisableDefaultToc, 
$wgHeaderTabsGenerateTabTocs,
+                       $wgHeaderTabsStyle, $wgHeaderTabsEditTabLink,
+                       $wgHeaderTabsTabIndexes;
 
                //! @todo handle __NOTABTOC__, __TABTOC__, __FORCETABTOC__ here 
(2011-12-12, ofb)
 
@@ -72,9 +74,9 @@
                $above = '';
 
                // auto tab and the first thing isn't a header (note we already 
removed the default toc, add it back later if needed)
-               if ( $htDefaultFirstTab !== FALSE && $parts[0] !== '' ) {
+               if ( $wgHeaderTabsDefaultFirstTab !== FALSE && $parts[0] !== '' 
) {
                        // add the default header
-                       $headline = '<h1><span class="mw-headline" 
id="'.str_replace(' ', '_', 
$htDefaultFirstTab).'">'.$htDefaultFirstTab.'</span></h1>';
+                       $headline = '<h1><span class="mw-headline" 
id="'.str_replace(' ', '_', 
$wgHeaderTabsDefaultFirstTab).'">'.$wgHeaderTabsDefaultFirstTab.'</span></h1>';
                        array_unshift( $parts, $headline );
                        $above = ''; // explicit
                } else {
@@ -83,7 +85,7 @@
                        array_shift( $parts ); // don't need above part anyway
                }
 
-               $partslimit = $htRenderSingleTab ? 2 : 4;
+               $partslimit = $wgHeaderTabsRenderSingleTab ? 2 : 4;
 
                wfDebugLog('headertabs', __METHOD__.': parts (limit 
'.$partslimit.'): '.count($parts));
                if ( $above !== '' ) {
@@ -97,7 +99,7 @@
                wfDebugLog('headertabs', __METHOD__.': split count OK, 
continuing');
 
                // disable default TOC
-               if ( $htDisableDefaultToc ) {
+               if ( $wgHeaderTabsDisableDefaultToc ) {
                        // if it was somewhere else, we need to remove it
                        if ( count( $tocmatches ) > 0 && $tocmatches[0][1] !== 
0 ) {
                                wfDebugLog('headertabs', __METHOD__.': removed 
non-standard-pos TOC');
@@ -130,7 +132,7 @@
                        preg_match( $tabpatternmatch, $parts[$i * 2], $matches 
);
 
                        // if this is a default tab, don't increment our 
section number
-                       if ( $s !== 0 || $i !== 0 || $htDefaultFirstTab === 
FALSE || $matches[3] !== $htDefaultFirstTab ) {
+                       if ( $s !== 0 || $i !== 0 || 
$wgHeaderTabsDefaultFirstTab === FALSE || $matches[3] !== 
$wgHeaderTabsDefaultFirstTab ) {
                                ++$s;
                        }
 
@@ -164,7 +166,7 @@
                        }
 
                        //! @todo handle __TOC__, __FORCETOC__, __NOTOC__ here 
(2011-12-12, ofb)
-                       if ( $htGenerateTabTocs ) {
+                       if ( $wgHeaderTabsGenerateTabTocs ) {
                                // really? that was it?
                                // maybe a better way then clone... 
formatHeadings changes properties on the parser which we don't want to do
                                // would be better to have a 'clean' parser so 
the tab was treated as a new page
@@ -220,13 +222,13 @@
                wfDebugLog( 'headertabs', __METHOD__ . ': generated ' . count( 
$tabs ) . ' tabs' );
 
                $tabhtml = '<div id="headertabs"';
-               if (!empty($htStyle) && $htStyle !== 'jquery') {
-                       $tabhtml .= ' class="'.$htStyle.'"';
+               if (!empty($wgHeaderTabsStyle) && $wgHeaderTabsStyle !== 
'jquery') {
+                       $tabhtml .= ' class="'.$wgHeaderTabsStyle.'"';
                }
                $tabhtml .= '>';
 
                //! @todo handle __NOEDITTAB__ here (2011-12-12, ofb)
-               if ( $htEditTabLink ) {
+               if ( $wgHeaderTabsEditTabLink ) {
                        $tabhtml .= '<span class="ht-editsection" 
id="edittab">[<a href="" 
title="'.wfMessage('headertabs-edittab-hint')->text().'">'.wfMessage('headertabs-edittab')->text().'</a>]</span>';
                }
 
@@ -259,7 +261,7 @@
 
                foreach ( $tabs as $i => $tab ) {
                        $tabTitle = str_replace( ' ', '_', $tab['title'] );
-                       $htTabIndexes[$tabTitle] = $i;
+                       $wgHeaderTabsTabIndexes[$tabTitle] = $i;
                }
 
                return true;
diff --git a/skins/ext.headertabs.core.js b/skins/ext.headertabs.core.js
index 3ee8b07..8fabdd3 100644
--- a/skins/ext.headertabs.core.js
+++ b/skins/ext.headertabs.core.js
@@ -84,18 +84,18 @@
 }
 
 // page load behaviour
-if (mw.config.get("htEditTabLink")) {
+if (mw.config.get("wgHeaderTabsEditTabLink")) {
        tabEditTabLink(window.location.hash);
 }
 
 // only fires when the user clicks on a tab, not on page load
 $tabs.bind('tabsshow', function(event, ui) {
        // make the url show the current tab name for bookmarks
-       if (mw.config.get("htUseHistory")) {
+       if (mw.config.get("wgHeaderTabsUseHistory")) {
                window.location.hash = '#tab='+ui.tab.hash.slice(1);
        }
 
-       if (mw.config.get("htEditTabLink")) {
+       if (mw.config.get("wgHeaderTabsEditTabLink")) {
                tabEditTabLink(ui.tab.hash);
        }
 });
@@ -103,7 +103,7 @@
 /* click a tab parserhook link */
 $(".tabLink").click( function() {
        var tabName = $(this).attr('href').replace('#tab=', '');
-       var tabIndex = htTabIndexes[tabName];
+       var tabIndex = wgHeaderTabsTabIndexes[tabName];
        $tabs.tabs('select', tabIndex ); //tabNameEscape(href));
        return false;
 } );

-- 
To view, visit https://gerrit.wikimedia.org/r/232059
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e1601a846f7089456bc2f1cb10c1c65d1c610a9
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/HeaderTabs
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to