-- begin BHG addition for tracking source pages
function checksourcepages()
-- no tracking unless we are in Portal namespace
if (mw.title.getCurrentTitle().nsText ~= "Portal") then
return ""
end
local pagecounter = 0;
local templatecount = 0;
local outlinecount = 0;
local retval ="";
local debugging = false;
if debugging then
retval = '<div style="display:block; border:10px solid green; background-color:#efe; padding:1em; margin:1em">\n----\n'
retval = retval .. "sourcepgagesusedcounter: " .. sourcepgagesusedcounter .. "\n----\n"
retval = retval .. "pages used:"
end
local apage
for apage in arrayvalues(sourcepgagesused) do
if debugging then
retval = retval .. "\n# [[:" .. apage .. "]]"
retval = retval .. " — " .. "First 999 = /" .. string.sub(apage, 1, 999) .. "/"
end
if (string.find(apage, "^[tT]emplate ?:") == 1) then
templatecount = templatecount + 1;
end
if (string.find(apage, "^[oO]utline +of ") == 1) then
outlinecount = outlinecount + 1;
end
pagecounter = pagecounter + 1
end
if debugging then
retval = retval .. "\nTotal pages: " .. pagecounter
retval = retval .. "\ntemplatecount: " .. templatecount
retval = retval .. "</div>"
end
-- first do a sanity check that both counting methods have produced the same result
if (sourcepgagesusedcounter == pagecounter) then
-- if all pages are templates, then populate tracking categories
if (pagecounter == templatecount) then
if (templatecount == 1) then
retval = retval .. "[[Category:Automated portals with article list built solely from one template]]"
elseif (templatecount == 2) then
retval = retval .. "[[Category:Automated portals with article list built solely from two templates]]"
elseif (templatecount == 3) then
retval = retval .. "[[Category:Automated portals with article list built solely from three templates]]"
end
end
if (outlinecount >= 1) then
retval = retval .. "[[Category:Automated portals with article list built using one or more outline pages]]"
|