پودمان:Infobox road/sections
ظاهر
local p = {}
local convert_num = require('Module:Numeral converter').convert
local function terminus_a(num, args)
local direction = args["direction_a" .. num] or args.direction_a or ''
local label
if direction ~= '' then
label = "انتهای " .. direction .. "ی:" -- outputs e.g. انتهای غربی
else
label = "از:"
end
local data = args["terminus_a" .. num]
return label, data
end
local function terminus_b(num, args)
local direction = args["direction_b" .. num] or args.direction_b or ''
local label
if direction ~= '' then
label = "انتهای " .. direction .. "ی:"
else
label = "به:"
end
local data = args["terminus_b" .. num]
return label, data
end
function p._section(num, args)
local lead = --[[5 * num +]] 1
local parameters = {["label" .. (lead + 1)] = "طول:", ["label" .. (lead + 3)] = "تقاطعهای<br/>مهم:", child = "yes", decat = "yes", labelstyle = "text-align:left"}
local data = {}
local title = args["section" .. num] or "بخش " .. convert_num('fa', num)
--parameters["header" .. lead] = title
parameters.title = title
local lengthModule = require "Module:Infobox road/length/تمرین"
data[lead + 1] = lengthModule._length(num, args)
parameters["label" .. (lead + 2)], data[lead + 2] = terminus_a(num, args)
data[lead + 3] = args["junction" .. num]
parameters["label" .. (lead + 4)], data[lead + 4] = terminus_b(num, args)
local hasData = false
for k,v in pairs(data) do
hasData = true
break
end
if not(hasData) then
return ''
end
for k,v in pairs(data) do
parameters["data" .. k] = v
end
local infoboxModule = require 'Module:Infobox'
return infoboxModule.infobox(parameters)
end
function p.section(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 num = config.num or config['شماره']
return p._section(num, args)
end
local function loop(args)
local ring_road = args.ring_road or args['کمربندی'] or ''
if ring_road ~= '' then
return "[[جاده کمربندی]] حول " .. ring_road
end
local beltway_city = args.beltway_city or args['شهر کمربندی'] or ''
if beltway_city ~= '' then
return "[[جاده کمربندی]] حول " .. beltway_city
end
local orbital = args.orbital or args['مداری'] or ''
if orbital ~= '' then
return "[[جاده کمربندی]] حول " .. orbital
end
local loop = args.loop or args['حلقه'] or ''
if loop ~= '' then
return "[[جاده کمربندی|کمربندی]] حول " .. loop
end
local tloop = args.tloop or args['حلقه توریستی'] or ''
if tloop == 'none' then
return "حلقه توریستی"
elseif tloop ~= '' then
return "حلقه توریستی حول " .. tloop
end
return nil
end
function p._main(args)
local lead = --[[5 * num +]] 1
local parameters = {["label" .. (lead + 3)] = " ", child = "yes", decat = "yes", labelstyle = "text-align:left"}
local data = {}
local title = args.section0 or "تقاطعهای مهم"
--parameters["header" .. lead] = title
parameters.title = title
data[lead + 1] = loop(args)
parameters["label" .. (lead + 2)], data[lead + 2] = terminus_a('', args)
data[lead + 3] = args.junction
parameters["label" .. (lead + 4)], data[lead + 4] = terminus_b('', args)
local hasData = false
for k,v in pairs(data) do
hasData = true
break
end
if not(hasData) then
return ''
end
for k,v in pairs(data) do
parameters["data" .. k] = v
end
local infoboxModule = require 'Module:Infobox'
return infoboxModule.infobox(parameters)
end
function p.main(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
return p._main(args)
end
return p