יחידה:תבנית מידע/אישיות

גרסה מ־22:12, 21 באוקטובר 2017 מאת wikipedia:he>ערן (יצירת דף עם התוכן "local Infobox = require('Module:תבנית מידע').Infobox local LocationAndCountry = require('Module:LocationAndCountry') local PropertyLink = require('Modul...")
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)

יחידה זו מרחיבה את יחידה:תבנית מידע עבור תבניות מידע של אישים. היחידה כוללת תמיכה אוטומטית בפרמטרים האופיינים לאישים כדוגמת תאריכים ומקומות של לידה/פטירה, יחד עם ציון גיל.


local Infobox = require('Module:תבנית מידע').Infobox
local LocationAndCountry = require('Module:LocationAndCountry')
local PropertyLink = require('Module:LocationAndCountry')
local ageModule = require('Module:גיל לערכי אישים')

function getBirthDetails(birthDate, deathDate, birthPlace)
	local entityId = mw.wikibase.getEntityIdForCurrentPage()
	
	if birthDate==nil or birthDate=='' then
		birthDate = ageModule.ageCalc(birthDate, deathDate, true)
		-- early termination
		if birthDate == nil then
			return nil
		end
	end
	local formattedBirth = birthDate
	if birthPlace==nil or birthPlace=='' then
		birthPlace = LocationAndCountry.displayFromParams('P19', entityId, 'P569', 1)
	end
	
	if birthPlace~='' and birthPlace~=nil then
		formattedBirth = formattedBirth..'<br/>' ..birthPlace
	end

	return {
		label='לידה',
		data=formattedBirth
	}
end

function infobox(frame)
	local templateArgs = frame:getParent().args
	
	local infoObj = Infobox:new()
	infoObj:parseArgs(frame)

	local birthDetails = getBirthDetails(templateArgs['תאריך לידה'], templateArgs['תאריך פטירה'], templateArgs['מקום לידה'])
	table.insert(infoObj.templateStructure, 1, birthDetails)
	--[[	
	TODO:
	table.insert(infoObj.templateStructure, 2, deathDetails(frame))
	infoObj.args.usingWikidata
	infoObj.wikidataCats
	]]
	return infoObj:render()
end


return 	{
	['מידע']=infobox
}