예제 #1
0
    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");
    }
예제 #2
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Display LANGUAGES option just in case its available in the current site context
        if (!pnlUILanguages.IsHidden)
        {
            pnlUILanguages.Visible = CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName) && CultureInfoProvider.LicenseVersionCheck();
        }
    }
예제 #3
0
    protected string[] tabElem_OnTabCreated(UIElementInfo element, string[] parameters, int tabIndex)
    {
        bool   splitViewSupported = true;
        string elementName        = element.ElementName.ToLower();

        switch (elementName)
        {
        case "properties.languages":
            splitViewSupported = false;
            if (!CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName) || !CultureInfoProvider.LicenseVersionCheck())
            {
                return(null);
            }
            break;

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

        case "properties.variants":
            // Check license
            if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), "") != "")
            {
                if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleEntry.ONLINEMARKETING) ||
                    !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", CMSContext.CurrentSiteName))
                {
                    return(null);
                }
            }
            break;
        }

        // Ensure tab preselection
        if (elementName.StartsWith("properties.") && (elementName.Substring("properties.".Length) == selected))
        {
            CurrentMaster.Tabs.SelectedTab = tabIndex;
        }

        // Ensure split view mode
        if (splitViewSupported && CMSContext.DisplaySplitMode)
        {
            parameters[2] = GetSplitViewUrl(parameters[2]);
        }

        return(parameters);
    }
예제 #4
0
    protected TabItem tabElem_OnTabCreated(UIElementInfo element, TabItem tab, int tabIndex)
    {
        string elementName = element.ElementName.ToLowerCSafe();
        string siteName    = CMSContext.CurrentSiteName;

        if ((elementName == "onlinemarketing.languages") && (!CultureInfoProvider.IsSiteMultilignual(siteName) || !CultureInfoProvider.LicenseVersionCheck()))
        {
            return(null);
        }

        if (elementName.StartsWithCSafe("onlinemarketing.") && (!ModuleEntry.IsModuleLoaded("cms.onlinemarketing")))
        {
            return(null);
        }

        return(tab);
    }
예제 #5
0
    protected string[] tabElem_OnTabCreated(UIElementInfo element, string[] parameters, int tabIndex)
    {
        string elementName = element.ElementName.ToLower();
        string siteName    = CMSContext.CurrentSiteName;

        if ((elementName == "onlinemarketing.languages") && (!CultureInfoProvider.IsSiteMultilignual(siteName) || !CultureInfoProvider.LicenseVersionCheck()))
        {
            return(null);
        }

        if (elementName.StartsWith("onlinemarketing.") && (!ModuleEntry.IsModuleLoaded("cms.onlinemarketing")))
        {
            return(null);
        }

        if (elementName.StartsWith("onlinemarketing.") && (elementName.Substring("onlinemarketing.".Length) == selected))
        {
            selectedTabIndex = tabIndex;
        }

        return(parameters);
    }
    /// <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();
        }
    }
예제 #7
0
    protected TabItem tabElem_OnTabCreated(UIElementInfo element, TabItem tab, int tabIndex)
    {
        bool   splitViewSupported = true;
        string elementName        = element.ElementName.ToLowerCSafe();

        switch (elementName)
        {
        case "properties.languages":
            splitViewSupported = false;
            if (!CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName) || !CultureInfoProvider.LicenseVersionCheck())
            {
                return(null);
            }
            break;

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

        case "properties.wireframe":
        {
            // Hide wireframe tab if wireframe is not present
            if ((DocumentManager.Node == null) || (DocumentManager.Node.NodeWireframeTemplateID <= 0))
            {
                return(null);
            }

            splitViewSupported = false;
        }
        break;

        case "properties.variants":

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


            break;

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

        // Ensure tab pre-selection
        if (elementName.StartsWithCSafe("properties.") && (elementName.Substring("properties.".Length) == selected))
        {
            CurrentMaster.Tabs.SelectedTab = tabIndex;
        }

        // Ensure split view mode
        if (splitViewSupported && CMSContext.DisplaySplitMode)
        {
            tab.RedirectUrl = GetSplitViewUrl(tab.RedirectUrl);
        }

        return(tab);
    }
예제 #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;
            }
        }
    }
예제 #9
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

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

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

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

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

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

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

                // No workflow
                if (node.GetWorkflow() == null)
                {
                    // Hide menu items
                    pnlUIWorkflow.Visible = false;
                    pnlUIVersions.Visible = false;
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // If there is only one culture on site and hiding is enabled hide webpart
            if (HideIfOneCulture && !CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName))
            {
                Visible = false;
                return;
            }

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

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

                string imgFlagIcon = String.Empty;

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

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

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

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

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

                result.Append("<ul>");

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

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

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

                result.Append("</ul></li></ul>");
                ltlLanguages.Text = result.ToString();
            }
            else if (HideIfOneCulture)
            {
                Visible = false;
            }
        }
    }
예제 #11
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");
        }
    }