diff --git a/.travis.yml b/.travis.yml index ca5985b..b19c8b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,11 @@ language: php -env: - - THENEEDFORTHIS=FAIL - matrix: include: - env: DB=mysql; MW=master; TYPE=coverage php: 5.5 - - env: DB=sqlite; MW=1.22.0 + - env: DB=sqlite; MW=1.26.0 php: 5.3 - exclude: - - env: THENEEDFORTHIS=FAIL install: - bash ./tests/travis/install-mediawiki.sh @@ -30,4 +25,4 @@ notifications: channels: - "chat.freenode.net#semantic-mediawiki" on_success: change - on_failure: always \ No newline at end of file + on_failure: always diff --git a/SemanticGlossary.i18n.php b/SemanticGlossary.i18n.php deleted file mode 100644 index 68d6f13..0000000 --- a/SemanticGlossary.i18n.php +++ /dev/null @@ -1,35 +0,0 @@ -load( $GLOBALS[ 'wgExtensionDirectory' ] . '/Lingo/extension.json' ); -if ( !defined( 'SMW_VERSION' ) ) { - die( 'Semantic Glossary depends on the Semantic MediaWiki extension. You need to install Semantic MediaWiki first.' ); -} + $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter'; -if ( !defined( 'LINGO_VERSION' ) ) { - die( 'Semantic Glossary depends on the Lingo extension. You need to install Lingo first.' ); -} + $GLOBALS[ 'wgExtensionFunctions' ][] = function () { -call_user_func( function () { + $hookRegistry = new HookRegistry( + ApplicationFactory::getInstance()->getStore() + ); - // register the extension - $GLOBALS[ 'wgExtensionCredits' ][ 'semantic' ][] = array( - 'path' => __FILE__, - 'name' => 'Semantic Glossary', - 'author' => array( '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', 'James Hong Kong' ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:Semantic_Glossary', - 'descriptionmsg' => 'semanticglossary-desc', - 'version' => SG_VERSION, - 'license-name' => 'GPL-2.0+' - ); + $hookRegistry->register(); + }; + } - // set SemanticGlossaryBackend as the backend to access the glossary - $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter'; + /** + * @since 2.0 + * + * @return string|null + */ + public static function getVersion() { + $extensionData = ExtensionRegistry::getInstance()->getAllThings(); - // server-local path to this file - $dir = __DIR__; + if ( isset( $extensionData['Semantic Glossary'] ) ) { + return $extensionData['Semantic Glossary']['version']; + } - // register message file - $GLOBALS[ 'wgMessagesDirs' ]['SemanticGlossary'] = $dir . '/i18n'; - $GLOBALS[ 'wgExtensionMessagesFiles' ]['SemanticGlossary'] = $dir . '/SemanticGlossary.i18n.php'; - - $GLOBALS['wgExtensionFunctions'][] = function() { - - $hookRegistry = new HookRegistry( - ApplicationFactory::getInstance()->getStore() - ); - - $hookRegistry->register(); - }; - -} ); + return null; + } +} diff --git a/composer.json b/composer.json index 572f112..1d919c6 100644 --- a/composer.json +++ b/composer.json @@ -30,12 +30,12 @@ "require": { "php": ">=5.3.0", "composer/installers":"^1.0.12", - "mediawiki/semantic-media-wiki": "~2.2", - "mediawiki/lingo": "~1.2" + "mediawiki/semantic-media-wiki": "~2.3", + "mediawiki/lingo": "~2.0" }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { @@ -52,4 +52,4 @@ "scripts":{ "phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist" } -} \ No newline at end of file +} diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..d407dbe --- /dev/null +++ b/extension.json @@ -0,0 +1,23 @@ +{ + "name": "Semantic Glossary", + "version": "2.0-dev", + "author": [ + "[https://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]", + "[https://www.semantic-mediawiki.org/wiki/User:MWJames James Hong Kong]", + "..." + ], + "url": "https://www.mediawiki.org/wiki/Extension:Semantic_Glossary", + "descriptionmsg": "semanticglossary-desc", + "license-name": "GPL-2.0+", + "type": "semantic", + "requires": { + "MediaWiki": "~1.26" + }, + "MessagesDirs": { + "SemanticGlossary": [ + "i18n" + ] + }, + "callback": "SemanticGlossary::initExtension", + "manifest_version": 1 +} diff --git a/src/Cache/CacheInvalidator.php b/src/Cache/CacheInvalidator.php index 9d7fcbd..fda7d73 100644 --- a/src/Cache/CacheInvalidator.php +++ b/src/Cache/CacheInvalidator.php @@ -10,7 +10,7 @@ use SMW\DIWikiPage; use SMW\DIProperty; -use LingoParser; +use Lingo\LingoParser; use Title; diff --git a/src/Cache/ElementsCacheBuilder.php b/src/Cache/ElementsCacheBuilder.php index 2bdbb9d..8df1f16 100644 --- a/src/Cache/ElementsCacheBuilder.php +++ b/src/Cache/ElementsCacheBuilder.php @@ -2,7 +2,6 @@ namespace SG\Cache; -use SG\Cache\GlossaryCache; use SG\PropertyRegistry; use SMW\Store; @@ -15,7 +14,7 @@ use SMWSomeProperty as SomeProperty; use SMWQuery as Query; -use LingoElement; +use Lingo\Element; /** * @ingroup SG @@ -114,11 +113,11 @@ private function buildElements( $terms, $definition, $link, $style, $page ) { foreach ( $terms as $term ) { $tmp_ret = array( - LingoElement::ELEMENT_TERM => $term, - LingoElement::ELEMENT_DEFINITION => $definition, - LingoElement::ELEMENT_LINK => $link, - LingoElement::ELEMENT_STYLE => $style, - LingoElement::ELEMENT_SOURCE => $page + Element::ELEMENT_TERM => $term, + Element::ELEMENT_DEFINITION => $definition, + Element::ELEMENT_LINK => $link, + Element::ELEMENT_STYLE => $style, + Element::ELEMENT_SOURCE => $page ); $ret[] = $tmp_ret; diff --git a/src/LingoBackendAdapter.php b/src/LingoBackendAdapter.php index efeb4a2..77ee5f9 100644 --- a/src/LingoBackendAdapter.php +++ b/src/LingoBackendAdapter.php @@ -7,8 +7,8 @@ use SMW\StoreFactory; -use LingoBackend; -use LingoMessageLog; +use Lingo\Backend; +use Lingo\MessageLog; /** * @ingroup SG @@ -19,7 +19,7 @@ * * @author mwjames */ -class LingoBackendAdapter extends LingoBackend { +class LingoBackendAdapter extends Backend { /* @var ElementsCacheBuilder */ protected $elementsCacheBuilder = null; @@ -29,10 +29,10 @@ class LingoBackendAdapter extends LingoBackend { /** * @since 1.1 * - * @param LingoMessageLog|null &$messages + * @param MessageLog|null &$messages * @param ElementsCacheBuilder|null $elementsCacheBuilder */ - public function __construct( LingoMessageLog &$messages = null, ElementsCacheBuilder $elementsCacheBuilder = null ) { + public function __construct( MessageLog &$messages = null, ElementsCacheBuilder $elementsCacheBuilder = null ) { parent::__construct( $messages ); $this->elementsCacheBuilder = $elementsCacheBuilder; @@ -69,7 +69,7 @@ public function next() { * This backend is cache-enabled so this function returns true. * * Actual caching is done by the parser, the backend just calls - * LingoParser::purgeCache when necessary. + * Parser::purgeCache when necessary. * * @since 1.1 * diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 67cf271..d3dc794 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,7 +8,11 @@ die( 'The SemanticMediaWiki test autoloader is not available' ); } -print sprintf( "\n%-20s%s\n", "Semantic Glossary: ", SG_VERSION ); +if ( ( $version = SemanticGlossary::getVersion() ) === null ) { + die( 'SemanticGlossary is not registered via wfLoadExtension, please adapt your LocalSettings.' ); +} + +print sprintf( "\n%-20s%s\n", "Semantic Glossary: ", $version ); $autoloader = require $autoloaderClassPath; $autoloader->addPsr4( 'SG\\Tests\\', __DIR__ . '/phpunit/Unit' ); diff --git a/tests/phpunit/Integration/MwDBSQLStoreIntegrationTest.php b/tests/phpunit/Integration/MwDBSQLStoreIntegrationTest.php index 46cc579..8af1688 100644 --- a/tests/phpunit/Integration/MwDBSQLStoreIntegrationTest.php +++ b/tests/phpunit/Integration/MwDBSQLStoreIntegrationTest.php @@ -32,6 +32,7 @@ class MwDBSQLStoreIntegrationTest extends MwDBaseUnitTestCase { private $runnerFactory; protected function setUp() { + parent::setUp(); $this->pageCreator = UtilityFactory::getInstance()->newPageCreator(); $this->pageDeleter = UtilityFactory::getInstance()->newPageDeleter(); diff --git a/tests/phpunit/Unit/Cache/ElementsCacheBuilderTest.php b/tests/phpunit/Unit/Cache/ElementsCacheBuilderTest.php index f63f16d..e6da04f 100644 --- a/tests/phpunit/Unit/Cache/ElementsCacheBuilderTest.php +++ b/tests/phpunit/Unit/Cache/ElementsCacheBuilderTest.php @@ -5,7 +5,7 @@ use SG\Cache\ElementsCacheBuilder; use SG\Cache\GlossaryCache; -use LingoElement; +use Lingo\Element; use SMWDIWikiPage as DIWikiPage; use SMWDIBlob as DIBlob; @@ -99,14 +99,14 @@ public function testGetTermsForSingleTermWithDefinitionOnNonCachedResult() { protected function assertLingoElement( $term, $definition, $link, $style, $result ) { - $this->assertEquals( $term, $result[ LingoElement::ELEMENT_TERM ] ); - $this->assertEquals( $definition, $result[ LingoElement::ELEMENT_DEFINITION ] ); - $this->assertEquals( $link, $result[ LingoElement::ELEMENT_LINK ] ); - $this->assertEquals( $style, $result[ LingoElement::ELEMENT_STYLE ] ); + $this->assertEquals( $term, $result[ Element::ELEMENT_TERM ] ); + $this->assertEquals( $definition, $result[ Element::ELEMENT_DEFINITION ] ); + $this->assertEquals( $link, $result[ Element::ELEMENT_LINK ] ); + $this->assertEquals( $style, $result[ Element::ELEMENT_STYLE ] ); $this->assertInstanceOf( 'SMWDIWikiPage', - $result[ LingoElement::ELEMENT_SOURCE ] + $result[ Element::ELEMENT_SOURCE ] ); } diff --git a/tests/phpunit/Unit/LingoBackendAdapterTest.php b/tests/phpunit/Unit/LingoBackendAdapterTest.php index 800938c..fd0b576 100644 --- a/tests/phpunit/Unit/LingoBackendAdapterTest.php +++ b/tests/phpunit/Unit/LingoBackendAdapterTest.php @@ -30,7 +30,7 @@ public function testCanConstruct() { public function testNextOnEmptyElementsResult() { - $lingoMessageLog = $this->getMockBuilder( '\LingoMessageLog' ) + $lingoMessageLog = $this->getMockBuilder( '\Lingo\MessageLog' ) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/travis/install-semantic-glossary.sh b/tests/travis/install-semantic-glossary.sh index 4489861..38807a8 100644 --- a/tests/travis/install-semantic-glossary.sh +++ b/tests/travis/install-semantic-glossary.sh @@ -62,6 +62,7 @@ function updateConfiguration { echo '$wgShowExceptionDetails = true;' >> LocalSettings.php echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php echo "putenv( 'MW_INSTALL_PATH=$(pwd)' );" >> LocalSettings.php + echo "wfLoadExtension('SemanticGlossary');" >> LocalSettings.php php maintenance/update.php --quick }