diff --git a/includes/Constants.php b/includes/Constants.php index bae1c6315..cf62adb83 100644 --- a/includes/Constants.php +++ b/includes/Constants.php @@ -296,6 +296,26 @@ final class Constants { */ public const FEATURE_LANGUAGE_ALERT_IN_SIDEBAR = 'LanguageAlertInSidebar'; + /** + * @var string + */ + public const REQUIREMENT_TABLE_OF_CONTENTS = 'TableOfContents'; + + /** + * @var string + */ + public const CONFIG_TABLE_OF_CONTENTS = 'VectorTableOfContents'; + + /** + * @var string + */ + public const QUERY_PARAM_TABLE_OF_CONTENTS = 'tableofcontents'; + + /** + * @var string + */ + public const FEATURE_TABLE_OF_CONTENTS = 'TableOfContents'; + /** * This class is for namespacing constants only. Forbid construction. * @throws FatalError diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index ab9e243ce..d1f95ebca 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -191,6 +191,30 @@ return [ ] ); + // Feature: T297610: Table of Contents + // ================================ + $featureManager->registerRequirement( + new OverridableConfigRequirement( + $services->getMainConfig(), + $context->getUser(), + $context->getRequest(), + null, + Constants::CONFIG_TABLE_OF_CONTENTS, + Constants::REQUIREMENT_TABLE_OF_CONTENTS, + Constants::QUERY_PARAM_TABLE_OF_CONTENTS, + null + ) + ); + + $featureManager->registerFeature( + Constants::FEATURE_TABLE_OF_CONTENTS, + [ + Constants::REQUIREMENT_FULLY_INITIALISED, + Constants::REQUIREMENT_LATEST_SKIN_VERSION, + Constants::REQUIREMENT_TABLE_OF_CONTENTS + ] + ); + // Feature: Use Wvui Search // ================================ $featureManager->registerRequirement( diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 67b36bfcc..8a2be3e7c 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -461,6 +461,16 @@ class SkinVector extends SkinMustache { return $featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR ); } + /** + * Determines if the Table of Contents should be visible. + * + * @return bool + */ + private function isTableOfContentsVisible(): bool { + $featureManager = VectorServices::getFeatureManager(); + return $featureManager->isFeatureEnabled( Constants::FEATURE_TABLE_OF_CONTENTS ); + } + /** * @inheritDoc */ @@ -498,6 +508,8 @@ class SkinVector extends SkinMustache { 'is-language-in-content-top' => $this->isLanguagesInContentAt( 'top' ), 'is-language-in-content-bottom' => $this->isLanguagesInContentAt( 'bottom' ), + 'is-vector-table-of-contents-visible' => $this->isTableOfContentsVisible(), + 'data-search-box' => $this->getSearchData( $parentData['data-search-box'], !$this->isLegacy(), diff --git a/includes/templates/TableOfContents.mustache b/includes/templates/TableOfContents.mustache new file mode 100644 index 000000000..3f5478c1a --- /dev/null +++ b/includes/templates/TableOfContents.mustache @@ -0,0 +1,3 @@ +
diff --git a/includes/templates/skin.mustache b/includes/templates/skin.mustache index 101c08a54..e7e77a314 100644 --- a/includes/templates/skin.mustache +++ b/includes/templates/skin.mustache @@ -43,6 +43,9 @@ {{#sidebar-visible}}checked{{/sidebar-visible}}> {{>Header}} + +{{#is-vector-table-of-contents-visible}}{{>TableOfContents}}{{/is-vector-table-of-contents-visible}} +