Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  














Module:Fiction-based redirects to list entries category handler/RedirectType






کوردی
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 

< Module:Fiction-based redirects to list entries category handler

Module:Fiction-based redirects to list entries category handler/RedirectType handles the RedirectType class which is used in Module:Fiction-based redirects to list entries category handler.

Usage

local redirectType = require('Module:Fiction-based redirects to list entries category handler/RedirectType')
local typeList = redirectType.getRedirectTypes()
local defaultType = redirectType.getDefaultType(typeList)

Use local categoryType = typeList[i] (i = a number between 1 and 4) to retrieve the wanted categoryType. Once the categoryType has been retrieved, you can access the following functions:

categoryType:getMainCategory(mainCategory)
categoryType:getTopLevelCategory(media)
categoryType:getCategory(category)
categoryType:setTemplateAsArrowverse(articleTitle)

require("strict")

local libraryUtil = require("libraryUtil")

local p = {}

local franchiseList = {
 [1] = "Module:Arrowverse redirect category handler"
}

--[[
RedirectType class.
--]]
local function RedirectType(o)
 local RedirectType = o or {redirectType = "", defaultCategory = "", topLevelCategory = "", template = "", from = "", suffix = "", isFranchise = false}
 local checkSelf = libraryUtil.makeCheckSelfFunction("Fiction-based redirects to list entries category handler", "RedirectType", RedirectType, "Fiction-based redirects to list entries category handler object")

--[[
Public function which is used to retrieve the main category for a specific type.
--]]
 function RedirectType:getMainCategory(mainCategory)
  return RedirectType:getCategory(mainCategory)
 end
 
--[[
Public function which is used to retrieve the top level category (or categories) for a specific type and media format.
If no media format is passed, the function returns the default top level category.
--]]
 function RedirectType:getTopLevelCategory(mediaList)
  if (mediaList and #mediaList > 0) then
   local categories = ""
   for i = 1, #mediaList do
    local category
    if ((RedirectType.redirectType == "episode") and (string.lower(mediaList[i]) == "television")) then
     category = RedirectType:getCategory(RedirectType.defaultCategory)
    else
     category = RedirectType:getCategory(RedirectType.topLevelCategory)
    end
    categories = categories .. category:gsub("{media}", mediaList[i])
   end
   return categories
  else
   return RedirectType.defaultCategory
  end
 end 

--[[
Public function which is used to retrieve a category for a specific type.
--]]
 function RedirectType:getCategory(category)
  return category:gsub("{type}", RedirectType.redirectType)
 end

--[[
Public function which is used to check if the category belongs to a special franchise, such as the Arrowverse.
If the category is part of that franchise, returns the series name, else returns nil.
--]]
 function RedirectType:isCategorySpecialFranchise(series)
  local seriesParameter
  if (RedirectType.redirectType == "character" or RedirectType.redirectType == "element" or RedirectType.redirectType == "location") then
   
   for i, v in pairs(franchiseList) do
    local seriesModule = require(v)
    local seriesList = seriesModule.getSeriesList()
    for i, v in pairs(seriesList) do
     local currentTVSeries = seriesList[i]
     if (series == currentTVSeries.seriesName) then
      seriesParameter = currentTVSeries.argName
      break
     end
    end
   
    local franchise = seriesModule.getFranchiseName()
    if (series == franchise) then
     seriesParameter = franchise
     RedirectType.isFranchise = true
    end
    
    if (seriesParameter) then
     if (i == 1) then
      RedirectType:setTemplateAsArrowverse()
     end
     break
    end
   end
  end
  
  if (seriesParameter) then
   return seriesParameter
  else
   return nil
  end
 end

--[[
Public function which is used to change the type of template to the Arrowverse specific version.
--]] 
 function RedirectType:setTemplateAsArrowverse()
  RedirectType.template = "Arrowverse " .. RedirectType.redirectType .. " redirect"
 end

 return RedirectType
end

--[[
Public function which is used to retrieve the list of redirect types.
--]]
function p.getRedirectTypes()
 return {
  RedirectType{
   redirectType = "character",
   defaultCategory = "[[Category:Redirects from fictional characters]]",
   topLevelCategory = "[[Category:{media} character redirects to lists]]",
   template = "Fictional character redirect",
   from = "fictional characters",
   suffix = "redirects to lists"
  },
  RedirectType{
   redirectType = "element",
   defaultCategory = "[[Category:Fictional element redirects]]",
   topLevelCategory = "[[Category:{media} element redirects to lists]]",
   template = "Fictional element redirect",
   from = "fictional elements",
   suffix = "redirects to lists"
  },
  RedirectType{
   redirectType = "episode",
   defaultCategory = "[[Category:Episode redirects to lists]]",
   topLevelCategory = "[[Category:{media} episode redirects to lists]]",
   template = "Television episode redirect handler",
   from = "episodes",
   suffix = "redirects to lists"
  },
  RedirectType{
   redirectType = "location",
   defaultCategory = "[[Category:Redirects from fictional locations]]",
   topLevelCategory = "[[Category:{media} location redirects]]",
   template = "Fictional location redirect",
   from = "fictional locations or settings",
   suffix = "redirects"
  }
 }

end

--[[
Public function which is used to retrieve a default redirect type.
--]]
function p.getDefaultType(typeList)
 return typeList[3]
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Fiction-based_redirects_to_list_entries_category_handler/RedirectType&oldid=1231139532"

Category: 
Television-related modules
Hidden categories: 
Wikipedia extended-confirmed-protected modules
Modules depending on under-protected modules
 



This page was last edited on 26 June 2024, at 18:00 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki