אונטערשייד צווישן ווערסיעס פון "יחידה:תבנית מידע"

קיין רעדאגירונג באמערקונג
ק (1 רעוויזיע אימפארטירט פון wikipedia:he:יחידה:תבנית_מידע: אימפארטירט פון די העברעאישע וויקיפעדיע. זע דארט ביישטייערער ליסטע)
אין תקציר עריכה
שורה 143: שורה 143:
]]
]]
function Infobox:renderEditLinks()
function Infobox:renderEditLinks()
local wbEdit='' -- link to wikidata
if self.args.usingWikidata then
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]]', 'עזרה:תבנית מידע')
end
if #wbEdit > 0 then
self.root:tag('tr')
:tag('td')
:attr('colspan', 2)
:css('text-align','left')
:wikitext(wbEdit)
end
end
end


שורה 210: שורה 222:
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
שורה 237: שורה 259:
function Infobox:renderInfobox()
function Infobox:renderInfobox()
self:removeEmptyHeaders()
self:removeEmptyHeaders()
 
-- 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
local templateTitle = mw.getCurrentFrame():getParent():getTitle()
errors = {}
local templateName = mw.ustring.gsub(templateTitle, 'תבנית:', '', 1)
if mw.title.getCurrentTitle().namespace==0 then
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות בתבנית '..templateName..']]')
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות בתבנית מידע]]')
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות]]' )
else
table.insert(errors, '[[קטגוריה:שגיאות פרמטריות מחוץ למרחב הערכים]]')
end
local report = 'תבנית {{' .. templateName .. '}} ריקה מתוכן. יש להזין פרמטרים בערך או בוויקינתונים. ' .. table.concat(errors, '')
local ParamValidator = require('Module:ParamValidator')
return ParamValidator.wrapReport(report, templateName, {})
end
-- sub infobox
-- sub infobox
if self.args.subtemplate then
if self.args.subtemplate then
שורה 290: שורה 329:
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, "%]%]$", "")
mw.log(args.imgDesc)
local imgSuffix = '|' .. args.imgDesc .. ']]'
valueArg = valueArg .. imgSuffix
end
end
end
end
שורה 401: שורה 450:
wikidataOptions['allowMulti'] = true
wikidataOptions['allowMulti'] = true
wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה']
wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה']
wikidataOptions['sort'] = templateParams[missingParam..'-ויקינתונים-מרובה-מיון'] or nil
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")
שורה 468: שורה 518:
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
שורה 529: שורה 579:
local templateStructure = {}
local templateStructure = {}
args.subtemplate = frame.args['תת-תבנית']
args.subtemplate = frame.args['תת-תבנית']
args.entityId = templateArgs['qid'] or templateParams['qid']
args.entityId = templateArgs['qid'] or templateParams['qid'] or mw.wikibase.getEntityIdForCurrentPage()
-- 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
שורה 554: שורה 604:
args.leftImageDesc = templateParams['כיתוב שמאל']
args.leftImageDesc = templateParams['כיתוב שמאל']
args.imageDesc = templateParams['כיתוב']
args.imageDesc = templateParams['כיתוב']
args.image = getValueOrWikidataImage{
if templateParams['תמונה ללא שאיבה אוטומטית'] ==  'כן' then
valueArg=templateParams['תמונה'],
args.image = 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 = 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['כותרת-עיצוב']
שורה 569: שורה 638:
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['תיעוד-אוטומטי']


אַנאנימער באַניצער