public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            _styleInfoList = TableStyleManager.GetSiteStyleInfoList(SiteId);

            if (!IsPostBack)
            {
                VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);

                TbSiteName.Text = SiteInfo.SiteName;

                var nameValueCollection = TranslateUtils.DictionaryToNameValueCollection(SiteInfo.Additional.ToDictionary());

                LtlAttributes.Text = GetAttributesHtml(nameValueCollection);

                BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));
            }
            else
            {
                LtlAttributes.Text = GetAttributesHtml(Request.Form);
            }
        }
Exemple #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.Site, PublishmentSystemId, PublishmentSystemId);

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdConfigration, "站点属性设置", AppManager.Cms.Permission.WebSite.Configration);

                TbPublishmentSystemName.Text = PublishmentSystemInfo.PublishmentSystemName;

                LtlSettings.Text =
                    $@"<a class=""btn btn-success"" href=""{PageTableStyle.GetRedirectUrl(PublishmentSystemId,
                        ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, PublishmentSystemId)}"">设置站点属性</a>";

                AcAttributes.SetParameters(PublishmentSystemInfo.Additional.Attributes, PublishmentSystemInfo, 0, _relatedIdentities, ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, true, IsPostBack);

                BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));
            }
            else
            {
                AcAttributes.SetParameters(Request.Form, PublishmentSystemInfo, 0, _relatedIdentities, ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, true, IsPostBack);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            var relatedIdentities = RelatedIdentities.GetRelatedIdentities(SiteId, SiteId);

            _styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.SiteDao.TableName, relatedIdentities);

            if (!IsPostBack)
            {
                VerifySitePermissions(ConfigManager.Permissions.WebSite.Configration);

                TbSiteName.Text = SiteInfo.SiteName;

                LtlAttributes.Text = GetAttributesHtml(SiteInfo.Additional.ToNameValueCollection());

                BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));
            }
            else
            {
                LtlAttributes.Text = GetAttributesHtml(Request.Form);
            }
        }
        private static string ParseSelectOne(AttributesImpl attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            var builder    = new StringBuilder();
            var styleItems = styleInfo.StyleItems ?? new List <TableStyleItemInfo>();

            var selectedValue = attributes.GetString(styleInfo.AttributeName);

            var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            builder.Append($@"<select id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" class=""form-control""  isListItem=""true"" {validateAttributes}>");

            var isTicked = false;

            foreach (var styleItem in styleItems)
            {
                var isOptionSelected = false;
                if (!isTicked)
                {
                    isTicked = isOptionSelected = styleItem.ItemValue == selectedValue;
                }

                builder.Append($@"<option value=""{styleItem.ItemValue}"" {(isOptionSelected ? "selected" : string.Empty)}>{styleItem.ItemTitle}</option>");
            }

            builder.Append("</select>");

            return(builder.ToString());
        }
Exemple #5
0
        private static string ParseSelectMultiple(IAttributes attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            var builder    = new StringBuilder();
            var styleItems = styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);

            var selectedValues = TranslateUtils.StringCollectionToStringList(attributes.GetString(styleInfo.AttributeName));

            var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            builder.Append($@"<select id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" class=""form-control"" isListItem=""true"" multiple  {validateAttributes}>");

            foreach (var styleItem in styleItems)
            {
                var isSelected = selectedValues.Contains(styleItem.ItemValue);
                builder.Append($@"<option value=""{styleItem.ItemValue}"" {(isSelected ? "selected" : string.Empty)}>{styleItem.ItemTitle}</option>");
            }

            builder.Append("</select>");
            return(builder.ToString());
        }
Exemple #6
0
        private static string ParseCheckBox(IAttributes attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            var builder = new StringBuilder();

            var styleItems = styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);

            var checkBoxList = new CheckBoxList
            {
                CssClass        = "checkbox checkbox-primary",
                ID              = styleInfo.AttributeName,
                RepeatDirection = styleInfo.IsHorizontal ? RepeatDirection.Horizontal : RepeatDirection.Vertical,
                RepeatColumns   = styleInfo.Additional.Columns
            };

            var selectedValues = TranslateUtils.StringCollectionToStringList(attributes.GetString(styleInfo.AttributeName));

            InputParserUtils.GetValidateAttributesForListItem(checkBoxList, styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            foreach (var styleItem in styleItems)
            {
                var isSelected = selectedValues.Contains(styleItem.ItemValue);
                var listItem   = new ListItem(styleItem.ItemTitle, styleItem.ItemValue)
                {
                    Selected = isSelected
                };

                checkBoxList.Items.Add(listItem);
            }
            checkBoxList.Attributes.Add("isListItem", "true");
            builder.Append(ControlUtils.GetControlRenderHtml(checkBoxList));

            var i = 0;

            foreach (var styleItem in styleItems)
            {
                builder.Replace($@"name=""{styleInfo.AttributeName}${i}""",
                                $@"name=""{styleInfo.AttributeName}"" value=""{styleItem.ItemValue}""");
                i++;
            }

            return(builder.ToString());
        }
        protected override void Render(HtmlTextWriter output)
        {
            var nodeId = int.Parse(HttpContext.Current.Request.QueryString["NodeID"]);
            var publishmentSystemId   = int.Parse(HttpContext.Current.Request.QueryString["PublishmentSystemID"]);
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            if (_formCollection == null)
            {
                if (HttpContext.Current.Request.Form.Count > 0)
                {
                    _formCollection = HttpContext.Current.Request.Form;
                }
                else
                {
                    _formCollection = new NameValueCollection();
                }
            }

            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId);
            var styleInfoList     = TableStyleManager.GetTableStyleInfoList(ETableStyle.Channel, DataProvider.NodeDao.TableName, relatedIdentities);

            if (styleInfoList != null)
            {
                var builder     = new StringBuilder();
                var pageScripts = new NameValueCollection();
                foreach (var styleInfo in styleInfoList)
                {
                    if (styleInfo.IsVisible)
                    {
                        var attributes = InputParserUtils.GetAdditionalAttributes(string.Empty, EInputTypeUtils.GetEnumType(styleInfo.InputType));
                        //string inputHtml = TableInputParser.Parse(styleInfo, styleInfo.AttributeName, this.formCollection, this.isEdit, isPostBack, attributes, pageScripts);
                        var inputHtml = BackgroundInputTypeParser.Parse(publishmentSystemInfo, nodeId, styleInfo, ETableStyle.Channel, styleInfo.AttributeName, _formCollection, _isEdit, _isPostBack, attributes, pageScripts, true);

                        builder.AppendFormat(GetFormatString(EInputTypeUtils.GetEnumType(styleInfo.InputType)), styleInfo.DisplayName, inputHtml, styleInfo.HelpText);
                    }
                }

                output.Write(builder.ToString());

                foreach (string key in pageScripts.Keys)
                {
                    output.Write(pageScripts[key]);
                }
            }
        }
