יחידה:תבנית מידע: הבדלים בין גרסאות בדף

מאין תקציר עריכה
ניסוי
שורה 300: שורה 300:
end
end
end
end
if wikidataArg then  
if not empty(wikidataArg) then  
return propertyLink.getImageLink(wikidataArg, width)
return propertyLink.getImageLink(wikidataArg, width)
end
end
שורה 319: שורה 319:
This function fills missing parameter using wikidata
This function fills missing parameter using wikidata
]]
]]
function empty(p)
mw.log('calling empty. p=', p)
return not p or mw.text.trim(p) == ''
end
function fillMissingParamFromWikidata(missingParam, templateParams, templateArg, frame)
function fillMissingParamFromWikidata(missingParam, templateParams, templateArg, frame)
local inWikidata = false
local inWikidata = false
שורה 324: שורה 330:
local maintainceCats = nil
local maintainceCats = nil
local propertyName = nil
local propertyName = nil
if templateParams[missingParam..'-ויקינתונים'] then
if not empty(templateParams[missingParam..'-ויקינתונים']) then
templateArg.data = propertyLink.getProperty(templateParams[missingParam..'-ויקינתונים']) or nil
templateArg.data = propertyLink.getProperty(templateParams[missingParam..'-ויקינתונים']) or nil
inWikidata = templateArg.data and #(templateArg.data)>0
inWikidata = templateArg.data and #(templateArg.data)>0
elseif templateParams[missingParam..'-ויקינתונים-מרובה'] then
elseif not empty(templateParams[missingParam..'-ויקינתונים-מרובה']) then
mw.log('wikidata-many: ', missingParam, templateParams[missingParam..'-ויקינתונים-מרובה'])
templateArg.data = propertyLink.getProperty(templateParams[missingParam..'-ויקינתונים-מרובה'], true, false, nil, templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה'], templateParams[missingParam..'-ויקינתונים-פרטים']) or nil
templateArg.data = propertyLink.getProperty(templateParams[missingParam..'-ויקינתונים-מרובה'], true, false, nil, templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה'], templateParams[missingParam..'-ויקינתונים-פרטים']) or nil
inWikidata = templateArg.data and #(templateArg.data)>0
inWikidata = templateArg.data and #(templateArg.data)>0
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then
elseif not empty(templateParams[missingParam..'-ויקינתונים-פשוט']) then
-- use data should be taken from wikidata and link must not be added
-- use data should be taken from wikidata and link must not be added
local wikidataParamValue = propertyLink.getLabel(templateParams[missingParam..'-ויקינתונים-פשוט'])
local wikidataParamValue = propertyLink.getLabel(templateParams[missingParam..'-ויקינתונים-פשוט'])
שורה 344: שורה 351:
hasData, maintainceCats = splitMaintainceCategory(templateArg.data)
hasData, maintainceCats = splitMaintainceCategory(templateArg.data)
if hasData then
if hasData then
propertyName=templateParams[missingParam..'-ויקינתונים'] or templateParams[missingParam..'-ויקינתונים-מרובה']
propertyName=templateParams[missingParam..'-ויקינתונים'] or templateParams[missingParam..'-ויקינתונים-מרובה']-- very suspicious!emptystring evaluates to true in lua!!!
if propertyName then
if propertyName then
templateArg.data = templateArg.data.. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..mw.wikibase.getEntityIdForCurrentPage().. '?uselang=he#'..propertyName..'|עריכת הנתון בוויקינתונים]]'
templateArg.data = templateArg.data.. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..mw.wikibase.getEntityIdForCurrentPage().. '?uselang=he#'..propertyName..'|עריכת הנתון בוויקינתונים]]'
שורה 479: שורה 486:
if m then
if m then
local inWikidata = false
local inWikidata = false
if templateParams[m..'-ויקינתונים'] then
if not empty(templateParams[m..'-ויקינתונים']) then
local wikidataParamValue = propertyLink.getProperty(templateParams[m..'-ויקינתונים']) or nil
local wikidataParamValue = propertyLink.getProperty(templateParams[m..'-ויקינתונים']) or nil
if wikidataParamValue then
if wikidataParamValue then
args.title = wikidataParamValue
args.title = wikidataParamValue
end
end
elseif templateParams[m..'-ויקינתונים-פשוט'] then
elseif not empty(templateParams[m..'-ויקינתונים-פשוט']) then
-- use data should be taken from wikidata and link must not be added
-- use data should be taken from wikidata and link must not be added
local wikidataParamValue = propertyLink.getLabel(templateParams[m..'-ויקינתונים-פשוט'])
local wikidataParamValue = propertyLink.getLabel(templateParams[m..'-ויקינתונים-פשוט'])