Yaron Koren has submitted this change and it was merged.
Change subject: Some improvements to SemanticForms extension.json
......................................................................
Some improvements to SemanticForms extension.json
Lets use $GLOBALS['']
Also move some code to use ExtensionFunction since using a callback seems
to not show the error but really it loads the code after it processes the
file.
Change-Id: I04679e8f6f895b97b7bafd36916aeb2e79d3dd25
---
M extension.json
M includes/SF_Utils.php
2 files changed, 28 insertions(+), 32 deletions(-)
Approvals:
Yaron Koren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index 2480fca..8663f3e 100644
--- a/extension.json
+++ b/extension.json
@@ -11,6 +11,12 @@
"descriptionmsg": "semanticforms-desc",
"type": "specialpage",
"callback": "SFUtils::registerExtension",
+ "ExtensionFunctions": [
+ "SFUtils::initialize"
+ ],
+ "requires": {
+ "MediaWiki": ">= 1.26.0"
+ },
"GroupPermissions": {
"*": {
"viewedittab": true
diff --git a/includes/SF_Utils.php b/includes/SF_Utils.php
index dcb8edc..5462858 100644
--- a/includes/SF_Utils.php
+++ b/includes/SF_Utils.php
@@ -10,10 +10,6 @@
class SFUtils {
public static function registerExtension() {
- global $wgResourceBasePath, $sfgScriptPath, $sfgPartialPath,
$sfgIP, $wgEditPageFrameOptions,
- $smwgEnabledSpecialPage, $wgExtensionFunctions, $wgSpecialPages,
- $wgAutoloadClasses, $sfgContLang, $sfgFormPrinter,
$wgLanguageCode;
-
if ( defined( 'SF_VERSION' ) ) {
// Do not load Semantic Forms more than once.
return 1;
@@ -27,9 +23,7 @@
define( 'SF_NS_FORM_TALK', 107 );
}
- $sfgScriptPath = __DIR__ . '/../';
-
- $sfgIP = dirname( __FILE__ );
+ $GLOBALS['sfgIP'] = dirname( __FILE__ );
// Constants for special properties
define( 'SF_SP_HAS_DEFAULT_FORM', 1 );
@@ -46,28 +40,10 @@
// This global variable is needed so that other
// extensions can hook into it to add their own
// input types.
- if ( defined( 'SMW_VERSION' ) ) {
- $GLOBALS['wgExtensionFunctions'][] = function() {
- $GLOBALS['sfgFormPrinter'] = new StubObject(
'sfgFormPrinter', 'SFFormPrinter' );
- };
- } else {
- $GLOBALS['sfgFormPrinter'] = new StubObject(
'sfgFormPrinter', 'SFFormPrinter' );
- }
if ( defined( 'SMW_VERSION' ) ) {
- // Admin Links hook needs to be called in a delayed way
so that it
- // will always be called after SMW's Admin Links
addition; as of
- // SMW 1.9, SMW delays calling all its hook functions.
- $GLOBALS['wgExtensionFunctions'][] = function() {
- $GLOBALS['wgHooks']['AdminLinks'][] =
'SFUtils::addToAdminLinks';
- };
- } else {
- $GLOBALS['wgHooks']['AdminLinks'][] =
'SFUtils::addToAdminLinks';
- }
-
- if ( defined( 'SMW_VERSION' ) ) {
- $wgSpecialPages['CreateProperty'] = 'SFCreateProperty';
- $wgAutoloadClasses['SFCreateProperty'] = __DIR__ .
'/../specials/SF_CreateProperty.php';
+ $GLOBALS['wgSpecialPages']['CreateProperty'] =
'SFCreateProperty';
+ $GLOBALS['wgAutoloadClasses']['SFCreateProperty'] =
__DIR__ . '/specials/SF_CreateProperty.php';
}
/**
@@ -76,11 +52,11 @@
* determine labels for additional namespaces. In contrast,
messages
* can be initialised much later, when they are actually needed.
*/
- if ( !empty( $sfgContLang ) ) {
+ if ( !empty( $GLOBALS['sfgContLang'] ) ) {
return;
}
- $cont_lang_class = 'SF_Language' . str_replace( '-', '_',
ucfirst( $wgLanguageCode ) );
+ $cont_lang_class = 'SF_Language' . str_replace( '-', '_',
ucfirst( $GLOBALS['wgLanguageCode'] ) );
if ( file_exists( __DIR__ . '/../languages/' . $cont_lang_class
. '.php' ) ) {
include_once( __DIR__ . '/../languages/' .
$cont_lang_class . '.php' );
}
@@ -91,13 +67,27 @@
$cont_lang_class = 'SF_LanguageEn';
}
- $sfgContLang = new $cont_lang_class();
+ $GLOBALS['sfgContLang'] = new $cont_lang_class();
// Allow for popup windows for file upload
- $wgEditPageFrameOptions = 'SAMEORIGIN';
+ $GLOBALS['wgEditPageFrameOptions'] = 'SAMEORIGIN';
// Necessary setting for SMW 1.9+
- $smwgEnabledSpecialPage[] = 'RunQuery';
+ $GLOBALS['smwgEnabledSpecialPage'][] = 'RunQuery';
+ }
+
+ public static function initialize() {
+ $GLOBALS['sfgScriptPath'] = __DIR__ . '/../';
+
+ // Admin Links hook needs to be called in a delayed way so that
it
+ // will always be called after SMW's Admin Links addition; as of
+ // SMW 1.9, SMW delays calling all its hook functions.
+ $GLOBALS['wgHooks']['AdminLinks'][] =
'SFUtils::addToAdminLinks';
+
+ // This global variable is needed so that other
+ // extensions can hook into it to add their own
+ // input types.
+ $GLOBALS['sfgFormPrinter'] = new StubObject( 'sfgFormPrinter',
'SFFormPrinter' );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/267411
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I04679e8f6f895b97b7bafd36916aeb2e79d3dd25
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Kghbln <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: Reedy <[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