Exemple #8
0
        public static string GetValidateHtmlString(TableStyleInfo styleInfo, out string validateAttributes)
        {
            var builder = new StringBuilder();

            validateAttributes = string.Empty;

            if (styleInfo.Additional.IsValidate && !EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
            {
                validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

                builder.Append(
                    $@"&nbsp;<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span>");
                builder.Append($@"
<script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>
");
            }
            return(builder.ToString());
        }
Exemple #9
0
        private static string GetValidateHtmlString(TableStyleInfo styleInfo, out string validateAttributes)
        {
            validateAttributes = string.Empty;
            if (!styleInfo.Additional.IsValidate || EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
            {
                return(string.Empty);
            }

            var builder = new StringBuilder();

            validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            builder.Append(
                $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;margin-left: 5px;display:none;"">*</span>");
            builder.Append($@"
<script>inputBlur('{styleInfo.AttributeName}');</script>
");
            return(builder.ToString());
        }
Exemple #10
0
        public static string ParseTextArea(IAttributes attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            var height = styleInfo.Additional.Height;

            if (height == 0)
            {
                height = 80;
            }
            string style = $@"style=""height:{height}px;""";

            var value = StringUtils.HtmlDecode(attributes.GetString(styleInfo.AttributeName));

            return
                ($@"<textarea id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" class=""form-control"" {style} {validateAttributes}>{value}</textarea>");
        }
Exemple #11
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            nodeID    = Body.GetQueryInt("NodeID");
            contentID = Body.GetQueryInt("ID");
            returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            tableStyle        = ETableStyle.VoteContent;
            tableName         = PublishmentSystemInfo.AuxiliaryTableForVote;
            relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeID);

            if (!IsPostBack)
            {
                var pageTitle = (contentID == 0) ? "添加投票" : "修改投票";
                var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeID);
                BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, pageTitle, nodeNames, string.Empty);

                ltlPageTitle.Text = pageTitle;

                var excludeAttributeNames = TableManager.GetExcludeAttributeNames(tableStyle);
                acAttributes.AddExcludeAttributeNames(excludeAttributeNames);

                if (contentID == 0)
                {
                    var listItem = new ListItem("无结束日期", string.Empty);
                    ddlEndDate.Items.Add(listItem);
                    listItem = new ListItem("一周", DateTime.Now.AddDays(7).ToShortDateString());
                    ddlEndDate.Items.Add(listItem);
                    listItem          = new ListItem("一月", DateTime.Now.AddDays(30).ToShortDateString());
                    listItem.Selected = true;
                    ddlEndDate.Items.Add(listItem);
                    listItem = new ListItem("半年", DateTime.Now.AddDays(180).ToShortDateString());
                    ddlEndDate.Items.Add(listItem);
                    listItem = new ListItem("一年", DateTime.Now.AddDays(365).ToShortDateString());
                    ddlEndDate.Items.Add(listItem);
                    listItem = new ListItem("自定义", DateTime.Now.AddDays(30).ToShortDateString());
                    ddlEndDate.Items.Add(listItem);

                    dtbEndDate.DateTime = DateTime.Now.AddDays(30);

                    var formCollection = new NameValueCollection();

                    acAttributes.SetParameters(formCollection, PublishmentSystemInfo, nodeID, relatedIdentities, tableStyle, tableName, false, IsPostBack);
                }
                else
                {
                    var contentInfo = DataProvider.VoteContentDao.GetContentInfo(PublishmentSystemInfo, contentID);

                    voteOptionInfoArrayList = DataProvider.VoteOptionDao.GetVoteOptionInfoArrayList(PublishmentSystemId, nodeID, contentID);
                    var script = string.Empty;
                    for (var i = 2; i < voteOptionInfoArrayList.Count; i++)
                    {
                        var optionInfo = voteOptionInfoArrayList[i] as VoteOptionInfo;
                        script += $"addItem('{optionInfo.Title}');";
                    }
                    if (!string.IsNullOrEmpty(script))
                    {
                        ltlScript.Text = $@"<script>{script}</script>";
                    }

                    isSummary      = contentInfo.IsSummary;
                    tbSummary.Text = contentInfo.Summary;

                    for (var i = 2; i < voteOptionInfoArrayList.Count; i++)
                    {
                        var listItem = new ListItem($"最多选{i}项", i.ToString());
                        ddlMaxSelectNum.Items.Add(listItem);
                    }

                    ControlUtils.SelectListItems(ddlMaxSelectNum, contentInfo.MaxSelectNum.ToString());
                    dtbAddDate.DateTime = contentInfo.AddDate;
                    ddlEndDate.Visible  = false;
                    dtbEndDate.DateTime = contentInfo.EndDate;
                    ControlUtils.SelectListItemsIgnoreCase(rblIsVotedView, contentInfo.IsVotedView.ToString());
                    tbHiddenContent.Text = contentInfo.HiddenContent;

                    acAttributes.SetParameters(contentInfo.Attributes, PublishmentSystemInfo, nodeID, relatedIdentities, tableStyle, tableName, true, IsPostBack);
                }

                Submit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));
            }
            else
            {
                if (contentID == 0)
                {
                    acAttributes.SetParameters(Request.Form, PublishmentSystemInfo, nodeID, relatedIdentities, tableStyle, tableName, false, IsPostBack);
                }
                else
                {
                    acAttributes.SetParameters(Request.Form, PublishmentSystemInfo, nodeID, relatedIdentities, tableStyle, tableName, true, IsPostBack);
                }
            }
            DataBind();
        }
Exemple #12
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID", "ReturnUrl");

            var nodeId = Body.GetQueryInt("NodeID");

            _nodeInfo = NodeManager.GetNodeInfo(1, nodeId);
            var    contentId   = Body.GetQueryInt("ID");
            string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId);

            ReturnUrl  = $@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID=1&NodeId={nodeId}";
            ReturnPUrl = $@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID=1&NodeId={ (Body.GetQueryInt("PNodeID")==0? nodeId:Body.GetQueryInt("PNodeID"))}";
            //ReturnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));
            _isAjaxSubmit = Body.GetQueryBool("isAjaxSubmit");
            _isPreview    = Body.GetQueryBool("isPreview");

            _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo);
            _tableName  = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo);
            //_tableName = "model_content";
            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId);
            ContentInfo contentInfo = null;

            if (_isAjaxSubmit == false)
            {
                if (contentId == 0)
                {
                    if (_nodeInfo != null && _nodeInfo.Additional.IsContentAddable == false)
                    {
                        PageUtils.RedirectToErrorPage("此栏目不能添加内容!");
                        return;
                    }

                    if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentAdd))
                    {
                        if (!Body.IsAdministratorLoggin)
                        {
                            PageUtils.RedirectToLoginPage();
                            return;
                        }
                        else
                        {
                            PageUtils.RedirectToErrorPage("您无此栏目的添加内容权限!");
                            return;
                        }
                    }
                }
                else
                {
                    contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId);
                    if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentEdit))
                    {
                        if (!Body.IsAdministratorLoggin)
                        {
                            PageUtils.RedirectToLoginPage();
                            return;
                        }
                        PageUtils.RedirectToErrorPage("您无此栏目的修改内容权限!");
                        return;
                    }
                }

                if (!IsPostBack)
                {
                    var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemId, _nodeInfo.NodeId);
                    var pageTitle = (contentId == 0) ?
                                    $"添加{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}"
                        : $"编辑{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}";
                    BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, pageTitle, nodeNames, string.Empty);

                    LtlPageTitle.Text  = pageTitle;
                    LtlPageTitle.Text += $@"
