Modul:Goalscorers: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Catalyszczowski (bicara | kontrib)
Tidak ada ringkasan suntingan
Tag: Pengembalian manual
Catalyszczowski (bicara | kontrib)
Tidak ada ringkasan suntingan
Baris 1:
require('Module:No globals');
local data = {}
local yesno = require('Module:Yesno')
 
local p = {}
-- flag template
local g = {} -- for parameters with global scope in this module
data.templates = { flag_icon_linked = "fbicon" }
g.goalscorers = {} -- table where selected and sorted players will be place
g.args = {}
g.totalGoals = 0
local data = {} -- module subpage data -- require('Module:Goalscorers/data/UEFA Euro 2016 qualifying');
 
p.errorString = ""
-- date and matches played of latest update
function p.error_msg()
data.updated = { -- round, matches, update date
if p.errorString ~= "" then
group = { A = { 11, "complete" } }, -- First round
return '<span style="font-size:100%" class="error">'
secondround = { 157, "complete" },
-- '<code style="color:inherit;border:inherit;padding:inherit;">&#124;_template=</code>'
thirdround = { 0, "2021-06-15" },
.. p.errorString .. '</span>';
fourthround = { 0, "" }
end
}
end
-- data for goals scored held in module subpages, e.g. "Module:Goalscorers/data/UEFA Euro 2016 qualifying"
--[[ parameters containing data help in three tables
data.rounds = {} -- group, play-off
data.goalscorers = {} -- player, country, goals in each round)
data.owngoalscorers = {} -- player, country, goals in each round)
data.updated = {} -- date of latest update (month, day, year)
--]]
 
--[[ ############################ Parameter handing ###############################
data.groups = { -- DO NOT CHANGE THIS SECTION
this section is currently unused
A = { "IRN", "JPN", "KOR", "AUS", "QAT", "UAE", "KSA", "CHN",
will be used to take check parameters set in template
"IRQ", "SYR", "UZB", "LBN", "OMA", "KGZ", "JOR", "VIE",
]]
"PLE", "IND", "BHR", "THA", "TJK", "PRK", "PHI", "TPE",
"TKM", "MYA", "HKG", "YEM", "AFG", "MDV", "KUW", "IDN",
"SIN", "NEP", "MAS", "CAM", "MAC", "LAO", "BHU", "MNG",
"BAN", "GUM", "BRU", "TLS", "PAK", "SRI" }
}
 
local function getArgs(frame)
-- controls which teams are still active in qualifying, and therefore have their players bolded
local parents = mw.getCurrentFrame():getParent()
data.active_countries = { "IRN", "JPN", "KOR", "AUS", "UAE", "KSA", "CHN", "VIE",
"IRQ", "SYR", "OMA", "LBN" }
for k,v in pairs(parents.args) do
--check content
if v and v ~= "" then
g.args[k]=mw.text.trim(v) --parents.args[k]
end
end
for k,v in pairs(frame.args) do
--check content
if v and v ~= "" then
g.args[k]= mw.text.trim(v) --parents.args[k]
end
end
-- allow empty caption to blank default
--if parents.args['caption'] then templateArgs['caption'] = parents.args['caption'] end
end
 
