[MediaWiki-commits] [Gerrit] Refactored SemanticGlossaryBackend - change (mediawiki...SemanticGlossary)
Foxtrott has submitted this change and it was merged. Change subject: Refactored SemanticGlossaryBackend .. Refactored SemanticGlossaryBackend - Encapsulated LingoBackend using \SG\LingoBackendAdapter - Added \SG\Cache\ElementsCacheBuilder Change-Id: Id59164a9cc2c34a777313fb12524ceedf35801e5 --- A README.md M SemanticGlossary.php D SemanticGlossaryBackend.php D SemanticGlossaryCacheHandling.php A src/Cache/ElementsCacheBuilder.php A src/LingoBackendAdapter.php M tests/bootstrap.php A tests/mw-phpunit-runner.php A tests/phpunit/Cache/ElementsCacheBuilderTest.php A tests/phpunit/LingoBackendAdapterTest.php 10 files changed, 596 insertions(+), 380 deletions(-) Approvals: Foxtrott: Verified; Looks good to me, approved diff --git a/README.md b/README.md new file mode 100644 index 000..4982fc6 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Semantic Glossary +[![Latest Stable Version](https://poser.pugx.org/mediawiki/semantic-glossary/version.png)](https://packagist.org/packages/mediawiki/chameleon-skin) +[![Packagist download count](https://poser.pugx.org/mediawiki/semantic-glossary/d/total.png)](https://packagist.org/packages/mediawiki/chameleon-skin) +[![Dependency Status](https://www.versioneye.com/php/mediawiki:semantic-glossary/badge.png)](https://www.versioneye.com/php/mediawiki:chameleon-skin) + +The [Semantic Glossary][mw-semantic-glossary] (a.k.a SG) is a [Semantic MediaWiki][smw] extension where terms and abbreviations can be defined using semantic properties. + +## Requirements + +- PHP 5.3.2 or later +- MediaWiki 1.20 or later +- [Lingo extension][mw-lingo] 1.0 or later + +## Installation + +The recommended way to install this skin is by using [Composer][composer]. Just add the following to the MediaWiki `composer.json` file and run the `php composer.phar install/update` command. + +```json +{ + require: { + mediawiki/semantic-glossary: ~1.0 + } +} +``` + +## Tests + +The extension provides unit tests that covers core-functionality normally run by a continues integration platform. Tests can also be executed manually using the `mw-phpunit-runner.php` script (loads necessary MediaWiki dependencies) or running `phpunit` with the [PHPUnit][mw-testing] configuration file found in the root directory. + +```sh +php mw-phpunit-runner.php +``` + +[mw-semantic-glossary]: https://www.mediawiki.org/wiki/Extension:Semantic_Glossary +[mw-lingo]: https://www.mediawiki.org/wiki/Extension:Lingo +[smw]: https://www.mediawiki.org/wiki/Semantic_MediaWiki +[mw-testing]: https://www.mediawiki.org/wiki/Manual:PHP_unit_testing +[composer]: https://getcomposer.org/ \ No newline at end of file diff --git a/SemanticGlossary.php b/SemanticGlossary.php index 37509b8..68e2252 100644 --- a/SemanticGlossary.php +++ b/SemanticGlossary.php @@ -44,9 +44,8 @@ 'version' = SG_VERSION, ); - // set SemanticGlossaryBackend as the backend to access the glossary - $GLOBALS[ 'wgexLingoBackend' ] = 'SemanticGlossaryBackend'; + $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter'; // server-local path to this file $dir = __DIR__; @@ -57,11 +56,12 @@ // register class files with the Autoloader $autoloadClasses = array( - 'SemanticGlossaryBackend' = $dir . '/SemanticGlossaryBackend.php', 'SG\PropertyRegistry' = $dir . '/src/PropertyRegistry.php', 'SG\CacheInvalidator' = $dir . '/src/CacheInvalidator.php', 'SG\CacheHelper' = $dir . '/src/CacheHelper.php', 'SG\DataComparator'= $dir . '/src/DataComparator.php', + 'SG\LingoBackendAdapter' = $dir . '/src/LingoBackendAdapter.php', + 'SG\Cache\ElementsCacheBuilder'= $dir . '/src/Cache/ElementsCacheBuilder.php' ); $GLOBALS[ 'wgAutoloadClasses' ] = array_merge( $GLOBALS[ 'wgAutoloadClasses' ], $autoloadClasses ); diff --git a/SemanticGlossaryBackend.php b/SemanticGlossaryBackend.php deleted file mode 100644 index ad9797d..000 --- a/SemanticGlossaryBackend.php +++ /dev/null @@ -1,195 +0,0 @@ -?php - -/** - * File holding the SemanticGlossaryBackend class - * - * @author Stephan Gambke - * @file - * @ingroup SemanticGlossary - */ -if ( !defined( 'SG_VERSION' ) ) { - die( 'This file is part of the SemanticGlossary extension, it is not a valid entry point.' ); -} - -/** - * The SemanticGlossaryBackend class. - * - * @ingroup SemanticGlossary - */ -class SemanticGlossaryBackend extends LingoBackend { - - //array of SMWDIWikiPage - protected $mQueryResults; - - protected $mDiTerm; - protected $mDiDefinition; - protected $mDiLink; - protected $mDiStyle; - - protected $mDvTerm; - protected $mDvDefinition; - protected $mDvLink; - protected $mDvStyle; - - protected
[MediaWiki-commits] [Gerrit] Refactored SemanticGlossaryBackend - change (mediawiki...SemanticGlossary)
Mwjames has uploaded a new change for review. https://gerrit.wikimedia.org/r/133044 Change subject: Refactored SemanticGlossaryBackend .. Refactored SemanticGlossaryBackend - Encapsulate LingoBackend using \SG\LingoBackendAdapter - Added \SG\Cache\TermsBuilder Change-Id: Id59164a9cc2c34a777313fb12524ceedf35801e5 --- A README.md M SemanticGlossary.php D SemanticGlossaryBackend.php D SemanticGlossaryCacheHandling.php A src/Cache/TermsBuilder.php A src/LingoBackendAdapter.php M tests/bootstrap.php A tests/phpunit/Cache/TermsBuilderTest.php A tests/phpunit/LingoBackendAdapterTest.php 9 files changed, 506 insertions(+), 380 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticGlossary refs/changes/44/133044/1 diff --git a/README.md b/README.md new file mode 100644 index 000..3981a91 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Semantic Glossary +[![Latest Stable Version](https://poser.pugx.org/mediawiki/semantic-glossary/version.png)](https://packagist.org/packages/mediawiki/chameleon-skin) +[![Packagist download count](https://poser.pugx.org/mediawiki/semantic-glossary/d/total.png)](https://packagist.org/packages/mediawiki/chameleon-skin) +[![Dependency Status](https://www.versioneye.com/php/mediawiki:semantic-glossary/badge.png)](https://www.versioneye.com/php/mediawiki:chameleon-skin) + +The [Semantic Glossary][mw-semantic-glossary] (a.k.a SG) is a [Semantic MediaWiki][smw] extension where terms and abbreviations can be defined using semantic properties. + +## Requirements + +- PHP 5.3.2 or later +- MediaWiki 1.20 or later +- [Lingo extension][mw-lingo] 1.0 or later + +## Installation + +The recommended way to install this skin is by using [Composer][composer]. Just add the following to the MediaWiki `composer.json` file and run the `php composer.phar install/update` command. + +```json +{ + require: { + mediawiki/semantic-glossary: ~1.0 + } +} +``` + +## Tests + +The extension provides unit tests that covers core-functionality normally run by a continues integration platform. Tests can also be executed manually using the [PHPUnit][mw-testing] configuration file found in the root directory: + +Due to an existing Mediawiki dependency, the deployed `phpunit.php` should be used to ensure proper autoloading of classes during testing. +```sh +php mw-path/tests/phpunit/phpunit.php -c mw-path/extensions/SemanticGlossary/phpunit.xml.dist +``` + +[mw-semantic-glossary]: https://www.mediawiki.org/wiki/Extension:Semantic_Glossary +[mw-lingo]: https://www.mediawiki.org/wiki/Extension:Lingo +[smw]: https://www.mediawiki.org/wiki/Semantic_MediaWiki +[mw-testing]: https://www.mediawiki.org/wiki/Manual:PHP_unit_testing +[composer]: https://getcomposer.org/ \ No newline at end of file diff --git a/SemanticGlossary.php b/SemanticGlossary.php index 37509b8..b6848fc 100644 --- a/SemanticGlossary.php +++ b/SemanticGlossary.php @@ -44,9 +44,8 @@ 'version' = SG_VERSION, ); - // set SemanticGlossaryBackend as the backend to access the glossary - $GLOBALS[ 'wgexLingoBackend' ] = 'SemanticGlossaryBackend'; + $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter'; // server-local path to this file $dir = __DIR__; @@ -57,11 +56,12 @@ // register class files with the Autoloader $autoloadClasses = array( - 'SemanticGlossaryBackend' = $dir . '/SemanticGlossaryBackend.php', 'SG\PropertyRegistry' = $dir . '/src/PropertyRegistry.php', 'SG\CacheInvalidator' = $dir . '/src/CacheInvalidator.php', 'SG\CacheHelper' = $dir . '/src/CacheHelper.php', 'SG\DataComparator'= $dir . '/src/DataComparator.php', + 'SG\LingoBackendAdapter' = $dir . '/src/LingoBackendAdapter.php', + 'SG\Cache\TermsBuilder'= $dir . '/src/Cache/TermsBuilder.php' ); $GLOBALS[ 'wgAutoloadClasses' ] = array_merge( $GLOBALS[ 'wgAutoloadClasses' ], $autoloadClasses ); diff --git a/SemanticGlossaryBackend.php b/SemanticGlossaryBackend.php deleted file mode 100644 index ad9797d..000 --- a/SemanticGlossaryBackend.php +++ /dev/null @@ -1,195 +0,0 @@ -?php - -/** - * File holding the SemanticGlossaryBackend class - * - * @author Stephan Gambke - * @file - * @ingroup SemanticGlossary - */ -if ( !defined( 'SG_VERSION' ) ) { - die( 'This file is part of the SemanticGlossary extension, it is not a valid entry point.' ); -} - -/** - * The SemanticGlossaryBackend class. - * - * @ingroup SemanticGlossary - */ -class SemanticGlossaryBackend extends LingoBackend { - - //array of SMWDIWikiPage - protected $mQueryResults; - - protected $mDiTerm; - protected $mDiDefinition; - protected $mDiLink; - protected $mDiStyle; - - protected $mDvTerm; -