Ejemplo n.º 1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
            _channelId = AuthRequest.GetQueryInt("channelId");
            _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));

            CacAttributes.SiteInfo  = SiteInfo;
            CacAttributes.ChannelId = _channelId;

            if (!IsPostBack)
            {
                if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ChannelEdit))
                {
                    PageUtils.RedirectToErrorPage("您没有修改栏目的权限!");
                    return;
                }

                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
                if (nodeInfo == null)
                {
                    return;
                }

                if (nodeInfo.ParentId == 0)
                {
                    PhLinkUrl.Visible           = false;
                    PhLinkType.Visible          = false;
                    PhChannelTemplateId.Visible = false;
                    PhFilePath.Visible          = false;
                }

                BtnSubmit.Attributes.Add("onclick", $"if (UE && UE.getEditor('Content', {ETextEditorTypeUtils.ConfigValues})){{ UE.getEditor('Content', {ETextEditorTypeUtils.ConfigValues}).sync(); }}");

                CacAttributes.Attributes = nodeInfo.Additional;

                if (PhLinkType.Visible)
                {
                    ELinkTypeUtils.AddListItems(DdlLinkType);
                }

                ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);

                CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
                if (PhChannelTemplateId.Visible)
                {
                    DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
                }
                DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);

                DataBind();

                if (PhChannelTemplateId.Visible)
                {
                    DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                    ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());
                }

                DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString());

                TbNodeName.Text      = nodeInfo.ChannelName;
                TbNodeIndexName.Text = nodeInfo.IndexName;
                if (PhLinkUrl.Visible)
                {
                    TbLinkUrl.Text = nodeInfo.LinkUrl;
                }

                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    item.Selected = StringUtils.In(nodeInfo.GroupNameCollection, item.Value);
                }
                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = nodeInfo.FilePath;
                }

                if (PhLinkType.Visible)
                {
                    ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType);
                }
                ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType);

                TbImageUrl.Text             = nodeInfo.ImageUrl;
                LtlImageUrlButtonGroup.Text = WebUtils.GetImageUrlButtonGroupHtml(SiteInfo, TbImageUrl.ClientID);
                TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content);
                if (TbKeywords.Visible)
                {
                    TbKeywords.Text = nodeInfo.Keywords;
                }
                if (TbDescription.Visible)
                {
                    TbDescription.Text = nodeInfo.Description;
                }
            }
            else
            {
                CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
            }
        }
Ejemplo n.º 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
            _channelId = AuthRequest.GetQueryInt("channelId");
            ReturnUrl  = StringUtils.ValueFromUrl(PageUtils.FilterSqlAndXss(AuthRequest.GetQueryString("ReturnUrl")));
            //if (!base.HasChannelPermissions(this.channelId, AppManager.CMS.Permission.Channel.ChannelAdd))
            //{
            //    PageUtils.RedirectToErrorPage("您没有添加栏目的权限!");
            //    return;
            //}

            var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            if (parentNodeInfo.Additional.IsChannelAddable == false)
            {
                PageUtils.RedirectToErrorPage("此栏目不能添加子栏目!");
                return;
            }

            CacAttributes.SiteInfo  = SiteInfo;
            CacAttributes.ChannelId = _channelId;

            if (!IsPostBack)
            {
                ChannelManager.AddListItems(DdlParentChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions);
                ControlUtils.SelectSingleItem(DdlParentChannelId, _channelId.ToString());

                DdlContentModelPluginId.Items.Add(new ListItem("<默认>", string.Empty));
                var contentTables = PluginContentManager.GetContentModelPlugins();
                foreach (var contentTable in contentTables)
                {
                    DdlContentModelPluginId.Items.Add(new ListItem(contentTable.Title, contentTable.Id));
                }
                ControlUtils.SelectSingleItem(DdlContentModelPluginId, parentNodeInfo.ContentModelPluginId);

                var plugins = PluginContentManager.GetAllContentRelatedPlugins(false);
                if (plugins.Count > 0)
                {
                    foreach (var pluginMetadata in plugins)
                    {
                        CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id));
                    }
                }
                else
                {
                    PhContentRelatedPluginIds.Visible = false;
                }

                CacAttributes.Attributes = new ExtendedAttributes();

                TbImageUrl.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", SiteInfo.Additional.WebUrl));

                var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID);
                BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID);
                BtnCreateContentRule.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbImageUrl.ClientID);
                BtnSelectImage.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalUploadImage.GetOpenWindowString(SiteId, TbImageUrl.ClientID);
                BtnUploadImage.Attributes.Add("onclick", showPopWinString);

                ELinkTypeUtils.AddListItems(DdlLinkType);

                ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);
                ControlUtils.SelectSingleItem(DdlTaxisType, ETaxisTypeUtils.GetValue(ETaxisType.OrderByTaxisDesc));

                CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
                DdlChannelTemplateId.DataSource       = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
                DdlContentTemplateId.DataSource       = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);

                DataBind();

                DdlChannelTemplateId.Items.Insert(0, new ListItem("<默认>", "0"));
                DdlChannelTemplateId.Items[0].Selected = true;

                DdlContentTemplateId.Items.Insert(0, new ListItem("<默认>", "0"));
                DdlContentTemplateId.Items[0].Selected = true;
                TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, string.Empty);
            }
            else
            {
                CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
            }
        }
