跳转到内容

模組:Wikibase

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Shizhao留言 | 贡献2015年8月13日 (四) 01:24 (取消Haowa对话)的编辑;更改回Lucie Kaffee (WMDE)的最后一个版本)编辑。这可能和当前版本存在着巨大的差异。

-- from https://test2.wikipedia.org/s/4te
-- Module:Wikibase
local p = {}
 
-- Return the item ID of the item linked to the current page.
function p.id(frame)
        if not mw.wikibase then
           return "wikibase模块未找到"
        end
 
        entity = mw.wikibase.getEntityObject()
 
        if entity == nil then
           return "(无项目可连接)"
        end
 
        return entity.id
end
 
-- Return the label of a given data item.
function p.label(frame)
        if frame.args[1] == nil then
            entity = mw.wikibase.getEntityObject()
            if not entity then return nil end
 
            id = entity.id
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.label( id )
end
 
-- Return the local page about a given data item.
function p.page(frame)
        if frame.args[1] == nil then
            entity = mw.wikibase.getEntityObject()
            if not entity then return nil end
 
            id = entity.id
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.sitelink( id )
end
 
return p