diff --git a/DefaultSettings.php b/DefaultSettings.php
deleted file mode 100644
index 7cd9466..0000000
--- a/DefaultSettings.php
+++ /dev/null
@@ -1,46 +0,0 @@
- array( 'Has keywords', ... )
- */
-$GLOBALS['smtgTagsProperties'] = $GLOBALS['smtgTagsProperties'] ?? [];
-
-/**
- * Describes static content for an assigned `` tag
- *
- * 'some:tag' => 'Content that is static'
- */
-$GLOBALS['smtgTagsStrings'] = $GLOBALS['smtgTagsStrings'] ?? [];
-
-/**
- * Listed tags are generally assumed to be reserved or excluded for free use
- */
-$GLOBALS['smtgTagsBlacklist'] = $GLOBALS['smtgTagsBlacklist'] ?? [
- 'generator',
- 'robots'
-];
-
-/**
- * In case it is set `true` then the first property that returns a valid content
- * for an assigned tag will be used exclusively.
- */
-$GLOBALS['smtgTagsPropertyFallbackUsage'] = $GLOBALS['smtgTagsPropertyFallbackUsage'] ?? false;
-
-/**
- * Identifies prefixes that require `meta:property:...`
- */
-$GLOBALS['smtgMetaPropertyPrefixes'] = $GLOBALS['smtgMetaPropertyPrefixes'] ?? [ 'og:' ];
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 41e5358..769e104 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -7,6 +7,7 @@ This file contains the RELEASE-NOTES of the **Semantic Meta Tags** (a.k.a. SMT)
* Semantic MediaWiki to version 7.0 and later
* MediaWiki to version 1.43 and later
* Updated to Semantic MediaWiki 7.0's namespaced data-item classes
+* Moved the extension registration and settings defaults into `extension.json` (the `$smtgā¦` configuration variable names are unchanged)
* The major version jumps from 4.x to 7.0 to track the Semantic MediaWiki release it supports
### 4.1.1
diff --git a/SemanticMetaTags.php b/SemanticMetaTags.php
deleted file mode 100644
index d230559..0000000
--- a/SemanticMetaTags.php
+++ /dev/null
@@ -1,93 +0,0 @@
-Error: This version of SemanticMetaTags is only compatible with MediaWiki 1.27 or above. You need to upgrade MediaWiki first.' );
- }
- }
-
- /**
- * @since 1.0
- */
- public static function onExtensionFunction() {
- if ( !defined( 'SMW_VERSION' ) ) {
-
- if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
- die( "\nThe 'Semantic Meta Tags' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
- } else {
- die(
- 'Error: The Semantic Meta Tags ' .
- 'extension requires Semantic MediaWiki to be ' .
- 'installed and enabled.
'
- );
- }
- }
-
- $configuration = [
- 'metaTagsContentPropertySelector' => $GLOBALS['smtgTagsProperties'],
- 'metaTagsStaticContentDescriptor' => $GLOBALS['smtgTagsStrings'],
- 'metaTagsBlacklist' => $GLOBALS['smtgTagsBlacklist'],
- 'metaTagsFallbackUseForMultipleProperties' => $GLOBALS['smtgTagsPropertyFallbackUsage'],
- 'metaTagsMetaPropertyPrefixes' => $GLOBALS['smtgMetaPropertyPrefixes']
- ];
-
- $hookRegistry = new HookRegistry(
- ApplicationFactory::getInstance()->getStore(),
- new Options( $configuration )
- );
-
- $hookRegistry->register();
- }
-
-}
diff --git a/extension.json b/extension.json
index a6d3fcc..2d3a94c 100644
--- a/extension.json
+++ b/extension.json
@@ -20,19 +20,43 @@
"i18n"
]
},
- "callback": "SemanticMetaTags::initExtension",
"ExtensionFunctions": [
- "SemanticMetaTags::onExtensionFunction"
+ "SMT\\Setup::onExtensionFunction"
],
- "AutoloadClasses": {
- "SemanticMetaTags": "SemanticMetaTags.php"
- },
"AutoloadNamespaces": {
"SMT\\": "src/"
},
"TestAutoloadNamespaces": {
"SMT\\Tests\\": "tests/phpunit/"
},
+ "config_prefix": "smtg",
+ "config": {
+ "TagsProperties": {
+ "value": [],
+ "description": "An array of tags that assigns related properties such as `'keywords' => [ 'Has keywords', ... ]`."
+ },
+ "TagsStrings": {
+ "value": [],
+ "description": "Describes static content for an assigned `` tag such as `'some:tag' => 'Content that is static'`."
+ },
+ "TagsBlacklist": {
+ "value": [
+ "generator",
+ "robots"
+ ],
+ "description": "Listed tags are generally assumed to be reserved or excluded for free use."
+ },
+ "TagsPropertyFallbackUsage": {
+ "value": false,
+ "description": "In case it is set `true` then the first property that returns a valid content for an assigned tag will be used exclusively."
+ },
+ "MetaPropertyPrefixes": {
+ "value": [
+ "og:"
+ ],
+ "description": "Identifies prefixes that require `meta:property:...`."
+ }
+ },
"load_composer_autoloader": true,
"manifest_version": 2
}
diff --git a/src/Setup.php b/src/Setup.php
new file mode 100644
index 0000000..8d71961
--- /dev/null
+++ b/src/Setup.php
@@ -0,0 +1,35 @@
+ $GLOBALS['smtgTagsProperties'],
+ 'metaTagsStaticContentDescriptor' => $GLOBALS['smtgTagsStrings'],
+ 'metaTagsBlacklist' => $GLOBALS['smtgTagsBlacklist'],
+ 'metaTagsFallbackUseForMultipleProperties' => $GLOBALS['smtgTagsPropertyFallbackUsage'],
+ 'metaTagsMetaPropertyPrefixes' => $GLOBALS['smtgMetaPropertyPrefixes']
+ ];
+
+ $hookRegistry = new HookRegistry(
+ ApplicationFactory::getInstance()->getStore(),
+ new Options( $configuration )
+ );
+
+ $hookRegistry->register();
+ }
+
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index ba7aa74..b85d848 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,17 +12,15 @@
die( "\nThe Semantic MediaWiki test autoloader is not available" );
}
-if ( !defined( 'SMT_VERSION' ) ) {
- die( "\nSemantic Meta Tags is not available, please check your Composer or LocalSettings.php.\n" );
-}
-
$width = 20;
if ( !defined( 'SMW_PHPUNIT_FIRST_COLUMN_WIDTH' ) ) {
define( 'SMW_PHPUNIT_FIRST_COLUMN_WIDTH', $width );
}
-print sprintf( "\n%-{$width}s%s\n", "Semantic Meta Tags: ", SMT_VERSION );
+$extensionInfo = json_decode( file_get_contents( __DIR__ . '/../extension.json' ), true );
+
+print sprintf( "\n%-{$width}s%s\n", "Semantic Meta Tags: ", $extensionInfo['version'] ?? 'UNKNOWN' );
$autoLoader = require SMW_PHPUNIT_AUTOLOADER_FILE;
$autoloader->addPsr4( 'SMT\\Tests\\', __DIR__ . '/phpunit/Unit' );
diff --git a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php
index fc9c175..6bf0dfd 100644
--- a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php
+++ b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php
@@ -38,6 +38,10 @@ public function i18nFileProvider() {
$provider = [];
$location = $GLOBALS['wgMessagesDirs']['SemanticMetaTags'];
+ if ( is_array( $location ) ) {
+ $location = $location[0];
+ }
+
$bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location );
$bulkFileProvider->searchByFileExtension( 'json' );