Ejemplo n.º 1
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        TreeNode     node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            // Hide Properties for wireframe
            plcProperties.Visible &= !node.IsWireframe();
            if (plcProperties.Visible)
            {
                // Properties menu
                var elements = UIElementInfoProvider.GetChildUIElements("CMS.Content", "Properties");
                if (!DataHelper.DataSourceIsEmpty(elements))
                {
                    var      index = 0;
                    UserInfo user  = MembershipContext.AuthenticatedUser;

                    foreach (var elem in elements)
                    {
                        // If UI element is available and user has permission to show it then add it
                        if (UIContextHelper.CheckElementAvailabilityInUI(elem) && user.IsAuthorizedPerUIElement(elem.ElementResourceID, elem.ElementName))
                        {
                            var elementName = elem.ElementName;

                            switch (elementName.ToLower())
                            {
                            case "properties.languages":
                                if (!CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName) || !CultureSiteInfoProvider.LicenseVersionCheck())
                                {
                                    continue;
                                }
                                break;

                            case "properties.wireframe":
                                if (node.NodeWireframeTemplateID <= 0)
                                {
                                    continue;
                                }
                                break;

                            case "properties.variants":
                                if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleName.ONLINEMARKETING) ||
                                    !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", SiteContext.CurrentSiteName) ||
                                    !PortalContext.ContentPersonalizationEnabled ||
                                    (VariantHelper.GetVariantID(VariantModeEnum.ContentPersonalization, node.GetUsedPageTemplateId(), String.Empty) <= 0))
                                {
                                    continue;
                                }
                                break;

                            case "properties.workflow":
                            case "properties.versions":
                                if (node.GetWorkflow() == null)
                                {
                                    continue;
                                }
                                break;
                            }


                            var item = new ContextMenuItem();
                            item.ID = "p" + index;
                            item.Attributes.Add("onclick", String.Format("Properties(GetContextMenuParameter('nodeMenu'), '{0}');", elementName));
                            item.Text = ResHelper.LocalizeString(elem.ElementDisplayName);

                            pnlPropertiesMenu.Controls.Add(item);

                            index++;
                        }
                    }

                    if (index == 0)
                    {
                        // Hide 'Properties' menu if user has no permission for at least one properties section
                        plcProperties.Visible = false;
                    }
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }
Ejemplo n.º 2
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
        TreeNode     node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            // Hide Properties menu item with separator
            plcProperties.Visible = !HidePropertiesItem && !node.IsWireframe();
            if (plcProperties.Visible)
            {
                iProperties.ImageUrl = GetImageUrl("CMSModules/CMS_Content/ContextMenu/Properties.png");
                iProperties.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'general');");

                // Properties menu
                iGeneral.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'general');");
                iUrls.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'urls');");
                iTemplate.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'template');");
                iMetadata.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'metadata');");
                iCategories.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'categories');");
                iMenu.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'menu');");
                iWorkflow.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'workflow');");
                iVersions.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'versions');");
                iRelated.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'relateddocs');");
                iLinked.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'linkeddocs');");
                iSecurity.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'security');");
                iAttachments.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'attachments');");
                iLanguages.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'languages');");
                iWireframe.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'wireframe');");
                iVariants.Attributes.Add("onclick", "Properties(GetContextMenuParameter('nodeMenu'), 'variants');");

                // Hide language item
                if (!CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName) || !CultureInfoProvider.LicenseVersionCheck())
                {
                    pnlUILanguages.Visible = false;
                }

                // Hide wireframe tab if wireframe is not present
                if (node.NodeWireframeTemplateID <= 0)
                {
                    pnlUIWireframe.Visible = false;
                }

                if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), "") != "")
                {
                    // Check license and whether content personalization is enabled and whether exists at least one variant for current template
                    if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleEntry.ONLINEMARKETING) ||
                        !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", CMSContext.CurrentSiteName) ||
                        !PortalContext.ContentPersonalizationEnabled ||
                        (ModuleCommands.OnlineMarketingGetContentPersonalizationVariantId(node.GetUsedPageTemplateId(), String.Empty) <= 0))
                    {
                        pnlUICPVariants.Visible = false;
                    }
                }

                // No workflow
                if (node.GetWorkflow() == null)
                {
                    // Hide menu items
                    pnlUIWorkflow.Visible = false;
                    pnlUIVersions.Visible = false;
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }