모듈:ArtworkInfo
위 설명은 모듈:ArtworkInfo/설명문서의 내용을 가져와 보여주고 있습니다. (편집 | 역사) 이 틀에 대한 수정 연습과 시험은 연습장 (만들기)과 시험장 (만들기)에서 할 수 있습니다. 분류는 /설명문서에 넣어주세요. 이 문서에 딸린 문서. |
local p = {}
local entity = mw.wikibase.getEntityObject()
function p.getLabel(frame)
local lang = frame.args[1] or 'ko'
local id = mw.wikibase.getEntityIdForCurrentPage()
local label = mw.wikibase.getLabelByLang( id , lang )
return label
end
function p.startTime(qid , key)
local valueTable = entity.claims[qid]
local startTime = valueTable[key].qualifiers.P580[1].datavalue.value.time
startTime = string.match(startTime, '+(%d+)-')
return startTime
end
function p.endTime(qid , key)
local valueTable = entity.claims[qid]
local endTime = valueTable[key].qualifiers.P582[1].datavalue.value.time
endTime = string.match(endTime, '+(%d+)-')
return endTime
end
function p.pointInTime(qid , key)
local valueTable = entity.claims[qid]
if valueTable[key].qualifiers == nil then
return nil
elseif valueTable[key].qualifiers['P585'] == nil then
return nil
end
local pointInTime = valueTable[key].qualifiers.P585[1].datavalue.value.time
pointInTime = string.match(pointInTime, '+(%d+)-')
return pointInTime
end
function p.listOfOwners(frame)
local qid = frame.args[1]
local valueTable = entity.claims[qid]
local str
local i = 1
local startTime, endTime
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
if valueTable[key].mainsnak.datavalue == nil then
return nil
end
local id = valueTable[key].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
local pointInTime = p.pointInTime(qid , key)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if i == 1 then
if valueTable[key].qualifiers then
if (valueTable[key].qualifiers.P580 and valueTable[key].qualifiers.P582) then
startTime = p.startTime(qid , key)
endTime = p.endTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(%d - %d)</small>", koPage, item, startTime, endTime)
else
str = string.format("[[d:%s|%s]] <small>(%d - %d)</small>", id, item, startTime, endTime)
end
elseif valueTable[key].qualifiers.P580 then
startTime = p.startTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(%d - )</small>", koPage, item, startTime)
else
str = string.format("[[d:%s|%s]] <small>(%d - )</small>", id, item, startTime)
end
elseif valueTable[key].qualifiers.P582 then
endTime = p.endTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>( - %d)</small>", koPage, item, endTime)
else
str = string.format("[[d:%s|%s]] <small>( - %d)</small>", id, item, endTime)
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = "[[" .. koPage .. '|' .. item .. ']]'
else
str = "[[d:" .. id .. '|' .. item .. ']]'
end
end
elseif pointInTime ~= nil then
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(%d)</small>", koPage, item, pointInTime)
else
str = string.format("[[d:%s|%s]] <small>(%d)</small>", id, item, pointInTime)
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = "[[" .. koPage .. '|' .. item .. ']]'
else
str = "[[d:" .. id .. '|' .. item .. ']]'
end
end
else
if valueTable[key].qualifiers then
if (valueTable[key].qualifiers.P580 and valueTable[key].qualifiers.P582) then
startTime = p.startTime(qid , key)
endTime = p.endTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("[[%s|%s]] <small>(%d - %d)</small>", koPage, item, startTime, endTime)
else
item = string.format("[[d:%s|%s]] <small>(%d - %d)</small>", id, item, startTime, endTime)
end
str = string.format("%s<br>%s", str, item)
elseif valueTable[key].qualifiers.P580 then
startTime = p.startTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("[[%s|%s]] <small>(%d - )</small>", koPage, item, startTime)
else
item = string.format("[[d:%s|%s]] <small>(%d - )</small>", id, item, startTime)
end
str = string.format("%s<br>%s", str, item)
elseif valueTable[key].qualifiers.P582 then
endTime = p.endTime(qid , key)
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("[[%s|%s]] <small>( - %d)</small>", koPage, item, endTime)
else
item = string.format("[[d:%s|%s]] <small>( - %d)</small>", id, item, endTime)
end
str = string.format("%s<br>%s", str, item)
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("%s<br>[[%s|%s]]", str, koPage, item)
else
str = string.format("%s<br>[[d:%s|%s]]", str, id, item)
end
end
elseif pointInTime ~= nil then
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("[[%s|%s]] <small>(%d)</small>", koPage, item, pointInTime)
else
item = string.format("[[d:%s|%s]] <small>(%d)</small>", id, item, pointInTime)
end
str = string.format("%s<br>%s", str, item)
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("%s<br>[[%s|%s]]", str, koPage, item)
else
str = string.format("%s<br>[[d:%s|%s]]", str, id, item)
end
end
end
i = i + 1
end
end
return str
end
function p.meterialUsed()
local valueTable = entity.claims['P186']
local str = ''
local str1 = ''
local str2 = ''
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local label = mw.wikibase.getLabel(id)
if valueTable[key].qualifiers then
local qualifiers = valueTable[key].qualifiers
for qkey in pairs(qualifiers) do
if qualifiers[qkey][1].datavalue.value.id == 'Q861259' then
if str1 == '' then
str1 = label
else
str1 = string.format("%s %s", str1, label)
end
end
end
else
if str1 == '' then
str2 = label
else
str2 = string.format("%s %s", str2, label)
end
end
end
if str1 == '' then
str = str2
else
str = string.format("%s에 %s", str1, str2)
end
return str
end
function p.getFilename(frame)
local property
if frame.args[1] == nil then
property = 'P18'
else
property = frame.args[1]
end
local valueTable = entity.claims[property]
local name
name = valueTable[1].mainsnak.datavalue.value
return name
end
function p.getLists(frame)
local property = frame.args[1]
local valueTable = entity.claims[property]
local str = ''
local i = 1
local num = frame.args['num']
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local check, item = mw.wikibase.getLabelByLang( id, 'ko' )
local page = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if i == 1 then
if (check ~= nil) and (page ~= nil) then
str = '[[' .. page .. '|' .. item .. ']]'
else
str = '[[:d:' .. id .. '|' .. item .. ']]'
end
else
if (check ~= nil) and (page ~= nil) then
str = str .. ', [[' .. page .. '|' .. item .. ']]'
else
str = str .. ', [[:d:' .. id .. '|' .. item .. ']]'
end
end
i = i + 1
if num ~= nil and num == (i - 1) then
break
end
end
end
return str
end
function p.getNotableWorks()
local property = 'P800'
local valueTable = entity.claims[property]
local str = ''
local i = 1
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if i == 1 then
if (koCheck ~= nil) and (koPage ~= nil) then
str = '[[' .. koPage .. '|' .. item .. ']]'
else
str = '[[:d:' .. id .. '|' .. item .. ']]'
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = str .. ', [[' .. koPage .. '|' .. item .. ']]'
else
str = str .. ', [[:d:' .. id .. '|' .. item .. ']]'
end
end
i = i+1
end
end
return str
end
function p.getAwords()
local property = 'P166'
local valueTable = entity.claims[property]
local str = ''
local i = 1
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
local pointInTime = p.pointInTime(property , key)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if i == 1 then
if pointInTime == nil then
if (koCheck ~= nil) and (koPage ~= nil) then
str = '[[' .. koPage .. '|' .. item .. ']]'
else
str = '[[:d:' .. id .. '|' .. item .. ']]'
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = '[[' .. koPage .. '|' .. item .. ']] <small>(' .. pointInTime .. ')</small>'
else
str = '[[:d:' .. id .. '|' .. item .. ']] <small>(' .. pointInTime .. ')</small>'
end
end
else
if pointInTime == nil then
if (koCheck ~= nil) and (koPage ~= nil) then
str = str .. '<br />[[' .. koPage .. '|' .. item .. ']]'
else
str = str .. '<br />[[:d:' .. id .. '|' .. item .. ']]'
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = str .. '<br />[[' .. koPage .. '|' .. item .. ']] <small>(' .. pointInTime .. ')</small>'
else
str = str .. '<br />[[:d:' .. id .. '|' .. item .. ']] <small>(' .. pointInTime .. ')</small>'
end
end
end
i = i+1
end
end
return str
end
function p.getParents()
local valueTable = entity.claims['P22']
local valueTable2 = entity.claims['P25']
local str = ''
if valueTable ~= nil then
if not valueTable[1].mainsnak.datavalue then
return nil
end
local id = valueTable[1].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if (item ~= nil) and (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(부)</small>", koPage, item)
elseif item ~= nil then
str = string.format("[[d:%s|%s]] <small>(부)</small>", id, item)
end
if valueTable2 ~= nil then
id = valueTable2[1].mainsnak.datavalue.value.id
koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
koPage = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("[[%s|%s]] <small>(모)</small>", koPage, item)
str = string.format("%s<br>%s", str, item)
elseif item ~= nil then
item = string.format("[[d:%s|%s]] <small>(모)</small>", id, item)
str = string.format("%s<br>%s", str, item)
end
end
end
elseif valueTable2 ~= nil then
id = valueTable2[1].mainsnak.datavalue.value.id
koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
koPage = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
if (item ~= nil) and (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(모)</small>", koPage, item)
elseif item ~= nil then
str = string.format("[[d:%s|%s]] <small>(모)</small>", id, item)
end
end
return str
end
function p.getRelatives(frame)
local property
if frame.args[1] ~= nil then
property = frame.args[1]
else
property = 'P1038'
end
local valueTable = entity.claims[property]
local str = ''
local i = 1
if valueTable ~= nil then
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
local id2
local typeOfKinship
if valueTable[key].qualifiers ~= nil then
id2 = valueTable[key].qualifiers.P1039[1].datavalue.value.id
typeOfKinship = mw.wikibase.getLabelByLang( id2, 'ko' )
else
typeOfKinship = nil
end
if item == nil then
item = mw.wikibase.getLabel( id )
end
if item ~= nil then
if i == 1 then
if typeOfKinship ~= nil then
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]] <small>(%s)</small>", koPage, item, typeOfKinship)
else
str = string.format("[[d:%s|%s]] <small>(%s)</small>", id, item, typeOfKinship)
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("[[%s|%s]]", koPage, item)
else
str = string.format("[[d:%s|%s]]", id, item)
end
end
else
if typeOfKinship ~= nil then
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("%s<br/>[[%s|%s]] <small>(%s)</small>", str, koPage, item, typeOfKinship)
else
str = string.format("%s<br/>[[d:%s|%s]] <small>(%s)</small>",str, id, item, typeOfKinship)
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("%s<br/>[[%s|%s]]", str, koPage, item)
else
str = string.format("%s<br/>[[d:%s|%s]]", str, id, item)
end
end
end
end
i = i + 1
end
end
return str
end
function p.getGallery()
local property = 'P800'
local valueTable = entity.claims[property]
local str = ''
local i = 1
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local koCheck, item = mw.wikibase.getLabelByLang( id, 'ko' )
local koPage = mw.wikibase.getSitelink(id)
if item == nil then
item = mw.wikibase.getLabel( id )
end
local rawname = mw.wikibase.getEntityObject(id).claims['P18']
if rawname ~= nil then
local fileName = rawname[1].mainsnak.datavalue.value
if i == 1 then
if (koCheck ~= nil) and (koPage ~= nil) then
str = string.format("<gallery>\nFile:%s | [[%s|%s]]", fileName, koPage, item)
else
if item ~= nil then
str = string.format("<gallery>\nFile:%s | %s", fileName, item)
else
str = string.format("<gallery>\nFile:%s", fileName)
end
end
else
if (koCheck ~= nil) and (koPage ~= nil) then
item = string.format("\nFile:%s | [[%s|%s]]", fileName, koPage, item)
str = str .. item
else
if item ~= nil then
item = string.format("\nFile:%s | %s", fileName, item)
str = str .. item
else
item = string.format("\nFile:%s", fileName)
str = str .. item
end
end
end
i = i+1
end
end
if i == 1 then
return nil
else
str = str .. "\n</gallery>"
end
return str
end
function p.getGalleryTest()
local property = 'P800'
local valueTable = entity.claims[property]
local str = ''
local i = 1
if valueTable == nil then
return nil
end
for key in ipairs(valueTable) do
local id = valueTable[key].mainsnak.datavalue.value.id
local rawname = mw.wikibase.getEntityObject(id).claims['P18']
if rawname ~= nil then
local fileName = rawname[1].mainsnak.datavalue.value
if item == nil then
item = mw.wikibase.getLabel( id )
end
if i == 1 then
str = fileName
else
str = str .. '<br>' .. fileName
end
i = i+1
end
end
return str
end
return p