Модуль:GeoInfobox
Жөндөмдүүлүгү жана милдеттери
renderId
VD идентификаторлору (GVR, GeoNames ж.б.), idArray идентификаторлордун жана анын массивиндеги тексттердин тизмеси менен кошоктолмо жаратат.
renderLine
Геокар+ негизиндеги карталарда, кутуча үчүн саптарды иштеп чыгарат. Аталышы жок аргументтер: маани, жеке маанилер үчүн белги, көптүк маанилер үчүн белги (эгерде төмөндөгү параметрди көрсөткөн учурда, маани көптүк мааниде текшерилет (бөлүүчү изделет — слеш) жана тиешелүү белги чагылдырылат), викилештирүү, постфикс (мисалы, өлчөө бирдиги).
findImage
Мисалы: {{#invoke:GeoInfobox|findImage|{{{Сүрөт|}}}}}
Макаланы толугу менен алып, тексттен ":Сүрөт" (Файл:Сүрөт) издейт, андагы "Сүрөт" — параметрлери толтурулган болсо. Мындай учурда сүрөт картада да, текстте да бар же жок экенин текшерет. Ошондой эле төмөнкү категорияны кошот: Категория:Геокардагы карточка: сүрөтү оңдоо. Ыкма Калып:Дарыя калыбында колдонулат.
Дагы караңыз
local p = {};
require('strict');
function p.renderId(frame)
local idArray = {
['p590'] = '[[GNIS]]',
['p884'] = '[[Мамлекеттик суулар реестри|МСР]]',
['p1397'] = '[[Географиялык аталыштардын мамлекеттик топтому|ГАМТ]]',
-- ['p1566'] = '[[GeoNames]]',
['p1886'] = '[[Global Volcanism Program|GVP]]',
['p4708'] = '{{comment|VOGRIPA|Volcano Global Risk Identification and Analysis Project}}'
}
local text = ''
for i, j in pairs(idArray) do
local tmp = frame:expandTemplate { title = 'Wikidata', args = { i } }
if tmp and tmp ~= '' then
text = text .. '<li>' .. frame:preprocess(j) .. ': ' .. tmp .. '</li>'
end
end
if text ~= '' then
return '<tr><td class="hlist" colspan="2"><hr><ul>' .. text .. '</ul></td></tr>'
end
end
function p.renderLine(frame)
local args = frame:getParent().args;
frame.args = frame:getParent().args;
local cat = ''
local prefix = {
['~'] = 'болжол менен',
['>'] = 'көбүрөөк',
['<'] = 'азыраак'
}
local before = ''
local ref = ''
local text = args[1] or '';
local label = args[2] or ''; -- жалгыз белги
local label2 = args[3] or ''; -- көптүк белги
local wikify = args[4] or '';
local after = args[5] or '';
if text == '-' then
return '';
end
if text ~= '' then
if label2 ~= '' then
if mw.ustring.match(text, "[^/]+/[^/]+") then
label = label2
end
if wikify == '1' then
frame.args['o'] = '[[%]]'
frame.args['nodis'] = '1'
end
local split = require('Module:String/split').split
frame.args[1] = text
text = split(frame)
else
if after ~= '' then
if mw.ustring.match(text, '\127') and not mw.ustring.match(text, 'templatestyles') then
text, ref = mw.ustring.match(text, '[^\127]+'), mw.ustring.match(text, '\127.+')
end
if not mw.ustring.match(text, '[-—×]') then
local tmp_text = mw.ustring.gsub(text, '[≈−, ]',
{ ['≈'] = '~',['−'] = '-',[','] = '.',[' '] = '' })
if mw.ustring.match(text, '^[≈~<>]%s*%d') and prefix[tmp_text:sub(1, 1)] then
before = prefix[tmp_text:sub(1, 1)] .. ' '
text = mw.ustring.gsub(text, '^[≈~<>]%s*', '')
elseif mw.ustring.match(text, '^[бдмо][еко][лно]?[ел]?[ео]?') then -- |болжол менен|көбүрөөк|азыраак
before = mw.ustring.match(text, '^[бдмо][еко][лно]?[ел]?[ео]?') .. ' '
text = mw.ustring.gsub(text, '^[бдмо][еко][лно]?[ел]?[ео]?%s*', '')
end
tmp_text = mw.ustring.gsub(tmp_text, '^[≈~<>бдмо][еко]?[лно]?[ел]?[ео]?%s*', '')
if tonumber(tmp_text) then
local lang = mw.language.getContentLanguage()
text = lang:formatNum(tonumber(tmp_text))
elseif mw.title.getCurrentTitle():inNamespace(0) then
cat = '[[Категория:Геокардагы карточка: оңдоо: сандык параметрлер]]'
end
end
end
if wikify == '1' then
text = '[[' .. text .. '|' .. mw.ustring.gsub(text, '%s?%(.*%)$', '') .. ']]'
end
text = before .. text .. ref .. ' ' .. after
end
end
if args['d'] and args['d'] ~= '' then
text = frame:expandTemplate { title = 'Wikidata', args = {
args['d'],
text,
separator = args['r'] or ''
} };
end
if text ~= '' then
return '<tr><th scope="row">' .. label .. '</th><td>' .. text .. '</td></tr>' .. cat;
end
return '';
end
function p.findImage(frame)
local page = mw.title.getCurrentTitle()
local txt, args = page:getContent(), frame.args
if args and args[1] and args[1] ~= '' then
if txt:match(':' .. args[1]) and mw.title.getCurrentTitle():inNamespace(0) then
return
'[[Категория:Геокардагы карточка: сүрөттү оңдоо]]'
end
end
end
return p;