Skip to content
Merged
3 changes: 2 additions & 1 deletion lua/wikis/ageofempires/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')
Expand Down Expand Up @@ -131,7 +132,7 @@ function MatchLegacy._convertParameters(match2)
match[prefix .. 'flag'] = player.flag
match.extradata[prefix .. 'name'] = player.displayname
elseif opponent.type == Opponent.team then
match[prefix] = mw.ext.TeamTemplate.raw(opponent.template).page
match[prefix] = TeamTemplate.getRaw(opponent.template).page
match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}
for i, player in pairs(opponentmatch2players) do
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/ageofempires/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local Operator = Lua.import('Module:Operator')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
Expand Down Expand Up @@ -94,7 +95,7 @@ function MatchFunctions.readOpponent(match, opponentIndex, options)
local manualPlayersInput = MatchGroupInputUtil.extractManualPlayersInput(match, opponentIndex, opponentInput)
substitutions = manualPlayersInput.substitutions
-- Change compared to commons MatchGroupInputUtil.readOpponent
local template = mw.ext.TeamTemplate.raw(opponent.template or '') or {}
local template = TeamTemplate.getRawOrNil(opponent.template) or {}
opponent.players = MatchGroupInputUtil.readPlayersOfTeam(
template.page or '',
manualPlayersInput,
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Logic = Lua.import('Module:Logic')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local UpcomingMatches = Lua.import('Module:Matches Player')

local Injector = Lua.import('Module:Widget/Injector')
Expand Down Expand Up @@ -112,7 +113,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args)
end

if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getPageName(args.team2)
end

return lpdbData
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/arenafps/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')

Expand Down Expand Up @@ -68,7 +69,7 @@ function MatchLegacy._convertParameters(match2)
local opponent = match2.match2opponents[index] or {}
local opponentmatch2players = opponent.match2players or {}
if opponent.type == 'team' then
match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template)
match[prefix] = TeamTemplate.getRaw(opponent.template).page
Comment thread
ElectricalBoy marked this conversation as resolved.
match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}
Array.forEach(opponentmatch2players, function(player)
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/battalion/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')

Expand Down Expand Up @@ -74,7 +75,7 @@ function MatchLegacy._convertParameters(match2)
local opponent = match2.match2opponents[opponentIndex] or {}
local opponentmatch2players = opponent.match2players or {}
if opponent.type == 'team' then
match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template)
match[prefix] = TeamTemplate.getRaw(opponent.template).page
Comment thread
ElectricalBoy marked this conversation as resolved.
match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}
for playerIndex = 1, 10 do
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/brawlstars/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')
local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
Expand Down Expand Up @@ -107,7 +108,7 @@ function MatchLegacy._convertParameters(match2)
local opponentmatch2players = opponent.match2players or {}
if opponent.type == 'team' then
match.extradata['team' .. index .. 'icon'] = opponent.icon
match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template)
match[prefix] = TeamTemplate.getRaw(opponent.template).page
Comment thread
ElectricalBoy marked this conversation as resolved.
match[prefix .. 'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}

Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/callofduty/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')
Expand Down Expand Up @@ -101,7 +102,7 @@ function MatchLegacy._convertParameters(match2)
local opponent = match2.match2opponents[index] or {}
local opponentmatch2players = opponent.match2players or {}
if opponent.type == 'team' then
match[prefix] = mw.ext.TeamTemplate.teampage(opponent.template)
match[prefix] = TeamTemplate.getRaw(opponent.template).page
Comment thread
ElectricalBoy marked this conversation as resolved.
match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}
for i = 1,10 do
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/AutomaticPointsTable/Display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Lua = require('Module:Lua')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')

Expand Down Expand Up @@ -144,7 +145,7 @@ end

