模块:PRC admin/ref/sandbox
外观
< Module:PRC admin | ref
![]() | 这是Module:PRC admin/ref(差异)的沙盒。 |
local p = {}
local utils = require("Module:PRC_admin/utils")
local function useMCA(codeObj)
return codeObj:level() <= 3
end
function p._generateCitation(code)
local frame = mw.getCurrentFrame()
local codeObj = utils.PRCAdminCode.new(code)
if useMCA(codeObj) then
local digits = codeObj:tostripslashes(3)
return frame:expandTemplate({
title = "Cite web",
args = {
url = string.format("https://dmfw.mca.gov.cn/9095/xzqh/getList?code=%s", digits),
title = string.format("行政区划搜索:%s", codeObj:plainname()),
website = "中国·国家地名信息库"
}
})
else
local level = codeObj:level()
local page
if level == 0 then
page = "index"
elseif level == 1 then
page = codeObj:tostripstring()
else
page = string.format(
"%s/%s",
codeObj:parent():tostripstring(),
codeObj:tostripslashes()
)
end
return frame:expandTemplate({
title = "Cite web",
args = {
url = string.format("http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/%s.html", page),
title = string.format("2023年%s统计用区划代码和城乡划分代码", codeObj:plainname()),
publisher = "[[国家统计局|中华人民共和国国家统计局]]",
date = "2023",
language = "zh-cn"
}
}) .. frame:expandTemplate({
title = "Dead link",
args = {}
})
end
end
function p.generateCitation(frame)
local code = frame.args[1] or ""
return p._generateCitation(code)
end
return p