nyurik / OsmWikibase

Wikibase customizations for OpenStreetMap
MIT License
1 stars 2 forks source link

MediaWiki extension to customize the Wikibase on OSM Wiki.

Implemented

Work in progress

This turned out to be much more difficult than anticipated. The work has been moved to the customPrefix branch. The proposed solution works for creating and editing items, but it breaks when a sitelink needs to be resolved into a Wikibase ID.

Custom Site object

To customize site link normalization, use OsmWikibase\OsmSite instead of Site object. This code assumes you want wiki as the site ID.

.../mediawki$ php maintenance/shell.php
>>>
  $site = new OsmWikibase\OsmSite();
  $site->setGlobalId( 'wiki' );
  $site->setGroup( 'osm' );
  $site->setPath( Site::PATH_LINK, "https://wiki.openstreetmap.org/wiki/$1" );

  // If updating, make sure to keep internal ID  
  $store = SiteSQLStore::newInstance();
  $oldSite = $store->getSite( $site->getGlobalId() );
  if ( $oldSite ) $site->setInternalId( $oldSite->getInternalId() );
  $store->saveSites( [ $site ] );