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

אפדעיט
(דא איז דער לאך. קרויז אויס אידישע דאטום צו רעכענען אויך בעפאר קביעת הלוח)
(אפדעיט)
 
(14 מיטלסטע ווערסיעס פון 2 באַניצער נישט געוויזן.)
שורה 1: שורה 1:
local Infobox = require('Module:תבנית מידע').Infobox
local dataTemplateModule = require('Module:תבנית מידע')
local Infobox = dataTemplateModule.Infobox
local BackgroundColors = mw.loadJsonData('Module:תבנית מידע/אישיות/צבע רקע לפי סיווג.json')
local LocationAndCountry = require('Module:LocationAndCountry')
local LocationAndCountry = require('Module:LocationAndCountry')
local PropertyLink = require('Module:PropertyLink')
local PropertyLink = require('Module:PropertyLink')
שורה 6: שורה 8:
local hebrewDateModule = require('Module:אידישע דאטום')
local hebrewDateModule = require('Module:אידישע דאטום')
local WikidataCrossValidation = require('Module:WikidataCrossValidation')
local WikidataCrossValidation = require('Module:WikidataCrossValidation')
local siteModule = require('Module:תבנית מידע/אתר')
local TimeRange = require('Module:טווח זמנים')
local gim = require( "Module:גימטריה" )
local gim = require( "Module:גימטריה" )
function count(str, substring)
function count(str, substring)
     local count = 0
     local count = 0
שורה 14: שורה 17:
     end)
     end)
     return count
     return count
end
function enclosed(s)
return mw.ustring.sub(s, 1, 2) == "[[" and mw.ustring.sub(s, -2) == "]]" and count(s, "%[%[") == 1
end
end


שורה 20: שורה 26:
function getSpeculativeDate(generalDate, hebrewDate)
function getSpeculativeDate(generalDate, hebrewDate)
if generalDate == '-' then return nil end
if generalDate == '-' then return nil end
if generalDate~=nil and generalDate~='' then return generalDate end
if generalDate ~= nil and generalDate ~= '' then return generalDate end
if hebrewDate~=nil and hebrewDate~='' then
if hebrewDate ~= nil and hebrewDate ~= '' then
local success, sepcDate = pcall(hebrewDateModule.pick, mw.getCurrentFrame():newChild{ args = {hebrew=hebrewDate, world='', exact='כן' } })
local success, sepcDate = pcall(hebrewDateModule.pick, mw.getCurrentFrame():newChild{ args = {hebrew=hebrewDate, world='', exact='כן' } })
if not success or sepcDate=='' then return nil end
if not success or sepcDate == '' then return nil end
return sepcDate
return sepcDate
end
end
return nil
return nil
end
local function getPencilLink(entityId, prop)
if not entityId then return '' end
return string.format(' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/%s?uselang=he#%s|עריכת הנתון בוויקינתונים]]', entityId, prop)
end
end


שורה 32: שורה 43:
local result=''
local result=''
local fromWikidata=nil
local fromWikidata=nil
entityId = entityId
entityId = nil
if ( deathCause == nil or deathCause =='' ) and entityId ~= nil then
if ( deathCause == nil or deathCause == '' ) and entityId ~= nil then
local deathCauseWikidata = mw.wikibase.getBestStatements(entityId, 'P1196')
local deathCauseWikidata = mw.wikibase.getBestStatements(entityId, 'P1196')
deathCauseWikidata = deathCauseWikidata and deathCauseWikidata[1] and deathCauseWikidata[1].mainsnak
deathCauseWikidata = deathCauseWikidata and deathCauseWikidata[1] and deathCauseWikidata[1].mainsnak
שורה 49: שורה 60:
elseif deathCause == 'נרצח' or deathCause == 'נרצחה' or deathCause == 'רצח' or deathCause == 'רצח המוני' or deathCause == 'רעל' then
elseif deathCause == 'נרצח' or deathCause == 'נרצחה' or deathCause == 'רצח' or deathCause == 'רצח המוני' or deathCause == 'רעל' then
return (gender=='נקבה' and 'נרצחה') or 'נרצח'
return (gender=='נקבה' and 'נרצחה') or 'נרצח'
    elseif deathCause == 'התאבד' or deathCause == 'התאבדה' or deathCause == 'התאבדות' then
