Модуль:Культурное наследие народов РФЭтот модуль предназначен для обработки данных регистрационного номера ОКН в шаблоне {{Культурное наследие народов РФ}} См. такжеrequire('strict')
local IRH = {}
IRH.__index = IRH
IRH.config = require('Module:Культурное наследие народов РФ/config')
IRH.Munconfig = nil-- пока пустой, он должен require'ться только при указании региона
IRH.ucfirst = false
IRH.Regconfig = nil
local theobjword, theregword
local wordseparator
local function valkey(t,val)
for k,v in pairs(t) do
if v==val then return k end
end
return nil
end
function IRH:regidexists(regid, disp)
if self.config.forceemptycategorization==true then return true end
local cato
if disp==true then cato = 'Объекты культурного наследия ' else cato = 'Объекты культурного наследия России ' end
if mw.title.new('Category:'..cato..self:getregiondatas().regins[regid]).exists then
return true
end
return false
end
function IRH:isTable(val)
if val and val~=nil then
if type(val)=='table' then
return true
end
end
return false
end
function mw.ustring.ucfirst(str)
return mw.ustring.upper(mw.ustring.sub(str,1,1))..mw.ustring.sub(str,math.min(mw.ustring.len(str),2),-1)
end
local function cntendsmb(str,smb)
local cnt
cnt = 0
smb = smb or ' '
local isfinished = false
while isfinished==false do
if mw.ustring.sub(str,-1,-1)==smb then
cnt = cnt + 1
str = mw.ustring.sub(str,1,-2)
else
isfinished = true
end
end
return cnt
end
function IRH:isTableandHasKey(tab,key)
if self:isTable(tab)==true then
if tab[key] and (tab[key]~=nil) then
return true
end
end
return false
end
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
function IRH:armsgen(regid, statusid, munid)
local arms
arms = 'Coat of Arms of the Russian Federation 2.svg'
if statusid~='Ф' then
if regid then
if self:getregiondatas().regarms[regid] then
arms = self:getregiondatas().regarms[regid]
end
end
if statusid=='М' then
if munid and ((munid~=nil) and (munid~='')) then
if ((self.Munconfig~=nil) and self:isTable(self.Munconfig.munarms)) and self.Munconfig.munarms[munid] then
arms = self.Munconfig.munarms[munid]
end
end
end
end
return arms
end
function IRH:dispterrcheck(regid)
if table.contains(self.config.reginsdisp,regid) then return true end
return false
end
function IRH:firstwordcat(statusid)
if self.config.statuscats[statusid] and self.config.statuscats[statusid][2] then
if (self.config.statuscats[statusid][2]~=nil) and (self.config.statuscats[statusid][2]~='') then
return {false, 2}
end
end
return {true, 1}
end
function IRH:gencatlink(regid, statusid, number, voynumber, munid)
local regdisp
local regido
local cat
local shallbefirst, firstcatflag, firstcatcell
shallbefirst = self:firstwordcat(statusid)
firstcatflag = shallbefirst[1]
firstcatcell = shallbefirst[2]
shallbefirst = nil -- дальше нам это не требуется
if table.contains(self.config.statussuppress,statusid) then return '' end
cat = 'Объекты культурного наследия России'
if self.args['утрачен'] then
cat = ''
else
if regid and self:getregiondatas().regins[regid] then
regdisp = self:dispterrcheck(regid)
regido = self:regidexists(regid, regdisp)
else
regdisp = false
regido = self.config.forceemptycategorization==true and true or false
end
if statusid then
if regid then
if self:getregiondatas().regins[regid] then
if self.config.statuscats[statusid] and self.config.statuscats[statusid][1] then
if mw.title.new('Category:' .. self.config.statuscats[statusid][1]..' объекты культурного наследия '..self:getregiondatas().regins[regid]).exists then
cat = self.config.statuscats[statusid][1]..' объекты культурного наследия '..self:getregiondatas().regins[regid]
else
local cattemp
cattemp = cat
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
if regido==true then
cat = cat..' '..self:getregiondatas().regins[regid]
end
end
if munid and ((munid~=nil) and (munid~='')) then
if self.Munconfig~=nil and (self:isTable(self.Munconfig.munins)==true) and self.Munconfig.munins[munid] then
if self.config.statuscats[statusid] and self.config.statuscats[statusid][1] then
if mw.title.new('Category:' .. self.config.statuscats[statusid][1]..' объекты культурного наследия '..self.Munconfig.munins[munid]).exists then
cat = self.config.statuscats[statusid][1]..' объекты культурного наследия '..self.Munconfig.munins[munid]
else
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists
if muncatexist then
cat = checker..self.Munconfig.munins[munid]
end
end
else
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists
if muncatexist then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
else
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
if regido==true then
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Объекты культурного наследия' then cat = cat..' России' end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if self.Munconfig~=nil and (self:isTable(self.Munconfig.munins)==true) and self.Munconfig.munins[munid] then
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists
if muncatexist then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
end
else
if regid then
if self:getregiondatas().regins[regid] then
if regido==true then
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Объекты культурного наследия' then cat = cat..' России' end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if self.Munconfig~=nil and (self:isTable(self.Munconfig.munins)==true) and self.Munconfig.munins[munid] then
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists
if muncatexist then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
end
end
if cat=='Объекты культурного наследия России' then
if number or (voynumber and ((voynumber ~='') and (voynumber ~= nil))) then
cat = ''
end
end
return cat~='Объекты культурного наследия' and (':Категория:'..cat) or ''
end
function IRH:gencat(regid, statusid, number, voynumber, munid)
local regdisp
local regido
local cat
local shallbefirst, firstcatflag, firstcatcell
shallbefirst = self:firstwordcat(statusid)
firstcatflag = shallbefirst[1]
firstcatcell = shallbefirst[2]
shallbefirst = nil -- дальше нам это не требуется
if table.contains(self.config.statussuppress,statusid) then return '' end
cat = 'Объекты культурного наследия России'
if self.args['утрачен'] then
cat = ''
else
if regid and self:getregiondatas().regins[regid] then
regdisp = self:dispterrcheck(regid)
regido = self:regidexists(regid, regdisp)
else
regdisp = false
regido = self.config.forceemptycategorization==true and true or false
end
if statusid then
if regid then
if self:getregiondatas().regins[regid] then
if self.config.statuscats[statusid] and self.config.statuscats[statusid][1] then
if mw.title.new('Category:' .. self.config.statuscats[statusid][1]..' объекты культурного наследия '..self:getregiondatas().regins[regid]).exists then
cat = self.config.statuscats[statusid][1]..' объекты культурного наследия '..self:getregiondatas().regins[regid]
else
local cattemp
cattemp = cat
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
local cattolook
if firstcatflag==false then
cattolook = cattemp..' '..self.config.statuscats[statusid][2]
else
cattolook = self.config.statuscats[statusid][1]..' объекты культурного наследия России'
end
local secondcat
if self.config.statuscats[statusid] and self.config.statuscats[statusid][firstcatcell] and mw.title.new('Category:' .. cattolook).exists then
secondcat = ']][[Категория:'..cattolook
else secondcat = ''
end
if regido==true then
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Объекты культурного наследия' then cat=cat..' России' end
if number or (voynumber and ((voynumber ~='') and (voynumber ~= nil))) then
if secondcat~='' then
cat=mw.ustring.sub(secondcat,15,-1)
secondcat = ''
end
end
end
cat = cat..(secondcat or '')
end
else
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
if regido==true then
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Объекты культурного наследия' then cat = cat..' России' end
end
end
else
local cattolook
if firstcatflag==false then
cattolook = cat..' '..self.config.statuscats[statusid][2]
else
cattolook = self.config.statuscats[statusid][1]..' объекты культурного наследия России'
end
if self.config.statuscats[statusid] and self.config.statuscats[statusid][firstcatcell] then
if mw.title.new('Category:' .. cattolook).exists then
cat = cattolook
end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if self.Munconfig~=nil and (self:isTable(self.Munconfig.munins)==true) and self.Munconfig.munins[munid] then
if self.config.statuscats[statusid] and self.config.statuscats[statusid][1] then
if mw.title.new('Category:' .. self.config.statuscats[statusid][1]..' объекты культурного наследия '..self.Munconfig.munins[munid]).exists then
cat = self.config.statuscats[statusid][1]..' объекты культурного наследия '..self.Munconfig.munins[munid]
else
local thirdcat
local checker
if regdisp==true then checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists
if self:getregiondatas().regins[regid]~=nil then
if mw.title.new('Category:' .. self.config.statuscats[statusid][1]..' объекты культурного наследия '..self:getregiondatas().regins[regid]).exists then
if muncatexist then
thirdcat = ']][[Категория:'..checker..self.Munconfig.munins[munid]
else thirdcat = '' end
else
thirdcat = ''
if muncatexist then
if regdisp==true then
cat = mw.ustring.gsub(cat,'Объекты культурного наследия '..self:getregiondatas().regins[regid],'Объекты культурного наследия '..self.Munconfig.munins[munid])
else
cat = mw.ustring.gsub(cat,'Объекты культурного наследия России '..self:getregiondatas().regins[regid],'Объекты культурного наследия России '..self.Munconfig.munins[munid])
end
end
end
else
if muncatexist then
thirdcat = ']][[Категория:Объекты культурного наследия России '..self.Munconfig.munins[munid]
end
end
cat = cat..thirdcat
end
end
end
end
else
local cattolook
if firstcatflag==false then
cattolook = cat..' '..self.config.statuscats[statusid][2]
else
cattolook = self.config.statuscats[statusid][1]..' объекты культурного наследия России'
end
if self.config.statuscats[statusid] and self.config.statuscats[statusid][firstcatcell] then
if mw.title.new('Category:' .. cattolook).exists then
cat = cattolook
end
end
end
else
if regid then
if self:getregiondatas().regins[regid] then
if regido==true then
if regdisp==true then
cat=mw.ustring.sub(cat,1,28)
end
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Объекты культурного наследия' then cat = cat..' России' end
end
end
if munid and ((munid~=nil) and (munid~='')) then
if (self.Munconfig~=nil and (self:isTable(self.Munconfig.munins)==true) and self.Munconfig.munins[munid]) then
local checker
if regdisp==true then
checker = 'Объекты культурного наследия ' else checker = 'Объекты культурного наследия России '
end
if self.config.forceemptycategorization==true or mw.title.new('Category:'..checker..self.Munconfig.munins[munid]).exists then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
end
end
if cat=='Объекты культурного наследия России' then
if number or (voynumber and ((voynumber ~='') and (voynumber ~= nil))) then
cat = ''
end
end
return cat
end
function IRH:genmunicipality(munid)
if munid then
if tonumber(munid) then
if self.Munconfig~=nil and (self:isTable(self.Munconfig.municipality)==true) then
munid = self.Munconfig.municipality[munid]
else
munid = nil
end
end
if not ((self.Munconfig~=nil) and (self:isTableandHasKey(self.Munconfig.munarms,munid) or (self:isTableandHasKey(self.Munconfig.munins,munid)))) then
munid = nil
end
end
return munid
end
function IRH:returnnotnil(variable)
if variable then
if variable ~=nil then
return variable
end
end
return ''
end
function IRH:getregiondatas()
if self.Regconfig~=nil then
return self.Regconfig
else
return self.config
end
end
function IRH:genstatus(statusid, number, voyagecode)
local statusword, statusfirstword
statusword, statusfirstword = ''
if statusid then
if tonumber(statusid) then
statusid = self.config.statuskeys[tostring(statusid)] else
if (mw.ustring.len(statusid)==3) then
if mw.ustring.sub(statusid,-2) == 'ВГ' then
statusid = self.config.statuskeysvoy[tostring(mw.ustring.sub(statusid,1,1))]
end
else
statusid = statusid
end
end
else
if number then
statusid = statusid or self.config.statuskeys[tostring(mw.ustring.sub(number,-1))]
else
if voyagecode then
statusid = statusid or self.config.statuskeysvoy[tostring(mw.ustring.sub(voyagecode, 3, 3))]
end
end
end
if statusid then
if not self.config.statuscats[statusid] then
statusid = nil
end
if statusid~=nil and self.config.statuscats[statusid] and self.config.statuscats[statusid][2] then
statusword = self.config.statuscats[statusid][2]
else statusword = '' end
if statusid ~=nil and self.config.statuscats[statusid] and self.config.statuscats[statusid][1] then
statusfirstword = mw.ustring.sub(self.config.statuscats[statusid][1],1,-2)..'й'
else
statusfirstword = ''
end
end
return {['statusid']=statusid, ['statusword']=statusword, ['statusfirstword']=statusfirstword,}
end
function IRH:genreg(regid, number, voynumber)
if regid then
if tonumber(regid) then
regid = self.config.regionsEGR[tostring(regid)]
else
if mw.ustring.len(regid)==4 then
if mw.ustring.sub(regid,-2)=='ВГ' then
regid = self.config.regionsvoy[tostrins(mw.ustring.sub(regid,1,2))]
end
end
end
end
local EGRregid, voyregid
if number then
EGRregid = self.config.regionsEGR[mw.ustring.sub(number,1,2)]
end
if voynumber then
if (voynumber ~= nil) and (voynumber ~= '') then
voyregid = self.config.regionsvoy[mw.ustring.sub(voynumber,1,2)]
end
end
if self.config.forcewvregions then
regid = regid or voyregid or EGRregid
else
regid = regid or EGRregid or voyregid
end
if self.config.regionsaliases[regid] then
regid = self.config.regionsaliases[regid] end
for _,v in ipairs(self.config.fdlist) do
for b,r in ipairs(self.config.feddistr[v]) do
if regid==r then
self.Regconfig = 'Модуль:Культурное наследие народов РФ/config/'..v
break
end
if self.Regconfig ~=nil then break end
end
end
if self.Regconfig ~= nil then
if not mw.title.new(self.Regconfig).exists then
self.Regconfig=nil
end
end
if self.Regconfig ~= nil then
self.Regconfig = require(self.Regconfig).Reg()
end
return regid
end
function IRH:tablecount(tab)
local Count
Count = 0
for Index, Value in pairs( tab ) do
Count = Count + 1
end
return Count
end
function IRH:getMunconfig(regid)
local IsFD
IsFD = false
local MCSTRtest
local Munconfigstring
for _,v in ipairs(self.config.fdlist) do
for _,s in ipairs(self.config.feddistr[v]) do
if regid==s then
Munconfigstring = 'Модуль:Культурное наследие народов РФ/config/'..v
IsFD = true
break
end
if Munconfigstring~=nil then break end
end
end
if Munconfigstring ~= nil then
if not mw.title.new(Munconfigstring).exists then
Munconfigstring=nil
IsFD = false
end
end
--if IsFD==false or self.args['reg_pages'] then
if mw.title.new('Модуль:Культурное наследие народов РФ/config/'..regid).exists then
MCSTRtest = require('Модуль:Культурное наследие народов РФ/config/'..regid)
if (MCSTRtest~=nil) and (type(MCSTRtest)~='boolean') then
Munconfigstring ='Модуль:Культурное наследие народов РФ/config/'..regid
end
end
--end
if Munconfigstring~= nil and Munconfigstring~='' then
if IsFD==true then
return require(Munconfigstring).Mun(tostring(regid))
else
return require(Munconfigstring)
end
else
return nil
end
end
function IRH:coregen(number, url, regid, statusid, wikivoyageid, munid)
self.shortminiview = mw.ustring.find(self:returnnotnil(self.args['мини']),'short',0,true)~=nil and true or false
self.regwordtooltip = nil
local munarray = {}
local numarray = {}
local munarmsid
local munplaceid
local numWVarray = {}
local statusword, statusfirstword
local regidword
local statusarms
local regcatword
local wikivoyageword
local alphabetstatus
if munid then
if mw.ustring.sub(munid,1,1)=='{' and mw.ustring.sub(munid,-1)=='}' then
munid = mw.ustring.sub(munid,2,-2)
munid = string.gsub(munid, "%s+", "")
munarray = mw.text.split(munid,',')
end
end
if self:tablecount(munarray)>0 then
if self:tablecount(munarray)>2 then
munarray={munarray[1], munarray[2]}
else if self:tablecount(munarray)==1 then
munid = munarray[1]
munarray = {}
end
end
end
if munarray[1] then
munarmsid = munarray[1]
end
if munarray[2] then
munplaceid = munarray[2]
end
if munarmsid=='~0' then
munarmsid=''
end
if munplaceid=='~0' then
munplaceid=''
end
if not theregword then
if self.shortminiview==true then
theregword = 'р. №'
self.regwordtooltip = 'Регистрационный номер в Едином государственный реестр объектов культурного наследия'
else
theregword = 'рег. №'
end
end
if not theobjword then
theobjword = (self.shortminiview==true and self.frame:preprocess('{{abbr|'..(self.ucfirst==true and 'О' or 'о')..'б.|объект(ы)|0}}') or 'объект')..' №'
end
if self.ucfirst == true then
theregword,theobjword = mw.ustring.ucfirst(theregword),mw.ustring.ucfirst(theobjword)
end
wikivoyageword = ''
if wikivoyageid then
if (wikivoyageid~=nil) and (wikivoyageid~='') then
if ((wikivoyageid) and (mw.ustring.sub(wikivoyageid,1,1) == '{')) and (mw.ustring.sub(wikivoyageid,-1) == '}') or (mw.ustring.find(self:returnnotnil(wikivoyageid),', ',0,true)~=nil) then
if ((wikivoyageid) and (mw.ustring.sub(wikivoyageid,1,1) == '{')) and (mw.ustring.sub(wikivoyageid,-1) == '}') then
wikivoyageid = mw.ustring.sub(wikivoyageid,2,-2)
end
wikivoyageid = string.gsub(wikivoyageid, "%s+", "")
numWVarray = mw.text.split(wikivoyageid,',')
if cntendsmb(theobjword,'№')==1 then theobjword = theobjword..'№' end
theobjword = mw.ustring.gsub(theobjword,'ъект ','ъекты ')
wikivoyageword = theobjword..(self.micro~=true and ': ' or '')
local indexoWV
local wikivoyageido
local WVsubarray
WVsubarray = ''
if (self:tablecount(numWVarray)>2) and (self.config.collapsiblenumbers) then
wikivoyageword = wikivoyageword..'[https://ru-monuments.toolforge.org/wikivoyage.php?id='..numWVarray[1]..' '..numWVarray[1]..']'
end
for i=(((self:tablecount(numWVarray)<=2) or (not self.config.collapsiblenumbers)) and 1 or 2),self:tablecount(numWVarray) do
if i==1 then
indexoWV=''
else
indexoWV = ((self:tablecount(numWVarray)<=2) or (not self.config.collapsiblenumbers)) and wordseparator or (wordseparator~='<br>' and wordseparator or ', ')
end
wikivoyageido = numWVarray[i]
if (self:tablecount(numWVarray)>2) and (self.config.collapsiblenumbers) then
WVsubarray = WVsubarray..(i>2 and indexoWV or '')..'[https://ru-monuments.toolforge.org/wikivoyage.php?id='..wikivoyageido..' '..wikivoyageido..']'
else
wikivoyageword = wikivoyageword..indexoWV..'[https://ru-monuments.toolforge.org/wikivoyage.php?id='..wikivoyageido..' '..wikivoyageido..']'
end
end
if WVsubarray ~= '' then
WVsubarray = self.frame:preprocess(' <div class="NavFrame collapsed" style="border: none;display:inline; padding: 0px;"><div class="NavHead" style="height:auto; font-size:105%; background:transparent; display:inline; font-weight: normal;">и другие:</div><div class="NavContent" style="font-size:105%; display:inline;>'..WVsubarray..'</div></div>')
wikivoyageword = wikivoyageword..WVsubarray
end
else
wikivoyageword = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Код-памятника'])..'|title='..theobjword..' $1}}') or '[https://ru-monuments.toolforge.org/wikivoyage.php?id='..self:returnnotnil(self.args['Код-памятника'])..' '..theobjword..self:returnnotnil(self.args['Код-памятника'])..']'
end
end
end
local namespacecheck = mw.ustring.len(self.frame:preprocess('{{NAMESPACE}}'))
regidword = ''
if number then
if (number~=nil) and (number~='') then
if (mw.ustring.sub(number,1,1)=='{' and mw.ustring.sub(number,-1)=='}') or (mw.ustring.find(number,', ',0,true)~=nil) then
if (mw.ustring.sub(number,1,1)=='{' and mw.ustring.sub(number,-1)=='}') then
number = mw.ustring.sub(number,2,-2)
end
number = string.gsub(number, "%s+", "")
numarray = mw.text.split(number,',')
if cntendsmb(theregword,'№')==1 then
theregword = theregword..'№'
end
if self:returnnotnil(self.regwordtooltip)~='' then
theregword = self.frame:preprocess('{{Abbr|'..theregword..'|'..self.regwordtooltip..'|0}}')
end
regidword = theregword..(self.micro~=true and ': ' or '')
local indexo
local numbero
local numsubarray
numsubarray = ''
if (self:tablecount(numarray)>2) and (self.config.collapsiblenumbers) then
regidword = regidword..'[https://tools.wmflabs.org/ru-monuments/get_info.php?id='..numarray[1]..' '..numarray[1]..']'
end
for i=(((self:tablecount(numarray)<=2) or (not self.config.collapsiblenumbers)) and 1 or 2),self:tablecount(numarray) do
if i==1 then
indexo=''
else
indexo = ((self:tablecount(numarray)<=2) or (not self.config.collapsiblenumbers)) and wordseparator or (wordseparator~='<br>' and wordseparator or ', ')
end
numbero = numarray[i]
if (self:tablecount(numarray)>2) and (self.config.collapsiblenumbers) then
numsubarray = numsubarray..(i>2 and indexo or '')..'[https://tools.wmflabs.org/ru-monuments/get_info.php?id='..numbero..' '..numbero..']'
else
regidword = regidword..indexo..'[https://tools.wmflabs.org/ru-monuments/get_info.php?id='..numbero..' '..numbero..']'
end
end
if numsubarray ~= '' then
numsubarray = self.frame:preprocess(' <div class="NavFrame collapsed" style="border: none;display:inline; padding: 0px;"><div class="NavHead" style="height:auto; font-size:105%; background:transparent; display:inline; font-weight: normal;">и другие:</div><div class="NavContent" style="font-size:105%; display:inline;>'..numsubarray..'</div></div>')
regidword = regidword..numsubarray
end
else
if not url then
regidword = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..number..'|title='..theregword..' $1}}') or '[https://tools.wmflabs.org/ru-monuments/get_info.php?id='..number..' '..theregword..' '..number..']'
else
regidword = '[https://okn-mk.mkrf.ru/cultureObjects/viewMaps/'..url..' '..theregword..' '..number..']'
end
end
end
end
local statusarray = self:genstatus(statusid, numarray[1] or number, numWVarray[1] or wikivoyageid)
statusid = statusarray.statusid
statusword = statusarray.statusword or ''
statusfirstword = statusarray.statusfirstword or ''
local addstatuses = {}
local addstatuseshash = {}
local addstatusesfinal = {}
if self.config.multistatuses==true then
if math.max(self:tablecount(numarray), self:tablecount(numWVarray))>1 then
local statustemp
for i=2,math.max(self:tablecount(numarray), self:tablecount(numWVarray)),1 do
statustemp = self:genstatus((self.args['Статус'] or self.args['статус'] or self.args['4'] or nil), numarray[i] or nil, numWVarray[i] or nil)
addstatuses[#addstatuses+1]={['statusid']=statustemp.statusid,['statusword']=statustemp.statusword,['statusfirstword']=statustemp.statusfirstword}
end
if self:tablecount(addstatuses)>0 then
addstatuseshash[statusarray] = true
end
for _,v in ipairs(addstatuses) do
if (not addstatuseshash[v]) then
addstatusesfinal[#addstatusesfinal+1] = v -- you could print here instead of saving to result table if you wanted
addstatuseshash[v] = true
end
end
--addstatuses, addstatuseshash = {}, {}
end
end
regid = self:genreg(regid, numarray[1] or number, wikivoyageid)
local coredataRegidtoreturn = statusid~='Ф' and regid or nil
regcatword = ''
if regid then
if munid then
self.Munconfig = self:getMunconfig(regid)
end
end
statusarms = self:armsgen(regid, statusid, self:genmunicipality(munarmsid or munid))
local munarmsID = statusid=='М' and (self:genmunicipality(munarmsid or munid)) or nil
local addstatusesarms = {}
if self.config.multistatuses==true then
if self:tablecount(addstatusesfinal)>0 then
for _,v in pairs(addstatusesfinal) do
addstatusesarms[#addstatusesarms+1] = self:armsgen(regid, v.statusid, self:genmunicipality(munarmsid or munid))
end
end
end
local gencatlink = self:gencatlink(regid, statusid, number, wikivoyageid, self:genmunicipality(munplaceid or munid))
if not self.args['nocat'] then
if namespacecheck==0 then
if not self.args['утрачен'] then
if self:gencat(regid, statusid, number, wikivoyageid, self:genmunicipality(munplaceid or munid))~='' then
regcatword='[[Категория:'..self:gencat(regid, statusid, number, wikivoyageid, self:genmunicipality(munplaceid or munid))..']]'
end
if number or (wikivoyageid and ((wikivoyageid ~='') and (wikivoyageid ~= nil))) then
if not table.contains(self.config.statussuppress,statusid) then
if table.contains(self.config.forcestatuscats,statusid) then
if self:firstwordcat(statusid)[1]==true then
alphabetstatus='[[Категория:'..tostring(self.config.statuscats[statusid][1])..' объекты культурного наследия России по алфавиту]]'
else
alphabetstatus='[[Категория:Объекты культурного наследия России'..tostring(self.config.statuscats[statusid][1])..' по алфавиту]]'
end
else
alphabetstatus='[[Категория:Объекты культурного наследия России по алфавиту]]'
end
regcatword=alphabetstatus..regcatword
--if not number then
--добавляем tracking category
--regcatword='[[Категория:Объекты культурного наследия России без 15-значных номеров]]'..regcatword
--end
if self.config.multistatuses==true then
if self:tablecount(addstatusesfinal)>0 then
for _,v in pairs(addstatusesfinal) do
if not table.contains(self.config.statussuppress,v.statusid) then
regcatword=regcatword..'[[Категория:'..self:gencat(regid, v.statusid, number, wikivoyageid, self:genmunicipality(munplaceid or munid))..']]'
end
end
end
end
end
end
end
end
end
return {['number']=number, ['regidword']=regidword, ['regcatword']=regcatword, ['statusid']=statusid, ['munarmsID']=munarmsID, ['regid']=coredataRegidtoreturn, ['gencatlink']=gencatlink, ['statusword']=statusword, ['statusarms']=statusarms, ['wikivoyageword']=wikivoyageword, ['statusfirstword']=statusfirstword,['addstatuses']=addstatusesfinal,['addstatusesarms']=addstatusesarms,}
end
function IRH:rendercatWVonly()
if self.args['мини'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata=self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['1'] or self.args['Код-памятника'])..'|plain=true}}')
local region = self.args['Регион'] or self.args['регион']
local status = self.args['Статус'] or self.args['статус']
local municipality = self.args['Муниципалитет'] or self.args['МО'] or self.args['Район'] or self.args['Город']
self.ucfirst = true
local Coredata = self:coregen(nil, nil, region, status, WVwikidata, municipality)
return self.frame:preprocess(Coredata.regcatword)
end
function IRH:render()
if self.args['мини'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Код-памятника'])..'|plain=true}}') or self:returnnotnil(self.args['Код-памятника'])
local EGRNNum
EGRNNum = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..self:returnnotnil(self.args['рег_N'] or self.args['1'])..'|plain=true}}') or self:returnnotnil(self.args['рег_N'] or self.args['1'])
local URLnum = self.args['id_страницы'] or self.args ['2']
local region = self.args['Регион'] or self.args['регион'] or self.args['3']
local status = self.args['Статус'] or self.args['статус'] or self.args['4']
local municipality = self.args['Муниципалитет'] or self.args['МО'] or self.args['Район'] or self.args['Город']
local doc = self.args['док'] or self.args['Док']
local renderdoc
renderdoc = ''
local div, divend
div, divend = '', ''
self.micro = mw.ustring.find(self:returnnotnil(self.args['мини']),'микро',0,true)~=nil and true or false
if (self.micro==true) then
self.micro = true
theobjword, theregword = '',''
end
if doc and ((doc~=nil) and (doc~='')) then
renderdoc = ' '..'('..doc..')'
end
local statuswordrender
local regidrender
local WVrender
local firstword
local suppressrender
wordseparator = self.args['мини'] and ', ' or '<br>'
self.ucfirst = self.args['мини'] and true or false
local Coredata = self:coregen(EGRNNum, URLnum, region, status, WVwikidata, municipality)
local minidiv = mw.ustring.find(self:returnnotnil(self.args['мини']),'div',0,true)~=nil and true or false
suppressrender = false
if self.config.suppressablerender==true then
if Coredata.statusid=='В' then
if not (doc and ((doc~=nil) and (doc~=''))) then
suppressrender=true
end
elseif table.contains(self.config.statussuppress,Coredata.statusid) then return ''
else
if (Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~='')))) then
if not (doc and ((doc~=nil) and (doc~=''))) then
suppressrender=true
end
end
end
end
if suppressrender==true then
return ''
else
if self.args['мини'] then
if (minidiv==true) then
div, divend = '<div>','</div>'
end
if self.args['утрачен'] then
firstword = self.frame:preprocess('{{abbr|Утраченный|может быть восстановлен|0}} [[Объект культурного наследия России|'..(self.shortminiview==true and 'ОКН' or 'объект культурного наследия народов РФ')..']]')
else
firstword = '[[Объект культурного наследия России|'..(self.shortminiview==true and 'ОКН' or 'Объект культурного наследия народов РФ')..']]'
end
if self.args['NumOnly'] then statuswordrender = '' else
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..(self.shortminiview==true and self.frame:preprocess('{{Abbr|'..(mw.ustring.lower(mw.ustring.sub(Coredata.statusfirstword,1,(self.config.statshortnum[Coredata.statusid] or 3)))..'. зн')..'|'..Coredata.statusword..'|0}}') or Coredata.statusword) end
end
if (Coredata.statusword=='') and (Coredata.statusfirstword~='') then
if not self.args['утрачен'] then
firstword = (self.shortminiview==true and mw.ustring.sub(Coredata.statusfirstword,1,(self.config.statshortnum[Coredata.statusid] or 3)) or Coredata.statusfirstword)..' [[Объект культурного наследия России|объект культурного наследия народов РФ]]'
end
else
if not ((Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~=''))))) then
renderdoc = ''
end
end
local regdot
if self.args['NumOnly'] then regdot = '' else regdot = (self.micro~=true and '. ' or '') end
if Coredata.regidword~='' then
local regnote
regnote = self.shortminiview==false and ' ({{abbr|ЕГРОКН|Единый государственный реестр объектов культурного наследия|0}})' or ''
if self.micro==true then
if Coredata.wikivoyageword=='' then
regnote = ''
end
end
if (mw.ustring.sub(EGRNNum,1,1) == '{') or (mw.ustring.find(self:returnnotnil(EGRNNum),', ',0,true)~=nil) then
regidrender =regdot..Coredata.regidword..regnote
else
regidrender =regdot..'{{nobr|1='..Coredata.regidword..'}}'..regnote end else regidrender = '' end
local margin
margin='margin-left: 0.2em; '
local ArmstoRender
if self.args['Без герба'] then
ArmstoRender = ''
if self.args['Без герба']=='nomargin' then
margin = ''
end
else ArmstoRender = '[[Файл:'..Coredata.statusarms..'|20px|link='..(Coredata.gencatlink or '')..'|Объект культурного наследия народов РФ '..statuswordrender..(Coredata.statusarms~='Coat of Arms of the Russian Federation 2.svg' and (' ('..(Coredata.munarmsID~=nil and Coredata.munarmsID or Coredata.regid)..')') or '')..']] ' end
if self.args['NumOnly'] then firstword = '' end
if Coredata.wikivoyageword~='' then
local wvnote
wvnote = self.shortminiview==false and ' (БД Викигида)' or ''
if (self.args['NumOnly']) and (Coredata.regidword=='') then WVrender = '{{nobr|1='..Coredata.wikivoyageword..'}}'..wvnote else WVrender = '. {{nobr|1='..Coredata.wikivoyageword..'}}'..wvnote end else WVrender = '' end
local stringtoreturn = self.frame:preprocess(div..ArmstoRender..'<span title="Объект культурного наследия народов РФ" style="'..margin..'"><small>'..(self.micro~=true and ((firstword or '[[Объект культурного наследия России|'..(self.shortminiview==true and 'ОКН' or 'Объект культурного наследия народов РФ')..']]')..statuswordrender..renderdoc) or '')..regidrender.. WVrender..'</small></span>'..divend..Coredata.regcatword)
return stringtoreturn
else
if self.args['утрачен'] then
firstword = self.frame:preprocess('{{abbr|Утраченный|Объект может быть восстановлен|0}} [[объект культурного наследия России]]')
else
firstword = self.frame:preprocess('[[Объект культурного наследия России]]')
end
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword
end
if (Coredata.statusword == '') and (Coredata.statusfirstword~='') then
if not self.args['утрачен'] then
firstword = Coredata.statusfirstword..' [[Объект культурного наследия России|объект культурного наследия народов РФ]]'
end
else
if not ((Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~=''))))) then
renderdoc = ''
end
end
if Coredata.regidword~='' then
regidrender = self.frame:preprocess('<br><small>'..Coredata.regidword..' ({{abbr|ЕГРОКН|Единый государственный реестр объектов культурного наследия|0}})</small>') else regidrender = '' end
if Coredata.wikivoyageword~='' then
WVrender = '<br><small>'..Coredata.wikivoyageword..' (БД Викигида)</small>' else WVrender = '' end
if renderdoc ~= '' then renderdoc = '<br>'..renderdoc end
local embwidth, embclass, embbordercss, cellspa
if not self.args['встраивать'] then
embclass = 'infobox'
embwidth = nil
embbordercss = nil
else
embclass = 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('role', 'presentation')
:attr('width', embwidth)
:attr('cellspacing', cellspa)
:addClass(embclass)
:css('border', embbordercss)
:tag('tr')
:tag('td')
:cssText('vertical-align: middle; padding: 5px;')
:wikitext('[[Файл:'..Coredata.statusarms..'|45px|link='..(Coredata.gencatlink or '')..'|Объект культурного наследия народов РФ'..statuswordrender..(Coredata.statusarms~='Coat of Arms of the Russian Federation 2.svg' and (' ('..(Coredata.munarmsID~=nil and Coredata.munarmsID or Coredata.regid)..')') or '')..']]')
: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;">'..(firstword or '[[Объект культурного наследия России]]')..statuswordrender..'</span>'..renderdoc..regidrender..WVrender..Coredata.regcatword)
:done()
:done()
builder = builder:done()
return builder
end
end
end
function IRH:renderTextOnly()
if self.args['мини'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Код-памятника'])..'|plain=true}}') or self:returnnotnil(self.args['Код-памятника'])
local EGRNNum
EGRNNum = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..self:returnnotnil(self.args['рег_N'] or self.args['1'])..'|plain=true}}') or self:returnnotnil(self.args['рег_N'] or self.args['1'])
local URLnum = self.args['id_страницы'] or self.args ['2']
local region = self.args['Регион'] or self.args['регион'] or self.args['3']
local status = self.args['Статус'] or self.args['статус'] or self.args['4']
local municipality = self.args['Муниципалитет'] or self.args['МО'] or self.args['Район'] or self.args['Город']
local doc = self.args['док'] or self.args['Док']
local renderdoc
renderdoc = ''
local div, divend
div, divend = '', ''
if doc and ((doc~=nil) and (doc~='')) then
renderdoc = ' '..'('..doc..')'
end
local statuswordrender
local regidrender
local WVrender
local firstword
local suppressrender
wordseparator = self.args['мини'] and ', ' or '<br>'
self.ucfirst = self.args['мини'] and true or false
local Coredata = self:coregen(EGRNNum, URLnum, region, status, WVwikidata, municipality)
suppressrender = false
if Coredata.statusid=='В' then
if not (doc and ((doc~=nil) and (doc~=''))) then
suppressrender=true
end
elseif table.contains(self.config.statussuppress,Coredata.statusid) then return ''
else
if (Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~='')))) then
if not (doc and ((doc~=nil) and (doc~=''))) then
suppressrender=true
end
end
end
if suppressrender==true then
return ''
else
if self.args['мини'] then
if self.args['мини']=='div' then
div, divend = '<div>','</div>'
end
if self.args['утрачен'] then
firstword = self.frame:preprocess('{{abbr|Утраченный|может быть восстановлен|0}} [[Объект культурного наследия России|объект культурного наследия народов РФ]]')
else
firstword = '[[Объект культурного наследия России|Объект культурного наследия народов РФ]]'
end
if self.args['NumOnly'] then statuswordrender = '' else
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword end
end
if (Coredata.statusword=='') and (Coredata.statusfirstword~='') then
if not self.args['утрачен'] then
firstword = Coredata.statusfirstword..' [[Объект культурного наследия России|объект культурного наследия народов РФ]]'
end
else
if not ((Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~=''))))) then
renderdoc = ''
end
end
local regdot
if self.args['NumOnly'] then regdot = '' else regdot = '. ' end
if Coredata.regidword~='' then
if mw.ustring.sub(EGRNNum,1,1) == '{' then
regidrender =regdot..Coredata.regidword..' ({{abbr|ЕГРОКН|Единый государственный реестр объектов культурного наследия|0}})'
else
regidrender =regdot..'{{nobr|1='..Coredata.regidword..'}} ({{abbr|ЕГРОКН|Единый государственный реестр объектов культурного наследия|0}})' end else regidrender = '' end
local margin
margin='margin-left: 0.2em; '
local ArmstoRender
if self.args['NumOnly'] then firstword = '' end
if Coredata.wikivoyageword~='' then
if (self.args['NumOnly']) and (Coredata.regidword=='') then WVrender = '{{nobr|1='..Coredata.wikivoyageword..'}} (БД Викигида)' else WVrender = '. {{nobr|1='..Coredata.wikivoyageword..'}} (БД Викигида)' end else WVrender = '' end
local stringtoreturn = self.frame:preprocess((firstword or '[[Объект культурного наследия России|Объект культурного наследия народов РФ]]')..statuswordrender..renderdoc..regidrender.. WVrender..Coredata.regcatword)
return stringtoreturn
else
if self.args['утрачен'] then
firstword = self.frame:preprocess('{{abbr|Утраченный|Объект может быть восстановлен|0}} [[объект культурного наследия России]]')
else
firstword = self.frame:preprocess('[[Объект культурного наследия России]]')
end
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword
end
if (Coredata.statusword == '') and (Coredata.statusfirstword~='') then
if not self.args['утрачен'] then
firstword = Coredata.statusfirstword..' [[Объект культурного наследия России|объект культурного наследия народов РФ]]'
end
else
if not ((Coredata.wikivoyageword == '') and (not (Coredata.number and ((Coredata.number~=nil) and (Coredata.number~=''))))) then
renderdoc = ''
end
end
if Coredata.regidword~='' then
regidrender = self.frame:preprocess('<br><small>'..Coredata.regidword..' ({{abbr|ЕГРОКН|Единый государственный реестр объектов культурного наследия|0}})</small>') else regidrender = '' end
if Coredata.wikivoyageword~='' then
WVrender = '<br><small>'..Coredata.wikivoyageword..' (БД Викигида)</small>' else WVrender = '' end
if renderdoc ~= '' then renderdoc = '<br>'..renderdoc end
local toreturn = self.frame:preprocess('<span style="white-space: normal !important; font-weight: bold;">'..(firstword or '[[Объект культурного наследия России]]')..statuswordrender..'</span>'..statuswordrender..renderdoc..regidrender..WVrender..Coredata.regcatword)
return toreturn
end
end
end
function IRH:GetArms()
if self.args['мини'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Код-памятника'])..'|plain=true}}') or self:returnnotnil(self.args['Код-памятника'])
local EGRNNum
EGRNNum = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..self:returnnotnil(self.args['рег_N'] or self.args['1'])..'|plain=true}}') or self:returnnotnil(self.args['рег_N'] or self.args['1'])
local URLnum = self.args['id_страницы'] or self.args ['2']
local region = self.args['Регион'] or self.args['регион'] or self.args['3']
local status = self.args['Статус'] or self.args['статус'] or self.args['4']
local municipality = self.args['Муниципалитет'] or self.args['МО'] or self.args['Район'] or self.args['Город']
local doc = self.args['док'] or self.args['Док']
local renderdoc
renderdoc = ''
local div, divend
div, divend = '', ''
if doc and ((doc~=nil) and (doc~='')) then
renderdoc = ' '..'('..doc..')'
end
local statuswordrender
local regidrender
local WVrender
local firstword
local suppressrender
wordseparator = self.args['мини'] and ', ' or '<br>'
self.ucfirst = self.args['мини'] and true or false
local Coredata = self:coregen(EGRNNum, URLnum, region, status, WVwikidata, municipality)
return Coredata.statusarms
end
function IRH.new(frame, args)
if not args then
args = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Культурное наследие народов РФ', 'Template:Культурное наследие РФ', 'Template:Культурное наследие РФ 4', 'Template:Культурное наследие Крым','Template:Песочница/Seryo93/Культурное наследие Крым'}})
--return
end
local obj = {
frame = frame,
args = args
}
return setmetatable(obj, IRH)
end
local p = {}
function p.main(frame)
return IRH.new(frame):render()
end
function p.mainCatonly(frame)
return IRH.new(frame):rendercatWVonly()
end
function p.mainCoregen(frame,args)
return IRH.new(frame,args):renderTextOnly()
end
function p.mainArms(frame,args)
return IRH.new(frame):GetArms()
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