--[[ ############################## Main function and other functions ######################
-- rounds of competition
data.rounds = { group = 3, secondround = 4, thirdround = 5, fourthround = 6 } -- DO NOT CHANGE
 
main() - simple output of the data in the module in list form
-- all competition goalscorers
]]
data.goalscorers = {
function p.main(frame)
-- player name, country, goals in R1, goals in R2, goals in R3, goals in R4
-- AfghanistangetArgs(frame)
local dataTarget = g.args[1] or g.args['data']
{"[[Zelfy Nazary]]", "AFG", 0, 1, 0, 0 },
if dataTarget then
{"[[Farshad Noor]]", "AFG", 0, 1, 0, 0 },
data = require('Module:Goalscorers/data/'.. dataTarget) --or 'UEFA Euro 2016 qualifying'
{"[[Omid Popalzay]]", "AFG", 0, 1, 0, 0 },
return p.useModuleData(frame) -- data on goals taken from module subpage
{"[[Amredin Sharifi]]", "AFG", 0, 1, 0, 0 },
else
{"[[Hossein Zamani]]", "AFG", 0, 1, 0, 0 },
return p.useTemplateData(frame) -- data on goals/assists taken from template
end
end
function p.useModuleData(frame)
 
--p.goalscorers = {} -- table where selected and sorted players will be place
-- Australia
g.totalGoals = 0
{"[[Martin Boyle]]", "AUS", 0, 1, 0, 0 },
p.selectGoalscorers() -- selected goalscorers meeting round and group criteris
{"[[Mitchell Duke]]", "AUS", 0, 2, 0, 0 },
{"[[Ajdin Hrustic]]", "AUS", 0, 1, 0, 0 },
-- CHANGEe: append own goals to list (data will now include goals and own goals (negative))
{"[[Jackson Irvine]]", "AUS", 0, 3, 0, 0 },
p.selectGoalscorers("OG")
{"[[Fran Karacic]]", "AUS", 0, 1, 0, 0 },
{"[[Mathew Leckie]]", "AUS", 0, 4, 0, 0 },
{"[[Jamie Maclaren]]", "AUS", 0, 5, 0, 0 },
p.sortGoalscorers() -- sort selected goalscorers by number of goal, then country
{"[[Aaron Mooy]]", "AUS", 0, 1, 0, 0 },
{"[[Trent Sainsbury]]", "AUS", 0, 1, 0, 0 },
{"[[Harry Souttar]]", "AUS", 0, 6, 0, 0 },
local outputString = p.addIntroductorySentence() .. p.outputGoalscorers(frame) .. p.addFooterSentence()
{"[[Adam Taggart]]", "AUS", 0, 3, 0, 0 },
-- .. "" --TODO add intermediate heading?
-- .. p._owngoals(frame) -- output list of goalscorers
return p.error_msg() or outputString
end
function p.addIntroductorySentence() -- add introductory text
local totalGoalString = "A total of " .. g.totalGoals .. " goals were scored."
--There were [has been|have been|was|were] #GOALS goal(s) scored in #MATCHES match(s), for an average of #GOALS/#MATCHES per match.
local matches, dateUpdated = p.getNumberMatches()
local mdyFormat = yesno(g.args['mdy'])
local Date = require('Module:Date')._Date
local pluralGoals = "s"
local text1 = ""
if g.totalGoals == 1 then
pluralGoals = ""
if dateUpdated == 'complete' then text1 = "was" else text1 = "has been" end
else
if dateUpdated == 'complete' then text1 = "were" else text1 = "have been" end
end
local text = string.format("There %s %s goal%s scored", text1, mw.getLanguage('en'):formatNum(g.totalGoals), pluralGoals)
local pluralMatches = "es"
if matches==1 then pluralMatches = "" end
if matches then
local average = g.totalGoals/tonumber(matches)
local precision = 3 -- display d.dd (three significant disgits)
if average < 1 then precision = 2 end -- display 0.dd (thwo significant disgits)
average = tostring (average)
 
local pluralAverage = "s"
-- Bahrain
if tonumber(string.format("%.2f",average))==1 then pluralAverage = "" end
{"[[Ismail Abdullatif]]", "BHR", 0, 3, 0, 0 },
text = text .. string.format(" in %d match%s, for an average of %."..precision.."g goal%s per match", matches, pluralMatches, average, pluralAverage)
{"[[Kamil Al Aswad]]", "BHR", 0, 4, 0, 0 },
end
{"[[Mohammed Al-Hardan]]", "BHR", 0, 1, 0, 0 },
{"[[Mohamed Al-Romaihi]]", "BHR", 0, 1, 0, 0 },
if dateUpdated == 'complete' or dateUpdated == "" then
{"[[Jasim Al-Shaikh]]", "BHR", 0, 1, 0, 0 },
text = text .. "."
{"[[Hashim&nbsp;Sayed Isa]]", "BHR", 0, 2, 0, 0 },
else
{"[[Ali Madan]]", "BHR", 0, 2, 0, 0 },
local dateFormat = 'dmy' -- default
{"[[Sayed&nbsp;Dhiya Saeed]]", "BHR", 0, 1, 0, 0 },
if data.params and data.params['date_format'] then dateFormat = data.params['date_format'] end -- from data module
if mdyFormat == true then dateFormat = "mdy" else
if mdyFormat == false then dateFormat = "dmy" end -- template param overrides
end
text = text .. " (as of " .. Date(dateUpdated):text(dateFormat) .. ")."
end
text = p.addAdditionHeaderText(text, dateUpdated) -- handles template parameters bold, further, extra
 
return text --totalGoalString
-- Bangladesh
end
{"[[Biplu Ahmed]]", "BAN", 0, 1, 0, 0 },
function p.addFooterSentence() -- add notes at bottom
{"[[Topu Barman]]", "BAN", 0, 1, 0, 0 },
{"[[Robiul Hasan]]", "BAN", 1, 0, 0, 0 },
local footerSentence = g.args['footer'] or ""
{"[[Saad Uddin]]", "BAN", 0, 1, 0, 0 },
--footerSentence = "This is a footer sentence." -- test footer
if data.params then
local footer = data.params['footer'] or nil
if footer then
local frame = mw.getCurrentFrame()
local processed = frame:preprocess(footer)
if g.notes then
footerSentence = footerSentence .. processed
end
end
end
if footerSentence ~= "" then
footerSentence = '<div style = "" >' .. footerSentence .. '</div>'
end
return footerSentence
end
function p.getNumberMatches()
local matches = g.args['matches']
local dateUpdated = data.updated['date'] or "1700-01-01" --'complete' -- assume completed if missing
local round = g.args['round'] or "all" -- round = all(empty)|group|playoffs
local group = g.args['group'] or "all" -- group = all(empty), A,B,C etc
local allGroupGames = 0
local latestGroupDate = "1800-01-01"
if round == "all" or group == "all" then -- count all the group games
for k,v in pairs(data.updated.group) do
allGroupGames = allGroupGames + v[1]
if v[2] ~= "complete" and v[2] > latestGroupDate then latestGroupDate = v[2] end -- update if later date
end
if latestGroupDate == "1800-01-01" then latestGroupDate = "complete" end -- no dates so must be complete
end
 
if round == "all" then -- all rounds and goals
-- Bhutan
matches=0
{"[[Tshering Dorji]]", "BHU", 1, 0, 0, 0 },
for k,v in pairs(data.updated) do
if k == "group" then
matches = matches + allGroupGames
if latestGroupDate ~= "complete" and latestGroupDate > dateUpdated then
dateUpdated = latestGroupDate -- update if later date
end
else
matches = matches + v[1]
if v[2] ~= "complete" and v[2] > dateUpdated then dateUpdated = v[2] end -- update if later date
end
end
elseif round == "group" then -- group round only
if group == "all" then
matches = allGroupGames
dateUpdated = latestGroupDate
else -- single group only
matches = data.updated.group[group][1] -- number matches
dateUpdated = data.updated.group[group][2] -- update date or completed
end
else -- any other round
matches = data.updated[round][1] -- number matches
dateUpdated = data.updated[round][2] -- update date or completed
end
if dateUpdated == "1700-01-01" then dateUpdated = "complete" end -- no dates so must be complete
 
return matches, dateUpdated
-- Brunei
end
{"[[Razimie&nbsp;Ramlli]]", "BRU", 2, 0, 0, 0 },
 
function p.owngoals(frame) -- need to check parameters if external call
-- Cambodia
getArgs(frame)
{"[[Keo Sokpheng]]", "CAM", 0, 1, 0, 0 },
data = require('Module:Goalscorers/data/'.. g.args[1]) --or 'UEFA Euro 2016 qualifying'
{"[[Kouch Sokumpheak]]", "CAM", 1, 0, 0, 0 },
{"[[Reung Bunheing]]", "CAM", 1, 0, 0, 0 },
{"[[Sath Rosib]]", "CAM", 1, 0, 0, 0 },
{"[[Sieng Chanthea]]", "CAM", 1, 0, 0, 0 },
{"[[Soeuy Visal]]", "CAM", 0, 1, 0, 0 },
 
local outputString = p._owngoals(frame)
-- China PR
return p.error_msg() or outputString
{"[[Alan Carvalho|Alan]]", "CHN", 0, 3, 0, 0 },
end
{"[[Elkeson]]", "CHN", 0, 4, 0, 0 },
function p._owngoals(frame) -- internal call for own goals
{"[[Jin Jingdao]]", "CHN", 0, 1, 0, 0 },
{"[[Liu Binbin]]", "CHN", 0, 1, 0, 0 },
{"[[Tan Long]]", "CHN", 0, 1, 0, 0 },
{"[[Wu Lei]]", "CHN", 0, 8, 0, 0 },
{"[[Wu Xi (footballer)|Wu Xi]]","CHN", 0, 3, 0, 0 },
{"[[Wu Xinghan]]", "CHN", 0, 1, 0, 0 },
{"[[Yang Xu]]", "CHN", 0, 5, 0, 0 },
{"[[Zhang Xizhe]]", "CHN", 0, 1, 0, 0 },
{"[[Zhang Yuning (footballer, born 1997)|Zhang Yuning]]", "CHN", 0, 2, 0, 0 },
 
--p.goalscorers = {} -- table where selected and sorted players will be place
-- Chinese Taipei
{"[[Chen Yi-wei]]", "TPE", 0, 1, 0, 0 },
{"[[Gao Wei-jie]]", "TPE", 0, 1, 0, 0 },
{"[[Wen Chih-hao]]", "TPE", 0, 1, 0, 0 },
{"[[Wu Chun-ching]]", "TPE", 0, 1, 0, 0 },
p.selectGoalscorers("OG") -- selected goalscorers meeting round and group criteris
-- Guam
{"[[Jason Cunliffe]]", "GUM", 3, 0, 0, 0 },
p.sortGoalscorers() -- sort selected goalscorers by number of goal, then country
{"[[Isiah Lagutang]]", "GUM", 1, 0, 0, 0 },
{"[[Marcus Lopez]]", "GUM", 0, 1, 0, 0 },
{"[[Shane Malcolm]]", "GUM", 1, 0, 0, 0 },
{"[[John Matkin]]", "GUM", 0, 1, 0, 0 },
 
return p.outputGoalscorers(frame, "OG") -- output list of goalscorers
-- Hong Kong
{"[[James Ha]]", "HKG", 0, 1, 0, 0 },
end
{"[[Matt Orr]]", "HKG", 0, 1, 0, 0 },
{"[[Roberto Orlando Affonso Júnior|Roberto]]", "HKG", 0, 1, 0, 0 },
{"[[Tan&nbsp;Chun&nbsp;Lok]]", "HKG", 0, 1, 0, 0 },
 
-- India
{"[[Sunil Chhetri]]", "IND", 0, 3, 0, 0 },
{"[[Seiminlen Doungel]]", "IND", 0, 1, 0, 0 },
{"[[Adil Khan (footballer)|Adil Khan]]", "IND", 0, 1, 0, 0 },
 
-- select players meeting round and goal criteria
-- Indonesia
function p.selectGoalscorers(og)
{"[[Irfan Bachdim]]", "IDN", 0, 1, 0, 0 },
{"[[Evan Dimas]]", "IDN", 0, 1, 0, 0 },
{"[[Beto Gonçalves]]", "IDN", 0, 2, 0, 0 },
{"[[I&nbsp;Kadek&nbsp;Agung Widnyana]]", "IDN", 0, 1, 0, 0 },
 
--data = require('Module:Goalscorers/data/'.. g.args[1]) --or 'UEFA Euro 2016 qualifying'
-- Iran
{"[[Vahid Amiri]]", "IRN", 0, 1, 0, 0 },
local goalMinimum = tonumber(g.args['minimum']) or -5 -- assume 5 own goals is maximum
{"[[Karim Ansarifard]]", "IRN", 0, 7, 0, 0 },
{"[[Sardar Azmoun]]", "IRN", 0, 7, 0, 0 },
-- select all players with goals totals for appropriate rounds
{"[[Mehdi Ghayedi]]", "IRN", 0, 1, 0, 0 },
local round = g.args['round'] or "all" -- round = all(empty)|group|playoffs
{"[[Ali Gholizadeh]]", "IRN", 0, 1, 0, 0 },
local group = g.args['group'] or "all" -- group = all(empty), A,B,C etc
{"[[Alireza Jahanbakhsh]]", "IRN", 0, 1, 0, 0 },
{"[[Hossein Kanaanizadegan]]", "IRN", 0, 1, 0, 0 },
{"[[Shojae Khalilzadeh]]", "IRN", 0, 1, 0, 0 },
{"[[Mehrdad Mohammadi]]", "IRN", 0, 1, 0, 0 },
{"[[Milad Mohammadi]]", "IRN", 0, 1, 0, 0 },
{"[[Mohammad Mohebi]]", "IRN", 0, 2, 0, 0 },
{"[[Ahmad Nourollahi]]", "IRN", 0, 2, 0, 0 },
{"[[Morteza Pouraliganji]]", "IRN", 0, 1, 0, 0 },
{"[[Kaveh Rezaei]]", "IRN", 0, 2, 0, 0 },
{"[[Mehdi Taremi]]", "IRN", 0, 3, 0, 0 },
 
local goalsCol = p.getGoalsCol(round) -- 4 -- first column for goals
-- Iraq
--local groupCol = 3 -- default column for group
{"[[Alaa Abbas]]", "IRQ", 0, 1, 0, 0 },
if round then
{"[[Mohanad Ali]]", "IRQ", 0, 5, 0, 0 },
-- goalsCol = data.rounds[round] or data.rounds[1] or 4 -- get column containing goals for that round or first round listed if all
{"[[Amjad Attwan]]", "IRQ", 0, 1, 0, 0 },
end
{"[[Ibrahim Bayesh]]", "IRQ", 0, 1, 0, 0 },
--groupCol = data.group[round] or 3 -- get column containing goals for that round
{"[[Safaa Hadi]]", "IRQ", 0, 1, 0, 0 },
{"[[Ahmad Ibrahim&nbsp;Khalaf]]","IRQ", 0, 1, 0, 0 },
-- select players who have scored in rounds/groups requested
{"[[Ali&nbsp;Adnan Kadhim]]", "IRQ", 0, 2, 0, 0 },
local goalscorerData = data.goalscorers
{"[[Bashar Resan]]", "IRQ", 0, 1, 0, 0 },
if og == "OG" then goalscorerData = data.owngoalscorers end
for k,v in pairs(goalscorerData) do
local goals, comment = 0, "" -- goals > 0 is the flag to include the player
local playerName, playerAlias = p.getPlayer(v[1]) -- player name
local goalsByRound, commentByRound = 0, ""
if round == "all" then -- all rounds and goals
--local i = 4
for i = goalsCol, #v, 1 do --or while i <= #v do
goalsByRound, commentByRound = p.getGoals( v[i] , playerName)
goals = goals + goalsByRound --TODO use getGoals on round options
if commentByRound ~= "" then
if comment == "" then
comment = commentByRound
else
comment = comment .. "," .. commentByRound --TODO decide on comma or semi-colon
end
end
i = i+1
end
elseif round == "group" then -- group round only
--if group == v[groupCol] then -- single group only
if group == p.getGroup(v[2], v[3]) then -- single group only
goals, comment = p.getGoals( v[goalsCol] , playerName)
elseif group == "all" then -- any group
goals, comment = p.getGoals( v[goalsCol] , playerName)
else -- do nothing for other groups
end
--elseif round == "playoffs" then -- playoff round (redunant?)
-- goals = v[goalsCol]
else -- any other round
goals, comment = p.getGoals( v[goalsCol] , playerName) -- should also handle playoffs
end
if goals >= goalMinimum and goals ~= 0 then
if comment ~= "" then
if og == "OG" then
comment = '<span> (' .. p.sortComment(comment) .. ')</span>'
else
comment = '<span>' .. comment .. '</span>' -- no parenthesis when using notes
end
end
if og == "OG" then goals = -goals end -- make owngoals negative numbers
g.goalscorers[#g.goalscorers+1] = { player=playerName, alias=playerAlias,
country=v[2],
goals=goals,
comment=p.parseComment(comment)}
--g.totalGoals = g.totalGoals + math.abs(goals) -- increment total goal counter
end
g.totalGoals = g.totalGoals + math.abs(goals) -- increment total goal counter
end
--return p.goalscorers -- it is available anyway
end
--[[ get column for round or first round listed if "all"
-allows group column to be omitted from player table when group table provided ]]
function p.getGoalsCol(round)
if round == "all" then -- if all need column of first round
for k,v in pairs(data.rounds) do
return v; -- return the first one
end
end
return data.rounds[round] or 4 -- get column containing goals for that round or first round listed if all
end
--[[ get group from group table or from player table ]]
function p.getGroup(country, possibleGroup) -- row contain player name, country code, group if given, goals
if data.groups then
for k,v in pairs(data.groups) do -- iterate through the groups
--local = gotGroup = false
for j,u in pairs(v) do -- for each group
if u == country then
return k
end
end
end
return "no group found"
else
return possibleGroup -- no group table, so assume column three contains the group
end
end
--[[ get number of goals and any associated comment
the goals can be a single number (the usual case)
or as an option table (e.g. for own goals): { number of own goals, comma-delimited list of opponents }
- if the entry is a table, we want the first entry (a number) and the second (comment string)
- otherwise, if a number, we just want the number and an empty string
]]
function p.getGoals (u, player)
if type(u) == 'table' and type(u[1]) == 'number' then
return u[1], u[2] -- return number of goals, comment
elseif type(u) == 'number' then
return u, "" -- return number of goals, empty string
else
p.errorString = p.errorString .. " Invalid goals entry for player " .. player
return 0, ""
end
end
function p.parseComment(comment)
local frame = mw.getCurrentFrame()
 
-- we have something like "{{efn-ua|name=goals}}"
-- Japan
if string.find(comment, "efn" , 1 , true ) then -- if we have a comment with a note
{"[[Takuma Asano]]", "JPN", 0, 3, 0, 0 },
g.notes = true -- set flag
{"[[Wataru Endo]]", "JPN", 0, 1, 0, 0 },
end
{"[[Kyogo Furuhashi]]", "JPN", 0, 3, 0, 0 },
{"[[Sho Inagaki]]", "JPN", 0, 2, 0, 0 },
{"[[Ko Itakura]]", "JPN", 0, 1, 0, 0 },
return frame:preprocess(comment)
{"[[Junya Ito (footballer, born 1993)|Junya Ito]]", "JPN", 0, 2, 0, 0 },
end
{"[[Genki Haraguchi]]", "JPN", 0, 1, 0, 0 },
{"[[Kento Hashimoto]]", "JPN", 0, 1, 0, 0 },
{"[[Daichi Kamada]]", "JPN", 0, 3, 0, 0 },
{"[[Hayao Kawabe]]", "JPN", 0, 1, 0, 0 },
{"[[Takumi Minamino]]", "JPN", 0, 9, 0, 0 },
{"[[Hidemasa Morita]]", "JPN", 0, 2, 0, 0 },
{"[[Kensuke Nagai]]", "JPN", 0, 1, 0, 0 },
{"[[Yuto Nagatomo]]", "JPN", 0, 1, 0, 0 },
{"[[Shoya Nakajima]]", "JPN", 0, 1, 0, 0 },
{"[[Ado Onaiwu]]", "JPN", 0, 3, 0, 0 },
{"[[Yuya Osako]]", "JPN", 0, 8, 0, 0 },
{"[[Sho Sasaki (footballer)|Sho Sasaki]]", "JPN", 0, 1, 0, 0 },
{"[[Maya Yoshida]]", "JPN", 0, 1, 0, 0 },
 
function p.getPlayer(u)
-- Jordan
if type(u) == 'table' then
{"[[Salem Al-Ajalin]]", "JOR", 0, 1, 0, 0 },
if type(u[1]) == 'string' and type(u[2]) == 'string' then
{"[[Yazan Al-Arab]]", "JOR", 0, 1, 0, 0 },
--[[if #u[2] >1 then
{"[[Hamza Al-Dardour]]", "JOR", 0, 1, 0, 0 },
p.errorString = p.errorString .. "\n\nWe have u[1]=" .. u[1] .. " and u[2]=" .. u[2]
{"[[Ahmad Ersan]]", "JOR", 0, 2, 0, 0 },
end]]
{"[[Baha' Faisal]]", "JOR", 0, 6, 0, 0 },
return u[1], u[2] -- return player name, player sorting alias
{"[[Ahmed Samir (footballer, born 1991)|Ahmed Samir]]", "JOR", 0, 1, 0, 0 },
else
{"[[Feras Shelbaieh]]", "JOR", 0, 1, 0, 0 },
p.errorString = p.errorString .. " Invalid name entry for player " .. u[1] .. ", " .. u[2]
return "", "" --TODO errroer
end
elseif type(u) == 'string' then
return u, "" -- return player name
else
p.errorString = p.errorString .. " Invalid name entry for player " .. u or u[1] or "unknown"
return "", ""
end
end
--[=[ function p.preprocessSortName()
stripp off wikitext [[ and ]]
force to lowercase
change special characters to standard letters
]=]
function p.preprocessSortName (name)
name = string.gsub(name, "%[%[", "") -- strip off [[ and ]]
name = string.gsub(name, "%]%]", "")
--name =string.lower(name) -- force lower case and return
name = mw.ustring.lower(name) -- use unicode function
 
local specialChars = { -- list of special characters and replacement pairs
-- Kuwait
{ "[[Redhaı", Abujabarah]]"i" } , { "KUWİ", 0 "i" } , 1 { "ß", 0, 0 "ss" },
{ "ý", "y" } , { "ř", "r" } , { "ő", "o" },
{"[[Faisal Ajab Al-Azemi|Faisal Ajab]]", "KUW", 0, 1, 0, 0 },
{ "[[Fahadé", Al"e" } , { Ansari]]", "KUWe" } , 0 { "þ", 1, 0, 0 "th" },
{ "ē", "e" } , { "ņ", "n" } , { "č", "c" },
{"[[Mobarak Al-Faneeni]]", "KUW", 0, 1, 0, 0 },
{ "[[Fahadū", Al"u" } , { Hajeri]]", "KUWz" } , 0 { "æ", 1, 0, 0 "ae" },
{ "[[Shabibå", Al-Khaldi]]"a" } , { "KUWø", 0 "o" } , 1 { "ą", 0, 0 "a" },
{ "ń", "n" } , { "ł", "l" } , { "ã", "a" },
{"[[Hussain Al-Musawi]]", "KUW", 0, 1, 0, 0 },
{ "[[Baderș", Al-Mutawa]]"s" } , { "KUWš", 0 "s" } , 3 { "í", 0, 0 "i" },
{ "[[Abdullahá", Mawei]]"a" } , { "KUWä", 0 "a" } , 1 { "ć", 0, 0 "c" },
{ "[[Yousefç", Nasser]]"c" } , { "KUWğ", 0 "g" } , 6 { "ö", 0, 0 "o" },
{ "[[Faisalë", Zayid]]"e" } , { "KUWú", 0 "u" } , 1 { "ó", 0, 0 "o" },
{ "ð", "d" } , { "ü", "u" } , { "ű", "u" },
{ "ā", "a" } , { "ī", "i" } , { "đ", "d" },
{ "ă", "a" } , { "â", "a" } , { "ż", "z" },
{ "ț", "t" } , { "ş", "s" } , { "ś", "s" },
{ "ǎ", "a" } , { "ě", "e" } , { "ů", "u" },
{ "ĕ", "e" } , { "ñ", "n" } , { "ď", "d" },
{ "ï", "i" } , { "ź", "z" } , { "ô", "o" },
{ "ė", "e" } , { "ľ", "l" } , { "ģ", "g" },
{ "ļ", "l" } , { "ę", "e" } , { "ň", "n" },
{ "ò", "o" }
}
for k,v in pairs(specialChars) do -- replace special characters from supplied list
name = string.gsub(name, v[1], v[2])
end
 
