Example #1
0
        public static string GetSpecialUrl(SiteInfo siteInfo, int specialId, bool isLocal)
        {
            var specialUrl = SpecialManager.GetSpecialUrl(siteInfo, specialId);

            return(isLocal
                ? ApiRoutePreview.GetSpecialUrl(siteInfo.Id, specialId)
                : ParseNavigationUrl(siteInfo, specialUrl, false));
        }
Example #2
0
        public static string GetFileUrl(SiteInfo siteInfo, int fileTemplateId, bool isLocal)
        {
            var createdFileFullName = TemplateManager.GetCreatedFileFullName(siteInfo.Id, fileTemplateId);

            return(isLocal
                ? ApiRoutePreview.GetFileUrl(siteInfo.Id, fileTemplateId)
                : ParseNavigationUrl(siteInfo, createdFileFullName, false));
        }
Example #3
0
        // 得到发布系统首页地址
        public static string GetIndexPageUrl(SiteInfo siteInfo, bool isLocal)
        {
            var indexTemplateId     = TemplateManager.GetIndexTempalteId(siteInfo.Id);
            var createdFileFullName = TemplateManager.GetCreatedFileFullName(siteInfo.Id, indexTemplateId);

            return(isLocal
                ? ApiRoutePreview.GetSiteUrl(siteInfo.Id)
                : ParseNavigationUrl(siteInfo, createdFileFullName, false));
        }
Example #4
0
        public static string GetSpecialUrl(SiteInfo siteInfo, int specialId, bool isLocal)
        {
            var specialUrl = SpecialManager.GetSpecialUrl(siteInfo, specialId);

            var url = isLocal
                ? ApiRoutePreview.GetSpecialUrl(siteInfo.Id, specialId)
                : ParseNavigationUrl(siteInfo, specialUrl, false);

            return(RemoveDefaultFileName(siteInfo, url));
        }
Example #5
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 #6
0
 private static void DefaultRedirect(int siteId)
 {
     if (siteId == 0)
     {
         siteId = DataProvider.SiteDao.GetIdByIsRoot();
     }
     if (siteId != 0)
     {
         var siteInfo = SiteManager.GetSiteInfo(siteId);
         var url      = siteInfo.Additional.IsSeparatedWeb
             ? ApiRoutePreview.GetSiteUrl(siteId)
             : siteInfo.Additional.WebUrl;
         PageUtils.Redirect(url);
     }
     else
     {
         var url = PageUtils.ApplicationPath;
         PageUtils.Redirect(url);
     }
 }
Example #7
0
        private string GetTopMenuLinksHtml()
        {
            if (_siteInfo == null || _siteInfo.Id <= 0)
            {
                return(string.Empty);
            }

            var builder = new StringBuilder();

            builder.Append(
                $@"<li><a href=""{PageUtility.GetSiteUrl(_siteInfo, false)}"" target=""_blank"">访问站点</a></li>");
            builder.Append(
                $@"<li><a href=""{ApiRoutePreview.GetSiteUrl(_siteInfo.Id)}"" target=""_blank"">预览站点</a></li>");

            return($@"<li class=""has-submenu"">
              <a href=""javascript:;"">站点链接</a>
              <ul class=""submenu"">
                {builder}
              </ul>
            </li>");
        }
        protected override object Process()
        {
            var siteId    = AuthRequest.SiteId;
            var channelId = AuthRequest.ChannelId;
            var contentId = AuthRequest.ContentId;

            var siteInfo      = SiteManager.GetSiteInfo(siteId);
            var channelInfo   = ChannelManager.GetChannelInfo(siteId, channelId);
            var tableName     = ChannelManager.GetTableName(siteInfo, channelInfo);
            var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo);

            var form = AuthRequest.HttpRequest.Form;

            var dict        = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, form, ContentAttribute.AllAttributes.Value);
            var contentInfo = new ContentInfo(dict)
            {
                ChannelId        = channelId,
                SiteId           = siteId,
                AddUserName      = AuthRequest.AdminName,
                LastEditUserName = AuthRequest.AdminName,
                LastEditDate     = DateTime.Now
            };

            //contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
            var tagCollection = TagUtils.ParseTagsString(form["TbTags"]);

            contentInfo.Title = form["TbTitle"];
            var formatString    = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatStrong"]);
            var formatEm        = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatEM"]);
            var formatU         = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatU"]);
            var formatColor     = form[ContentAttribute.Title + "_formatColor"];
            var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);

            contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
            //foreach (ListItem listItem in CblContentAttributes.Items)
            //{
            //    var value = listItem.Selected.ToString();
            //    var attributeName = listItem.Value;
            //    contentInfo.Set(attributeName, value);
            //}
            //contentInfo.LinkUrl = TbLinkUrl.Text;
            contentInfo.AddDate   = TranslateUtils.ToDateTime(form["TbAddDate"]);
            contentInfo.IsChecked = false;
            contentInfo.Tags      = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

            foreach (var service in PluginManager.Services)
            {
                try
                {
                    service.OnContentFormSubmit(new ContentFormSubmitEventArgs(siteId, channelId, contentInfo.Id, new AttributesImpl(form), contentInfo));
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                }
            }

            contentInfo.Id = DataProvider.ContentDao.InsertPreview(tableName, siteInfo, channelInfo, contentInfo);

            return(new
            {
                previewUrl = ApiRoutePreview.GetContentPreviewUrl(siteId, channelId, contentId, contentInfo.Id)
            });
        }
