„Modul:Infobox” változatai közötti eltérés
[ellenőrzött változat] | [ellenőrzött változat] |
Tartalom törölve Tartalom hozzáadva
koordináták közvetlenül a modul meghívásával, sablont kihagyva |
pozíciós térkép/koordináta: Wikidata-rangok figyelembe vétele, koordináta kiolvasása a székhely minősítőjéből, ha nincs külön állításként megadva |
||
120. sor: | 120. sor: | ||
end |
end |
||
return result |
return result |
||
end |
|||
local function getWikidataCoord(entityId) |
|||
local item = mw.wikibase.getEntity(entityId) |
|||
local P625 = item:getBestStatements('P625') |
|||
if #P625 > 0 then |
|||
⚫ | |||
⚫ | |||
return lat, long |
|||
⚫ | |||
for _, v in ipairs(item:getBestStatements('P159')) do |
|||
if v.qualifiers and v.qualifiers.P625 then |
|||
⚫ | |||
⚫ | |||
return lat, long |
|||
end |
|||
end |
|||
end |
|||
return nil, nil |
|||
end |
end |
||
196. sor: | 215. sor: | ||
end |
end |
||
else |
else |
||
mapArgs.lat, mapArgs.long = getWikidataCoord(args['wd-entity']) |
|||
if |
if not mapArgs.lat or not mapArgs.long then |
||
⚫ | |||
⚫ | |||
⚫ | |||
return nil |
return nil |
||
end |
end |
||
249. sor: | 265. sor: | ||
end |
end |
||
if not args[1] or not args[5] then |
if not args[1] or not args[5] then |
||
mapArgs.lat, mapArgs.long = getWikidataCoord(args['wd-entity']) |
|||
if |
if not mapArgs.lat or not mapArgs.long then |
||
⚫ | |||
⚫ | |||
else |
|||
return nil |
return nil |
||
end |
end |
A lap 2019. január 30., 15:09-kori változata
Infobox[mi ez?] • [dokumentáció: mutat, ] • [tesztek: létrehozás]
Függ az alábbi moduloktól: |
A megvalósított sablonok dokumentációját lásd a Sablon:Infobox lapon.
require"Modul:No globals"
local getArgs = require"Modul:Arguments".getArgs
local p = {}
p.row = function (args)
args = getArgs(args)
local val, label, group, undertag
val = args[1]
if not val then
return nil
end
if args[3] then
label = '[[' .. args[3] .. '|' .. args[2] .. ']]'
else
label = args[2]
end
group = args['csoportazonosító']
undertag = not (not args['címke alatt'])
local row = mw.html.create('tr')
if group then
row:addClass( 'csoport-' .. tostring(group) )
end
local labeltag = row:tag('td')
labeltag:addClass(undertag and 'cimkealatt' or 'cimke')
if not undertag then
labeltag:css('font-weight', 'bolder')
end
labeltag:wikitext(label)
labeltag:done()
local valtag = row:tag('td')
valtag:wikitext(val)
valtag:done()
return tostring(row)
end
p["ország"] = function (frame)
local args = getArgs(frame, { wrappers = "Sablon:Infobox/Ország" })
local cdata = require('Modul:Country data').main
if args[1] == "-" then
return nil
end
return p.row{
cdata{ [1] = args[1], ['size'] = args[4] },
'Ország'
}
end
p.image = function (filename, legend, property, entityId)
if filename == '-' then
return nil, nil
end
if (not filename) and property then
local item = mw.wikibase.getEntity(entityId)
if not item then
return nil, nil
end
local image = item:getBestStatements(string.upper(property))[1]
if image and image.mainsnak.snaktype == 'value' then
filename = image.mainsnak.datavalue.value
legend = nil
if image.qualifiers and image.qualifiers.P2096 then
for _, snak in ipairs(image.qualifiers.P2096) do
if snak.snaktype == 'value' then
if snak.datavalue.value.language == 'hu' then
legend = snak.datavalue.value.text
elseif snak.datavalue.value.language == 'en' and not legend then
legend = snak.datavalue.value.text
end
end
end
end
else
return nil, nil
end
end
return filename, legend
end
p["kép"] = function (frame)
local args = getArgs(frame, {wrappers = "Sablon:Infobox/Kép"})
local filename, legend = p.image(args[1], args[3], args["wd-property"], args["wd-entity"])
if not filename then
return nil
end
local filesize = args[2]
if not filesize then
local title = mw.title.new('Media:' .. filename)
if (
title and title.file.width and title.file.width < 250
and title.file.mimeType ~= 'image/svg' and title.file.mimeType ~= 'image/svg+xml'
) then
filesize = title.file.width
else
filesize = 250
end
filesize = tostring(filesize) .. 'px'
end
local link = "[[Fájl:" .. filename .. "|" .. filesize
if legend then
link = link .. "|" .. legend
end
link = link .. "]]"
local result = tostring(mw.html.create"tr"
:tag"td"
:attr("colspan", "2")
:css("text-align", "center")
:wikitext(link)
:allDone()
)
if legend then
result = result .. tostring(mw.html.create"tr"
:tag"td"
:attr("colspan", "2")
:css("text-align", "center")
:css("font-size", "92%")
:wikitext(legend)
:allDone()
)
end
return result
end
local function getWikidataCoord(entityId)
local item = mw.wikibase.getEntity(entityId)
local P625 = item:getBestStatements('P625')
if #P625 > 0 then
local lat = P625[1].mainsnak.datavalue.value.latitude
local long = P625[1].mainsnak.datavalue.value.longitude
return lat, long
else
for _, v in ipairs(item:getBestStatements('P159')) do
if v.qualifiers and v.qualifiers.P625 then
local lat = v.qualifiers.P625[1].datavalue.value.latitude
local long = v.qualifiers.P625[1].datavalue.value.longitude
return lat, long
end
end
end
return nil, nil
end
local function coordRow(coordinatesLink)
return '<tr><td colspan="2" style="text-align:center">' .. coordinatesLink .. '</td></tr>'
end
--[[
Helyi értékű paramétereket átalakítja szám szerinti paraméterekké.
Modul:Pozíciós térkép-ből is.
--]]
function p.coord(frame, args)
local coorArgs = {args[9], display = args.display, format = 'dms', with_pfunc = true}
if args[1] and args[5] then
local hemisphereMultipliers = {
longitude = { W = -1, w = -1, E = 1, e = 1, NY = -1, Ny = -1, ny = -1, K = 1, k = 1 },
latitude = { S = -1, s = -1, N = 1, n = 1, D = -1, d = -1, ['É'] = 1, ['é'] = 1 }
}
table.insert(coorArgs, 1, hemisphereMultipliers.latitude[args[4]] and args[4] or 'N')
table.insert(coorArgs, 2, hemisphereMultipliers.longitude[args[8]] and args[8] or 'E')
table.insert(coorArgs, 1, args[1])
table.insert(coorArgs, 3, args[5])
if args[2] and args[6] then
table.insert(coorArgs, 2, args[2])
table.insert(coorArgs, 5, args[6])
if args[3] and args[7] then
table.insert(coorArgs, 3, args[3])
table.insert(coorArgs, 7, args[7])
end
else
if not args[4] or not args[8] then
table.remove(coorArgs, 4)
table.remove(coorArgs, 2)
end
end
elseif args.lat and args.long then
table.insert(coorArgs, 1, args.lat)
table.insert(coorArgs, 2, args.long)
coorArgs.precision = 'wikidata'
else
return nil
end
return require( 'Modul:Coordinate' ).coord( nil, coorArgs )
end
p["pozíciós térkép"] = function (frame)
local args = getArgs(frame, {wrappers = "Sablon:Infobox/Pozíciós térkép"})
if args[4] == '-' or args[8] == '-' then
return nil
end
local mapArgs = {
args[1],
['felirat'] = "'''" .. (args[2] ~= '{{{név}}}' and args[2] or require'Modul:String'.simpletitle{args = {}}) .. "'''",
['keret'] = 'none',
['felirat pozíciója'] = args[3],
['jel'] = args.jel or 'Green pog.svg',
['felirat mérete'] = '100',
['méret'] = '248',
['igazítás'] = 'none',
['térképtípus'] = args['térképtípus'],
['meta'] = args.meta,
['jel mérete'] = args['jel mérete']
}
if args[4] and args[8] then
mapArgs['szélesség'] = args[7]
mapArgs['hosszúság'] = args[11]
mapArgs['szélességi fok'] = args[4]
mapArgs['hosszúsági fok'] = args[8]
if args[5] and args[9] then
mapArgs['szélességi ívperc'] = args[5]
mapArgs['hosszúsági ívperc'] = args[9]
if args[6] and args[10] then
mapArgs['szélességi ívmásodperc'] = args[6]
mapArgs['hosszúsági ívmásodperc'] = args[10]
end
end
else
mapArgs.lat, mapArgs.long = getWikidataCoord(args['wd-entity'])
if not mapArgs.lat or not mapArgs.long then
return nil
end
end
local result = {}
local trackWikidata = false
if not args[1] then
if not args['koordinátakategória nélkül'] then
table.insert(result, '[[Kategória:Koordináták térkép nélkül]]')
end
elseif args[1] ~= '-' then
local title = mw.title.new('Sablon:Pozíciós térkép ' .. args[1])
if title and title.exists then
local success, map = pcall(require'Modul:Pozíciós térkép'.many, frame, mapArgs)
if not success then
map = '<strong class="error">' .. map .. '</strong>[[Kategória:Hibásan használt pozícióstérkép-sablonok]]'
else
trackWikidata = true
end
table.insert(result, '<tr><td colspan="2" align="center">' .. map .. '</td></tr>\n')
else
table.insert(result, '[[Kategória:Pozíciós térképet hiányoló lapok]]')
end
end
if args['koordináta a térkép alatt'] then
table.insert(result, coordRow(p.coord(frame, {args[4], args[5], args[6], args[7],
args[8], args[9], args[10], args[11], args.meta, display = args['koordináta a cím alatt'] and 'inline,title',
lat = mapArgs.lat, long = mapArgs.long})))
trackWikidata = true
elseif args['koordináta a cím alatt'] then
table.insert(result, p.coord(frame, {args[4], args[5], args[6], args[7],
args[8], args[9], args[10], args[11], args.meta, display = 'title',
lat = mapArgs.lat, long = mapArgs.long}))
trackWikidata = true
end
if trackWikidata and mapArgs.lat then
table.insert(result, '[[Kategória:Wikidata koordinátákat használó lapok]]')
end
return table.concat(result)
end
p["koordináta"] = function (frame)
local args = getArgs(frame, {wrappers = "Sablon:Infobox/Koordináta"})
if args[1] == '-' or args[5] == '-' then
return nil
end
if not args[1] or not args[5] then
mapArgs.lat, mapArgs.long = getWikidataCoord(args['wd-entity'])
if not mapArgs.lat or not mapArgs.long then
return nil
end
end
return coordRow(p.coord(frame, args))
end
return p