Jump to content

Module:Professional wrestling profiles/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Edgars2007 (talk | contribs) at 10:58, 29 May 2016 (should be safe to use string.gsub instread of mw.ustring.gsub). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
function getpropertyvalue(ent, prop)
	if ent then return ent:formatPropertyValues(prop).value else return "" end
end

function getpropertyvaluewithdefaultvalues(ent, prop, value1, value2)
	local value = value1 or ""; if value == "" then value = value2 or "" end
    if value == "" then value = getpropertyvalue(ent, prop) end
    return value;
end

function p.getpropertyvalue(frame)
local ent = mw.wikibase.getEntityObject();
local prop = frame.args[1];
return getpropertyvalue(ent, prop);
end

local p = {}
local categories = {}
local ent = mw.wikibase.getEntityObject()
local yesno = require('Module:Yesno')
local getArgs = require('Module:Arguments').getArgs

function p._profiles(args)
	local title = mw.title.getCurrentTitle()
	local name = args.name or string.gsub(title.text, " %b()", "")

	local cagematchid = getpropertyvaluewithdefaultvalues(ent, 'P2728', frame.args["cagematch"], nil);		
	local wrestlingdataid = getpropertyvaluewithdefaultvalues(ent, 'P2764', frame.args["wrestlingdata"], nil);
	local iwdid = getpropertyvaluewithdefaultvalues(ent, 'P2829', frame.args["iwd"], nil);
	if (cagematchid == "") and (wrestlingdataid == "") and (iwdid == "") then return "" end
	local text = name .. "'s profile at ";
	if cagematchid ~= "" then text = text .. "[http://www.cagematch.net/?id=2&nr=" .. cagematchid .. " Cagematch.net], " end
	if wrestlingdataid ~= "" then text = text .. "[http://wrestlingdata.com/index.php?befehl=bios&wrestler=" .. wrestlingdataid .. " Wrestlingdata.com], " end
	if iwdid ~= "" then text = text .. "[http://www.profightdb.com/wrestlers/" .. iwdid .. ".html Internet Wrestling Database], " end
	return string.sub(text, 1, -3);
end	

function p.profiles(frame)
	local args = getArgs(frame)
	return p._profiles(args)
end

return p