elseif deathCause == 'התאבד' or deathCause == 'התאבדה' or deathCause == 'התאבדות' then
return (gender=='נקבה' and 'התאבדה') or 'התאבד'
return (gender=='נקבה' and 'התאבדה') or 'התאבד'
elseif deathCause == 'הוצא להורג' or deathCause == 'הוצאה להורג' or deathCause == 'עונש מוות' or deathCause == 'תלייה' then
elseif deathCause == 'הוצא להורג' or deathCause == 'הוצאה להורג' or deathCause == 'עונש מוות' or deathCause == 'תלייה' then
return 'הוצאה להורג'
return 'הוצאה להורג'
elseif not fromWikidata then result='[[קאטעגאריע:ערכים עם סיבת מוות שגויה בתבנית]]'
elseif not fromWikidata then result = '[[קאטעגאריע:ערכים עם סיבת מוות שגויה בתבנית]]'
end
end
end
end
שורה 60: שורה 71:


function getEventDetails(generalDate, hebDate, eventPlace, propDate, propPlace, age, usingWikidata, infoObj)
function getEventDetails(generalDate, hebDate, eventPlace, propDate, propPlace, age, usingWikidata, infoObj)
entityId = infoObj.args.entityId
entityId = nil --infoObj.args.entityId or mw.wikibase.getEntityIdForCurrentPage()
age = age or ''
age = age or ''
local formattedEvent = ''
local formattedEvent = ''
local placeDate = propDate
local placeDate = propDate
if generalDate~=nil and generalDate~='' then
if generalDate ~= nil and generalDate ~= '' then
local success, placeDateParsed = pcall(Date.newFromWikitext, generalDate)
local success, placeDateParsed = pcall(Date.newFromWikitext, generalDate)
if success then
if success then
placeDate = placeDateParsed
placeDate = placeDateParsed
end
end
formattedEvent = generalDate .. age
formattedEvent = generalDate .. age
if hebDate~=nil and hebDate~='' then  
if hebDate ~= nil and hebDate ~= '' then  
formattedEvent = formattedEvent ..'<br/>' ..hebDate
formattedEvent = formattedEvent .. '<br/>' .. hebDate
end
end
elseif hebDate~=nil and hebDate~='' then
elseif hebDate ~= nil and hebDate ~= '' then
formattedEvent = hebDate .. age
formattedEvent = hebDate .. age
end
end
if (eventPlace == nil or eventPlace == '') and entityId then
if (eventPlace == nil or eventPlace == '') and entityId then
local success, res = pcall(LocationAndCountry.displayFromParams, propPlace, entityId, placeDate , 1)
local success, res = pcall(LocationAndCountry.displayFromParams, propPlace, entityId, placeDate , 1)
if success and res and #res>0 then
if success and res and #res > 0 then
usingWikidata = true
usingWikidata = true
eventPlace = res
eventPlace = res
שורה 86: שורה 97:
local pageNs = mw.title.getCurrentTitle().namespace
local pageNs = mw.title.getCurrentTitle().namespace
if pageNs==0 and not infoObj.isNonPerson then
if pageNs==0 and not infoObj.isNonPerson then
local matching = WikidataCrossValidation.crossValidate(eventPlace, propPlace, entityId )
local matching = WikidataCrossValidation.crossValidate(eventPlace, propPlace, entityId)
if matching then
if matching then
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, propPlace))
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, propPlace))
שורה 98: שורה 109:
if usingWikidata and entityId then
if usingWikidata and entityId then
formattedEvent = formattedEvent .. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..entityId.. '?uselang=he#P569|עריכת הנתון בוויקינתונים]]'
formattedEvent = formattedEvent .. getPencilLink(entityId, 'P856')
end
end


שורה 106: שורה 117:
-- Split the comma-separated lists into tables and sort them
-- Split the comma-separated lists into tables and sort them
local function splitString(inputstr, sep)
local function splitString(inputstr, sep)
    local sep, fields = sep or ",", {}
local sep, fields = sep or ",", {}
    local pattern = string.format("([^%s]+)", sep)
