Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/156086
Change subject: New build, update PropertySuggester and add WikimediaBadges ...................................................................... New build, update PropertySuggester and add WikimediaBadges Change-Id: Idbf027b9dd1ecca520d83e5bc710ea22e16723fb --- M composer.json M composer.lock M extensions/PropertySuggester/README.md M extensions/PropertySuggester/build/travis/script.sh M extensions/PropertySuggester/i18n/en.json M extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js M extensions/PropertySuggester/src/PropertySuggester/GetSuggestions.php M extensions/PropertySuggester/src/PropertySuggester/SuggesterParams.php M extensions/PropertySuggester/src/PropertySuggester/SuggesterParamsParser.php M extensions/PropertySuggester/src/PropertySuggester/Suggesters/SimpleSuggester.php M extensions/PropertySuggester/src/PropertySuggester/Suggesters/SuggesterEngine.php M extensions/PropertySuggester/src/PropertySuggester/SuggestionGenerator.php M extensions/PropertySuggester/tests/bootstrap.php M extensions/PropertySuggester/tests/phpunit/PropertySuggester/GetSuggestionsTest.php M extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggesterParamsParserTest.php M extensions/PropertySuggester/tests/phpunit/PropertySuggester/Suggesters/SimpleSuggesterTest.php M extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggestionGeneratorTest.php A extensions/WikimediaBadges/.gitignore A extensions/WikimediaBadges/COPYING A extensions/WikimediaBadges/README.md A extensions/WikimediaBadges/RELEASE-NOTES.md A extensions/WikimediaBadges/WikimediaBadges.hooks.php A extensions/WikimediaBadges/WikimediaBadges.php A extensions/WikimediaBadges/composer.json A extensions/WikimediaBadges/i18n/en.json A extensions/WikimediaBadges/i18n/qqq.json A extensions/WikimediaBadges/resources/Resources.php A extensions/WikimediaBadges/resources/images/badge-golden-star.png A extensions/WikimediaBadges/resources/images/badge-silver-star.png A extensions/WikimediaBadges/resources/skins/cologneblue/wikimedia-badges.css A extensions/WikimediaBadges/resources/skins/default/wikimedia-badges.css M vendor/composer/ClassLoader.php M vendor/composer/autoload_classmap.php M vendor/composer/autoload_files.php M vendor/composer/installed.json M vendor/composer/installers/README.md M vendor/composer/installers/composer.json M vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php A vendor/composer/installers/src/Composer/Installers/ChefInstaller.php M vendor/composer/installers/src/Composer/Installers/Installer.php M vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php M vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php 42 files changed, 1,364 insertions(+), 388 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata refs/changes/86/156086/1 diff --git a/composer.json b/composer.json index dd25d63..e6d882a 100644 --- a/composer.json +++ b/composer.json @@ -3,12 +3,20 @@ { "type": "vcs", "url": "https://github.com/wmde/Wikidata.org.git" + }, + { + "type": "vcs", + "url": "https://github.com/wmde/WikimediaBadges.git" } ], "require": { "php": ">=5.3.0", - "propertysuggester/property-suggester": "~1.0", + "propertysuggester/property-suggester": "~1.1", + "serialization/serialization": "3.2.0", + "wikibase/data-model-javascript": "0.3.1", + "wikibase/serialization-javascript": "1.1.1", "wikibase/wikibase": "dev-mw1.24-wmf17", + "wikibase/wikimedia-badges": "dev-master", "wikibase/Wikidata.org" : "dev-master" }, "config": { diff --git a/composer.lock b/composer.lock index 3469f3d..2380dd8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9b8e1059e6bc75ae46df037d4136ffad", + "hash": "d16206fbc25f12ed7a8d8b65dbd12d46", "packages": [ { "name": "composer/installers", - "version": "v1.0.16", + "version": "v1.0.18", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "033679ad3cfc5ab759f9ed2a58881aeef13c342b" + "reference": "74fb0a7a1a23696d9c8cc2fba5903f6711cdd067" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/033679ad3cfc5ab759f9ed2a58881aeef13c342b", - "reference": "033679ad3cfc5ab759f9ed2a58881aeef13c342b", + "url": "https://api.github.com/repos/composer/installers/zipball/74fb0a7a1a23696d9c8cc2fba5903f6711cdd067", + "reference": "74fb0a7a1a23696d9c8cc2fba5903f6711cdd067", "shasum": "" }, "replace": { @@ -64,6 +64,7 @@ "annotatecms", "bitrix", "cakephp", + "chef", "codeigniter", "concrete5", "croogo", @@ -93,7 +94,7 @@ "zend", "zikula" ], - "time": "2014-07-21 15:54:34" + "time": "2014-08-18 20:00:12" }, { "name": "data-values/common", @@ -723,16 +724,16 @@ }, { "name": "propertysuggester/property-suggester", - "version": "v1.0", + "version": "v1.1", "source": { "type": "git", "url": "https://github.com/Wikidata-lib/PropertySuggester.git", - "reference": "2fb712f58c368a1151b3e8aeb09876ffa1f66913" + "reference": "fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/2fb712f58c368a1151b3e8aeb09876ffa1f66913", - "reference": "2fb712f58c368a1151b3e8aeb09876ffa1f66913", + "url": "https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1", + "reference": "fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1", "shasum": "" }, "require": { @@ -766,7 +767,7 @@ "wikibase", "wikidata" ], - "time": "2014-06-23 17:01:20" + "time": "2014-07-25 01:45:14" }, { "name": "serialization/serialization", @@ -1268,6 +1269,56 @@ "source": "https://github.com/wikimedia/mediawiki-extensions-Wikibase/tree/mw1.24-wmf17" }, "time": "2014-08-19 20:18:42" + }, + { + "name": "wikibase/wikimedia-badges", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/wmde/WikimediaBadges.git", + "reference": "b562f39a88b26a7b968931fe2ab13bd3a68b707e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/WikimediaBadges/zipball/b562f39a88b26a7b968931fe2ab13bd3a68b707e", + "reference": "b562f39a88b26a7b968931fe2ab13bd3a68b707e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "mediawiki-extension", + "autoload": { + "files": [ + "WikimediaBadges.php" + ], + "classmap": [ + "WikimediaBadges.hooks.php" + ] + }, + "license": [ + "GNU GPL v2+" + ], + "authors": [ + { + "name": "Bene*", + "email": "benestar.wikime...@gmail.com", + "homepage": "https://www.wikidata.org/wiki/User:Bene*", + "role": "Developer" + } + ], + "description": "Extension which contains default themes to display badges on Wikimedia projects", + "homepage": "https://github.com/wmde/WikimediaBadges", + "keywords": [ + "Wikibase", + "Wikidata" + ], + "support": { + "irc": "irc://irc.freenode.net/wikidata", + "source": "https://github.com/wmde/WikimediaBadges/tree/master", + "issues": "https://github.com/wmde/WikimediaBadges/issues" + }, + "time": "2014-08-22 10:30:41" } ], "packages-dev": [ @@ -1279,6 +1330,7 @@ "minimum-stability": "stable", "stability-flags": { "wikibase/wikibase": 20, + "wikibase/wikimedia-badges": 20, "wikibase/wikidata.org": 20 }, "prefer-stable": false, diff --git a/extensions/PropertySuggester/README.md b/extensions/PropertySuggester/README.md index f639bc3..9a3ae2a 100644 --- a/extensions/PropertySuggester/README.md +++ b/extensions/PropertySuggester/README.md @@ -17,12 +17,12 @@ ### Composer To add this package as a local, per-project dependency to your project, simply add a -dependency on `propertysuggester/propertysuggester` to your project's `composer.json` file. +dependency on `propertysuggester/property-suggester` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file: { "require": { - "propertysuggester/propertysuggester": "*" + "propertysuggester/property-suggester": "*" } } @@ -34,5 +34,19 @@ * run ```composer dump-autoload``` in the extension folder (if installed without composer) * add ```require_once "$IP/extensions/PropertySuggester/PropertySuggester.php";``` to your localsettings -* run ```maintenance/update.php``` to create the neccessary table +* run ```maintenance/update.php``` to create the necessary table * follow the readme of PropertySuggester-Python to generate and load suggestion data + +### Configuration + +* $wgPropertySuggesterMinProbability - a float that sets a minimum threshold for suggestions (default 0.05) +* $wgPropertySuggesterDeprecatedIds - a list of ints that blacklist suggestions + +## Release notes + +### 1.1 (soon) +* Suggest properties for qualifiers and references based on the property of the mainsnak + +### 1.0 (2014-07-01) + +* Provide Property-Suggestions based on correlations to other properties in the item diff --git a/extensions/PropertySuggester/build/travis/script.sh b/extensions/PropertySuggester/build/travis/script.sh index 2f4f104..d487611 100644 --- a/extensions/PropertySuggester/build/travis/script.sh +++ b/extensions/PropertySuggester/build/travis/script.sh @@ -2,8 +2,8 @@ set -x -# cd ../wiki/tests/phpunit -# php phpunit.php -c ../../extensions/PropertySuggester/phpunit.xml.dist --debug +cd ../wiki/tests/phpunit +php phpunit.php -c ../../extensions/PropertySuggester/phpunit.xml.dist -cd ../wiki/extensions/PropertySuggester -php vendor/bin/phpunit -c phpunit.xml.dist +# cd ../wiki/extensions/PropertySuggester +# php vendor/bin/phpunit -c phpunit.xml.dist diff --git a/extensions/PropertySuggester/i18n/en.json b/extensions/PropertySuggester/i18n/en.json index 0bdc18c..8d0ea9e 100644 --- a/extensions/PropertySuggester/i18n/en.json +++ b/extensions/PropertySuggester/i18n/en.json @@ -2,7 +2,7 @@ "@metadata": { "authors": [] }, - "propertysuggester-desc": "Shows suggested properties for items.", + "propertysuggester-desc": "Shows suggested properties for wikibase items.", "propertysuggester": "Property Suggester", "propertysuggester-intro": "This is the PropertySuggester." } diff --git a/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js b/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js index dd5a2b2..09d72ad 100644 --- a/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js +++ b/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js @@ -10,6 +10,10 @@ var Item = $.wikibase.entityselector.Item; + /** + * This widget overrides the wikibase.entityselector and extends it with functionality to + * suggest matching properties instead of just searching for them. + */ $.widget( 'wikibase.entityselector', $.wikibase.entityselector, { _oldCreate: $.wikibase.entityselector.prototype._create, @@ -17,50 +21,67 @@ _create: function() { var self = this; - self._oldCreate.apply(self, arguments); + self._oldCreate.apply( self, arguments ); var focusHandler = function( event ) { - if ( self.__useSuggester() && self.element.val() === '' - && !self.options.menu.element.is( ":visible" ) ) { + if( self._useSuggester() && self.element.val() === '' + && !self.options.menu.element.is( ":visible" ) ) { self._minTermLength = 0; self._cache = {}; // is done in the entityselector on eachchange too self.search( event ); - } + } }; self.element.on( 'focus', focusHandler ); - }, _oldGetData: $.wikibase.entityselector.prototype._getData, + /** + * + * @param {string} term + * @return {Object} + */ _getData: function( term ) { var self = this; - if ( !self.__useSuggester() ) { + if( !self._useSuggester() ) { return self._oldGetData( term ) } else { - return { + var data = { action: 'wbsgetsuggestions', search: term, - entity: self.__getEntity().getId(), + context: this._getPropertyContext(), format: 'json', language: self.options.language, type: self.options.type, 'continue': self._cache[term] && self._cache[term].nextSuggestionOffset - ? self._cache[term].nextSuggestionOffset: 0 + ? self._cache[term].nextSuggestionOffset : 0 }; + if( data.context == 'item' ) { + data.entity = self._getEntity().getId(); + } else { + data.properties = self._getPropertyId(); + } + return data; } }, - __useSuggester: function() { - var entity = this.__getEntity(); - return this.options.type === 'property' && entity && entity.getType() === 'item' && this.__isInNewStatementView(); + /** + * @return {boolean} + */ + _useSuggester: function() { + var entity = this._getEntity(); + return this.options.type === 'property' && entity !== null && entity.getType() === 'item'; }, - __getEntity: function() { + /** + * Get the entity from the surrounding entityview or return null + * @return {wikibase.Entity|null} + */ + _getEntity: function() { try { var $entityView = this.element.closest( ':wikibase-entityview' ); - } catch (e) { + } catch( e ) { return null; } var entity = $entityView.length > 0 ? $entityView.data( 'entityview' ).option( 'value' ) : null; @@ -72,17 +93,74 @@ }, /** - * only entityselectors in statements describing the item should get suggestions. - * this is hopefully exactly the case if the statement has no value. - * other entityselectors like source and quantifier should not get suggestions since - * they already have a statementview with a value. + * Returns the property id for the enclosing statementview or null if no property is selected yet. + * + * @return {string|null} */ - __isInNewStatementView: function() { - var $statementView = this.element.closest( ':wikibase-statementview' ); - var value = $statementView.length > 0 ? $statementView.data( 'statementview' ).option( 'value' ) : null; + _getPropertyId: function() { + try { + var $statementView = this.element.closest( ':wikibase-statementview' ); + } catch( e ) { + return null; + } + var statement = $statementView.length > 0 ? $statementView.data( 'statementview' ).option( 'value' ) : null; + if( statement ) { + return statement.getMainSnak().getPropertyId(); + } else { + return null; + } + }, + + /** + * Returns either 'item', 'qualifier', 'reference' or null depending on the context of the entityselector. + * 'item' is returned in case that the selector is for a new property in an item. + * + * @return {string} + */ + _getPropertyContext: function() { + if( this._isInNewStatementView() ) { + return 'item'; + } else if( this._isQualifier() ) { + return 'qualifier'; + } else if( this._isReference() ) { + return 'reference' + } else { + return null; + } + }, + + /** + * @return {boolean} + */ + _isQualifier: function() { + var $claimview = this.element.closest( ':wikibase-claimview, :wikibase-statementview' ); + var claimview = $claimview.data( 'claimview' ) || $claimview.data( 'statementview' ); + if( !claimview ) { + return false; + } + return this.element.closest( claimview.$qualifiers ).length > 0; + }, + + /** + * @return {boolean} + */ + _isReference: function() { + var $referenceview = this.element.closest( ':wikibase-referenceview' ); + return $referenceview.length > 0; + }, + + /** + * detect if this is a new statement view. + * @return {boolean} + */ + _isInNewStatementView: function() { + var $statementView = this.element.closest( ':wikibase-statementview' ); + var value = ( $statementView.length > 0 ) + ? $statementView.data( 'statementview' ).option( 'value' ) + : null; return value === null; } - }); + } ); $.extend( $.wikibase.entityselector, { Item: Item diff --git a/extensions/PropertySuggester/src/PropertySuggester/GetSuggestions.php b/extensions/PropertySuggester/src/PropertySuggester/GetSuggestions.php index 243a86b..55f36c5 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/GetSuggestions.php +++ b/extensions/PropertySuggester/src/PropertySuggester/GetSuggestions.php @@ -74,9 +74,9 @@ $suggestionGenerator = new SuggestionGenerator( $this->entityLookup, $this->termIndex, $this->suggester ); if ( $params->entity !== null ) { - $suggestions = $suggestionGenerator->generateSuggestionsByItem( $params->entity, $params->suggesterLimit, $params->minProbability ); + $suggestions = $suggestionGenerator->generateSuggestionsByItem( $params->entity, $params->suggesterLimit, $params->minProbability, $params->context ); } else { - $suggestions = $suggestionGenerator->generateSuggestionsByPropertyList( $params->properties, $params->suggesterLimit, $params->minProbability ); + $suggestions = $suggestionGenerator->generateSuggestionsByPropertyList( $params->properties, $params->suggesterLimit, $params->minProbability, $params->context ); } $suggestions = $suggestionGenerator->filterSuggestions( $suggestions, $params->search, $params->language, $params->resultSize ); @@ -154,6 +154,10 @@ ApiBase::PARAM_TYPE => Utils::getLanguageCodes(), ApiBase::PARAM_DFLT => $this->getContext()->getLanguage()->getCode(), ), + 'context' => array( + ApiBase::PARAM_TYPE => 'string', + ApiBase::PARAM_DFLT => 'item', + ), 'search' => array( ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_DFLT => '', @@ -171,6 +175,7 @@ 'size' => 'Specify number of suggestions to be returned', 'language' => 'language for result', 'limit' => 'Maximal number of results', + 'context' => 'Either item, reference or qualifier', 'continue' => 'Offset where to continue a search' ); } @@ -194,7 +199,11 @@ 'api.php?action=wbsgetsuggestions&entity=Q4&continue=10&limit=5' => 'Get suggestions for entity 4 from rank 10 to 15', 'api.php?action=wbsgetsuggestions&properties=P31|P21' - => 'Get suggestions for the property combination P21 and P31' + => 'Get suggestions for the property combination P21 and P31', + 'api.php?action=wbsgetsuggestions&properties=P21&context=qualifier' + => 'Get suggestions for the qualifier that are used with P21', + 'api.php?action=wbsgetsuggestions&properties=P21&context=reference' + => 'Get suggestions for the references that are used with P21' ); } diff --git a/extensions/PropertySuggester/src/PropertySuggester/SuggesterParams.php b/extensions/PropertySuggester/src/PropertySuggester/SuggesterParams.php index 18b4e9a..919d98d 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/SuggesterParams.php +++ b/extensions/PropertySuggester/src/PropertySuggester/SuggesterParams.php @@ -49,6 +49,11 @@ public $continue; /** + * @var string + */ + public $context; + + /** * @var int */ public $resultSize; diff --git a/extensions/PropertySuggester/src/PropertySuggester/SuggesterParamsParser.php b/extensions/PropertySuggester/src/PropertySuggester/SuggesterParamsParser.php index 9dc8760..b1522e9 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/SuggesterParamsParser.php +++ b/extensions/PropertySuggester/src/PropertySuggester/SuggesterParamsParser.php @@ -65,6 +65,7 @@ } $result->language = $params['language']; + $result->context = $params['context']; if ( $result->search ) { // the results matching '$search' can be at the bottom of the list diff --git a/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SimpleSuggester.php b/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SimpleSuggester.php index c1348e2..afbe9c1 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SimpleSuggester.php +++ b/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SimpleSuggester.php @@ -47,10 +47,11 @@ * @param int[] $propertyIds * @param int $limit * @param float $minProbability + * @param string $context * @throws InvalidArgumentException * @return Suggestion[] */ - protected function getSuggestions( array $propertyIds, $limit, $minProbability ) { + protected function getSuggestions( array $propertyIds, $limit, $minProbability, $context ) { $profiler = new ProfileSection( __METHOD__ ); if ( !is_int( $limit ) ) { throw new InvalidArgumentException( '$limit must be int!' ); @@ -64,7 +65,6 @@ $excludedIds = array_merge( $propertyIds, $this->deprecatedPropertyIds ); $count = count( $propertyIds ); - $context = 'item'; // only 'item' is supported at the moment $dbr = $this->lb->getConnection( DB_SLAVE ); $res = $dbr->select( @@ -92,13 +92,14 @@ * * @param PropertyId[] $propertyIds * @param int $limit - * @param float $minProbability + * @param float $minProbability + * @param string $context * @return Suggestion[] */ - public function suggestByPropertyIds( array $propertyIds, $limit, $minProbability ) { + public function suggestByPropertyIds( array $propertyIds, $limit, $minProbability, $context ) { $numericIds = array_map( array( $this, 'getNumericIdFromPropertyId' ), $propertyIds ); - return $this->getSuggestions( $numericIds, $limit, $minProbability ); + return $this->getSuggestions( $numericIds, $limit, $minProbability, $context ); } /** @@ -106,13 +107,14 @@ * * @param Item $item * @param int $limit - * @param float $minProbability + * @param float $minProbability + * @param string $context * @return Suggestion[] */ - public function suggestByItem( Item $item, $limit, $minProbability ) { + public function suggestByItem( Item $item, $limit, $minProbability, $context ) { $claims = $item->getClaims(); $numericIds = array_unique( array_map( array( $this, 'getNumericIdFromClaim' ), $claims ) ); - return $this->getSuggestions( $numericIds, $limit, $minProbability ); + return $this->getSuggestions( $numericIds, $limit, $minProbability, $context ); } /** diff --git a/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SuggesterEngine.php b/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SuggesterEngine.php index 714c7c4..327890e 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SuggesterEngine.php +++ b/extensions/PropertySuggester/src/PropertySuggester/Suggesters/SuggesterEngine.php @@ -18,9 +18,10 @@ * @param PropertyId[] $propertyIds * @param int $limit * @param float $minProbability + * @param string $context * @return Suggestion[] */ - public function suggestByPropertyIds( array $propertyIds, $limit, $minProbability ); + public function suggestByPropertyIds( array $propertyIds, $limit, $minProbability, $context ); /** * Returns suggested attributes @@ -28,9 +29,10 @@ * @param Item $item * @param int $limit * @param float $minProbability + * @param string $context * @return Suggestion[] */ - public function suggestByItem( Item $item, $limit, $minProbability ); + public function suggestByItem( Item $item, $limit, $minProbability, $context ); /** * @param int[] $numericIds - blacklist used to filter suggestions diff --git a/extensions/PropertySuggester/src/PropertySuggester/SuggestionGenerator.php b/extensions/PropertySuggester/src/PropertySuggester/SuggestionGenerator.php index 04791c1..c3a413c 100644 --- a/extensions/PropertySuggester/src/PropertySuggester/SuggestionGenerator.php +++ b/extensions/PropertySuggester/src/PropertySuggester/SuggestionGenerator.php @@ -42,19 +42,21 @@ } /** - * @param string $item - An item id + * @param string $itemIdString - An item id * @param int $limit * @param float $minProbability - * @throws InvalidArgumentException + * @param string $context + * @throws \InvalidArgumentException * @return array */ - public function generateSuggestionsByItem( $item, $limit, $minProbability ) { - $id = new ItemId( $item ); + + public function generateSuggestionsByItem( $itemIdString, $limit, $minProbability, $context ) { + $id = new ItemId( $itemIdString ); $item = $this->entityLookup->getEntity( $id ); if( $item == null ){ throw new InvalidArgumentException( 'Item ' . $id . ' could not be found' ); } - $suggestions = $this->suggester->suggestByItem( $item, $limit, $minProbability ); + $suggestions = $this->suggester->suggestByItem( $item, $limit, $minProbability, $context ); return $suggestions; } @@ -62,14 +64,16 @@ * @param string[] $propertyIdList - A list of property-id-strings * @param int $limit * @param float $minProbability + * @param string $context * @return Suggestion[] */ - public function generateSuggestionsByPropertyList( array $propertyIdList, $limit, $minProbability ) { + public function generateSuggestionsByPropertyList( array $propertyIdList, $limit, $minProbability, $context ) { $propertyIds = array(); foreach ( $propertyIdList as $stringId ) { $propertyIds[] = new PropertyId( $stringId ); } - $suggestions = $this->suggester->suggestByPropertyIds( $propertyIds, $limit, $minProbability ); + + $suggestions = $this->suggester->suggestByPropertyIds( $propertyIds, $limit, $minProbability, $context ); return $suggestions; } diff --git a/extensions/PropertySuggester/tests/bootstrap.php b/extensions/PropertySuggester/tests/bootstrap.php index f28925d..077594a 100644 --- a/extensions/PropertySuggester/tests/bootstrap.php +++ b/extensions/PropertySuggester/tests/bootstrap.php @@ -1,4 +1,3 @@ <?php -require_once __DIR__ . "/evilMediaWikiBootstrap.php"; require_once __DIR__ . "/../PropertySuggester.php"; diff --git a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/GetSuggestionsTest.php b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/GetSuggestionsTest.php index 3d16d05..6939756 100644 --- a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/GetSuggestionsTest.php +++ b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/GetSuggestionsTest.php @@ -92,7 +92,7 @@ $p56 = self::$idMap['%P56%']; $p72 = self::$idMap['%P72%']; - $params = array( 'action' => 'wbsgetsuggestions', 'properties' => $p56, 'search' => '*' ); + $params = array( 'action' => 'wbsgetsuggestions', 'properties' => $p56, 'search' => '*', 'context' => 'item' ); $res = $this->doApiRequest( $params ); $result = $res[0]; @@ -106,8 +106,7 @@ public function testExecutionWithSearch() { $p56 = self::$idMap['%P56%']; - // TODO add terms to do a useful search! - $params = array( 'action' => 'wbsgetsuggestions', 'properties' => $p56, 'search' => 'IdontExist', 'continue' => 0); + $params = array( 'action' => 'wbsgetsuggestions', 'properties' => $p56, 'search' => 'IdontExist', 'continue' => 0, 'context' => 'item'); $res = $this->doApiRequest( $params ); $result = $res[0]; diff --git a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggesterParamsParserTest.php b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggesterParamsParserTest.php index 6021102..399ce83 100644 --- a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggesterParamsParserTest.php +++ b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggesterParamsParserTest.php @@ -22,7 +22,7 @@ protected $defaultSuggesterResultSize = 100; protected $defaultMinProbability = 0.01; protected $defaultParams = array( 'entity' => null, 'properties' => null, 'continue' => 10, 'limit' => 5, - 'language' => 'en', 'search' => '' ); + 'language' => 'en', 'search' => '', 'context' => 'item' ); public function setUp() { parent::setUp(); @@ -42,6 +42,7 @@ $this->assertEquals( 5+10, $params->suggesterLimit ); $this->assertEquals( $this->defaultMinProbability, $params->minProbability ); $this->assertEquals( '', $params->search ); + $this->assertEquals( 'item', $params->context ); } public function testSuggesterWithSearchParameters() { @@ -57,6 +58,7 @@ $this->assertEquals( $this->defaultSuggesterResultSize, $params->suggesterLimit ); $this->assertEquals( 0, $params->minProbability ); $this->assertEquals( 'asd', $params->search ); + $this->assertEquals( 'item', $params->context ); } /** diff --git a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/Suggesters/SimpleSuggesterTest.php b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/Suggesters/SimpleSuggesterTest.php index 9a33803..4797451 100644 --- a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/Suggesters/SimpleSuggesterTest.php +++ b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/Suggesters/SimpleSuggesterTest.php @@ -57,7 +57,7 @@ public function testSuggestByPropertyIds() { $ids = array( new PropertyId( 'p1' ) ); - $res = $this->suggester->suggestByPropertyIds( $ids, 100, 0.0 ); + $res = $this->suggester->suggestByPropertyIds( $ids, 100, 0.0, 'item' ); $this->assertEquals( new PropertyId( 'p2' ), $res[0]->getPropertyId() ); $this->assertEquals( 0.1, $res[0]->getProbability(), '', 0.0001 ); @@ -71,7 +71,7 @@ $statement->setGuid( 'claim0' ); $item->addClaim( $statement ); - $res = $this->suggester->suggestByItem( $item, 100, 0.0 ); + $res = $this->suggester->suggestByItem( $item, 100, 0.0, 'item' ); $this->assertEquals( new PropertyId( 'p2' ), $res[0]->getPropertyId() ); $this->assertEquals( new PropertyId( 'p3' ), $res[1]->getPropertyId() ); @@ -82,7 +82,7 @@ $this->suggester->setDeprecatedPropertyIds( array( 2 ) ); - $res = $this->suggester->suggestByPropertyIds( $ids, 100, 0.0 ); + $res = $this->suggester->suggestByPropertyIds( $ids, 100, 0.0, 'item' ); $resultIds = array_map( function ( Suggestion $r ) { return $r->getPropertyId()->getNumericId(); }, $res ); $this->assertNotContains( 2 , $resultIds ); @@ -90,21 +90,21 @@ } public function testEmptyResult() { - $this->assertEmpty( $this->suggester->suggestByPropertyIds( array(), 10, 0.01 ) ); + $this->assertEmpty( $this->suggester->suggestByPropertyIds( array(), 10, 0.01, 'item' ) ); } /** * @expectedException InvalidArgumentException */ public function testInvalidLimit() { - $this->suggester->suggestByPropertyIds( array(), '10', 0.01 ); + $this->suggester->suggestByPropertyIds( array(), '10', 0.01, 'item' ); } /** * @expectedException InvalidArgumentException */ public function testInvalidMinProbability() { - $this->suggester->suggestByPropertyIds( array(), 10, '0.01' ); + $this->suggester->suggestByPropertyIds( array(), 10, '0.01', 'item' ); } } diff --git a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggestionGeneratorTest.php b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggestionGeneratorTest.php index 289dbc5..4edf2f7 100644 --- a/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggestionGeneratorTest.php +++ b/extensions/PropertySuggester/tests/phpunit/PropertySuggester/SuggestionGeneratorTest.php @@ -96,7 +96,7 @@ ->with( $this->equalTo( $properties ) ) ->will( $this->returnValue( array( 'foo' ) ) ); - $result1 = $this->suggestionGenerator->generateSuggestionsByPropertyList( array( 'P12', 'p13', 'P14' ) , 100, 0.0 ); + $result1 = $this->suggestionGenerator->generateSuggestionsByPropertyList( array( 'P12', 'p13', 'P14' ) , 100, 0.0, 'item' ); $this->assertEquals( $result1, array( 'foo' ) ); } @@ -119,7 +119,7 @@ ->with( $this->equalTo( $item ) ) ->will( $this->returnValue( array( 'foo' ) ) ); - $result3 = $this->suggestionGenerator->generateSuggestionsByItem( 'Q42', 100, 0.0 ); + $result3 = $this->suggestionGenerator->generateSuggestionsByItem( 'Q42', 100, 0.0, 'item' ); $this->assertEquals( $result3, array( 'foo' ) ); } @@ -134,7 +134,7 @@ ->with( $this->equalTo( $itemId ) ) ->will( $this->returnValue( null ) ); - $this->suggestionGenerator->generateSuggestionsByItem( 'Q41', 100, 0.0 ); + $this->suggestionGenerator->generateSuggestionsByItem( 'Q41', 100, 0.0, 'item' ); } } diff --git a/extensions/WikimediaBadges/.gitignore b/extensions/WikimediaBadges/.gitignore new file mode 100644 index 0000000..9e0631e --- /dev/null +++ b/extensions/WikimediaBadges/.gitignore @@ -0,0 +1,11 @@ +*~ +*.kate-swp + +composer.phar +composer.lock + +vendor/ +build/ + +!.* +.idea/ diff --git a/extensions/WikimediaBadges/COPYING b/extensions/WikimediaBadges/COPYING new file mode 100644 index 0000000..7d2552f --- /dev/null +++ b/extensions/WikimediaBadges/COPYING @@ -0,0 +1,347 @@ +The license text below "----" applies to all files within this distribution, other +than those that are in a directory which contains files named "LICENSE" or +"COPYING", or a subdirectory thereof. For those files, the license text contained in +said file overrides any license information contained in directories of smaller depth. +Alternative licenses are typically used for software that is provided by external +parties, and merely packaged with the Wikibase release for convenience. +---- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/extensions/WikimediaBadges/README.md b/extensions/WikimediaBadges/README.md new file mode 100644 index 0000000..b03c676 --- /dev/null +++ b/extensions/WikimediaBadges/README.md @@ -0,0 +1,4 @@ +WikimediaBadges +=============== + +Extension which contains default themes to display badges on Wikimedia projects. diff --git a/extensions/WikimediaBadges/RELEASE-NOTES.md b/extensions/WikimediaBadges/RELEASE-NOTES.md new file mode 100644 index 0000000..44b6e55 --- /dev/null +++ b/extensions/WikimediaBadges/RELEASE-NOTES.md @@ -0,0 +1,7 @@ +These are the release notes for the [WikimediaBadges extension](README.md). + +## Version 0.1 (dev) + +Initial release with these features: + +* New default theme to display badges on Wikimedia wikis diff --git a/extensions/WikimediaBadges/WikimediaBadges.hooks.php b/extensions/WikimediaBadges/WikimediaBadges.hooks.php new file mode 100644 index 0000000..c0d4b6f --- /dev/null +++ b/extensions/WikimediaBadges/WikimediaBadges.hooks.php @@ -0,0 +1,39 @@ +<?php + +namespace WikimediaBadges; + +use OutputPage; +use Skin; +use Wikibase\Settings; + +/** + * File defining the hook handlers for the WikimediaBadges extension. + * + * @since 0.1 + * + * @license GNU GPL v2+ + * @author Bene* < benestar.wikime...@gmail.com > + */ +final class Hooks { + + /** + * Handler for the BeforePageDisplay hook + * + * @since 0.1 + * + * @param OutputPage $out + * @param Skin $skin + * + * @return bool + */ + public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { + $skinName = $skin->getSkinName(); + if ( $skinName === 'vector' || $skinName === 'monobook' ) { + $out->addModules( 'wikimediaBadges.default' ); + } elseif ( $skinName === 'cologneblue' ) { + $out->addModules( 'wikimediaBadges.cologneblue' ); + } + return true; + } + +} diff --git a/extensions/WikimediaBadges/WikimediaBadges.php b/extensions/WikimediaBadges/WikimediaBadges.php new file mode 100644 index 0000000..d86d0a7 --- /dev/null +++ b/extensions/WikimediaBadges/WikimediaBadges.php @@ -0,0 +1,57 @@ +<?php + +/** + * Extension which contains different themes + * to display badges on Wikimedia projects + */ + +/** + * Entry point for for the WikimediaBadges extension. + * + * @see README.md + * @see https://github.com/wmde/WikimediaBadges + * @license GNU GPL v2+ + */ + +if ( !defined( 'MEDIAWIKI' ) ) { + die( 'Not an entry point.' ); +} + +if ( defined( 'WIKIMEDIA_BADGES_VERSION' ) ) { + // Do not initialize more than once. + return 1; +} + +define( 'WIKIMEDIA_BADGES_VERSION', '0.1 alpha' ); + +// This is the path to the autoloader generated by composer in case of a composer install. +if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + include_once( __DIR__ . '/vendor/autoload.php' ); +} + +$GLOBALS['wgExtensionFunctions'][] = function() { + global $wgExtensionCredits, $wgMessagesDirs, $wgHooks, $wgResourceModules; + + if ( !defined( 'WBC_VERSION' ) ) { + throw new Exception( 'The WikimediaBadges extension requires Wikibase Client to be installed.' ); + } + + $wgExtensionCredits['wikibase'][] = array( + 'path' => __DIR__, + 'name' => 'WikimediaBadges', + 'version' => WIKIMEDIA_BADGES_VERSION, + 'author' => '[[mw:User:Bene*|Bene*]]', + 'url' => 'https://github.com/wmde/WikimediaBadges', + 'descriptionmsg' => 'wikimedia-badges-desc' + ); + + // i18n + $wgMessagesDirs['WikimediaBadges'] = __DIR__ . '/i18n'; + + // Hooks + $wgHooks['BeforePageDisplay'][] = 'WikimediaBadges\Hooks::onBeforePageDisplay'; + + // Resource Loader modules + $wgResourceModules = array_merge( $wgResourceModules, include( __DIR__ . '/resources/Resources.php' ) ); + +}; diff --git a/extensions/WikimediaBadges/composer.json b/extensions/WikimediaBadges/composer.json new file mode 100644 index 0000000..bec0688 --- /dev/null +++ b/extensions/WikimediaBadges/composer.json @@ -0,0 +1,34 @@ +{ + "name": "wikibase/wikimedia-badges", + "description": "Extension which contains default themes to display badges on Wikimedia projects", + "type": "mediawiki-extension", + "version": "0.1-alpha", + "keywords": [ + "Wikidata", + "Wikibase" + ], + "homepage": "https://github.com/wmde/WikimediaBadges", + "license": "GNU GPL v2+", + "authors": [ + { + "name": "Bene*", + "email": "benestar.wikime...@gmail.com", + "homepage": "https://www.wikidata.org/wiki/User:Bene*", + "role": "Developer" + } + ], + "support": { + "irc": "irc://irc.freenode.net/wikidata" + }, + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "files": [ + "WikimediaBadges.php" + ], + "classmap": [ + "WikimediaBadges.hooks.php" + ] + } +} diff --git a/extensions/WikimediaBadges/i18n/en.json b/extensions/WikimediaBadges/i18n/en.json new file mode 100644 index 0000000..3a16dc2 --- /dev/null +++ b/extensions/WikimediaBadges/i18n/en.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Bene*" + ] + }, + "wikimedia-badges-desc": "Extension which contains default themes to display badges on Wikimedia projects" +} diff --git a/extensions/WikimediaBadges/i18n/qqq.json b/extensions/WikimediaBadges/i18n/qqq.json new file mode 100644 index 0000000..d7ada50 --- /dev/null +++ b/extensions/WikimediaBadges/i18n/qqq.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Bene*" + ] + }, + "wikimedia-badges-desc": "{{desc|name=WikimediaBadges|url=https://github.com/wmde/WikimediaBadges}}" +} diff --git a/extensions/WikimediaBadges/resources/Resources.php b/extensions/WikimediaBadges/resources/Resources.php new file mode 100644 index 0000000..0cbcf49 --- /dev/null +++ b/extensions/WikimediaBadges/resources/Resources.php @@ -0,0 +1,33 @@ +<?php + +/** + * WikimediaBadges ResourceLoader modules + * + * @since 0.1 + * + * @licence GNU GPL v2+ + * @author Bene* < benestar.wikime...@gmail.com > + */ + +return call_user_func( function() { + $remoteExtPathParts = explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR , __DIR__, 2 ); + $moduleTemplate = array( + 'localBasePath' => __DIR__, + 'remoteExtPath' => $remoteExtPathParts[1] + ); + + $modules = array( + 'wikimediaBadges.default' => $moduleTemplate + array( + 'styles' => array( + 'skins/default/wikimedia-badges.css' + ) + ), + 'wikimediaBadges.cologneblue' => $moduleTemplate + array( + 'styles' => array( + 'skins/cologneblue/wikimedia-badges.css' + ) + ) + ); + + return $modules; +} ); diff --git a/extensions/WikimediaBadges/resources/images/badge-golden-star.png b/extensions/WikimediaBadges/resources/images/badge-golden-star.png new file mode 100644 index 0000000..838df8e --- /dev/null +++ b/extensions/WikimediaBadges/resources/images/badge-golden-star.png Binary files differ diff --git a/extensions/WikimediaBadges/resources/images/badge-silver-star.png b/extensions/WikimediaBadges/resources/images/badge-silver-star.png new file mode 100644 index 0000000..4080d62 --- /dev/null +++ b/extensions/WikimediaBadges/resources/images/badge-silver-star.png Binary files differ diff --git a/extensions/WikimediaBadges/resources/skins/cologneblue/wikimedia-badges.css b/extensions/WikimediaBadges/resources/skins/cologneblue/wikimedia-badges.css new file mode 100644 index 0000000..106ae19 --- /dev/null +++ b/extensions/WikimediaBadges/resources/skins/cologneblue/wikimedia-badges.css @@ -0,0 +1,20 @@ +/** + * Styles for badges on client wikis in the Cologne Blue skin + * + * @since 0.1 + * + * @license GNU GPL v2+ + * @author Bene* < benestar.wikime...@gmail.com > + */ + +.badge-goodarticle:before { + /* @embed */ + content: url(../../images/badge-silver-star.png); + margin-right: .2em; +} + +.badge-featuredarticle:before { + /* @embed */ + content: url(../../images/badge-golden-star.png); + margin-right: .2em; +} diff --git a/extensions/WikimediaBadges/resources/skins/default/wikimedia-badges.css b/extensions/WikimediaBadges/resources/skins/default/wikimedia-badges.css new file mode 100644 index 0000000..324bce3 --- /dev/null +++ b/extensions/WikimediaBadges/resources/skins/default/wikimedia-badges.css @@ -0,0 +1,18 @@ +/** + * Styles for badges on client wikis in the Vector and MonoBook skins + * + * @since 0.1 + * + * @license GNU GPL v2+ + * @author Bene* < benestar.wikime...@gmail.com > + */ + +.badge-goodarticle { + /* @embed */ + list-style-image: url(../../images/badge-silver-star.png); +} + +.badge-featuredarticle { + /* @embed */ + list-style-image: url(../../images/badge-golden-star.png); +} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 88684c5..4433649 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -143,6 +143,8 @@ * @param string $prefix The prefix/namespace, with trailing '\\' * @param array|string $paths The PSR-0 base directories * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException */ public function addPsr4($prefix, $paths, $prepend = false) { @@ -204,6 +206,8 @@ * * @param string $prefix The prefix/namespace, with trailing '\\' * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException */ public function setPsr4($prefix, $paths) { diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index a88f995..6c5561a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -12,6 +12,7 @@ 'Composer\\Installers\\BaseInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BaseInstaller.php', 'Composer\\Installers\\BitrixInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', 'Composer\\Installers\\CakePHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', + 'Composer\\Installers\\ChefInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ChefInstaller.php', 'Composer\\Installers\\CodeIgniterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', 'Composer\\Installers\\Concrete5Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', 'Composer\\Installers\\CraftInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CraftInstaller.php', @@ -1032,6 +1033,7 @@ 'Wikibase\\WikibaseDiffOpFactory' => $baseDir . '/extensions/Wikibase/lib/includes/WikibaseDiffOpFactory.php', 'Wikibase\\util\\Test\\GenericEventDispatcherTest' => $baseDir . '/extensions/Wikibase/repo/tests/phpunit/includes/GenericEventDispatcherTest.php', 'WikidataOrg\\Hooks' => $baseDir . '/extensions/Wikidata.org/WikidataOrg.hooks.php', + 'WikimediaBadges\\Hooks' => $baseDir . '/extensions/WikimediaBadges/WikimediaBadges.hooks.php', 'importInterlang' => $baseDir . '/extensions/Wikibase/repo/maintenance/importInterlang.php', 'importProperties' => $baseDir . '/extensions/Wikibase/repo/maintenance/importProperties.php', ); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 251f046..d0bf17d 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -17,9 +17,10 @@ $vendorDir . '/data-values/number/Number.php', $vendorDir . '/data-values/geo/Geo.php', $vendorDir . '/wikibase/data-model-javascript/init.mw.php', - $vendorDir . '/wikibase/serialization-javascript/init.mw.php', $vendorDir . '/data-values/data-types/DataTypes.php', $vendorDir . '/data-values/validators/Validators.php', $baseDir . '/extensions/ValueView/ValueView.php', + $vendorDir . '/wikibase/serialization-javascript/init.mw.php', $baseDir . '/extensions/Wikibase/Wikibase.composer.php', + $baseDir . '/extensions/WikimediaBadges/WikimediaBadges.php', ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 60183ad..b1dfd0f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,145 +1,5 @@ [ { - "name": "composer/installers", - "version": "v1.0.16", - "version_normalized": "1.0.16.0", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "033679ad3cfc5ab759f9ed2a58881aeef13c342b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/033679ad3cfc5ab759f9ed2a58881aeef13c342b", - "reference": "033679ad3cfc5ab759f9ed2a58881aeef13c342b", - "shasum": "" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" - }, - "time": "2014-07-21 15:54:34", - "type": "composer-installer", - "extra": { - "class": "Composer\\Installers\\Installer", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Composer\\Installers\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle Robinson Young", - "email": "k...@dontkry.com", - "homepage": "https://github.com/shama" - } - ], - "description": "A multi-framework Composer library installer", - "homepage": "http://composer.github.com/installers/", - "keywords": [ - "Craft", - "Dolibarr", - "Hurad", - "MODX Evo", - "OXID", - "WolfCMS", - "agl", - "annotatecms", - "bitrix", - "cakephp", - "codeigniter", - "concrete5", - "croogo", - "drupal", - "elgg", - "fuelphp", - "installer", - "joomla", - "kohana", - "laravel", - "lithium", - "magento", - "mako", - "mediawiki", - "modulework", - "moodle", - "phpbb", - "piwik", - "ppi", - "puppet", - "roundcube", - "shopware", - "silverstripe", - "symfony", - "typo3", - "wordpress", - "zend", - "zikula" - ] - }, - { - "name": "propertysuggester/property-suggester", - "version": "v1.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/Wikidata-lib/PropertySuggester.git", - "reference": "2fb712f58c368a1151b3e8aeb09876ffa1f66913" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/2fb712f58c368a1151b3e8aeb09876ffa1f66913", - "reference": "2fb712f58c368a1151b3e8aeb09876ffa1f66913", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "satooshi/php-coveralls": "dev-master" - }, - "time": "2014-06-23 17:01:20", - "type": "mediawiki-extension", - "installation-source": "dist", - "autoload": { - "psr-4": { - "PropertySuggester\\": "src/PropertySuggester/" - }, - "files": [ - - ], - "classmap": [ - "PropertySuggesterHooks.php", - "maintenance/UpdateTable.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "description": "Extension for Wikibase to provide usefull suggestions for new properties", - "homepage": "https://github.com/Wikidata-lib/PropertySuggester", - "keywords": [ - "propertysuggester", - "wikibase", - "wikidata" - ] - }, - { "name": "wikibase/easyrdf_lite", "version": "0.8.1", "version_normalized": "0.8.1.0", @@ -222,121 +82,6 @@ "diffing", "diffop", "patching", - "wikidata" - ] - }, - { - "name": "wikibase/serialization-javascript", - "version": "1.1.1", - "version_normalized": "1.1.1.0", - "source": { - "type": "git", - "url": "https://github.com/wmde/WikibaseSerializationJavaScript.git", - "reference": "53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wmde/WikibaseSerializationJavaScript/zipball/53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028", - "reference": "53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028", - "shasum": "" - }, - "require": { - "data-values/javascript": "~0.5.0", - "wikibase/data-model-javascript": "~0.3.0" - }, - "time": "2014-07-10 12:57:32", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "init.mw.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com", - "role": "Developer" - }, - { - "name": "Daniel Werner", - "email": "danwe...@web.de", - "homepage": "https://www.mediawiki.org/wiki/User:Danwe", - "role": "Developer" - }, - { - "name": "H. Snater", - "email": "mediaw...@snater.com", - "homepage": "http://www.snater.com", - "role": "Developer" - }, - { - "name": "Adrian Lang", - "email": "adrian.l...@wikimedia.de" - } - ], - "description": "Wikibase datamodel serialization implementation in JavaScript" - }, - { - "name": "serialization/serialization", - "version": "3.2", - "version_normalized": "3.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/wmde/Serialization.git", - "reference": "7e13a0bc0173adc3aea0f16545e871e03a2ac4c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wmde/Serialization/zipball/7e13a0bc0173adc3aea0f16545e871e03a2ac4c4", - "reference": "7e13a0bc0173adc3aea0f16545e871e03a2ac4c4", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2014-05-20 15:57:52", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "Serialization.php" - ], - "psr-4": { - "Deserializers\\": "src/Deserializers/", - "Serializers\\": "src/Serializers/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com", - "role": "Developer" - } - ], - "description": "Library defining a Serializer and a Deserializer interface and basic utilities", - "homepage": "https://github.com/wmde/Serialization", - "keywords": [ - "deserialization", - "deserializer", - "serialization", - "serializer", - "unserialization", "wikidata" ] }, @@ -1121,57 +866,6 @@ "homepage": "https://www.mediawiki.org/wiki/Extension:ValueView" }, { - "name": "wikibase/data-model-javascript", - "version": "0.3.1", - "version_normalized": "0.3.1.0", - "source": { - "type": "git", - "url": "https://github.com/wmde/WikibaseDataModelJavascript.git", - "reference": "983e8b2b334a4ec4d4418b2e46728818921abfa0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wmde/WikibaseDataModelJavascript/zipball/983e8b2b334a4ec4d4418b2e46728818921abfa0", - "reference": "983e8b2b334a4ec4d4418b2e46728818921abfa0", - "shasum": "" - }, - "require": { - "data-values/javascript": "~0.5.0" - }, - "time": "2014-08-14 18:19:35", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "init.mw.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Adrian Lang", - "email": "adrian.l...@wikimedia.de" - }, - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com" - }, - { - "name": "Daniel Werner", - "homepage": "https://www.mediawiki.org/wiki/User:Danwe" - }, - { - "name": "H. Snater", - "homepage": "http://www.snater.com" - } - ], - "description": "Wikibase datamodel implementation in JavaScript" - }, - { "name": "wikibase/wikibase", "version": "dev-mw1.24-wmf17", "version_normalized": "dev-mw1.24-wmf17", @@ -1307,5 +1001,364 @@ "source": "https://github.com/wmde/Wikidata.org/tree/master", "issues": "https://github.com/wmde/Wikidata.org/issues" } + }, + { + "name": "composer/installers", + "version": "v1.0.18", + "version_normalized": "1.0.18.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "74fb0a7a1a23696d9c8cc2fba5903f6711cdd067" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/74fb0a7a1a23696d9c8cc2fba5903f6711cdd067", + "reference": "74fb0a7a1a23696d9c8cc2fba5903f6711cdd067", + "shasum": "" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + }, + "time": "2014-08-18 20:00:12", + "type": "composer-installer", + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Composer\\Installers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "k...@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "http://composer.github.com/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Hurad", + "MODX Evo", + "OXID", + "WolfCMS", + "agl", + "annotatecms", + "bitrix", + "cakephp", + "chef", + "codeigniter", + "concrete5", + "croogo", + "drupal", + "elgg", + "fuelphp", + "installer", + "joomla", + "kohana", + "laravel", + "lithium", + "magento", + "mako", + "mediawiki", + "modulework", + "moodle", + "phpbb", + "piwik", + "ppi", + "puppet", + "roundcube", + "shopware", + "silverstripe", + "symfony", + "typo3", + "wordpress", + "zend", + "zikula" + ] + }, + { + "name": "propertysuggester/property-suggester", + "version": "v1.1", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Wikidata-lib/PropertySuggester.git", + "reference": "fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1", + "reference": "fe77e3d6db4582d2b4cefbe51a1f74e8838f79d1", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "satooshi/php-coveralls": "dev-master" + }, + "time": "2014-07-25 01:45:14", + "type": "mediawiki-extension", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PropertySuggester\\": "src/PropertySuggester/" + }, + "files": [ + + ], + "classmap": [ + "PropertySuggesterHooks.php", + "maintenance/UpdateTable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Extension for Wikibase to provide usefull suggestions for new properties", + "homepage": "https://github.com/Wikidata-lib/PropertySuggester", + "keywords": [ + "propertysuggester", + "wikibase", + "wikidata" + ] + }, + { + "name": "wikibase/wikimedia-badges", + "version": "dev-master", + "version_normalized": "9999999-dev", + "source": { + "type": "git", + "url": "https://github.com/wmde/WikimediaBadges.git", + "reference": "b562f39a88b26a7b968931fe2ab13bd3a68b707e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/WikimediaBadges/zipball/b562f39a88b26a7b968931fe2ab13bd3a68b707e", + "reference": "b562f39a88b26a7b968931fe2ab13bd3a68b707e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2014-08-22 10:30:41", + "type": "mediawiki-extension", + "installation-source": "dist", + "autoload": { + "files": [ + "WikimediaBadges.php" + ], + "classmap": [ + "WikimediaBadges.hooks.php" + ] + }, + "license": [ + "GNU GPL v2+" + ], + "authors": [ + { + "name": "Bene*", + "email": "benestar.wikime...@gmail.com", + "homepage": "https://www.wikidata.org/wiki/User:Bene*", + "role": "Developer" + } + ], + "description": "Extension which contains default themes to display badges on Wikimedia projects", + "homepage": "https://github.com/wmde/WikimediaBadges", + "keywords": [ + "Wikibase", + "Wikidata" + ], + "support": { + "irc": "irc://irc.freenode.net/wikidata", + "source": "https://github.com/wmde/WikimediaBadges/tree/master", + "issues": "https://github.com/wmde/WikimediaBadges/issues" + } + }, + { + "name": "serialization/serialization", + "version": "3.2", + "version_normalized": "3.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/wmde/Serialization.git", + "reference": "7e13a0bc0173adc3aea0f16545e871e03a2ac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/Serialization/zipball/7e13a0bc0173adc3aea0f16545e871e03a2ac4c4", + "reference": "7e13a0bc0173adc3aea0f16545e871e03a2ac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2014-05-20 15:57:52", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "Serialization.php" + ], + "psr-4": { + "Deserializers\\": "src/Deserializers/", + "Serializers\\": "src/Serializers/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Jeroen De Dauw", + "email": "jeroended...@gmail.com", + "homepage": "http://jeroendedauw.com", + "role": "Developer" + } + ], + "description": "Library defining a Serializer and a Deserializer interface and basic utilities", + "homepage": "https://github.com/wmde/Serialization", + "keywords": [ + "deserialization", + "deserializer", + "serialization", + "serializer", + "unserialization", + "wikidata" + ] + }, + { + "name": "wikibase/data-model-javascript", + "version": "0.3.1", + "version_normalized": "0.3.1.0", + "source": { + "type": "git", + "url": "https://github.com/wmde/WikibaseDataModelJavascript.git", + "reference": "983e8b2b334a4ec4d4418b2e46728818921abfa0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/WikibaseDataModelJavascript/zipball/983e8b2b334a4ec4d4418b2e46728818921abfa0", + "reference": "983e8b2b334a4ec4d4418b2e46728818921abfa0", + "shasum": "" + }, + "require": { + "data-values/javascript": "~0.5.0" + }, + "time": "2014-08-14 18:19:35", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "init.mw.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Adrian Lang", + "email": "adrian.l...@wikimedia.de" + }, + { + "name": "Jeroen De Dauw", + "email": "jeroended...@gmail.com", + "homepage": "http://jeroendedauw.com" + }, + { + "name": "Daniel Werner", + "homepage": "https://www.mediawiki.org/wiki/User:Danwe" + }, + { + "name": "H. Snater", + "homepage": "http://www.snater.com" + } + ], + "description": "Wikibase datamodel implementation in JavaScript" + }, + { + "name": "wikibase/serialization-javascript", + "version": "1.1.1", + "version_normalized": "1.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/wmde/WikibaseSerializationJavaScript.git", + "reference": "53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/WikibaseSerializationJavaScript/zipball/53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028", + "reference": "53cc6abd5e8fd612bb408bf2bc0ad6fc234bb028", + "shasum": "" + }, + "require": { + "data-values/javascript": "~0.5.0", + "wikibase/data-model-javascript": "~0.3.0" + }, + "time": "2014-07-10 12:57:32", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "init.mw.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Jeroen De Dauw", + "email": "jeroended...@gmail.com", + "homepage": "http://jeroendedauw.com", + "role": "Developer" + }, + { + "name": "Daniel Werner", + "email": "danwe...@web.de", + "homepage": "https://www.mediawiki.org/wiki/User:Danwe", + "role": "Developer" + }, + { + "name": "H. Snater", + "email": "mediaw...@snater.com", + "homepage": "http://www.snater.com", + "role": "Developer" + }, + { + "name": "Adrian Lang", + "email": "adrian.l...@wikimedia.de" + } + ], + "description": "Wikibase datamodel serialization implementation in JavaScript" } ] diff --git a/vendor/composer/installers/README.md b/vendor/composer/installers/README.md index eff0d5a..cb77101 100644 --- a/vendor/composer/installers/README.md +++ b/vendor/composer/installers/README.md @@ -37,6 +37,7 @@ | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service` | Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme` | CakePHP 2+ | **`cakephp-plugin`** +| Chef | `chef-recipe`<br>`chef-role` | CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module` | concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update` | Craft | `craft-plugin` diff --git a/vendor/composer/installers/composer.json b/vendor/composer/installers/composer.json index c00f474..c398531 100644 --- a/vendor/composer/installers/composer.json +++ b/vendor/composer/installers/composer.json @@ -9,6 +9,7 @@ "AnnotateCms", "Bitrix", "CakePHP", + "Chef", "CodeIgniter", "concrete5", "Craft", diff --git a/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php index 870229b..df91a12 100644 --- a/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +++ b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php @@ -31,15 +31,47 @@ /** * Change the default plugin location when cakephp >= 3.0 */ - public function getLocations() { + public function getLocations() + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + $this->locations['plugin'] = 'plugins/{$name}/'; + } + return $this->locations; + } + + /** + * Add installer-name for CakePHP >= 3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $extra = $package->getExtra(); + if (empty($extra['installer-name']) && $this->matchesCakeVersion('>=', '3.0.0')) { + $this->setInstallerName($package); + } + return parent::getInstallPath($package, $frameworkType); + } + + /** + * Check if CakePHP version matches against a version + * + * @param string $matcher + * @param string $version + * @return bool + */ + protected function matchesCakeVersion($matcher, $version) + { $repositoryManager = $this->composer->getRepositoryManager(); if ($repositoryManager) { $repos = $repositoryManager->getLocalRepository(); if (!$repos) { - return $this->locations; + return false; } $cake3 = new MultiConstraint(array( - new VersionConstraint('>=', '3.0.0'), + new VersionConstraint($matcher, $version), new VersionConstraint('!=', '9999999-dev'), )); $pool = new Pool('dev'); @@ -48,11 +80,66 @@ foreach ($packages as $package) { $installed = new VersionConstraint('=', $package->getVersion()); if ($cake3->matches($installed)) { - $this->locations['plugin'] = 'plugins/{$name}/'; + return true; break; } } } - return $this->locations; + return false; } + + /** + * Set installer-name based on namespace for the source path checking in + * following order: + * + * - With only one autoload path the namespace for that path will be used. + * - With multiple paths if path 'src' exists it's namespace will be used. + * - With two autoload paths provided, the namespace of path other than + * 'tests' will be used. + * + * No installer-name is set if PSR-4 autoload block is not found or if none + * of the above conditions are met. + * + * @param PackageInterface $package + */ + protected function setInstallerName(PackageInterface $package) + { + $primaryNS = null; + $autoLoad = $package->getAutoload(); + foreach ($autoLoad as $type => $typeConfig) { + if ($type !== 'psr-4') { + continue; + } + $count = count($typeConfig); + + if ($count === 1) { + $primaryNS = key($typeConfig); + break; + } + + $matches = preg_grep('#^(\./)?src/?$#', $typeConfig); + if ($matches) { + $primaryNS = key($matches); + break; + } + + if ($count === 2) { + reset($typeConfig); + if (preg_match('#^(\./)?tests/?$#', current($typeConfig))) { + next($typeConfig); + } + $primaryNS = key($typeConfig); + break; + } + + break; + } + + if ($primaryNS) { + $package->setExtra(array( + 'installer-name' => trim(str_replace('\\', '/', $primaryNS), '/') + )); + } + } + } diff --git a/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php new file mode 100644 index 0000000..ab2f9aa --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php @@ -0,0 +1,11 @@ +<?php +namespace Composer\Installers; + +class ChefInstaller extends BaseInstaller +{ + protected $locations = array( + 'cookbook' => 'Chef/{$vendor}/{$name}/', + 'role' => 'Chef/roles/{$name}/', + ); +} + diff --git a/vendor/composer/installers/src/Composer/Installers/Installer.php b/vendor/composer/installers/src/Composer/Installers/Installer.php index 832950d..87080db 100644 --- a/vendor/composer/installers/src/Composer/Installers/Installer.php +++ b/vendor/composer/installers/src/Composer/Installers/Installer.php @@ -17,6 +17,7 @@ 'annotatecms' => 'AnnotateCmsInstaller', 'bitrix' => 'BitrixInstaller', 'cakephp' => 'CakePHPInstaller', + 'chef' => 'ChefInstaller', 'codeigniter' => 'CodeIgniterInstaller', 'concrete5' => 'Concrete5Installer', 'craft' => 'CraftInstaller', diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php index 2f571ae..3b15ea4 100644 --- a/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +++ b/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php @@ -101,6 +101,56 @@ $this->assertContains('plugins/', $result['plugin']); } + /** + * Test if installer-name was set + * + */ + public function testGetInstallPath() { + $autoload = array( + 'psr-4' => array( + 'FOC\\Authenticate' => '' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setType('cakephp-plugin'); + $rm = new RepositoryManager( + $this->getMock('Composer\IO\IOInterface'), + $this->getMock('Composer\Config') + ); + $this->composer->setRepositoryManager($rm); + $installer = new CakePHPInstaller($this->package, $this->composer); + + $this->setCakephpVersion($rm, '3.0.0'); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('FOC/Authenticate', $extra['installer-name']); + + $autoload = array( + 'psr-4' => array( + 'FOC\Acl\Test' => './tests', + 'FOC\Acl' => '' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setExtra(array()); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('FOC/Acl', $extra['installer-name']); + + $autoload = array( + 'psr-4' => array( + 'Foo\Bar' => 'foo', + 'Acme\Plugin\Test' => 'tests', + 'Acme\Plugin' => './src' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setExtra(array()); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('Acme/Plugin', $extra['installer-name']); + } + protected function setCakephpVersion($rm, $version) { $parser = new VersionParser(); list(, $version) = explode(' ', $parser->parseConstraints($version)); diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php index 47665c1..3d429d1 100644 --- a/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +++ b/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php @@ -95,6 +95,8 @@ array('cakephp-', false), array('cakephp-app', false), array('cakephp-plugin', true), + array('chef-cookbook', true), + array('chef-role', true), array('codeigniter-app', false), array('codeigniter-library', true), array('codeigniter-third-party', true), @@ -189,6 +191,8 @@ array('bitrix-component', 'local/components/my_component/', 'author/my_component'), array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'), array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'), + array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'), + array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'), array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'), array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'), array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'), -- To view, visit https://gerrit.wikimedia.org/r/156086 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idbf027b9dd1ecca520d83e5bc710ea22e16723fb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikidata Gerrit-Branch: mw1.24-wmf18 Gerrit-Owner: Aude <aude.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits