La documentación para este módulo puede ser creada en Módulo:Ilink/doc
local p = {}
local cargo = mw.ext.cargo
function p.Main( frame )
local text = ""
local icontext = ""
local separator = ""
local linktext = ""
local needicon = true
local needlink = true
local iconsize = "18px"
if frame.args[3] ~= nil then
for token in string.gmatch(frame.args[3], "([^;]+);?") do
if token == "option=notext" then
needlink = false
elseif token == "option=noicon" then
needicon = false
end
end
end
local innertext = frame.args[1]
if frame.args[2] ~= "" and frame.args[2] ~= nil then
innertext = frame.args[2]
end
if needicon then
local tables = 'Items'
local 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 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:" or "Archivo:" then
r.Image = "File:" .. r.Image
end
image = "[["..r.Image.."|"..iconsize.."|text-bottom|link="..r._pageName.."]]"
if string.sub(r.Image,1,5) == "Archivo:Archivo:" then
r.Image = "Archivo:" .. r.Image
end
image = "[["..r.Image.."|"..iconsize.."|text-bottom|link="..r._pageName.."]]"
end
icontext = '<span class="'..class..t..'" style="border:1px solid #D3D3D3">'..image..'</span>'
end
end
if needlink then
if needicon then
separator = " "
end
linktext = '[['..frame.args[1]..'|<span class="itemlink ajaxttlink">'..innertext..'</span>]]'
end
text = icontext .. separator .. linktext
return text
end
return p