public void ReloadData(bool force)
    {
        if (DeletedNode != null)
        {
            if (!RequestHelper.IsPostBack() || force)
            {
                plcConfirmation.Visible = true;
            }
            // Display confirmation
            lblConfirmation.Text = string.Format(GetString("contentdelete.questionspecific"), DeletedNode.NodeName);

            // Set visibility of 'delete all cultures' checkbox
            string currentSiteName = SiteContext.CurrentSiteName;
            chkAllCultures.Visible = CultureSiteInfoProvider.IsSiteMultilingual(currentSiteName);

            if (MembershipContext.AuthenticatedUser.UserHasAllowedCultures)
            {
                DataSet siteCultures = CultureSiteInfoProvider.GetSiteCultures(currentSiteName);
                foreach (DataRow culture in siteCultures.Tables[0].Rows)
                {
                    string cultureCode = ValidationHelper.GetString(DataHelper.GetDataRowValue(culture, "CultureCode"), string.Empty);
                    if (!MembershipContext.AuthenticatedUser.IsCultureAllowed(cultureCode, currentSiteName))
                    {
                        chkAllCultures.Visible = false;
                        break;
                    }
                }
            }
        }

        Visible        = (DeletedNode != null);
        btnCancel.Text = GetString("general.cancel");
    }
