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

אין תקציר עריכה
מ. רובין (שיחה | תרומות)
אין תקציר עריכה
 
שורה 22: שורה 22:
for k,v in pairs(self.templateParams) do
for k,v in pairs(self.templateParams) do
if mw.ustring.match( k, '-ויקינתונים') then
if mw.ustring.match( k, '-ויקינתונים') then
templateDocumentation = templateDocumentation .. '[[קטגוריה:תבניות שמשתמשות בוויקינתונים]]'
templateDocumentation = templateDocumentation .. '[[קטגוריה:תבניות מידע שמשתמשות בוויקינתונים]]'
break
break
end
end
שורה 65: שורה 65:
         :attr('dir', 'auto')
         :attr('dir', 'auto')
             :addClass(self.args.titleclass)
             :addClass(self.args.titleclass)
             :cssText(self.args.titlestyle)
             :cssText("display: table-caption; " .. (self.args.titlestyle or ""))
             :wikitext(self.args.title)
             :wikitext(self.args.title)


שורה 139: שורה 139:
end
end


--[[  
--[=[  
Adds edit links for easier editing of the template. If the template use data from wikidata it also adds edit link in Wikidata
Adds edit links for easier editing of the template. If the template use data from wikidata it also adds edit link in Wikidata
]]
]=]
function Infobox:renderEditLinks()
function Infobox:renderEditLinks()
local wbEdit='' -- link to wikidata
local wbEdit='' -- link to wikidata
if self.args.usingWikidata then
if self.args.usingWikidata then
wbEdit = '[[File:Wikidata-logo S.svg|22px|link=d:'..self.args.entityId..'|לעריכה בוויקינתונים שמשמש מקור לחלק מהמידע בתבנית]]'
wbEdit = '[[File:Wikidata-logo S.svg|22px|link=d:'..self.args.entityId..'|לעריכה בוויקינתונים שמשמש מקור לחלק מהמידע בתבנית]]'
wbEdit = wbEdit .. mw.ustring.format(' [[File:OOjs UI icon info big.svg|16px|link=%s]]', 'עזרה:תבנית מידע')
if not self.args.subtemplate then
wbEdit = wbEdit .. mw.ustring.format(' [[File:OOjs UI icon info big.svg|16px|link=%s]]', 'עזרה:תבנית מידע')
end
end
end
if #wbEdit > 0 then
if #wbEdit > 0 then
local wbEditAlignment = 'left'
if self.args.subtemplate then
wbEditAlignment = 'right'
end
self.root:tag('tr')
self.root:tag('tr')
:tag('td')
:tag('td')
:attr('colspan', 2)
:attr('colspan', 2)
:css('text-align','left')
:css('text-align', wbEditAlignment)
:wikitext(wbEdit)
:wikitext(wbEdit)
end
end
שורה 222: שורה 228:
function Infobox:removeEmptyHeaders()
function Infobox:removeEmptyHeaders()
  local lastHeaderIndex=nil
  local lastHeaderIndex=nil
  local removeFirstHeader = (not self.args.image or #self.args.image==0) -- remove the first header if there is no image
 
  local hasImage = (self.args.image~=nil and #self.args.image>0)
hasImage = hasImage or (self.args.rightImage~=nil and #self.args.rightImage>0)
hasImage = hasImage or (self.args.leftImage~=nil and #self.args.leftImage>0)  
 
local removeFirstHeader = nil
if self.args.removeFirstHeader~=nil then
removeFirstHeader = (not hasImage) and self.args.removeFirstHeader -- remove the first header if there are no images & the first header is generic
else
removeFirstHeader = (not hasImage)-- default, remove the first header if there are no images
end
 
  local tempTemplateStructure = {}
  local tempTemplateStructure = {}
  for i,v in pairs(self.templateStructure) do
  for i,v in pairs(self.templateStructure) do
שורה 232: שורה 248:
  if lastHeaderIndex then
  if lastHeaderIndex then
  if not removeFirstHeader then
  if not removeFirstHeader then
  table.insert(tempTemplateStructure, self.templateStructure[lastHeaderIndex])
  -- skip headers that are only spaces/nowiki - marking structure seperation
local headerData =mw.text.unstripNoWiki( self.templateStructure[lastHeaderIndex].data )
local headerDataNoSpace = mw.ustring.gsub(headerData, "%s", "")
if #headerDataNoSpace >0 then
table.insert(tempTemplateStructure, self.templateStructure[lastHeaderIndex])
end
  end
  end
  lastHeaderIndex = nil
  lastHeaderIndex = nil
שורה 249: שורה 270:
function Infobox:renderInfobox()
function Infobox:renderInfobox()
self:removeEmptyHeaders()
self:removeEmptyHeaders()
local hasImage = (self.args.image~=nil and #self.args.image>0)
hasImage = hasImage or (self.args.rightImage~=nil and #self.args.rightImage>0)
hasImage = hasImage or (self.args.leftImage~=nil and #self.args.leftImage>0)
-- error if there is no data/structure given to template from wiki page or wikidata
-- error if there is no data/structure given to template from wiki page or wikidata
if ((#self.templateStructure)==0) and not self.args.subtemplate then
if ((#self.templateStructure)==0) and not self.args.subtemplate and not hasImage then
local templateTitle = mw.getCurrentFrame():getParent():getTitle()
local templateTitle = mw.getCurrentFrame():getParent():getTitle()
errors = {}
--errors = {}
local templateName = mw.ustring.gsub(templateTitle, 'תבנית:', '', 1)
local templateName = mw.ustring.gsub(templateTitle, 'תבנית:', '', 1)
--[=[
if mw.title.getCurrentTitle().namespace==0 then
if mw.title.getCurrentTitle().namespace==0 then
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות בתבנית '..templateName..']]')
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות בתבנית '..templateName..']]')
שורה 264: שורה 289:
local report = 'תבנית {{' .. templateName .. '}} ריקה מתוכן. יש להזין פרמטרים בערך או בוויקינתונים. ' .. 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, {})]=]
return '<span class="empty-infobox error">תבנית ' .. templateName .. ' ריקה[[קטגוריה:דפים עם תבנית מידע ריקה]] [[קטגוריה:דפים עם תבנית ' .. templateName .. ' ריקה]]</span>'
end
end
שורה 304: שורה 330:
return nil
return nil
else
else
if not mw.ustring.match(valueArg, '^ *%[%[') and
-- wrap with wikisyntax if only filename provided. avoid that in case of tags or wikisyntaxed files
not mw.ustring.match(valueArg, '^ *%[%[') and  
if not mw.ustring.match(valueArg, '%[%[') and
  not  mw.ustring.match(valueArg, '^ *<') then
    not  mw.ustring.match(valueArg, '<') then
  local imgSuffix = '|'..args.width .. 'px'
  local imgSuffix = '|'..args.width .. 'px'
  if args.imgDesc~=nil and #args.imgDesc>0 then
  if args.imgDesc~=nil and #args.imgDesc>0 then
שורה 319: שורה 345:
else
else
valueArg = '[[File:' .. valueArg .. imgSuffix
valueArg = '[[File:' .. valueArg .. imgSuffix
end
elseif args.imgDesc~=nil and #args.imgDesc>0 and not mw.ustring.match(args.imgDesc, '%[%[קטגוריה:ערכים להחלפת תמונה בחופשית%]%]$') then
if mw.ustring.match(valueArg, '^ *%[%[[Ff]ile:') or
mw.ustring.match(valueArg, '^ *%[%[[Ii]mage:') or
mw.ustring.match(valueArg, '^ *%[%[קובץ:') or
mw.ustring.match(valueArg, '^ *%[%[תמונה:') then
valueArg = mw.ustring.gsub(valueArg, "%]%]$", "")
local imgSuffix = '|' .. args.imgDesc .. ']]'
valueArg = valueArg .. imgSuffix
end
end
end
end
return valueArg
return valueArg, args.imgDesc
end
end
end
end
שורה 357: שורה 392:
if hasData then
if hasData then
if options['formatter'] then
res = options['formatter'](res)
end
local link = mw.title.makeTitle( 0, entityId, propertyName, 'wikidata' ):fullUrl('uselang=he')
local link = mw.title.makeTitle( 0, entityId, propertyName, '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)
שורה 402: שורה 441:
local filterFunc = mw.ustring.match(templateParams[missingParam..'-ויקינתונים-סינון'],'filter[a-zA-Z]+')
local filterFunc = mw.ustring.match(templateParams[missingParam..'-ויקינתונים-סינון'],'filter[a-zA-Z]+')
wikidataOptions['filter'] = require(moduleTitle)[filterFunc]
wikidataOptions['filter'] = require(moduleTitle)[filterFunc]
end
if templateParams[missingParam..'-ויקינתונים-עיצוב'] and mw.ustring.match(templateParams[missingParam..'-ויקינתונים-עיצוב'], '[a-zA-Z]+') then
local moduleTitle = mw.ustring.match( frame:getParent():getTitle(), 'תבנית:(.+)' )
moduleTitle = mw.ustring.format('יחידה:%s', moduleTitle)
local formatFunc = templateParams[missingParam..'-ויקינתונים-עיצוב']
wikidataOptions['formatter'] = require(moduleTitle)[formatFunc]
end
end
שורה 410: שורה 456:
     table.insert(wikidataOptions['qualifiers'], v)
     table.insert(wikidataOptions['qualifiers'], v)
end
end
wikidataOptions['default-value'] = templateParams[missingParam..'-ויקינתונים-פרטים-ברירת מחדל'] or nil
end
end
if templateParams[missingParam..'-ויקינתונים-תמונה-גודל']~=nil then
if templateParams[missingParam..'-ויקינתונים-תמונה-גודל']~=nil then
wikidataOptions['img-width'] = templateParams[missingParam..'-ויקינתונים-תמונה-גודל']
wikidataOptions['img-width'] = templateParams[missingParam..'-ויקינתונים-תמונה-גודל']
end
end
if templateParams[missingParam..'-ויקינתונים'] then
if templateParams[missingParam..'-ויקינתונים'] then
if templateParams[missingParam..'-ויקינתונים-יחידה'] then
if templateParams[missingParam..'-ויקינתונים-יחידה'] then
שורה 430: שורה 478:
wikidataOptions['allowMulti'] = true
wikidataOptions['allowMulti'] = true
wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה']
wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה']
wikidataOptions['sort'] = { templateParams[missingParam..'-ויקינתונים-מרובה-מיון'] } or nil
if templateParams[missingParam..'-ויקינתונים-מרובה-מיון-יורד'] then
wikidataOptions['sort-order'] = 'desc'
end
paramsData = {}
paramsData = {}
-- split multiple params to include all of them (e.g: "P1,P2")
-- split multiple params to include all of them (e.g: "P1,P2")
שורה 448: שורה 500:
end
end
end
end
templateArg.data = table.concat(paramsData, wikidataOptions['seperator'])
if wikidataOptions['seperator'] == '*' and #paramsData>1 then
templateArg.data = '*' .. table.concat( paramsData, '\n*' )
else
templateArg.data = table.concat(paramsData, wikidataOptions['seperator'])
end
inWikidata = templateArg.data and #(templateArg.data)>0
inWikidata = templateArg.data and #(templateArg.data)>0
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then
שורה 454: שורה 510:
local wikidataParamValue = propertyLink.getLabel(templateParams[missingParam..'-ויקינתונים-פשוט'], entityId)
local wikidataParamValue = propertyLink.getLabel(templateParams[missingParam..'-ויקינתונים-פשוט'], entityId)
if wikidataParamValue and #wikidataParamValue>0 then
if wikidataParamValue and #wikidataParamValue>0 then
templateArg.data = frame:preprocess(mw.ustring.gsub(templateArg.data, '\{\{\{('..missingParam..')\}\}\}', wikidataParamValue))
templateArg.data = frame:preprocess(mw.ustring.gsub(templateArg.data, '{{{('..missingParam..')}}}', wikidataParamValue))
inWikidata = true
inWikidata = true
end
end
-- special cases
-- special cases
--[=[no wikidata/no OpenStreetMap
elseif missingParam == 'קואורדינטות' then
elseif missingParam == 'קואורדינטות' then
שורה 471: שורה 528:
['פריטים'] = entityId
['פריטים'] = entityId
} }
} }
end
end]=]
end
end
if inWikidata then
if inWikidata then
שורה 483: שורה 540:
return inWikidata, maintainceCats
return inWikidata, maintainceCats
end
end


--[[
--[[
שורה 497: שורה 553:
if templateParams[missingParam..'-ויקינתונים'] then
if templateParams[missingParam..'-ויקינתונים'] then
propertyName = templateParams[missingParam..'-ויקינתונים']
propertyName = templateParams[missingParam..'-ויקינתונים']
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName)
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName, entityId)
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then
propertyName = templateParams[missingParam..'-ויקינתונים-פשוט']
propertyName = templateParams[missingParam..'-ויקינתונים-פשוט']
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName)
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName, entityId)
elseif templateParams[missingParam..'-ויקינתונים-מרובה'] then
elseif templateParams[missingParam..'-ויקינתונים-מרובה'] then
local genderAware = templateParams[missingParam..'-ויקינתונים-מגדר'] == 'כן'
local genderAware = templateParams[missingParam..'-ויקינתונים-מגדר'] == 'כן'
propertyName =  templateParams[missingParam..'-ויקינתונים-מרובה']
propertyName =  templateParams[missingParam..'-ויקינתונים-מרובה']
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName)
matching = WikidataCrossValidation.crossValidate(templateArg, propertyName, entityId)
end
end
שורה 535: שורה 591:
if #propertyVals == 0 then propertyVals = mw.wikibase.getBestStatements(entityId, 'P1559') end
if #propertyVals == 0 then propertyVals = mw.wikibase.getBestStatements(entityId, 'P1559') end
if #propertyVals > 0 then
if #propertyVals > 0 then
local propValue = propertyVals[1].mainsnak and propertyVals[1].mainsnak.datavalue
for _,propertyVal in pairs(propertyVals) do
if  propValue and propValue.value and propValue.value.text and propValue.value.text~=name then
local propValue = propertyVal.mainsnak and propertyVal.mainsnak.datavalue
originName = mw.ustring.format('<span lang="%s" title="%s">%s</span>', propValue.value.language,  
-- by convention we pick single origin name
        mw.language.fetchLanguageName( propValue.value.language , 'he'), propValue.value.text)
if  propValue and propValue.value and propValue.value.text and propValue.value.text~=name and not originName then
    end
originName = mw.ustring.format('<span lang="%s" title="%s">%s</span>', propValue.value.language,  
        mw.language.fetchLanguageName( propValue.value.language , 'he'), propValue.value.text)
    end
end
end
end
end
end
if originName and #originName and originName~=name then
if originName and #originName and originName~=name then
name = name..'<br>'..originName
name = name..'<br>'..originName
שורה 558: שורה 615:
local templateStructure = {}
local templateStructure = {}
args.subtemplate = frame.args['תת-תבנית']
args.subtemplate = frame.args['תת-תבנית']
args.entityId = templateArgs['qid'] or templateParams['qid'] or mw.wikibase.getEntityIdForCurrentPage()
--[=[ no wikidata
if (templateArgs['qid'] ~= nil and templateArgs['qid'] ~= '') then
args.entityId = templateArgs['qid']
elseif (templateParams['qid'] ~= nil and templateParams['qid'] ~= '') then
args.entityId = templateParams['qid']
else
args.entityId = mw.wikibase.getEntityIdForCurrentPage()
end
]=]
args.entityId = ''
-- disable wikidata fetching
-- disable wikidata fetching
if args.entityId == '' or args.entityId == '-' then args.entityId = nil end
if args.entityId == '' or args.entityId == '-' then args.entityId = nil end
שורה 565: שורה 631:
args.titlestyle = templateParams['כותרת תבנית-עיצוב']
args.titlestyle = templateParams['כותרת תבנית-עיצוב']
args.titleclass = templateParams['כותרת תבנית-מחלקה']
args.titleclass = templateParams['כותרת תבנית-מחלקה']
args.subtitle = templateParams['תת כותרת תבנית']
args.subtitle = templateParams['תת-כותרת תבנית']
args.subtitlestyle = templateParams['תת כותרת תבנית-עיצוב']
args.subtitlestyle = templateParams['תת-כותרת תבנית-עיצוב']
args.subtitleclass = templateParams['תת כותרת תבנית-מחלקה']
args.subtitleclass = templateParams['תת-כותרת תבנית-מחלקה']
args.rightImage = getValueOrWikidataImage{
args.rightImageDesc = templateParams['כיתוב ימין']
args.rightImage, args.rightImageDesc = getValueOrWikidataImage{
valueArg=templateParams['תמונה ימין'],
valueArg=templateParams['תמונה ימין'],
wikidataArg=templateParams['תמונה ימין-ויקינתונים'],  
wikidataArg=templateParams['תמונה ימין-ויקינתונים'],
width='100x80',  
width=templateParams['תמונה ימין-גודל'] or '100x80',
imgDesc=args.rightImageDesc,
args=args
args=args
}
}
args.rightImageDesc = templateParams['כיתוב ימין']
args.leftImage = getValueOrWikidataImage{
args.leftImageDesc = templateParams['כיתוב שמאל']
args.leftImage, args.leftImageDesc = getValueOrWikidataImage{
valueArg=templateParams['תמונה שמאל'],
valueArg=templateParams['תמונה שמאל'],
wikidataArg=templateParams['תמונה שמאל-ויקינתונים'],  
wikidataArg=templateParams['תמונה שמאל-ויקינתונים'],
width='100x80',  
width=templateParams['תמונה שמאל-גודל'] or '100x80',
imgDesc=args.leftImageDesc,
args=args
args=args
}
}
args.leftImageDesc = templateParams['כיתוב שמאל']
 
args.imageDesc = templateParams['כיתוב']
args.imageDesc = templateParams['כיתוב']
args.image = getValueOrWikidataImage{
if templateParams['תמונה ללא שאיבה אוטומטית'] ==  'כן' then
valueArg=templateParams['תמונה'],
args.image, args.imageDesc = getValueOrWikidataImage{
wikidataArg=templateParams['תמונה-ויקינתונים'] or 'P18',
valueArg=templateParams['תמונה'],
width=templateParams['תמונה-גודל'] or '220',
wikidataArg=templateParams['תמונה-ויקינתונים'],
imgDesc=args.imageDesc,
width=templateParams['תמונה-גודל'] or '220',
args=args
imgDesc=args.imageDesc,
}
args=args
}
else
args.image, args.imageDesc = getValueOrWikidataImage{
valueArg=templateParams['תמונה'],
wikidataArg=templateParams['תמונה-ויקינתונים'] or 'P18',
width=templateParams['תמונה-גודל'] or '220',
imgDesc=args.imageDesc,
args=args
}
end
 
args.removeFirstHeader = false-- default based on vote on 18/7/21
    -- explictly override the default
    if templateParams['כותרת כללית'] ==  'כן' then
args.removeFirstHeader = true
elseif templateParams['כותרת כללית'] ==  'לא' then
args.removeFirstHeader = false
end
args.headerclass = templateParams['כותרת-מחלקה']
args.headerclass = templateParams['כותרת-מחלקה']
args.headerstyle = templateParams['כותרת-עיצוב']
args.headerstyle = templateParams['כותרת-עיצוב']
שורה 598: שורה 688:
args.tableclass = templateArgs['טבלה-מחלקה'] or templateParams['טבלה-מחלקה']
args.tableclass = templateArgs['טבלה-מחלקה'] or templateParams['טבלה-מחלקה']
local pageNs = mw.title.getCurrentTitle().namespace
local pageNs = mw.title.getCurrentTitle().namespace
local isSelfUse = (pageNs==10)
local subpageText = mw.title.getCurrentTitle().subpageText
local isSelfUse = (pageNs==10 and subpageText ~= "תיעוד")
self.autoDocumentation = templateParams['תיעוד-אוטומטי']
self.autoDocumentation = templateParams['תיעוד-אוטומטי']


local labelPrefix = 'תווית'
local labelPrefix = 'תווית'
local dataPrefix = 'מידע'
local dataPrefix = 'מידע'
local parameterDataPrefix = 'מידע-פרמטרי'
local subheader = 'כותרת'
local subheader = 'כותרת'
local labelDataPrefix = 'תווית-מידע'
local labelDataPrefix = 'תווית-מידע'
שורה 623: שורה 715:
else
else
local labelName = templateParams[labelPrefix..i]
local labelName = templateParams[labelPrefix..i]
local dataTemplate = templateParams[dataPrefix..i]
local dataTemplate = templateParams[dataPrefix..i] or templateParams[parameterDataPrefix..i]
if dataTemplate then
if dataTemplate then
-- if parameter contains only category with no value, replace with with nil and add teh value to maintaince category
-- if parameter contains only category with no value, replace with with nil and add the value to maintaince category
local hasData, maintainceCats = splitMaintainceCategory(dataTemplate)
local hasData, maintainceCats = splitMaintainceCategory(dataTemplate)
if maintainceCats and not hasData then
if maintainceCats and not hasData then
שורה 633: שורה 725:
end
end
if labelName and dataTemplate then
if labelName and dataTemplate then
--label: data type
if dataTemplate == templateParams[parameterDataPrefix..i] then
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix],  
local hasContent = templateArgs[dataTemplate] and #templateArgs[dataTemplate]>0
-- + and use explicit wikidata replace the content with such if available from wikidata
local isExplicitWikidataParam = templateParams[dataTemplate..explicitWikidata]
local isExplicitWikidataEnabled = false
if isExplicitWikidataParam then
isExplicitWikidataEnabled = templateArgs[dataTemplate]~=nil and mw.ustring.match(templateArgs[dataTemplate], '^ *+$')
end
local skipContent = false
if hasContent and not isExplicitWikidataEnabled then
dataTemplate = templateArgs[dataTemplate]
else
if isExplicitWikidataParam and not isExplicitWikidataEnabled then
skipContent = true
end
dataTemplate = '{{{' ..dataTemplate.. '}}}'
end
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})
end
else
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
elseif labelName and not dataTemplate then
elseif labelName and not dataTemplate then
--skip it. no only label [use subheader]
--skip it. no only label [use subheader]
elseif not labelName and dataTemplate then
elseif not labelName and dataTemplate then
--only data type
if dataTemplate == templateParams[parameterDataPrefix..i] then
table.insert(templateStructure, {data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], indic=indic})
local hasContent = templateArgs[dataTemplate] and #templateArgs[dataTemplate]>0
-- + and use explicit wikidata replace the content with such if available from wikidata
local isExplicitWikidataParam = templateParams[dataTemplate..explicitWikidata]
local isExplicitWikidataEnabled = false
if isExplicitWikidataParam then
isExplicitWikidataEnabled = templateArgs[dataTemplate]~=nil and mw.ustring.match(templateArgs[dataTemplate], '^ *+$')
end
local skipContent = false
if hasContent and not isExplicitWikidataEnabled then
dataTemplate = templateArgs[dataTemplate]
else
if isExplicitWikidataParam and not isExplicitWikidataEnabled then
skipContent = true
end
dataTemplate = '{{{' ..dataTemplate.. '}}}'
end
if not skipContent then
table.insert(templateStructure, {data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], indic=indic})
end
else
table.insert(templateStructure, {data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], indic=indic})
end
else
else
local label_data_names = templateParams[labelDataPrefix..i]
local label_data_names = templateParams[labelDataPrefix..i]
שורה 666: שורה 801:
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix],  
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
end
שורה 686: שורה 821:
table.insert(entriesToRemove, 1, k)
table.insert(entriesToRemove, 1, k)
else
else
-- otherwise if the template isn't full - try to use wikidata to fill it
-- otherwise if the template isn't full or if there is a Wikidata-beats tag - them try to use wikidata to fill it
local m = mw.ustring.match(v.data, '\{\{\{(.-)\}\}\}')
local m = mw.ustring.match(v.data, '{{{(.-)}}}')
if v.label and templateParams[v.label..'-ויקינתונים-גובר'] then
m = templateParams[v.label..'-ויקינתונים-גובר']
end
if m then
if m then
m = mw.uri.decode( m ) -- some templates may add encoding and are preprocessed before
m = mw.uri.decode( m ) -- some templates may add encoding and are preprocessed before
local before = v.data
local inWikidata, maintainceCats = fillMissingParamFromWikidata(m, templateParams, v, args.entityId, frame)
local inWikidata, maintainceCats = fillMissingParamFromWikidata(m, templateParams, v, args.entityId, frame)
if (v.data==nil or v.data=="") and v.label and templateParams[v.label..'-ויקינתונים-גובר'] then
v.data = before
inWikidata = true
end
if maintainceCats then
if maintainceCats then
table.insert(wikidataCats, maintainceCats)
table.insert(wikidataCats, maintainceCats)
שורה 712: שורה 856:
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, args.entityId)
local maintainceCats = nil --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)
שורה 723: שורה 867:
-- use wikidata in title
-- use wikidata in title
if args.title then
if args.title then
local m = mw.ustring.match(args.title, '\{\{\{(.-)\|?\}\}\}')  
local m = mw.ustring.match(args.title, '{{{(.-)|(?)}}}')  
if m then
if m then
local inWikidata = false
local inWikidata = false
שורה 735: שורה 879:
local wikidataParamValue = propertyLink.getLabel(templateParams[m..'-ויקינתונים-פשוט'])
local wikidataParamValue = propertyLink.getLabel(templateParams[m..'-ויקינתונים-פשוט'])
if wikidataParamValue then
if wikidataParamValue then
args.title = frame:preprocess(mw.ustring.gsub(args.title, '\{\{\{('..m..')\|?\}\}\}', wikidataParamValue))
args.title = frame:preprocess(mw.ustring.gsub(args.title, '{{{('..m..')\|?}}}', wikidataParamValue))
end
end
end
end
שורה 757: שורה 901:
return {
return {
['מידע']=infobox,
['מידע']=infobox,
Infobox=Infobox
Infobox=Infobox,
getValueOrWikidataImage=getValueOrWikidataImage
}
}