בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,381
רעדאגירונגען
אין תקציר עריכה |
(אפדעיט) |
||
| שורה 6: | שורה 6: | ||
if parameter~=nil then return parameter, false end | if parameter~=nil then return parameter, false end | ||
return nil, false | return nil, false | ||
end | |||
--[[ | |||
This function fills missing parameter using wikidata | |||
]] | |||
function crossValidateWikidata(missingParam, templateParams, templateArg, frame, entityId) | |||
local WikidataCrossValidation = require('Module:WikidataCrossValidation') | |||
local matching = nil | |||
local propertyName | |||
if entityId == nil or missingParam==nil then | |||
return nil | |||
end | |||
if templateParams[missingParam..'-ויקינתונים'] then | |||
propertyName = templateParams[missingParam..'-ויקינתונים'] | |||
if mw.ustring.find(propertyName, ',')~=nil then return end | |||
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName, entityId) | |||
end | |||
if matching then | |||
return WikidataCrossValidation.maintainceCategory(matching, propertyName) | |||
end | |||
end | end | ||
| שורה 11: | שורה 33: | ||
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true }) | local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true }) | ||
local res = '' | local res = '' | ||
local maintainceCategory = '' | |||
local entityId = args['qid'] | local entityId = args['qid'] | ||
if (entityId == '-' or entityId=='') then entityId = nil end | if (entityId == '-' or entityId=='') then entityId = nil end | ||
| שורה 20: | שורה 42: | ||
local wikidataStartDate = args['תאריך התחלה-ויקינתונים'] or 'P580' | local wikidataStartDate = args['תאריך התחלה-ויקינתונים'] or 'P580' | ||
local wikidataEndDate = args['תאריך סיום-ויקינתונים'] or 'P582' | local wikidataEndDate = args['תאריך סיום-ויקינתונים'] or 'P582' | ||
local wikidataEndDateLimit = args['גבול תאריך סיום-ויקינתונים'] | |||
local showEditWikidata = true | local showEditWikidata = true | ||
-- text to show if we have only end date. Example: "Last even - %s" where %s is time. nil - will not show end date | -- text to show if we have only end date. Example: "Last even - %s" where %s is time. nil - will not show end date | ||
local onlyEndDateText = args['טקסט סיום'] | local onlyEndDateText = args['טקסט סיום'] | ||
| שורה 33: | שורה 56: | ||
if entityId~=nil then | if entityId~=nil then | ||
local crossValBegin = crossValidateWikidata('תאריך התחלה', frame.args, startDate, frame, entityId) | |||
if crossValBegin~=nil then maintainceCategory = maintainceCategory ..crossValBegin end | |||
local crossvalEnd = crossValidateWikidata('תאריך סיום', frame.args, endDate, frame, entityId) | |||
if crossvalEnd~=nil then maintainceCategory= maintainceCategory ..crossvalEnd end | |||
-- todo: support different fallbacks for properties | -- todo: support different fallbacks for properties | ||
local usingWikidataStartDate = false | local usingWikidataStartDate = false | ||
| שורה 39: | שורה 68: | ||
local usingWikidataDuration = false | local usingWikidataDuration = false | ||
wikidataStartDate = mw.text.split( wikidataStartDate, ' *, *', false ) | wikidataStartDate = mw.text.split( wikidataStartDate, ' *, *', false ) | ||
wikidataEndDate = mw.text.split( wikidataEndDate, ' *, *', false ) | wikidataEndDate = mw.text.split( wikidataEndDate, ' *, *', false ) | ||
| שורה 46: | שורה 76: | ||
for _, wikidataEndProp in pairs(wikidataEndDate) do | for _, wikidataEndProp in pairs(wikidataEndDate) do | ||
endDate, usingWikidataEndDate = WikidataSimpleFill(endDate, entityId, wikidataEndProp ) | endDate, usingWikidataEndDate = WikidataSimpleFill(endDate, entityId, wikidataEndProp ) | ||
end | |||
if endDate == '' or endDate == nil and wikidataEndDateLimit~=nil and wikidataEndDateLimit~='' then | |||
-- fallback | |||
endDate, usingWikidataEndDate = WikidataSimpleFill(endDate, entityId, wikidataEndDateLimit ) | |||
end | end | ||
| שורה 134: | שורה 169: | ||
local link = mw.title.makeTitle( 0, entityId, '', 'wikidata' ):fullUrl('uselang=he') | local link = mw.title.makeTitle( 0, entityId, '', 'wikidata' ):fullUrl('uselang=he') | ||
res = res .. mw.ustring.format(' [[File:Blue pencil RTL.svg|15px|link=%s|עריכת הנתון בוויקינתונים]]', link) | res = res .. mw.ustring.format(' [[File:Blue pencil RTL.svg|15px|link=%s|עריכת הנתון בוויקינתונים]]', link) | ||
end | |||
if maintainceCategory~=nil and res~=nil then | |||
res = res..maintainceCategory | |||
end | end | ||
return res | return res | ||
end | end | ||
רעדאגירונגען