Beispiel #2
0
 /// <summary>
 /// Handles visibility of culture settings radio buttons.
 /// </summary>
 private void HandleCultureSettings()
 {
     // Check multilingual mode
     if (!CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName))
     {
         if (radThisCulture.Checked)
         {
             radThisCulture.ResourceString = "Template.OwnOne";
             plcAllCultures.Visible        = false;
             plcThisCulture.Visible        = true;
         }
         else
         {
             radAllCultures.ResourceString = "Template.OwnOne";
             plcThisCulture.Visible        = false;
             plcAllCultures.Visible        = true;
         }
     }
 }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        // Set current UI culture
        currentCulture = CultureHelper.PreferredUICultureCode;
        // Initialize current user
        currentUser = MembershipContext.AuthenticatedUser;
        // Initialize current site
        currentSite = SiteContext.CurrentSite;

        // Initialize events
        ctlAsync.OnFinished   += ctlAsync_OnFinished;
        ctlAsync.OnError      += ctlAsync_OnError;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnCancel     += ctlAsync_OnCancel;

        if (!RequestHelper.IsCallback())
        {
            DataSet      allDocs = null;
            TreeProvider tree    = new TreeProvider(currentUser);
            btnCancel.Text = GetString("general.cancel");

            // Current Node ID to delete
            string parentAliasPath = string.Empty;
            if (Parameters != null)
            {
                parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
            }
            if (string.IsNullOrEmpty(parentAliasPath))
            {
                nodeIdsArr = QueryHelper.GetString("nodeid", string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string nodeId in nodeIdsArr)
                {
                    int id = ValidationHelper.GetInteger(nodeId, 0);
                    if (id != 0)
                    {
                        nodeIds.Add(id);
                    }
                }
            }
            else
            {
                string where = "ClassName <> 'CMS.Root'";
                if (!string.IsNullOrEmpty(WhereCondition))
                {
                    where = SqlHelper.AddWhereCondition(where, WhereCondition);
                }
                allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                           TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where,
                                           "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                           TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath,NodeSKUID");

                if (!DataHelper.DataSourceIsEmpty(allDocs))
                {
                    foreach (DataTable table in allDocs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                        }
                    }
                }
            }

            // Setup page title text and image
            PageTitle.TitleText = GetString("Content.DeleteTitle");
            EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

            btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

            // Register the dialog script
            ScriptHelper.RegisterDialogScript(this);

            titleElemAsync.TitleText = GetString("ContentDelete.DeletingDocuments");
            // Set visibility of panels
            pnlContent.Visible = true;
            pnlLog.Visible     = false;

            bool isMultilingual = CultureSiteInfoProvider.IsSiteMultilingual(currentSite.SiteName);
            if (!isMultilingual)
            {
                // Set all cultures checkbox
                chkAllCultures.Checked = true;
                chkAllCultures.Visible = false;
            }

            if (nodeIds.Count > 0)
            {
                if (nodeIds.Count == 1)
                {
                    // Single document deletion
                    int      nodeId = ValidationHelper.GetInteger(nodeIds[0], 0);
                    TreeNode node   = null;

                    if (string.IsNullOrEmpty(parentAliasPath))
                    {
                        // Get any culture if current not found
                        node = tree.SelectSingleNode(nodeId, CultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                    }
                    else
                    {
                        if (allDocs != null)
                        {
                            DataRow dr = allDocs.Tables[0].Rows[0];
                            node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr, tree);
                        }
                    }

                    if (node != null)
                    {
                        bool rootDeleteDisabled = false;

                        if (IsProductsMode)
                        {
                            string startingPath = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSStoreProductsStartingPath");
                            if (node.NodeAliasPath.CompareToCSafe(startingPath) == 0)
                            {
                                string closeLink = "<a href=\"#\"><span style=\"cursor: pointer;\" " +
                                                   "onclick=\"SelectNode(" + node.NodeID + "); return false;\">" + GetString("general.back") +
                                                   "</span></a>";

                                ShowError(string.Format(GetString("com.productsection.deleteroot"), closeLink, ""));
                                pnlDelete.Visible  = false;
                                rootDeleteDisabled = true;
                            }
                        }

                        if (node.IsRoot() && isMultilingual)
                        {
                            // Hide 'Delete all cultures' checkbox
                            chkAllCultures.Visible = false;

                            if (!URLHelper.IsPostback())
                            {
                                // Check if there are any documents in another culture or current culture has some documents
                                pnlDeleteRoot.Visible = IsAnyDocumentInAnotherCulture(node) && (tree.SelectNodesCount(SiteContext.CurrentSiteName, "/%", LocalizationContext.PreferredCultureCode, false, null, null, null, TreeProvider.ALL_LEVELS, false) > 0);

                                if (pnlDeleteRoot.Visible)
                                {
                                    // Insert 'Delete current root' option if current root node is translated to current culture
                                    if (node.DocumentCulture == LocalizationContext.PreferredCultureCode)
                                    {
                                        rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentroot"), "current"));
                                    }

                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentculture"), "allculturepages"));
                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages"));
                                }
                                else
                                {
                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages"));
                                }

                                if (rblRoot.SelectedIndex < 0)
                                {
                                    rblRoot.SelectedIndex = 0;
                                }
                            }
                        }

                        // Display warning for root node
                        if (!rootDeleteDisabled && node.IsRoot())
                        {
                            if (!currentUser.IsGlobalAdministrator)
                            {
                                pnlDelete.Visible = false;

                                ShowInformation(GetString("delete.rootonlyglobaladmin"));
                            }
                            else
                            {
                                if ((rblRoot.SelectedValue == "allpages") || !isMultilingual || ((rblRoot.SelectedValue == "allculturepages") && !IsAnyDocumentInAnotherCulture(node)))
                                {
                                    messagesPlaceholder.ShowWarning(GetString("Delete.RootWarning"));

                                    plcDeleteRoot.Visible = true;
                                }
                                else
                                {
                                    plcDeleteRoot.Visible = false;
                                }
                            }
                        }

                        hasChildren = node.NodeHasChildren;

                        bool authorizedToDeleteSKU = !node.HasSKU || IsUserAuthorizedToModifySKU(node);
                        if (!RequestHelper.IsPostBack())
                        {
                            bool authorizedToDeleteDocument = IsUserAuthorizedToDeleteDocument(node);
                            if (!authorizedToDeleteDocument || !authorizedToDeleteSKU)
                            {
                                pnlDelete.Visible = false;
                                RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                            }
                        }

                        if (node.IsLink)
                        {
                            PageTitle.TitleText    = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\"";
                            headQuestion.Text      = GetString("ContentDelete.QuestionLink");
                            chkAllCultures.Checked = true;
                            plcCheck.Visible       = false;
                        }
                        else
                        {
                            string nodeName = HTMLHelper.HTMLEncode(node.GetDocumentName());
                            // Get name for root document
                            if (node.NodeClassName.ToLowerCSafe() == "cms.root")
                            {
                                nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName);
                            }
                            PageTitle.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\"";

                            bool showSKUGroup = false;
                            if (NodeHasChildWithProduct(tree, node))
                            {
                                // Deleting product section
                                lblSKUActionInfo.Text = GetString("ContentDelete.SectionAssignedSKUInfo");
                                headDeleteSKU.Text    = GetString("ContentDelete.AssignedSKUs");

                                showSKUGroup = true;
                            }
                            else if (node.HasSKU && authorizedToDeleteSKU)
                            {
                                // Deleting product
                                if (!NodeSharesSKUWithOtherNode(tree, node))
                                {
                                    lblSKUActionInfo.Text = GetString("contentdelete.assignedskuinfo");
                                    headDeleteSKU.Text    = GetString("ContentDelete.AssignedSKU");

                                    showSKUGroup = true;
                                }
                            }

                            pnlDeleteSKU.Visible = showSKUGroup;
                            rblSKUAction.Visible = showSKUGroup;
                        }

                        // Show or hide checkbox
                        chkDestroy.Visible = CanDestroy(node);

                        cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID;

                        if (node.IsRoot())
                        {
                            // Change SEO panel if root is selected
                            pnlSeo.Visible = false;
                        }
                    }
                    else
                    {
                        if (!RequestHelper.IsPostBack())
                        {
                            URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists"));
                        }
                        else
                        {
                            // Hide everything
                            pnlContent.Visible = false;
                        }
                    }

                    headQuestion.Text       = GetString("ContentDelete.Question");
                    chkAllCultures.Text     = GetString("ContentDelete.AllCultures");
                    chkDestroy.Text         = GetString("ContentDelete.Destroy");
                    headDeleteDocument.Text = GetString("ContentDelete.Document");
                }
                else if (nodeIds.Count > 1)
                {
                    pnlDocList.Visible = true;
                    string where       = "NodeID IN (";
                    foreach (int nodeID in nodeIds)
                    {
                        where += nodeID + ",";
                    }

                    where = where.TrimEnd(',') + ")";
                    DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false);

                    if (!DataHelper.DataSourceIsEmpty(ds))
                    {
                        string docList = null;

                        if (string.IsNullOrEmpty(parentAliasPath))
                        {
                            cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                        }
                        else
                        {
                            cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath);
                        }

                        bool canDestroy  = true;
                        bool permissions = true;

                        foreach (DataTable table in ds.Tables)
                        {
                            foreach (DataRow dr in table.Rows)
                            {
                                bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                                string name   = (string)dr["DocumentName"];
                                docList += HTMLHelper.HTMLEncode(name);
                                if (isLink)
                                {
                                    docList += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                }
                                docList          += "<br />";
                                lblDocuments.Text = docList;

                                // Set visibility of checkboxes
                                TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr);

                                if (!IsUserAuthorizedToDeleteDocument(node))
                                {
                                    permissions = false;
                                    AddError(String.Format(
                                                 GetString("cmsdesk.notauthorizedtodeletedocument"),
                                                 HTMLHelper.HTMLEncode(node.NodeAliasPath)), null);
                                }

                                // Can destroy if "can destroy all previous AND current"
                                canDestroy = CanDestroy(node) && canDestroy;

                                if (!hasChildren)
                                {
                                    hasChildren = node.NodeHasChildren;
                                }

                                if ((node.HasSKU && IsUserAuthorizedToModifySKU(node)) || NodeHasChildWithProduct(tree, node))
                                {
                                    pnlDeleteSKU.Visible = true;
                                    rblSKUAction.Visible = true;
                                }
                            }
                        }

                        pnlDelete.Visible  = permissions;
                        chkDestroy.Visible = canDestroy;
                    }
                    else
                    {
                        if (!RequestHelper.IsPostBack())
                        {
                            URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists"));
                        }
                        else
                        {
                            // Hide everything
                            pnlContent.Visible = false;
                        }
                    }

                    headQuestion.Text       = GetString("ContentDelete.QuestionMultiple");
                    PageTitle.TitleText     = GetString("Content.DeleteTitleMultiple");
                    chkAllCultures.Text     = GetString("ContentDelete.AllCulturesMultiple");
                    chkDestroy.Text         = GetString("ContentDelete.DestroyMultiple");
                    headDeleteDocument.Text = GetString("global.pages");
                    headDeleteSKU.Text      = GetString("ContentDelete.AssignedSKUs");
                    lblSKUActionInfo.Text   = GetString("ContentDelete.AssignedSKUsInfo");
                }

                // Init product actions
                if (!RequestHelper.IsPostBack())
                {
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.deleteordisable"), "deleteordisable"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.delete"), "delete"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.disable"), "disable"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.noaction"), "noaction"));

                    rblSKUAction.SelectedValue = "deleteordisable";
                }

                lblAltPath.AssociatedControlClientID = selAltPath.PathTextBox.ClientID;

                chkUseDeletedPath.CheckedChanged += chkUseDeletedPath_CheckedChanged;
                if (!RequestHelper.IsPostBack())
                {
                    selAltPath.Enabled     = false;
                    chkAltSubNodes.Enabled = false;
                    chkAltAliases.Enabled  = false;

                    // Set default path if is defined
                    selAltPath.Value = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSDefaultDeletedNodePath");

                    if (!hasChildren)
                    {
                        chkAltSubNodes.Checked = false;
                        chkAltSubNodes.Enabled = false;
                    }
                }

                // If user has allowed cultures specified
                if (currentUser.UserHasAllowedCultures)
                {
                    // Get all site cultures
                    DataSet siteCultures            = CultureSiteInfoProvider.GetSiteCultures(currentSite.SiteName);
                    bool    denyAllCulturesDeletion = false;
                    // Check that user can edit all site cultures
                    foreach (DataRow culture in siteCultures.Tables[0].Rows)
                    {
                        string cultureCode = ValidationHelper.GetString(DataHelper.GetDataRowValue(culture, "CultureCode"), string.Empty);
                        if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName))
                        {
                            denyAllCulturesDeletion = true;
                        }
                    }
                    // If user can't edit all site cultures
                    if (denyAllCulturesDeletion)
                    {
                        // Hide all cultures selector
                        chkAllCultures.Visible = false;
                        chkAllCultures.Checked = false;
                    }
                }
                pnlDeleteDocument.Visible = chkAllCultures.Visible || chkDestroy.Visible;
            }
            else
            {
                // Hide everything
                pnlContent.Visible = false;
            }
        }
    }