Example #9
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 #10
0
        //得到栏目经过计算后的连接地址
        public static string GetChannelUrl(SiteInfo siteInfo, ChannelInfo channelInfo, bool isLocal)
        {
            if (channelInfo == null)
            {
                return(string.Empty);
            }

            if (isLocal)
            {
                return(ApiRoutePreview.GetChannelUrl(siteInfo.Id, channelInfo.Id));
            }

            var url = string.Empty;

            if (channelInfo.ParentId == 0)
            {
                url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
            }
            else
            {
                var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType);
                if (linkType == ELinkType.None)
                {
                    url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                }
                else if (linkType == ELinkType.NoLink)
                {
                    url = PageUtils.UnclickedUrl;
                }
                else
                {
                    if (linkType == ELinkType.NoLinkIfContentNotExists)
                    {
                        var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                        url = count == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                    }
                    else if (linkType == ELinkType.LinkToOnlyOneContent)
                    {
                        var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                        if (count == 1)
                        {
                            var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                            var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType)));
                            url = GetContentUrl(siteInfo, channelInfo, contentId, false);
                        }
                        else
                        {
                            url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                        }
                    }
                    else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToOnlyOneContent)
                    {
                        var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                        if (count == 0)
                        {
                            url = PageUtils.UnclickedUrl;
                        }
                        else if (count == 1)
                        {
                            var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                            var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType)));
                            url = GetContentUrl(siteInfo, channelInfo, contentId, false);
                        }
                        else
                        {
                            url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                        }
                    }
                    else if (linkType == ELinkType.LinkToFirstContent)
                    {
                        var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                        if (count >= 1)
                        {
                            var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                            var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType)));
                            //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
                            url = GetContentUrl(siteInfo, channelInfo, contentId, false);
                        }
                        else
                        {
                            url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                        }
                    }
                    else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToFirstContent)
                    {
                        var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                        if (count >= 1)
                        {
                            var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                            var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType)));
                            //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
                            url = GetContentUrl(siteInfo, channelInfo, contentId, false);
                        }
                        else
                        {
                            url = PageUtils.UnclickedUrl;
                        }
                    }
                    else if (linkType == ELinkType.NoLinkIfChannelNotExists)
                    {
                        url = channelInfo.ChildrenCount == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                    }
                    else if (linkType == ELinkType.LinkToLastAddChannel)
                    {
                        var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id);
                        url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                    }
                    else if (linkType == ELinkType.LinkToFirstChannel)
                    {
                        var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id);
                        url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, false);
                    }
                    else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToLastAddChannel)
                    {
                        var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id);
                        url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, false) : PageUtils.UnclickedUrl;
                    }
                    else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToFirstChannel)
                    {
                        var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id);
                        url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, false) : PageUtils.UnclickedUrl;
                    }
                }
            }

            return(RemoveDefaultFileName(siteInfo, url));
        }
Example #11
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();
        }
