Beispiel #1
0
        protected override void Initialize()
        {
            string rawurl = Request.RawUrl;
            rawurl = We7Helper.RemoveParamFromUrl(rawurl, "keyword");
            string  qString = @"<label class=""hidden"" for=""user-search-input"">ËÑË÷{0}:</label>
                <input type=""text"" class=""search-input"" id=""KeyWord"" name=""KeyWord"" value=""""  onKeyPress=""javascript:KeyPressSearch('{1}',event);""  />
                <input type=""button"" value=""ËÑË÷"" class=""button"" id=""SearchButton""  onclick=""javascript:doSearch('{1}');""  />";
            qString = string.Format(qString, "À¸Ä¿", rawurl);
            SearchSimpleLiteral.Text = qString;

            MyChannelList = new ArrayList();
            List<Channel> allChannel = null;
            if (!string.IsNullOrEmpty(ChannelType) && ChannelType.ToString() == "link")
            {
                allChannel = ChannelHelper.GetAllLinkChannels();
            }
            else if (!string.IsNullOrEmpty(ChannelType) && ChannelType.ToString() == "article")
            {
                allChannel = ChannelHelper.GetChannelByModelName("");
            }
            else
            {
                Channel ch = ChannelHelper.GetChannel(ColumnID, null);
                string enumState = "";
                if (ch != null) enumState = ch.EnumState;
                allChannel = ChannelHelper.GetChannelsByType(enumState);
            }
            if (allChannel != null)
            {
                GetSubChannels(We7Helper.EmptyGUID, "", allChannel);
            }
            MyChannelList = FilterByKeyword();
            DetailGridView.DataSource = MyChannelList;
            DetailGridView.DataBind();
        }
Beispiel #2
0
        public override void InitControl()
        {
            List <Channel> list = ChannelHelper.GetChannelByModelName(PanelContext.ModelName);

            ddlChannel.DataSource     = list;
            ddlChannel.DataValueField = "ID";
            ddlChannel.DataTextField  = "FullPath";
            ddlChannel.DataBind();
            ddlChannel.Items.Insert(0, new ListItem("选择栏目", ""));

            if (Value != null && !String.IsNullOrEmpty(Value.ToString()))
            {
                ddlChannel.SelectedValue = Value.ToString();
            }
            else
            {
                ddlChannel.SelectedValue = Request["oid"];
            }

            ddlChannel.CssClass = Control.CssClass;
            if (Control.Required && !ddlChannel.CssClass.Contains("required"))
            {
                ddlChannel.CssClass += " required";
            }
        }
        /// <summary>
        /// 取得当前记录的Url
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public string GetUrl(Article a)
        {
            string key = a.ModelName + "$modelchannelurl$const";

            if (!ChannelMap.ContainsKey(key))
            {
                lock (Page)
                {
                    if (!ChannelMap.ContainsKey(key))
                    {
                        List <Channel> chs = ChannelHelper.GetChannelByModelName(a.ModelName);
                        ChannelMap.Add(key, chs != null && chs.Count > 0 ? chs[0].FullUrl : "");
                    }
                }
            }
            return(String.Format("{0}{1}", ChannelMap[key], a.FullUrl));
        }
        /// <summary>
        /// 格式化列表中的数据
        /// </summary>
        /// <param name="list">文章列表</param>        
        protected List<Article> FormatArticlesData(List<Article> list)
        {
            DateTime now = DateTime.Now;

            foreach (Article a in list)
            {
                //连接地址
                if (a.ContentType == (int)TypeOfArticle.LinkArticle)
                {
                    a.LinkUrl = a.ContentUrl;
                }
                else
                {
                    if (String.IsNullOrEmpty(a.ChannelFullUrl) && !String.IsNullOrEmpty(a.ModelName))
                    {
                        //这儿只能做一个容错处理
                        List<Channel> chs = ChannelHelper.GetChannelByModelName(a.ModelName);
                        if (chs.Count > 0)
                        {
                            a.ChannelFullUrl = chs[0].FullUrl;
                        }
                    }
                    a.LinkUrl = String.Format("{0}{1}", a.ChannelFullUrl, a.FullUrl);
                }
                a.TimeNote = a.Updated.ToString(DateFormat);
            

                if (ShowField("ToolTip"))
                {
                    a.FullTitle = a.Title;
                    a.FullTitle += "," + a.TimeNote;
                    if (a.Clicks > 0) a.FullTitle += ",阅读量:" + a.Clicks;
                }
                else
                    a.FullTitle = a.Title;


                if (TitleMaxLength > 0 && a.Title.Length > TitleMaxLength)
                {
                    a.Title = a.Title.Substring(0, TitleMaxLength) + "...";
                }                
            }
            return list;
        }
Beispiel #5
0
        void FormatArticle(Article article)
        {
            if (IsImage)
            {
                article.TagThumbnail = article.GetTagThumbnail(ThumbnailTag);
            }
            if (!ChannelMap.ContainsKey(article.OwnerID))
            {
                Channel ch = ChannelHelper.GetChannel(article.OwnerID, null);
                ChannelMap.Add(article.OwnerID, ch);
            }

            if (!String.IsNullOrEmpty(ShowChannel))
            {
                Channel ch          = ChannelMap[article.OwnerID];
                string  channelName = ch.Name;
                if (ChannelHasLink)
                {
                    channelName = string.Format("<a href='{1}' target='{2}'>{0}</a>", ch.Name, article.ChannelFullUrl, LinkTarget);
                }

                article.FullChannelPath = string.Format(ShowChannel, channelName);
            }

            article.Icon = GetIcon(article.State);

            if (NoLink)
            {
                article.LinkUrl = "";
            }
            else
            {
                if (article.ContentType == (int)TypeOfArticle.LinkArticle)
                {
                    article.LinkUrl = article.ContentUrl;
                }
                else
                {
                    if (We7Helper.IsEmptyID(article.OwnerID))
                    {
                        string key = article.ModelName + "$modelchannelurl$const";
                        if (!ChannelMap.ContainsKey(key))
                        {
                            List <Channel> chs = ChannelHelper.GetChannelByModelName(article.ModelName);
                            article.LinkUrl = String.Format("{0}{1}", chs != null && chs.Count > 0?chs[0].FullUrl:"", article.FullUrl);
                        }
                    }
                    else
                    {
                        article.LinkUrl = String.Format("{0}{1}", article.ChannelFullUrl, article.FullUrl);
                    }
                }
            }

            if (DateFormat == null || DateFormat == "")
            {
                TimeSpan ts = DateTime.Now - article.Updated;
                article.TimeNote = GetTimeNote(ts);
            }
            else
            {
                article.TimeNote = article.Updated.ToString(DateFormat);
            }

            if (ShowField("ToolTip"))
            {
                article.FullTitle  = article.Title;
                article.FullTitle += "," + article.TimeNote;
                if (article.Clicks > 0)
                {
                    article.FullTitle += ",阅读量:" + article.Clicks;
                }
            }
            else
            {
                article.FullTitle = article.Title;
            }

            if (TitleMaxLength > 0 && article.Title.Length > TitleMaxLength)
            {
                article.Title = article.Title.Substring(0, TitleMaxLength) + "...";
            }

            if (!string.IsNullOrEmpty(KeyWord))
            {
                article.Title = article.Title.Replace(KeyWord, "<em>" + KeyWord + "</em>");
            }

            if (Show("Description"))
            {
                if (SummaryMaxLength > 0 && article.Description != null &&
                    article.Description.Length > SummaryMaxLength)
                {
                    article.Description = article.Description.Substring(0, SummaryMaxLength) + "...";
                }

                if (string.IsNullOrEmpty(article.Description) && !string.IsNullOrEmpty(article.Content))
                {
                    string content = We7Helper.RemoveHtml(article.Content);
                    if (content.Length > summaryMaxLength)
                    {
                        article.Description = content.Substring(0, SummaryMaxLength) + "...";
                    }
                    else
                    {
                        article.Description = content;
                    }
                }

                if (!string.IsNullOrEmpty(KeyWord) && !string.IsNullOrEmpty(article.Description))
                {
                    article.Description = article.Description.Replace(KeyWord, "<em>" + KeyWord + "</em>");
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// 格式化列表中的数据
        /// </summary>
        /// <param name="list">文章列表</param>
        protected List <Article> FormatArticlesData(List <Article> list)
        {
            DateTime now = DateTime.Now;

            foreach (Article a in list)
            {
                if (ShowField("Thumbnail"))
                {
                    a.TagThumbnail = GetTagThumbnail(a, ThumbnailTag); //a.GetTagThumbnail(ThumbnailTag);
                }
                //Channel ch = ChannelHelper.GetChannel(a.OwnerID, null);
                if (!String.IsNullOrEmpty(ShowChannel))
                {
                    string channelName = a.ChannelName;
                    if (ChannelHasLink)
                    {
                        channelName = string.Format("<a href='{1}' target='{2}'>{0}</a>", a.ChannelName, a.ChannelFullUrl, LinkTarget);
                    }

                    a.FullChannelPath = string.Format(ShowChannel, channelName);
                }

                a.Icon = GetIcon(a.State);

                if (NoLink)
                {
                    a.LinkUrl = "";
                }
                else
                {
                    if (a.ContentType == (int)TypeOfArticle.LinkArticle)
                    {
                        a.LinkUrl = a.ContentUrl;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(a.ChannelFullUrl) && !String.IsNullOrEmpty(a.ModelName))
                        {
                            //这儿只能做一个容错处理
                            List <Channel> chs = ChannelHelper.GetChannelByModelName(a.ModelName);
                            if (chs.Count > 0)
                            {
                                a.ChannelFullUrl = chs[0].FullUrl;
                            }
                        }
                        a.LinkUrl = String.Format("{0}{1}", a.ChannelFullUrl, a.FullUrl);
                    }
                }

                if (DateFormat == null || DateFormat == "")
                {
                    TimeSpan ts = now - a.Updated;
                    a.TimeNote = GetTimeNote(ts);
                }
                else
                {
                    a.TimeNote = a.Updated.ToString(DateFormat);
                }

                if (ShowField("ToolTip"))
                {
                    a.FullTitle  = a.Title;
                    a.FullTitle += "," + a.TimeNote;
                    if (a.Clicks > 0)
                    {
                        a.FullTitle += ",阅读量:" + a.Clicks;
                    }
                }
                else
                {
                    a.FullTitle = a.Title;
                }

                if (TitleMaxLength > 0 && a.Title.Length > TitleMaxLength)
                {
                    a.Title = a.Title.Substring(0, TitleMaxLength) + "...";
                }

                if (!string.IsNullOrEmpty(KeyWord))
                {
                    a.Title = a.Title.Replace(KeyWord, "<em>" + KeyWord + "</em>");
                }

                if (Show("Description"))
                {
                    if (SummaryMaxLength > 0 && a.Description != null &&
                        a.Description.Length > SummaryMaxLength)
                    {
                        a.Description = a.Description.Substring(0, SummaryMaxLength) + "...";
                    }

                    if (string.IsNullOrEmpty(a.Description) && !string.IsNullOrEmpty(a.Content))
                    {
                        string content = We7Helper.RemoveHtml(a.Content);
                        if (content.Length > summaryMaxLength)
                        {
                            a.Description = content.Substring(0, SummaryMaxLength) + "...";
                        }
                        else
                        {
                            a.Description = content;
                        }
                    }

                    if (!string.IsNullOrEmpty(KeyWord) && !string.IsNullOrEmpty(a.Description))
                    {
                        a.Description = a.Description.Replace(KeyWord, "<em>" + KeyWord + "</em>");
                    }
                }

                if (AttachmentNum > 0)
                {
                    a.Attachments = AttachmentHelper.GetAttachments(a.ID);
                }
            }
            return(list);
        }