Модуль:Памятник культурного наследия УкраиныЭтот модуль предназначен для работы с шаблоном {{Памятник культурного наследия Украины}} См. такжеrequire('strict')
local IUH = {}
IUH.__index = IUH
local IUHconfig = require('Module:Памятник культурного наследия Украины/config')
local Munconfig -- пока пустой
local IUHucfirst
local theregword
function IUH:armsgen(regid, statusid)
local arms
arms = 'Lesser Coat of Arms of Ukraine.svg'
if statusid~='Н' then
if regid then
if IUHconfig.regarms[regid] then
arms = IUHconfig.regarms[regid]
end
end
end
return arms
end
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
function IUH:regidexists(regid, disp)
local cato
if disp==true then cato = 'Объекты культурного наследия ' else cato = 'Памятники культурного наследия Украины ' end
if mw.title.new('Category:'..cato..IUHconfig.regins[regid]).exists then
return true
end
return false
end
function IUH:dispterrcheck(regid)
if table.contains(IUHconfig.reginsdisp,regid) then return true end
return false
end
function IUH:gencat(regid, statusid, munid)
local regdisp
local regido
local cat
cat = 'Памятники культурного наследия Украины'
if regid and IUHconfig.regins[regid] then
regdisp=self:dispterrcheck(regid)
regido = self:regidexists(regid, regdisp) else
regdisp = false
regido = false
end
if statusid then
if regid then
if IUHconfig.regins[regid] then
if IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][1] then
if mw.title.new('Category:' .. IUHconfig.statuscats[statusid][1]..' памятники культурного наследия '..IUHconfig.regins[regid]).exists then
cat = IUHconfig.statuscats[statusid][1]..' памятники культурного наследия '..IUHconfig.regins[regid]
else
local cattemp
cattemp = cat
if regdisp==true then
cat='Объекты культурного наследия'
end
local secondcat
if IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][2] and mw.title.new('Category:'..cattemp..' '..IUHconfig.statuscats[statusid][2]).exists then
secondcat = ']][[Категория:'..cattemp..' '..IUHconfig.statuscats[statusid][2]
else secondcat = ''
end
if regido==true then
cat = cat..' '..IUHconfig.regins[regid]
else
if cat=='Объекты культурного наследия' then cat='Памятники культурного наследия Украины'
end
if secondcat~='' then
cat=mw.ustring.sub(secondcat,15,-1)
secondcat = ''
end
end
cat = cat..' '..IUHconfig.regins[regid]..secondcat
end
else
if regdisp==true then
cat='Объекты культурного наследия'
end
if regido==true then
cat = cat..' '..IUHconfig.regins[regid]
else
if cat=='Объекты культурного наследия' then cat = 'Памятники культурного наследия Украины' end
end
end
else
if IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][2] then
if mw.title.new('Category:'..cat..' '..IUHconfig.statuscats[statusid][2]).exists then
cat = cat..' '..IUHconfig.statuscats[statusid][2]
end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if Munconfig and Munconfig.munins[munid] then
if IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][1] then
if mw.title.new('Category:' .. IUHconfig.statuscats[statusid][1]..' памятники культурного наследия '..Munconfig.munins[munid]).exists then
cat = IUHconfig.statuscats[statusid][1]..' памятники культурного наследия '..Munconfig.munins[munid]
else
local thirdcat
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Памятники культурного наследия Украины ' end
if mw.title.new('Category:'..checker..Munconfig.munins[munid]).exists then
if IUHconfig.regins[regid]~=nil then
if mw.title.new('Category:' .. IUHconfig.statuscats[statusid][1]..' памятники культурного наследия '..IUHconfig.regins[regid]).exists then
thirdcat = ']][[Категория:'..checker..Munconfig.munins[munid]
else
thirdcat = ''
if regdisp==true then
cat = mw.ustring.gsub(cat,'Объекты культурного наследия '..IUHconfig.regins[regid],'Объекты культурного наследия '..Munconfig.munins[munid])
else
cat = mw.ustring.gsub(cat,'Памятники культурного наследия Украины '..IUHconfig.regins[regid],'Памятники культурного наследия Украины '..Munconfig.munins[munid])
end
end
else
thirdcat = ']][[Категория:Памятники культурного наследия Украины '..Munconfig.munins[munid]
end
else thirdcat = ''
end
cat = cat..thirdcat
end
end
end
end
else
if IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][2] then
if mw.title.new('Category:'..cat..' '..IUHconfig.statuscats[statusid][2]).exists then
cat = cat..' '..IUHconfig.statuscats[statusid][2]
end
end
end
else
if regid then
if IUHconfig.regins[regid] then
if regdisp==true then
cat='Объекты культурного наследия'
end
if regido==true then
cat = cat..' '..IUHconfig.regins[regid]
else
if cat=='Объекты культурного наследия' then cat = 'Памятники культурного наследия Украины' end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if (Munconfig and Munconfig.munins[munid]) then
local checker
if regdisp==true then
checker = 'Объекты культурного наследия ' else checker = 'Памятники культурного наследия Украины '
end
if mw.title.new('Category:'..checker..''..Munconfig.munins[munid]).exists then
cat = checker..Munconfig.munins[munid]
end
end
end
end
end
return cat
end
function IUH:genmunicipality(munid)
if munid then
if tonumber(munid) then
munid = Munconfig.municipality[munid]
end
if not Munconfig.munins[munid] then
munid = nil
end
end
return munid
end
function IUH:returnnotnill(variable)
if variable then
if variable ~=nil then
return variable
end
end
return ''
end
function IUH:getmunconfig(regid)
local Munconfigstring
if mw.title.new('Модуль:Памятник культурного наследия Украины/config/'..regid).exists then
if require('Модуль:Памятник культурного наследия Украины/config/'..regid)~=nil then
Munconfigstring ='Памятник культурного наследия Украины/config/'..regid
end
end
if Munconfigstring~= nil and Munconfigstring~='' and require(Munconfigstring)~=nil then
return require(Munconfigstring)
else
return nil
end
end
function IUH:genstatus(statusid, number)
local statusword
statusword = ''
if not statusid then
if number then
if(mw.ustring.sub(number,-2))=='-Н' then
statusid = 'Н'
end
if (IUHconfig.regarms[mw.ustring.sub(number,-2)] or IUHconfig.regaliases_native[mw.ustring.sub(number,-2)]) then
statusid = 'М'
end
end
end
if statusid then
if not IUHconfig.statuscats[statusid] then
statusid = nil
end
if statusid~=nil and IUHconfig.statuscats[statusid] and IUHconfig.statuscats[statusid][2] then
statusword = IUHconfig.statuscats[statusid][2]
else statusword = '' end
end
return {['statusid']=statusid, ['statusword']=statusword,}
end
function IUH:genreg(regid, number)
if regid then
if IUHconfig.regaliases_native[regid] then
regid = IUHconfig.regaliases_native[regid]
end
if not IUHconfig.regarms[regid] then
regid = nil
end
end
if number then
local regtest = mw.ustring.sub(number,-2)
if IUHconfig.regaliases_native[regtest] then
regid = IUHconfig.regaliases_native[regtest]
end
if IUHconfig.regarms[regtest] then
if not regid then
regid = regtest
end
end
end
return regid
end
function IUH:coregen(number, regid, statusid, munid)
local statusword
local URL
local regidword
local statusarms
local regcatword
if number then
if mw.ustring.len(tostring(number)) > 10 then
number = nil
end
end
if not theregword then
if IUHucfirst == true then
theregword = 'Охр. №'
else
theregword = 'охр. №'
end
end
local statusarray = self:genstatus(statusid, number)
statusid = statusarray.statusid
statusword = statusarray.statusword or ''
regid = self:genreg(regid, number)
regcatword = ''
if regid then
if munid then
Munconfig = self:getmunconfig(regid)
end
end
local namespacecheck = mw.ustring.len(self.frame:preprocess('{{NAMESPACE}}'))
if statusid then
if self.args['нпп'] then
URL = 'http://zakon.rada.gov.ua/laws/show/574-17'
else
if statusid =='Н' then
if self.args['сов'] then
URL = 'http://search.ligazakon.ua/l_doc2.nsf/link1/KP630970.html'
else
URL = 'https://mkip.gov.ua/content/perelik-pamyatok-kulturnoi-spadshchini-nacionalnogo-znachennya.html'
end
else
if statusid == 'М' then
URL = 'https://mkip.gov.ua/content/derzhavniy-reestr-pamyatok-miscevogo-znachennya.html'
else
URL = 'https://mkip.gov.ua/content/derzhavniy-reestr-neruhomih-pamyatok-ukraini.html'
end
end
end
else
URL = 'https://mkip.gov.ua/content/derzhavniy-reestr-neruhomih-pamyatok-ukraini.html'
end
if number then
regidword = '['..URL..' '..theregword..' '..number..']'
else
regidword = ''
end
statusarms = self:armsgen(regid, statusid)
if not self.args['nocat'] then
if namespacecheck==0 then
regcatword='[[Категория:'..self:gencat(regid, statusid)..']]'
end
end
return {['number']=number, ['regidword']=regidword, ['regcatword']=regcatword, ['statusword']=statusword, ['statusarms']=statusarms,}
end
function IUH:render()
local ArmstoRender
local numarg, regarg, statarg
local municipality = self.args['Район'] or self.args['Город']
if self.args['1'] then
numarg = self.args['1']
end
if self.args['номер'] then
numarg = self.args['номер']
end
if self.args['2'] then
regarg = self.args['2']
end
if self.args['регион'] then
regarg = self.args['регион']
end
if self.args['3'] then
statarg = self.args['3']
end
if self.args['статус'] then
statarg = self.args['статус']
end
local div, divend
div, divend = '', ''
local Coredata
local statuswordrender
local regidrender
self.micro = mw.ustring.find(self:returnnotnill(self.args['мини']),'микро',0,true)~=nil and true or false
local minidiv = mw.ustring.find(self:returnnotnill(self.args['мини']),'div',0,true)~=nil and true or false
if self.args['мини'] then
if minidiv==true then
div, divend = '<div>','</div>'
end
IUHucfirst = true
Coredata = self:coregen(numarg, regarg, statarg, municipality)
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword end
if Coredata.regidword~='' then regidrender =(self.micro~=true and '. ' or '')..'{{nobr|1='..Coredata.regidword..'}}' else regidrender = '' end
if self.args['Без герба'] then
ArmstoRender = '' else ArmstoRender = '[[Файл:'..Coredata.statusarms..'|20x25px|link=|Герб]] ' end
local stringtoreturn = self.frame:preprocess(div..ArmstoRender..'<span title="Памятник культурного наследия Украины" style="margin-left: 0.2em; font-size: 85%;">'..(self.micro~=true and ('Памятник культурного наследия Украины'..statuswordrender) or '')..regidrender..'</span>'..divend..Coredata.regcatword)
return stringtoreturn
else
IUHucfirst = false
Coredata = self:coregen(numarg, regarg, statarg, municipality)
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword end
if Coredata.regidword~='' then
regidrender = self.frame:preprocess('<br><small>'..Coredata.regidword..'</small>') else regidrender = '' end
local embwidth, embclass, embwidthcss, embbordercss, cellspa
if not self.args['встраивать'] then
embclass = 'infobox'
embwidthcss = '280px'
embwidth = nil
embbordercss = nil
else
embclass = nil
embwidthcss = nil
embwidth = '100%'
embbordercss = '1px solid #a2a9b1'
if self.args['встраивать']=='UNESCO' then
cellspa = '5'
end
end
local builder = mw.html.create()
builder = builder:tag('table')
:attr('width', embwidth)
:attr('cellspacing', cellspa)
:addClass(embclass)
:css('width', embwidthcss)
:css('border', embbordercss)
:tag('tr')
:tag('td')
:cssText('vertical-align: middle; padding: 5px;')
:wikitext('[[Файл:'..Coredata.statusarms..'|45x55px|link=|Герб]]')
:done()
:tag('td')
:cssText('text-align:center; vertical-align:middle; background:'..(self.args['цвет']=='transparent' and self.args['цвет'] or '#dcebff')..'; width:100%;')
:wikitext('<span style="white-space: normal !important; font-weight: bold;">Памятник культурного наследия Украины'..statuswordrender..'</span>'..regidrender..Coredata.regcatword)
:done()
:done()
builder = builder:done()
return builder
end
end
function IUH:renderText()
local ArmstoRender = ''
local numarg, regarg, statarg
local municipality = self.args['Район'] or self.args['Город']
if self.args['1'] then
numarg = self.args['1']
end
if self.args['номер'] then
numarg = self.args['номер']
end
if self.args['2'] then
regarg = self.args['2']
end
if self.args['регион'] then
regarg = self.args['регион']
end
if self.args['3'] then
statarg = self.args['3']
end
if self.args['статус'] then
statarg = self.args['статус']
end
local Coredata
local statuswordrender
local regidrender
if self.args['мини'] then
IUHucfirst = true
Coredata = self:coregen(numarg, regarg, statarg, municipality)
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword end
if Coredata.regidword~='' then regidrender ='. {{nobr|1='..Coredata.regidword..'}}' else regidrender = '' end
local stringtoreturn = self.frame:preprocess('<span title="Памятник культурного наследия Украины" style="margin-left: 0.2em; font-size: 85%;">Памятник культурного наследия Украины'..statuswordrender..regidrender..'</span>'..Coredata.regcatword)
return stringtoreturn
else
IUHucfirst = false
Coredata = self:coregen(numarg, regarg, statarg, municipality)
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword end
if Coredata.regidword~='' then
regidrender = self.frame:preprocess('<br><small>'..Coredata.regidword..'</small>') else regidrender = '' end
return '<span style="white-space: normal !important; font-weight: bold;">Памятник культурного наследия Украины'..statuswordrender..'</span>'..regidrender..Coredata.regcatword
end
end
function IUH:renderArms()
local ArmstoRender = ''
local numarg, regarg, statarg
local municipality = self.args['Район'] or self.args['Город']
if self.args['1'] then
numarg = self.args['1']
end
if self.args['номер'] then
numarg = self.args['номер']
end
if self.args['2'] then
regarg = self.args['2']
end
if self.args['регион'] then
regarg = self.args['регион']
end
if self.args['3'] then
statarg = self.args['3']
end
if self.args['статус'] then
statarg = self.args['статус']
end
local Coredata
local statuswordrender
local regidrender
IUHucfirst = true
Coredata = self:coregen(numarg, regarg, statarg, municipality)
return Coredata.statusarms
end
function IUH.new(frame, args)
if not args then
args = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Памятник культурного наследия Украины', 'Template:Культурное наследие Крым'}})
--return
end
local obj = {
frame = frame,
args = args
}
return setmetatable(obj, IUH)
end
local p = {}
function p.main(frame)
return IUH.new(frame):render()
end
function p.mainText(frame)
return IUH.new(frame):renderText()
end
function p.mainArms(frame)
return IUH.new(frame):renderArms()
end
return p
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia