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 = CMSContext.CurrentSiteName;
            chkAllCultures.Visible = CultureInfoProvider.IsSiteMultilignual(currentSiteName);

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

        Visible        = (DeletedNode != null);
        btnCancel.Text = GetString("general.cancel");
    }
    /// <summary>
    /// Groups created event handler.
    /// </summary>
    protected void ucUIToolbar_OnGroupsCreated(object sender, List <Group> groups)
    {
        if (!IsPageNotFound)
        {
            // Replace Culture button
            Group culture = groups.Find(g => g.CssClass.Contains("OnSiteCultures"));
            if (culture != null)
            {
                // Hide culture selector when there is only one culture for the current site
                InfoDataSet <CultureInfo> sites = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);
                if ((sites.Tables[0].Rows.Count < 2) ||
                    (IsPageNotFound && OnSiteEditHelper.PageInfoForPageNotFound.NodeID == 0))
                {
                    // Remove the culture button
                    groups.Remove(culture);
                }
                else
                {
                    culture.ControlPath = "~/CMSAdminControls/UI/UniMenu/OnSiteEdit/CultureMenu.ascx";
                }
            }

            // Replace Device profile button
            Group deviceProfile = groups.Find(g => g.CssClass.Contains("OnSiteDeviceProfile"));
            if (deviceProfile != null)
            {
                // Hide device profile selector when there is only one device defined or device profile module is disabled
                if (!DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName))
                {
                    // Remove the device profile button
                    groups.Remove(deviceProfile);
                }
                else
                {
                    deviceProfile.ControlPath = "~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx";
                }
            }

            // Replace the Highlight and Hidden buttons
            Group otherGroup = groups.Find(g => g.CssClass.Contains("OnSiteOthers"));
            if (otherGroup != null)
            {
                otherGroup.ControlPath = "~/CMSAdminControls/UI/UniMenu/OnSiteEdit/OtherMenu.ascx";
            }

            // Use a specific css class for the large CMSDesk button
            if (largeCMSDeskButton)
            {
                Group adminsGroup = groups.Find(g => g.CssClass.Contains("OnSiteAdmins"));
                if (adminsGroup != null)
                {
                    adminsGroup.CssClass += " BigCMSDeskButton";
                }
            }
        }
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Init currently selected culture
        mnuLanguage.SelectedCulture           = Culture;
        mnuContent.NewImageUrl                = GetImageUrl("CMSModules/CMS_Ecommerce/newproductsection.png");
        mnuContent.DeleteImageUrl             = GetImageUrl("CMSModules/CMS_Ecommerce/deleteproductsection.png");
        mnuContent.ShrinkedButtonMinimalWidth = 79;
        mnuContent.SmallButtonMinimalWidth    = 80;

        // Hide language menu when only one language present
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS) && (siteCulturesDS.Tables[0].Rows.Count < 2))
        {
            pnlLanguageMenu.Visible    = false;
            mnuLanguage.StopProcessing = true;
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.ManagersContainer = this.scriptManager;

        // Register the dialog script
        ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/Menu.js");
        ScriptHelper.RegisterDialogScript(this);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ContentMenuScripts", ScriptHelper.GetScript("var contentDir = '" + ResolveUrl("~/CMSModules/Content/CMSDesk/") + "';"));

        ltlData.Text += string.Format("<input type=\"hidden\" id=\"imagesUrl\" value=\"{0}\" />",
                                      GetImageUrl("CMSModules/CMS_Content/Menu/", false, true));

        // Check (and ensure) the proper content culture
        CheckPreferredCulture(true);

        // Setup selected node ID
        selectedNodeId = QueryHelper.GetInteger("nodeid", 0);

        // Initialize menu
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        // Do not display language menu
        if (DataHelper.DataSourceIsEmpty(siteCulturesDS) || (siteCulturesDS.Tables[0].Rows.Count <= 1))
        {
            contentMenu.Groups = new string[, ] {
                { GetString("ContentMenu.ContentManagement"), "~/CMSAdminControls/UI/UniMenu/Content/ContentMenu.ascx", "ContentMenuGroup" }, { GetString("ContentMenu.ViewMode"), "~/CMSAdminControls/UI/UniMenu/Content/ModeMenu.ascx", "ContentMenuGroup" }, { GetString("contentmenu.other"), "~/CMSAdminControls/UI/UniMenu/Content/OtherMenu.ascx", "ContentMenuGroup" }
            };
        }
        else
        {
            contentMenu.Groups = new string[, ] {
                { GetString("ContentMenu.ContentManagement"), "~/CMSAdminControls/UI/UniMenu/Content/ContentMenu.ascx", "ContentMenuGroup" }, { GetString("ContentMenu.ViewMode"), "~/CMSAdminControls/UI/UniMenu/Content/ModeMenu.ascx", "ContentMenuGroup" }, { GetString("contentmenu.language"), "~/CMSModules/Content/Controls/LanguageMenu.ascx", "ContentMenuGroup" }, { GetString("contentmenu.other"), "~/CMSAdminControls/UI/UniMenu/Content/OtherMenu.ascx", "ContentMenuGroup" }
            };
        }

        ScriptHelper.RegisterTitleScript(this, GetString("cmsdesk.ui.content"));
    }