local pattern = string.format("([^%s]+)", sep)
    inputstr:gsub(pattern, function(c) fields[#fields + 1] = c end)
inputstr:gsub(pattern, function(c) fields[#fields + 1] = c end)
    return fields
return fields
end
end


function addMissingImage(infoObj, birthDate, deathDate, gender)
function addMissingImage(infoObj, birthDate, deathDate, gender)
return
if infoObj.args.image ~= nil and #infoObj.args.image > 0 then return end -- there is already image
-- Assuming you have defined deathDate and birthDate earlier
local latestDate = deathDate or birthDate
if latestDate == nil then return end
-- Split the comma-separated lists and extract dates
local dateList = splitString(latestDate:gsub(" או ", ","), ",")
if #dateList == 0 then return end
local countSuccess = 0
for i, date in ipairs(dateList) do
local success, DateRes = pcall(Date.newFromWikitext, date)
if success then
dateList[i] = DateRes
countSuccess = countSuccess + 1
end
end
 
if #dateList > 1 and countSuccess == #dateList then
latestDate = dateList[1]
for i, date in ipairs(dateList) do
if i ~= 1 then
local success, DateLeRes = pcall(Date.le, latestDate, date)
if DateLeRes then
latestDate = date
end
end
end
latestDate = os.time(latestDate)
latestDate = os.date("%d %m %Y", latestDate)
end
 
local success, res = pcall(Date.parseDateRange, latestDate, 'raw')
if success==false then return end -- there is no known VALID date
local yearsEstimated = res/(60*60*24*365)
if yearsEstimated>150 then return end
local frame = mw.getCurrentFrame()
infoObj.args.image = frame:expandTemplate{ title = 'אין תמונה', args = { gender, ['יישור'] = 'מרכז' } }
end
end


שורה 125: שורה 176:
return false -- no wikidata entity
return false -- no wikidata entity
end
end
if templateArgs[paramName]==nil or templateArgs[paramName]=='' then
if templateArgs[paramName] == nil or templateArgs[paramName] == '' then
templateArgs[paramName] = PropertyLink.getPropertyByOptions( property, infoObj.args.entityId )
templateArgs[paramName] = PropertyLink.getPropertyByOptions( property, infoObj.args.entityId )
if templateArgs[paramName] and #templateArgs[paramName]>0 then
if templateArgs[paramName] and #templateArgs[paramName] > 0 then
usingWikidata = true
usingWikidata = true
end
end
שורה 144: שורה 195:
local function instanceOfViolation(infoObj)
local function instanceOfViolation(infoObj)
local pageNs = mw.title.getCurrentTitle().namespace
local pageNs = mw.title.getCurrentTitle().namespace
if pageNs~=0 then
if pageNs ~= 0 then
return true
return true
end
end
שורה 157: שורה 208:
local matching = WikidataCrossValidation.crossValidate('אדם', 'P31', infoObj.args.entityId )
local matching = WikidataCrossValidation.crossValidate('אדם', 'P31', infoObj.args.entityId )
if matching then
if matching then
mw.logObject(matching)
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, 'P31'))
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, 'P31'))
end
end
שורה 168: שורה 218:
end
end
return false
return false
end
local function insertInOrder(templateStructure, row)
local inserted = false
for index, existingRow in ipairs(templateStructure) do
if existingRow.indic and existingRow.indic > row.indic then
table.insert(templateStructure, index, row)
inserted = true
break
end
end
if not inserted then
table.insert(templateStructure, row)
end
end
function filterMinorPrizes( propertyVals )
local tempVals = {}
    for i, property in ipairs(propertyVals) do
    local propValue = property.mainsnak and property.mainsnak.datavalue
    if propValue and propValue.value then
    local subGroup =  mw.wikibase.getBestStatements(propValue.value['id'], 'P279')
    local isMinor = false
    for _, p in pairs(subGroup) do
    local subGroupId = p.mainsnak and p.mainsnak.datavalue and p.mainsnak.datavalue.value and p.mainsnak.datavalue.value.id
if subGroupId=='Q11415564' then
isMinor = true
end
end
if not isMinor then
table.insert(tempVals, property)
end
end
end
return tempVals
end
local function useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, label, propertyIds, paramName, opts)
    opts = opts or {}
    local content = templateArgs[paramName]
    if disableWikidataFetch then
        if content == nil or content == '' then return end -- No local content, no display
    end
    if content == '-' then return end -- explicitly suppressed
    local row = { label = label }
    if content and content ~= '' then
        row.data = content
        if opts.image == true then
        row.data = dataTemplateModule.getValueOrWikidataImage({
valueArg=content,
width='180'
})
        end
    else
        local values = {}
        if #propertyIds > 0 and not disableWikidataFetch then
            for _, prop in ipairs(propertyIds) do
                local result = PropertyLink.getPropertyByOptions(prop, entityId, {
        allowMulti = opts.multi or false,
        seperator = opts.sep or ', ',
        ['entity-gender-aware'] = opts.genderAware or false,
        qualifiers = opts.qualifiers,
        ['qualifiers-sep'] = opts.qualSep,
        ['default-value'] = opts.qualDefault,
        ['sort'] = opts.sort,
        ['sort-order'] = opts.sortOrder,
        ['img-width'] = '180px',
        ['filter'] = opts.filter
        })
                if result and result ~= '' then
