Example #1
0
        private static string GetContentUrlById(SiteInfo siteInfo, int channelId, int contentId, int sourceId, int referenceId, string linkUrl, bool isLocal)
        {
            if (isLocal)
            {
                return(ApiRoutePreview.GetContentUrl(siteInfo.Id, channelId, contentId));
            }

            var tableNameCurrent   = ChannelManager.GetTableName(siteInfo, channelId);
            var contentInfoCurrent = Content.GetContentInfo(tableNameCurrent, contentId);

            if (referenceId > 0 && contentInfoCurrent.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
            {
                if (sourceId > 0 && (ChannelManager.IsExists(siteInfo.Id, sourceId) || ChannelManager.IsExists(sourceId)))
                {
                    var targetChannelId   = sourceId;
                    var targetSiteId      = Node.GetSiteId(targetChannelId);
                    var targetSiteInfo    = SiteManager.GetSiteInfo(targetSiteId);
                    var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);

                    var tableName   = ChannelManager.GetTableName(targetSiteInfo, targetChannelInfo);
                    var contentInfo = Content.GetContentInfo(tableName, referenceId);
                    if (contentInfo == null || contentInfo.ChannelId <= 0)
                    {
                        return(PageUtils.UnclickedUrl);
                    }
                    if (contentInfo.SiteId == targetSiteInfo.Id)
                    {
                        return(GetContentUrlById(targetSiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false));
                    }
                    var siteInfoTmp = SiteManager.GetSiteInfo(contentInfo.SiteId);
                    return(GetContentUrlById(siteInfoTmp, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false));
                }
                else
                {
                    var tableName = ChannelManager.GetTableName(siteInfo, channelId);
                    channelId = Content.GetChannelId(tableName, referenceId);
                    linkUrl   = Content.GetValue(tableName, referenceId, ContentAttribute.LinkUrl);
                    return(GetContentUrlById(siteInfo, channelId, referenceId, 0, 0, linkUrl, false));
                }
            }
            if (!string.IsNullOrEmpty(linkUrl))
            {
                return(ParseNavigationUrl(siteInfo, linkUrl, false));
            }
            var contentUrl = PathUtility.ContentFilePathRules.Parse(siteInfo, channelId, contentId);

            return(GetSiteUrl(siteInfo, contentUrl, false));
        }