<script language=""javascript"" type=""text/javascript"">
var previewUrl = '{PagePreview.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentId, 0, 0)}';
</script>
";

                    if (PublishmentSystemInfo.Additional.IsAutoSaveContent && PublishmentSystemInfo.Additional.AutoSaveContentInterval > 0)
                    {
                        LtlPageTitle.Text += $@"
<input type=""hidden"" id=""savedContentID"" name=""savedContentID"" value=""{contentId}"">
<script language=""javascript"" type=""text/javascript"">setInterval(""autoSave()"",{PublishmentSystemInfo.Additional.AutoSaveContentInterval*1000});</script>
";
                    }
                    //专题
                    if (contentId == 0)
                    {
                        var specialParentId = DataProvider.NodeDao.GetSpecialParentId();
                        NodeIdDic = new Dictionary <NodeInfo, List <NodeInfo> >();
                        if (nodeId != 0 && nodeId == specialParentId)
                        {
                            PhSpecial.Visible  = true;
                            PhCategory.Visible = true;
                            var             specialNodeIdList = DataProvider.NodeDao.GetNodeInfoListByParentId(1, specialParentId);
                            List <NodeInfo> secondLevel       = new List <NodeInfo>();
                            foreach (var nodeInfo in specialNodeIdList)
                            {
                                var secondChild = DataProvider.NodeDao.GetNodeInfoListByParentId(1, nodeInfo.NodeId);
                                if (secondChild != null && secondChild.Count > 0)
                                {
                                    NodeIdDic.Add(nodeInfo, secondChild);
                                }
                            }
                            if (NodeIdDic != null && NodeIdDic.Count > 0)
                            {
                                KeyValuePair <NodeInfo, List <NodeInfo> > kv = NodeIdDic.First();
                                var defaultItem = new ListItem(kv.Key.NodeName, kv.Key.NodeId.ToString());
                                defaultItem.Selected = true;
                                TbSpecial.Items.Add(defaultItem);
                                foreach (var info in kv.Value)
                                {
                                    TbCategory.Items.Add(new ListItem(info.NodeName, info.NodeId.ToString()));
                                }
                                foreach (var info in specialNodeIdList)
                                {
                                    if (info.NodeId != kv.Key.NodeId)
                                    {
                                        TbSpecial.Items.Add(new ListItem(info.NodeName, info.NodeId.ToString()));
                                    }
                                }
                            }
                        }
                        else
                        {
                            //信息类型
                            var childSpecial = DataProvider.NodeDao.GetNodeInfoListByParentId(1, nodeId);
                            if (childSpecial != null && childSpecial.Count > 0)
                            {
                                PhCategory.Visible = true;
                                foreach (var nodeInfo in childSpecial)
                                {
                                    var item = new ListItem(nodeInfo.NodeName, nodeInfo.NodeId.ToString());
                                    TbCategory.Items.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        PhSpecial.Visible  = false;
                        PhCategory.Visible = true;
                        TbCategory.Items.Add(new ListItem(_nodeInfo.NodeName, _nodeInfo.NodeId.ToString()));
                        //if (_nodeInfo.ParentsCount == 1)
                        //{
                        //    PhSpecial.Visible = false;
                        //    PhCategory.Visible = true;
                        //    TbSpecial.Items.Add(new ListItem(_nodeInfo.NodeName, _nodeInfo.NodeId.ToString()));
                        //}else if(_nodeInfo.ParentsCount == 1)
                    }


                    //转移
                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, PublishmentSystemId, _nodeInfo.NodeId, AppManager.Cms.Permission.Channel.ContentTranslate))
                    {
                        PhTranslate.Visible = PublishmentSystemInfo.Additional.IsTranslate;
                        DivTranslateAdd.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(PublishmentSystemId, true));

                        ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true);
                        ControlUtils.SelectListItems(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy));
                    }
                    else
                    {
                        PhTranslate.Visible = false;
                    }

                    //内容属性
                    var excludeAttributeNames = TableManager.GetExcludeAttributeNames(_tableStyle);
                    AcAttributes.AddExcludeAttributeNames(excludeAttributeNames);

                    if (excludeAttributeNames.Count == 0)
                    {
                        PhContentAttributes.Visible = false;
                    }
                    else
                    {
                        PhContentAttributes.Visible = true;
                        foreach (var attributeName in excludeAttributeNames)
                        {
                            var styleInfo = TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, attributeName, _relatedIdentities);
                            if (styleInfo.IsVisible)
                            {
                                var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                                if (contentId > 0)
                                {
                                    listItem.Selected = TranslateUtils.ToBool(contentInfo?.GetExtendedAttribute(styleInfo.AttributeName));
                                }
                                else
                                {
                                    if (TranslateUtils.ToBool(styleInfo.DefaultValue))
                                    {
                                        listItem.Selected = true;
                                    }
                                }
                                CblContentAttributes.Items.Add(listItem);
                            }
                        }
                    }

                    //内容组
                    var contentGroupNameList = DataProvider.ContentGroupDao.GetContentGroupNameList(PublishmentSystemId);

                    if (!PublishmentSystemInfo.Additional.IsGroupContent || contentGroupNameList.Count == 0)
                    {
                        PhContentGroup.Visible = false;
                    }
                    else
                    {
                        foreach (var groupName in contentGroupNameList)
                        {
                            var item = new ListItem(groupName, groupName);
                            if (contentId > 0)
                            {
                                item.Selected = StringUtils.In(contentInfo?.ContentGroupNameCollection, groupName);
                            }
                            CblContentGroupNameCollection.Items.Add(item);
                        }
                    }

                    //标签
                    if (!PublishmentSystemInfo.Additional.IsRelatedByTags)
                    {
                        PhTags.Visible = false;
                    }
                    else
                    {
                        var tagScript = @"
<script type=""text/javascript"">
function getTags(tag){
	$.get('[url]&tag=' + encodeURIComponent(tag) + '&r=' + Math.random(), function(data) {
		if(data !=''){
			var arr = data.split('|');
			var temp='';
			for(i=0;i<arr.length;i++)
			{
				temp += '<li><a>'+arr[i].replace(tag,'<b>' + tag + '</b>') + '</a></li>';
			}
			var myli='<ul>'+temp+'</ul>';
			$('#tagTips').html(myli);
			$('#tagTips').show();
		}else{
            $('#tagTips').hide();
        }
		$('#tagTips li').click(function () {
			var tag = $('#TbTags').val();
			var i = tag.lastIndexOf(' ');
			if (i > 0)
			{
				tag = tag.substring(0, i) + ' ' + $(this).text();
			}else{
				tag = $(this).text();	
			}
			$('#TbTags').val(tag);
			$('#tagTips').hide();
		})
	});	
}
$(document).ready(function () {
$('#TbTags').keyup(function (e) {
    if (e.keyCode != 40 && e.keyCode != 38) {
        var tag = $('#TbTags').val();
		var i = tag.lastIndexOf(' ');
		if (i > 0){ tag = tag.substring(i + 1);}
        if (tag != '' && tag != ' '){
            window.setTimeout(""getTags('"" + tag + ""');"", 200);
        }else{
            $('#tagTips').hide();
        }
    }
}).blur(function () {
	window.setTimeout(""$('#tagTips').hide();"", 200);
})});
</script>
<div id=""tagTips"" class=""inputTips""></div>
";
                        LtlTags.Text = tagScript.Replace("[url]", AjaxCmsService.GetTagsUrl(PublishmentSystemId));
                    }

                    if (contentId == 0)
                    {
                        var formCollection = new NameValueCollection();
                        if (Body.IsQueryExists("isUploadWord"))
                        {
                            var isFirstLineTitle  = Body.GetQueryBool("isFirstLineTitle");
                            var isFirstLineRemove = Body.GetQueryBool("isFirstLineRemove");
                            var isClearFormat     = Body.GetQueryBool("isClearFormat");
                            var isFirstLineIndent = Body.GetQueryBool("isFirstLineIndent");
                            var isClearFontSize   = Body.GetQueryBool("isClearFontSize");
                            var isClearFontFamily = Body.GetQueryBool("isClearFontFamily");
                            var isClearImages     = Body.GetQueryBool("isClearImages");
                            var contentLevel      = Body.GetQueryInt("contentLevel");
                            var fileName          = Body.GetQueryString("fileName");

                            formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName);
                        }

                        AcAttributes.SetParameters(formCollection, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, false, IsPostBack);
                    }
                    else
                    {
                        AcAttributes.SetParameters(contentInfo?.Attributes, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, true, IsPostBack);
                        TbTags.Text = contentInfo?.Tags;
                    }

                    if (HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentCheck))
                    {
                        PhStatus.Visible = true;
                        int checkedLevel;
                        var isChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, _nodeInfo.NodeId, out checkedLevel);
                        if (Body.IsQueryExists("contentLevel"))
                        {
                            checkedLevel = TranslateUtils.ToIntWithNagetive(Body.GetQueryString("contentLevel"));
                            if (checkedLevel != LevelManager.LevelInt.NotChange)
                            {
                                isChecked = checkedLevel >= PublishmentSystemInfo.CheckContentLevel;
                            }
                        }

                        LevelManager.LoadContentLevelToEdit(RblContentLevel, PublishmentSystemInfo, nodeId, contentInfo, isChecked, checkedLevel);
                    }
                    else
                    {
                        PhStatus.Visible = false;
                    }

                    BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()"));
                    //自动检测敏感词
                    ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(PublishmentSystemInfo));
                }
                else
                {
                    AcAttributes.SetParameters(Request.Form, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities,
                                               _tableStyle, _tableName, contentId != 0, IsPostBack);
                }
                DataBind();
            }
            else
            {
                var    success = false;
                string errorMessage;
                var    savedContentId = SaveContentInfo(true, _isPreview, out errorMessage);
                if (savedContentId > 0)
                {
                    success = true;
                }

                string jsonString = $@"{{success:'{success.ToString().ToLower()}',savedContentID:'{savedContentId}'}}";

                PageUtils.ResponseToJson(jsonString);
            }
        }