Example #12
0
        private static List <Tab> GetTopMenus(SiteInfo siteInfo, bool isSuperAdmin, List <int> siteIdListLatestAccessed, List <int> siteIdListWithPermissions)
        {
            var menus = new List <Tab>();

            if (siteInfo != null && siteIdListWithPermissions.Contains(siteInfo.Id))
            {
                var siteMenus = new List <Tab>();
                if (siteIdListWithPermissions.Count == 1)
                {
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Children = siteMenus.ToArray()
                    });
                }
                else
                {
                    var siteIdList = AdminManager.GetLatestTop10SiteIdList(siteIdListLatestAccessed, siteIdListWithPermissions);
                    foreach (var siteId in siteIdList)
                    {
                        var site = SiteManager.GetSiteInfo(siteId);
                        if (site == null)
                        {
                            continue;
                        }

                        siteMenus.Add(new Tab
                        {
                            Href   = PageUtils.GetMainUrl(site.Id),
                            Target = "_top",
                            Text   = site.SiteName
                        });
                    }
                    siteMenus.Add(new Tab
                    {
                        Href   = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target = "_layer",
                        Text   = "全部站点..."
                    });
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Href     = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target   = "_layer",
                        Children = siteMenus.ToArray()
                    });
                }

                var linkMenus = new List <Tab>
                {
                    new Tab {
                        Href = PageUtility.GetSiteUrl(siteInfo, false), Target = "_blank", Text = "访问站点"
                    },
                    new Tab {
                        Href = ApiRoutePreview.GetSiteUrl(siteInfo), Target = "_blank", Text = "预览站点"
                    }
                };
                menus.Add(new Tab {
                    Text = "站点链接", Children = linkMenus.ToArray()
                });
            }

            if (isSuperAdmin)
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    var tabs = TabManager.GetTabList(tab.Id, 0);
                    tab.Children = tabs.ToArray();

                    menus.Add(tab);
                }
            }

            return(menus);
        }
Example #13
0
        private static List <Tab> GetTopMenus(SiteInfo siteInfo, bool isSuperAdmin, List <int> siteIdListLatestAccessed, List <int> siteIdListWithPermissions, List <string> permissionList)
        {
            var menus = new List <Tab>();

            if (siteInfo != null && siteIdListWithPermissions.Contains(siteInfo.Id))
            {
                var siteMenus = new List <Tab>();
                if (siteIdListWithPermissions.Count == 1)
                {
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Children = siteMenus.ToArray()
                    });
                }
                else
                {
                    var siteIdList = AdminManager.GetLatestTop10SiteIdList(siteIdListLatestAccessed, siteIdListWithPermissions);
                    foreach (var siteId in siteIdList)
                    {
                        var site = SiteManager.GetSiteInfo(siteId);
                        if (site == null)
                        {
                            continue;
                        }

                        siteMenus.Add(new Tab
                        {
                            Href   = PageUtils.GetMainUrl(site.Id),
                            Target = "_top",
                            Text   = site.SiteName
                        });
                    }
                    siteMenus.Add(new Tab
                    {
                        Href   = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target = "_layer",
                        Text   = "全部站点..."
                    });
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Href     = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target   = "_layer",
                        Children = siteMenus.ToArray()
                    });
                }

                var linkMenus = new List <Tab>
                {
                    new Tab {
                        Href = PageUtility.GetSiteUrl(siteInfo, false), Target = "_blank", Text = "访问站点"
                    },
                    new Tab {
                        Href = ApiRoutePreview.GetSiteUrl(siteInfo.Id), Target = "_blank", Text = "预览站点"
                    }
                };
                menus.Add(new Tab {
                    Text = "站点链接", Children = linkMenus.ToArray()
                });
            }

            if (isSuperAdmin)
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    var tabs = TabManager.GetTabList(tab.Id, 0);
                    tab.Children = tabs.ToArray();

                    menus.Add(tab);
                }
            }
            else
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    if (!TabManager.IsValid(tab, permissionList))
                    {
                        continue;
                    }

                    var tabToAdd = new Tab
                    {
                        Id     = tab.Id,
                        Name   = tab.Name,
                        Text   = tab.Text,
                        Target = tab.Target,
                        Href   = tab.Href
                    };
                    var tabs      = TabManager.GetTabList(tab.Id, 0);
                    var tabsToAdd = new List <Tab>();
                    foreach (var menu in tabs)
                    {
                        if (!TabManager.IsValid(menu, permissionList))
                        {
                            continue;
                        }

                        Tab[] children = null;
                        if (menu.Children != null)
                        {
                            children = menu.Children.Where(child => TabManager.IsValid(child, permissionList))
                                       .ToArray();
                        }

                        var menuToAdd = new Tab
                        {
                            Id       = menu.Id,
                            Name     = menu.Name,
                            Text     = menu.Text,
                            Target   = menu.Target,
                            Href     = menu.Href,
                            Children = children
                        };
                        tabsToAdd.Add(menuToAdd);
                    }
                    tabToAdd.Children = tabsToAdd.ToArray();

                    menus.Add(tabToAdd);
                }
            }

            return(menus);
        }