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

Нет описания правки
Нет описания правки
Строка 415: Строка 415:
     local searchType = (args.searchType or ""):lower()
     local searchType = (args.searchType or ""):lower()


     if searchValue == "" or pagePath == "" or keyPath == "" or tplPath == "" then
     if searchType == "" then
        searchType = "value"
    end
    if searchType == "path" then
        searchValue = ""
        pagePath = args[1] or ""
        keyPath = args[2] or ""
        tplPath = mw.text.unstripNoWiki(args[3] or "")
    end
    if pagePath == "" or keyPath == "" or tplPath == "" then
         return ""
         return ""
     end
     end
     if searchType == "" then
     if searchType ~= "path" and searchValue == "" then
         searchType = "value"
         return ""
     end
     end


Строка 432: Строка 441:


     local matches
     local matches
     if searchType == "key" then
     if searchType == "path" then
        matches = {}
        for idKey, entry in pairs(idsTable) do
            if type(entry) == "table" then
                local v = get_by_path(entry, keyPath)
                if v ~= nil then
                    matches[#matches + 1] = idKey
                end
            end
        end
    elseif searchType == "key" then
         local target = tostring(searchValue)
         local target = tostring(searchValue)
         matches = {}
         matches = {}