Module:Render/Job

local model = require('Module:Data').model local cargo = require('Module:CargoUtil') local jobPageName = require('Module:Data/Extra/JobPageName') local linkUtils = require('Module:LinkUtils')

local p = {}

function p.icon(frame) local args = require('Module:Arguments').getArgs(frame, {       parentFirst = true,        wrappers = {            'Template:Job/Icon',        }    }) return p._icon(args) end

function p._icon(args) local iname = args[1] local jobpage = cargo.query{ tables = 'Pages', fields = 'iname', where = 'type = "Job" AND _pageName = "' .. iname .. '" OR iname = "' .. iname .. '"', }[1] if jobpage then iname = jobpage.iname end local data = args.data or model.query('Job','_pageName,server,ac2d,mdl',{where='iname="'..iname..'"'})[1] or {}

local jobIconDir = (args['size'] == 'large' and 'JobIconM,') or 'JobIcon,'

local icon = 'ItemIcon,IT_UNKNOWN' if data.ac2d and data.ac2d ~= '' then icon = jobIconDir..data.ac2d elseif data.mdl and data.mdl ~= '' then icon = jobIconDir..data.mdl end

local name = model.getLoc(data._pageName, 'name') local link = nil if args['link'] ~= 'none' then if data._pageName ~= nil then link = (cargo.query{tables='Pages',fields='_pageName',where='type="Job" and iname="'..iname..'"'}[1] or {_pageName = jobPageName[iname] or linkUtils.wikiSafeName(name)})._pageName or nil end end

local displayName = args['name'] ~= 'none' and (name and name ~=  and (link and ..name..'') or name) or nil local size = (args['size'] == 'large' and 128) or (args['size'] == 'small' and 32) or 64

local rarity = 0

-- Generate the image local imageOutput = {} table.insert(imageOutput, '') -- Generate the container around the image local output = {} if args['size'] == 'small' then table.insert(output, table.concat(imageOutput)) if displayName then table.insert(output, ' '..displayName) end else local iconBackground = 'x-'..rarity..' y-2' local classList = args['classes'] ~= nil and ' '..args['classes'] or '' if args['float'] ~= nil and args['float'] ~= '' then classList = classList..' float'..args['float'] end table.insert(output, ' '.."\n") table.insert(output, ' ') table.insert(output, table.concat(imageOutput)) table.insert(output, ' ') if displayName then table.insert(output, "\n "..displayName..' ') end table.insert(output, "\n ") end return table.concat(output) end

-- Non cargo version function p._icon2(args) local data = args.data or {} local iname = data.iname if not iname then return end

local jobIconDir = args.size == 'large' and 'JobIconM,' or 'JobIcon,'

local icon = 'ItemIcon,IT_UNKNOWN' if data.icon then icon = jobIconDir..data.icon end

local name = data.name local link = nil if args['link'] ~= 'none' then link = data._pageName or linkUtils.wikiSafeName(name) or nil end

local displayName = args.name ~= 'none' and (name and name ~=  and (link and ..name..'') or name) or nil local size = (args.size == 'large' and 128) or (args.size == 'small' and 32) or 64 local rarity = 0

-- Generate the image local imageOutput = {} table.insert(imageOutput, '') -- Generate the container around the image local output = {} if args['size'] == 'small' then table.insert(output, table.concat(imageOutput)) if displayName then table.insert(output, ' '..displayName) end else local iconBackground = 'x-'..rarity..' y-2' local classList = args['classes'] ~= nil and ' '..args['classes'] or '' if args['float'] ~= nil and args.float ~= '' then classList = classList..' float'..args['float'] end table.insert(output, ' '.."\n") table.insert(output, ' ') table.insert(output, table.concat(imageOutput)) table.insert(output, ' ') if displayName then table.insert(output, "\n "..displayName..' ') end table.insert(output, "\n ") end return table.concat(output) end

function p.pageName(frame) local args = require('Module:Arguments').getArgs(frame, {       parentFirst = true,        wrappers = {            'Template:Job/Name',        }    }) return p._pageName(args) end

function p._pageName(args) local iname = args[1] local data = args.data or model.query('Job','_pageName,server',{where='iname="'..iname..'"'})[1] or {}

local name = model.getLoc(data._pageName, 'name') local link = nil if data._pageName ~= nil then link = (cargo.query{tables='Pages',fields='_pageName',where='type="Job" and iname="'..iname..'"'}[1] or {_pageName = jobPageName[iname] or linkUtils.wikiSafeName(name)})._pageName or nil end

local displayName = (name and name ~=  and (link and ..name..'') or name) or iname return displayName end

return p