Open main menu

Extension:IDProvider

MediaWiki extensions manual
OOjs UI icon advanced.svg
IDProvider
Release status: stable
Implementation Parser function
Description Provides IDs using different ID algorithms
Author(s) Simon Heimler, gesinn.it
Latest version 1.1.2 (2019-02-06)
MediaWiki 1.27+
PHP 5.3+
Database changes Yes
Composer gesinn-it/id-provider
License MIT License
Download
Translate the IDProvider extension if it is available at translatewiki.net
Check usage and version matrix.

The IDProvider extension provides the generation of (unique) IDs through different ID algorithms. They can be accessed through parser functions, API or as a static PHP function.

There no dependencies on other extensions.

InstallationEdit

MW 1.25+Edit

wfLoadExtension( 'IDProvider' );

MW 1.24 and olderEdit

  • Download and place the file(s) in a directory called IDProvider in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/IDProvider/IDProvider.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Instead of downloading the zip archive you may also clone from Git:

git clone https://github.com/gesinn-it/IDProvider.git

Run Database UpdatesEdit

As this extension saves the current increments per prefix in a database table, you have to run php maintenance/update.php first!

UsageEdit

If you've got the ApiSandbox extension installed, it will display and document all available options. All parameters are given as key values and work the same way whether you use the parser function, api or a static php call.

Through parser functionsEdit

This makes most sense in combination with Page Forms. There it can be used for auto-creating unique page titles.

Please note that you should avoid spaces within the parser functions if you use it as a parameter of a Page Form info tag.

{{{info|page name={{#idprovider-increment:Feature_|padding=5}} }}}

#idprovider-incrementEdit

{{#idprovider-increment:}}
{{#idprovider-increment:Issue_}}
{{#idprovider-increment:
  |prefix=Issue_
  |padding=5
  |skipUniqueTest=true
}}

#idprovider-randomEdit

{{#idprovider-random:}}
{{#idprovider-random:uuid}}
{{#idprovider-random:fakeid}}
{{#idprovider-random:
  |type=uuid
  |skipUniqueTest=true
}}

Through the APIEdit

#idprovider-incrementEdit

  • api.php?action=idprovider-increment
  • api.php?action=idprovider-increment&prefix=Issue_&padding=8&skipUniqueTest=true

#idprovider-randomEdit

  • api.php?action=idprovider-random&type=uuid
  • api.php?action=idprovider-random&type=fakeid&prefix=Issue_&skipUniqueTest=true

Through a static PHP callEdit

For more examples, take a look at the unit-tests.

IDProviderFunctions::getIncrementEdit

$id = IDProviderFunctions::getIncrement(array(
	'prefix' => '___TEST___',
	'padding' => 8,
));

IDProviderFunctions::getRandomEdit

$id = IDProviderFunctions::getRandom(array(
	'type' => 'fakeid',
	'prefix' => 'PREFIX_',
));

ExamplesEdit

API CallEdit