יחידה:תבנית מידע/אישיות: הבדלים בין גרסאות בדף
מראה
מאין תקציר עריכה |
מאין תקציר עריכה |
||
| שורה 9: | שורה 9: | ||
if isBirth then | if isBirth then | ||
eventDate = birthDate | eventDate = birthDate | ||
if deathDate==nil or deathDate=='' then | if (deathDate==nil or deathDate=='') and entityId then | ||
eventDate = eventDate .. ageModule.ageCalc(birthDate, deathDate, true, false, true) | eventDate = eventDate .. ageModule.ageCalc(birthDate, deathDate, true, false, true) | ||
end | end | ||
| שורה 17: | שורה 17: | ||
local formattedEvent = eventDate | local formattedEvent = eventDate | ||
if eventPlace==nil or eventPlace=='' then | if (eventPlace==nil or eventPlace=='') and entityId then | ||
eventPlace = LocationAndCountry.displayFromParams( propPlace, entityId, propDate , 1) | eventPlace = LocationAndCountry.displayFromParams( propPlace, entityId, propDate , 1) | ||
usingWikidata = true | usingWikidata = true | ||
| שורה 29: | שורה 29: | ||
formattedEvent = formattedEvent .. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..entityId.. '?uselang=he#P569|עריכת הנתון בוויקינתונים]]' | formattedEvent = formattedEvent .. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..entityId.. '?uselang=he#P569|עריכת הנתון בוויקינתונים]]' | ||
end | end | ||
return formattedEvent | return formattedEvent | ||
end | end | ||
גרסה מ־21:21, 24 באוקטובר 2017
יחידה זו מרחיבה את יחידה:תבנית מידע עבור תבניות מידע של אישים. היחידה כוללת תמיכה אוטומטית בפרמטרים האופיינים לאישים כדוגמת תאריכים ומקומות של לידה/פטירה, יחד עם ציון גיל.
local Infobox = require('Module:תבנית מידע').Infobox
local LocationAndCountry = require('Module:LocationAndCountry')
local PropertyLink = require('Module:PropertyLink')
local ageModule = require('Module:גיל לערכי אישים')
function getEventDetails(birthDate, deathDate, eventPlace, propDate, propPlace, isBirth, usingWikidata)
local entityId = mw.wikibase.getEntityIdForCurrentPage()
local eventDate
if isBirth then
eventDate = birthDate
if (deathDate==nil or deathDate=='') and entityId then
eventDate = eventDate .. ageModule.ageCalc(birthDate, deathDate, true, false, true)
end
else
eventDate = deathDate .. ageModule.ageCalc(birthDate, deathDate, false, false, true)
end
local formattedEvent = eventDate
if (eventPlace==nil or eventPlace=='') and entityId then
eventPlace = LocationAndCountry.displayFromParams( propPlace, entityId, propDate , 1)
usingWikidata = true
end
if eventPlace~='' and eventPlace~=nil then
formattedEvent = formattedEvent..'<br/>' ..eventPlace
end
if usingWikidata and entityId then
formattedEvent = formattedEvent .. ' [[File:Blue pencil RTL.svg|15px|link=https://www.wikidata.org/wiki/'..entityId.. '?uselang=he#P569|עריכת הנתון בוויקינתונים]]'
end
return formattedEvent
end
function infobox(frame)
local templateArgs = frame:getParent().args
local infoObj = Infobox:new()
infoObj:parseArgs(frame)
local usingBirthWikidata = false
local usingDeathWikidata = false
if templateArgs['תאריך לידה']==nil or templateArgs['תאריך לידה']=='' then
templateArgs['תאריך לידה'] = PropertyLink.getProperty( 'P569' )
if templateArgs['תאריך לידה'] then
usingBirthWikidata = true
end
end
if templateArgs['תאריך פטירה']==nil or templateArgs['תאריך פטירה']=='' then
templateArgs['תאריך פטירה'] = PropertyLink.getProperty( 'P570' )
if templateArgs['תאריך פטירה'] then
usingDeathWikidata = true
end
end
if templateArgs['תאריך לידה']~=nil and templateArgs['תאריך לידה']~='' then
local birthDetails = getEventDetails(templateArgs['תאריך לידה'], templateArgs['תאריך פטירה'], templateArgs['מקום לידה'], 'P569', 'P19', true, usingBirthWikidata)
table.insert(infoObj.templateStructure, 1, {
label='לידה',
data=birthDetails
})
end
if templateArgs['תאריך פטירה']~=nil and templateArgs['תאריך פטירה']~='' then
local deathDetails = getEventDetails(templateArgs['תאריך לידה'], templateArgs['תאריך פטירה'], templateArgs['מקום פטירה'], 'P570', 'P20', false, usingDeathWikidata)
table.insert(infoObj.templateStructure, 2, {
label='פטירה',
data=deathDetails
})
end
if infoObj.isSelfUse then
table.insert(infoObj.templateStructure, 1, {
label='לידה',
data='{{{תאריך לידה}}}<br/>{{{מקום לידה}}}'
})
table.insert(infoObj.templateStructure, 2, {
label='פטירה',
data='{{{תאריך פטירה}}} <br/>{{{מקום פטירה}}}'
})
end
--[[
TODO:
table.insert(infoObj.templateStructure, 2, deathDetails(frame))
infoObj.args.usingWikidata
infoObj.wikidataCats
]]
return infoObj:render()
end
return {
['מידע']=infobox
}