Модуль:GetField: различия между версиями

м Замена текста — «getGenerator» на «searchStore»
Метки: с мобильного устройства из мобильной версии
Нет описания правки
 
(не показано 12 промежуточных версий этого же участника)
Строка 1: Строка 1:
local p = {}
local p = {}
local lang = mw.language.getContentLanguage()


local JsonPaths = require('Module:JsonPaths')
local JsonPaths = require('Module:JsonPaths')
local project = JsonPaths.project()
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs


Строка 352: Строка 354:


local moduleName = get_module_name(pagePath)
local moduleName = get_module_name(pagePath)
if not data then
data = data or load_cached_data(moduleName)
data = load_cached_data(moduleName)
end
if not data then
if not data then
return ""
return ""
Строка 362: Строка 362:
local extra = flatten_entry(entry)
local extra = flatten_entry(entry)


local tplStr = "{{" .. tostring(tplPath) .. "|id=" .. tostring(id)
local templatePath = tplPath
if project ~= nil and project ~= "" then
templatePath = project .. ":" .. lang:ucfirst(tplPath)
templatePath = "{{#ifexist:Шаблон:" .. templatePath .. "|" .. templatePath .. "|" .. tplPath .. "}}"
end
 
local tplStr = "{{Шаблон:" .. templatePath .. "|id=" .. tostring(id)
if extra ~= "" then
if extra ~= "" then
tplStr = tplStr .. "|" .. extra
tplStr = tplStr .. "|" .. extra
Строка 525: Строка 531:
end
end


function p.searchTplId(frame)
function p.searchIdTpl(frame)
local args = getArgs(frame, { removeBlanks = false })
local args = getArgs(frame, { removeBlanks = false })
local searchValue = args[1] or ""
local searchValue = args[1] or ""
Строка 643: Строка 649:
end
end


function p.getTplGenerator(frame)
function p.searchStoreTpl(frame)
local args = getArgs(frame, { removeBlanks = false })
local args = getArgs(frame, { removeBlanks = false })
local searchId = args[1] or ""
local searchId = args[1] or ""
Строка 749: Строка 755:
end
end


function p.GeneratorId(frame)
function p.getAll(frame)
local args = getArgs(frame, { removeBlanks = false })
local args = getArgs(frame, { removeBlanks = false })
local pagePath = args[1] or ""
local pagePath = args[1] or ""
Строка 799: Строка 805:
end
end


function p.GeneratorTplId(frame)
function p.getAllTpl(frame)
local args = getArgs(frame, { removeBlanks = false })
local args = getArgs(frame, { removeBlanks = false })
local pagePath = args[1] or ""
local pagePath = args[1] or ""
Строка 838: Строка 844:
local jsonStr = mw.text.unstripNoWiki(args[1] or args.json or "")
local jsonStr = mw.text.unstripNoWiki(args[1] or args.json or "")
local tplPath = mw.text.unstripNoWiki(args[2] or args.template or "")
local tplPath = mw.text.unstripNoWiki(args[2] or args.template or "")
if jsonStr == "" or tplPath == "" then
if jsonStr == "" or tplPath == "" then
return ""
return ""
Строка 848: Строка 855:


local okDp, dp = pcall(require, "Module:GetField")
local okDp, dp = pcall(require, "Module:GetField")
local calls = {}


local calls = {}
local projectPath = nil
if project ~= nil and project ~= "" then
projectPath = project .. ":" .. lang:ucfirst(tplPath)
end
 
local function makeTemplatePrefix()
if projectPath then
return "{{Шаблон:{{#ifexist:Шаблон:" .. projectPath .. "|" .. projectPath .. "|" .. tplPath .. "}}"
end
 
return "{{" .. tplPath
end


local function makeCall(id, obj)
local function makeCall(id, obj)
Строка 856: Строка 875:
end
end


local parts = { "{{" .. tplPath, "id=" .. id }
local parts = { makeTemplatePrefix(), "id=" .. id }


if type(obj) == "table" then
if type(obj) == "table" then