return name
-- Kyrgyzstan
end
{"[[Gulzhigit Alykulov]]", "KGZ", 0, 3, 0, 0 },
--[[ return the name for sorting
{"[[Edgar Bernhardt]]", "KGZ", 0, 3, 0, 0 },
return supplied alias name for sorting
{"[[Abay Bokoleyev]]", "KGZ", 0, 1, 0, 0 },
otherwise
{"[[Tamirlan Kozubaev]]", "KGZ", 0, 1, 0, 0 },
checks for pipe (redirect) and uses name after pipe
{"[[Valery Kichin]]", "KGZ", 0, 1, 0, 0 },
splits name into words
{"[[Mirlan Murzaev]]", "KGZ", 0, 5, 0, 0 },
returns first name if only name (e.g. Nani)
{"[[Farhat Musabekov]]", "KGZ", 0, 1, 0, 0 },
otherwise returns name in format second_name [.. last name], firstname
{"[[Tursunali Rustamov]]", "KGZ", 0, 1, 0, 0 },
]]
{"[[Alimardon Shukurov]]", "KGZ", 0, 3, 0, 0 },
function p.getPlayerSortName (playerName, sortName, countryName)
--dewikify all names before sorting, also forces lowercase
playerName = p.preprocessSortName(playerName)
sortName = p.preprocessSortName(sortName)
if sortName ~= "" then -- if we have a sort name supplied
return sortName -- then return it
end
-- players from certain countries will use name in order supplied
local noSort = { "CAM", "CHN", "TPE", "MYA", "PRK", "KOR", "VIE" }
for k,v in pairs(noSort) do
if v == countryName then
return playerName
end
end
-- else work it out from the supplied player name
-- we don't want to test the name in a redirect, so get name after pipe if there is one
if string.find (playerName, "|") then -- test for redirect
local names = mw.text.split( playerName, "|")
playerName = names[2] -- get name after pipe
end
 
