local p = {}
local yesno = require('Module:Yesno')
local class_normalize = require("Module:Class/convert")._main
local TrackingCategory = require('Module:TrackingCategory')
local templateExist = require("Module:TemplateExist").templateExist
function p.cat_for_wpbs(frame)
local args = frame
local working_frame = frame
if type(frame.args) == type({}) then
args = frame.args
end
if type(frame.preprocess) ~= type(tostring) then
working_frame = mw.getCurrentFrame()
end
--本模板是示例模板,不加分類
if yesno(args.demo) or not yesno(args.category) then return end
local wpbs_class = mw.text.trim(args.class or '')
local WPBS_count = templateExist({args={"WPBS",count=true}})
if wpbs_class == '' and wpbs_class ~= '¬' then
--[[w:en:Category:Articles using WikiProject banner shell with empty class parameter]]
TrackingCategory.append(working_frame, "含有空白class參數的WPBS")
end
if WPBS_count > 1 then
TrackingCategory.append(working_frame, "重複放置WPBS模板的條目")
end
return ''
end
function p.cat_for_wpbm(frame)
local args = frame
local working_frame = frame
if type(frame.args) == type({}) then
args = frame.args
end
if type(frame.preprocess) ~= type(tostring) then
working_frame = mw.getCurrentFrame()
end
local WPBS_exist = templateExist("WPBS")
--本模板是示例模板,不加分類
if yesno(args.demo) or not yesno(args.category) then return '' end
--取得WPBS資料
local WPBS_data = mw.loadData("Module:PJBSClass/page")
--輸入於本專題橫幅的評級class值
local local_class = mw.text.trim(args.class or '')
--輸入於WPBS的評級class值
local article_class = mw.text.trim(WPBS_data.class or '')
local raw_class = mw.text.trim(args.raw_class or '¬')
local norm_local_class = class_normalize({local_class})
local norm_article_class = class_normalize({article_class})
if WPBS_exist then --如果存在WPBS模板
if article_class == '' then --WPBS模板沒有給定評級
if local_class ~= '' and raw_class ~= '¬' then --但專題橫幅有給定評級
local success, auto_class = pcall(require("Module:PJBSClass/main").getClassAuto, nil, '', yesno(args.demo), args.napagens or '{{{napagens}}}')
auto_class = class_normalize({auto_class or "unassessed"})
if auto_class == "unassessed" or auto_class == "" then
--[[w:en:Category:Pages using WikiProject banner shell without a project-independent quality rating]]
TrackingCategory.append(working_frame, "缺少獨立於專題評級的WPBS")
end
end
elseif norm_local_class == norm_article_class then --專題橫幅的評級與WPBS完全一致
if norm_local_class ~= "unassessed" and raw_class ~= '¬' and raw_class ~= '' then
if local_class ~= '' and raw_class ~= '¬' then
--[[w:en:Category:WikiProject banners with redundant class parameter]]
TrackingCategory.append(working_frame, "有不必要class參數的專題橫幅")
end
end
end
else --如果不存在WPBS模板
--[[w:en:Category:WikiProject banners without banner shells]]
TrackingCategory.append(working_frame, "沒有使用WPBS的專題橫幅")
end
return ''
end
return p