Exemple #13
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

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

            var channelId = AuthRequest.GetQueryInt("channelId");
            var contentId = AuthRequest.GetQueryInt("id");

            ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));
            if (string.IsNullOrEmpty(ReturnUrl))
            {
                ReturnUrl = CmsPages.GetContentsUrl(SiteId, channelId);
            }

            _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
            _tableName   = ChannelManager.GetTableName(SiteInfo, _channelInfo);
            ContentInfo contentInfo = null;

            _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo);

            if (!IsPermissions(contentId))
            {
                return;
            }

            if (contentId > 0)
            {
                contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId);
            }

            var titleFormat = IsPostBack ? Request.Form[ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)] : contentInfo?.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title));

            LtlTitleHtml.Text = ContentUtility.GetTitleHtml(titleFormat, AjaxCmsService.GetTitlesUrl(SiteId, _channelInfo.Id));

            AcAttributes.SiteInfo      = SiteInfo;
            AcAttributes.ChannelId     = _channelInfo.Id;
            AcAttributes.ContentId     = contentId;
            AcAttributes.StyleInfoList = _styleInfoList;

            if (!IsPostBack)
            {
                var pageTitle = contentId == 0 ? "添加内容" : "编辑内容";

                LtlPageTitle.Text = pageTitle;

                if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate))
                {
                    PhTranslate.Visible = true;
                    BtnTranslate.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(SiteId, true));

                    ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true);
                    ControlUtils.SelectSingleItem(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy));
                }
                else
                {
                    PhTranslate.Visible = false;
                }

                CblContentAttributes.Items.Add(new ListItem("置顶", ContentAttribute.IsTop));
                CblContentAttributes.Items.Add(new ListItem("推荐", ContentAttribute.IsRecommend));
                CblContentAttributes.Items.Add(new ListItem("热点", ContentAttribute.IsHot));
                CblContentAttributes.Items.Add(new ListItem("醒目", ContentAttribute.IsColor));
                TbAddDate.DateTime = DateTime.Now;
                TbAddDate.Now      = true;

                var contentGroupNameList = ContentGroupManager.GetGroupNameList(SiteId);
                foreach (var groupName in contentGroupNameList)
                {
                    var item = new ListItem(groupName, groupName);
                    CblContentGroups.Items.Add(item);
                }

                BtnContentGroupAdd.Attributes.Add("onclick", ModalContentGroupAdd.GetOpenWindowString(SiteId));

                LtlTags.Text = ContentUtility.GetTagsHtml(AjaxCmsService.GetTagsUrl(SiteId));

                if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck))
                {
                    PhStatus.Visible = true;
                    int checkedLevel;
                    var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, _channelInfo.Id, out checkedLevel);
                    if (AuthRequest.IsQueryExists("contentLevel"))
                    {
                        checkedLevel = TranslateUtils.ToIntWithNagetive(AuthRequest.GetQueryString("contentLevel"));
                        if (checkedLevel != CheckManager.LevelInt.NotChange)
                        {
                            isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
                        }
                    }

                    CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, contentInfo, isChecked, checkedLevel);
                }
                else
                {
                    PhStatus.Visible = false;
                }

                BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()"));
                //自动检测敏感词
                ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(SiteInfo));

                if (contentId == 0)
                {
                    var attributes = TableStyleManager.GetDefaultAttributes(_styleInfoList);

                    if (AuthRequest.IsQueryExists("isUploadWord"))
                    {
                        var isFirstLineTitle  = AuthRequest.GetQueryBool("isFirstLineTitle");
                        var isFirstLineRemove = AuthRequest.GetQueryBool("isFirstLineRemove");
                        var isClearFormat     = AuthRequest.GetQueryBool("isClearFormat");
                        var isFirstLineIndent = AuthRequest.GetQueryBool("isFirstLineIndent");
                        var isClearFontSize   = AuthRequest.GetQueryBool("isClearFontSize");
                        var isClearFontFamily = AuthRequest.GetQueryBool("isClearFontFamily");
                        var isClearImages     = AuthRequest.GetQueryBool("isClearImages");
                        var contentLevel      = AuthRequest.GetQueryInt("contentLevel");
                        var fileName          = AuthRequest.GetQueryString("fileName");

                        var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName);
                        attributes.Load(formCollection);

                        TbTitle.Text = formCollection[ContentAttribute.Title];
                    }

                    AcAttributes.Attributes = attributes;
                }
                else if (contentInfo != null)
                {
                    TbTitle.Text = contentInfo.Title;

                    TbTags.Text = contentInfo.Tags;

                    var list = new List <string>();
                    if (contentInfo.IsTop)
                    {
                        list.Add(ContentAttribute.IsTop);
                    }
                    if (contentInfo.IsRecommend)
                    {
                        list.Add(ContentAttribute.IsRecommend);
                    }
                    if (contentInfo.IsHot)
                    {
                        list.Add(ContentAttribute.IsHot);
                    }
                    if (contentInfo.IsColor)
                    {
                        list.Add(ContentAttribute.IsColor);
                    }
                    ControlUtils.SelectMultiItems(CblContentAttributes, list);
                    TbLinkUrl.Text     = contentInfo.LinkUrl;
                    TbAddDate.DateTime = contentInfo.AddDate;
                    ControlUtils.SelectMultiItems(CblContentGroups, TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection));

                    AcAttributes.Attributes = contentInfo;
                }
            }
            else
            {
                AcAttributes.Attributes = new AttributesImpl(Request.Form);
            }
            //DataBind();
        }