local names = mw.text.split( playerName, " ") -- we don't want to sort on first name
-- Laos
if #names == 1 then
return names[1] -- return name of single name player
else
-- we will assume the second name is the sort name e.g, Joe Bloggs, Jan van Bloggen
local name = names[2] -- set name to second name e.g. Bloggs or van
local i=3
while i <= #names do -- any addition names e.g. Bloggen
name= name .. names[i]
i=i+1
end
name = name .. ", " .. names[1] -- add first name e.g. Joe or Jan
return name -- sort on second name third name etc, first name
end
end
 
-- sort the list of countries alphabetically
-- Lebanon
function p.sortComment(comment)
{"[[Rabih Ataya]]", "LBN", 0, 1, 0, 0 },
{"[[Hilal El-Helwe]]", "LBN", 0, 3, 0, 0 },
{"[[Mohamad Kdouh (footballer, born 1997)|Mohamad Kdouh]]", "LBN", 0, 1, 0, 0 },
{"[[Hassan Maatouk]]", "LBN", 0, 1, 0, 0 },
{"[[Nader Matar]]", "LBN", 0, 1, 0, 0 },
{"[[Joan Oumari]]", "LBN", 0, 2, 0, 0 },
{"[[Soony Saad]]", "LBN", 0, 2, 0, 0 },
 
