Jump to content

Module:Professional wrestling profiles

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Silverfish (talk | contribs) at 16:12, 26 May 2016 (Fix links). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

function getpropertyvalue(ent, prop)
	return ent:formatPropertyValues(prop).value;
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 getname(frame, name1, name2)
	local name = name1 or ""; if name == "" then name = name2 or "" end
    if name == "" then name = frame:expandTemplate{title = 'PAGENAMEBASE'} end
    return name
end	



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

function p.cagematch(frame)
	local ent = mw.wikibase.getEntityObject(); 
    local id = getpropertyvaluewithdefaultvalues(ent, 'P2728', frame.args[1], frame.args["id"]);	
    local name = getname(frame, frame.args[2], frame.args["name"]);
	local code = "[http://www.cagematch.net/?id=2&nr=" .. id .. " " ..	name .. "]'s profile at Cagematch.net";
    return code
end


function p.profiles(frame)
	local ent = mw.wikibase.getEntityObject();
	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 name = getname(frame, frame.args["name"], nil);
	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	

return p