local cleaned_result = mw.ustring.gsub(result, '%[%[%s*[Cc]ategory:[^%[%]]-%]%]', '')
cleaned_result = mw.ustring.gsub(cleaned_result, '%[%[%s*קאטעגאריע:[^%[%]]-%]%]', '')
                if cleaned_result and cleaned_result ~= '' then
                    local valueWithPencil = result .. (opts.pencil ~= false and getPencilLink(entityId, prop) or '')
                    table.insert(values, valueWithPencil)
                end
            end
            end
        end
       
        if #values == 0 then return end
        row.data = table.concat(values, opts.join or '<br/>')
    end
    row.indic = opts.indic or 700
    insertInOrder(infoObj.templateStructure, row)
end
local function isRelogiousLeader(entityId)
local religionLeader = false
if entityId == nil then
return false
end
local religionLeaderQIds ={
--jewish
['Q133485'] = true, -- rav
['Q931732']=true, --posek
--islam
['Q217029'] =true, --kadi
['Q1999841']=true, --faqih
['Q125482']=true, --imam
--christ
['Q152002']=true, -- pastor
['Q49476']=true, -- archbishop
['Q611644']=true, --Catholic bishop
}
local wikidataPosition = mw.wikibase.getBestStatements(entityId, 'P106')
if wikidataPosition then
for _,v in pairs(wikidataPosition) do
if v.mainsnak and v.mainsnak.datavalue and v.mainsnak.datavalue.value.id and religionLeaderQIds[v.mainsnak.datavalue.value.id] then
religionLeader=true
end
end
end
return religionLeader
end
local function addAdditionalDetails(frame, infoObj, wikidataGender, disableWikidataFetch)
local parentArgs = frame:getParent().args
local directArgs = frame.args
local templateArgs = setmetatable({}, { __index = function(_, key)
return directArgs[key] ~= nil and directArgs[key] or parentArgs[key]
end })
local entityId = infoObj.args.entityId
-- Determine the correct label for "Known For" based on gender
local knownForLabel = (wikidataGender == 'נקבה' and 'ידועה בשל' or 'ידוע בשל')
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'קבורה', {'P119'}, 'קבורה', {multi=true, pencil=true, indic=5})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'תאריך עלייה', {}, 'תאריך עלייה', {indic=10})
-- Full name
local full_name_content =templateArgs['שם מלא']
local birth_name_content = templateArgs['שם לידה']
if full_name_content and full_name_content ~= '-' then
if (birth_name_content and birth_name_content ~= "-" and full_name_content ~= birth_name_content) or (not birth_name_content) then
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'שם מלא', {}, 'שם מלא', {indic=13})
end
end
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'שם לידה', {'P1477'}, 'שם לידה', {pencil=true, indic=15})
country_label = templateArgs['סוג ישות'] or 'מדינה'
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, country_label, {'P27'}, 'מדינה', {pencil=true, indic=20})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'לאום', {'P172'}, 'לאום', {pencil=true, indic=22})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'וואוין ארט', {'P551'}, 'וואוין ארט', {multi=true, sep='*', join='*', pencil=true, indic=25})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'כינוי', {'P1449'}, 'כינוי', {pencil=true, indic=30})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'פעילות בולטת', {}, 'פעילות בולטת', {indic=35})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, knownForLabel, {}, 'ידוע בשל', {indic=40})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'השכלה', {'P69'}, 'השכלה', {multi=true, qualifiers={'P582'}, sort={'P582'}, sortOrder='asc', sep='*', join='*', pencil=true, indic=45})
-- Time range
start_args = templateArgs['התחלת פעילות'] or ''
end_args = templateArgs['סיום פעילות'] or ''
if (not disableWikidataFetch) or (start_args ~= '' and end_args ~= '') then
local timeRangeArgs = {
['תאריך התחלה'] = start_args,
['תאריך סיום'] = end_args,
['הצגת הפרשת זמנים'] = 'כן',
['הווה'] = 'הווה,היום',
['טקסט הווה'] = 'הווה',
['טקסט התחלה'] = 'מ-%s',
['טקסט סיום'] = 'עד ל-%s',
['תאריך התחלה-ויקינתונים'] = 'P2031',
['תאריך סיום-ויקינתונים'] = 'P2032',
['גבול תאריך סיום-ויקינתונים'] = 'P570'
}
local timeRange = TimeRange['טווח זמנים'](frame:newChild{ args = timeRangeArgs })
if timeRange and timeRange ~= '' then
insertInOrder(infoObj.templateStructure, {
label = 'תקופת פעילות',
data = timeRange,
indic = 50
})
end
end
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'עיסוק', {}, 'עיסוק', {indic=55})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'מעסיק', {}, 'מעסיק', {indic=60})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'תארים', {'P812', 'P811', 'P512', 'P97', 'P2962'}, 'תואר', {multi=true, pencil=true, indic=65})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'מפלגה', {'P102'}, 'מפלגה', {multi=true, pencil=true, indic=70})
local religionLeader = isRelogiousLeader(entityId)
--deathCauseWikidata = deathCauseWikidata and deathCauseWikidata[1] and deathCauseWikidata[1].mainsnak
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch or religionLeader, 'השקפה דתית', {'P140'}, 'השקפה דתית', {pencil=true, indic=75})
-- Spouse + Partner
local spouseVal = templateArgs['מאן'] or templateArgs['ווייב'] or ""
if (not disableWikidataFetch) or spouseVal ~= '' then
if spouseVal ~= '-' then
local output = {}
if spouseVal and spouseVal ~= '' then
table.insert(output, spouseVal)
else
for _, prop in ipairs({'P26', 'P451'}) do
local result = PropertyLink.getPropertyByOptions(prop, entityId, {
allowMulti = true,
seperator = '*',
['entity-gender-aware'] = true,
qualifiers = {'P580', 'P582'},
['qualifiers-sep'] = ' – ',
['default-value'] = '?'
})
if result and result ~= '' then
table.insert(output, result .. getPencilLink(entityId, prop))
end
end
end
if #output > 0 then
insertInOrder(infoObj.templateStructure, {
label = ((templateArgs['מאן']) and 'מאן') or ((templateArgs['ווייב']) and 'ווייב') or 'מאן אדער ווייב',
data = table.concat(output, '\n*'),
indic = 80
})
end
end
end
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'קינדער', {'P40'}, 'קינדער', {pencil=true, multi=true, indic=85})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'צאל קינדער', {'P1971'}, 'צאל קינדער', {pencil=true, indic=90})
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'פרסים והוקרה', {'P166'}, 'פרסים והוקרה', {multi=true, sep='*', join='*', pencil=true, indic=95, qualifiers={'P585'}, sortOrder = 'desc', filter = filterMinorPrizes})
-- Signature (P109)
useArgsOrWikidata(templateArgs, infoObj, disableWikidataFetch, 'חתימה', {'P109'}, 'חתימה', {pencil=true, image=true, indic=100})
-- Official website (P856)
local siteInput = templateArgs['אתר אינטרנט'] or ""
if (not disableWikidataFetch) or siteInput ~= "" then
local childFrame = frame:newChild{ args = { ['1'] = siteInput } }
local siteVal = siteModule.site(childFrame)
if siteVal and siteVal ~= '' then
insertInOrder(infoObj.templateStructure, {
label,
data = siteVal,
indic = 300
})
end
end
end
end