Ejemplo n.º 3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");

            _channelId = Body.GetQueryInt("channelId");
            ReturnUrl  = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            if (Body.GetQueryString("CanNotEdit") == null && Body.GetQueryString("UncheckedChannel") == null)
            {
                if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ChannelEdit))
                {
                    PageUtils.RedirectToErrorPage("您没有修改栏目的权限!");
                    return;
                }
            }
            if (Body.IsQueryExists("CanNotEdit"))
            {
                BtnSubmit.Visible = false;
            }

            var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            if (nodeInfo == null)
            {
                return;
            }

            CacAttributes.SiteInfo  = SiteInfo;
            CacAttributes.ChannelId = _channelId;

            if (!IsPostBack)
            {
                DdlContentModelPluginId.Items.Add(new ListItem("<默认>", string.Empty));
                var contentTables = PluginContentManager.GetContentModelPlugins();
                foreach (var contentTable in contentTables)
                {
                    DdlContentModelPluginId.Items.Add(new ListItem(contentTable.Title, contentTable.Id));
                }
                ControlUtils.SelectSingleItem(DdlContentModelPluginId, nodeInfo.ContentModelPluginId);

                var plugins = PluginContentManager.GetAllContentRelatedPlugins(false);
                if (plugins.Count > 0)
                {
                    var relatedPluginIds =
                        TranslateUtils.StringCollectionToStringList(nodeInfo.ContentRelatedPluginIds);
                    foreach (var pluginMetadata in plugins)
                    {
                        CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id)
                        {
                            Selected = relatedPluginIds.Contains(pluginMetadata.Id)
                        });
                    }
                }
                else
                {
                    PhContentRelatedPluginIds.Visible = false;
                }

                CacAttributes.Attributes = nodeInfo.Additional;

                TbImageUrl.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", SiteInfo.Additional.WebUrl));

                var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID);
                BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID);
                BtnCreateContentRule.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbImageUrl.ClientID);
                BtnSelectImage.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalUploadImage.GetOpenWindowString(SiteId, TbImageUrl.ClientID);
                BtnUploadImage.Attributes.Add("onclick", showPopWinString);

                ELinkTypeUtils.AddListItems(DdlLinkType);
                ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);

                CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);

                DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);

                DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);

                DataBind();

                DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());

                DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString());

                TbNodeName.Text      = nodeInfo.ChannelName;
                TbNodeIndexName.Text = nodeInfo.IndexName;
                TbLinkUrl.Text       = nodeInfo.LinkUrl;

                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    item.Selected = CompareUtils.Contains(nodeInfo.GroupNameCollection, item.Value);
                }
                TbFilePath.Text            = nodeInfo.FilePath;
                TbChannelFilePathRule.Text = nodeInfo.ChannelFilePathRule;
                TbContentFilePathRule.Text = nodeInfo.ContentFilePathRule;

                ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType);
                ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType);
                ControlUtils.SelectSingleItem(RblIsChannelAddable, nodeInfo.Additional.IsChannelAddable.ToString());
                ControlUtils.SelectSingleItem(RblIsContentAddable, nodeInfo.Additional.IsContentAddable.ToString());

                TbImageUrl.Text = nodeInfo.ImageUrl;

                TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content);

                TbKeywords.Text    = nodeInfo.Keywords;
                TbDescription.Text = nodeInfo.Description;

                //this.Content.SiteId = base.SiteId;
                //this.Content.Text = StringUtility.TextEditorContentDecode(nodeInfo.Content, ConfigUtils.Instance.ApplicationPath, base.SiteInfo.SiteUrl);
            }
            else
            {
                CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
            }
        }