Esempio n. 5
0
    protected void ucPath_pathchanged(object sender, EventArgs ea)
    {
        string[] parameters = SessionHelper.GetValue(PreviewObjectName) as string[];

        // Get old site ID
        int SiteID = CMSContext.CurrentSiteID;

        if ((parameters != null) && (parameters.Length == 4))
        {
            SiteID = ValidationHelper.GetInteger(parameters[1], 0);
        }

        // If site ID changed - register postback for reload update panel with culture selector
        if (SiteID != ucPath.SiteID)
        {
            String script = Page.ClientScript.GetPostBackEventReference(imgShow, "reloadculture");
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "UpdateImageScript", ScriptHelper.GetScript(script));

            // If cultures from other site is shown
            DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(SiteInfoProvider.GetSiteName(ucPath.SiteID));
            if (!DataHelper.DataSourceIsEmpty(siteCulturesDS))
            {
                DataTable siteCultures = siteCulturesDS.Tables[0];
                // SelectedCulture may not be in site culture list
                DataRow[] dr = siteCulturesDS.Tables[0].Select("CultureCode= '" + ucSelectCulture.SelectedCulture + "'");
                if (dr.Length == 0)
                {
                    // In such case, select first site's culture
                    ucSelectCulture.SelectedCulture = ValidationHelper.GetString(siteCultures.Rows[0]["CultureCode"], CMSContext.CurrentUser.PreferredCultureCode);
                }
            }
        }

        UpdatePreview();
        RegisterRefreshPreviewScript();
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        string prefferedCultureCode = CMSContext.PreferredCultureCode;
        string defaultSmallIconUrl  = GetImageUrl("CMSModules/CMS_DeviceProfiles/default_list.png");
        string defaultBigIconUrl    = GetImageUrl("CMSModules/CMS_DeviceProfiles/default.png");
        string defaultString        = GetString("general.default");

        InfoDataSet <CultureInfo> siteCultures = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        pi = CMSContext.CurrentPageInfo ?? OnSiteEditHelper.PageInfoForPageNotFound;

        // Cultures button
        MenuItem cultureItem = new MenuItem();

        cultureItem.CssClass     = "BigButton";
        cultureItem.ImageAlign   = ImageAlign.Top;
        cultureItem.ImagePath    = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, prefferedCultureCode, "16x16"), URLHelper.ApplicationPath);
        cultureItem.Text         = GetString("general.cultures");
        cultureItem.Tooltip      = GetString("onsiteedit.languageselector");
        cultureItem.ImageAltText = GetString("general.cultures");

        // Add all cultures to the sub menu
        foreach (CultureInfo culture in siteCultures)
        {
            string iconUrl          = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16");
            string cultureName      = culture.CultureName;
            string cultureCode      = culture.CultureCode;
            string cultureShortName = culture.CultureShortName;

            if (cultureCode != prefferedCultureCode)
            {
                SubMenuItem menuItem = new SubMenuItem()
                {
                    Text         = cultureName,
                    Tooltip      = cultureName,
                    ImagePath    = iconUrl,
                    ImageAltText = cultureName
                };

                // Build the web part image html
                bool translationExists = NodeCultures.ContainsKey(cultureCode);

                if (translationExists)
                {
                    // Assign click action which changes the document culture
                    menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(URLHelper.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");";
                }
                else
                {
                    // Display the "Not translated" image
                    menuItem.RightImagePath    = GetImageUrl("/CMSModules/CMS_PortalEngine/OnSiteEdit/no_culture.png");
                    menuItem.RightImageAltText = GetString("onsitedit.culturenotavailable");

                    // Assign click action -> Create new document culture
                    menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');";
                }

                cultureItem.SubItems.Add(menuItem);
            }
            else
            {
                // Current culture
                cultureItem.Text         = culture.CultureShortName;
                cultureItem.Tooltip      = cultureName;
                cultureItem.ImagePath    = iconUrl;
                cultureItem.ImageAltText = cultureName;
            }
        }

        btnCulture.Buttons.Add(cultureItem);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            string preferredCultureCode = CMSContext.PreferredCultureCode;
            string currentSiteName      = CMSContext.CurrentSiteName;
            string where = "CultureCode IN (SELECT DocumentCulture FROM View_CMS_Tree_Joined WHERE NodeID = " + Node.NodeID + ")";
            DataSet documentCultures = CultureInfoProvider.GetCultures(where, null, 0, "CultureCode");

            // Get site cultures
            DataSet siteCultures = CultureInfoProvider.GetSiteCultures(currentSiteName);
            if (!DataHelper.DataSourceIsEmpty(siteCultures) && !DataHelper.DataSourceIsEmpty(documentCultures))
            {
                string suffixNotTranslated = GetString("SplitMode.NotTranslated");

                foreach (DataRow row in siteCultures.Tables[0].Rows)
                {
                    string cultureCode = ValidationHelper.GetString(row["CultureCode"], null);
                    string cultureName = ResHelper.LocalizeString(ValidationHelper.GetString(row["CultureName"], null));

                    string suffix = string.Empty;

                    // Compare with preferred culture
                    if (CMSString.Compare(preferredCultureCode, cultureCode, true) == 0)
                    {
                        suffix = GetString("SplitMode.Current");
                    }
                    else
                    {
                        // Find culture
                        DataRow[] findRows = documentCultures.Tables[0].Select("CultureCode = '" + cultureCode + "'");
                        if (findRows.Length == 0)
                        {
                            suffix = suffixNotTranslated;
                        }
                    }

                    // Add new item
                    ListItem item = new ListItem(cultureName + " " + suffix, cultureCode);
                    drpCultures.Items.Add(item);
                }
            }

            drpCultures.SelectedValue = CMSContext.SplitModeCultureCode;
            drpCultures.Attributes.Add("onchange", "if (parent.CheckChanges('frame2')) { parent.FSP_ChangeCulture(this); }");
        }

        // Image URL and tooltip
        helpElem.IconUrl       = GetImageUrl("Design/Controls/SplitView/splitviewhelpicon.png");
        imgHorizontal.ImageUrl = UIHelper.GetImageUrl(Page, HorizontalImageUrl);
        imgVertical.ImageUrl   = UIHelper.GetImageUrl(Page, VerticalImageUrl);
        imgClose.ImageUrl      = UIHelper.GetImageUrl(Page, CloseImageUrl);
        imgHorizontal.ToolTip  = GetString("splitmode.horizontallayout");
        imgVertical.ToolTip    = GetString("splitmode.verticallayout");
        imgClose.ToolTip       = GetString("splitmode.closesplitmode");

        // Set css class
        switch (CMSContext.SplitMode)
        {
        case SplitModeEnum.Horizontal:
            divHorizontal.Attributes["class"] = buttonSelectedClass;
            divVertical.Attributes["class"]   = buttonClass;
            break;

        case SplitModeEnum.Vertical:
            divHorizontal.Attributes["class"] = buttonClass;
            divVertical.Attributes["class"]   = buttonSelectedClass;
            break;

        default:
            divHorizontal.Attributes["class"] = buttonClass;
            divVertical.Attributes["class"]   = buttonClass;
            break;
        }

        string checkedSyncUrl   = UIHelper.GetImageUrl(Page, mSyncCheckedImageUrl);
        string uncheckedSyncUrl = UIHelper.GetImageUrl(Page, mSyncUncheckedImageUrl);

        // Synchronize image
        string tooltip = GetString("splitmode.scrollbarsynchronization");

        imgSync.AlternateText = tooltip;
        imgSync.ToolTip       = tooltip;
        imgSync.ImageUrl      = CMSContext.SplitModeSyncScrollbars ? checkedSyncUrl : uncheckedSyncUrl;

        StringBuilder script = new StringBuilder();

        script.Append(@"
function FSP_Layout(vertical, frameName, cssClassName)
{
    if ((frameName != null) && parent.CheckChanges(frameName)) {
        if (cssClassName != null) {
            var element = document.getElementById('", pnlMain.ClientID, @"');
            if (element != null) {
                element.setAttribute(""class"", 'SplitToolbar ' + cssClassName);
                element.setAttribute(""className"", 'SplitToolbar ' + cssClassName);
            }
        }
        var divRight = document.getElementById('", divRight.ClientID, @"');
        if (vertical) {
            divRight.setAttribute(""class"", 'RightAlign');
            parent.FSP_VerticalLayout();
        }
        else {
            divRight.setAttribute(""class"", '');
            parent.FSP_HorizontalLayout();
        }
    }
}");

        script.Append(@"
function FSP_Close() { if (parent.CheckChanges()) { parent.FSP_CloseSplitMode(); } }"
                      );

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "toolbarScript_" + ClientID, ScriptHelper.GetScript(script.ToString()));

        // Register js events
        imgHorizontal.Attributes.Add("onclick", "javascript:FSP_Layout(false,'frame1Vertical','Horizontal');");
        imgHorizontal.AlternateText = GetString("SplitMode.Horizontal");
        imgVertical.Attributes.Add("onclick", "javascript:FSP_Layout('true','frame1','Vertical');");
        imgVertical.AlternateText = GetString("SplitMode.Vertical");
        imgClose.Attributes.Add("onclick", "javascript:FSP_Close();");
        imgSync.Attributes.Add("onclick", "javascript:parent.FSP_SynchronizeToolbar()");
        imgClose.Style.Add("cursor", "pointer");

        // Set layout
        if (CMSContext.SplitMode == SplitModeEnum.Horizontal)
        {
            pnlMain.CssClass             = "SplitToolbar Horizontal";
            divRight.Attributes["class"] = null;
        }
        else if (CMSContext.SplitMode == SplitModeEnum.Vertical)
        {
            pnlMain.CssClass = "SplitToolbar Vertical";
        }

        // Register Init script - FSP_ToolbarInit(selectorId, checkboxId)
        StringBuilder initScript = new StringBuilder();

        initScript.Append("parent.FSP_ToolbarInit('", drpCultures.ClientID, "','", imgSync.ClientID, "','", checkedSyncUrl, "','", uncheckedSyncUrl,
                          "','", divHorizontal.ClientID, "','", divVertical.ClientID, "');");

        // Register js scripts
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "FSP_initToolbar", ScriptHelper.GetScript(initScript.ToString()));
    }
Esempio n. 8
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.PreferredUICulture;
        // Initialize current user
        currentUser = CMSContext.CurrentUser;
        // Initialize current site
        currentSite = CMSContext.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 char[] { '|' }, 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 = SqlHelperClass.AddWhereCondition(where, WhereCondition);
                }
                allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%",
                                           TreeProvider.ALL_CULTURES, true, 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
            CurrentMaster.Title.TitleText     = GetString("Content.DeleteTitle");
            CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");
            CurrentMaster.Title.HelpName      = "cms_content_delete";
            CurrentMaster.Title.HelpTopicName = "cms_content_delete";

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

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

            titleElemAsync.TitleText  = GetString("ContentDelete.DeletingDocuments");
            titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");

            // Set visibility of panels
            pnlContent.Visible = true;
            pnlLog.Visible     = false;

            if (!CultureInfoProvider.IsSiteMultilignual(currentSite.SiteName))
            {
                // 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(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty), tree);
                        }
                    }

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

                        if (IsProductsMode)
                        {
                            string startingPath = SettingsKeyProvider.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;
                            }
                        }

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

                                ShowInformation(GetString("delete.rootonlyglobaladmin"));
                            }
                            else
                            {
                                ShowWarning(GetString("Delete.RootWarning"), null, null);

                                plcDeleteRoot.Visible = true;
                            }
                        }

                        hasChildren = node.NodeChildNodesCount > 0;

                        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)
                        {
                            CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\"";
                            lblQuestion.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);
                            }
                            CurrentMaster.Title.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\"";

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

                                showSKUGroup = true;
                            }
                            else if (node.HasSKU && authorizedToDeleteSKU)
                            {
                                // Deleting product
                                if (!NodeSharesSKUWithOtherNode(tree, node))
                                {
                                    lblSKUActionInfo.Text     = GetString("contentdelete.assignedskuinfo");
                                    pnlDeleteSKU.GroupingText = 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;
                    }
                    else
                    {
                        if (!RequestHelper.IsPostBack())
                        {
                            URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists"));
                        }
                        else
                        {
                            // Hide everything
                            pnlContent.Visible = false;
                        }
                    }

                    lblQuestion.Text               = GetString("ContentDelete.Question");
                    chkAllCultures.Text            = GetString("ContentDelete.AllCultures");
                    chkDestroy.Text                = GetString("ContentDelete.Destroy");
                    pnlDeleteDocument.GroupingText = GetString("ContentDelete.Document");
                    pnlSeo.GroupingText            = GetString("ContentDelete.Seo");
                }
                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 += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                }
                                docList          += "<br />";
                                lblDocuments.Text = docList;

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

                                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.NodeChildNodesCount > 0;
                                }

                                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;
                        }
                    }

                    lblQuestion.Text = GetString("ContentDelete.QuestionMultiple");
                    CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleMultiple");
                    chkAllCultures.Text           = GetString("ContentDelete.AllCulturesMultiple");
                    chkDestroy.Text = GetString("ContentDelete.DestroyMultiple");
                    pnlDeleteDocument.GroupingText = GetString("ContentDelete.Documents");
                    pnlDeleteSKU.GroupingText      = GetString("ContentDelete.AssignedSKUs");
                    lblSKUActionInfo.Text          = GetString("ContentDelete.AssignedSKUsInfo");
                }

                // Init product actions
                if (!RequestHelper.IsPostBack())
                {
                    rblSKUAction.Items.Add(new System.Web.UI.WebControls.ListItem(GetString("ContentDelete.SKU.deleteordisable"), "deleteordisable"));
                    rblSKUAction.Items.Add(new System.Web.UI.WebControls.ListItem(GetString("ContentDelete.SKU.delete"), "delete"));
                    rblSKUAction.Items.Add(new System.Web.UI.WebControls.ListItem(GetString("ContentDelete.SKU.disable"), "disable"));
                    rblSKUAction.Items.Add(new System.Web.UI.WebControls.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 = SettingsKeyProvider.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            = CultureInfoProvider.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;
                    }
                }
            }
            else
            {
                // Hide everything
                pnlContent.Visible = false;
            }
        }
    }