Example #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

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

            _channelId = Body.GetQueryInt("channelId");
            var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            _tableName = ChannelManager.GetTableName(SiteInfo, channelInfo);
            _contentId = Body.GetQueryInt("ID");
            _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);

            _contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, _contentId);

            if (IsPostBack)
            {
                return;
            }

            var styleInfoList        = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
            var myStyleInfoArrayList = new ArrayList();

            if (styleInfoList != null)
            {
                foreach (var styleInfo in styleInfoList)
                {
                    myStyleInfoArrayList.Add(styleInfo);
                }
            }

            RptContents.DataSource     = myStyleInfoArrayList;
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            LtlNodeName.Text = ChannelManager.GetChannelName(SiteId, _channelId);

            LtlTags.Text = _contentInfo.Tags;
            if (string.IsNullOrEmpty(LtlTags.Text))
            {
                PhTags.Visible = false;
            }

            LtlContentGroup.Text = _contentInfo.GroupNameCollection;
            if (string.IsNullOrEmpty(LtlContentGroup.Text))
            {
                PhContentGroup.Visible = false;
            }

            LtlLastEditDate.Text     = DateUtils.GetDateAndTimeString(_contentInfo.LastEditDate);
            LtlAddUserName.Text      = AdminManager.GetDisplayName(_contentInfo.AddUserName, true);
            LtlLastEditUserName.Text = AdminManager.GetDisplayName(_contentInfo.LastEditUserName, true);

            LtlContentLevel.Text = CheckManager.GetCheckState(SiteInfo, _contentInfo.IsChecked, _contentInfo.CheckedLevel);

            if (_contentInfo.ReferenceId > 0 && _contentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
            {
                var referenceSiteId      = DataProvider.ChannelDao.GetSiteId(_contentInfo.SourceId);
                var referenceSiteInfo    = SiteManager.GetSiteInfo(referenceSiteId);
                var referenceTableName   = ChannelManager.GetTableName(referenceSiteInfo, _contentInfo.SourceId);
                var referenceContentInfo = DataProvider.ContentDao.GetContentInfo(referenceTableName, _contentInfo.ReferenceId);

                if (referenceContentInfo != null)
                {
                    var pageUrl           = PageUtility.GetContentUrl(referenceSiteInfo, referenceContentInfo, true);
                    var referenceNodeInfo = ChannelManager.GetChannelInfo(referenceContentInfo.SiteId, referenceContentInfo.ChannelId);
                    var addEditUrl        =
                        WebUtils.GetContentAddEditUrl(referenceSiteInfo.Id,
                                                      referenceNodeInfo, _contentInfo.ReferenceId, Body.GetQueryString("ReturnUrl"));

                    LtlScripts.Text += $@"
<div class=""tips"">此内容为对内容 (站点:{referenceSiteInfo.SiteName},栏目:{referenceNodeInfo.ChannelName})“<a href=""{pageUrl}"" target=""_blank"">{_contentInfo.Title}</a>”(<a href=""{addEditUrl}"">编辑</a>) 的引用,内容链接将和原始内容链接一致</div>";
                }
            }

            BtnSubmit.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowString(SiteInfo.Id, _channelId, _contentId, _returnUrl));
            HlPreview.NavigateUrl = ApiRoutePreview.GetContentUrl(SiteId, _contentInfo.ChannelId, _contentInfo.Id);
        }
Example #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

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

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

            ReturnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("returnUrl"));
            if (string.IsNullOrEmpty(ReturnUrl))
            {
                ReturnUrl = PageContent.GetRedirectUrl(SiteId, channelId);
            }

            _nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId);

            _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo);
            ContentInfo contentInfo = null;

            _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, relatedIdentities);

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

            if (contentId > 0)
            {
                contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
            }

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

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

            AcAttributes.SiteInfo      = SiteInfo;
            AcAttributes.ChannelId     = _nodeInfo.Id;
            AcAttributes.StyleInfoList = _styleInfoList;

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

                LtlPageTitle.Text  = pageTitle;
                LtlPageTitle.Text += $@"
<script language=""javascript"" type=""text/javascript"">
var previewUrl = '{ApiRoutePreview.GetContentUrl(SiteId, _nodeInfo.Id, contentId)}?';
</script>
";

                if (HasChannelPermissions(_nodeInfo.Id, ConfigManager.Permissions.Channel.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 = DataProvider.ContentGroupDao.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(_nodeInfo.Id, ConfigManager.Permissions.Channel.ContentCheck))
                {
                    PhStatus.Visible = true;
                    int checkedLevel;
                    var isChecked = CheckManager.GetUserCheckLevel(Body.AdminName, SiteInfo, _nodeInfo.Id, out checkedLevel);
                    if (Body.IsQueryExists("contentLevel"))
                    {
                        checkedLevel = TranslateUtils.ToIntWithNagetive(Body.GetQueryString("contentLevel"));
                        if (checkedLevel != CheckManager.LevelInt.NotChange)
                        {
                            isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
                        }
                    }

                    CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, _nodeInfo.Id, 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 (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");

                        var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, 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 ExtendedAttributes(Request.Form);

                if (Body.GetQueryBool("isPreview"))
                {
                    string errorMessage;
                    var    previewId = SaveContentInfo(true, out errorMessage);
                    Response.Clear();
                    Response.Write($"{{previewId:{previewId} }}");
                    Response.Flush();
                    Response.End();
                }
            }
            //DataBind();
        }