Ejemplo n.º 4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
            _channelId = Body.GetQueryInt("channelId");
            _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            CacAttributes.SiteInfo  = SiteInfo;
            CacAttributes.ChannelId = _channelId;

            if (!IsPostBack)
            {
                if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ChannelEdit))
                {
                    PageUtils.RedirectToErrorPage("您没有修改栏目的权限!");
                    return;
                }

                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
                if (nodeInfo == null)
                {
                    return;
                }

                if (nodeInfo.ParentId == 0)
                {
                    PhLinkUrl.Visible           = false;
                    PhLinkType.Visible          = false;
                    PhChannelTemplateId.Visible = false;
                    PhFilePath.Visible          = false;
                }

                BtnSubmit.Attributes.Add("onclick", "if (UE && UE.getEditor('Content', {{allowDivTransToP: false}})){ UE.getEditor('Content', {{allowDivTransToP: false}}).sync(); }");

                if (!string.IsNullOrEmpty(SiteInfo.Additional.ChannelEditAttributes))
                {
                    var channelEditAttributes = TranslateUtils.StringCollectionToStringList(SiteInfo.Additional.ChannelEditAttributes);
                    if (channelEditAttributes.Count > 0)
                    {
                        PhNodeName.Visible = PhNodeIndexName.Visible = PhLinkUrl.Visible = PhNodeGroupNameCollection.Visible = PhLinkType.Visible = PhTaxisType.Visible = PhChannelTemplateId.Visible = PhContentTemplateId.Visible = PhImageUrl.Visible = PhFilePath.Visible = PhContent.Visible = PhKeywords.Visible = PhDescription.Visible = false;
                        foreach (var attribute in channelEditAttributes)
                        {
                            if (attribute == ChannelAttribute.ChannelName)
                            {
                                PhNodeName.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.ChannelIndex)
                            {
                                PhNodeIndexName.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.LinkUrl)
                            {
                                PhLinkUrl.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.ChannelGroupNameCollection)
                            {
                                PhNodeGroupNameCollection.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.LinkType)
                            {
                                PhLinkType.Visible = true;
                            }
                            else if (attribute == nameof(ChannelInfoExtend.DefaultTaxisType))
                            {
                                PhTaxisType.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.ChannelTemplateId)
                            {
                                PhChannelTemplateId.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.ContentTemplateId)
                            {
                                PhContentTemplateId.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.ImageUrl)
                            {
                                PhImageUrl.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.FilePath)
                            {
                                PhFilePath.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.Content)
                            {
                                PhContent.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.Keywords)
                            {
                                PhKeywords.Visible = true;
                            }
                            else if (attribute == ChannelAttribute.Description)
                            {
                                PhDescription.Visible = true;
                            }
                        }
                    }
                }

                CacAttributes.Attributes = nodeInfo.Additional;

                if (PhLinkType.Visible)
                {
                    ELinkTypeUtils.AddListItems(DdlLinkType);
                }

                if (PhTaxisType.Visible)
                {
                    ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);
                }

                if (PhNodeGroupNameCollection.Visible)
                {
                    CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
                }
                if (PhChannelTemplateId.Visible)
                {
                    DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
                }
                if (PhContentTemplateId.Visible)
                {
                    DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);
                }

                DataBind();

                if (PhChannelTemplateId.Visible)
                {
                    DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                    ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());
                }

                if (PhContentTemplateId.Visible)
                {
                    DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
                    ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString());
                }

                if (PhNodeName.Visible)
                {
                    TbNodeName.Text = nodeInfo.ChannelName;
                }
                if (PhNodeIndexName.Visible)
                {
                    TbNodeIndexName.Text = nodeInfo.IndexName;
                }
                if (PhLinkUrl.Visible)
                {
                    TbLinkUrl.Text = nodeInfo.LinkUrl;
                }

                if (PhNodeGroupNameCollection.Visible)
                {
                    foreach (ListItem item in CblNodeGroupNameCollection.Items)
                    {
                        item.Selected = CompareUtils.Contains(nodeInfo.GroupNameCollection, item.Value);
                    }
                }
                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = nodeInfo.FilePath;
                }

                if (PhLinkType.Visible)
                {
                    ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType);
                }
                if (PhTaxisType.Visible)
                {
                    ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType);
                }

                if (PhImageUrl.Visible)
                {
                    TbImageUrl.Text             = nodeInfo.ImageUrl;
                    LtlImageUrlButtonGroup.Text = WebUtils.GetImageUrlButtonGroupHtml(SiteInfo, TbImageUrl.ClientID);
                }
                if (PhContent.Visible)
                {
                    TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content);

                    //this.Content.SiteId = base.SiteId;
                    //this.Content.Text = StringUtility.TextEditorContentDecode(nodeInfo.Content, ConfigUtils.Instance.ApplicationPath, base.SiteInfo.SiteUrl);
                }
                if (TbKeywords.Visible)
                {
                    TbKeywords.Text = nodeInfo.Keywords;
                }
                if (TbDescription.Visible)
                {
                    TbDescription.Text = nodeInfo.Description;
                }
            }
            else
            {
                CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
            }
        }