コード例 #1
0
        private static void PurgeCdn_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            if (sender.TreeAlias != "content")
            {
                return;
            }

            if (CdnPurger.IsActive())
            {
                var menuItem = new Umbraco.Web.Models.Trees.MenuItem("purgeCdn", "Purge CDN");
                menuItem.AdditionalData.Add("actionView", "/App_Plugins/PurgeCdn/Views/purgecdn.html");
                menuItem.AdditionalData.Add("contentId", e.NodeId);
                menuItem.Icon            = "axis-rotation";
                menuItem.SeperatorBefore = true;

                e.Menu.Items.Insert(e.Menu.Items.Count, menuItem);
            }
        }
コード例 #2
0
        public DialogViewModel InitDialog(int nodeId)
        {
            if (nodeId == -1)
            {
                if (CdnPurger.PurgeMethod == "tag")
                {
                    return(new DialogViewModel()
                    {
                        NodeId = nodeId,
                        NodeName = "All content",
                        Status = "ok"
                    });
                }
                else
                {
                    return(new DialogViewModel()
                    {
                        Status = "error", ErrorMessage = "Purging by tag not enabled."
                    });
                }
            }

            if (nodeId < -1)
            {
                return(new DialogViewModel()
                {
                    Status = "error", ErrorMessage = "Purging of this node is not allowed."
                });
            }

            var node = Umbraco.TypedContent(nodeId);

            if (node == null)
            {
                return(new DialogViewModel()
                {
                    Status = "error", ErrorMessage = "Invalid node id: " + nodeId
                });
            }

            if (node.TemplateId == 0)
            {
                return(new DialogViewModel()
                {
                    Status = "error", ErrorMessage = "There is no template for this node."
                });
            }

            // if KeyCDN Client ID and/or Secret are missing, return error message
            if (!CdnPurger.IsActive())
            {
                return new DialogViewModel()
                       {
                           Status = "error", ErrorMessage = "KeyCDN Client ID and/or Secret not set."
                       }
            }
            ;

            return(new DialogViewModel()
            {
                NodeId = nodeId,
                NodeName = node.Name,
                Status = "ok"
            });
        }