Lua error in package.lua at line 80: module 'Module:UtilsCode' not found.
local p = {}
local cargo = mw.ext.cargo
local utilsCode = require("Module:UtilsCode")
local utilsLocalization = require("Module:UtilsLocalization")
local utilsGame = require("Module:UtilsGame")
local utilsText = require('Module:UtilsText')
local utilsTable = require('Module:UtilsTable')
function p._Main (frame)
local args = frame.args
return p.Main(args["game"], args["term"], args["link"], args["plural"], args["display"], args["langcode"])
end
function p.Main(game, term, link, plural, display, langcode)
local returnedValue = ""
local fetchedTerm = p.fetchRow(game, term, langcode)
if utilsCode.IsEmpty(fetchedTerm) then
return "<span class='explain facelift-term-invalid' title='" .. utilsLocalization.MissingOrInvalidTerm(langcode) .. "'>[[" .. term .. "]]</span>[[Category:Pages With Invalid or Missing Terms]]"
else
if link == "link" then
local gameSub = utilsGame.AbbToBaseGame(game, true)
returnedValue = returnedValue .. "[[" .. fetchedTerm._pageName
if (gameSub ~= "Unknown" and game ~= utilsLocalization.Series(langcode)) then
returnedValue = returnedValue .. "#" .. gameSub
end
returnedValue = returnedValue .. "|"
else
returnedValue = returnedValue .. "<span class='term'>"
end
if not utilsCode.IsEmpty(display) then
returnedValue = returnedValue .. display
elseif plural == "plural" then
returnedValue = returnedValue .. fetchedTerm["plural"]
else
returnedValue = returnedValue .. fetchedTerm["term"]
end
if link == "link" then
returnedValue = returnedValue .. "]]"
else
returnedValue = returnedValue .. "</span>"
end
end
return returnedValue
end
-- Returns raw term
function p.fetchTerm(game, page, langcode)
return p.fetchRow(game, page, langcode)["term"]
end
function p._fetchTerm(frame)
local args = frame.args
return p.fetchTerm(args["game"], args["term"], args["langcode"])
end
-- Returns raw plural
function p.fetchPlural(game, page, langcode)
return p.fetchRow(game, page, langcode)["plural"]
end
function p._fetchPlural(frame)
local args = frame.args
return p.fetchPlural(args["game"], args["term"], args["langcode"])
end
-- Returns the table row of the specified game for the specified page.
-- Returns the entry for "Series" if not found.
function p.fetchRow(game, page, langcode)
local tables = ""
local fields = ""
local queryArgs = {}
-- If we're fetching a term in a foreign language, we check in the joint table for the correct page name
if not utilsCode.IsEmpty(langcode) then
tables = 'Terminologies = t, ChangedTitles = ct'
fields = 't._pageName = _pageName, t.games = games, t.term = term, t.plural = plural'
queryArgs = {
where = '(t._pageName = "' .. page .. '" OR ct.title = "' .. page .. '") AND ct.lang = "' .. langcode .. '"',
join = 't._pageName = ct._pageName'
}
else
tables = 'Terminologies'
fields = '_pageName, games, term, plural'
queryArgs = {
where = '_pageName = "' .. page .. '"'
}
end
local result = cargo.query( tables, fields, queryArgs )
--Looks for the game
for _, row in pairs(result) do
local games = utilsText.split(row.games)
if utilsTable.keyOf(games, game) then
return row
end
end
--Else, looks for "Series"
for _, row in pairs(result) do
local games = utilsText.split(row.games)
if utilsTable.keyOf(games, utilsLocalization.Series(langcode)) then
return row
end
end
return nil
end
return p