Module:Infobox television season name
Appearance
![]() | This Lua module is used on approximately 10,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Module:Infobox television season name is used to validate or create a formatted season link for use in Template:Infobox television season.
Usage
{{#invoke:Infobox television season name|isPrevOrNextSeasonLinkValid}}
{{#invoke:Infobox television season name|isPrevSeasonLinkValid}}
{{#invoke:Infobox television season name|isNextSeasonLinkValid}}
{{#invoke:Infobox television season name|getPrevSeasonArticle}}
{{#invoke:Infobox television season name|getNextSeasonArticle}}
{{#invoke:Infobox television season name|getSeasonWord}}
{{#invoke:Infobox television season name|getSubHeader}}
{{#invoke:Infobox television season name|getListOfEpisodes|link}}
Parameter list
The following parameters can be used as named parameters or nameless positional parameters.
Parameter | Explanation | Status |
---|---|---|
title
|
The title of TV program. If not supplied, will use the article title. | optional |
link
|
Only for getListOfEpisodes. The plain link to the list of episode article. If not supplied, will create one based on the series name. | optional |
Function list
Function | Explanation |
---|---|
checkAll
|
Checks if the next or previous season have a created article or redirect. |
checkPrevSeason
|
Checks if the previous season has a created article or redirect. |
checkNextSeason
|
Checks if the next season has a created article or redirect. |
getPrevSeasonArticle
|
Retrieves the previous season article title. |
getNextSeasonArticle
|
Retrieves the next season article title. |
getSeasonWord
|
Returns either the word "season" or "series" as used in the disambiguation of the article title. |
getInfoboxSubHeader
|
Returns the relevant text for the sub-header field. The text is returned in the format of Season # or Series # , depending on either what the article disambiguation uses, or on manually entered parameters of the infobox.
|
getListOfEpisodes
|
Returns the formatted link to the list of episodes article in the style of: [[List of <series name> <disambiguation if present> episodes <seasons if present>|List of ''<series name>'' episodes <seasons if present>]] . The link will only return if the page exists.
|
Examples
isPrevOrNextSeasonLinkValid
- Code:
{{#invoke:Infobox television season name|isPrevOrNextSeasonLinkValid|title=Dallas (1978 TV series, season 7)}}
- Produces:
Script error: The function "isPrevOrNextSeasonLinkValid" does not exist.
getPrevSeasonArticle
- Code:
{{#invoke:Infobox television season name|getPrevSeasonArticle|title=Dallas (1978 TV series, season 7)}}
- Produces:
Season -1
getNextSeasonArticle
- Code:
{{#invoke:Infobox television season name|getNextSeasonArticle|title=Lost (season 3)}}
- Produces:
Season 1
-- This module requires the use of Module:Arguments.
local getArgs = require('Module:Arguments').getArgs
local pipedLink
local p = {}
-- Local function which is used to create an pipped article link.
local function createArticleTitleWithPipedLink(article)
return "[[" .. article .. "|" .. pipedLink .. "]]"
end
-- Local function which is used to check if the given article exists.
local function checkArticle(articleName)
local article = mw.title.new(articleName)
if (article ~= nil and article.exists) then
return "true"
else
return nil
end
end
-- Local function which is used to create a TV season link.
local function createLink(args, number)
local showName = args[1] or args['show_name']
if (showName == nil) then
showName = ""
else
showName = showName .. " "
end
local preSeasonQualifier = args[2] or args['pre_season_qualifier']
if (preSeasonQualifier == nil) then
preSeasonQualifier = ""
else
preSeasonQualifier = preSeasonQualifier .. " "
end
local seasonQualifier = args[3] or args['season_qualifier']
if (seasonQualifier == nil) then
seasonQualifier = ""
else
seasonQualifier = seasonQualifier .. " "
end
local seasonType = args[4] or args['season_type']
if (seasonType == nil) then
seasonType = "season"
end
seasonType = seasonType .. " "
local seasonNumber = args[5] or args['season_number']
if (seasonNumber == nil) then
seasonNumber = 0
end
if (tonumber(seasonNumber) == nil) then
return ""
else
seasonNumber = seasonNumber + number
pipedLink = seasonType:gsub("^%l", string.upper) .. seasonNumber
return showName .. preSeasonQualifier .. "(" .. seasonQualifier .. seasonType .. seasonNumber .. ")"
end
end
-- Local function which is called to create a TV season link for the next season.
-- Passes the value "1" to increment the current season number.
local function createNextSeasonArticle(args)
return createLink(args, 1)
end
-- Local function which is called to create a TV season link for the previous season.
-- Passes the value "-1" to decrement the current season number.
local function createPreviousSeasonArticle(args)
return createLink(args, -1)
end
--[[
Wrapper function which handles the processing of the arguments
from multiple public invoked functions.
Parameters:
-- |show_name= — required; The title of TV program.
-- |pre_season_qualifier= — optional; For cases where disambiguation before the season is required
(e.g. the pre-season qualifier for Dallas (1978 TV series) (season 7) is (1978 TV series)).
-- |season_qualifier= — optional; For cases where disambiguation (typically of the show's origin country) before the season type is required
(e.g. the season qualifier for The Apprentice (U.S. season 2) is U.S.).
-- |season_type= — optional; To determine the usage of the word "season" for American-based shows, or "series" for shows using British-English.
-- |season_number= — optional; Season number. The N season of this particular show.
--]]
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame)
return p[funcName](args)
end
end
p.checkNextSeason = makeInvokeFunc('_checkNextSeason')
--[[
Public function which is used to check if the next season has
a created article or redirect.
Parameters: See makeInvokeFunc() for documentation.
--]]
function p._checkNextSeason(args)
local seasonNumber = args[5] or args['season_number']
if (seasonNumber == nil) then
return nil
else
local articleName = createNextSeasonArticle(args)
return checkArticle(articleName)
end
end
p.checkPrevSeason = makeInvokeFunc('_checkPrevSeason')
--[[
Public function which is used to check if the previous season has
a created article or redirect.
Parameters: See makeInvokeFunc() for documentation.
--]]
function p._checkPrevSeason(args)
local seasonNumber = args[5] or args['season_number']
if (seasonNumber == nil) then
return nil
else
local articleName = createPreviousSeasonArticle(args)
return checkArticle(articleName)
end
end
p.checkAll = makeInvokeFunc('_checkAll')
--[[
Public function which is used to check if the next or previous season have
a created article or redirect.
Parameters: See makeInvokeFunc() for documentation.
--]]
function p._checkAll(args)
if (p._checkPrevSeason(args) == "true") then
return "true"
else
return p._checkNextSeason(args)
end
end
p.getNextSeasonArticle = makeInvokeFunc('_getNextSeasonArticle')
--[[
Public function which is used to get the next season article title.
Parameters: See makeInvokeFunc() for documentation.
--]]
function p._getNextSeasonArticle(args)
local articleTitle = createNextSeasonArticle(args)
return createArticleTitleWithPipedLink(articleTitle)
end
p.getPrevSeasonArticle = makeInvokeFunc('_getPrevSeasonArticle')
--[[
Public function which is used to get the previous season article title.
Parameters: See makeInvokeFunc() for documentation.
--]]
function p._getPrevSeasonArticle(args)
local articleTitle = createPreviousSeasonArticle(args)
return createArticleTitleWithPipedLink(articleTitle)
end
return p