FANDOM


 
local p = {}
 
local type_img_data = mw.loadData( 'Module:Inlinegfx/img_link_data.json' ) -- load json
local getArgs = require('Module:Arguments').getArgs
local strlower = string.lower -- Convert to lower case
 
-- Get data from json page given main type name and piece name
function getInlineInfo(inline_type, inline_piece)
    inline_type = strlower(inline_type)
 
    local inline_DB = mw.loadData("Module:Inlinegfx/img_link_data.json")
    local inline_chunk = inline_DB[inline_type]
 
    if inline_chunk and inline_DB[inline_type][inline_piece] then
       return inline_DB[inline_type][inline_piece]
    end
end
 
function p.Inlinegfx(frame) -- Implements {{Inlinegfx}}
	local args = getArgs(frame, {
		trim = false,
		removeBlanks = false
		})
	local nosort = false
 
	if args["nosort"] then
        nosort = true
    end
 
	return p._Inlinegfx(args, nosort)
end
 
function p._Inlinegfx( args, hidesort )
	local sort_tpl = ' '
	local img_type = args['type'] -- use type param for type
	if args['type'] == nil then -- use param 1, if no type=
	    img_type = args[1]
	elseif args[1] == nil then -- blank type if no param 1
	    img_type = ''
	end
	if img_type ~= nil then -- if not nil, make lowercase
		img_type = string.lower(img_type)
    end
	local img_filename = 'Inv_misc_questionmark.png'
	local img_wikitext = '[[File:' .. img_filename .. '|18px|link=]]'
	local img_size = nil
	local img_link = 'Warcraft universe'
 
	-- Use new img_type, if alias found
	if img_type ~= nil and getInlineInfo(img_type, "alias") ~= nil then
		img_type = getInlineInfo(img_type, "alias")
	end
 
	-- Get image size change if it exists
	if img_type ~= nil and getInlineInfo(img_type, "size") ~= nil then
	    img_size = getInlineInfo(img_type, "size")
	end
 
	-- Get link for image
	if img_type ~= nil and getInlineInfo(img_type, "link") ~= nil then
	    img_link = getInlineInfo(img_type, "link")
	end
 
	if args['size'] ~= nil then -- use size= for img_size, if passed
		img_size = args['size']
	end
 
    -- Get image filename and build image wikitext
	if img_type ~= nil and getInlineInfo(img_type, "img") ~= nil then
	    	img_filename = getInlineInfo(img_type, "img") -- Get image filename
	    	-- Build image wikitext
	        if img_size ~= nil then -- add size, if it exists
	            img_wikitext = '[[File:' .. img_filename .. '|' .. img_size .. '|' .. img_link .. '|link=' .. img_link .. ']]'
	        else
	            img_wikitext = '[[File:' .. img_filename .. '|' .. img_link .. '|link=' .. img_link .. ']]'
	        end
    elseif img_type == nil then
        img_type = 'none'
    end
 
	-- Get sort order (if hidesort is true, then don't set sort_tpl)
	if img_type ~= nil and getInlineInfo(img_type, "sortorder") ~= nil and not hidesort then
	    sort_tpl = getInlineInfo(img_type, "sortorder")
	end
 
	-- Build sort span with image wikitext
	local img_span_link = mw.html.create('span')
	    :wikitext('<span style="display:none;">' .. sort_tpl .. '</span>' .. img_wikitext)
 
	-- Return sort span and image wikitext
	return img_span_link
end
 
return p

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

查看其他FANDOM

随机维基