Modulis:Monument

Vikipēdijas lapa
Dokumentācijas ikona Moduļa dokumentācija[izveidot]
-- local image_module = require('Module:InfoboxImage')

local i18n = {
	html = {
		topline = '{| border=0 style="font-size:97%%;width:100%%;"\n|- valign="top" %s\n| ',
		nameline = '[[Attēls:%s|%s]] %s<span style="font-size:115%%">' .. "'''%s'''</span><br>",
		precise = '<span style="color:#FF0000;">!</span>',
		photo = 'width="160px" style="background-color:#F8F8F8" | %s\n|',
		photo2 = '<br />[[:commons:Category:%s|Galerija]]',
		munlogo = '[[File:Wikidata-logo.svg|16px|link=http://wikidata.org/wiki/%s]]',
		karte = '[[Attēls:Map mag.png|18px|link=%s|Karte]]',
		wikipedia = '[[Attēls:Wikipedia-logo-v2.svg|20px|link=http://lv.wikipedia.org/wiki/%s|Vikipēdijas raksts]]',
		wdid = '[[Attēls:Wikidata-logo.svg|20px|link=http://wikidata.org/wiki/%s|Wikidata]]',
		commonscat = '[[Attēls:Commons-logo.svg|18px|link=http://commons.wikimedia.org/wiki/Category:%s|Wikimedia Commons kategorija]]',
		extlink = '[[Attēls:P geography 3 b.png|24px|link=%s|Arējās saites]]',
		extlink2 = '[[Attēls:P geography 3 b.png|24px|link=%s|Arējās saites]]',
		upwizlink = '//commons.wikimedia.org/w/index.php?title=Special:UploadWizard&id=%s&description=%s&lat=%s&lon=%s&categories=%s&descriptionlang=lv&campaign=wlm-lv'

	},
	valuenames = {
		['national'] = 'Valsts nozīmes',
		['local'] = 'Vietējas nozīmes',
	},
	typelabelimages = {
		['valsts nozīmes arheoloģijas piemineklis'] = 'ArcheologyIcon .svg',
		['vietējas nozīmes arheoloģijas piemineklis'] = 'ArcheologyIcon .svg',
		['valsts nozīmes arhitektūras piemineklis'] = 'PorticoIcon.svg',
		['vietējas nozīmes arhitektūras piemineklis'] = 'PorticoIcon.svg',
		['valsts nozīmes industriālais piemineklis'] = 'Factory icon blue.svg',
		['vietējas nozīmes industriālais piemineklis'] = 'Factory icon blue.svg',
		['valsts nozīmes mākslas piemineklis'] = 'Colorize.png',
		['vietējas nozīmes mākslas piemineklis'] = 'Colorize.png',
		['valsts nozīmes pilsētbūvniecības piemineklis'] = 'Brown community icon.svg',
		['vietējas nozīmes pilsētbūvniecības piemineklis'] = 'Brown community icon.svg',
		['valsts nozīmes vēstures piemineklis'] = 'Battle icon gladii green.svg',
		['vietējas nozīmes vēstures piemineklis'] = 'Battle icon gladii green.svg',
		['valsts nozīmes vēsturiska notikuma vieta'] = 'Battle icon gladii green.svg',
		['vietējas nozīmes vēsturiska notikuma vieta'] = 'Battle icon gladii green.svg',
	},
	typeimages = {
		['archeology'] = 'ArcheologyIcon .svg',
		['architecture'] = 'PorticoIcon.svg',
		['industrial'] = 'Factory icon blue.svg',
		['art'] = 'Colorize.png',
		['urban'] = 'Brown community icon.svg',
		['history'] = 'Battle icon gladii green.svg',
		['event'] = 'Battle icon gladii green.svg',
	},
	typenames = {
		['archeology'] = 'Arheoloģija',
		['architecture'] = 'Arhitektūra',
		['industrial'] = 'Industriālais',
		['art'] = 'Māksla',
		['urban'] = 'Pilsētbūvniecība',
		['history'] = 'Vēsture',
		['event'] = 'Vēsturiska notikuma vieta',
	},
	sizelabelimages = {
		['valsts nozīmes arheoloģijas piemineklis'] = '20px',
		['vietējas nozīmes arheoloģijas piemineklis'] = '20px',
		['valsts nozīmes arhitektūras piemineklis'] = '18px',
		['vietējas nozīmes arhitektūras piemineklis'] = '18px',
		['valsts nozīmes industriālais piemineklis'] = '18px',
		['vietējas nozīmes industriālais piemineklis'] = '18px',
		['valsts nozīmes mākslas piemineklis'] = '18px',
		['vietējas nozīmes mākslas piemineklis'] = '18px',
		['valsts nozīmes pilsētbūvniecības piemineklis'] = '18px',
		['vietējas nozīmes pilsētbūvniecības piemineklis'] = '18px',
		['valsts nozīmes vēstures piemineklis'] = '15px',
		['vietējas nozīmes vēstures piemineklis'] = '15px',
		['valsts nozīmes vēsturiska notikuma vieta'] = '18px',
		['vietējas nozīmes vēsturiska notikuma vieta'] = '18px',
	},
	sizeimages = {
		['archeology'] = '20px',
		['architecture'] = '18px',
		['industrial'] = '18px',
		['art'] = '18px',
		['urban'] = '18px',
		['history'] = '15px',
		['event'] = '18px',
	},
	regions = {
		['LV-001'] = 'Aglona Municipality',
		['LV-002'] = 'Aizkraukle Municipality',
		['LV-003'] = 'Aizpute Municipality',
		['LV-004'] = 'Aknīste Municipality',
		['LV-005'] = 'Aloja Municipality',
		['LV-006'] = 'Alsunga Municipality',
		['LV-007'] = 'Alūksne Municipality',
		['LV-008'] = 'Amata Municipality',
		['LV-009'] = 'Ape Municipality',
		['LV-010'] = 'Auce Municipality',
		['LV-011'] = 'Ādaži Municipality',
		['LV-012'] = 'Babīte Municipality',
		['LV-013'] = 'Baldone Municipality',
		['LV-014'] = 'Baltinava Municipality',
		['LV-015'] = 'Balvi Municipality',
		['LV-016'] = 'Bauska Municipality',
		['LV-017'] = 'Beverīna Municipality',
		['LV-018'] = 'Brocēni Municipality',
		['LV-019'] = 'Burtnieki Municipality',
		['LV-020'] = 'Carnikava Municipality',
		['LV-021'] = 'Cesvaine Municipality',
		['LV-022'] = 'Cēsis Municipality',
		['LV-023'] = 'Cibla Municipality',
		['LV-024'] = 'Dagda Municipality',
		['LV-025'] = 'Daugavpils Municipality',
		['LV-026'] = 'Dobele Municipality',
		['LV-027'] = 'Dundaga Municipality',
		['LV-028'] = 'Durbe Municipality',
		['LV-029'] = 'Engure Municipality',
		['LV-030'] = 'Ērgļi Municipality',
		['LV-031'] = 'Garkalne Municipality',
		['LV-032'] = 'Grobiņa Municipality',
		['LV-033'] = 'Gulbene Municipality',
		['LV-034'] = 'Iecava Municipality',
		['LV-035'] = 'Ikšķile Municipality',
		['LV-036'] = 'Ilūkste Municipality',
		['LV-037'] = 'Inčukalns Municipality',
		['LV-038'] = 'Jaunjelgava Municipality',
		['LV-039'] = 'Jaunpiebalga Municipality',
		['LV-040'] = 'Jaunpils Municipality',
		['LV-041'] = 'Jelgava Municipality',
		['LV-042'] = 'Jēkabpils Municipality',
		['LV-043'] = 'Kandava Municipality',
		['LV-044'] = 'Kārsava Municipality',
		['LV-045'] = 'Kocēni Municipality',
		['LV-046'] = 'Koknese Municipality',
		['LV-047'] = 'Krāslava Municipality',
		['LV-048'] = 'Krimulda Municipality',
		['LV-049'] = 'Krustpils Municipality',
		['LV-050'] = 'Kuldīga Municipality',
		['LV-051'] = 'Ķegums Municipality',
		['LV-052'] = 'Ķekava Municipality',
		['LV-053'] = 'Lielvārde Municipality',
		['LV-054'] = 'Limbaži Municipality',
		['LV-055'] = 'Līgatne Municipality',
		['LV-056'] = 'Līvāni Municipality',
		['LV-057'] = 'Lubāna Municipality',
		['LV-058'] = 'Ludza Municipality',
		['LV-059'] = 'Madona Municipality',
		['LV-060'] = 'Mazsalaca Municipality',
		['LV-061'] = 'Mālpils Municipality',
		['LV-062'] = 'Mārupe Municipality',
		['LV-063'] = 'Mērsrags Municipality',
		['LV-064'] = 'Naukšēni Municipality',
		['LV-065'] = 'Nereta Municipality',
		['LV-066'] = 'Nīca Municipality',
		['LV-067'] = 'Ogre Municipality',
		['LV-068'] = 'Olaine Municipality',
		['LV-069'] = 'Ozolnieki Municipality',
		['LV-070'] = 'Pārgauja Municipality',
		['LV-071'] = 'Pāvilosta Municipality',
		['LV-072'] = 'Pļaviņas Municipality',
		['LV-073'] = 'Preiļi Municipality',
		['LV-074'] = 'Priekule Municipality',
		['LV-075'] = 'Priekuļi Municipality',
		['LV-076'] = 'Rauna Municipality',
		['LV-077'] = 'Rēzekne Municipality',
		['LV-078'] = 'Riebiņi Municipality',
		['LV-079'] = 'Roja Municipality',
		['LV-080'] = 'Ropaži Municipality',
		['LV-081'] = 'Rucava Municipality',
		['LV-082'] = 'Rugāji Municipality',
		['LV-083'] = 'Rundāle Municipality',
		['LV-084'] = 'Rūjiena Municipality',
		['LV-085'] = 'Sala Municipality',
		['LV-086'] = 'Salacgrīva Municipality',
		['LV-087'] = 'Salaspils Municipality',
		['LV-088'] = 'Saldus Municipality',
		['LV-089'] = 'Saulkrasti Municipality',
		['LV-090'] = 'Sēja Municipality',
		['LV-091'] = 'Sigulda Municipality',
		['LV-092'] = 'Skrīveri Municipality',
		['LV-093'] = 'Skrunda Municipality',
		['LV-094'] = 'Smiltene Municipality',
		['LV-095'] = 'Stopiņi Municipality',
		['LV-096'] = 'Strenči Municipality',
		['LV-097'] = 'Talsi Municipality',
		['LV-098'] = 'Tērvete Municipality',
		['LV-099'] = 'Tukums Municipality',
		['LV-100'] = 'Vaiņode Municipality',
		['LV-101'] = 'Valka Municipality',
		['LV-102'] = 'Varakļāni Municipality',
		['LV-103'] = 'Vārkava Municipality',
		['LV-104'] = 'Vecpiebalga Municipality',
		['LV-105'] = 'Vecumnieki Municipality',
		['LV-106'] = 'Ventspils Municipality',
		['LV-107'] = 'Viesīte Municipality',
		['LV-108'] = 'Viļaka Municipality',
		['LV-109'] = 'Viļāni Municipality',
		['LV-110'] = 'Zilupe Municipality',
		['LV-111'] = 'Augšdaugava Municipality',
		['LV-112'] = 'Dienvidkurzeme Municipality',
		['LV-113'] = 'Valmiera Municipality',
		['LV-DGV'] = 'Daugavpils',
		['LV-JEL'] = 'Jelgava',
		['LV-JKB'] = 'Jēkabpils',
		['LV-JUR'] = 'Jūrmala',
		['LV-LPX'] = 'Liepāja',
		['LV-REZ'] = 'Rēzekne',
		['LV-RIX'] = 'Riga',
		['LV-VMR'] = 'Valmiera',
		['LV-VEN'] = 'Ventspils',
	},
	rixsubregionswp = {
		'Valsts aizsargājamie kultūras pieminekļi Vecrīgā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Centra rajonā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Kurzemes rajonā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Zemgales priekšpilsētā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Ziemeļu rajonā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Vidzemes priekšpilsētā',
		'Valsts aizsargājamie kultūras pieminekļi Rīgas Latgales priekšpilsētā',
	},
	rixsubregionscommons = {
		'Cultural heritage monuments in Vecrīga, Riga',
		'Cultural heritage monuments in Central District, Riga',
		'Cultural heritage monuments in Kurzeme District, Riga',
		'Cultural heritage monuments in Zemgale Suburb, Riga',
		'Cultural heritage monuments in Northern District, Riga',
		'Cultural heritage monuments in Vidzeme Suburb, Riga',
		'Cultural heritage monuments in Latgale Suburb, Riga',
	}
}

