الفرق بين الصفحتين: «وحدة:Location map» و«وحدة:Location map/ملعب»

(الفرق بين الصفحتين)
اذهب إلى التنقل اذهب إلى البحث
صفحة 1
صفحة 2
ط (غيّر إعدادات حماية »وحدة:Location map«: بوت: [https://w.wiki/7NGP تحسين مستوي الحماية] ([تعديل=السماح للمحررين فقط] (غير محدد) [النقل=السماح للمحررين فقط] (غير محدد)))
 
طلا ملخص تعديل
 
سطر 11: سطر 11:


function p.getMapParams(map, frame)
function p.getMapParams(map, frame)
local template;
local template_title;
local template_title;
if not map then
if not map then
error('يجب تحديد اسم خريطة الموقع لاستخدامه', 2)
error('يجب تحديد اسم خريطة الموقع لاستخدامه'
, 2)
end
end
local template =mw.title.new('قالب:خريطة مواقع ' .. map)
local map1 = find( map )
local map1 = find( map ) or map
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
if mw.title.new('قالب:خريطة مواقع ' .. map1).exists then
if mw.title.new('قالب:خريطة مواقع ' .. map1).exists then
سطر 36: سطر 37:
--if not moduletitle then
--if not moduletitle then
--error('"' .. map .. '" ليس اسما صالحا لتعريف خريطة الموقع', 2)
--error('"' .. map .. '" ليس اسما صالحا لتعريف خريطة الموقع', 2)
--else
--else
if moduletitle.exists then
if moduletitle.exists then
local mapData = mw.loadData('Module:Location map/data/' .. map)
local mapData = mw.loadData('Module:Location map/data/' .. map)
return function(name, params)
return function(name, params)
سطر 141: سطر 141:
-- Finds a parameter in a transclusion of {{Coord}}.
-- Finds a parameter in a transclusion of {{Coord}}.
local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign
local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign
mw.log("Module:Location map: " .. 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
سطر 180: سطر 179:
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((default_as_number or 240) * (tonumber(map('defaultscale')) or 1))
width = round((args.default_width 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)
سطر 188: سطر 186:
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
سطر 229: سطر 214:
retval = retval .. 'float:right;clear:right'
retval = retval .. 'float:right;clear:right'
end
end
retval = retval .. '"><div style="width:' .. width .. 'px;padding:0"><div style="direction:ltr; position:relative;width:' .. width .. 'px">'
retval = retval .. '"><div style="width:' .. width .. 'px;padding:0"><div style="position:relative;width:' .. width .. 'px">'
end
end
local image = getContainerImage(args, map)
local image = getContainerImage(args, map)
سطر 237: سطر 222:
image,
image,
width,
width,
args.alt or ((args.label or mw.title.getCurrentTitle().text) .. ' على خريطة ' .. map('name')),
args.alt or ((args.label or mw.title.getCurrentTitle().text) .. ' is located in ' .. map('name')),
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>'
سطر 284: سطر 263:
retval = retval .. '</div></div>'
retval = retval .. '</div></div>'
if args.caption_undefined then
if args.caption_undefined then
mw.log('Module:Location map: Removed parameter caption_undefined used.')
mw.log('Removed parameter caption_undefined used.')
local parent = frame:getParent()
local parent = frame:getParent()
if parent then
if parent then
mw.log('Module:Location map: Parent is ' .. parent:getTitle())
mw.log('Parent is ' .. parent:getTitle())
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
retval = retval .. '[[Category:Location maps with removed parameters|caption_undefined]]'
retval = retval .. '[[Category:Location maps with possible errors|Page using removed parameter]]'
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('Module:Location map: Removed parameter used in map definition ' .. map())
mw.log('Removed parameter used in map definition ' .. map())
local key = (map('skew') ~= '' and 'skew' or '') ..
retval = retval .. '[[Category:Location maps with possible errors|Map using removed parameter]]'
(map('lat_skew') ~= '' and 'lat_skew' or '') ..
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[Category:Location maps with removed parameters|' .. key .. ' ]]'
end
end
if string.find(map('name'), '|', 1, true) then
if string.find(map('name'), '|', 1, true) then
mw.log('Module:Location map: Pipe used in name of map definition ' .. map())
mw.log('Pipe used in name of map definition ' .. map())
retval = retval .. '[[Category:Location maps with a name containing a pipe]]'
retval = retval .. '[[Category:Location maps with possible errors|Name containing pipe]]'
end
end
if args.float == 'center' then
if args.float == 'center' then
سطر 308: سطر 283:
end
end
return retval
return retval
end
function p.container(frame, args, map)
if not args then
args = getArgs(frame)
end
if not map then
map = p.getMapParams(args[1], frame)
end
return p.top(frame, args, map) .. (args.places or '') .. p.bottom(frame, args, map)
end
end


سطر 364: سطر 329:
spanCss = 'float:left'
spanCss = 'float:left'
end
end
builder = builder:tag('div')
builder = builder:tag('span')
:css('display', 'inline')
:cssText('padding:1px')
:cssText('padding:1px')
:cssText(spanCss)
:cssText(spanCss)
سطر 394: سطر 358:
function p.mark(frame, args, map)
function p.mark(frame, args, map)
if not args then
if not args then
args = getArgs(frame, {wrappers = 'قالب:خريطة مواقع~'})
args = getArgs(frame, {wrappers = 'Template:Location map~'})
end
end
local mapnames = {}
if not map then
if not map then
if args[1] then
map = p.getMapParams(args[1], frame)
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
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 [[Wikipedia:Coordinates in infoboxes]]
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
سطر 467: سطر 400:
end
end
if args.skew or args.lon_shift or args.markhigh then
if args.skew or args.lon_shift or args.markhigh then
mw.log('Module:Location map: Removed parameter used in invocation.')
mw.log('Removed parameter used in invocation.')
local parent = frame:getParent()
local parent = frame:getParent()
if parent then
if parent then
mw.log('Module:Location map: Parent is ' .. parent:getTitle())
mw.log('Parent is ' .. parent:getTitle())
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
local key = (args.skew and 'skew' or '') ..
builder:wikitext('[[Category:Location maps with possible errors|Page using removed parameter]]')
(args.lon_shift and 'lon_shift' or '') ..
(args.markhigh and 'markhigh' or '')
builder:wikitext('[[Category:Location maps with removed parameters|' .. key ..' ]]')
end
end
if map('x') ~= '' then
if map('x') ~= '' then
سطر 489: سطر 419:
end
end
if (x < 0 or x > 100 or y < 0 or y > 100) and not args.outside then
if (x < 0 or x > 100 or y < 0 or y > 100) and not args.outside then
mw.log('Module:Location map: Mark placed outside map boundaries without outside flag set. x = ' .. x .. ', y = ' .. y)
mw.log('Mark placed outside map boundaries without outside flag set. x = ' .. x .. ', y = ' .. y)
local parent = frame:getParent()
local parent = frame:getParent()
if parent then
if parent then
mw.log('Module:Location map: Parent is ' .. parent:getTitle())
mw.log('Parent is ' .. parent:getTitle())
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
local key = frame:preprocess('{{FULLPAGENAME}}')
builder:wikitext('[[Category:Location maps with possible errors|Outside flag not set with mark outside map]]')
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
end
end
local mark = args.mark or map('mark')
local mark = args.mark or map('mark')
سطر 522: سطر 451:


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:خريطة مواقع', valueFunc = p.valueFunc})
args = getArgs(frame, {wrappers = 'Template:Location map', valueFunc = p.valueFunc})
end
end
if args.useWikidata == nil then
if args.useWikidata == nil then
سطر 533: سطر 461:
map = {}
map = {}
for mapname in string.gmatch(args[1], '[^#]+') do
for mapname in string.gmatch(args[1], '[^#]+') do
map[#map + 1] = p.getMapParams(mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1'), frame)
map[#map + 1] = p.getMapParams(mapname, 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
سطر 551: سطر 468:
end
end
end
end
if type(map) == 'table' then
if type(map) == 'table' then
local altmaps = switcherSeparate(args.AlternativeMap)
local altmaps = switcherSeparate(args.AlternativeMap)
سطر 560: سطر 476:
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 = {}
سطر 569: سطر 482:
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
سطر 576: سطر 488:
return p.top(frame, args, map) .. tostring( p.mark(frame, args, map) ) .. p.bottom(frame, args, map)
return p.top(frame, args, map) .. tostring( p.mark(frame, args, map) ) .. p.bottom(frame, args, map)
end
end
end
local function manyMakeArgs(fullArgs, n)
if n == 1 then
return {
fullArgs[1],
lat = fullArgs.lat1 or fullArgs.lat,
long = fullArgs.long1 or fullArgs.long,
lat_deg = fullArgs.lat1_deg or fullArgs.lat_deg,
lat_min = fullArgs.lat1_min or fullArgs.lat_min,
lat_sec = fullArgs.lat1_sec or fullArgs.lat_sec,
lat_dir = fullArgs.lat1_dir or fullArgs.lat_dir,
lon_deg = fullArgs.lon1_deg or fullArgs.lon_deg,
lon_min = fullArgs.lon1_min or fullArgs.lon_min,
lon_sec = fullArgs.lon1_sec or fullArgs.lon_sec,
lon_dir = fullArgs.lon1_dir or fullArgs.lon_dir,
mark = fullArgs.mark1 or fullArgs.mark,
marksize = fullArgs.mark1size or fullArgs.marksize,
link = fullArgs.link1 or fullArgs.link,
label = fullArgs.label1 or fullArgs.label,
label_size = fullArgs.label1_size or fullArgs.label_size,
position = fullArgs.position1 or fullArgs.pos1 or fullArgs.position or fullArgs.pos,
background = fullArgs.background1 or fullArgs.bg1 or fullArgs.background or fullArgs.bg
}
else
return {
fullArgs[1],
lat = fullArgs['lat' .. n],
long = fullArgs['long' .. n],
lat_deg = fullArgs['lat' .. n .. '_deg'],
lat_min = fullArgs['lat' .. n .. '_min'],
lat_sec = fullArgs['lat' .. n .. '_sec'],
lat_dir = fullArgs['lat' .. n .. '_dir'],
lon_deg = fullArgs['lon' .. n .. '_deg'],
lon_min = fullArgs['lon' .. n .. '_min'],
lon_sec = fullArgs['lon' .. n .. '_sec'],
lon_dir = fullArgs['lon' .. n .. '_dir'],
mark = fullArgs['mark' .. n],
marksize = fullArgs['mark' .. n .. 'size'],
link = fullArgs['link' .. n],
label = fullArgs['label' .. n],
label_size = fullArgs['label' .. n .. '_size'],
position = fullArgs['position' .. n] or fullArgs['pos' .. n],
background = fullArgs['background' .. n] or fullArgs['bg' .. n]
}
end
end
function p.many(frame, args, map)
if not args then
args = getArgs(frame)
end
if not args[1] then
args[1] = 'World'
end
if not map then
map = p.getMapParams(args[1], frame)
end
local marks = {}
local markhigh = args.markhigh
for k, v in pairs(args) do -- @todo change to uargs once we have that
if v then
if string.sub(k, -4) == '_deg' then
k = string.sub(k, 1, -5)
end
if string.sub(k, 1, 3) == 'lat' then
k = tonumber(string.sub(k, 4))
if k then
table.insert(marks, k)
end
end
end
end
table.sort(marks)
if marks[1] ~= 1 and (args.lat or args.lat_deg) then
table.insert(marks, 1, 1)
end
local body = ''
for _, v in ipairs(marks) do
-- don't try to consolidate this into the above loop. ordering of elements from pairs() is unspecified
body = body .. p.mark(frame, manyMakeArgs(args, v), map)
if args['mark' .. v .. 'high'] then
markhigh = true
end
end
args.label = nil -- there is no global label
return p.top(frame, args, map) .. body .. p.bottom(frame, args, map) .. (markhigh and '[[Category:Location map many using markhigh parameter]]' or '')
end
end


return p
return p