Documentation for this module may be created at Module:Ilink/doc
local p = {}
local cargo = mw.ext.cargo
function p.Main( frame )
local text = ""
tables = 'Items'
fields = 'Item_type,Type,Image,_pageName'
local args = {
where = '_pageName = "' .. frame.args[1] .. '"',
groupBy = '_pageName',
limit = 1,
}
local result = cargo.query( tables, fields, args )
local r = result[1]
if r == nil then
local innertext = frame.args[1]
if frame.args[2] ~= "" then
innertext = frame.args[2]
end
text = '[['..frame.args[1]..'|<span class="itemlink ajaxttlink">'..innertext..'</span>]]'
else
local class = ""
if r.Item_type == "Resource" then
class = "resource-"
end
local t = "technology"
if r.Type ~= "" then
t = string.gsub(string.lower(r.Type),' ','')
end
local image = ""
if r.Image ~= "" then
if string.sub(r.Image,1,5) ~= "File:" then
r.Image = "File:" .. r.Image
end
image = "[["..r.Image.."|18px|text-bottom|link="..r._pageName.."]]"
end
local innertext = frame.args[1]
if frame.args[2] ~= "" then
innertext = frame.args[2]
end
text = '<span class="'..class..t..'" style="border:1px solid #D3D3D3">'..image..'</span> [['..frame.args[1]..'|<span class="itemlink ajaxttlink">'..innertext..'</span>]]'
end
return text
end
return p