Exemple #14
0
        private static string ParseRadio(IAttributes attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            var builder = new StringBuilder();

            var styleItems = styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);

            if (styleItems == null || styleItems.Count == 0)
            {
                styleItems = new List <TableStyleItemInfo>
                {
                    new TableStyleItemInfo
                    {
                        ItemTitle = "是",
                        ItemValue = "1"
                    },
                    new TableStyleItemInfo
                    {
                        ItemTitle = "否",
                        ItemValue = "0"
                    }
                };
            }
            var radioButtonList = new RadioButtonList
            {
                CssClass        = "radio radio-primary",
                ID              = styleInfo.AttributeName,
                RepeatDirection = styleInfo.IsHorizontal ? RepeatDirection.Horizontal : RepeatDirection.Vertical,
                RepeatColumns   = styleInfo.Additional.Columns
            };

            var selectedValue = attributes.GetString(styleInfo.AttributeName);

            InputParserUtils.GetValidateAttributesForListItem(radioButtonList, styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            var isTicked = false;

            foreach (var styleItem in styleItems)
            {
                var isOptionSelected = false;
                if (!isTicked)
                {
                    isTicked = isOptionSelected = styleItem.ItemValue == selectedValue;
                }

                var listItem = new ListItem(styleItem.ItemTitle, styleItem.ItemValue)
                {
                    Selected = isOptionSelected
                };
                radioButtonList.Items.Add(listItem);
            }
            radioButtonList.Attributes.Add("isListItem", "true");
            builder.Append(ControlUtils.GetControlRenderHtml(radioButtonList));

            return(builder.ToString());
        }
