Extension:IDProvider
Appearance
IDProvider Release status: stable |
|
---|---|
Implementation | Parser function |
Description | Provides IDs using different ID algorithms |
Author(s) | Simon Heimler, Alexander Gesinn |
Maintainer(s) | gesinn.it |
Latest version | 3.0.0 (2024-12-16) |
MediaWiki | 1.39+ |
Database changes | Yes |
Composer | gesinn-it/id-provider |
License | MIT License |
Download | GitHub: Note: |
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.
Installation
[edit]- Download, extract and place the file(s) in a directory called
IDProvider
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'IDProvider' );
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Installation via Composer is broken.
Usage
[edit]The ApiSandbox 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 functions
[edit]This makes most sense in combination with Page Forms . There it can be used for auto-creating unique page titles.
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-increment
[edit]{{#idprovider-increment:}}
{{#idprovider-increment:Issue_}}
{{#idprovider-increment:
|prefix=Issue_
|padding=5
|skipUniqueTest=true
}}
#idprovider-random
[edit]{{#idprovider-random:}}
{{#idprovider-random:uuid}}
{{#idprovider-random:fakeid}}
{{#idprovider-random:
|type=uuid
|skipUniqueTest=true
}}
Through the API
[edit]#idprovider-increment
[edit]- api.php?action=idprovider-increment
- api.php?action=idprovider-increment&prefix=Issue_&padding=8&skipUniqueTest=true
#idprovider-random
[edit]- api.php?action=idprovider-random&type=uuid
- api.php?action=idprovider-random&type=fakeid&prefix=Issue_&skipUniqueTest=true
Through a static PHP call
[edit]For more examples, take a look at the unit-tests.
IDProviderFunctions::getIncrement
[edit]$id = IDProviderFunctions::getIncrement([
'prefix' => '___TEST___',
'padding' => 8,
]);
IDProviderFunctions::getRandom
[edit]$id = IDProviderFunctions::getRandom([
'type' => 'fakeid',
'prefix' => 'PREFIX_',
]);
See also
[edit]- Extension:IDGenerator - Provides a parser function for numeric IDs. Alternative to IDProvider that can be installed via Composer.
This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |