@DeletedUser41170185 (talk | contribs) (mfilelink) |
@DeletedUser41170185 (talk | contribs) mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
local cargo = mw.ext.cargo |
local cargo = mw.ext.cargo |
||
+ | local fileExists = require('Module:FileExists') |
||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local mFileLink = require('Module:File link')._main |
local mFileLink = require('Module:File link')._main |
||
Line 33: | Line 34: | ||
icon = cargo_output['icon'] |
icon = cargo_output['icon'] |
||
else |
else |
||
− | + | if fileExists('File:Team icon ' .. args[1] .. '.png') then |
|
− | if success == true and result == true then |
||
icon = 'Team icon ' .. args[1] .. '.png' |
icon = 'Team icon ' .. args[1] .. '.png' |
||
end |
end |
Latest revision as of 20:36, 17 May 2018
▶️
Planeshift.
The documentation for this module can be found at Template:Team icon.
You may be forwarded to another wiki language, in case a translation is not available.
Dependencies
local p = {}
local cargo = mw.ext.cargo
local fileExists = require('Module:FileExists')
local getArgs = require('Module:Arguments').getArgs
local mFileLink = require('Module:File link')._main
function p.main(frame)
local args = getArgs(frame, {
wrappers = {
'Template:Team icon'
}
})
return p._main(args)
end
function p._main(args)
assert(args[1], 'Check your input')
local name = args[1]
local size = args[2] or '40px'
local icon = 'Team icon Default.png'
-- Attempt to get the data through Cargo.
-- _pageName matches are prioritized over matches in the names table.
-- If multiple teams have the same name in their names table the first one is used.
local cargo_output = cargo.query( 'professional_teams', 'icon, name', { where='_pageName="' .. args[1] .. '"', groupBy='_pageID' } )[1]
if not cargo_output then
cargo_output = cargo.query( 'professional_teams', 'icon, name', { where='names HOLDS "' .. args[1] .. '"', groupBy='_pageID' } )[1]
end
if cargo_output and cargo_output['icon'] ~= '' then
name = cargo_output['name']
icon = cargo_output['icon']
else
if fileExists('File:Team icon ' .. args[1] .. '.png') then
icon = 'Team icon ' .. args[1] .. '.png'
end
end
return mFileLink{
file = icon,
size = size,
link = args[1],
alt = name
}
end
return p