local p = {}

function p.row(frame)
	local result, seq, mstatus, mimage, mimagetitle, mcomplex, mimagetype, mimagesize, maincomplex
	local mwikipedia, mwdid, mcommonscat, mextlink, mextlink2
	local mphoto, mphoto2, nametype, namevalue, myear
	local mdistrict, mmunicipality, mmunid, mblock, maddress, mlocality
	local mvaid, mcoord, mprecise
	local upwizlink, upwizlinkname, upwizlinkname2, upwizlinkcommons, commonscatwiz
	local monmaplink, thispagetitle, regioname, subregion, rixsubregion, subRegCount

	local type = frame.args['type'] or ''
	local typelabel = frame.args['typelabel'] or ''
	local value = frame.args['value'] or ''
	local lat = frame.args['lat'] or ''
	local long = frame.args['long'] or ''
	local precise = frame.args['precise'] or ''
	local vaid = frame.args['vaid'] or ''
	local complex = frame.args['complex'] or ''
	local wdid = frame.args['wdid'] or ''
	local qid = frame.args['qid'] or ''
	local decreenum = frame.args['decreenum'] or ''
	local decreedate = frame.args['decreedate'] or ''
	local decreepublicated = frame.args['decreepublicated'] or ''
	local region = frame.args['region'] or ''
	local district = frame.args['district'] or ''
	local munid = frame.args['munid'] or ''
	local municipality = frame.args['municipality'] or ''
	local munwiki = frame.args['munwiki'] or ''
	local address = frame.args['address'] or ''
	local name = frame.args['name'] or ''
	local year = frame.args['year'] or ''
	local author = frame.args['author'] or ''
	local locality = frame.args['locality'] or ''
	local description = frame.args['description'] or ''
	local image = frame.args['image'] or ''
	local wikipedia = frame.args['wikipedia'] or ''
	local wikipediauri = frame.args['wikipediauri'] or ''
	local commonscat = frame.args['commonscat'] or ''
	local extlink = frame.args['extlink'] or ''
	local extlink2 = frame.args['extlink2'] or ''
	local status = frame.args['status'] or ''
	local block = frame.args['block'] or ''

