Mô đun:Infobox road/locations
Giao diện
local p = {}local function countries(args, country) local data = {EUR = "no", ASIA = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then return args.countries else return nil endendlocal function regions(args, country) local data = {EUR = "no", ESP = "no", ITA = "no", HRV = "no", CZE = "no", CAN = "no", CYP = "no", GRC = "no", POL = "no", HUN = "no", SVN = "no", SVK = "no", AUT = "no", TUR = "no", UKR = "no", BIH = "no", SRB = "no", SGP = "no", AUS = "no", default = "yes"} if args.communities then return "Cộng đồng tự trị:", args.communities end local yesOrNo = data[country] or data.default if yesOrNo == "no" then return "Vùng:", args.regions else return "Vùng:", nil endendlocal function states(args, country) local data = {USA = "no", IND = "no", DEU = "no", AUT = "no", MEX = "no", AUS = "no", BRA = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then return args.states else return nil endendlocal function provinces(args, country) local data = {CAN = "no", TUR = "no", THA = "no", IRN = "no", NLD = "no", ESP = "no", PHL = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then return args.provinces else return nil endendlocal function counties(args, country) local counties = args.counties local districts = args.districts local municipalities = args.municipalities local parishes = args.parishes local boroughs = args.boroughs if counties then return "Hạt", counties elseif districts then return "Huyện", districts elseif municipalities then return "Đô thị", municipalities elseif parishes then return "Giáo xứ", parishes elseif boroughs then return "Các quận", boroughs else return '', nil endendlocal function ruralMunis(args, country) local label local province = country or '' if province == "AB" then label = "Các đô thị<br />chuyên ngành và<br />nông thôn" else label = "Đô thị<br />nông nghiệp" end local data = {MB = "no", SK = "no", AB = "no", default = "yes"} local yesOrNo = data[province] or data.default if yesOrNo == "no" then return label, args.rural_municipalities else return '', nil endendlocal function divisions(args, country) local province = country or '' local data = {ON = "no", default = "yes"} local yesOrNo = data[province] or data.default if yesOrNo == "no" then return args.divisions else return nil endendlocal function cities(args, country, parameter) local data = {USA = "yes", default = "no"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then return args[parameter] else return nil endendlocal function destinations(args, country) local label if country == "GBR" then label = "[[Trạng thái chính|Các điểm đến chính]]" else label = "Các điểm đến chính" end local data = {AUS = "no", NZL = "no", GBR = "no", IRL = "no", MYS = "no", IND = "no", NPL = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then return label, args.destinations else return '', nil endendlocal function lga(args, country) local labels = {SA = "[[Các khu vực chính quyền địa phương của Nam Úc|LGA(s)]]", VIC = "[[Chính quyền địa phương ở Victoria|LGA(s)]]", NSW = "[[Các khu vực chính quyền địa phương của New South Wales|LGA(s)]]", QLD = "[[Các khu vực chính quyền địa phương của Queensland|LGA(s)]]", NT = "[[Các khu vực chính quyền địa phương của Lãnh thổ phía Bắc|LGA(s)]]", WA = "[[Các khu vực chính quyền địa phương của Tây Úc|LGA(s)]]", TAS = "[[Các khu vực chính quyền địa phương của Tasmania|LGA(s)]]", ACT = "Quận"} local data = {AUS = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then local state = args.state or '' local label = labels[state] or "[[Chính quyền địa phương ở Úc|LGA(s)]]" return label, args.lga else return '', nil endendlocal function locations(args, country) local labels = {highway = "Các khu định cư chính", ["rural road"] = "Các khu định cư chính", freeway = "Vùng ngoại ô chính", ["city highway"] = "Vùng ngoại ô chính", road = "Vùng ngoại ô chính", street = "Ngoại ô"} local data = {AUS = "no", default = "yes"} local yesOrNo = data[country] or data.default if yesOrNo == "no" then local type = args.type or '' local label = labels[type] or "Các điểm đến chính" return label, args.locations else return '', nil endendfunction p.locations(frame) local pframe = frame:getParent() local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template local parameters = {label1 = "Các quốc gia", label3 = "Tiểu bang", label4 = "Tỉnh", label7 = "Đơn vị hành chính", label8 = "Các thành phố chính", label9 = "Thị trấn", label10 = "Làng", child = "yes", decat = "yes", labelstyle = "text-align:right", title = "Vị trí"} local data = {} local function emptyParam(param) if param == '' then return nil else return param end end local country = emptyParam(args.country) local state = emptyParam(args.state) local province = emptyParam(args.province) if not(country) then local stateParam = args.state or args.province if not(stateParam) then country = '' else local countryMask = require "Mô đun:Infobox road/meta/mask/country" country = countryMask._country(stateParam, country) end end data[1] = countries(args, country) parameters.label2, data[2] = regions(args, country) data[3] = states(args, country) data[4] = provinces(args, country) parameters.label5, data[5] = counties(args, country) parameters.label6, data[6] = ruralMunis(args, province) data[7] = divisions(args, province) data[8] = cities(args, country, 'cities') data[9] = cities(args, country, 'towns') data[10] = cities(args, country, 'villages') parameters.label11, data[11] = destinations(args, country) parameters.label12, data[12] = lga(args, country) parameters.label13, data[13] = locations(args, country) local hasData = false for k,v in pairs(data) do if v ~= '' then hasData = true break end end if not(hasData) then return '' end for k,v in pairs(data) do parameters["data" .. k] = v end local infoboxModule = require 'Mô đun:Infobox' return infoboxModule.infobox(parameters)endreturn p