local items = mw.text.split( comment, ",") -- split comma-delimited list
-- Macau
{"[[Filipe Duarte (footballer)|Filipe Duarte]]", "MAC", 1, 0, 0, 0 },
 
for k,v in pairs(items) do
-- Malaysia
items[k] = mw.text.trim(v) -- trim spaces and coe
{"[[Akhyar&nbsp;Rashid]]", "MAS", 2, 0, 0, 0 },
end
{"[[La'Vere Corbin-Ong]]", "MAS", 1, 0, 0, 0 },
{"[[Brendan Gan]]", "MAS", 0, 1, 0, 0 },
table.sort(items, function(a,b) return a<b end) -- sort the table alphbetically
{"[[Guilherme de Paula Lucrécio|Guilherme]]", "MAS", 0, 1, 0, 0 },
{"[[Faiz&nbsp;Nasir]]", "MAS", 1, 0, 0, 0 },
{"[[Shahrel Fikri]]", "MAS", 4, 0, 0, 0 },
{"[[Norshahrul Idlan]]", "MAS", 1, 0, 0, 0 },
{"[[Safawi&nbsp;Rasid]]", "MAS", 2, 3, 0, 0 },
{"[[Mohamadou Sumareh]]", "MAS", 1, 3, 0, 0 },
{"[[Syafiq&nbsp;Ahmad]]", "MAS", 0, 2, 0, 0 },
 
local list = "against " -- construct the alphabetical list string
-- Maldives
for i=1, #items do
{"[[Ali Ashfaq]]", "MDV", 0, 2, 0, 0 },
local sep = ", " -- separator for comma-delimited list
{"[[Ali Fasir]]", "MDV", 0, 1, 0, 0 },
if i==1 then sep = "" -- first word doesn't need comma
{"[[Naiz Hassan]]", "MDV", 0, 1, 0, 0 },
elseif i==#items then sep = " & " -- use "and" before last word
{"[[Ibrahim Mahudhee]]", "MDV", 0, 1, 0, 0 },
end
{"[[Ali Samooh]]", "MDV", 0, 1, 0, 0 },
list = list .. sep .. items[i]
end
return list
end
function p.getCountryName(country)
if string.len(country) == 3 then -- if the country given as a three-letter code
local codes = require('Module:Goalscorers/data/Country codes')
for k,v in pairs(codes.alias) do
if v[1] == country then
return v[2]
end
end
else
return country -- return the country name as is
end
end
--[[ sort goalscorers by goals, country and name
the sort first sorts by number of goals
when these are equal, it sorts by country
when these are equal, it sorts by name
Note: the name sort is on the first name
- a split of the name and sort on the last name is possible
- however, this would be complicated by Dutch (e.g. Stefan de Vrij) and Spanish names
- would sort on second name be better
]]
function p.sortGoalscorers()
local sort_function = function( a,b )
if (a.goals > b.goals) then -- primary sort on 'goals' -> a before b
return true
elseif (a.goals < b.goals) then -- primary sort on 'goals' -> b before a
return false
else -- a.goals == b.goals -- primary sort tied,
--return a.country < b.country -- resolve with secondary sort on 'country'
local country_a = p.getCountryName(a.country) -- sort on name of country, not the code
local country_b = p.getCountryName(b.country)
if (country_a < country_b) then -- secondary sort on 'country'
return true
elseif (country_a > country_b) then -- secondary sort on 'country'
return false
else -- a.country == b.country -- secondary sort tied,
 
--return a.player < b.player --resolve with tertiary sort on 'player' name
-- Mongolia
{"[[Dölgöön Amaraa]]", "MNG", 0, 1, 0, 0 },
local player_a = p.getPlayerSortName(a.player, a.alias, a.country) -- get player name for sorting
{"[[Oyunbaataryn Mijiddorj]]", "MNG", 0, 1, 0, 0 },
local player_b = p.getPlayerSortName(b.player, b.alias, b.country)
{"[[Nyam-Osor Naranbold]]", "MNG", 1, 0, 0, 0 },
{"[[Norjmoogiin Tsedenbal]]", "MNG", 2, 1, 0, 0 },
return player_a < player_b --
--[[]
--local test_a, test_b = a.player, b.player
 
-- we don't want to test the name in a redirect, so get name after pipe if there is one
-- Myanmar
if string.find (a.player, "|") then -- test for redirect
{"[[Aung Thu (footballer)|Aung Thu]]", "MYA", 0, 1, 0, 0 },
local names = mw.text.split( a.player, "|")
{"[[Hlaing Bo Bo]]", "MYA", 0, 2, 0, 0 },
test_a = names[2] -- get name after pipe
{"[[Maung Maung Lwin]]", "MYA", 0, 1, 0, 0 },
end
{"[[Suan Lam Mang]]", "MYA", 0, 2, 0, 0 },
if string.find (b.player, "|") then
local names = mw.text.split( b.player, "|")
test_b = names[2]
end
local names_a = mw.text.split( test_a, " ") -- we don't want to sort on first name
local names_b = mw.text.split( test_b, " ") -- so split names
if not names_a[2] then names_a[2] = test_a end -- for players with one name
if not names_b[2] then names_b[2] = test_b end
return names_a[2] < names_b[2] -- sort on second name
]]
end
end
end
table.sort(g.goalscorers, sort_function)
 
-- Nepal
{"[[Anjan Bista]]", "NEP", 0, 3, 0, 0 },
{"[[Nawayug Shrestha]]", "NEP", 0, 1, 0, 0 },
 
end
-- North Korea
function p.tabulateGoalscorers(frame, og)
{"[[Han Kwang-song]]", "PRK", 0, 1, 0, 0 },
{"[[Jang Kuk-chol]]", "PRK", 0, 1, 0, 0 },
-- ==============output the lists of goalscorers by goal======================
{"[[Jong Il-gwan]]", "PRK", 0, 2, 0, 0 },
local goalNumber = 1000
local maxRank = tonumber(g.args['maxrank'] or 10) -- limit list top ten or value in parameter maxrank
local rank = 1
local playerCount = 0
local rankCount = 0
local playerCells = ""
local firstplayerCell = ""
 
local tableString = '\n{| class="wikitable"' -- start table
-- Oman
..'\n|-' .. '\n!Rank !! Player !! Goals' -- add table headers
{"[[Arshad Al-Alawi]]", "OMA", 0, 1, 0, 0 },
if g.args['header'] then tableString = tableString .. '\n|+ ' .. g.args['header'] end -- add header
{"[[Rabia Al-Alawi]]", "OMA", 0, 4, 0, 0 },
for j,u in pairs(g.goalscorers) do -- run through sorted list of selected goalscorers
{"[[Mohammed Al-Ghafri]]", "OMA", 0, 1, 0, 0 },
{"[[Muhsen Al-Ghassani]]", "OMA", 0, 2, 0, 0 },
-- is the player active still?
{"[[Khalid Al-Hajri]]", "OMA", 0, 2, 0, 0 },
local playerActive = false
{"[[Amran Al-Hidi]]", "OMA", 0, 1, 0, 0 },
if data.active_countries then
{"[[Mohsin Al-Khaldi]]", "OMA", 0, 1, 0, 0 },
for k,v in pairs(data.active_countries) do
{"[[Abdul Aziz Al-Muqbali]]", "OMA", 0, 2, 0, 0 },
if v == u['country'] then
{"[[Abdullah Fawaz]]", "OMA", 0, 2, 0, 0 },
playerActive = true
break;
end
end
end
local _,roundStatus = p.getNumberMatches()
if roundStatus == "complete" then playerActive = false end -- overrides active_countries
-- wikitext for tablulated list
local goalscorerString = p.addLinkedIcon(frame, u['country']) -- linked flag icon
if playerActive and g.args['bold']~='no' then
goalscorerString = goalscorerString .. " '''" .. u['player'] .. "'''>" -- bolded name
else
goalscorerString = goalscorerString .. " " .. u['player'] -- name
end
goalscorerString = goalscorerString .. u['comment'] -- comment for o.g.
 