Exemple #15
0
        public void Page_Load(object sender, EventArgs e)
        {
            PageUtils.CheckRequestParameter("PublishmentSystemID");

            var nodeId = TranslateUtils.ToInt(Request.QueryString["NodeID"]);

            if (nodeId == 0)
            {
                nodeId = PublishmentSystemInfo.Additional.GovPublicNodeId;
            }
            _contentId = TranslateUtils.ToInt(Request.QueryString["ID"]);
            ReturnUrl  = StringUtils.ValueFromUrl(Request.QueryString["ReturnUrl"]);

            _nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId);

            _tableStyle        = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo);
            _tableName         = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo);
            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId);

            GovPublicContentInfo contentInfo = null;

            if (_contentId == 0)
            {
                if (_nodeInfo != null && _nodeInfo.Additional.IsContentAddable == false)
                {
                    PageUtils.RedirectToErrorPage("此栏目不能添加内容!");
                    return;
                }

                if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentAdd))
                {
                    if (!Body.IsAdministratorLoggin)
                    {
                        PageUtils.RedirectToLoginPage();
                        return;
                    }
                    PageUtils.RedirectToErrorPage("您无此栏目的添加内容权限!");
                    return;
                }
            }
            else
            {
                contentInfo = DataProvider.GovPublicContentDao.GetContentInfo(PublishmentSystemInfo, _contentId);
                if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentEdit))
                {
                    if (!Body.IsAdministratorLoggin)
                    {
                        PageUtils.RedirectToLoginPage();
                        return;
                    }
                    PageUtils.RedirectToErrorPage("您无此栏目的修改内容权限!");
                    return;
                }
            }

            if (!IsPostBack)
            {
                var nodeNames      = NodeManager.GetNodeNameNavigationByGovPublic(PublishmentSystemId, nodeId);
                var departmentId   = 0;
                var departmentName = string.Empty;

                var pageTitle = _contentId == 0 ? "添加信息" : "修改信息";
                BreadCrumbWithItemTitle(AppManager.Wcm.LeftMenu.IdGovPublic, AppManager.Wcm.LeftMenu.GovPublic.IdGovPublicContent, pageTitle, nodeNames, AppManager.Wcm.Permission.WebSite.GovPublicContent);

                ltlPageTitle.Text  = pageTitle;
                ltlPageTitle.Text += $@"
<script language=""javascript"" type=""text/javascript"">
var previewUrl = '{PagePreview.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, _contentId, 0, 0)}';
</script>
";

                EBooleanUtils.AddListItems(rblIsAbolition);
                ControlUtils.SelectListItemsIgnoreCase(rblIsAbolition, false.ToString());

                //转移
                if (_tableStyle == ETableStyle.BackgroundContent && AdminUtility.HasChannelPermissions(Body.AdministratorName, PublishmentSystemId, _nodeInfo.NodeId, AppManager.Cms.Permission.Channel.ContentTranslate))
                {
                    phTranslate.Visible = PublishmentSystemInfo.Additional.IsTranslate;
                    divTranslateAdd.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(PublishmentSystemId, true));

                    ETranslateContentTypeUtils.AddListItems(ddlTranslateType, true);
                    ControlUtils.SelectListItems(ddlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy));
                }
                else
                {
                    phTranslate.Visible = false;
                }

                //内容属性
                var excludeAttributeNames = TableManager.GetExcludeAttributeNames(_tableStyle);
                acAttributes.AddExcludeAttributeNames(excludeAttributeNames);

                if (excludeAttributeNames.Count == 0)
                {
                    phContentAttributes.Visible = false;
                }
                else
                {
                    phContentAttributes.Visible = true;
                    foreach (var attributeName in GovPublicContentAttribute.CheckBoxAttributes)
                    {
                        var styleInfo = TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, attributeName, _relatedIdentities);
                        if (styleInfo.IsVisible)
                        {
                            var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                            if (_contentId > 0)
                            {
                                listItem.Selected = TranslateUtils.ToBool(contentInfo.GetExtendedAttribute(styleInfo.AttributeName));
                            }
                            ContentAttributes.Items.Add(listItem);
                        }
                    }
                }

                //内容组
                var contentGroupNameList = DataProvider.ContentGroupDao.GetContentGroupNameList(PublishmentSystemId);

                if (!PublishmentSystemInfo.Additional.IsGroupContent || contentGroupNameList.Count == 0)
                {
                    phContentGroup.Visible = false;
                }
                else
                {
                    foreach (var groupName in contentGroupNameList)
                    {
                        var item = new ListItem(groupName, groupName);
                        if (_contentId > 0)
                        {
                            item.Selected = StringUtils.In(contentInfo.ContentGroupNameCollection, groupName);
                        }
                        ContentGroupNameCollection.Items.Add(item);
                    }
                }

                if (!PublishmentSystemInfo.Additional.IsRelatedByTags || _tableStyle != ETableStyle.BackgroundContent)
                {
                    phTags.Visible = false;
                }
                else
                {
                    var tagScript = @"
<script type=""text/javascript"">
function getTags(tag){
	$.get('[url]&tag=' + encodeURIComponent(tag) + '&r=' + Math.random(), function(data) {
		if(data !=''){
			var arr = data.split('|');
			var temp='';
			for(i=0;i<arr.length;i++)
			{
				temp += '<li><a>'+arr[i].replace(tag,'<b>' + tag + '</b>') + '</a></li>';
			}
			var myli='<ul>'+temp+'</ul>';
			$('#tagTips').html(myli);
			$('#tagTips').show();
		}else{
            $('#tagTips').hide();
        }
		$('#tagTips li').click(function () {
			var tag = $('#Tags').val();
			var i = tag.lastIndexOf(' ');
			if (i > 0)
			{
				tag = tag.substring(0, i) + ' ' + $(this).text();
			}else{
				tag = $(this).text();	
			}
			$('#Tags').val(tag);
			$('#tagTips').hide();
		})
	});	
}
$(document).ready(function () {
$('#Tags').keyup(function (e) {
    if (e.keyCode != 40 && e.keyCode != 38) {
        var tag = $('#Tags').val();
		var i = tag.lastIndexOf(' ');
		if (i > 0){ tag = tag.substring(i + 1);}
        if (tag != '' && tag != ' '){
            window.setTimeout(""getTags('"" + tag + ""');"", 200);
        }else{
            $('#tagTips').hide();
        }
    }
}).blur(function () {
	window.setTimeout(""$('#tagTips').hide();"", 200);
})});
</script>
<div id=""tagTips"" class=""inputTips""></div>
";
                    ltlTags.Text = tagScript.Replace("[url]", AjaxCmsService.GetTagsUrl(PublishmentSystemId));
                }

                divAddChannel.Attributes.Add("onclick", ModalGovPublicCategoryChannelSelect.GetOpenWindowString(PublishmentSystemId));
                divAddDepartment.Attributes.Add("onclick", ModalGovPublicCategoryDepartmentSelect.GetOpenWindowString(PublishmentSystemId));

                var categoryBuilder = new StringBuilder();

                var categoryClassInfoArrayList = DataProvider.GovPublicCategoryClassDao.GetCategoryClassInfoArrayList(PublishmentSystemId, ETriState.False, ETriState.True);
                if (categoryClassInfoArrayList.Count > 0)
                {
                    var categoryIndex = 1;
                    foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList)
                    {
                        categoryIndex++;
                        if (categoryIndex % 2 == 0)
                        {
                            categoryBuilder.Append("<tr>");
                        }
                        categoryBuilder.Append(
                            $@"<td height=""30"">{categoryClassInfo.ClassName}分类:</td><td height=""30"">
<div class=""fill_box"" id=""category{categoryClassInfo.ClassCode}Container"" style=""display:none"">
                  <div class=""addr_base addr_normal""> <b id=""category{categoryClassInfo.ClassCode}Name""></b> <a class=""addr_del"" href=""javascript:;"" onClick=""showCategory{categoryClassInfo
                                .ClassCode}('', '0')""></a>
                    <input id=""category{categoryClassInfo.ClassCode}ID"" name=""category{categoryClassInfo.ClassCode}ID"" value=""0"" type=""hidden"">
                  </div>
                </div>
                <div ID=""divAdd{categoryClassInfo.ClassCode}"" class=""btn_pencil"" onclick=""{ModalGovPublicCategorySelect
                                .GetOpenWindowString(PublishmentSystemId, categoryClassInfo.ClassCode)}""><span class=""pencil""></span> 修改</div>
                <script language=""javascript"">
			  function showCategory{categoryClassInfo.ClassCode}({categoryClassInfo.ClassCode}Name, {categoryClassInfo.ClassCode}ID){{
				  $('#category{categoryClassInfo.ClassCode}Name').html({categoryClassInfo.ClassCode}Name);
				  $('#category{categoryClassInfo.ClassCode}ID').val({categoryClassInfo.ClassCode}ID);
				  if ({categoryClassInfo.ClassCode}ID == '0'){{
					$('#category{categoryClassInfo.ClassCode}Container').hide();
				  }}else{{
					  $('#category{categoryClassInfo.ClassCode}Container').show();
				  }}
			  }}
			  </script>
</td>");
                        if (categoryIndex % 2 == 1)
                        {
                            categoryBuilder.Append("</tr>");
                        }
                    }
                }

                if (_contentId == 0)
                {
                    var formCollection = new NameValueCollection();
                    if (Body.IsQueryExists("isUploadWord"))
                    {
                        var isFirstLineTitle  = TranslateUtils.ToBool(Request.QueryString["isFirstLineTitle"]);
                        var isFirstLineRemove = TranslateUtils.ToBool(Request.QueryString["isFirstLineRemove"]);
                        var isClearFormat     = TranslateUtils.ToBool(Request.QueryString["isClearFormat"]);
                        var isFirstLineIndent = TranslateUtils.ToBool(Request.QueryString["isFirstLineIndent"]);
                        var isClearFontSize   = TranslateUtils.ToBool(Request.QueryString["isClearFontSize"]);
                        var isClearFontFamily = TranslateUtils.ToBool(Request.QueryString["isClearFontFamily"]);
                        var isClearImages     = TranslateUtils.ToBool(Request.QueryString["isClearImages"]);
                        var contentLevel      = TranslateUtils.ToInt(Request.QueryString["contentLevel"]);
                        var fileName          = Request.QueryString["fileName"];

                        formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName);
                    }

                    ascTitle.SetParameters(PublishmentSystemInfo, _nodeInfo.NodeId, _tableStyle, _tableName, ContentAttribute.Title, formCollection, false, IsPostBack);
                    acAttributes.SetParameters(formCollection, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, false, IsPostBack);
                }
                //else
                //{

                //    this.Tags.Text = contentInfo.Tags;
                //}

                //if (contentID == 0)
                //{
                //    NameValueCollection formCollection = new NameValueCollection();
                //    this.ascContent.SetParameters(base.PublishmentSystemInfo, base.PublishmentSystemInfo.Additional.GovPublicNodeID, ETableStyle.GovPublicContent, base.PublishmentSystemInfo.AuxiliaryTableForGovPublic, GovPublicContentAttribute.Content, formCollection, false, base.IsPostBack);
                //}
                else
                {
                    departmentId   = contentInfo.DepartmentId;
                    departmentName = DepartmentManager.GetDepartmentName(departmentId);

                    foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList)
                    {
                        var categoryId = TranslateUtils.ToInt(contentInfo.GetExtendedAttribute(categoryClassInfo.ContentAttributeName));
                        if (categoryId > 0)
                        {
                            var categoryName = DataProvider.GovPublicCategoryDao.GetCategoryName(categoryId);
                            categoryBuilder.Append(
                                $@"<script>showCategory{categoryClassInfo.ClassCode}('{categoryName}', '{categoryId}');</script>");
                        }
                    }

                    tbIdentifier.Text       = contentInfo.Identifier;
                    tbPublisher.Text        = contentInfo.Publisher;
                    tbDocumentNo.Text       = contentInfo.DocumentNo;
                    dtbPublishDate.DateTime = contentInfo.PublishDate;
                    tbKeywords.Text         = contentInfo.Keywords;
                    dtbEffectDate.DateTime  = contentInfo.EffectDate;
                    ControlUtils.SelectListItemsIgnoreCase(rblIsAbolition, contentInfo.IsAbolition.ToString());
                    dtbAbolitionDate.DateTime = contentInfo.AbolitionDate;
                    tbDescription.Text        = contentInfo.Description;

                    ascTitle.SetParameters(PublishmentSystemInfo, _nodeInfo.NodeId, _tableStyle, _tableName, ContentAttribute.Title, contentInfo.Attributes, true, IsPostBack);

                    acAttributes.SetParameters(contentInfo.Attributes, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, true, IsPostBack);
                    Tags.Text = contentInfo.Tags;
                }

                if (departmentId == 0)
                {
                    departmentId = BaiRongDataProvider.AdministratorDao.GetDepartmentId(Body.AdministratorName);
                    if (departmentId > 0)
                    {
                        departmentName = DepartmentManager.GetDepartmentName(departmentId);
                    }
                }

                categoryBuilder.Append(
                    $@"<script>showCategoryChannel('{nodeNames}', '{nodeId}');showCategoryDepartment('{departmentName}', '{departmentId}');</script>");

                ltlCategoryScript.Text = categoryBuilder.ToString();

                if (HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentCheck))
                {
                    phStatus.Visible = true;

                    int checkedLevel;
                    var isChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, PublishmentSystemId, out checkedLevel);
                    LevelManager.LoadContentLevelToEdit(ContentLevel, PublishmentSystemInfo, nodeId, contentInfo, isChecked, checkedLevel);
                }
                else
                {
                    phStatus.Visible = false;
                }

                Submit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));

                if (PublishmentSystemInfo.Additional.GovPublicIsPublisherRelatedDepartmentId && string.IsNullOrEmpty(tbPublisher.Text))
                {
                    tbPublisher.Text = departmentName;
                }
            }
            else
            {
                if (_contentId == 0)
                {
                    ascTitle.SetParameters(PublishmentSystemInfo, _nodeInfo.NodeId, _tableStyle, _tableName, ContentAttribute.Title, Request.Form, false, IsPostBack);

                    acAttributes.SetParameters(Request.Form, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, false, IsPostBack);
                }
                else
                {
                    ascTitle.SetParameters(PublishmentSystemInfo, _nodeInfo.NodeId, _tableStyle, _tableName, ContentAttribute.Title, Request.Form, true, IsPostBack);

                    acAttributes.SetParameters(Request.Form, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, true, IsPostBack);
                }
                //this.ascContent.SetParameters(base.PublishmentSystemInfo, base.PublishmentSystemInfo.Additional.GovPublicNodeID, ETableStyle.GovPublicContent, base.PublishmentSystemInfo.AuxiliaryTableForGovPublic, GovPublicContentAttribute.Content, base.Request.Form, true, base.IsPostBack);
            }
            DataBind();
        }
