تضامنًا مع حق الشعب الفلسطيني |
الفرق بين الصفحتين: «وحدة:Location map» و«وحدة:Location map/ملعب»
(الفرق بين الصفحتين)
عبود السكاف (نقاش | مساهمات) ط (غيّر إعدادات حماية »وحدة: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 map1 = find( map ) | |||
local map1 = find( 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 | |||
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 | ||
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 | ||
if not args.width then | if not args.width then | ||
width = round(( | 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 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=" | 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) .. ' | 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.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(' | mw.log('Removed parameter caption_undefined used.') | ||
local parent = frame:getParent() | local parent = frame:getParent() | ||
if parent then | if parent then | ||
mw.log(' | mw.log('Parent is ' .. parent:getTitle()) | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
retval = retval .. '[[Category:Location maps with removed | 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(' | mw.log('Removed parameter used in map definition ' .. map()) | ||
retval = retval .. '[[Category:Location maps with possible errors|Map using removed parameter]]' | |||
retval = retval .. '[[Category:Location maps with removed | |||
end | end | ||
if string.find(map('name'), '|', 1, true) then | if string.find(map('name'), '|', 1, true) then | ||
mw.log(' | mw.log('Pipe used in name of map definition ' .. map()) | ||
retval = retval .. '[[Category:Location maps with | 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 | end | ||
سطر 364: | سطر 329: | ||
spanCss = 'float:left' | spanCss = 'float:left' | ||
end | end | ||
builder = builder:tag(' | builder = builder:tag('span') | ||
: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 | ||
if not map then | if not map then | ||
map = p.getMapParams(args[1], frame) | |||
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.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(' | mw.log('Removed parameter used in invocation.') | ||
local parent = frame:getParent() | local parent = frame:getParent() | ||
if parent then | if parent then | ||
mw.log(' | mw.log('Parent is ' .. parent:getTitle()) | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
builder:wikitext('[[Category:Location maps with possible errors|Page using removed parameter]]') | |||
builder:wikitext('[[Category:Location maps with removed | |||
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(' | 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(' | mw.log('Parent is ' .. parent:getTitle()) | ||
end | end | ||
mw.logObject(args, 'args') | mw.logObject(args, 'args') | ||
builder:wikitext('[[Category:Location maps with possible errors|Outside flag not set with mark outside map]]') | |||
builder:wikitext('[[Category:Location maps with | |||
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) | ||
if not args then | if not args then | ||
args = getArgs(frame, {wrappers = 'Template: | 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 | map[#map + 1] = p.getMapParams(mapname, frame) | ||
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 | 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] | ||
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 | end | ||
return p | return p |