public Dictionary <string, object> ToDictionary()
        {
            var jObject = JObject.FromObject(this);

            var styleInfoList = TableStyleManager.GetChannelStyleInfoList(this);

            foreach (var styleInfo in styleInfoList)
            {
                jObject[styleInfo.AttributeName] = Attributes.GetString(styleInfo.AttributeName);
            }

            var siteInfo = SiteManager.GetSiteInfo(SiteId);

            if (!string.IsNullOrEmpty(ImageUrl))
            {
                jObject[nameof(ImageUrl)] = PageUtility.ParseNavigationUrl(siteInfo, ImageUrl, false);
            }

            jObject["NavigationUrl"] = PageUtility.GetChannelUrl(siteInfo, this, false);

            var dict = jObject.ToObject <Dictionary <string, object> >();

            if (Children == null)
            {
                Children = ChannelManager.GetChildren(SiteId, Id);
            }

            var list = Children.Select(channelInfo => channelInfo.ToDictionary()).ToList();

            dict["Children"] = list;

            return(dict);
        }
Esempio n. 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _tableName = DataProvider.ChannelDao.TableName;
            var channelId = AuthRequest.GetQueryInt("channelId", SiteId);

            _channelInfo       = ChannelManager.GetChannelInfo(SiteId, channelId);
            _redirectUrl       = GetRedirectUrl(SiteId, channelId);
            _relatedIdentities = TableStyleManager.GetRelatedIdentities(_channelInfo);

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.SitePermissions.ConfigTableStyles);

            //删除样式
            if (AuthRequest.IsQueryExists("DeleteStyle"))
            {
                var attributeName = AuthRequest.GetQueryString("AttributeName");
                if (TableStyleManager.IsExists(_channelInfo.Id, _tableName, attributeName))
                {
                    try
                    {
                        DataProvider.TableStyleDao.Delete(_channelInfo.Id, _tableName, attributeName);
                        AuthRequest.AddSiteLog(SiteId, "删除数据表单样式", $"表单:{_tableName},字段:{attributeName}");
                        SuccessDeleteMessage();
                    }
                    catch (Exception ex)
                    {
                        FailDeleteMessage(ex);
                    }
                }
            }

            ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, false, true, AuthRequest.AdminPermissionsImpl);
            ControlUtils.SelectSingleItem(DdlChannelId, channelId.ToString());

            RptContents.DataSource     = TableStyleManager.GetChannelStyleInfoList(_channelInfo);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(SiteId, 0, _relatedIdentities, _tableName, string.Empty, _redirectUrl));
            BtnAddStyles.Attributes.Add("onclick", ModalTableStylesAdd.GetOpenWindowString(SiteId, _relatedIdentities, _tableName, _redirectUrl));
            BtnImport.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_tableName, SiteId, channelId));
            BtnExport.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableName, SiteId, channelId));
        }
Esempio n. 3
0
        public Dictionary <string, object> ToDictionary()
        {
            var jObject = JObject.FromObject(this);

            var styleInfoList = TableStyleManager.GetChannelStyleInfoList(this);

            foreach (var styleInfo in styleInfoList)
            {
                jObject[styleInfo.AttributeName] = Attributes.GetString(styleInfo.AttributeName);
            }

            var siteInfo = SiteManager.GetSiteInfo(SiteId);

            if (!string.IsNullOrEmpty(ImageUrl))
            {
                jObject[nameof(ImageUrl)] = PageUtility.ParseNavigationUrl(siteInfo, ImageUrl, false);
            }

            jObject["NavigationUrl"] = PageUtility.GetChannelUrl(siteInfo, this, false);

            return(jObject.ToObject <Dictionary <string, object> >());
        }