Beispiel #4
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;
        }
    }
Beispiel #5
0
    /// <summary>
    /// Creates default mass actions. Has to be called on Page_Init before MassActions extenders are initialized, so default actions will be at the beginning.
    /// </summary>
    private void CreateMassActionItems()
    {
        var urlBuilder = new DocumentListMassActionsUrlGenerator();

        // Converts functions with signature as in DocumentListMassActionsUrlGenerator to CreateUrlDelegate as MassActionItem expects
        Func <Func <List <int>, DocumentListMassActionsParameters, string>, CreateUrlDelegate> functionConverter = generateActionFunction =>
        {
            return((scope, selectedNodeIDs, parameters) =>
            {
                return generateActionFunction(scope == MassActionScopeEnum.AllItems ? null : selectedNodeIDs, (DocumentListMassActionsParameters)parameters);
            });
        };

        ctrlMassActions.AddMassActions(
            new MassActionItem
        {
            CodeName = "action|move",
            DisplayNameResourceString = "general.move",
            CreateUrl  = functionConverter(urlBuilder.GetMoveActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        },
            new MassActionItem
        {
            CodeName = "action|copy",
            DisplayNameResourceString = "general.copy",
            CreateUrl  = functionConverter(urlBuilder.GetCopyActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        });

        ctrlMassActions.AddMassActions(new MassActionItem
        {
            CodeName = "action|link",
            DisplayNameResourceString = "general.link",
            CreateUrl  = functionConverter(urlBuilder.GetLinkActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        });

        ctrlMassActions.AddMassActions(new MassActionItem
        {
            CodeName = "action|delete",
            DisplayNameResourceString = "general.delete",
            CreateUrl  = functionConverter(urlBuilder.GetDeleteActionUrl),
            ActionType = MassActionTypeEnum.Redirect,
        });

        if (CultureSiteInfoProvider.IsSiteMultilingual(currentSiteName) &&
            LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.TranslationServices) &&
            TranslationServiceHelper.IsTranslationAllowed(currentSiteName) &&
            TranslationServiceHelper.AnyServiceAvailable(currentSiteName))
        {
            ctrlMassActions.AddMassActions(new MassActionItem
            {
                CodeName = "action|translate",
                DisplayNameResourceString = "general.translate",
                CreateUrl  = functionConverter(urlBuilder.GetTranslateActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            });
        }

        if (currentUserInfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || currentUserInfo.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow"))
        {
            ctrlMassActions.AddMassActions(
                new MassActionItem
            {
                CodeName = "action|publish",
                DisplayNameResourceString = "general.publish",
                CreateUrl  = functionConverter(urlBuilder.GetPublishActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            },
                new MassActionItem
            {
                CodeName = "action|archive",
                DisplayNameResourceString = "general.archive",
                CreateUrl  = functionConverter(urlBuilder.GetArchiveActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            });
        }
    }
Beispiel #6
0
    protected void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        var tab     = e.Tab;
        var element = e.UIElement;

        var manager = DocumentManager;
        var node    = manager.Node;

        bool splitViewSupported = PortalContext.ViewMode != ViewModeEnum.EditLive;

        string elementName = element.ElementName.ToLowerCSafe();

        if (DocumentUIHelper.IsElementHiddenForNode(element, node))
        {
            e.Tab = null;
            return;
        }

        switch (elementName)
        {
        case "properties.languages":
            splitViewSupported = false;
            if (!CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName) || !CultureSiteInfoProvider.LicenseVersionCheck())
            {
                e.Tab = null;
                return;
            }
            break;

        case "properties.security":
        case "properties.relateddocs":
        case "properties.linkeddocs":
            splitViewSupported = false;
            break;

        case "properties.variants":

            if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, "") != "")
            {
                // Check license and whether content personalization is enabled and whether exists at least one variant for current template
                if ((node == null) ||
                    !LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleName.ONLINEMARKETING) ||
                    !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", SiteContext.CurrentSiteName) ||
                    !PortalContext.ContentPersonalizationEnabled ||
                    (VariantHelper.GetVariantID(VariantModeEnum.ContentPersonalization, node.GetUsedPageTemplateId(), String.Empty) <= 0))
                {
                    e.Tab = null;
                    return;
                }
            }
            break;

        case "properties.workflow":
        case "properties.versions":
            if (manager.Workflow == null)
            {
                e.Tab = null;
                return;
            }
            break;

        case "properties.personas":
            tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "objectid", manager.NodeID.ToString(CultureInfo.InvariantCulture));
            break;
        }

        // UI elements could have a different display name if content only document is selected
        tab.Text = DocumentUIHelper.GetUIElementDisplayName(element, node);

        // Ensure split view mode
        if (splitViewSupported && UIContext.DisplaySplitMode)
        {
            tab.RedirectUrl = DocumentUIHelper.GetSplitViewUrl(tab.RedirectUrl);
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // If there is only one culture on site and hiding is enabled hide webpart
            if (HideIfOneCulture && !CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName))
            {
                Visible = false;
                return;
            }

            // Get list of cultures
            List <string[]> cultures = GetCultures();

            // Check whether exists more than one culture
            if ((cultures != null) && ((cultures.Count > 1) || (HideCurrentCulture && (cultures.Count > 0))))
            {
                // Add CSS Stylesheet
                CSSHelper.RegisterCSSLink(Page, URLHelper.ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/langselector.css"));

                string imgFlagIcon = String.Empty;

                StringBuilder result = new StringBuilder();
                result.Append("<ul class=\"langselector\">");

                // Set first item to the current language
                CultureInfo ci = CultureInfoProvider.GetCultureInfo(CultureHelper.GetPreferredCulture());
                if (ci != null)
                {
                    // Drop down imitating icon
                    string dropIcon = ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/dd_arrow.gif");

                    // Current language
                    imgFlagIcon = GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(ci.CultureCode) + ".png");

                    string currentCultureShortName = String.Empty;
                    if (ShowCultureNames)
                    {
                        currentCultureShortName = HTMLHelper.HTMLEncode(ci.CultureShortName);
                    }

                    result.AppendFormat("<li class=\"lifirst\" style=\"background-image:url('{0}'); background-repeat: no-repeat\"><a class=\"first\" style=\"background-image:url({1}); background-repeat: no-repeat\" href=\"{2}\">{3}</a>",
                                        dropIcon, imgFlagIcon, "#", currentCultureShortName);
                }

                result.Append("<ul>");

                // Loop thru all cultures
                foreach (string[] data in cultures)
                {
                    string url  = data[0];
                    string code = data[1];
                    string name = HTMLHelper.HTMLEncode(data[2]);

                    // Language icon
                    imgFlagIcon = GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(code) + ".png");
                    if (!ShowCultureNames)
                    {
                        name = string.Empty;
                    }

                    result.AppendFormat("<li><a style=\"background-image:url({0}); background-repeat: no-repeat\" href=\"{1}\">{2}</a></li>\r\n",
                                        imgFlagIcon, HTMLHelper.EncodeForHtmlAttribute(URLHelper.ResolveUrl(url)), name);
                }

                result.Append("</ul></li></ul>");
                ltlLanguages.Text = result.ToString();
            }
            else if (HideIfOneCulture)
            {
                Visible = false;
            }
        }
    }