Jump to content

Module:NatureMonument

Unchecked
From Wikipedia

Documentation for this module may be created at Module:NatureMonument/doc

-- local image_module = require('Module:InfoboxImage')

local NatureMonumentIssuesLV = require('Module:NatureMonumentIssuesLV')

local i18n = {
	html = {
		topline = '{| border=0 style="font-size:97%%;width:100%%;"\n|- valign="top" \n| ',
		nameline = '<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 = '[[File:Map mag.png|18px|link=%s|Karte]]',
		wikipedia = '[[File:Wikipedia-logo-v2.svg|20px|link=http://lv.wikipedia.org/wiki/%s|Vikipēdijas raksts]]',
		wdid = '[[File:Wikidata-logo.svg|20px|link=http://wikidata.org/wiki/%s|Wikidata]]',
		commonscat = '[[File:Commons-logo.svg|18px|link=http://commons.wikimedia.org/wiki/Category:%s|Wikimedia Commons kategorija]]',
		extlink = '[[File:P geography 3 b.png|24px|link=%s|Arējās saites]]',
		extlink2 = '[[File: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',
	},
	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-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 issues4wdid, 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, msquare, mnatura2000
	local upwizlink, upwizlinkname, upwizlinkname2, upwizlinkcommons, commonscatwiz
	local monmaplink, thispagetitle, regioname, subregion, rixsubregion, subRegCount

	local name = frame.args['name'] or ''
	local lat = frame.args['lat'] or ''
	local long = frame.args['long'] or ''
	local image = frame.args['image'] or ''
	local commonscat = frame.args['commonscat'] or ''
	local region = frame.args['region'] or ''
	local year = frame.args['year'] or ''
	local square = frame.args['square'] or ''
	local natura2000 = frame.args['natura2000'] or ''
	local wdid = frame.args['wdid'] or ''

	local type = frame.args['type'] or ''
	local typelabel = frame.args['typelabel'] or ''
	local value = frame.args['value'] or ''
	local precise = frame.args['precise'] or ''
	local complex = frame.args['complex'] or ''
	local decreenum = frame.args['decreenum'] or ''
	local decreedate = frame.args['decreedate'] or ''
	local decreepublicated = frame.args['decreepublicated'] 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 author = frame.args['author'] or ''
	local locality = frame.args['locality'] or ''
	local description = frame.args['description'] or ''
	local wikipedia = frame.args['wikipedia'] 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

    seq[cnt] = mw.ustring.format(i18n.html.topline)
	cnt = cnt + 1

	upwizlinkname2 = name
	upwizlinkname = mw.uri.encode(upwizlinkname2, "PATH")

	if region == '' then regionname = 'Cultural heritage monuments in ' .. region else regionname = '' end

	if commonscat == '' then commonscatwiz = regionname else commonscatwiz = commonscat end
	upwizlinkcommons = mw.uri.encode(commonscatwiz, "PATH")
	upwizlink = mw.ustring.format(i18n.html.upwizlink, natura2000, upwizlinkname, lat, long, upwizlinkcommons)

	if image == '' then 
		mphoto = '[[File:Ieladet attelus.png|150px|link=' .. upwizlink .. ']]'
	else
		mphoto = '[[File:' .. 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 name ~= '' then mwikipedia = name else mwikipedia = '' end
	seq[cnt] = mw.ustring.format(i18n.html.nameline, mwikipedia)
	cnt = cnt + 1

	if natura2000 ~= '' then 
		mnatura2000 = '[http://natura2000.eea.europa.eu/Natura2000/SDF.aspx?site=' .. natura2000 .. ' ' .. natura2000 .. ']'
	else
		mnatura2000 = ''
	end
	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)
	end
	seq[cnt] = "''Aizsardzības numurs:'' " .. '<span style="font-size:93%">' .. mnatura2000 .. "</span>&nbsp;&nbsp;&nbsp;<br>''Saites:''&nbsp;" .. mcoord .. '&nbsp;'
	cnt = cnt + 1

	if wikipedia ~= '' then mwikipedia = mw.ustring.format(i18n.html.wikipedia, mw.uri.encode(wikipedia,"PATH")) else mwikipedia = '' 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
	seq[cnt] = mwikipedia .. mwdid .. mcommonscat .. '<br />'
	cnt = cnt + 1

	if square ~= '' then msquare = square .. ' ha' else msquare = '' end
	seq[cnt] = "''Platība:'' " .. msquare .. '<br>'
	cnt = cnt + 1

	if year ~= '' then myear = year else myear = '' end
	seq[cnt] = "''Dibināšanas gads/datums:'' " .. myear .. '<br>'
	cnt = cnt + 1

    issues4wdid = NatureMonumentIssuesLV.issues(wdid)
    if issues4wdid ~= '' then 
		missues = "\n|"
        size,imgcnt,atsauces,vikisaites = issues4wdid:match("([^,]+),([^,]+),([^,]+),([^,]+)")
		if size ~= '' then missues = missues ..  "''Raksta garums:'' " .. size .. '<br>' else missues = missues .. '' end
		if imgcnt ~= '' then missues = missues ..  "''Attēli:'' " .. imgcnt .. '<br>' else missues = missues .. '' end
		if atsauces ~= '0' then missues = missues ..  "'''Nav atsauču''' " .. '<br>' end
		if vikisaites ~= '0' then missues = missues ..  "'''Trūkst vikisaišu''' " .. '<br>' end
	else
		missues = "\n|"
	end
	seq[cnt] =  missues .. '<br>'
	cnt = cnt + 1

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

return p