جز
«پودمان:Location map» را محافظت کرد: الگوهای حساس ([ویرایش=تنها کاربران تأییدشدهٔ پایدار و مدیران] (بیپایان) [انتقال=تنها کاربران تأییدشدهٔ پایدار و مدیران] (بیپایان))
جز (۱ نسخه واردشده) |
www>Huji جز («پودمان:Location map» را محافظت کرد: الگوهای حساس ([ویرایش=تنها کاربران تأییدشدهٔ پایدار و مدیران] (بیپایان) [انتقال=تنها کاربران تأییدشدهٔ پایدار و مدیران] (بیپایان))) |
||
خط ۵: | خط ۵: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local converter = require("Module:Numeral converter") | local converter = require("Module:Numeral converter") | ||
local function round(n, decimals) | local function round(n, decimals) | ||
local pow = 10^(decimals or 0) | local pow = 10^(decimals or 0) | ||
خط ۱۲۶: | خط ۱۲۵: | ||
coord = converter.convert("en", coord) | coord = converter.convert("en", coord) | ||
--- پایان بومیسازی | --- پایان بومیسازی | ||
local result = mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]') or '', '[ °]') | local result = mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]') or '', '[ °]') | ||
if para == 'longitude' then result = {result[3], result[4]} end | if para == 'longitude' then result = {result[3], result[4]} end | ||
خط ۱۶۵: | خط ۱۶۳: | ||
end | end | ||
local width | local width | ||
local default_as_number = tonumber(mw.ustring.match(tostring(args.default_width),"%d*")) | |||
if not args.width then | if not args.width then | ||
width = round(( | width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1)) | ||
elseif mw.ustring.sub(args.width, -2) == 'px' then | elseif mw.ustring.sub(args.width, -2) == 'px' then | ||
width = mw.ustring.sub(args.width, 1, -3) | width = mw.ustring.sub(args.width, 1, -3) | ||
خط ۱۷۲: | خط ۱۷۱: | ||
width = args.width | width = args.width | ||
end | end | ||
local width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0; | |||
if width_as_number == 0 then | |||
-- check to see if width is junk. If it is, then use default calculation | |||
width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1)) | |||
width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0; | |||
end | |||
if args.max_width ~= "" and args.max_width ~= nil then | |||
-- check to see if width bigger than max_width | |||
local max_as_number = tonumber(mw.ustring.match(args.max_width,"%d*")) or 0; | |||
if width_as_number>max_as_number and max_as_number>0 then | |||
width = args.max_width; | |||
end | |||
end | |||
local retval = args.float == 'center' and '<div class="center">' or '' | local retval = args.float == 'center' and '<div class="center">' or '' | ||
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then | if args.caption and args.caption ~= '' and args.border ~= 'infobox' then | ||
خط ۲۱۱: | خط ۲۲۳: | ||
args.maplink and ('|link=' .. args.maplink) or '' | args.maplink and ('|link=' .. args.maplink) or '' | ||
) | ) | ||
if args.caption and args.caption ~= '' then | |||
if mw.ustring.find(args.caption, '##') then | |||
retval = retval .. '[[Category:Pages using location map with a double number sign in the caption]]' | |||
end | |||
end | |||
if args.overlay_image then | if args.overlay_image then | ||
return retval .. '<div style="position:absolute;top:0;left:0">[[File:' .. args.overlay_image .. '|' .. width .. 'px]]</div>' | return retval .. '<div style="position:absolute;top:0;left:0">[[File:' .. args.overlay_image .. '|' .. width .. 'px]]</div>' | ||
خط ۲۴۴: | خط ۲۶۱: | ||
retval = retval .. '<span class="switcher-label" style="display:none">' .. args.switcherLabel .. '</span>' | retval = retval .. '<span class="switcher-label" style="display:none">' .. args.switcherLabel .. '</span>' | ||
elseif args.autoSwitcherLabel then | elseif args.autoSwitcherLabel then | ||
retval = retval .. '<span class="switcher-label" style="display:none"> | retval = retval .. '<span class="switcher-label" style="display:none">نمایش نقشه ' .. map('name') .. '</span>' | ||
end | end | ||
خط ۲۵۵: | خط ۲۷۲: | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی| | retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی|زیرنویس نامشخص]]' | ||
end | end | ||
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then | if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then | ||
mw.log('Removed parameter used in map definition ' .. map()) | mw.log('Removed parameter used in map definition ' .. map()) | ||
retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی| | local key = (map('skew') ~= '' and 'skew' or '') .. | ||
(map('lat_skew') ~= '' and 'lat_skew' or '') .. | |||
(map('crosses180') ~= '' and 'crosses180' or '') .. | |||
(map('type') ~= '' and 'type' or '') | |||
retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی|' .. key .. ' ]]' | |||
end | end | ||
if string.find(map('name'), '|', 1, true) then | if string.find(map('name'), '|', 1, true) then | ||
mw.log('Pipe used in name of map definition ' .. map()) | mw.log('Pipe used in name of map definition ' .. map()) | ||
retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی | retval = retval .. '[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی]]' | ||
end | end | ||
if args.float == 'center' then | if args.float == 'center' then | ||
خط ۳۱۵: | خط ۳۳۶: | ||
spanCss = 'float:left' | spanCss = 'float:left' | ||
end | end | ||
builder = builder:tag(' | builder = builder:tag('div') | ||
:css('display', 'inline') | |||
:cssText('padding:1px') | :cssText('padding:1px') | ||
:cssText(spanCss) | :cssText(spanCss) | ||
خط ۳۴۶: | خط ۳۶۸: | ||
args = getArgs(frame, {wrappers = 'Template:Location map~'}) | args = getArgs(frame, {wrappers = 'Template:Location map~'}) | ||
end | end | ||
local mapnames = {} | |||
if not map then | if not map then | ||
map = p.getMapParams(args[1], frame) | if args[1] then | ||
map = {} | |||
for mapname in mw.text.gsplit(args[1], '#', true) do | |||
map[#map + 1] = p.getMapParams(mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1'), frame) | |||
mapnames[#mapnames + 1] = mapname | |||
end | |||
if #map == 1 then map = map[1] end | |||
else | |||
map = p.getMapParams('World', frame) | |||
args[1] = 'World' | |||
end | |||
end | |||
if type(map) == 'table' then | |||
local outputs = {} | |||
local oldargs = args[1] | |||
for k,v in ipairs(map) do | |||
args[1] = mapnames[k] | |||
outputs[k] = tostring(p.mark(frame, args, v)) | |||
end | |||
args[1] = oldargs | |||
return table.concat(outputs, '#PlaceList#') .. '#PlaceList#' | |||
end | end | ||
-- خطوط زیر برای پشتیبانی از ارقام فارسی اضافه شدهاست. | -- خطوط زیر برای پشتیبانی از ارقام فارسی اضافه شدهاست. | ||
for k,v in pairs(args) do | for k,v in pairs(args) do | ||
خط ۳۵۸: | خط ۴۰۰: | ||
end | end | ||
-- پایان بومیسازی | -- پایان بومیسازی | ||
local x, y, longitude, latitude | local x, y, longitude, latitude | ||
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') | longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') | ||
latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude') | latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude') | ||
if args.excludefrom then | |||
-- If this mark is to be excluded from certain maps entirely (useful in the context of multiple maps) | |||
for exclusionmap in mw.text.gsplit(args.excludefrom, '#', true) do | |||
-- Check if this map is excluded. If so, return an empty string. | |||
if args[1] == exclusionmap then | |||
return '' | |||
end | |||
end | |||
end | |||
if args.coordinates then | if args.coordinates then | ||
-- Temporarily removed to facilitate infobox conversion. See [[ | -- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]] | ||
-- if longitude or latitude then | -- if longitude or latitude then | ||
خط ۴۰۲: | خط ۴۵۳: | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
local key = (args.skew and 'skew' or '') .. | |||
(args.lon_shift and 'lon_shift' or '') .. | |||
(args.markhigh and 'markhigh' or '') | |||
builder:wikitext('[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی|صفحهای که از پارامتر حذفشده استفاده میکند]]') | builder:wikitext('[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی|صفحهای که از پارامتر حذفشده استفاده میکند]]') | ||
end | end | ||
خط ۴۲۱: | خط ۴۷۵: | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
builder:wikitext('[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی| | local key = frame:preprocess('{{FULLPAGENAME}}') | ||
builder:wikitext('[[رده:نقشههای موقعیت مکانی با خطاهای احتمالی|' .. key .. ' ]]') | |||
end | end | ||
local mark = args.mark or map('mark') | local mark = args.mark or map('mark') | ||
خط ۴۴۷: | خط ۵۰۲: | ||
function p.main(frame, args, map) | function p.main(frame, args, map) | ||
local caption_list = {} | |||
if not args then | if not args then | ||
args = getArgs(frame, {wrappers = 'Template:Location map', valueFunc = p.valueFunc}) | args = getArgs(frame, {wrappers = 'Template:Location map', valueFunc = p.valueFunc}) | ||
end | end | ||
-- خطوط زیر برای پشتیبانی از ارقام فارسی اضافه شدهاست. | -- خطوط زیر برای پشتیبانی از ارقام فارسی اضافه شدهاست. | ||
for k,v in pairs(args) do | for k,v in pairs(args) do | ||
خط ۴۵۹: | خط ۵۱۴: | ||
end | end | ||
-- پایان بومیسازی | -- پایان بومیسازی | ||
if args.useWikidata == nil then | if args.useWikidata == nil then | ||
args.useWikidata = true | args.useWikidata = true | ||
خط ۴۶۷: | خط ۵۲۱: | ||
map = {} | map = {} | ||
for mapname in string.gmatch(args[1], '[^#]+') do | for mapname in string.gmatch(args[1], '[^#]+') do | ||
map[#map + 1] = p.getMapParams(mapname, frame) | map[#map + 1] = p.getMapParams(mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1'), frame) | ||
end | |||
if args['caption'] then | |||
if args['caption'] == "" then | |||
while #caption_list < #map do | |||
caption_list[#caption_list + 1] = args['caption'] | |||
end | |||
else | |||
for caption in mw.text.gsplit(args['caption'], '##', true) do | |||
caption_list[#caption_list + 1] = caption | |||
end | |||
end | |||
end | end | ||
if #map == 1 then map = map[1] end | if #map == 1 then map = map[1] end | ||
خط ۴۸۲: | خط ۵۴۷: | ||
if #overlays > #map then | if #overlays > #map then | ||
error(string.format('%d overlay_images were provided, but only %d maps were provided', #overlays, #map)) | error(string.format('%d overlay_images were provided, but only %d maps were provided', #overlays, #map)) | ||
end | |||
if #caption_list > #map then | |||
error(string.format('%d captions were provided, but only %d maps were provided', #caption_list, #map)) | |||
end | end | ||
local outputs = {} | local outputs = {} | ||
خط ۴۸۸: | خط ۵۵۶: | ||
args.AlternativeMap = altmaps[k] | args.AlternativeMap = altmaps[k] | ||
args.overlay_image = overlays[k] | args.overlay_image = overlays[k] | ||
args.caption = caption_list[k] | |||
outputs[k] = p.main(frame, args, v) | outputs[k] = p.main(frame, args, v) | ||
end | end |