Участник:Lzhl/Модуль:Monument
local p = {}
function p.monument_documents(frame)
local fdocs = require("Module:Monument/federal documents") -- Основные документы федерального уровня со страницы Модуль:Monument/federal documents
local pArgs = frame:getParent().args
local dregion = pArgs["region"]local t = '
- ' .. dt .. '
'
local attr = require("Module:Monument/attribution")
if attr[dregion] then
t = t .. [[
-- Изображение local imagelink = '

'
if image and image ~= then
imagelink = '
'
end t = t .. '\n| width="160px" | ' .. imagelink
-- Цвет карточки
local background_color = local isofficial = 1
if knid and knid ~= then
if tonumber(knid) % 100000000 >= 40000000 and tonumber(knid) % 100000000 <= 49999999 then
isofficial = 0
if complex and complex ~= then
if complex == knid then
background_color = "#cdeefe;"
else
background_color = "#ebf5f9;"
end
else
background_color = "#f8f8ed;"
end
if m_type == 'settlement' then
background_color = "#CDEEFE;"
end
else
if complex and complex ~= then
if complex == knid then
background_color = "#BAFFC1;"
else
background_color = "#E1FFE4;"
end
else
background_color = "#F8F8F8;"
end
if m_type == 'settlement' then
background_color = "#BAFFC1;"
end
end
end
t = t .. '\n| style=" background-color:' .. background_color .. ' padding-left:10px;" valign="middle" | '-- Архитектурный стиль
if style and style ~= then
t = t .. '
elseif style == 'модерн' or style == 'Модерн' then
t = t.. 'модерна">М'
else
t = t .. '">'
end
t = t .. ''
end
-- Иконка памятника
t = t .. frame:expandTemplate{ title = 'Якорь', args = { knid } }
if m_type == 'architecture' then
t = t .. "
"
elseif m_type == 'history' then
t = t .. "
"
elseif m_type == 'archeology' then
t = t .. "
"
elseif m_type == 'monument' then
t = t .. "
"
elseif m_type == 'settlement' then
t = t .. "
"
end-- Название
if unesco and unesco ~= then t = t .. "" end if knid == complex then t = t .. '
' end t = t .. '' if wikivoyage and wikivoyage ~= then t = t .. '
' .. name .. '' else t = t .. name end if alt and alt ~= then t = t .. ' / ' .. alt end t = t .. '
'
-- Адрес
t = t .. "Адрес: " local addressprecomma = ; if municipality and municipality ~= then t = t .. "" .. municipality .. "" addressprecomma = ', ' end if munid and munid ~= then t = t .. '' end if block and block ~= then t = t .. ', квартал ' .. block end if address and address ~= then t = t .. addressprecomma .. address end t = t .. '
'
-- Номер
t = t .. "Номер объекта: " .. '' .. knid
if not knid or knid == then
t = t .. 'Не указан'
end
if knid_new and knid_new ~= then
t = t .. ' / .. knid_new .. ' ' .. knid_new .. ''
end
if uid and uid ~= then
t = t .. " / " .. uid .. ''
end
t = t .. ' '-- Ссылки (пробелы между ними???)
t = t .. " Ссылки: " if lat and long and lat~= and long ~= then t = t .. '' if precise ~= 'yes' then t = t .. '!' end end if wiki and wiki ~= then t = t .. '
' end if commonscat and commonscat ~= then t = t .. '
' end if wdid and wdid ~= then t = t .. '
' end if sobory and sobory ~= then t = t .. '
' end if temples and temples ~= then t = t .. '
' end if link and link ~= then t = t .. '
' end if linkextra and linkextra ~= then t = t .. '
' end t = t .. ' галерея' if mw.title.new('Passport_' .. knid .. '.pdf', 'File').exists == true then t = t .. ", паспорт объекта" end t = t .. "
"
-- Год, автор
t = t .. "Описание: "
if year and year ~= then
t = t .. year
if author and author ~= then
t = t .. ", " .. author .. "."
end
t = t .. " "
elseif author and author ~= then
t = t .. author .. ". "
end-- Тип памятника и категория охраны
typetext = {architecture1 = "Памятник архитектуры",
history1 = "Памятник истории",
archeology1 = "Памятник археологии",
monument1 = "Памятник монументального искусства",
settlement1 = "Историческое поселение",
architecture0 = "Обладает признаками памятника архитектуры, не охраняется государством",
history0 = "Обладает признаками памятника истории, не охраняется государством",
archeology0 = "Обладает признаками памятника археологии, не охраняется государством",
monument0 = "Обладает признаками памятника монументального искусства, не охраняется государством",
settlement0 = "Обладает признаками исторического поселения, не охраняется государством"}
t = t .. (typetext[(m_type or ) .. tostring(isofficial)] or )
if protection == "Ф" then
t = t .. " федерального значения."
elseif protection == "Р" then
t = t .. " регионального значения."
elseif protection == "М" then
t = t .. " местного значения."
elseif protection == "В" then
t = t .. ", выявленный."
else
t = t .. "."
end-- Документы, статус, описание
if document and document ~= then
t = t .. frame:extensionTag{name = 'ref', , args = {name = document}}
end
if document2 and document2 ~= then
t = t .. frame:extensionTag{name = 'ref', , args = {name = document2}}
end
if status == "destroyed" then
t = t .. " Утраченный."
end
if dismissed and dismissed ~= "" then
t = t .. " Снят с охраны." .. frame:extensionTag{name = 'ref', , args = {name = dismissed}}
end
if unesco and unesco ~= then
local unesco_title =
if string.sub(unesco, 1, 1) == "Q" then
unesco_title = mw.wikibase.getEntityObject(unesco).sitelinks['ruwiki'].title
else
local unesco_list = require("Module:Monument/unesco")
unesco_title = unesco_list.unesco(unesco)
end
t = t .. " Входит в состав объекта Всемирного наследия ЮНЕСКО «" .. unesco_title .. "»."
end
if description and description ~= "" then
if mw.ustring.sub(description, -1) ~= '.' then
description = description .. '.'
end
t = t .. " " .. description
end-- Служебные категории
if mw.title.getCurrentTitle().namespace == 0 then
if pArgs["doc"] and pArgs["doc"] ~= then
t = t .. ''
end
if not knid or knid == then
t = t .. ''
end
end-- Ссылка на загрузку
if noupload ~= 'yes' then
t = t .. '\n| class="plainlinks" style="width:10%; text-align:center; vertical-align:middle; background-color:#FFFACD; padding:0 1em" '
local campaign = "wlm-ru"
if region == "ru-km" or region == "ru-sev" then
campaign = "wlm-crimea"
end
t = t .. "| [//commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=" .. mw.uri.encode(campaign, "PATH")
t = t .. &id= .. mw.uri.encode(knid or , "PATH")
t = t .. &id2= .. mw.uri.encode(uid or , "PATH") local upload_desc = (mw.ustring.gsub(name, '"', ) or ) .. ": "
if address and address ~= then
upload_desc = upload_desc .. address .. ", "
end
if municipality and municipality ~= and (municipality or ) ~= (district or ) then
upload_desc = upload_desc .. municipality .. ", "
end
if district and district ~= then
upload_desc = upload_desc .. district .. ", "
end
upload_desc = upload_desc .. (p.region_name(region) or )
t = t .. &description= .. mw.uri.encode(upload_desc, "PATH")
if not commonscat or commonscat == then
local ccat = mw.loadData("Module:Monument/commonscat")
if ccat[region] then
commonscat = ccat[region][(district or ) .. '_' .. (municipality or )] or ccat[region][district] or ccat[region]["default"]
end
end
t = t .. &categories= .. mw.uri.encode(commonscat or , "PATH")
t = t .. '&uselang=ru ]'
endt = t .. "\n|}
"
return t
end
-- Названия региона по его коду
function p.region_name(x)
local regions = {["ru-ad"] = "Адыгея",["ru-ba"] = "Башкортостан" ,["ru-bu"] = "Бурятия" ,["ru-al"] = "Алтай" ,["ru-da"] = "Дагестан" ,["ru-in"] = "Ингушетия" ,["ru-kb"] = "Кабардино-Балкария" ,["ru-kl"] = "Калмыкия" ,["ru-kc"] = "Карачаево-Черкесия" ,["ru-krl"] = "Карелия" ,["ru-ko"] = "Республика Коми" ,["ru-me"] = "Марий Эл" ,["ru-mo"] = "Мордовия" ,["ru-sa"] = "Якутия (Саха)" ,["ru-se"] = "Северная Осетия" ,["ru-ta"] = "Татарстан" ,["ru-ty"] = "Тува" ,["ru-ud"] = "Удмуртия" ,["ru-kk"] = "Хакасия" ,["ru-ce"] = "Чеченская республика" ,["ru-chv"] = "Чувашия" ,["ru-alt"] = "Алтайский край" ,["ru-kda"] = "Краснодарский край" ,["ru-kya"] = "Красноярский край" ,["ru-pri"] = "Приморский край" ,["ru-sta"] = "Ставропольский край" ,["ru-kha"] = "Хабаровский край" ,["ru-amu"] = "Амурская область" ,["ru-ark"] = "Архангельская область" ,["ru-ast"] = "Астраханская область" ,["ru-bel"] = "Белгородская область" ,["ru-bry"] = "Брянская область" ,["ru-vla"] = "Владимирская область" ,["ru-vgg"] = "Волгоградская область" ,["ru-vol"] = "Вологодская область" ,["ru-vor"] = "Воронежская область" ,["ru-iva"] = "Ивановская область" ,["ru-irk"] = "Иркутская область" ,["ru-kal"] = "Калининградская область" ,["ru-klu"] = "Калужская область" ,["ru-kam"] = "Камчатский край" ,["ru-kem"] = "Кемеровская область" ,["ru-kir"] = "Кировская область" ,["ru-kos"] = "Костромская область" ,["ru-kgn"] = "Курганская область" ,["ru-krs"] = "Курская область" ,["ru-len"] = "Ленинградская область" ,["ru-lip"] = "Липецкая область" ,["ru-mag"] = "Магаданская область" ,["ru-mos"] = "Московская область" ,["ru-mur"] = "Мурманская область" ,["ru-niz"] = "Нижегородская область" ,["ru-ngr"] = "Новгородская область" ,["ru-nvs"] = "Новосибирская область" ,["ru-oms"] = "Омская область" ,["ru-ore"] = "Оренбургская область" ,["ru-orl"] = "Орловская область" ,["ru-pnz"] = "Пензенская область" ,["ru-per"] = "Пермский край" ,["ru-psk"] = "Псковская область" ,["ru-ros"] = "Ростовская область" ,["ru-rya"] = "Рязанская область" ,["ru-sam"] = "Самарская область" ,["ru-sar"] = "Саратовская область" ,["ru-sak"] = "Сахалинская область" ,["ru-sve"] = "Свердловская область" ,["ru-smo"] = "Смоленская область" ,["ru-tam"] = "Тамбовская область" ,["ru-tve"] = "Тверская область" ,["ru-tom"] = "Томская область" ,["ru-tul"] = "Тульская область" ,["ru-tyu"] = "Тюменская область" ,["ru-uly"] = "Ульяновская область" ,["ru-che"] = "Челябинская область" ,["ru-zab"] = "Забайкальский край" ,["ru-yar"] = "Ярославская область" ,["ru-mow"] = "Москва" ,["ru-spb"] = "Санкт-Петербург" ,["ru-jew"] = "Еврейская автономная область" ,["ru-km"] = "Крым" ,["ru-nen"] = "Ненецкий автономный округ" ,["ru-khm"] = "Ханты-Мансийский автономный округ" ,["ru-chu"] = "Чукотский автономный округ" ,["ru-yam"] = "Ямало-Ненецкий автономный округ" ,["ru-sev"] = "Севастополь"}
return regions[x] or end
-- Возможность вывода полного списка категорий из Monument/commonscat как таблицы function p.commonscatdistricts(frame)
t = '
' local ccat = mw.loadData("Module:Monument/commonscat") for key, val in pairs(ccat) do for k1, v1 in pairs(val) do t = t .. '' end end t = t .. '
| ' .. key .. ' | ' .. k1 .. ' | ' .. v1 .. ' |
'
return t end
-- Возможность вывода полного списка категорий из Monument/commonscat в формате json function p.commonscatjson(frame) local ccat = mw.loadData("Module:Monument/commonscat") t = mw.text.jsonEncode(ccat) return t end
return p;