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 Functions  



1.1  above_title  





1.2  validate_values  







2 See also  





3 Maintenance categories  














Module:Infobox television






Cebuano
فارسی
ि
Kurdî


Română

Simple English
Tagalog

 

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  



Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


This is an old revision of this page, as edited by Gonnym (talk | contribs)at18:04, 27 September 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff)  Previous revision | Latest revision (diff) | Newer revision  (diff)

Module:Infobox television is used to validate parameter values for Template:Infobox television.

Functions

above_title

Returns the text used for the |above= field of the infobox.

validate_values

Returns the relevant maintenance categories based on the {{Infobox television}} values validated.

See also

Maintenance categories

The module places relevant pages in the following maintenance categories:

--- @module
local p = {}

local maintenance_categories = {
 image_values_without_an_image = "[[Category:Pages using infobox television with image-related values without an image]]",
 unnecessary_title_parameter = "[[Category:Pages using infobox television with unnecessary name parameter]]",
 non_matching_title = "[[Category:Pages using infobox television with non-matching title]]",
 flag_icon = "[[Category:Pages using infobox television with flag icon]]",
 dates_incorrectly_formatted = "[[Category:Pages using infobox television with nonstandard dates]]",
 manual_display_title = "[[Category:Pages using infobox television with unnecessary manual displaytitle]]",
}

--- Returns a maintenance category if the dates aren't formatted correctly with
--- {{Start date}} and {{End date}} templates.
---
--- @param start_date string The start date parameter.
--- @param end_date string The end date parameter.
--- @return string
local function are_dates_formatted_correctly(start_date, end_date)
 if start_date and not string.find(start_date, "dtstart") then
  return maintenance_categories.dates_incorrectly_formatted
 end

 if end_date and (not string.find(end_date, "dtend") and end_date ~= "present") then
  return maintenance_categories.dates_incorrectly_formatted
 end

 return ""
end

--- Returns a maintenance category if a {{Italic title}} or {{DISPLAYTITLE}} template is used.
---
---@return string
local function has_display_title()
 local page_text = mw.title.getCurrentTitle():getContent()
 if string.find(page_text, "[Ii]talic title") or string.find(page_text, "DISPLAYTITLE") then
  return maintenance_categories.manual_display_title
 end
 return ""
end

--- Returns a maintenance category if a flag icon is used.
---
--- All the infobox values are checked.
---
--- @param args table
--- @return string
local function has_flag_icon(args)
 for _, v in pairs(args) do
  if string.find(v, "flagicon") then
   return maintenance_categories.flag_icon
  end
 end
 return ""
end

--- Returns a maintenance category if there is no image file while image auxiliary values are present.
---
--- Infobox parameters checked:
--- - |image=
--- - |image_size=
--- - |image_upright=
--- - |image_alt=
--- - |alt=
--- - |caption=
---
--- @param args table
--- @return string
local function are_image_auxiliary_values_used_for_no_image(args)
 if args.image then
  return ""
 end

 if args.image_size or args.image_upright or args.image_alt or args.alt or args.caption then
  return maintenance_categories.image_values_without_an_image
 end

 return ""
end

--- Returns a maintenance category if the infobox title is equal to the article title.
---
--- Infobox parameters checked:
--- - |name=
---
--- The function currently checks if the infobox title is equal to the article title while ignoring styling such as:
--- - nowrap spans.
--- - line breaks.
---
--- |page_title_test= is used for testing only.
---
--- @param frame table
--- @param args table
--- @return string
local function is_infobox_title_equal_to_article_title(frame, args)
 if not args.name then
  return ""
 end

 local article_title = args.page_title_test
 if not args.page_title_test then
  article_title = mw.title.getCurrentTitle().text
 end

 -- Remove disambiguation.
 local page_name, _ = string.gsub(article_title, "%s+%b()$", "")

 -- Remove nowrap span.
 if string.find(args.name, "nowrap") then
  local title = frame:expandTemplate{title = "Strip tags", args = {args.name}}
  if title == page_name then
   return ""
  end
  return maintenance_categories.non_matching_title
 end

 -- Remove line breaks and additional spaces as a result.
 if string.find(args.name, "<br%s?/?>") then
  local title, _ = string.gsub(args.name, "<br%s?/?>", "")
  title, _ = string.gsub(title, "  ", " ")
  if title == page_name then
   return ""
  end
  return maintenance_categories.non_matching_title
 end

 if args.name == page_name then
  return maintenance_categories.unnecessary_title_parameter
 end

 -- Article and infobox titles do not match.
 return maintenance_categories.non_matching_title
end

--- Returns the relevant maintenance categories based on the {{Infobox television}} values validated.
---
--- @param frame table
--- @return string
function p.validate_values(frame)
 local getArgs = require("Module:Arguments").getArgs
 local args = getArgs(frame)

 local categories = {}
 table.insert(categories, is_infobox_title_equal_to_article_title(frame, args))
 table.insert(categories, has_display_title())
 table.insert(categories, are_image_auxiliary_values_used_for_no_image(args))
 table.insert(categories, has_flag_icon(args))
 table.insert(categories, are_dates_formatted_correctly(args.first_aired or args.released, args.last_aired))

 return table.concat(categories, "")
end


return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Infobox_television&oldid=1046844686"

Categories: 
Television-related modules
Infobox modules
Modules that add a tracking category
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 27 September 2021, at 18:04 (UTC).

This version of the page has been revised. Besides normal editing, the reason for revision may have been that this version contains factual inaccuracies, vandalism, or material not compatible with the Creative Commons Attribution-ShareAlike License.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki