Module:Objet patrimonial culturel de Russie
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
require('strict')
local IRH = {}
IRH.__index = IRH
IRH.config = require('Module:Objet patrimonial culturel de Russie/config')
IRH.Munconfig = nil-- lorsqu'il est vide, il ne devrait être requis que lors de la spécification d'un sujet
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 = 'Objet patrimonial culturel ' else cato = 'Objet patrimonial culturel de Russie ' end
if mw.title.new('Catégorie:'..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~='F' 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 -- nous n'en avons plus besoin
if table.contains(self.config.statussuppress,statusid) then return '' end
cat = 'Objet patrimonial culturel de Russie'
if self.args['perdu'] 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('Catégorie:' .. self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self:getregiondatas().regins[regid]).exists then
cat = self.config.statuscats[statusid][1]..' objet patrimonial culturel '..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('Catégorie:' .. self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self.Munconfig.munins[munid]).exists then
cat = self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self.Munconfig.munins[munid]
else
local checker
if regdisp==true then checker = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Catégorie:'..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 = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Catégorie:'..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=='Objet patrimonial culturel' then cat = cat..' Russie' 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 = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Catégorie:'..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=='Objet patrimonial culturel' then cat = cat..' Russie' 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 = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Catégorie:'..checker..self.Munconfig.munins[munid]).exists
if muncatexist then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
end
end
if cat=='Objet patrimonial culturel de Russie' then
if number or (voynumber and ((voynumber ~='') and (voynumber ~= nil))) then
cat = ''
end
end
return cat~='Objet patrimonial culturel' and (':Catégorie:'..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 -- nous n'en avons plus besoin
if table.contains(self.config.statussuppress,statusid) then return '' end
cat = 'Objet patrimonial culturel de Russie'
if self.args['perdu'] 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('Catégorie:' .. self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self:getregiondatas().regins[regid]).exists then
cat = self.config.statuscats[statusid][1]..' objet patrimonial culturel '..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('Catégorie:' .. cattolook).exists then
secondcat = ']][[Catégorie:'..cattolook
else secondcat = ''
end
if regido==true then
cat = cat..' '..self:getregiondatas().regins[regid]
else
if cat=='Objet patrimonial culturel' then cat=cat..' Russie' 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=='Objet patrimonial culturel' then cat = cat..' Russie' 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('Catégorie:' .. 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('Catégorie:' .. self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self.Munconfig.munins[munid]).exists then
cat = self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self.Munconfig.munins[munid]
else
local thirdcat
local checker
if regdisp==true then checker = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie ' end
local muncatexist = self.config.forceemptycategorization==true and true or mw.title.new('Catégorie:'..checker..self.Munconfig.munins[munid]).exists
if self:getregiondatas().regins[regid]~=nil then
if mw.title.new('Catégorie:' .. self.config.statuscats[statusid][1]..' objet patrimonial culturel '..self:getregiondatas().regins[regid]).exists then
if muncatexist then
thirdcat = ']][[Catégorie:'..checker..self.Munconfig.munins[munid]
else thirdcat = '' end
else
thirdcat = ''
if muncatexist then
if regdisp==true then
cat = mw.ustring.gsub(cat,' Objet patrimonial culturel '..self:getregiondatas().regins[regid],' Objet patrimonial culturel '..self.Munconfig.munins[munid])
else
cat = mw.ustring.gsub(cat,'Objet patrimonial culturel de Russie '..self:getregiondatas().regins[regid],'Objet patrimonial culturel de Russie '..self.Munconfig.munins[munid])
end
end
end
else
if muncatexist then
thirdcat = ']][[Catégorie:Objet patrimonial culturel de Russie '..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('Catégorie:' .. 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=='Objet patrimonial culturel' then cat = cat..' Russie' 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 = ' Objet patrimonial culturel ' else checker = 'Objet patrimonial culturel de Russie '
end
if self.config.forceemptycategorization==true or mw.title.new('Catégorie:'..checker..self.Munconfig.munins[munid]).exists then
cat = checker..self.Munconfig.munins[munid]
end
end
end
end
end
end
if cat=='Objet patrimonial culturel de Russie' 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) == 'VG' 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)=='VG' 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 = 'Modèle:Objet patrimonial culturel de Russie/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 = 'Modèle:Objet patrimonial culturel de Russie/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('Modèle:Objet patrimonial culturel de Russie/config/'..regid).exists then
MCSTRtest = require('Modèle:Objet patrimonial culturel de Russie/config/'..regid)
if (MCSTRtest~=nil) and (type(MCSTRtest)~='boolean') then
Munconfigstring ='Modèle:Objet patrimonial culturel de Russie/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['mini']),'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 = 'région №'
self.regwordtooltip = 'Numéro enregistrement au registre État unifié des objets du patrimoine culturel'
else
theregword = 'région №'
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['Code monument'])..'|title='..theobjword..' $1}}') or '[https://ru-monuments.toolforge.org/wikivoyage.php?id='..self:returnnotnil(self.args['Code monument'])..' '..theobjword..self:returnnotnil(self.args['Code monument'])..']'
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['Status'] or self.args['status'] 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['perdu'] then
if self:gencat(regid, statusid, number, wikivoyageid, self:genmunicipality(munplaceid or munid))~='' then
regcatword='[[Catégorie:'..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='[[Catégorie:'..tostring(self.config.statuscats[statusid][1])..' объекты культурного наследия России по алфавиту]]'
else
alphabetstatus='[[Catégorie:Objet patrimonial culturel de Russie'..tostring(self.config.statuscats[statusid][1])..' по алфавиту]]'
end
else
alphabetstatus='[[Catégorie:Objet patrimonial culturel de Russie по алфавиту]]'
end
regcatword=alphabetstatus..regcatword
--if not number then
--добавляем tracking category
--regcatword='[[Catégorie:Objet patrimonial culturel de Russie без 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..'[[Catégorie:'..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['mini'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata=self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['1'] or self.args['Code monument'])..'|plain=true}}')
local region = self.args['Région'] or self.args['région']
local status = self.args['Status'] or self.args['status']
local municipality = self.args['Municipalité'] or self.args['Okroug municipal'] or self.args['Raïon'] or self.args['Ville']
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['mini'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Code monument'])..'|plain=true}}') or self:returnnotnil(self.args['Code monument'])
local EGRNNum
local URLnum = self.args['id_pages'] or self.args ['2']
local region = self.args['Région'] or self.args['région'] or self.args['3']
local status = self.args['Status'] or self.args['status'] or self.args['4']
local municipality = self.args['Municipalité'] or self.args['Okroug municipal'] or self.args['Raïon'] or self.args['Ville']
local doc = self.args['doc'] or self.args['Doc']
local renderdoc
renderdoc = ''
local div, divend
div, divend = '', ''
self.micro = mw.ustring.find(self:returnnotnil(self.args['mini']),'micro',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['mini'] and ', ' or '<br>'
self.ucfirst = self.args['mini'] and true or false
local Coredata = self:coregen(EGRNNum, URLnum, region, status, WVwikidata, municipality)
local minidiv = mw.ustring.find(self:returnnotnil(self.args['mini']),'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['mini'] then
if (minidiv==true) then
div, divend = '<div>','</div>'
end
if self.args['perdu'] then
firstword = self.frame:preprocess('{{abbr|Perdu|peut être restauré|0}} [[Objet du patrimoine culturel de la Russie|'..(self.shortminiview==true and 'OPC' or 'objet patrimonial culturel Fédération de Russie')..']]')
else
firstword = '[[Objet du patrimoine culturel de la Russie|'..(self.shortminiview==true and 'OPC' or 'Objet patrimonial culturel Fédération de Russie')..']]'
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['perdu'] then
firstword = (self.shortminiview==true and mw.ustring.sub(Coredata.statusfirstword,1,(self.config.statshortnum[Coredata.statusid] or 3)) or Coredata.statusfirstword)..' [[Objet du patrimoine culturel de la Russie|objet patrimonial culturel Fédération de Russie]]'
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|EGROKN|Registre État unifié des objets du patrimoine culturel|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 = '[[Fichier:'..Coredata.statusarms..'|20px|link='..(Coredata.gencatlink or '')..'|Objet patrimonial culturel Fédération de Russie '..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 ' (Base de données Wikivoyage)' 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="Objet patrimonial culturel Fédération de Russie" style="'..margin..'"><small>'..(self.micro~=true and ((firstword or '[[Objet du patrimoine culturel de la Russie|'..(self.shortminiview==true and 'OPC' or 'Objet patrimonial culturel Fédération de Russie')..']]')..statuswordrender..renderdoc) or '')..regidrender.. WVrender..'</small></span>'..divend..Coredata.regcatword)
return stringtoreturn
else
if self.args['perdu'] then
firstword = self.frame:preprocess('{{abbr|Perdu|Objet peut être restauré|0}} [[objet patrimonial culturel de Russie]')
else
firstword = self.frame:preprocess('[[Objet du patrimoine culturel de la Russie]]')
end
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword
end
if (Coredata.statusword == '') and (Coredata.statusfirstword~='') then
if not self.args['perdu'] then
firstword = Coredata.statusfirstword..' [[Objet du patrimoine culturel de la Russie|objet patrimonial culturel Fédération de Russie]]'
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|EGROKN|Registre État unifié des objets du patrimoine culturel|0}})</small>') else regidrender = '' end
if Coredata.wikivoyageword~='' then
WVrender = '<br><small>'..Coredata.wikivoyageword..' (Base de données Wikivoyage)</small>' else WVrender = '' end
if renderdoc ~= '' then renderdoc = '<br>'..renderdoc end
local embwidth, embclass, embbordercss, cellspa
if not self.args['intégrer'] then
embclass = 'infobox'
embwidth = nil
embbordercss = nil
else
embclass = nil
embwidth = '100%'
embbordercss = '1px solid #a2a9b1'
if self.args['intégrer']=='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('[[Fichier:'..Coredata.statusarms..'|45px|link='..(Coredata.gencatlink or '')..'|Objet patrimonial culturel Fédération de Russie'..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 '[[Objet du patrimoine culturel de la Russie]]')..statuswordrender..'</span>'..renderdoc..regidrender..WVrender..Coredata.regcatword)
:done()
:done()
builder = builder:done()
return builder
end
end
end
function IRH:renderTextOnly()
if self.args['mini'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Code monument'])..'|plain=true}}') or self:returnnotnil(self.args['Code monument'])
local EGRNNum
EGRNNum = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..self:returnnotnil(self.args['région_N'] or self.args['1'])..'|plain=true}}') or self:returnnotnil(self.args['région_N'] or self.args['1'])
local URLnum = self.args['id_pages'] or self.args ['2']
local region = self.args['Région'] or self.args['région'] or self.args['3']
local status = self.args['Status'] or self.args['status'] or self.args['4']
local municipality = self.args['Municipalité'] or self.args['Okroug municipal'] or self.args['Raïon'] or self.args['Ville']
local doc = self.args['doc'] or self.args['Doc']
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['mini'] and ', ' or '<br>'
self.ucfirst = self.args['mini'] 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['mini'] then
if self.args['mini']=='div' then
div, divend = '<div>','</div>'
end
if self.args['perdu'] then
firstword = self.frame:preprocess('{{abbr|Perdu|peut être restauré|0}} [[Objet du patrimoine culturel de la Russie|objet patrimonial culturel Fédération de Russie]]')
else
firstword = '[[Objet du patrimoine culturel de la Russie|Objet patrimonial culturel Fédération de Russie]]'
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['perdu'] then
firstword = Coredata.statusfirstword..' [[Objet du patrimoine culturel de la Russie|objet patrimonial culturel Fédération de Russie]]'
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|EGROKN|Registre État unifié des objets du patrimoine culturel|0}})'
else
regidrender =regdot..'{{nobr|1='..Coredata.regidword..'}} ({{abbr|EGROKN|Registre État unifié des objets du patrimoine culturel|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..'}} (Base de données Wikivoyage)' else WVrender = '. {{nobr|1='..Coredata.wikivoyageword..'}} (Base de données Wikivoyage)' end else WVrender = '' end
local stringtoreturn = self.frame:preprocess((firstword or '[[Objet du patrimoine culturel de la Russie|Objet patrimonial culturel Fédération de Russie]]')..statuswordrender..renderdoc..regidrender.. WVrender..Coredata.regcatword)
return stringtoreturn
else
if self.args['perdu'] then
firstword = self.frame:preprocess('{{abbr|Perdu|Objet peut être restauré|0}} [[objet patrimonial culturel de Russie]')
else
firstword = self.frame:preprocess('[[Objet du patrimoine culturel de la Russie]]')
end
if Coredata.statusword == '' then statuswordrender = '' else statuswordrender = ' '..Coredata.statusword
end
if (Coredata.statusword == '') and (Coredata.statusfirstword~='') then
if not self.args['perdu'] then
firstword = Coredata.statusfirstword..' [[Objet du patrimoine culturel de la Russie|objet patrimonial culturel Fédération de Russie]]'
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|EGROKN|Registre État unifié des objets du patrimoine culturel|0}})</small>') else regidrender = '' end
if Coredata.wikivoyageword~='' then
WVrender = '<br><small>'..Coredata.wikivoyageword..' (Base de données Wikivoyage)</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 '[[Objet du patrimoine culturel de la Russie]]')..statuswordrender..'</span>'..statuswordrender..renderdoc..regidrender..WVrender..Coredata.regcatword)
return toreturn
end
end
end
function IRH:GetArms()
if self.args['mini'] then self.config.collapsiblenumbers=false end
local WVwikidata
WVwikidata = (self.config.disableWDlookup[2]~=true) and self.frame:preprocess('{{wikidata|p1483|'..self:returnnotnil(self.args['Code monument'])..'|plain=true}}') or self:returnnotnil(self.args['Code monument'])
local EGRNNum
EGRNNum = (self.config.disableWDlookup[1]~=true) and self.frame:preprocess('{{wikidata|P5381|'..self:returnnotnil(self.args['région_N'] or self.args['1'])..'|plain=true}}') or self:returnnotnil(self.args['région_N'] or self.args['1'])
local URLnum = self.args['id_pages'] or self.args ['2']
local region = self.args['Région'] or self.args['région'] or self.args['3']
local status = self.args['Status'] or self.args['status'] or self.args['4']
local municipality = self.args['Municipalité'] or self.args['Okroug municipal'] or self.args['Raïon'] or self.args['Ville']
local doc = self.args['doc'] or self.args['Doc']
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['mini'] and ', ' or '<br>'
self.ucfirst = self.args['mini'] 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 = {'Modèle:Objet patrimonial culturel de Russie', 'Template:Patrimoine culturel de Russie', 'Template:Patrimoine cuturel de Russie 4', 'Template:Patrimoine culturel de Crimée','Template:Brouillon/Seryo93/Patrimoine culturel de Crimée'}})
--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