function addPersonDetails(frame, infoObj)
function addPersonDetails(frame, infoObj)
local templateArgs = frame:getParent().args
local templateArgs = frame:getParent().args
local args = infoObj.args
local disableWikidataFetch = infoObj.args.title == '-'
local usingBirthWikidata = false
local usingBirthWikidata = false
local usingDeathWikidata = false
local usingDeathWikidata = false
local birthLabel = 'געבורט'
local birthLabel = 'געבורט'
local deathLabel = 'פטירה'  
local deathLabel = 'פטירה'  
 
infoObj.isNonPerson = instanceOfViolation(infoObj)
infoObj.isNonPerson = instanceOfViolation(infoObj)
local wikidataGender = nil
if not disableWikidataFetch then
if not infoObj.isNonPerson then
-- fill birth/death dates from wikidata if missing and the person is not a human biblical figure
wikidataGender = PropertyLink.getItem( 'P21', infoObj.args.entityId )
--[[
if wikidataGender == nil then
if PropertyLink.getItem('P31', infoObj.args.entityId) ~= "Q20643955" then
table.insert(infoObj.wikidataCats, '')
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
else
usingDeathWikidata = fillWikidataParam(templateArgs, 'תאריך פטירה', 'P570', infoObj)
if (wikidataGender == "Q6581097") then -- male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q2449503") then -- transgender male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q15145778") then -- cisgender male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q6581072") then -- female
wikidataGender = 'נקבה'
elseif (wikidataGender == "Q1052281") then -- transgender female
wikidataGender = 'נקבה'
elseif (wikidataGender == "Q15145779") then -- cisgender female
wikidataGender = 'נקבה'
elseif wikidataGender == 'Q1097630' -- intersex
or wikidataGender == 'Q48270' -- non binary
then wikidataGender = '' -- עד שתחליטו
end
end
end
end
]]
-- fill birth/death dates from wikidata if missing and the person is not a human biblical figure
 