-- Pakistanwe have a goalscorer
playerCount = playerCount + 1
{"[[Hassan Bashir]]", "PAK", 1, 0, 0, 0 },
rankCount = rankCount + 1
if u['goals'] < goalNumber then -- player belongs to rowspan for new number of goals
-- need to generate code for the previous rowspan (if there is one)
-- then start the counts and player list for the new one
if playerCount == 1 then
firstplayerCell = '\n|' .. goalscorerString -- if first player in list just create cell and set goals
goalNumber = u['goals']
--rank = 1
rankCount = 0
else -- else generate previous rowspan
local rowSpan = rankCount
if playerCount > maxRank * 1.5 then
firstplayerCell = '\n| style="font-style:italic;text-align:center;"|' .. rankCount .. " players"
playerCells = ""
rowSpan = 1
end
tableString = tableString .. '\n|-\n| style="text-align:center;" rowspan="' .. rowSpan .. '"|' .. rank
--if rankCount > 1 then tableString = tableString .. "=" end -- adds equals when rank shared
tableString = tableString .. firstplayerCell
tableString = tableString .. '\n| style="text-align:center;" rowspan="' .. rowSpan .. '"|' .. goalNumber
tableString = tableString .. playerCells
 
rank = rank + rankCount
-- Palestine
if rank > maxRank then break end -- limit list top ten or value in parameter
{"[[Islam Batran]]", "PLE", 0, 1, 0, 0 },
rankCount = 0
{"[[Oday Dabbagh]]", "PLE", 0, 4, 0, 0 },
goalNumber = u['goals']
{"[[Yaser Hamed]]", "PLE", 0, 3, 0, 0 },
firstplayerCell = '\n|' .. goalscorerString -- set first player cell for next rowspan
{"[[Tamer Seyam]]", "PLE", 0, 2, 0, 0 },
playerCells = ""
end
else -- else another player with same number of goals
playerCells = playerCells .. '\n|-' .. '\n|' .. goalscorerString -- add to player cell list
end
end -- reached end of list of goalscorers
 
if tableString ~= "" then
-- Philippines
tableString = tableString .. "\n|}"
{"[[Ángel Guirado]]", "PHI", 0, 3, 0, 0 },
return tableString
{"[[Mark Hartmann]]", "PHI", 0, 1, 0, 0 },
else
{"[[Mike Ott]]", "PHI", 0, 1, 0, 0 },
return ("No goals matching requested criteria.")
{"[[Javier Patiño]]", "PHI", 0, 1, 0, 0 },
end
{"[[Iain Ramsay]]", "PHI", 0, 1, 0, 0 },
{"[[Patrick Reichelt]]", "PHI", 0, 1, 0, 0 },
{"[[Stephan Schröck]]", "PHI", 0, 1, 0, 0 },
end
{"[[John-Patrick Strauß]]", "PHI", 0, 2, 0, 0 },
function p.outputGoalscorers(frame, og) -- output list of goalscorers
if g.args['table'] then return p.tabulateGoalscorers(frame, og) end -- optional table output
local outputString = ""
if og == "OG" then end
 
-- ==============output the lists of goalscorers by goal======================
-- Qatar
local goalNumber = 1000
{"[[Yusuf Abdurisag]]", "QAT", 0, 1, 0, 0 },
--local goalMinimum = tonumber(templateArgs['minimum']) or 0
{"[[Akram Afif]]", "QAT", 0, 4, 0, 0 },
{"[[Almoez Ali]]", "QAT", 0, 6, 0, 0 },
local listOpen = false -- flag for list started by template {{Div Col}}
{"[[Hassan Al-Haydos]]", "QAT", 0, 2, 0, 0 },
{"[[Karim Boudiaf]]", "QAT", 0, 1, 0, 0 },
for j,u in pairs(g.goalscorers) do -- run through sorted list of selected goalscorers
{"[[Abdelkarim Hassan]]", "QAT", 0, 1, 0, 0 },
{"[[Abdulaziz Hatem]]", "QAT", 0, 2, 0, 0 },
--if u['goals'] < goalMinimum then break end -- limit list to goals over a threshold (now handled in select goalscorers)
{"[[Boualem Khoukhi]]", "QAT", 0, 1, 0, 0 },
if u['goals'] < goalNumber then -- start new list of new number of goals
if listOpen then -- if an open list, close last list
outputString = outputString .. p.closeList(frame)
listOpen = false -- redundant as will be set true again
end
goalNumber = u['goals']
local goalString = " goal"
--if og == "OG" then
if goalNumber < 0 then
goalString = " own" .. goalString
end
if math.abs(u['goals']) ~= 1 then goalString = goalString .. "s" end
 
outputString = outputString .. "\n'''" .. math.abs(u['goals']) .. goalString .. "'''" -- list caption
-- Saudi Arabia
{"[[Salem Al-Dawsari]]", "KSA", 0, 5, 0, 0 },
outputString = outputString .. p.openList(frame,og) --start new list
{"[[Salman Al-Faraj]]", "KSA", 0, 4, 0, 0 },
listOpen = true
{"[[Abdullah Al-Hamdan]]", "KSA", 0, 1, 0, 0 },
--goalNumber = u['goals']
{"[[Ali Al-Hassan]]", "KSA", 0, 1, 0, 0 },
end
{"[[Fahad Al-Muwallad]]", "KSA", 0, 4, 0, 0 },
-- is the player active still?
{"[[Yasser Al-Shahrani]]", "KSA", 0, 1, 0, 0 },
local playerActive = false
{"[[Saleh Al-Shehri]]", "KSA", 0, 3, 0, 0 },
if data.active_countries then
{"[[Abdulfattah Asiri]]", "KSA", 0, 2, 0, 0 },
for k,v in pairs(data.active_countries) do
{"[[Hattan Bahebri]]", "KSA", 0, 1, 0, 0 },
if v == u['country'] then
playerActive = true
break;
end
end
end
local _,roundStatus = p.getNumberMatches()
if roundStatus == "complete" then playerActive = false end -- overrides active_countries
-- wikitext for bullet list
local goalscorerString = '\n*<span>' .. p.addLinkedIcon(frame, u['country']) -- linked flag icon
if playerActive and g.args['bold']~='no' then
goalscorerString = goalscorerString .. " <b>" .. u['player'] .. "</b>" -- bolded name
else
goalscorerString = goalscorerString .. " " .. u['player'] -- name
end
goalscorerString = goalscorerString .. u['comment'] .. '</span>' -- comment for o.g.
outputString = outputString .. goalscorerString -- .. " " .. tostring(u['goals'])
 
end -- reached end of list of goalscorers
-- Singapore
{"[[Faris&nbsp;Ramli]]", "SIN", 0, 1, 0, 0 },
{"[[Hafiz&nbsp;Nor]]", "SIN", 0, 1, 0, 0 },
{"[[Ikhsan&nbsp;Fandi]]", "SIN", 0, 3, 0, 0 },
{"[[Safuwan&nbsp;Baharudin]]", "SIN", 0, 1, 0, 0 },
{"[[Shakir&nbsp;Hamzah]]", "SIN", 0, 1, 0, 0 },
 
if outputString ~= "" then
-- South Korea
outputString = outputString .. p.closeList(frame)
{"[[Hwang Hee-chan]]", "KOR", 0, 2, 0, 0 },
{"[[Hwang Ui-jo]]", "KOR", 0, 2, 0, 0 },
{"[[Jung Sang-bin]]", "KOR", 0, 1, 0, 0 },
{"[[Jung Woo-young]]", "KOR", 0, 1, 0, 0 },
{"[[Kim Shin-wook]]", "KOR", 0, 6, 0, 0 },
{"[[Kim Young-gwon]]", "KOR", 0, 1, 0, 0 },
{"[[Kwon Chang-hoon]]", "KOR", 0, 2, 0, 0 },
{"[[Lee Dong-gyeong]]", "KOR", 0, 1, 0, 0 },
{"[[Na Sang-ho]]", "KOR", 0, 1, 0, 0 },
{"[[Nam Tae-hee]]", "KOR", 0, 1, 0, 0 },
{"[[Son Heung-min]]", "KOR", 0, 3, 0, 0 },
{"[[Song Min-kyu (footballer)|Song Min-kyu]]", "KOR", 0, 1, 0, 0 },
 