Esempio n. 4
0
        protected override void Render(HtmlTextWriter output)
        {
            if (Attributes == null)
            {
                return;
            }

            var channelInfo   = ChannelManager.GetChannelInfo(SiteInfo.Id, ChannelId);
            var styleInfoList = TableStyleManager.GetChannelStyleInfoList(channelInfo);

            if (styleInfoList == null)
            {
                return;
            }

            var builder     = new StringBuilder();
            var pageScripts = new NameValueCollection();

            foreach (var styleInfo in styleInfoList)
            {
                var value = BackgroundInputTypeParser.Parse(SiteInfo, ChannelId, styleInfo, Attributes, pageScripts, out var extra);

                if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra))
                {
                    continue;
                }

                if (styleInfo.InputType == InputType.TextEditor)
                {
                    builder.Append($@"
<div class=""form-group form-row"">
    <label class=""col-sm-2 col-form-label text-right"">{styleInfo.DisplayName}</label>
    <div class=""col-sm-9"">
        {value}
    </div>
    <div class=""col-sm-1"">
        {extra}
    </div>
</div>");
                }
                else
                {
                    builder.Append($@"
<div class=""form-group form-row"">
    <label class=""col-sm-2 col-form-label text-right"">{styleInfo.DisplayName}</label>
    <div class=""col-sm-4"">
        {value}
    </div>
    <div class=""col-sm-6"">
        {extra}
    </div>
</div>");
                }
            }

            output.Write(builder.ToString());

            foreach (string key in pageScripts.Keys)
            {
                output.Write(pageScripts[key]);
            }
        }
Esempio n. 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var isChanged = false;

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

                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                var styleInfoList = TableStyleManager.GetChannelStyleInfoList(nodeInfo);

                var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null);
                if (extendedAttributes.Count > 0)
                {
                    nodeInfo.Additional.Load(extendedAttributes);
                }

                nodeInfo.ChannelName = TbNodeName.Text;
                nodeInfo.IndexName   = TbNodeIndexName.Text;
                if (PhFilePath.Visible)
                {
                    nodeInfo.FilePath = TbFilePath.Text;
                }

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                if (TbKeywords.Visible)
                {
                    nodeInfo.Keywords = TbKeywords.Text;
                }
                if (TbDescription.Visible)
                {
                    nodeInfo.Description = TbDescription.Text;
                }

                if (PhLinkUrl.Visible)
                {
                    nodeInfo.LinkUrl = TbLinkUrl.Text;
                }
                if (PhLinkType.Visible)
                {
                    nodeInfo.LinkType = DdlLinkType.SelectedValue;
                }
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                if (PhChannelTemplateId.Visible)
                {
                    nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                }
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
            }

            if (isChanged)
            {
                CreateManager.CreateChannel(SiteId, _channelId);

                if (string.IsNullOrEmpty(_returnUrl))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            ChannelInfo channelInfo;

            try
            {
                var channelName             = TbNodeName.Text;
                var indexName               = TbNodeIndexName.Text;
                var filePath                = TbFilePath.Text;
                var channelFilePathRule     = TbChannelFilePathRule.Text;
                var contentFilePathRule     = TbContentFilePathRule.Text;
                var contentModelPluginId    = DdlContentModelPluginId.SelectedValue;
                var contentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds);
                var groupNameCollection     = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueStringList(CblNodeGroupNameCollection));
                var imageUrl                = TbImageUrl.Text;
                var content           = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                var keywords          = TbKeywords.Text;
                var description       = TbDescription.Text;
                var isChannelAddable  = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                var isContentAddable  = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);
                var linkUrl           = TbLinkUrl.Text;
                var linkType          = DdlLinkType.SelectedValue;
                var defaultTaxisType  = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                var channelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                var contentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
                if (!channelInfo.IndexName.Equals(indexName) && !string.IsNullOrEmpty(indexName))
                {
                    var indexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (indexNameList.IndexOf(indexName) != -1)
                    {
                        FailMessage("栏目属性修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (channelInfo.ContentModelPluginId != contentModelPluginId)
                {
                    channelInfo.ContentModelPluginId = contentModelPluginId;
                }
                channelInfo.ContentRelatedPluginIds = contentRelatedPluginIds;

                filePath = filePath.Trim();
                if (!channelInfo.FilePath.Equals(filePath) && !string.IsNullOrEmpty(filePath))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePath))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(filePath))
                    {
                        filePath = PageUtils.Combine(filePath, "index.html");
                    }

                    var filePathList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathList.IndexOf(filePath) != -1)
                    {
                        FailMessage("栏目修改失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(channelFilePathRule))
                {
                    var filePathRule = channelFilePathRule.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(contentFilePathRule))
                {
                    var filePathRule = contentFilePathRule.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var styleInfoList      = TableStyleManager.GetChannelStyleInfoList(channelInfo);
                var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null);
                channelInfo.Additional.Load(extendedAttributes);

                channelInfo.ChannelName         = channelName;
                channelInfo.IndexName           = indexName;
                channelInfo.FilePath            = filePath;
                channelInfo.ChannelFilePathRule = channelFilePathRule;
                channelInfo.ContentFilePathRule = contentFilePathRule;

                channelInfo.GroupNameCollection = groupNameCollection;
                channelInfo.ImageUrl            = imageUrl;
                channelInfo.Content             = content;

                channelInfo.Keywords    = keywords;
                channelInfo.Description = description;

                channelInfo.Additional.IsChannelAddable = isChannelAddable;
                channelInfo.Additional.IsContentAddable = isContentAddable;

                channelInfo.LinkUrl  = linkUrl;
                channelInfo.LinkType = linkType;
                channelInfo.Additional.DefaultTaxisType = defaultTaxisType;
                channelInfo.ChannelTemplateId           = channelTemplateId;
                channelInfo.ContentTemplateId           = contentTemplateId;

                DataProvider.ChannelDao.Update(channelInfo);
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
                return;
            }

            CreateManager.CreateChannel(SiteId, channelInfo.Id);

            AuthRequest.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目修改成功!");
            PageUtils.Redirect(ReturnUrl);
        }
