মডিউল:উইকিউপাত্ত তালিকা

এই মডিউলের জন্য মডিউল:উইকিউপাত্ত তালিকা/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

function mysplit (inputstr, sep)
        if sep == nil then
                sep = "%s"
        end
        local t={}
        for str in mw.ustring.gmatch(inputstr, "([^"..sep.."]+)") do
                table.insert(t, str)
        end
        return t
end

local p = {};

function p.getPublisherLink(frame)
    local item_id = frame.args[1]
    local current_item = mw.wikibase.getEntity(item_id)
    local current_sitelink = current_item:getSitelink()
    if current_sitelink == nil then
        current_sitelink = ':d:' .. item_id .. '|' .. current_item:getLabel()
    end
    local current_author_statement = current_item:getBestStatements('P50')[1]
    local current_author = 'অজানা লেখক'
    if current_author_statement.mainsnak.datavalue ~= nil then
        local current_author_id = current_author_statement.mainsnak.datavalue.value.id
        local current_author_item = mw.wikibase.getEntity(current_author_id)
        local current_author_sitelink = current_author_item:getSitelink()
        if current_author_sitelink ~= nil then
            current_author = '[[' .. current_author_sitelink ..  '|' .. mw.ustring.gsub(current_author_sitelink, 'লেখক:', '') .. ']]'
        else
            current_author = '[[:d:' .. current_author_id .. '|' .. current_author_item:getLabel()  .. ']]'
        end
    end
    newrow = frame:expandTemplate{ title = 'প্রকাশক সংস্করণ সারি', args = {
        ['item'] = item_id, ['label'] = '[[' .. current_sitelink .. ']]',
        p577 = current_item:formatPropertyValues( 'P577' ).value,
        p50 = current_author, 
        p1957 = current_item:formatPropertyValues('P1957').value }
    }
    return newrow
end

function p.PublisherPage(frame)
	local items = mysplit(frame.args[1], ',')
    output = ''
    for i, item_id in pairs(items) do
        local current_item = mw.wikibase.getEntity(item_id)
        local current_sitelink = current_item:getSitelink()
        if current_sitelink == nil then
            current_sitelink = ':d:' .. item_id .. '|' .. current_item:getLabel()
        end
        local current_author_statement = current_item:getBestStatements('P50')[1]
        local current_author = 'অজানা লেখক'
        if current_author_statement.mainsnak.datavalue ~= nil then
            local current_author_id = current_author_statement.mainsnak.datavalue.value.id
            local current_author_item = mw.wikibase.getEntity(current_author_id)
            local current_author_sitelink = current_author_item:getSitelink()
            if current_author_sitelink ~= nil then
                current_author = '[[' .. current_author_sitelink ..  '|' .. mw.ustring.gsub(current_author_sitelink, 'লেখক:', '') .. ']]'
            else
                current_author = '[[:d:' .. current_author_id .. '|' .. current_author_item:getLabel()  .. ']]'
            end
        end
        newrow = '\n' .. frame:expandTemplate{ title = 'প্রকাশক সংস্করণ সারি', args = {
            ['item'] = item_id, ['label'] = '[[' .. current_sitelink .. ']]',
            p577 = current_item:formatPropertyValues( 'P577' ).value,
            p50 = current_author, 
            p1957 = current_item:formatPropertyValues('P1957').value }
        }
        output = output .. newrow
    end
    return output
end

return p