Exemple #16
0
        protected override void Render(HtmlTextWriter output)
        {
            if (formCollection == null)
            {
                if (HttpContext.Current.Request.Form != null && HttpContext.Current.Request.Form.Count > 0)
                {
                    formCollection = HttpContext.Current.Request.Form;
                }
                else
                {
                    formCollection = new NameValueCollection();
                }
            }

            var styleInfo = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, attributeName, relatedIdentities);

            if (!string.IsNullOrEmpty(DefaultValue))
            {
                styleInfo.DefaultValue = DefaultValue;
            }

            if (styleInfo.IsVisible == false)
            {
                return;
            }

            var helpHtml    = $"{styleInfo.DisplayName}:";
            var pageScripts = new NameValueCollection();

            if (string.IsNullOrEmpty(AdditionalAttributes))
            {
                AdditionalAttributes = InputParserUtils.GetAdditionalAttributes(string.Empty, EInputTypeUtils.GetEnumType(styleInfo.InputType));
            }

            styleInfo.Additional.IsValidate = TranslateUtils.ToBool(IsValidate);
            styleInfo.Additional.IsRequired = TranslateUtils.ToBool(IsRequire);

            var inputHtml = BackgroundInputTypeParser.Parse(publishmentSystemInfo, nodeID, styleInfo, tableStyle, attributeName, formCollection, isEdit, isPostBack, AdditionalAttributes, pageScripts, true);

            if (string.IsNullOrEmpty(FormatString))
            {
                if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor))
                {
                    output.Write(@"
<tr><td colspan=""4"" align=""left"">{0}</td></tr>
<tr><td colspan=""4"" align=""left"">{1}</td></tr>
", helpHtml, inputHtml);
                }
                else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image))
                {
                    output.Write(@"
<tr height=""80"" valign=""middle""><td>{0}</td><td colspan=""3"">{1}</td></tr>
", helpHtml, inputHtml);
                }
                else
                {
                    output.Write(@"
<tr><td>{0}</td><td colspan=""3"">{1}</td></tr>
", helpHtml, inputHtml);
                }
            }
            else
            {
                output.Write(FormatString, helpHtml, inputHtml);
            }

            foreach (string key in pageScripts.Keys)
            {
                output.Write(pageScripts[key]);
            }
        }