return outputString
-- Sri Lanka
else
{"[[Ahmed&nbsp;Waseem Razeek]]", "SRI", 0, 2, 0, 0 },
return ("No goals matching requested criteria.")
end
end
 
-- output icon linked to national team page
-- Syria
function p.addLinkedIcon(frame, country)
{"[[Firas Al-Khatib]]", "SYR", 0, 1, 0, 0 },
local icon = data.templates['flag_icon_linked'] -- fbicon etc set in data module
{"[[Mahmoud Al-Mawas]]", "SYR", 0, 6, 0, 0 },
local level = data.templates['youth_level'] or "" -- parameter for youth level, ie under-21
{"[[Ward Al Salama]]", "SYR", 0, 1, 0, 0 },
-- equivalent to {{fbicon|country}}
{"[[Omar Al Somah]]", "SYR", 0, 7, 0, 0 },
local flagVariant = ""
{"[[Aias Aosman]]", "SYR", 0, 2, 0, 0 },
if data.templates.flagvar and data.templates.flagvar[country] then
{"[[Mardik Mardikian]]", "SYR", 0, 2, 0, 0 },
flagVariant = data.templates.flagvar[country]
{"[[Khaled Mobayed]]", "SYR", 0, 1, 0, 0 },
end
{"[[Osama Omari]]", "SYR", 0, 1, 0, 0 },
if level ~= "" then
return frame:expandTemplate{ title = icon , args = { level, country, flagVariant } }
else
return frame:expandTemplate{ title = icon , args = { country, flagVariant } } -- flag icon
end
end
-- formatting of list under each number of goals
function p.openList(frame,og)
 
return mw.getCurrentFrame():extensionTag{
-- Tajikistan
name = 'templatestyles', args = { src = 'Div col/styles.css' }
{"[[Sheriddin Boboev]]", "TJK", 0, 1, 0, 0 },
} .. '<div class="div-col" style="column-width:25em;">' -- perhaps add "column-count:3;"" to limit max number of columns?
{"[[Alisher Dzhalilov]]", "TJK", 0, 2, 0, 0 },
end
{"[[Manuchekhr Dzhalilov]]", "TJK", 0, 4, 0, 0 },
function p.closeList(frame)
{"[[Davron Ergashev]]", "TJK", 0, 1, 0, 0 },
return '</div>'
{"[[Jahongir Ergashev]]", "TJK", 0, 1, 0, 0 },
end
{"[[Ehson Panjshanbe]]", "TJK", 0, 1, 0, 0 },
function p.firstToUpper(str)
{"[[Shahrom Samiev]]", "TJK", 0, 2, 0, 0 },
return (str:gsub("^%l", string.upper))
{"[[Komron Tursunov]]", "TJK", 0, 1, 0, 0 },
end
{"[[Farkhod Vosiyev]]", "TJK", 0, 1, 0, 0 },
 
-- handles parameters bold, further, extra
-- Thailand
function p.addAdditionHeaderText(text, dateUpdated)
{"[[Theerathon Bunmathan]]", "THA", 0, 1, 0, 0 },
if g.args['inlineref'] then
{"[[Teerasil Dangda]]", "THA", 0, 1, 0, 0 },
text = text .. g.args['inlineref']
{"[[Adisak Kraisorn]]", "THA", 0, 1, 0, 0 },
end
{"[[Suphanat Mueanta]]", "THA", 0, 1, 0, 0 },
if g.args['bold'] and g.args['bold']~='no' then
{"[[Ekanit Panya]]", "THA", 0, 1, 0, 0 },
text = text .. " Players highlighted in '''bold''' are still active in the competition."
{"[[Supachok Sarachat]]", "THA", 0, 2, 0, 0 },
end
{"[[Chanathip Songkrasin]]", "THA", 0, 1, 0, 0 },
if g.args['further'] then
{"[[Narubadin Weerawatnodom]]", "THA", 0, 1, 0, 0 },
if text ~= "" then text = text .. " " end
text = text .. g.args['further']
end
if g.args['extra'] then
text = text .. "\n\n" .. g.args['extra']
end
return text
end
-- count number of goals for data in template
function p.countGoals(list, number, totalGoals)
 
local split = mw.text.split( list, "\n", true ) -- split the list for number of goals scorers with N goals
-- Timor-Leste
local count = #split * math.abs(number) -- calculate number of goals (including own goals)
{"[[Rufino Gama]]", "TLS", 1, 0, 0, 0 },
totalGoals = totalGoals + count
{"[[João Pedro (footballer, born 2000)|João Pedro]]", "TLS", 1, 0, 0, 0 },
--mw.addWarning( "Entry: " .. list .. "[" .. count .. "]")
 
return totalGoals
-- Turkmenistan
end
{"[[Arslanmyrat Amanow]]", "TKM", 0, 2, 0, 0 },
{"[[Altymyrat Annadurdyýew]]", "TKM", 0, 3, 0, 0 },
{"[[Güýçmyrat Annagulyýew]]", "TKM", 0, 1, 0, 0 },
{"[[Zafar Babajanow]]", "TKM", 0, 1, 0, 0 },
{"[[Abdy Bäşimow]]", "TKM", 0, 1, 0, 0 },
{"[[Wahyt Orazsähedow]]", "TKM", 0, 2, 0, 0 },
{"[[Mihail Titow]]", "TKM", 0, 1, 0, 0 },
 
--[[ use data supplied by template
-- United Arab Emirates
]]
{"[[Tareq Ahmed]]", "UAE", 0, 1, 0, 0 },
{"[[Caio Canedo Corrêa]]", "UAE", 0, 1, 0, 0 },
{"[[Mohammed Jumaa]]", "UAE", 0, 1, 0, 0 },
{"[[Khalil Ibrahim (footballer)|Khalil Ibrahim]]", "UAE", 0, 1, 0, 0 },
{"[[Mahmoud Khamees]]", "UAE", 0, 1, 0, 0 },
{"[[Fábio Virginio de Lima]]", "UAE", 0, 5, 0, 0 },
{"[[Ali Mabkhout]]", "UAE", 0, 11, 0, 0 },
{"[[Ali Salmeen]]", "UAE", 0, 1, 0, 0 },
{"[[Sebastián Tagliabúe]]", "UAE", 0, 1, 0, 0 },
 
