跳转到内容

模組:PRC admin/ref

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

这是Module:PRC admin/ref当前版本,由Xiplus-abot留言 | 贡献编辑于2025年1月26日 (日) 20:51 (已保护“Module:PRC admin/ref”:​高風險模板:43478引用<!-- 機器人3 -->([编辑=仅允许模板编辑员](无限期)[移动=仅允许模板编辑员](无限期)))。这个网址是本页该版本的固定链接。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local p = {}

local function useMCA(code)
    local parts = mw.text.split(code, "/")
    return not (parts[4] and parts[4]:match("^[45]")) and (code:match("000/000$") or #code <= 8)
end

function p.generateCitation(frame)
    local code = frame.args[1] or ""

    if useMCA(code) then
        local digits = code:gsub("000/000", ""):gsub("%D", "")
		local wikitext = string.format(
            "{{Cite web |url=https://dmfw.mca.gov.cn/9095/xzqh/getList?code=%s |title=行政区划搜索:{{PRC admin/plainname|%s}} |website=中国·国家地名信息库}}",
            digits, code
        )
        return frame:preprocess(wikitext)
    else
        local wikitext = string.format(
        	"{{Cite web|url=http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/{{#switch:{{PRC admin/level|%s}}|0=index|1={{PRC admin/stripcode|%s}}|#default={{PRC admin/stripcode|{{PRC admin/parent|%s}}}}/{{PRC admin/stripslashes|{{PRC admin/stripcode|%s}}}}}}.html|title=2023年{{PRC admin/plainname|%s}}统计用区划代码和城乡划分代码|publisher=[[国家统计局|中华人民共和国国家统计局]]|date=2023|language=zh-cn}}{{Dead link}}",
			code, code, code, code, code
        )
        return frame:preprocess(wikitext)
    end
end

return p