Exemple #17
0
        public static string ParseText(IAttributes attributes, SiteInfo siteInfo, int channelId, TableStyleInfo styleInfo, StringBuilder extraBuilder)
        {
            var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage);

            if (styleInfo.Additional.IsValidate)
            {
                extraBuilder.Append(
                    $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>");
            }

            if (styleInfo.Additional.IsFormatString)
            {
                var formatStrong = false;
                var formatEm     = false;
                var formatU      = false;
                var formatColor  = string.Empty;
                var formatValues = attributes.GetString(ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName));
                if (!string.IsNullOrEmpty(formatValues))
                {
                    ContentUtility.SetTitleFormatControls(formatValues, out formatStrong, out formatEm, out formatU, out formatColor);
                }

                extraBuilder.Append(
                    $@"<a class=""btn"" href=""javascript:;"" onclick=""$('#div_{styleInfo.AttributeName}').toggle();return false;""><i class=""icon-text-height""></i></a>
<script type=""text/javascript"">
function {styleInfo.AttributeName}_strong(e){{
var e = $(e);
if ($('#{styleInfo.AttributeName}_formatStrong').val() == 'true'){{
$('#{styleInfo.AttributeName}_formatStrong').val('false');
e.removeClass('btn-success');
}}else{{
$('#{styleInfo.AttributeName}_formatStrong').val('true');
e.addClass('btn-success');
}}
}}
function {styleInfo.AttributeName}_em(e){{
var e = $(e);
if ($('#{styleInfo.AttributeName}_formatEM').val() == 'true'){{
$('#{styleInfo.AttributeName}_formatEM').val('false');
e.removeClass('btn-success');
}}else{{
$('#{styleInfo.AttributeName}_formatEM').val('true');
e.addClass('btn-success');
}}
}}
function {styleInfo.AttributeName}_u(e){{
var e = $(e);
if ($('#{styleInfo.AttributeName}_formatU').val() == 'true'){{
$('#{styleInfo.AttributeName}_formatU').val('false');
e.removeClass('btn-success');
}}else{{
$('#{styleInfo.AttributeName}_formatU').val('true');
e.addClass('btn-success');
}}
}}
function {styleInfo.AttributeName}_color(){{
if ($('#{styleInfo.AttributeName}_formatColor').val()){{
$('#{styleInfo.AttributeName}_colorBtn').css('color', $('#{styleInfo.AttributeName}_formatColor').val());
$('#{styleInfo.AttributeName}_colorBtn').addClass('btn-success');
}}else{{
$('#{styleInfo.AttributeName}_colorBtn').css('color', '');
$('#{styleInfo.AttributeName}_colorBtn').removeClass('btn-success');
}}
$('#{styleInfo.AttributeName}_colorContainer').hide();
}}
</script>
");

                extraBuilder.Append($@"
<div class=""btn-group btn-group-sm"" style=""float:left;"">
    <button class=""btn{(formatStrong ? @" btn-success" : string.Empty)}"" style=""font-weight:bold;font-size:12px;"" onclick=""{styleInfo
                    .AttributeName}_strong(this);return false;"">粗体</button>
    <button class=""btn{(formatEm ? " btn-success" : string.Empty)}"" style=""font-style:italic;font-size:12px;"" onclick=""{styleInfo
                    .AttributeName}_em(this);return false;"">斜体</button>
    <button class=""btn{(formatU ? " btn-success" : string.Empty)}"" style=""text-decoration:underline;font-size:12px;"" onclick=""{styleInfo
                    .AttributeName}_u(this);return false;"">下划线</button>
    <button class=""btn{(!string.IsNullOrEmpty(formatColor) ? " btn-success" : string.Empty)}"" style=""font-size:12px;"" id=""{styleInfo
                    .AttributeName}_colorBtn"" onclick=""$('#{styleInfo.AttributeName}_colorContainer').toggle();return false;"">颜色</button>
</div>
<div id=""{styleInfo.AttributeName}_colorContainer"" class=""input-append"" style=""float:left;display:none"">
    <input id=""{styleInfo.AttributeName}_formatColor"" name=""{styleInfo.AttributeName}_formatColor"" class=""input-mini color {{required:false}}"" type=""text"" value=""{formatColor}"" placeholder=""颜色值"">
    <button class=""btn"" type=""button"" onclick=""Title_color();return false;"">确定</button>
</div>
<input id=""{styleInfo.AttributeName}_formatStrong"" name=""{styleInfo.AttributeName}_formatStrong"" type=""hidden"" value=""{formatStrong
                    .ToString().ToLower()}"" />
<input id=""{styleInfo.AttributeName}_formatEM"" name=""{styleInfo.AttributeName}_formatEM"" type=""hidden"" value=""{formatEm
                    .ToString().ToLower()}"" />
<input id=""{styleInfo.AttributeName}_formatU"" name=""{styleInfo.AttributeName}_formatU"" type=""hidden"" value=""{formatU
                    .ToString().ToLower()}"" />
");
            }

            if (channelId > 0 && styleInfo.AttributeName == ContentAttribute.Title)
            {
                extraBuilder.Append(@"
<script type=""text/javascript"">
function getTitles(title){
	$.get('[url]&title=' + encodeURIComponent(title) + '&channelID=' + $('#channelID').val() + '&r=' + Math.random(), function(data) {
		if(data !=''){
			var arr = data.split('|');
			var temp='';
			for(i=0;i<arr.length;i++)
			{
				temp += '<li><a>'+arr[i].replace(title,'<b>' + title + '</b>') + '</a></li>';
			}
			var myli='<ul>'+temp+'</ul>';
			$('#titleTips').html(myli);
			$('#titleTips').show();
		}else{
            $('#titleTips').hide();
        }
		$('#titleTips li').click(function () {
			$('#Title').val($(this).text());
			$('#titleTips').hide();
		})
	});	
}
$(document).ready(function () {
$('#Title').keyup(function (e) {
    if (e.keyCode != 40 && e.keyCode != 38) {
        var title = $('#Title').val();
        if (title != ''){
            window.setTimeout(""getTitles('"" + title + ""');"", 200);
        }else{
            $('#titleTips').hide();
        }
    }
}).blur(function () {
	window.setTimeout(""$('#titleTips').hide();"", 200);
})});
</script>
<div id=""titleTips"" class=""inputTips""></div>");
                extraBuilder.Replace("[url]", AjaxCmsService.GetTitlesUrl(siteInfo.Id, channelId));
            }

            var value = StringUtils.HtmlDecode(attributes.GetString(styleInfo.AttributeName));

            return
                ($@"<input id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" type=""text"" class=""form-control"" value=""{value}"" {validateAttributes} />");
        }