Esempio n. 9
0
    protected DataSet gridDocuments_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        string currentSiteName = CMSContext.CurrentSiteName;

        // Check if node is not null
        if (Node != null)
        {
            // Get documents
            int topN = gridLanguages.GridView.PageSize * (gridLanguages.GridView.PageIndex + 1 + gridLanguages.GridView.PagerSettings.PageButtonCount);
            columns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, columns), "DocumentModifiedWhen, VersionNumber, DocumentLastPublished, DocumentIsWaitingForTranslation");
            DataSet   documentsDS = DocumentHelper.GetDocuments(currentSiteName, Node.NodeAliasPath, TreeProvider.ALL_CULTURES, false, null, null, null, -1, false, topN, columns, Tree);
            DataTable documents   = documentsDS.Tables[0];

            if (!DataHelper.DataSourceIsEmpty(documents))
            {
                // Get site cultures
                DataSet allSiteCultures = CultureInfoProvider.GetSiteCultures(currentSiteName).Copy();

                // Rename culture column to enable row transfer
                allSiteCultures.Tables[0].Columns[2].ColumnName = "DocumentCulture";

                // Create where condition for row transfer
                string where = documents.Rows.Cast <DataRow>().Aggregate("DocumentCulture NOT IN (", (current, row) => current + ("'" + SqlHelperClass.GetSafeQueryString(ValidationHelper.GetString(row["DocumentCulture"], string.Empty)) + "',"));
                where        = where.TrimEnd(',') + ")";

                // Transfer missing cultures, keep original list of site cultures
                DataHelper.TransferTableRows(documents, allSiteCultures.Copy().Tables[0], where, null);
                DataHelper.EnsureColumn(documents, "DocumentCultureDisplayName", typeof(string));

                // Ensure culture names
                foreach (DataRow cultDR in documents.Rows)
                {
                    string    cultureCode = cultDR["DocumentCulture"].ToString();
                    DataRow[] cultureRow  = allSiteCultures.Tables[0].Select("DocumentCulture='" + cultureCode + "'");
                    if (cultureRow.Length > 0)
                    {
                        cultDR["DocumentCultureDisplayName"] = cultureRow[0]["CultureName"].ToString();
                    }
                }

                // Ensure default culture to be first
                DataRow[] culturreDRs = documents.Select("DocumentCulture='" + DefaultSiteCulture + "'");
                if (culturreDRs.Length <= 0)
                {
                    throw new Exception("[ReloadData]: Default site culture '" + DefaultSiteCulture + "' is not assigned to the current site.");
                }

                DataRow defaultCultureRow = culturreDRs[0];

                DataRow dr = documents.NewRow();
                dr.ItemArray = defaultCultureRow.ItemArray;
                documents.Rows.InsertAt(dr, 0);
                documents.Rows.Remove(defaultCultureRow);

                // Get last modification date of default culture
                defaultCultureRow       = documents.Select("DocumentCulture='" + DefaultSiteCulture + "'")[0];
                defaultLastModification = ValidationHelper.GetDateTime(defaultCultureRow["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
                defaultLastPublished    = ValidationHelper.GetDateTime(defaultCultureRow["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);

                // Add column containing translation status
                documents.Columns.Add("TranslationStatus", typeof(TranslationStatusEnum));

                // Get proper translation status and store it to datatable
                foreach (DataRow document in documents.Rows)
                {
                    TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
                    int documentId = ValidationHelper.GetInteger(document["DocumentID"], 0);
                    if (documentId == 0)
                    {
                        status = TranslationStatusEnum.NotAvailable;
                    }
                    else
                    {
                        string   versionNumber    = ValidationHelper.GetString(DataHelper.GetDataRowValue(document, "VersionNumber"), null);
                        DateTime lastModification = DateTimeHelper.ZERO_TIME;

                        if (ValidationHelper.GetBoolean(document["DocumentIsWaitingForTranslation"], false))
                        {
                            status = TranslationStatusEnum.WaitingForTranslation;
                        }
                        else
                        {
                            // Check if document is outdated
                            if (versionNumber != null)
                            {
                                lastModification = ValidationHelper.GetDateTime(document["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);
                                status           = (lastModification < defaultLastPublished) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
                            }
                            else
                            {
                                lastModification = ValidationHelper.GetDateTime(document["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
                                status           = (lastModification < defaultLastModification) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
                            }
                        }
                    }
                    document["TranslationStatus"] = status;
                }

                // Bind datasource
                DataSet   filteredDocuments = documentsDS.Clone();
                DataRow[] filteredDocs      = documents.Select(gridLanguages.GetDataTableFilter());
                foreach (DataRow row in filteredDocs)
                {
                    filteredDocuments.Tables[0].ImportRow(row);
                }

                return(filteredDocuments);
            }
        }

        return(null);
    }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        currentUserPreferredCultureCode = CMSContext.CurrentUser.PreferredCultureCode;
        currentSiteName = CMSContext.CurrentSiteName;
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName);

        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS))
        {
            // Register jQuery cookie script
            ScriptHelper.RegisterJQueryCookie(Page);

            string    defaultCulture = CultureHelper.GetDefaultCulture(currentSiteName);
            DataTable siteCultures   = siteCulturesDS.Tables[0];
            int       culturesCount  = siteCultures.Rows.Count;
            if ((culturesCount <= 3) && (culturesCount > 1))
            {
                // Disable culture uniselector
                cultureSelector.StopProcessing = true;
                pnlLang.Visible = false;

                string[,] bigButtons = new string[culturesCount, 9];

                for (int i = 0; i < culturesCount; i++)
                {
                    string cultureCode      = siteCultures.Rows[i]["CultureCode"].ToString();
                    string cultureShortName = siteCultures.Rows[i]["CultureShortName"].ToString();
                    string cultureLongName  = ResHelper.LocalizeString(siteCultures.Rows[i]["CultureName"].ToString());

                    if (string.Compare(cultureCode, defaultCulture, true) == 0)
                    {
                        cultureLongName += " " + GetString("general.defaultchoice");
                    }

                    bigButtons[i, 0] = HTMLHelper.HTMLEncode(cultureShortName);
                    bigButtons[i, 1] = cultureLongName;
                    bigButtons[i, 2] = "BigButton";
                    bigButtons[i, 3] = "ChangeLanguageByCode('" + cultureCode + "')";
                    bigButtons[i, 4] = null;
                    bigButtons[i, 5] = GetFlagIconUrl(cultureCode, "48x48");
                    bigButtons[i, 6] = cultureLongName;
                    bigButtons[i, 7] = ImageAlign.Top.ToString();
                    bigButtons[i, 8] = "48";
                    if (currentUserPreferredCultureCode.ToLower() == cultureCode.ToLower())
                    {
                        buttons.SelectedIndex = i;
                    }
                }

                buttons.Buttons = bigButtons;
            }
            else
            {
                // Do not show culture selection buttons
                buttons.StopProcessing = true;

                // Initialize culture selector
                cultureSelector.AddDefaultRecord                = false;
                cultureSelector.SiteID                          = CMSContext.CurrentSiteID;
                cultureSelector.DropDownCultures.CssClass       = "ContentMenuLangDrop";
                cultureSelector.UpdatePanel.RenderMode          = UpdatePanelRenderMode.Inline;
                cultureSelector.DropDownCultures.AutoPostBack   = true;
                cultureSelector.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged;

                if (!URLHelper.IsPostback())
                {
                    cultureSelector.Value = currentUserPreferredCultureCode;
                }
            }

            string compare = GetString("SplitMode.Compare");
            // Split mode button
            string[,] splitButton   = new string[1, 9];
            splitButton[0, 0]       = compare;
            splitButton[0, 1]       = GetString("SplitMode.CompareLangVersions");
            splitButton[0, 2]       = "BigButton";
            splitButton[0, 3]       = "ChangeSplitMode()";
            splitButton[0, 4]       = null;
            splitButton[0, 5]       = GetImageUrl("CMSModules/CMS_Content/Menu/Compare.png");
            splitButton[0, 6]       = compare;
            splitButton[0, 7]       = ImageAlign.Top.ToString();
            splitButton[0, 8]       = "48";
            splitView.Buttons       = splitButton;
            splitView.SelectedIndex = CMSContext.DisplaySplitMode ? 0 : -1;
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            mLayoutSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " ";

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

                    // Save to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all" });
                        cs.Data            = ds;
                    }
                }
            }

            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    // Try to get data from cache
                    using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", CMSContext.CurrentSiteName, currentPageInfo.NodeAliasPath.ToLower()))
                    {
                        if (cs.LoadData)
                        {
                            // Initialize tree provider object
                            TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                            tp.FilterOutDuplicates       = false;
                            tp.CombineWithDefaultCulture = false;

                            // Get all language versions
                            DataSet culturesDs = tp.SelectNodes(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                            // Create culture/UrlPath collection
                            if (!DataHelper.DataSourceIsEmpty(culturesDs))
                            {
                                documentCultures = new Dictionary <string, string>();
                                foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                {
                                    string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                    string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                    documentCultures.Add(docCulture, urlPath);
                                }
                            }

                            // Add to the cache
                            if (cs.Cached)
                            {
                                cs.CacheDependency = this.GetCacheDependency();
                                cs.Data            = documentCultures;
                            }
                        }
                    }
                }

                // Render the cultures
                ltlHyperlinks.Text = "";

                int count = 0;
                int rows  = ds.Tables[0].Rows.Count;

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = dr["CultureCode"].ToString();
                    string cultureShortName = dr["CultureShortName"].ToString();
                    string cultureAlias     = Convert.ToString(dr["CultureAlias"]);

                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (!((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            // Get flag icon URL
                            imgFlagIcon = UIHelper.GetFlagIconUrl(this.Page, cultureCode, "16x16");

                            string url  = null;
                            string lang = cultureCode;
                            // Check whether culture alias is defined and if so use it
                            if (!String.IsNullOrEmpty(cultureAlias))
                            {
                                lang = cultureAlias;
                            }

                            // Get specific url with language prefix
                            if (this.UseURLsWithLangPrefix && documentCultures != null)
                            {
                                string urlPath = String.Empty;
                                if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                {
                                    urlPath = documentCultures[cultureCode.ToLower()];
                                }
                                url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, CMSContext.CurrentSiteName, lang);
                                url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                            }
                            // Get URL with lang parameter
                            else
                            {
                                // Build current URL
                                url = URLHelper.CurrentURL;
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                            }

                            if (ShowCultureNames)
                            {
                                // Add flag icon before the link text
                                ltlHyperlinks.Text += "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />";
                                ltlHyperlinks.Text += "<a href=\"" + url + "\">";
                                ltlHyperlinks.Text += HTMLHelper.HTMLEncode(cultureShortName);

                                // Set surrounding div css class
                                selectionClass = "languageSelectionWithCultures";
                            }
                            else
                            {
                                ltlHyperlinks.Text += "<a href=\"" + url + "\">" + "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />";

                                // Set surrounding div css class
                                selectionClass = "languageSelection";
                            }

                            count++;

                            // Check last item
                            if (count == rows)
                            {
                                ltlHyperlinks.Text += "</a>";
                            }
                            else
                            {
                                ltlHyperlinks.Text += "</a>" + Separator + mLayoutSeparator;
                            }
                        }
                    }
                }
            }
            else
            {
                // Hide if less than two cultures
                Visible = false;
            }

            if (string.IsNullOrEmpty(selectionClass))
            {
                ltrDivOpen.Text = "<div>";
            }
            else
            {
                ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">";
            }
            ltrDivClose.Text = "</div>";

            // Check if RTL hack must be applied
            if (CultureHelper.IsPreferredCultureRTL())
            {
                ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>";
            }
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            string culture = CMSContext.PreferredCultureCode;

            mSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " ";

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

                    // Add to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = this.GetCacheDependency();
                        cs.Data            = ds;
                    }
                }
            }

            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    // Try to get data from cache
                    using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", CMSContext.CurrentSiteName, currentPageInfo.NodeAliasPath.ToLower()))
                    {
                        if (cs.LoadData)
                        {
                            // Initialize tree provider object
                            TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                            tp.FilterOutDuplicates       = false;
                            tp.CombineWithDefaultCulture = false;

                            // Get all language versions
                            DataSet culturesDs = tp.SelectNodes(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                            // Create culture/UrlPath collection
                            if (!DataHelper.DataSourceIsEmpty(culturesDs))
                            {
                                documentCultures = new Dictionary <string, string>();
                                foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                {
                                    string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                    string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                    documentCultures.Add(docCulture, urlPath);
                                }
                            }

                            // Add to the cache
                            if (cs.Cached)
                            {
                                cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all", "node|" + CurrentSiteName.ToLower() + "|" + currentPageInfo.NodeAliasPath.ToLower() });
                                cs.Data            = documentCultures;
                            }
                        }
                    }
                }

                // Render the cultures
                ltlHyperlinks.Text = "";
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = Convert.ToString(dr["CultureCode"]);
                    string cultureAlias     = Convert.ToString(dr["CultureAlias"]);
                    string cultureShortName = Convert.ToString(dr["CultureShortName"]);
                    // Indicates whether exists document in specific culture
                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (!(HideCurrentCulture && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            if (String.Compare(culture, cultureCode, StringComparison.InvariantCultureIgnoreCase) != 0)
                            {
                                string url  = null;
                                string lang = cultureCode;
                                // Check whether culture alias is defined and if so use it
                                if (!String.IsNullOrEmpty(cultureAlias))
                                {
                                    lang = cultureAlias;
                                }

                                // Get specific url with language prefix
                                if (this.UseURLsWithLangPrefix && documentCultures != null)
                                {
                                    string urlPath = String.Empty;
                                    if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                    {
                                        urlPath = documentCultures[cultureCode.ToLower()];
                                    }
                                    url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, CMSContext.CurrentSiteName, lang);
                                    url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                    url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                    url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                }
                                // Get URL with lang parameter
                                else
                                {
                                    // Build current URL
                                    url = URLHelper.CurrentURL;
                                    url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                    url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                                }



                                ltlHyperlinks.Text += "<a href=\"" + url + "\">" + HTMLHelper.HTMLEncode(cultureShortName) + "</a>";
                            }
                            else
                            {
                                ltlHyperlinks.Text += cultureShortName;
                            }
                            ltlHyperlinks.Text += mSeparator;
                        }
                    }
                }
            }
            else
            {
                Visible = false;
            }
        }
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/UI/UniMenu/UniMenu.js");

        currentSiteName = (SiteID != 0) ? SiteInfoProvider.GetSiteName(SiteID) : CMSContext.CurrentSiteName;
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName);

        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS))
        {
            // Register jQuery cookie script
            ScriptHelper.RegisterJQueryCookie(Page);

            string    defaultCulture = CultureHelper.GetDefaultCulture(currentSiteName);
            DataTable siteCultures   = siteCulturesDS.Tables[0];

            culturesCount = siteCultures.Rows.Count;
            if ((culturesCount <= MaxCulturesInRow) && (culturesCount > 1))
            {
                // Disable cultures menu
                btnCultures.StopProcessing = true;

                for (int i = 0; i < culturesCount; i++)
                {
                    string cultureCode      = siteCultures.Rows[i]["CultureCode"].ToString();
                    string cultureShortName = siteCultures.Rows[i]["CultureShortName"].ToString();
                    string cultureLongName  = ResHelper.LocalizeString(siteCultures.Rows[i]["CultureName"].ToString());

                    if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                    {
                        cultureLongName += " " + GetString("general.defaultchoice");
                    }

                    MenuItem item = new MenuItem();
                    item.Text          = HTMLHelper.HTMLEncode(cultureShortName);
                    item.Tooltip       = cultureLongName;
                    item.CssClass      = "BigButton";
                    item.OnClientClick = "ChangeLanguage('" + cultureCode + "')";
                    item.ImagePath     = GetFlagIconUrl(cultureCode, "48x48");
                    item.ImageAltText  = cultureLongName;
                    item.ImageAlign    = ImageAlign.Top;
                    item.MinimalWidth  = 48;
                    buttons.Buttons.Add(item);

                    if (SelectedCulture.ToLowerCSafe() == cultureCode.ToLowerCSafe())
                    {
                        buttons.SelectedIndex = i;
                    }
                }
            }
            else
            {
                // Do not show culture selection buttons
                buttons.StopProcessing = true;

                CultureInfo ci = CultureInfoProvider.GetCultureInfo(SelectedCulture);

                MenuItem item = new MenuItem();
                item.Text         = ci.CultureShortName;
                item.Tooltip      = GetString(ci.CultureName);
                item.ImagePath    = GetFlagIconUrl(SelectedCulture, UseSmallLanguageButton ? "16x16" : "48x48");
                item.ImageAltText = GetString(ci.CultureName);

                SetStyles(item);

                // Generate submenu only if more cultures to choose from
                if (culturesCount > 1)
                {
                    foreach (DataRow row in siteCultures.Rows)
                    {
                        string cultureCode      = row["CultureCode"].ToString();
                        string cultureShortName = row["CultureShortName"].ToString();
                        string cultureLongName  = GetString(row["CultureName"].ToString());

                        if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                        {
                            cultureLongName += " " + GetString("general.defaultchoice");
                        }

                        string      flagUrl    = GetFlagIconUrl(cultureCode, "16x16");
                        string      flagBigUrl = GetFlagIconUrl(cultureCode, "48x48");
                        SubMenuItem menuItem   = new SubMenuItem()
                        {
                            Text          = cultureLongName,
                            Tooltip       = cultureLongName,
                            ImagePath     = flagUrl,
                            ImageAltText  = cultureShortName,
                            OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeLanguage({2});", ScriptHelper.GetString(cultureShortName), ScriptHelper.GetString(ResolveUrl(flagBigUrl)), ScriptHelper.GetString(cultureCode))
                        };

                        item.SubItems.Add(menuItem);
                    }
                }

                btnCultures.Buttons.Add(item);
            }

            if (culturesCount > 1)
            {
                string compare = GetString("SplitMode.Compare");

                // Split mode button
                MenuItem splitItem = new MenuItem();
                splitItem.Text          = compare;
                splitItem.Tooltip       = GetString("SplitMode.CompareLangVersions");
                splitItem.OnClientClick = "ChangeSplitMode()";
                splitItem.ImagePath     = GetImageUrl("CMSModules/CMS_Content/Menu/Compare.png");
                splitItem.ImageAltText  = compare;
                splitItem.AllowToggle   = true;
                splitItem.IsToggled     = CMSContext.DisplaySplitMode;

                SetStyles(splitItem);

                splitView.Buttons.Add(splitItem);
            }
            else
            {
                splitView.StopProcessing = true;
            }
        }
    }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialize menu
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        Group content = new Group
        {
            Caption     = GetString("ContentMenu.ContentManagement"),
            ControlPath = "~/CMSAdminControls/UI/UniMenu/Content/ContentMenu.ascx",
            CssClass    = "ContentMenuGroup"
        };

        contentMenu.Groups.Add(content);

        CMSUserControl modeMenu = Page.LoadUserControl("~/CMSAdminControls/UI/UniMenu/Content/ModeMenu.ascx") as CMSUserControl;

        if (modeMenu != null)
        {
            modeMenu.ID = "grpMode";
            modeMenu.SetValue("SelectedMode", SelectedMode);
            Group view = new Group
            {
                Caption  = GetString("ContentMenu.ViewMode"),
                Control  = modeMenu,
                CssClass = "ContentMenuGroup"
            };
            contentMenu.Groups.Add(view);
        }

        if (DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName))
        {
            CMSUserControl devicesMenu = Page.LoadUserControl("~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx") as CMSUserControl;
            if (devicesMenu != null)
            {
                devicesMenu.ID = "grpDevices";
                devicesMenu.SetValue("SelectedDevice", SelectedDevice);
                Group view = new Group
                {
                    Caption  = GetString("ContentMenu.Device"),
                    Control  = devicesMenu,
                    CssClass = "ContentMenuGroup"
                };
                contentMenu.Groups.Add(view);
            }
        }

        // Do not display language menu
        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS) && (siteCulturesDS.Tables[0].Rows.Count > 1))
        {
            CMSUserControl langMenu = Page.LoadUserControl("~/CMSModules/Content/Controls/LanguageMenu.ascx") as CMSUserControl;
            if (langMenu != null)
            {
                langMenu.ID = "grpLang";
                langMenu.SetValue("SelectedCulture", SelectedCulture);
                Group lang = new Group
                {
                    Control  = langMenu,
                    Caption  = GetString("contentmenu.language"),
                    CssClass = "ContentMenuGroup"
                };
                contentMenu.Groups.Add(lang);
            }
        }

        Group other = new Group
        {
            Caption     = GetString("contentmenu.other"),
            ControlPath = "~/CMSAdminControls/UI/UniMenu/Content/OtherMenu.ascx",
            CssClass    = "ContentMenuGroup"
        };

        contentMenu.Groups.Add(other);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register main CMS script file
        ScriptHelper.RegisterCMS(this);

        // Fix messages position
        MessagesPlaceHolder.WrapperControlClientID = pnlContent.ClientID;

        if (QueryHelper.ValidateHash("hash") && (Parameters != null))
        {
            // Initialize current user
            currentUser = CMSContext.CurrentUser;

            // Check permissions
            if (!currentUser.IsGlobalAdministrator &&
                !currentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow"))
            {
                RedirectToAccessDenied("CMS.Content", "manageworkflow");
            }

            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICulture;

            // Initialize current site
            currentSiteName = CMSContext.CurrentSiteName;
            currentSiteId   = CMSContext.CurrentSiteID;

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

            if (!IsCallback)
            {
                DataSet      allDocs = null;
                TreeProvider tree    = new TreeProvider(currentUser);

                // Current Node ID to delete
                string parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                if (string.IsNullOrEmpty(parentAliasPath))
                {
                    // Get IDs of nodes
                    string   nodeIdsString = ValidationHelper.GetString(Parameters["nodeids"], string.Empty);
                    string[] nodeIdsArr    = nodeIdsString.Split(new char[] { '|' }, 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 = SqlHelperClass.AddWhereCondition(where, WhereCondition);
                    }
                    string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS,
                                                                 "NodeParentID, DocumentName,DocumentCheckedOutByUserID");
                    allDocs = tree.SelectNodes(currentSiteName, parentAliasPath.TrimEnd('/') + "/%",
                                               TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", 1, false, 0,
                                               columns);

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

                // Initialize strings based on current action
                switch (CurrentAction)
                {
                case WorkflowAction.Archive:
                    lblQuestion.ResourceString    = "content.archivequestion";
                    chkAllCultures.ResourceString = "content.archiveallcultures";
                    chkUnderlying.ResourceString  = "content.archiveunderlying";
                    canceledString = GetString("content.archivecanceled");

                    // Setup title of log
                    titleElemAsync.TitleText  = GetString("content.archivingdocuments");
                    titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png");

                    // Setup page title text and image
                    CurrentMaster.Title.TitleText  = GetString("Content.ArchiveTitle");
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png");
                    break;

                case WorkflowAction.Publish:
                    lblQuestion.ResourceString    = "content.publishquestion";
                    chkAllCultures.ResourceString = "content.publishallcultures";
                    chkUnderlying.ResourceString  = "content.publishunderlying";
                    canceledString = GetString("content.publishcanceled");

                    // Setup title of log
                    titleElemAsync.TitleText  = GetString("content.publishingdocuments");
                    titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png");

                    // Setup page title text and image
                    CurrentMaster.Title.TitleText  = GetString("Content.PublishTitle");
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png");
                    break;
                }
                if (nodeIds.Count == 0)
                {
                    // Hide if no node was specified
                    pnlContent.Visible = false;
                    return;
                }

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

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

                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;

                // Set all cultures checkbox
                DataSet culturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName);
                if ((DataHelper.DataSourceIsEmpty(culturesDS)) || (culturesDS.Tables[0].Rows.Count <= 1))
                {
                    chkAllCultures.Checked = true;
                    plcAllCultures.Visible = false;
                }

                if (nodeIds.Count > 0)
                {
                    pnlDocList.Visible = true;

                    // Create where condition
                    string where = SqlHelperClass.GetWhereCondition("NodeID", nodeIds.ToArray());
                    string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID");

                    // Select nodes
                    DataSet ds = allDocs ?? tree.SelectNodes(currentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false, 0, columns);

                    // Enumerate selected documents
                    if (!DataHelper.DataSourceIsEmpty(ds))
                    {
                        cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);

                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            AddToList(dr);
                        }

                        // Display enumeration of documents
                        foreach (KeyValuePair <int, string> line in list)
                        {
                            lblDocuments.Text += line.Value;
                        }
                    }
                }
            }

            // Set title for dialog mode
            string imgUrl = "CMSModules/CMS_Content/Dialogs/publish.png";
            string title  = GetString("general.publish");

            if (CurrentAction == WorkflowAction.Archive)
            {
                imgUrl = "CMSModules/CMS_Content/Dialogs/archive.png";
                title  = GetString("general.archive");
            }

            SetTitle(imgUrl, title, null, null);
        }
        else
        {
            pnlPublish.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
        }
    }
