Для документации этого модуля может быть создана страница Модуль:Monument uz/doc

local p = {}

function p.monument(frame)

  local pArgs = frame:getParent().args
  local lang = pArgs['lang'] or 'ru' 
  local country = pArgs['country']
  local llanguage = 'uz'
  local campaign = 'wlm-uz'
  local noupload = 'yes'
  local dcat = ''

  local background_color = "#F8F8F8;"
  local mwl = mw.language.new( lang )
  local sort = pArgs['sort'] or 'no'
  local sortlevel = tonumber(pArgs['sortlevel']) or 1
  local sections = pArgs['sections'] or ''
   
  local wdids = pArgs['wdid']
  wdids = mw.text.split( wdids, ",", true)
  
  values = {}

  for i, wdid in ipairs(wdids) do
    values[i] = {}
	values[i]['wdid'] = wdid
    values[i]['name'] = mw.wikibase.getLabelByLang(wdid, lang) or mw.wikibase.getLabelByLang(wdid, llanguage) or ''
    values[i]['wiki'] = mw.wikibase.getSitelink(wdid, lang .. 'wiki') or ''
    values[i]['image'] = mw.wikibase.getBestStatements(wdid, 'P18')
    values[i]['image'] = (values[i]['image'][1] and values[i]['image'][1]['mainsnak']['datavalue']['value'])
    values[i]['commonscat'] = mw.wikibase.getBestStatements(wdid, 'P373')
    values[i]['commonscat'] = (values[i]['commonscat'][1] and values[i]['commonscat'][1]['mainsnak']['datavalue']['value']) or '' 
    local coords = mw.wikibase.getBestStatements(wdid, 'P625')
    values[i]['lat'] = (coords[1] and coords[1]['mainsnak']['datavalue']['value'].latitude) or ''
    values[i]['long'] = (coords[1] and coords[1]['mainsnak']['datavalue']['value'].longitude) or ''
    local p17 = mw.wikibase.getBestStatements(wdid, 'P17')
    p17 = (p17[1] and p17[1]['mainsnak']['datavalue']['value']['id']) or ''
    values[i]['municipality'] = mw.wikibase.getBestStatements(wdid, 'P131')
    values[i]['municipality'] = (values[i]['municipality'][1] and mw.wikibase.getLabelByLang(values[i]['municipality'][1]['mainsnak']['datavalue']['value']['id'], lang)) or ''
    values[i]['first_level'] = values[i]['municipality']
    values[i]['munlevels'] = values[i]['municipality']
    if values[i]['municipality'] ~= '' then
      local x = mw.wikibase.getBestStatements(wdid, 'P131')
      x = mw.wikibase.getBestStatements(x[1]['mainsnak']['datavalue']['value']['id'], 'P131')
      while x and next(x) and x[1]['mainsnak']['datavalue']['value']['id'] ~= p17 do
	    values[i]['first_level'] = mw.wikibase.getLabelByLang(x[1]['mainsnak']['datavalue']['value']['id'], lang) or ''
        values[i]['municipality'] =  values[i]['first_level'] .. ", " .. values[i]['municipality']
        values[i]['munlevels'] =  values[i]['first_level'] .. "#%" .. values[i]['munlevels']
        x = mw.wikibase.getBestStatements(x[1]['mainsnak']['datavalue']['value']['id'], 'P131')
      end
      values[i]['munlevels'] = mw.text.split(values[i]['munlevels'], "#%", true)
    end
	local p1435 = mw.wikibase.getBestStatements(wdid, 'P1435')
	values[i]['unesco'] = ''
	values[i]['ramsar'] = ''
	for k, v in ipairs(p1435) do
	    local x = v.mainsnak.datavalue.value.id
	  	if x == 'Q19683138' then
		  values[i]['ramsar'] = mw.wikibase.getLabelByLang(x, lang) or ''
		end
		if x == 'Q9259' or x == 'Q43113623' or x == 'Q1459900' then
		  values[i]['unesco'] = mw.wikibase.getLabelByLang(x, lang) or ''
		  if x == 'Q43113623' and v['qualifiers']['P361'] then
		    values[i]['unesco'] = values[i]['unesco'] .. ' «' .. (mw.wikibase.getLabelByLang(v['qualifiers']['P361'][1]['datavalue']['value']['id'], lang) or '') .. '»'
		  end 
		end
	end
    local p2186 = mw.wikibase.getBestStatements(wdid, 'P2186')
    values[i]['id'] = p2186[1]['mainsnak']['datavalue']['value']
    local p2795 = mw.wikibase.getBestStatements(wdid, 'P2795')
    values[i]['address'] = p2795[1]['mainsnak']['datavalue']['value']['text'] or ''

  end

  local t = ''

  local csection = ''
  if sort and sort == "yes" then
    function comp(a, b)
	  if (a.munlevels[sortlevel] or '') < (b.munlevels[sortlevel] or '') or ((a.munlevels[sortlevel] or '') == (b.munlevels[sortlevel] or '') and (b.address or '') > (a.address or '')) then
	    return true
	  else
	    return false
	  end
	end
    table.sort( values, comp )
  end

local layout = require( "Модуль:Monument/layout" )

  for i, m in ipairs(values) do
   if sections and sections == 'yes' and (m.munlevels[sortlevel] or '') ~= csection then
      t = t .. "\n== " .. (m.munlevels[sortlevel] or '') .. " ==\n"
	  csection = (m.munlevels[sortlevel] or '')
	end
    t = t .. layout.monument_header(m.id, "", m.image, "", background_color)
    t = t .. layout.monument_title(m.name, "")
    t = t .. layout.makelabel("Адрес", m.address, "<br>") 
    t = t .. layout.makelabel("Номер объекта", '<span style="font-size:93%">' .. m.id .. "</span>", "&nbsp;&nbsp;&nbsp;&nbsp;")
    local links = ''
    if m.wiki and m.wiki ~= '' then
      links = links .. layout.wikipedialink(lang, m.wiki, "Статья в Википедии")
    end
    if m.commonscat and m.commonscat ~= '' then
      links = links .. layout.commonslink(m.commonscat, "Категория на Викискладе")
    end
    links = links .. layout.wikidatalink(m.wdid, "Элемент Викиданных")
    t = t .. layout.makelabel("Ссылки", links, "<br>") 
    t = t .. layout.makelabel("Описание", "", "<br>") 
    t = t .. layout.uploadlink(campaign, "Загрузить&nbsp;фото", m.id, "", m.name .. ": " .. m.municipality .. ", " .. m.address, m.commonscat)
  end
  
  return t
end

return p;