Этот модуль зависит от следующих других модулей: |
Реализует {{item infobox}}.
Вышеприведенная документация извлекается из Модуль:Item infobox/doc.
Редакторы могут экспериментировать в sandbox этого модуля и в testcases страницах.
Подстраницы этого модуля.
Редакторы могут экспериментировать в sandbox этого модуля и в testcases страницах.
Подстраницы этого модуля.
-------------------------------------------------------------------------------
--
-- Module:Item infobox
--
-- This module implements Template:Item infobox.
-------------------------------------------------------------------------------
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local m_util = require('Module:Util')
local m_cargo = require('Module:Cargo')
-- Should we use the sandbox version of our submodules?
local use_sandbox = m_util.misc.maybe_sandbox('Item infobox')
-- The cfg table contains all localisable strings and configuration, to make it
-- easier to port this module to another wiki.
local cfg = use_sandbox and mw.loadData('Module:Item infobox/config/sandbox') or mw.loadData('Module:Item infobox/config')
local i18n = cfg.i18n
-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------
local p = {}
--
-- Template:Item infobox
--
function p.query_item_infobox(frame)
--[[
Queries for an item infobox.
Examples
--------
=p.query_item_infobox{page='Map:Beach Map (Betrayal)'}
]]
local tpl_args = getArgs(frame, {
parentFirst = true
})
frame = m_util.misc.get_frame(frame)
local tables = {
'items',
'_pageData',
'maps',
'areas',
}
local fields = {
'items.html_extra',
'_pageData._pageNameOrRedirect',
'maps.area_id',
'areas.id',
'areas.infobox_html',
}
local query = {}
query.where = string.format(
'_pageData._pageName="%s"',
tpl_args.page
)
-- Join with _pageData in order to check for page redirect
query.join = 'items._pageName = _pageData._pageNameOrRedirect, items._pageID = maps._pageID, maps.area_id = areas.id'
local results = m_cargo.query(tables, fields, query)
if #results == 0 then
error(i18n.errors.no_results_found)
end
local out = {
results[1]['items.html_extra'],
results[1]['areas.infobox_html'],
}
return table.concat(out, '')
end
return p