function TableRow:nameCell(team)
local lastAlias = team.aliases[#team.aliases]
local teamDisplay = team.display and team.display or mw.ext.TeamTemplate.team(lastAlias)
local teamDisplay = team.display and team.display or OpponentDisplay.InlineTeamContainer{template = lastAlias}
local nameCell = self:baseCell(teamDisplay, team.bg):addClass('name-cell')
table.insert(self.cells, nameCell)
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')

local PointsDivTable = Class.new(
function(self, pointsData, tournaments, positionBackgrounds, limit)
Expand Down Expand Up @@ -123,7 +124,7 @@ end

function TableRow:nameCell(team)
local lastAlias = team.aliases[#team.aliases]
local teamDisplay = team.display and team.display or mw.ext.TeamTemplate.team(lastAlias)
local teamDisplay = team.display and team.display or OpponentDisplay.InlineTeamContainer{template = lastAlias}
local nameCell = self:baseCell(teamDisplay, team.bg):addClass('name-cell')
table.insert(self.cells, nameCell)
return self
Expand Down
33 changes: 16 additions & 17 deletions lua/wikis/commons/Infobox/Person.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ local Logic = Lua.import('Module:Logic')
local Lpdb = Lua.import('Module:Lpdb')
local Namespace = Lua.import('Module:Namespace')
local NameOrder = Lua.import('Module:NameOrder')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local AgeCalculation = Lua.import('Module:AgeCalculation')
Expand All @@ -40,6 +42,7 @@ local Center = Widgets.Center
local Builder = Widgets.Builder
local Customizable = Widgets.Customizable
local TeamHistoryWidget = Lua.import('Module:Widget/Infobox/TeamHistory')
local WidgetUtil = Lua.import('Module:Widget/Util')

---@class Person: BasicInfobox
---@operator call(Frame): Person
Expand Down Expand Up @@ -325,7 +328,7 @@ end
function Person:_setLpdbData(args, links, status, personType)
local teamLink, teamTemplate
local team = args.teamlink or args.team
local teamRaw = team and mw.ext.TeamTemplate.raw(team) or nil
local teamRaw = team and TeamTemplate.getRawOrNil(team) or nil
if teamRaw then
teamLink = teamRaw.page
teamTemplate = teamRaw.templatename
Expand Down Expand Up @@ -369,7 +372,7 @@ function Person:_setLpdbData(args, links, status, personType)
for teamKey, otherTeam, teamIndex in Table.iter.pairsByPrefix(args, 'team', {requireIndex = false}) do
if teamIndex > 1 then
otherTeam = args[teamKey .. 'link'] or otherTeam
lpdbData.extradata[teamKey] = (mw.ext.TeamTemplate.raw(otherTeam) or {}).templatename
lpdbData.extradata[teamKey] = TeamTemplate.resolve(otherTeam)
end
end

Expand Down Expand Up @@ -456,27 +459,23 @@ end
--- Allows for overriding this functionality
--- e.g. to add faction icons to the display for SC2, SC, WC
---@param args table
---@return string
---@return Renderable[]
function Person:nameDisplay(args)
local team = string.lower(args.teamicon or args.ttlink or args.teamlink or args.team or '')
local icon = mw.ext.TeamTemplate.teamexists(team)
and mw.ext.TeamTemplate.teamicon(team) or ''
local icon = TeamTemplate.exists(team)
and OpponentDisplay.InlineTeamContainer{template = team, style = 'icon'} or nil

local team2 = string.lower(args.team2icon or args.ttlink2 or args.team2link or args.team2 or '')
local icon2 = mw.ext.TeamTemplate.teamexists(team2)
and mw.ext.TeamTemplate.teamicon(team2) or ''
local icon2 = TeamTemplate.exists(team2)
and OpponentDisplay.InlineTeamContainer{template = team2, style = 'icon'} or nil

local name = args.id or mw.title.getCurrentTitle().text

local display = name
if not String.isEmpty(icon) then
display = icon .. ' ' .. name
end
if not String.isEmpty(icon2) then
display = display .. ' ' .. icon2
end

return display
return Array.interleave(
WidgetUtil.collect(icon, name, icon2),
' '
)
end

--- Allows for overriding this functionality
Expand Down Expand Up @@ -545,7 +544,7 @@ function Person:_createTeam(team, link)
end
---@cast link -nil

local teamRaw = mw.ext.TeamTemplate.raw(link)
local teamRaw = TeamTemplate.getRawOrNil(link)
if teamRaw then
link, team = teamRaw.page, teamRaw.name
end
Expand Down Expand Up @@ -602,7 +601,7 @@ function Person:getCategories(args, birthDisplay, personType, status)
table.insert(categories, personType .. 's with unknown birth date')
end

if String.isNotEmpty(team) and not mw.ext.TeamTemplate.teamexists(team) then
if String.isNotEmpty(team) and not TeamTemplate.exists(team) then
table.insert(categories, 'Players with invalid team')
end

Expand Down
14 changes: 6 additions & 8 deletions lua/wikis/commons/Infobox/Person/User.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')

local Person = Lua.import('Module:Infobox/Person')

---@class InfoboxUser: Person
---@operator call(Frame): InfoboxUser
local User = Class.new(Person)

---@return string
---@return VNode[]
function User:_getFavouriteTeams()
local foundArgs = self:getAllArgsForBase(self.args, 'fav-team-')

local display = ''
for _, item in ipairs(foundArgs) do
local team = item:lower():gsub('_', ' ')
display = display .. mw.ext.TeamTemplate.teamicon(team)
end

return display
return Array.map(foundArgs, function (favouriteTeam)
return OpponentDisplay.InlineTeamContainer{template = favouriteTeam, style = 'icon'}
end)
end

---@param base string
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/commons/Infobox/Person/User/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function CustomInjector:parse(id, widgets)
if not String.isEmpty(args['fav-team-1']) then
Array.appendWith(widgets,
Title{children = 'Favorite Teams'},
Center{children = {self.caller:_getFavouriteTeams()}}
Center{children = self.caller:_getFavouriteTeams()}
)
end
elseif
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PlayerIntroduction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Flags = Lua.import('Module:Flags')
local Logic = Lua.import('Module:Logic')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Roles = Lua.import('Module:Roles')

Expand Down Expand Up @@ -607,7 +608,7 @@ end
function PlayerIntroduction._displayTeam(team, date)
team = team:gsub('_', ' ')

local rawTeam = mw.ext.TeamTemplate.raw(team, date)
local rawTeam = TeamTemplate.getRawOrNil(team, date)
if rawTeam then
return ' [[' .. rawTeam.page .. '|' .. rawTeam.name .. ']]'
end
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PortalPlayers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local Logic = Lua.import('Module:Logic')
local Links = Lua.import('Module:Links')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Opponent = Lua.import('Module:Opponent/Custom')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')
Expand Down Expand Up @@ -264,7 +265,7 @@ function PortalPlayers:row(player, isPlayer)
:wikitext(self.showLocalizedName and (' (' .. player.localizedname .. ')') or nil)

local role = not isPlayer and mw.language.getContentLanguage():ucfirst((player.extradata or {}).role or '') or ''
local teamText = mw.ext.TeamTemplate.teamexists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{
local teamText = TeamTemplate.exists(player.team) and tostring(OpponentDisplay.InlineTeamContainer{
template = player.team, displayType = 'standard'
}) or ''
if String.isNotEmpty(role) and String.isEmpty(teamText) then
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PrizePool/Award/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Lua = require('Module:Lua')

local Class = Lua.import('Module:Class')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local BasePlacement = Lua.import('Module:PrizePool/Placement/Base')

Expand Down Expand Up @@ -55,7 +56,7 @@ function AwardPlacement:_getLpdbData(...)
local opponentType = opponent.opponentData.type

if opponentType == Opponent.team then
local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {}
local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {}

participant = teamTemplate.page or ''
if self.parent.options.resolveRedirect then
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PrizePool/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Ordinal = Lua.import('Module:Ordinal')
local PlacementInfo = Lua.import('Module:Placement')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local BasePlacement = Lua.import('Module:PrizePool/Placement/Base')

Expand Down Expand Up @@ -223,7 +224,7 @@ function Placement:_getLpdbData(...)
local opponentType = opponent.opponentData.type

if opponentType == Opponent.team then
local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {}
local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {}
image = teamTemplate.image
imageDark = teamTemplate.imagedark
elseif opponentType == Opponent.solo then
Expand Down
15 changes: 5 additions & 10 deletions lua/wikis/commons/Ratings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local FnUtil = Lua.import('Module:FnUtil')
local Json = Lua.import('Module:Json')
local Lpdb = Lua.import('Module:Lpdb')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local String = Lua.import('Module:StringUtils')

--- Liquipedia Ratings (LPR)
Expand Down Expand Up @@ -409,16 +410,10 @@ end
function Ratings.transfer(frame)
local args = Arguments.getArgs(frame)
local date = os.time(Date.parseIsoDate(args.date))
local from = mw.ext.TeamTemplate.teampage(args.from, args.date)
local to = String.isNotEmpty(args.to) and mw.ext.TeamTemplate.teampage(args.to, args.date) or ''
if String.startsWith(from, '<div class=') then
return from
elseif String.startsWith(to, '<div class=') then
return to
else
Ratings._storeTransfer(from, to, date, tonumber(args.mod))
end
return '<code>' .. args.date .. ': ' .. from .. ' --> ' .. to .. '</code><br>'
local from = TeamTemplate.getRaw(args.from, args.date)
local to = String.isNotEmpty(args.to) and TeamTemplate.getRaw(args.to, args.date) or {}
Ratings._storeTransfer(from.page, to.page, date, tonumber(args.mod))
return '<code>' .. args.date .. ': ' .. from.page .. ' --> ' .. (to.page or '') .. '</code><br>'
Comment thread
ElectricalBoy marked this conversation as resolved.
end

return Ratings
3 changes: 2 additions & 1 deletion lua/wikis/commons/SeriesMedalStats/Participant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Opponent = Lua.import('Module:Opponent/Custom')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')
Expand Down Expand Up @@ -48,7 +49,7 @@ function MedalStats:_processData()
---@param teamTemplate string
---@return string?
local resolveTeamToIdentifier = function(teamTemplate)
local rawData = mw.ext.TeamTemplate.raw(teamTemplate)
local rawData = TeamTemplate.getRawOrNil(teamTemplate)

if not rawData or not rawData.page then return end

Expand Down
Loading
Loading