Модуль:AutoDescriptionHuman/Krassotkin/Name
Этому модулю не хватает документации. |
--[[
------------------------------------------
-- AutoDescriptionHuman/Krassotkin/Name
-- Функция для получения имени человека
--
-- Usage:
-- {{#invoke:AutoDescriptionHuman/Krassotkin/Name|launch|id}}
------------------------------------------
--]]
local SerializeTable = require("Module:SerializeTable")
local AutoDescriptionHumanKrassotkinName = {}
local entitiesArray = {P735 = ""}
function AutoDescriptionHumanKrassotkinName.launch(frame)
local out = "test for id: "
local id = frame.args[1]
out = out..id
local entity = mw.wikibase.getEntity(id)
local logs = AutoDescriptionHumanKrassotkinName.parseP735(entity)
if(entitiesArray["P735"] == nil) then
out = out.."<br>nil name"
elseif(entitiesArray["P735"] == "") then
out = out.."<br>empty name"
else
out = out.."<br>name: "..entitiesArray["P735"]
end
return out.."<br>logs:"..logs
end
function AutoDescriptionHumanKrassotkinName.parseP735(entity)
local logs = ""
local p735Statement = mw.wikibase.getBestStatements(entity:getId(), "P735")
if(p735Statement ~= nil) then
for ki, vi in pairs (p735Statement) do
if(vi["mainsnak"] ~= nil
and vi["mainsnak"]["datavalue"] ~= nil
and vi["mainsnak"]["datavalue"]["value"] ~= nil
and vi["mainsnak"]["datavalue"]["value"]["id"] ~= nil) then
local givenNameId = vi["mainsnak"]["datavalue"]["value"]["id"]
logs = logs.."<br>givenNameId: "..givenNameId
if(givenNameId ~= nil and givenNameId ~="") then
local givenName = mw.wikibase.getLabelByLang(givenNameId, "ru")
logs = logs.."<br>givenName: "..givenName
if(givenName ~= nil) then entitiesArray["P735"] = givenName end
end
end
end
end
return logs
end
-- function AutoDescriptionHumanKrassotkinName.parseP735(entity)
-- local logs = ""
-- local p735Statement = mw.wikibase.getBestStatements(entity:getId(), "P735")
-- if(p735Statement == nil) then
-- logs = logs.."<br>p735Statement is nil"
-- else
-- for ki, vi in pairs (p735Statement) do
-- if(vi["mainsnak"] ~= nil
-- and vi["mainsnak"]["datavalue"] ~= nil
-- and vi["mainsnak"]["datavalue"]["value"] ~= nil
-- and vi["mainsnak"]["datavalue"]["value"]["id"] ~= nil) then
-- local givenNameId = vi["mainsnak"]["datavalue"]["value"]["id"]
-- if(givenNameId ~= nil) then entitiesArray.P735 = givenNameId end
-- local givenName = mw.wikibase.getLabelByLang(givenNameId, "ru")
-- if(givenName ~= nil) then
-- logs = logs..givenName
-- entitiesArray.P735 = givenName
-- end
-- else
-- logs = logs.."<br>snak is nil<br>"..SerializeTable.go(p735Statement)
-- end
-- end
-- end
-- return logs
-- end
--function AutoDescriptionHumanKrassotkinName.launch(frame)
-- local out = "test for id: "
-- local id = frame.args[1]
-- out = out..id
-- local entity = mw.wikibase.getEntity(id)
-- local p735Statement = mw.wikibase.getBestStatements(entity:getId(), "P735")
-- local givenNameId
-- if(p735Statement == nil) then
-- out = out.."<br><br> p735Statement is nil"
-- else
-- out = out.."<br><br> p735Statement isn't nil"
-- -- local log = mw.wikibase.renderSnak(p735Statement)
-- local log = SerializeTable.go(p735Statement)
-- if(log == nil) then
-- out = out.."<br><br> log is nil"
-- else
-- out = out.."<br><br> log:<br>"..log
-- --if(p735Statement["mainsnak"] ~= nil
-- -- and p735Statement["mainsnak"]["datavalue"] ~= nil
-- -- and p735Statement["mainsnak"]["datavalue"]["value"] ~= nil
-- -- and p735Statement["mainsnak"]["datavalue"]["value"]["id"] ~= nil) then
-- -- givenNameId = p735Statement["mainsnak"]["datavalue"]["value"]["id"]
-- -- out = out.."<br><br>givenNameId = "..givenNameId
-- --) then
-- -- out = out..";<br><br>mainsnak: "..SerializeTable.go(p735Statement["mainsnak"])
-- --end
-- for ki, vi in pairs (p735Statement) do
-- givenNameId = vi["mainsnak"]["datavalue"]["value"]["id"]
-- end
-- out = out.."<br><br>givenNameId = "..givenNameId
-- local givenName = mw.wikibase.getLabelByLang(givenNameId, "ru")
-- out = out.."<br><br>givenName = "..givenName
-- end
-- end
-- return out
--end
return AutoDescriptionHumanKrassotkinName