if PropertyLink.getItem( 'P31', infoObj.args.entityId )~="Q20643955" then
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
usingDeathWikidata = fillWikidataParam(templateArgs, 'תאריך פטירה', 'P570', infoObj)
end
-- יחידה:אידישע דאטום ווערט פארלוירן מיט יארן בעפאר ד'ק"כ
-- יחידה:אידישע דאטום ווערט פארלוירן מיט יארן בעפאר ד'ק"כ
local genBirthDate = templateArgs['תאריך לידה'] or templateArgs['געבורט דאטום']
local genBirthDate = templateArgs['תאריך לידה'] or templateArgs['געבורט דאטום']
if genBirthDate == nil and templateArgs['תאריך לידה עברי'] ~= nil then
if genBirthDate == nil and templateArgs['תאריך לידה עברי'] ~= nil then
local l = frame:preprocess(args['תאריך לידה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
local l = frame:preprocess(templateArgs['תאריך לידה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
if (#mw.text.split(l, '%s' ) == 1 or count(l, "%[%[") == 1) then --most probably just year or yearlink
if #mw.text.split(l, '%s' ) == 1 or enclosed(l) then --most probably just year or yearlink
if #mw.text.split(l, '%s' ) > 1 then
if #mw.text.split(l, '%s' ) > 1 then
l = l:match("%[%[.-|(.*)%]%]")
l = l:match("%[%[.-|(.*)%]%]") or l:match("%[%[(.-)%]%]") -- try after pipe first, fallback and get the whole if there is no pipe
end
end
local birthParts = mw.text.split( l, "'", true )
local birthParts = mw.text.split( l, "'", true )
if #birthParts == 1 then
if #birthParts == 1 then
table.insert(birthParts, 1, 0) -- אדער אלף החמישי?
table.insert(birthParts, 1, '') -- אדער אלף החמישי?
end
end
local BirthDateNum = gim.gimatria(birthParts[1])*1000 + gim.gimatria(birthParts[2]) - 3760
local BirthDateNum = gim.gimatria(birthParts[1])*1000 + gim.gimatria(birthParts[2]) - 3760
שורה 231: שורה 508:
local genDeathDate = templateArgs['תאריך פטירה'] or templateArgs['פטירה דאטום']
local genDeathDate = templateArgs['תאריך פטירה'] or templateArgs['פטירה דאטום']
if genDeathDate == nil and templateArgs['תאריך פטירה עברי'] ~= nil then
if genDeathDate == nil and templateArgs['תאריך פטירה עברי'] ~= nil then
local p = frame:preprocess(args['תאריך פטירה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
local p = frame:preprocess(templateArgs['תאריך פטירה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
if (#mw.text.split(p, '%s' ) == 1 or count(p, "%[%[") == 1) then --most probably just year or yearlink
if #mw.text.split(p, '%s' ) == 1 or enclosed(p) then --most probably just year or yearlink
if #mw.text.split(p, '%s' ) > 1 then
if #mw.text.split(p, '%s' ) > 1 then
p = p:match("%[%[.-|(.*)%]%]")
p = p:match("%[%[.-|(.*)%]%]") or p:match("%[%[(.-)%]%]") -- try after pipe first, fallback and get the whole if there is no pipe
end
end
local deathParts = mw.text.split( p, "'", true )
local deathParts = mw.text.split( p, "'", true )
if #deathParts == 1 then
if #deathParts == 1 then
table.insert(deathParts, 1, 0) -- אדער אלף החמישי?
table.insert(deathParts, 1, '') -- אדער אלף החמישי?
end
end
local DeathDateNum = gim.gimatria(deathParts[1])*1000 + gim.gimatria(deathParts[2]) - 3760
local DeathDateNum = gim.gimatria(deathParts[1])*1000 + gim.gimatria(deathParts[2]) - 3760
שורה 251: שורה 528:
local birthDate = getSpeculativeDate(genBirthDate, templateArgs['תאריך לידה עברי'])
local birthDate = getSpeculativeDate(genBirthDate, templateArgs['תאריך לידה עברי'])
local deathDate = getSpeculativeDate(genDeathDate, templateArgs['תאריך פטירה עברי'])
local deathDate = getSpeculativeDate(genDeathDate, templateArgs['תאריך פטירה עברי'])
if birthDate ~= nil then
local age = nil
if deathDate == nil and not templateArgs['ללא גיל'] then
age = ageModule.ageCalc(birthDate, nil, true, false, true, nil, wikidataGender) or ''
end
local birthDetails, usingBirthWikidataEvent = getEventDetails(templateArgs['תאריך לידה'] or templateArgs['געבורט דאטום'], templateArgs['תאריך לידה עברי'], templateArgs['מקום לידה'] or templateArgs['געבורט ארט'], 'P569', 'P19', age, usingBirthWikidata, infoObj)
table.insert(infoObj.templateStructure, 1, {
label = birthLabel,
data = birthDetails
})
usingBirthWikidata = usingBirthWikidata or usingBirthWikidataEvent
elseif templateArgs['געבורט ארט'] ~= '-' then
fillWikidataParam(templateArgs, 'געבורט ארט', 'P19', infoObj)
if templateArgs['געבורט ארט'] ~= nil and templateArgs['געבורט ארט'] ~= '' then -- only if we fill the parameter eventually - add to template
table.insert(infoObj.templateStructure, 1, {
label = birthLabel,
data = templateArgs['געבורט ארט']
})
end
end
deathLabel = getDeathLabel(templateArgs['סיבת המוות'], infoObj.args.entityId, wikidataGender)
if deathDate ~= nil then
if birthDate~=nil then
local age = ''
local age = nil
if not templateArgs['ללא גיל'] then
if deathDate==nil then
age = ageModule.ageCalc(birthDate, deathDate, false, false, true) or ''
age = ageModule.ageCalc(birthDate, nil, true, false, true, nil, wikidataGender) or ''
end
local deathDetails, usingDeathWikidataEvent = getEventDetails(templateArgs['תאריך פטירה'] or templateArgs['פטירה דאטום'], templateArgs['תאריך פטירה עברי'], templateArgs['מקום פטירה'] or templateArgs['פטירה ארט'], 'P570', 'P20', age, usingDeathWikidata, infoObj)
table.insert(infoObj.templateStructure, 2, {
label=deathLabel,
data=deathDetails
})
usingDeathWikidata = usingDeathWikidata or usingDeathWikidataEvent
elseif templateArgs['פטירה ארט'] ~= '-' then
fillWikidataParam(templateArgs, 'פטירה ארט', 'P20', infoObj)
if templateArgs['פטירה ארט'] ~= nil and templateArgs['פטירה ארט'] ~= '' then -- only if we fill the parameter eventually - add to template
table.insert(infoObj.templateStructure, 2, {
label=deathLabel,
data= templateArgs['פטירה ארט']
})
end
end
end
local birthDetails, usingBirthWikidataEvent = getEventDetails(templateArgs['תאריך לידה'], templateArgs['תאריך לידה עברי'], templateArgs['געבורט ארט'], 'P569', 'P19', age, usingBirthWikidata, infoObj)
table.insert(infoObj.templateStructure, 1, {
if infoObj.isSelfUse then
label=birthLabel,
data=birthDetails
})
usingBirthWikidata = usingBirthWikidata or usingBirthWikidataEvent
elseif templateArgs['געבורט ארט']~= '-' then
fillWikidataParam(templateArgs, 'געבורט ארט', 'P19', infoObj)
if  templateArgs['געבורט ארט']~= nil and templateArgs['געבורט ארט']~= '' then -- only if we fill the parameter eventually - add to template
table.insert(infoObj.templateStructure, 1, {
table.insert(infoObj.templateStructure, 1, {
label=birthLabel,
label=birthLabel,
data= templateArgs['געבורט ארט']
data='{{{תאריך לידה}}}<br/>{{{געבורט ארט}}}'
})
})
end
end
deathLabel = getDeathLabel(templateArgs['סיבת המוות'], infoObj.args.entityId, wikidataGender)
if deathDate~=nil then
local age =  ageModule.ageCalc(birthDate, deathDate, false, false, true) or ''
local deathDetails, usingDeathWikidataEvent = getEventDetails(templateArgs['תאריך פטירה'], templateArgs['תאריך פטירה עברי'], templateArgs['פטירה ארט'], 'P570', 'P20', age, usingDeathWikidata, infoObj)
table.insert(infoObj.templateStructure, 2, {
label=deathLabel,
data=deathDetails
})
usingDeathWikidata = usingDeathWikidata or usingDeathWikidataEvent
elseif templateArgs['פטירה ארט']~= '-' then
fillWikidataParam(templateArgs, 'פטירה ארט', 'P20', infoObj)
if templateArgs['פטירה ארט']~= nil and templateArgs['פטירה ארט']~= '' then -- only if we fill the parameter eventually - add to template
table.insert(infoObj.templateStructure, 2, {
table.insert(infoObj.templateStructure, 2, {
label=deathLabel,
label=deathLabel,
data= templateArgs['פטירה ארט']
data='{{{תאריך פטירה}}}<br/>{{{פטירה ארט}}}'
})
})
end
if usingBirthWikidata or usingDeathWikidata then
infoObj.args.usingWikidata = true
end
end
end
if frame.args['כותרת0'] then
if infoObj.isSelfUse then
table.insert(infoObj.templateStructure, 1, {
table.insert(infoObj.templateStructure, 1, {
label=birthLabel,
header=1,
data='{{{תאריך לידה}}}<br/>{{{געבורט ארט}}}'
data=frame.args['כותרת0'],
rowstyle=frame.args['עיצוב-שורה0'],
rowclass=frame.args['מחלקה-שורה0'],
headerstyle=frame.args['כותרת0-עיצוב']
})
})
table.insert(infoObj.templateStructure, 2, {
end
label=deathLabel,
data='{{{תאריך פטירה}}} <br/>{{{פטירה ארט}}}'
})
end
if usingBirthWikidata or usingDeathWikidata then
--[[
infoObj.args.usingWikidata = true
if frame.args['תמונה'] ~= '-' then
addMissingImage(infoObj, birthDate, deathDate, wikidataGender)
end
]]
end
end
if frame.args['כותרת0'] then
addAdditionalDetails(frame, infoObj, wikidataGender, disableWikidataFetch)
table.insert(infoObj.templateStructure, 1, {
header=1,
data=frame.args['כותרת0'],
rowstyle=frame.args['עיצוב-שורה0'],
rowclass=frame.args['מחלקה-שורה0'],
headerstyle=frame.args['כותרת0-עיצוב']
})
end
 
if frame.args['תמונה']~='-' then
addMissingImage(infoObj, birthDate, deathDate, wikidataGender)
end
end
end


function infobox(frame)
function infobox(frame)
local infoObj = Infobox:new()
local infoObj = Infobox:new()
frame.args['תמונה-גודל'] = frame.args['תמונה-גודל'] or '220'
frame.args['תמונה-גודל'] = frame.args['תמונה-גודל'] or '220'
 
local colorKey = frame.args["סיווג"] or frame.args["סוג"] or frame:getParent().args["סיווג"] or frame:getParent().args["סוג"]
local color = BackgroundColors[colorKey] or BackgroundColors["default"] or "#eeeeee"
 
infoObj.args.headerstyle = "background:" .. color .. ";" .. (infoObj.args.headerstyle or "")
local is_white_text = BackgroundColors[colorKey] == '#000000' or BackgroundColors[colorKey] == '#800000'
local header_style = "background:" .. color .. "; border:1px solid #aaaaaa; border-bottom:0px; color:" .. (is_white_text and 'white' or 'black')
frame.args['כותרת-עיצוב'] = header_style .. ";" .. (frame.args['כותרת-עיצוב'] or "")
frame.args['כותרת תבנית-עיצוב'] = header_style .. ";" .. (frame.args['כותרת תבנית-עיצוב'] or "")
frame.args['תת-כותרת תבנית-עיצוב'] = header_style .. ";" .. (frame.args['תת-כותרת תבנית-עיצוב'] or "")
infoObj:parseArgs(frame)
infoObj:parseArgs(frame)
 
if infoObj.args.title~='-' then
addPersonDetails(frame, infoObj)
addPersonDetails(frame, infoObj)
 
end
return infoObj:render()
return infoObj:render()
end
end