Esempio n. 16
0
    /// <summary>
    /// Reloads control.
    /// </summary>
    /// <param name="forceReload">Forces nested CMSForm to reload if true</param>
    public void ReloadData(bool forceReload)
    {
        if (!mFormLoaded || forceReload)
        {
            // Check License
            LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.UserContributions);

            if (StopProcessing)
            {
                formElem.StopProcessing = true;
            }
            else
            {
                // Set document manager mode
                if (NewDocument)
                {
                    DocumentManager.Mode           = FormModeEnum.Insert;
                    DocumentManager.ParentNodeID   = NodeID;
                    DocumentManager.NewNodeClassID = ClassID;
                    DocumentManager.CultureCode    = CultureCode;
                    DocumentManager.SiteName       = SiteName;
                }
                else if (NewCulture)
                {
                    DocumentManager.Mode             = FormModeEnum.InsertNewCultureVersion;
                    DocumentManager.NodeID           = NodeID;
                    DocumentManager.CultureCode      = CultureCode;
                    DocumentManager.SiteName         = SiteName;
                    DocumentManager.SourceDocumentID = CopyDefaultDataFromDocumentID;
                }
                else
                {
                    DocumentManager.Mode        = FormModeEnum.Update;
                    DocumentManager.NodeID      = NodeID;
                    DocumentManager.SiteName    = SiteName;
                    DocumentManager.CultureCode = CultureCode;
                }

                ScriptHelper.RegisterDialogScript(Page);

                formElem.StopProcessing = false;

                titleElem.TitleImage = String.Empty;
                titleElem.TitleText  = String.Empty;

                pnlSelectClass.Visible = false;
                pnlEdit.Visible        = false;
                pnlInfo.Visible        = false;
                pnlNewCulture.Visible  = false;
                pnlDelete.Visible      = false;

                // If node found, init the form

                if (NewDocument || (Node != null))
                {
                    // Delete action
                    if (Delete)
                    {
                        // Delete document
                        pnlDelete.Visible = true;

                        titleElem.TitleText  = GetString("Content.DeleteTitle");
                        titleElem.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/delete.png");

                        chkAllCultures.Text = GetString("ContentDelete.AllCultures");
                        chkDestroy.Text     = GetString("ContentDelete.Destroy");

                        lblQuestion.Text = GetString("ContentDelete.Question");
                        btnYes.Text      = GetString("general.yes");
                        // Prevent button double-click
                        btnYes.Attributes.Add("onclick", string.Format("document.getElementById('{0}').disabled=true;this.disabled=true;{1};", btnNo.ClientID, ControlsHelper.GetPostBackEventReference(btnYes, string.Empty, true, false)));
                        btnNo.Text = GetString("general.no");

                        DataSet culturesDS = CultureInfoProvider.GetSiteCultures(SiteName);
                        if ((DataHelper.DataSourceIsEmpty(culturesDS)) || (culturesDS.Tables[0].Rows.Count <= 1))
                        {
                            chkAllCultures.Visible = false;
                            chkAllCultures.Checked = true;
                        }

                        if (Node.IsLink)
                        {
                            titleElem.TitleText    = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(Node.NodeName) + "\"";
                            lblQuestion.Text       = GetString("ContentDelete.QuestionLink");
                            chkAllCultures.Checked = true;
                            plcCheck.Visible       = false;
                        }
                        else
                        {
                            titleElem.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(Node.NodeName) + "\"";
                        }
                    }
                    // New document or edit action
                    else
                    {
                        if (NewDocument)
                        {
                            titleElem.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/new.png");
                            titleElem.TitleText  = GetString("Content.NewTitle");
                        }

                        // Document type selection
                        if (NewDocument && (ClassID <= 0))
                        {
                            // Use parent node
                            TreeNode parentNode = DocumentManager.ParentNode;
                            if (parentNode != null)
                            {
                                // Select document type
                                pnlSelectClass.Visible = true;

                                // Get the allowed child classes
                                DataSet ds = DataClassInfoProvider.GetAllowedChildClasses(ValidationHelper.GetInteger(parentNode.GetValue("NodeClassID"), 0), ValidationHelper.GetInteger(SiteInfoProvider.GetSiteInfo(SiteName).SiteID, 0), "ClassName, ClassDisplayName, ClassID", -1);

                                ArrayList deleteRows = new ArrayList();

                                if (!DataHelper.DataSourceIsEmpty(ds))
                                {
                                    // Get the unwanted classes
                                    string allowed = AllowedChildClasses.Trim().ToLowerCSafe();
                                    if (!string.IsNullOrEmpty(allowed))
                                    {
                                        allowed = String.Format(";{0};", allowed);
                                    }

                                    CurrentUserInfo userInfo  = CMSContext.CurrentUser;
                                    string          className = null;
                                    // Check if the user has 'Create' permission per Content
                                    bool isAuthorizedToCreateInContent = userInfo.IsAuthorizedPerResource("CMS.Content", "Create");
                                    bool hasNodeAllowCreate            = (userInfo.IsAuthorizedPerTreeNode(parentNode, NodePermissionsEnum.Create) != AuthorizationResultEnum.Allowed);
                                    foreach (DataRow dr in ds.Tables[0].Rows)
                                    {
                                        className = ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, "ClassName"), String.Empty).ToLowerCSafe();
                                        // Document type is not allowed or user hasn't got permission, remove it from the data set
                                        if ((!string.IsNullOrEmpty(allowed) && (!allowed.Contains(";" + className + ";"))) ||
                                            (CheckPermissions && CheckDocPermissionsForInsert && !isAuthorizedToCreateInContent && !userInfo.IsAuthorizedPerClassName(className, "Create") && (!userInfo.IsAuthorizedPerClassName(className, "CreateSpecific") || !hasNodeAllowCreate)))
                                        {
                                            deleteRows.Add(dr);
                                        }
                                    }

                                    // Remove the rows
                                    foreach (DataRow dr in deleteRows)
                                    {
                                        ds.Tables[0].Rows.Remove(dr);
                                    }
                                }

                                // Check if some classes are available
                                if (!DataHelper.DataSourceIsEmpty(ds))
                                {
                                    // If number of classes is more than 1 display them in grid
                                    if (ds.Tables[0].Rows.Count > 1)
                                    {
                                        ds.Tables[0].DefaultView.Sort = "ClassDisplayName";
                                        lblError.Visible = false;
                                        lblInfo.Visible  = true;
                                        lblInfo.Text     = GetString("Content.NewInfo");

                                        DataSet sortedResult = new DataSet();
                                        sortedResult.Tables.Add(ds.Tables[0].DefaultView.ToTable());
                                        gridClass.DataSource = sortedResult;
                                        gridClass.ReloadData();
                                    }
                                    // else show form of the only class
                                    else
                                    {
                                        ClassID = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "ClassID"), 0);
                                        ReloadData(true);
                                        return;
                                    }
                                }
                                else
                                {
                                    // Display error message
                                    lblError.Visible  = true;
                                    lblError.Text     = GetString("Content.NoAllowedChildDocuments");
                                    lblInfo.Visible   = false;
                                    gridClass.Visible = false;
                                }
                            }
                            else
                            {
                                pnlInfo.Visible         = true;
                                lblFormInfo.Text        = GetString("EditForm.DocumentNotFound");
                                formElem.StopProcessing = true;
                            }
                        }
                        // Insert or update of a document
                        else
                        {
                            // Display the form
                            pnlEdit.Visible = true;

                            // Try to get GroupID if group context exists
                            int currentGroupId = ModuleCommands.CommunityGetCurrentGroupID();

                            btnDelete.Attributes.Add("style", "display: none;");
                            btnRefresh.Attributes.Add("style", "display: none;");

                            // CMSForm initialization
                            formElem.NodeID                 = Node.NodeID;
                            formElem.SiteName               = SiteName;
                            formElem.CultureCode            = CultureCode;
                            formElem.ValidationErrorMessage = ValidationErrorMessage;
                            formElem.IsLiveSite             = IsLiveSite;
                            // Set group ID if group context exists
                            formElem.GroupID = currentGroupId;
                            // WebDAV is allowed for live site only if the permissions are checked or user is global administrator or for group context - user is group administrator
                            formElem.AllowWebDAV = !IsLiveSite || CheckPermissions || CMSContext.CurrentUser.IsGlobalAdministrator || CMSContext.CurrentUser.IsGroupAdministrator(currentGroupId);

                            // Set the form mode
                            if (NewDocument)
                            {
                                ci = DataClassInfoProvider.GetDataClass(ClassID);
                                if (ci == null)
                                {
                                    throw new Exception(String.Format("[CMSAdminControls/EditForm.aspx]: Class ID '{0}' not found.", ClassID));
                                }

                                string classDisplayName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ci.ClassDisplayName));
                                titleElem.TitleText = GetString("Content.NewTitle") + ": " + classDisplayName;

                                // Set default template ID
                                formElem.DefaultPageTemplateID = TemplateID > 0 ? TemplateID : ci.ClassDefaultPageTemplateID;

                                // Set document owner
                                formElem.OwnerID  = OwnerID;
                                formElem.FormMode = FormModeEnum.Insert;
                                string newClassName = ci.ClassName;
                                string newFormName  = newClassName + ".default";
                                if (!String.IsNullOrEmpty(AlternativeFormName))
                                {
                                    // Set the alternative form full name
                                    formElem.AlternativeFormFullName = GetAltFormFullName(ci.ClassName);
                                }
                                if (newFormName.ToLowerCSafe() != formElem.FormName.ToLowerCSafe())
                                {
                                    formElem.FormName = newFormName;
                                }
                            }
                            else if (NewCulture)
                            {
                                formElem.FormMode = FormModeEnum.InsertNewCultureVersion;
                                // Default data document ID
                                formElem.CopyDefaultDataFromDocumentId = CopyDefaultDataFromDocumentID;

                                ci = DataClassInfoProvider.GetDataClass(Node.NodeClassName);
                                formElem.FormName = Node.NodeClassName + ".default";
                                if (!String.IsNullOrEmpty(AlternativeFormName))
                                {
                                    // Set the alternative form full name
                                    formElem.AlternativeFormFullName = GetAltFormFullName(ci.ClassName);
                                }
                            }
                            else
                            {
                                formElem.FormMode = FormModeEnum.Update;
                                ci = DataClassInfoProvider.GetDataClass(Node.NodeClassName);
                                formElem.FormName = String.Empty;
                                if (!String.IsNullOrEmpty(AlternativeFormName))
                                {
                                    // Set the alternative form full name
                                    formElem.AlternativeFormFullName = GetAltFormFullName(ci.ClassName);
                                }

                                // Initialize the CMSForm
                                formElem.LoadForm(forceReload);
                            }

                            // Display the CMSForm
                            formElem.Visible = true;

                            ReloadForm();
                        }
                    }
                }
                // New culture version
                else
                {
                    // Switch to new culture version mode
                    DocumentManager.Mode        = FormModeEnum.InsertNewCultureVersion;
                    DocumentManager.NodeID      = NodeID;
                    DocumentManager.CultureCode = CultureCode;
                    DocumentManager.SiteName    = SiteName;

                    if (Node != null)
                    {
                        // Offer a new culture creation
                        pnlNewCulture.Visible = true;

                        titleElem.TitleText  = GetString("Content.NewCultureVersionTitle") + " (" + HTMLHelper.HTMLEncode(CMSContext.CurrentUser.PreferredCultureCode) + ")";
                        titleElem.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/new.png");

                        lblNewCultureInfo.Text = GetString("ContentNewCultureVersion.Info");
                        radCopy.Text           = GetString("ContentNewCultureVersion.Copy");
                        radEmpty.Text          = GetString("ContentNewCultureVersion.Empty");

                        radCopy.Attributes.Add("onclick", "ShowSelection();");
                        radEmpty.Attributes.Add("onclick", "ShowSelection()");

                        AddScript(
                            "function ShowSelection() { \n" +
                            "   if (document.getElementById('" + radCopy.ClientID + "').checked) { document.getElementById('divCultures').style.display = 'block'; } \n" +
                            "   else { document.getElementById('divCultures').style.display = 'none'; } \n" +
                            "} \n"
                            );

                        btnOk.Text = GetString("ContentNewCultureVersion.Create");

                        // Load culture versions
                        SiteInfo si = SiteInfoProvider.GetSiteInfo(Node.NodeSiteID);
                        if (si != null)
                        {
                            lstCultures.Items.Clear();

                            DataSet nodes = TreeProvider.SelectNodes(si.SiteName, Node.NodeAliasPath, TreeProvider.ALL_CULTURES, false, null, null, null, 1, false);
                            foreach (DataRow nodeCulture in nodes.Tables[0].Rows)
                            {
                                ListItem li = new ListItem();
                                li.Text  = CultureInfoProvider.GetCultureInfo(nodeCulture["DocumentCulture"].ToString()).CultureName;
                                li.Value = nodeCulture["DocumentID"].ToString();
                                lstCultures.Items.Add(li);
                            }
                            if (lstCultures.Items.Count > 0)
                            {
                                lstCultures.SelectedIndex = 0;
                            }
                        }
                    }
                    else
                    {
                        pnlInfo.Visible         = true;
                        lblFormInfo.Text        = GetString("EditForm.DocumentNotFound");
                        formElem.StopProcessing = true;
                    }
                }
            }
            // Set flag that the form is loaded
            mFormLoaded = true;
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            string siteName = CMSContext.CurrentSiteName;

            // If there is only one culture on site and hiding is enabled hide webpart
            if (HideIfOneCulture && !CultureInfoProvider.IsSiteMultilignual(siteName))
            {
                this.Visible = false;
                return;
            }

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", siteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(siteName);

                    // Save to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all" });
                        cs.Data            = ds;
                    }
                }
            }

            // Add CSS Stylesheet
            string cssUrl = URLHelper.ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/langselector.css");
            this.Page.Header.Controls.Add(new LiteralControl("<link href=\"" + cssUrl + "\" type=\"text/css\" rel=\"stylesheet\" />"));

            // Build current URL
            string url = URLHelper.CurrentURL;
            url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
            url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);

            string imgFlagIcon = "";

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

            // Current language
            CultureInfo culture = CultureInfoProvider.GetCultureInfo(CMSContext.CurrentUser.PreferredCultureCode);
            if (culture != null)
            {
                // Drop down imitating icon
                string dropIcon = ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/dd_arrow.gif");

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

                string currentCultureShortName = "";
                if (this.ShowCultureNames)
                {
                    currentCultureShortName = HTMLHelper.HTMLEncode(culture.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, HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, culture.CultureCode)), currentCultureShortName);
            }

            // List of languages
            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    if (currentPageInfo != null)
                    {
                        // Try to get data from cache
                        using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", siteName, currentPageInfo.NodeAliasPath.ToLower()))
                        {
                            if (cs.LoadData)
                            {
                                // Initialize tree provider object
                                TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                                tp.FilterOutDuplicates       = false;
                                tp.CombineWithDefaultCulture = false;

                                // Get all language versions
                                DataSet culturesDs = tp.SelectNodes(siteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                                // Create culture/UrlPath collection
                                if (!DataHelper.DataSourceIsEmpty(culturesDs))
                                {
                                    documentCultures = new Dictionary <string, string>();
                                    foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                    {
                                        string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                        string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                        documentCultures.Add(docCulture, urlPath);
                                    }
                                }

                                // Add to the cache
                                if (cs.Cached)
                                {
                                    cs.CacheDependency = this.GetCacheDependency();
                                    cs.Data            = documentCultures;
                                }
                            }
                        }
                    }
                }

                result.Append("<ul>");

                // Create options for other culture
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = dr["CultureCode"].ToString();
                    string cultureShortName = dr["CultureShortName"].ToString();
                    string cultureAlias     = dr["CultureAlias"].ToString();

                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (CMSContext.CurrentDocument != null && !string.IsNullOrEmpty(CMSContext.CurrentDocument.DocumentCulture) && !((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            url = null;
                            string lang = cultureCode;
                            // Check whether culture alias is defined and if so use it
                            if (!String.IsNullOrEmpty(cultureAlias))
                            {
                                lang = cultureAlias;
                            }

                            // Get specific url with language prefix
                            if (this.UseURLsWithLangPrefix && documentCultures != null)
                            {
                                string urlPath = String.Empty;
                                if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                {
                                    urlPath = documentCultures[cultureCode.ToLower()];
                                }
                                url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, siteName, lang);
                                url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                            }
                            // Get URL with lang parameter
                            else
                            {
                                // Build current URL
                                url = URLHelper.CurrentURL;
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                            }

                            // Language icon
                            imgFlagIcon = this.GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(cultureCode) + ".png");

                            if (this.ShowCultureNames)
                            {
                                cultureShortName = HTMLHelper.HTMLEncode(cultureShortName);
                            }
                            else
                            {
                                cultureShortName = "";
                            }
                            result.AppendFormat("<li><a style=\"background-image:url({0}); background-repeat: no-repeat\" href=\"{1}\">{2}</a></li>\r\n",
                                                imgFlagIcon, HTMLHelper.HTMLEncode(URLHelper.ResolveUrl(url)), cultureShortName);
                        }
                    }
                }
                result.Append("</ul>");
            }
            result.Append("</li></ul>");
            ltlLanguages.Text = result.ToString();
        }
    }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (QueryHelper.ValidateHash("hash"))
        {
            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICulture;
            // Initialize current user
            currentUser = CMSContext.CurrentUser;
            // Initialize current site
            currentSite = CMSContext.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 char[] { '|' },
                                                                                               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 = SqlHelperClass.AddWhereCondition(where, WhereCondition);
                    }
                    allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%",
                                               TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, where,
                                               "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                               TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID");

                    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
                CurrentMaster.Title.TitleText  = GetString("Content.DeleteTitle");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");

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

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

                titleElemAsync.TitleText  = GetString("ContentDelete.DeletingDocuments");
                titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");

                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;

                // Set all cultures checkbox

                if (!CultureInfoProvider.IsSiteMultilignual(currentSite.SiteName))
                {
                    chkAllCultures.Checked = true;
                    chkAllCultures.Visible = false;
                }

                if (nodeIds.Count > 0)
                {
                    if (nodeIds.Count == 1)
                    {
                        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, currentUser.PreferredCultureCode) ??
                                   tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                        }
                        else
                        {
                            if (allDocs != null)
                            {
                                DataRow dr = allDocs.Tables[0].Rows[0];
                                node = TreeNode.New(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty),
                                                    tree);
                            }
                        }

                        if (node != null)
                        {
                            if (!IsUserAuthorizedToDeleteDocument(node))
                            {
                                pnlDelete.Visible = false;
                                lblError.Text     = String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"),
                                                                  HTMLHelper.HTMLEncode(node.NodeAliasPath));
                            }

                            if (node.IsLink)
                            {
                                CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleLink") + " \"" +
                                                                HTMLHelper.HTMLEncode(node.DocumentName) + "\"";
                                lblQuestion.Text       = GetString("ContentDelete.QuestionLink");
                                chkAllCultures.Checked = true;
                                plcCheck.Visible       = false;
                            }
                            else
                            {
                                string nodeName = HTMLHelper.HTMLEncode(node.DocumentName);
                                // Get name for root document
                                if (node.NodeClassName.ToLower() == "cms.root")
                                {
                                    nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName);
                                }
                                CurrentMaster.Title.TitleText = GetString("Content.DeleteTitle") + " \"" + nodeName +
                                                                "\"";
                                // If there is SKU
                                if (node.HasSKU)
                                {
                                    GeneralizedInfo product = ModuleCommands.ECommerceGetSKUInfo(node.NodeSKUID);
                                    if (product != null)
                                    {
                                        bool authorized = false;
                                        // Check if product is global
                                        if (product.GetValue("SKUSiteID") == null)
                                        {
                                            // Check EcommerceGlobalModify permission
                                            authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceGlobalModify");
                                        }
                                        else
                                        {
                                            // Check ModifyProducts/EcommerceModify permission
                                            authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify");
                                        }

                                        if (authorized)
                                        {
                                            pnlDeleteSKU.Visible = true;
                                            chkDeleteSKU.Visible = true;
                                        }
                                    }
                                }
                            }

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

                            cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID;
                        }
                        lblQuestion.Text    = GetString("ContentDelete.Question");
                        chkAllCultures.Text = GetString("ContentDelete.AllCultures");
                        chkDestroy.Text     = GetString("ContentDelete.Destroy");
                        chkDeleteSKU.Text   = GetString("ContentDelete.SKU");
                    }
                    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))
                        {
                            TreeNode node    = null;
                            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;

                            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 += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                    }
                                    docList          += "<br />";
                                    lblDocuments.Text = docList;

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

                                    if (!IsUserAuthorizedToDeleteDocument(node))
                                    {
                                        pnlDelete.Visible = false;
                                        lblError.Text     = String.Format(
                                            GetString("cmsdesk.notauthorizedtodeletedocument"),
                                            HTMLHelper.HTMLEncode(node.NodeAliasPath));
                                        break;
                                    }

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

                                    if ((currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify")) &&
                                        (node.HasSKU))
                                    {
                                        pnlDeleteSKU.Visible = true;
                                        chkDeleteSKU.Visible = true;
                                    }
                                }
                            }
                            chkDestroy.Visible = canDestroy;
                        }

                        lblQuestion.Text = GetString("ContentDelete.QuestionMultiple");
                        CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleMultiple");
                        chkAllCultures.Text           = GetString("ContentDelete.AllCulturesMultiple");
                        chkDestroy.Text   = GetString("ContentDelete.DestroyMultiple");
                        chkDeleteSKU.Text = GetString("ContentDelete.SKUMultiple");
                    }
                    // If user has allowed cultures specified
                    if (currentUser.UserHasAllowedCultures)
                    {
                        // Get all site cultures
                        DataSet siteCultures            = CultureInfoProvider.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;
                        }
                    }
                }
                else
                {
                    // Hide everything
                    pnlContent.Visible = false;
                }
            }
        }
        else
        {
            pnlDelete.Visible = false;
            lblError.Text     = GetString("dialogs.badhashtext");
        }
    }