--	if name == '' then return '[[Kategorija:Modulis Monuments slikts parametrs]]' end

	thispagetitle = mw.title.getCurrentTitle()
	seq = {}
	cnt = 1

	if status == 'destroyed' then mstatus = 'style="color:#808080;"|' else mstatus = '' end
	seq[cnt] = mw.ustring.format(i18n.html.topline, mstatus)
	cnt = cnt + 1

	upwizlinkname2 = name
	if municipality ~= '' then upwizlinkname2 = upwizlinkname2 .. ', ' .. municipality end
	if address ~= '' then upwizlinkname2 = upwizlinkname2 .. ', ' .. address end
	upwizlinkname = mw.uri.encode(upwizlinkname2, "PATH")
	if region == 'LV-RIX' then
		regionname = 'Cultural heritage monuments in Riga'
		for subRegCount = 1, 7 do
			if i18n.rixsubregionswp[subRegCount] == thispagetitle.prefixedText then
				regionname = i18n.rixsubregionscommons[subRegCount]
				break
			end
		end
	else
		regionname = 'Cultural heritage monuments in ' .. i18n.regions[region]
	end
	if commonscat == '' then commonscatwiz = regionname else commonscatwiz = commonscat end
	upwizlinkcommons = mw.uri.encode(commonscatwiz, "PATH")
	upwizlink = mw.ustring.format(i18n.html.upwizlink, vaid, upwizlinkname, lat, long, upwizlinkcommons)
	if image == '' then 
		mphoto = '[[Attēls:Ieladet attelus.png|150px|link=' .. upwizlink .. ']]'
	else
		mphoto = '[[Attēls:' .. image ..	'|150px]]<br>[' .. upwizlink .. ' Ielādēt vēl attēlus]'
	end
	if commonscat ~= '' then 
		mphoto2 = mw.ustring.format(i18n.html.photo2, commonscat)
	else
		mphoto2 = ''
	end
	seq[cnt] = mw.ustring.format(i18n.html.photo, mphoto .. mphoto2)
	cnt = cnt + 1

	if complex ~= '' then mcomplex = ' style="background-color:#EFFBEF;"| ' else mcomplex = ' style="background-color:#F8F8F8"| ' end
	seq[cnt] = mcomplex
	cnt = cnt + 1

	if typelabel ~= '' then mimagetype = i18n.typelabelimages[typelabel] else mimagetype = i18n.typeimages[type] end
	if typelabel ~= '' then mimagesize = i18n.sizelabelimages[typelabel] else mimagesize = i18n.sizeimages[type] end
	if complex == vaid then maincomplex = '[[Attēls:Location dot darkslategray.svg|10px]]&nbsp;' else maincomplex = '' end
	if wikipediauri ~= '' then wikipedia = mw.uri.decode(wikipediauri,"WIKI") end
	if wikipedia ~= '' then mwikipedia = '[[' .. wikipedia .. '|' .. name .. ']]' else mwikipedia = name end
	seq[cnt] = mw.ustring.format(i18n.html.nameline, mimagetype, mimagesize, maincomplex, mwikipedia)
	cnt = cnt + 1

	mdistrict = ''
	if district ~= '' then
		if municipality ~= district then mdistrict = district .. ',&nbsp;' end
	else
	end
	if munwiki ~= '' then 
		mmunicipality = '[[' .. munwiki .. '|' .. municipality .. ']]'
	else 
		if municipality ~= '' then mmunicipality = '[[' .. municipality .. ']]' else mmunicipality = '' end
	end
	if munid ~= '' then mmunid = mw.ustring.format(i18n.html.munlogo, mw.uri.encode(munid,"PATH")) else mmunid = '' end
	if block ~= '' then mblock = ', kvartāls' .. block else mblock = '' end
	if address ~= '' then maddress = ', ' .. address else maddress = '' end
	if locality ~= '' then mlocality = '(' .. locality .. ')' else mlocality = '' end
	seq[cnt] = "''Adrese:'' " .. mdistrict .. mmunicipality .. mmunid .. mblock .. maddress .. ' ' .. mlocality .. '<br />'
	cnt = cnt + 1

	if vaid ~= '' then 
		mvaid = '[https://mantojums.lv/' .. vaid .. ' ' .. vaid .. ']'
	else
		mvaid = ''
	end
	mprecise = ''
	mcoord = ''
	if lat ~= '' and long ~= '' then 
		monmaplink = 'http://tools.wmflabs.org/wikivoyage/w/monmap.php?lat=' .. lat .. '&lon=' .. long .. '&zoom=13&layer=OX&lang=lv&name=' .. mw.uri.encode(thispagetitle.prefixedText, "WIKI")
		mcoord = mw.ustring.format(i18n.html.karte, monmaplink)
		if precise ~= 'yes' then mprecise = i18n.html.precise end
	end
	seq[cnt] = "''Aizsardzības numurs:'' " .. '<span style="font-size:93%">' .. mvaid .. "</span>&nbsp;&nbsp;&nbsp;''Saites:''&nbsp;" .. mcoord .. mprecise .. '&nbsp;'
	cnt = cnt + 1


	if wikipedia ~= '' then mwikipedia = mw.ustring.format(i18n.html.wikipedia, mw.uri.encode(wikipedia,"PATH")) else mwikipedia = '' end
	if wdid == '' and qid ~= '' then wdid = qid end
	if wdid ~= '' then mwdid = mw.ustring.format(i18n.html.wdid, mw.uri.encode(wdid,"PATH")) else mwdid = '' end
	if commonscat ~= '' then mcommonscat = mw.ustring.format(i18n.html.commonscat, mw.uri.encode(commonscat,"PATH")) else mcommonscat = '' end
	if extlink ~= '' then mextlink = mw.ustring.format(i18n.html.extlink, extlink) else mextlink = '' end
	if extlink2 ~= '' then mextlink2 = mw.ustring.format(i18n.html.extlink2, extlink2) else mextlink2 = '' end
	seq[cnt] = mwikipedia .. mwdid .. mcommonscat .. mextlink .. mextlink2 .. '<br />'
	cnt = cnt + 1

	if typelabel ~= '' then
		nametypevalue = typelabel
	else
		nametype = i18n.typenames[type]
		namevalue = i18n.valuenames[value]
		nametypevalue = nametype .. ', ' .. namevalue
	end
	if year ~= '' then myear = year else myear = '' end
	   if year ~= '' and author ~= '' then mya = ', ' else mya = '' end
	if author ~= '' then mauthor = author else mauthor = '' end
	seq[cnt] = "''Apraksts:'' " .. myear .. mya .. mauthor .. ' ' .. nametypevalue .. '. ' .. description .. '<br>'
	cnt = cnt + 1

	seq[cnt] = '\n|}'
	result = table.concat(seq)
	return result
end

return p