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

אין תקציר עריכה
אין תקציר עריכה
שורה 262: שורה 262:
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות מחוץ למרחב הערכים]]')
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות מחוץ למרחב הערכים]]')
end
end
local report = 'תבנית ריקה מתוכן. יש להזין פרמטרים בערך או בוויקינתונים. ' .. table.concat(errors, '')
local report = 'תבנית {{' .. templateName .. '}} ריקה מתוכן. יש להזין פרמטרים בערך או בוויקינתונים. ' .. table.concat(errors, '')
local ParamValidator = require('Module:ParamValidator')
local ParamValidator = require('Module:ParamValidator')
return ParamValidator.wrapReport(report, templateName, {})
return ParamValidator.wrapReport(report, templateName, {})
שורה 466: שורה 466:
This function fills missing parameter using wikidata
This function fills missing parameter using wikidata
]]
]]
function crossValidateWikidata(missingParam, templateParams, templateArg, frame)
function crossValidateWikidata(missingParam, templateParams, templateArg, frame, entityId)
local matching = nil
local matching = nil
local propertyName
local propertyName
if missingParam==nil then
 
if entityId == nil or missingParam==nil then
return nil
return nil
end
end
שורה 536: שורה 537:
args.subtemplate = frame.args['תת-תבנית']
args.subtemplate = frame.args['תת-תבנית']
args.entityId = templateArgs['qid'] or templateParams['qid'] or mw.wikibase.getEntityIdForCurrentPage()
args.entityId = templateArgs['qid'] or templateParams['qid'] or mw.wikibase.getEntityIdForCurrentPage()
-- disable wikidata fetching
if args.entityId == '' or args.entityId == '-' then args.entityId = nil end
args.title = frame.args['כותרת תבנית'] or standardTitle(templateArgs, args.subtemplate, args.entityId)
args.title = frame.args['כותרת תבנית'] or standardTitle(templateArgs, args.subtemplate, args.entityId)
if args.title=='-' then args.subtemplate = true end
if args.title=='-' then args.subtemplate = true end
שורה 583: שורה 586:
local rowStyleClassPrefix = 'מחלקה-שורה'
local rowStyleClassPrefix = 'מחלקה-שורה'
local styleSuffix = '-עיצוב'
local styleSuffix = '-עיצוב'
local explicitWikidata = '-ויקינתונים-מפורש'
local k=0
local k=0
local processedParams = {['0']=1} -- param0 may be used by Lua, not be template
local processedParams = {['0']=1} -- param0 may be used by Lua, not be template
שורה 620: שורה 624:
labelName = label_data_names
labelName = label_data_names
label_data_names = mw.text.trim(label_data_names, '%[%]')
label_data_names = mw.text.trim(label_data_names, '%[%]')
if templateArgs[label_data_names] and #templateArgs[label_data_names]>0 then
local hasContent = templateArgs[label_data_names] and #templateArgs[label_data_names]>0
-- + and use explicit wikidata replace the content with such if available from wikidata
local isExplicitWikidataParam = templateParams[label_data_names..explicitWikidata]
local isExplicitWikidataEnabled = false
if isExplicitWikidataParam then
isExplicitWikidataEnabled = templateArgs[label_data_names]~=nil and mw.ustring.match(templateArgs[label_data_names], '^ *+$')
end
local skipContent = false
if hasContent and not isExplicitWikidataEnabled then
dataTemplate = templateArgs[label_data_names]
dataTemplate = templateArgs[label_data_names]
else
else
if isExplicitWikidataParam and not isExplicitWikidataEnabled then
skipContent = true
end
dataTemplate = '{{{' ..label_data_names.. '}}}'
dataTemplate = '{{{' ..label_data_names.. '}}}'
end
end
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix],  
if not skipContent then
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix],  
labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic})
labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic})
end
end
end
end
end
שורה 665: שורה 683:
end
end
end
end
end
end
end
end
שורה 672: שורה 690:
for k,v in pairs(templateArgs) do
for k,v in pairs(templateArgs) do
if crossValidatedFields[k]==nil and v and #v>0 and pageNs==0 and k~= 'תמונה' then
if crossValidatedFields[k]==nil and v and #v>0 and pageNs==0 and k~= 'תמונה' then
local maintainceCats = crossValidateWikidata(k,templateParams, v, frame)
local maintainceCats = crossValidateWikidata(k,templateParams, v, frame, args.entityId)
if maintainceCats and #maintainceCats>0 then
if maintainceCats and #maintainceCats>0 then
table.insert(wikidataCats, maintainceCats)
table.insert(wikidataCats, maintainceCats)