|
|
Zeile 4: |
Zeile 4: |
| local WikidataUtilities = { | | local WikidataUtilities = { |
| suite = 'WikidataUtilities', | | suite = 'WikidataUtilities', |
| serial = '2021-03-18', | | serial = '2021-04-08', |
| item = 65439025 | | item = 65439025 |
| } | | } |
Zeile 15: |
Zeile 15: |
| } | | } |
|
| |
|
| -- module variable | | -- module variable and administration |
| local wu = {} | | local wu = { |
| | moduleInterface = WikidataUtilities |
| | } |
|
| |
|
| -- table storing property ids used | | -- table storing property ids used |
Zeile 474: |
Zeile 476: |
| end | | end |
| return result | | return result |
| end
| |
|
| |
| -- similar function like Modul:Failsafe
| |
| function wu._failsafe( version, moduleInterface )
| |
| if type( moduleInterface ) ~= 'table' then
| |
| return false
| |
| end
| |
|
| |
| local i, parent, v
| |
|
| |
| -- check if version is a frame table
| |
| if type( version ) == 'table' and type( version.args ) == 'table' then
| |
| v = version.args[ 1 ]
| |
| if not v and type( version.getParent ) == 'function' then
| |
| parent = version:getParent()
| |
| if parent then
| |
| v = parent.args[ 1 ]
| |
| end
| |
| end
| |
| version = v
| |
| end
| |
| -- version should be a string
| |
| if type( version ) == 'string' then
| |
| -- check if empty string
| |
| version = mw.text.trim( version )
| |
| if version == '' then
| |
| version = nil
| |
| end
| |
| else
| |
| version = nil
| |
| end
| |
|
| |
| -- getting version from Wikidata
| |
| if version == 'wikidata' then
| |
| version = nil
| |
| i = moduleInterface.item
| |
| if type( i ) == 'number' and i > 0 then
| |
| v = wu.getValue( 'Q' .. i, wd.version )
| |
| if v ~= '' then
| |
| return v
| |
| end
| |
| end
| |
| end
| |
|
| |
| if not moduleInterface.serial then
| |
| return false
| |
| elseif not version or version <= moduleInterface.serial then
| |
| return moduleInterface.serial
| |
| else
| |
| return false
| |
| end
| |
| end
| |
|
| |
| -- module administration
| |
| function wu.getModuleInterface()
| |
| return WikidataUtilities
| |
| end
| |
|
| |
| function wu.failsafe( version )
| |
| return wu._failsafe( version, WikidataUtilities ) or ''
| |
| end | | end |
|
| |
|
| return wu | | return wu |