Esempio n. 7
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            int insertChannelId;

            try
            {
                var channelId = AuthRequest.GetQueryInt("ChannelId");
                var nodeInfo  = new ChannelInfo
                {
                    SiteId                  = SiteId,
                    ParentId                = channelId,
                    ContentModelPluginId    = DdlContentModelPluginId.SelectedValue,
                    ContentRelatedPluginIds =
                        ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds)
                };

                if (TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameArrayList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameArrayList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目索引已存在!");
                        return;
                    }
                }

                if (TbFilePath.Text.Length != 0)
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                    {
                        TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                    }

                    var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var parentNodeInfo     = ChannelManager.GetChannelInfo(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetChannelStyleInfoList(parentNodeInfo);
                var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null);
                nodeInfo.Additional.Load(extendedAttributes);
                //foreach (string key in attributes)
                //{
                //    nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                //}

                nodeInfo.ChannelName         = TbNodeName.Text;
                nodeInfo.IndexName           = TbNodeIndexName.Text;
                nodeInfo.FilePath            = TbFilePath.Text;
                nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection         = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl                    = TbImageUrl.Text;
                nodeInfo.Content                     = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                nodeInfo.Keywords                    = TbKeywords.Text;
                nodeInfo.Description                 = TbDescription.Text;
                nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);

                nodeInfo.LinkUrl  = TbLinkUrl.Text;
                nodeInfo.LinkType = DdlLinkType.SelectedValue;

                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));

                nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                nodeInfo.AddDate = DateTime.Now;
                insertChannelId  = DataProvider.ChannelDao.Insert(nodeInfo);
                //栏目选择投票样式后,内容
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                FailMessage(ex, $"栏目添加失败:{ex.Message}");
                return;
            }

            CreateManager.CreateChannel(SiteId, insertChannelId);

            AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目添加成功!");
            AddWaitAndRedirectScript(ReturnUrl);
        }