diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..6f59b5c --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,28 @@ +filter: + excluded_paths: + - 'vendor/*' + +tools: + php_mess_detector: + config: + controversial_rules: { superglobals: false } + php_cpd: true + php_pdepend: true + php_code_coverage: false + php_code_sniffer: true + php_cs_fixer: true + php_loc: true + php_analyzer: true + sensiolabs_security_checker: true + external_code_coverage: + timeout: '900' + +checks: + php: + psr2_class_declaration: false + psr2_switch_declaration: false + sql_injection_vulnerabilities: true + security_vulnerabilities: true + no_eval: true + code_rating: true + duplication: true diff --git a/README.md b/README.md index 46081e3..56bef34 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ The recommended way to install Semantic Forms Select is by using [Composer][comp ```json { "require": { - "mediawiki/semantic-forms-select": "~1.2" + "mediawiki/semantic-forms-select": "~1.3" } } ``` 1. From your MediaWiki installation directory, execute - `composer require mediawiki/semantic-forms-select:~1.2` + `composer require mediawiki/semantic-forms-select:~1.3` 2. Navigate to _Special:Version_ on your wiki and verify that the package have been successfully installed. diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md new file mode 100644 index 0000000..cd88519 --- /dev/null +++ b/RELEASE-NOTES.md @@ -0,0 +1,10 @@ +This file contains the RELEASE-NOTES of the Semantic Forms Select (a.k.a. SFS) extension. + +### 1.3.0 (2015-11-??) + +* Added the `SFS` PHP namespace +* Added full Composer compatibility and autoloading (PSR-4) +* Added stricter control over how the `scriptSelect.js` is being used (removed JS elements from PHP) and accessed from MediaWiki +* Added `ResourceLoader` support +* Added unit tests and general test coverage support +* Fixed parser call from `Special:FormEdit/DemoAjax1` diff --git a/SemanticFormsSelect.php b/SemanticFormsSelect.php index a1fb515..ea32ab4 100644 --- a/SemanticFormsSelect.php +++ b/SemanticFormsSelect.php @@ -23,12 +23,14 @@ return 1; } -define( 'SFS_VERSION', '1.3.0-alpha' ); +define( 'SFS_VERSION', '1.3.0' ); -//self executing anonymous function to prevent global scope assumptions +/** + * @codeCoverageIgnore + */ call_user_func( function() { - $GLOBALS['wgExtensionCredits'][defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array( + $GLOBALS['wgExtensionCredits']['semantic'][] = array( 'path' => __FILE__, 'name' => 'Semantic Forms Select', 'author' =>array( 'Jason Zhang', 'Toni Hermoso Pulido', '...' ), @@ -38,33 +40,27 @@ 'license-name' => 'GPL-2.0+', ); - //$wgAjaxExportList[] = "QueryExecution"; - //$wgAjaxExportList[] = "FunctionExecution"; - $GLOBALS['wgExtensionFunctions'][] = function() { - $GLOBALS['sfgFormPrinter']->setInputTypeHook( 'SF_Select', '\SFS\SemanticFormsSelect::init', array() ); - }; - - $GLOBALS['wgAutoloadClasses']['SFS\SemanticFormsSelect'] = __DIR__ . '/src/SemanticFormsSelect.php'; - $GLOBALS['wgAutoloadClasses']['SFS\ApiSemanticFormsSelect'] = __DIR__ . '/src/ApiSemanticFormsSelect.php'; - $GLOBALS['wgAutoloadClasses']['SFS\ApiRequestProcessor'] = __DIR__ . '/src/ApiRequestProcessor.php'; - $GLOBALS['wgAutoloadClasses']['SFS\Output'] = __DIR__ . '/src/Output.php'; - - // api modules + // Api modules $GLOBALS['wgAPIModules']['sformsselect'] = 'SFS\ApiSemanticFormsSelect'; - $GLOBALS['wgSF_SelectDir'] = dirname(__FILE__) ; - $GLOBALS['wgSF_SelectScriptPath'] = $GLOBALS['wgScriptPath'] . '/extensions/'.basename($GLOBALS['wgSF_SelectDir']); - $GLOBALS['wgScriptSelectCount'] = 0; $GLOBALS['wgSF_Select_debug'] = 0; + // Register resource files + $extensionPathParts = explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR , __DIR__, 2 ); + $GLOBALS['wgResourceModules']['ext.sf_select.scriptselect'] = array( - 'localBasePath' => $GLOBALS['wgSF_SelectDir'], - 'remoteExtPath' => 'SemanticFormsSelect', + 'localBasePath' => __DIR__ , + 'remoteExtPath' => end( $extensionPathParts ), + 'position' => 'bottom', 'scripts' => array( 'res/scriptSelect.js' ), 'dependencies' => array( 'ext.semanticforms.main' ) ); + $GLOBALS['wgExtensionFunctions'][] = function() { + $GLOBALS['sfgFormPrinter']->setInputTypeHook( 'SF_Select', '\SFS\SemanticFormsSelect::init', array() ); + }; + } ); diff --git a/src/SemanticFormsSelect.php b/src/SemanticFormsSelect.php index 2ef596c..9157aee 100644 --- a/src/SemanticFormsSelect.php +++ b/src/SemanticFormsSelect.php @@ -48,7 +48,7 @@ public static function init( $value, $inputName, $isMandatory, $isDisabled, $oth } public function select ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { - global $wgScriptPath,$wgSF_SelectDir, $wgScriptSelectCount, $sfgFieldNum, $wgUser,$wgSF_SelectScriptPath; + global $wgScriptSelectCount, $sfgFieldNum, $wgUser; $selectField = array(); $values = null;