--function p.list(frame)
-- Uzbekistan
function p.useTemplateData(frame)
{"[[Odil Ahmedov]]", "UZB", 0, 2, 0, 0 },
--getArgs(frame)
{"[[Jamshid Iskanderov]]", "UZB", 0, 1, 0, 0 },
{"[[Sanjar Kodirkulov]]", "UZB", 0, 1, 0, 0 },
--[[ {{{#if:{{{assists|}}}||There
{"[[Jaloliddin Masharipov]]", "UZB", 0, 3, 0, 0 },
{{#if:{{{ongoing|}}}|{{#ifexpr:{{{goals}}}=1|has|have}} been
{"[[Igor Sergeyev (Uzbekistani footballer)|Igor Sergeev]]", "UZB", 0, 1, 0, 0 },
|{{#ifexpr:{{{goals}}}=1|was|were}}}} {{{goals}}}
{"[[Eldor Shomurodov]]", "UZB", 0, 7, 0, 0 },
{{#ifexpr:{{{goals}}}=1|goal|goals}} scored{{#if:{{{players|}}}|&nbsp;by {{{players}}}
{"[[Otabek Shukurov]]", "UZB", 0, 1, 0, 0 },
{{#ifexpr:{{{players}}}=1|player|different players}}
{"[[Islom Tukhtakhujaev]]", "UZB", 0, 1, 0, 0 },
{{#if:{{{own goals|}}}|&nbsp;(with {{{own goals}}} of them credited as {{#ifexpr:{{{own goals}}}=1|an own goal|own goals}})|}}|}} in {{{matches}}}
{{#ifexpr:{{{matches}}}=1|match|matches}}, for an average of {{#expr:{{{goals}}}/{{{matches}}} round 2}}
{{#ifexpr:({{{goals}}}/{{{matches}}} round 2)=1|goal|goals}} per match
{{#if:{{{updated|}}}|&nbsp;(as of {{{updated}}})}}.}}{{#if:{{{bold|}}}|{{#if:{{{assists|}}}||&nbsp;}}
Players highlighted in '''bold''' are still active in the competition.
|}}{{#if:{{{further|}}}|{{#if:{{{assists|}}}||&nbsp;}}{{{further}}}|}}
{{#if:{{{extra|}}}|{{{extra}}}{{clear}}|}}
--]]
local statNumber = g.args['goals'] or g.args['assists'] or 0
local matches = g.args['matches']
local statType = "goal"
if g.args['assists'] then statType = "assist" end
if g.args['clean sheets'] then statType = "clean sheet" end
local ongoing = g.args['ongoing']
local text1 = "There"
if g.args['lc'] then text1 = "there" end
local text2 = "were"
if ongoing then text2 = "have been" end
local updateString = ""
local averageString = ""
local goalPlural = "s" -- goal(s)
if g.args['goals'] and tonumber(g.args['goals']) == 1 then
goalPlural = ""
text2 = "was"
if ongoing then text2 = "has been" end
end
local matchPlural = "es" -- match(es)
if g.args['matches'] and tonumber(g.args['matches']) == 1 then matchPlural = "" end
-- auto version: string.format(" in %d match%s, for an average of %."..precision.."g goal%s per match", matches, pluralMatches, average, pluralAverage)
if g.args['goals'] and g.args['matches'] then
local averageGoals = g.args['goals']/g.args['matches']
local avGoalPlural = "s"
if averageGoals == 1 then avGoalPlural = "" end
averageString = string.format(" in %d match%s, for an average of %.3g goal%s per match", g.args['matches'], matchPlural, averageGoals, avGoalPlural)
end
if g.args['updated'] and g.args['updated'] ~= "complete" then
updateString = "&nbsp;(as of " ..g.args['updated'] .. ")"
end
local sep = "."
if g.args['sep'] then sep = g.args['sep'] end
local text = ""
if g.args['goals'] then
text = string.format("%s %s %d %s%s scored%s",
text1, text2, statNumber, statType, goalPlural, averageString..updateString..sep)
end
text = p.addAdditionHeaderText(text) -- handles template parameters bold, further, extra
--[[ {{#if:{{{30 goals|{{{30 assists|}}}}}}|'''30 {{#if:{{{assists|}}}|assists|goals}}'''
<div class="div-col columns column-count column-count-3" style="column-count:3;">
{{#if:{{{assists|}}}|{{{30 assists}}}|{{{30 goals}}}}}</div>|}}]]
local output = "\n"
local number = 30
local totalGoals = 0
while number > -4 do -- for the each goals/assists
local entry = g.args[number .. ' goals'] or g.args[number .. ' goal']
or g.args[number .. ' assists'] or g.args[number .. ' assist']
or g.args[number .. ' clean sheets'] or g.args[number .. ' clean sheet']
if number < 0 then
entry = g.args[math.abs(number) .. ' own goals'] or g.args[math.abs(number) .. ' own goal']
statType = "own goal"
end
local plural = "s"
if number == 1 or number == -1 then plural = "" end
if entry then -- do we have goals/assists for this number
 
output = output .. "\n'''" .. tostring(math.abs(number)) .. " " .. statType .. plural .. "'''\n"
-- Vietnam
.. p.openList(frame) .. "\n" .. entry .. p.closeList(frame)
{"[[Đỗ Duy Mạnh]]", "VIE", 0, 1, 0, 0 },
totalGoals = p.countGoals(entry, number, totalGoals)
{"[[Nguyễn Quang Hải (footballer, born 1997)|Nguyễn Quang Hải]]", "VIE", 0, 2, 0, 0 },
end
{"[[Nguyễn Tiến Linh]]", "VIE", 0, 5, 0, 0 },
{"[[Nguyễn Công Phượng]]", "VIE", 0, 1, 0, 0 },
number = number -1
{"[[Quế Ngọc Hải]]", "VIE", 0, 2, 0, 0 },
end
{"[[Trần Minh Vương]]", "VIE", 0, 1, 0, 0 },
{"[[Vũ Văn Thanh]]", "VIE", 0, 1, 0, 0 },
if statType == "goal" or statType == "own goal" then
 
if g.args['goals'] and totalGoals ~= tonumber(g.args['goals']) then
-- Yemen
mw.addWarning("WARNING. Mismatch between number of goals listed (" .. totalGoals .. ") and goals parameter (" .. g.args['goals'] .. ").")
{"[[Omar Al-Dahi]]", "YEM", 0, 2, 0, 0 },
end
{"[[Nasser Al-Gahwashi]]", "YEM", 0, 1, 0, 0 },
end
{"[[Abdulwasea Al-Matari]]", "YEM", 0, 1, 0, 0 },
{"[[Mohsen Qarawi]]", "YEM", 0, 2, 0, 0 },
--{{#if:{{{bottom|}}}|{{small|{{{bottom_text}}}}} <div class="div-col columns column-count column-count-3" style="column-count:3;"> {{{bottom}}}</div>|}}{{#if:{{{source|}}}|{{smaller|Source: {{{source}}}}}|}}
}
local footerText = g.args['footer-text'] or g.args['bottom'] or ""
 
local footerHeading = g.args['footer-heading'] or g.args['bottom-text'] or ""
-- all competition own goal scorers
local footer = ""
data.owngoalscorers = {
if footerText ~= "" then
-- player name, country, { OG in R1, "R1 OG opponents" }, { OG in R2, "R2 OG opponents" }, { OG in R3, "R3 OG opponents" }, { OG in R4, "R4 OG opponents" }
local heading = ""
{"[[Ovays Azizi]]", "AFG", 0, { 1, "India" }, 0, 0 },
if footerHeading ~= "" then
{"[[Sor Rotana]]", "CAM", 0, { 1, "Iran" }, 0, 0 },
heading = '<p>' .. footerHeading .. '</p>'
{"[[Soeuy Visal]]", "CAM", 0, { 1, "Iran" }, 0, 0 },
end
{"[[Zhang Linpeng]]", "CHN", 0, { 1, "Syria" }, 0, 0 },
footer = '\n' .. heading .. p.openList(frame) .. '\n' .. footerText .. p.closeList(frame)
{"[[Chen Wei-chuan]]", "TPE", 0, { 1, "Kuwait" }, 0, 0 },
end
{"[[Marcus Lopez]]", "GUM", 0, { 1, "Philippines" }, 0, 0 },
{"[[Travis Nicklaw]]", "GUM", 0, { 1, "Maldives" }, 0, 0 },
{"[[Fung Hing Wa]]", "HKG", 0, { 1, "Iraq" }, 0, 0 },
--{{#if:{{{source|}}}|{{small|Source: {{{source}}}}}|}}
{"[[Khash-Erdene Tuya]]", "MNG", 0, { 1, "Japan" }, 0, 0 },
local source = g.args['source'] or ""
{"[[Irfan Fandi]]", "SIN", 0, { 1, "Uzbekistan" }, 0, 0 },
if source ~= "" then source = "<small>Source: " .. source .. "</small>" end
}
 
return text .. output .. footer .. source
return data
end
return p