Пример #1
0
        protected void rptRow_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem dataItem = (DefaultArticlePageItem)e.Item.DataItem;

                if (dataItem.InnerItem.InheritsTemplate(DefaultArticlePageItem.TemplateId))
                {
                    DefaultArticlePageItem article = (DefaultArticlePageItem)dataItem;

                    System.Web.UI.WebControls.Image imgThumbnail = e.FindControlAs <System.Web.UI.WebControls.Image>("imgThumbnail");
                    HyperLink hypArticleLink = e.FindControlAs <HyperLink>("hypArticleLink");
                    HyperLink hypThumbnail   = e.FindControlAs <HyperLink>("hypThumbnail");
                    ArticleRecommendationIcons articleRecommendationIcons = e.FindControlAs <ArticleRecommendationIcons>("articleRecommendationIcons");

                    if (imgThumbnail != null)
                    {
                        imgThumbnail.ImageUrl = article.GetArticleThumbnailUrl(230, 129);
                    }

                    if (hypArticleLink != null)
                    {
                        hypArticleLink.NavigateUrl = hypThumbnail.NavigateUrl = article.GetUrl();
                        hypArticleLink.Text        = article.ContentPage.PageTitle;
                    }

                    if (IsUserLoggedIn)
                    {
                        articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                        articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
                    }
                }
            }
        }
Пример #2
0
        protected void rptRow_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Item dataItem = e.Item.DataItem as Item;

                if (dataItem.InheritsTemplate(DefaultArticlePageItem.TemplateId))
                {
                    DefaultArticlePageItem article = (DefaultArticlePageItem)dataItem;

                    System.Web.UI.WebControls.Image imgThumbnail = e.FindControlAs <System.Web.UI.WebControls.Image>("imgThumbnail");
                    HyperLink hypArticleLink = e.FindControlAs <HyperLink>("hypArticleLink");
                    HyperLink hypThumbnail   = e.FindControlAs <HyperLink>("hypThumbnail");

                    if (imgThumbnail != null)
                    {
                        imgThumbnail.ImageUrl = article.GetArticleThumbnailUrl(230, 129);
                    }

                    if (hypArticleLink != null)
                    {
                        hypArticleLink.NavigateUrl = hypThumbnail.NavigateUrl = article.GetUrl();
                        hypArticleLink.Text        = article.ContentPage.PageTitle;
                    }
                }
            }
        }
Пример #3
0
        public ResultSet SearchAllArticles(string terms, string type, int page, string lang)
        {
            ResultSet results = new ResultSet();

            SetContextLanguage(lang);

            int blurbLimit         = 150; // TODO: move to constant
            SearchResultsItem item = Sitecore.Context.Database.GetItem(Constants.Pages.SearchResults);

            if (item != null && !string.IsNullOrEmpty(item.SearchResultSummaryCharacterLimit.Raw))
            {
                blurbLimit = item.SearchResultSummaryCharacterLimit.Integer;
            }

            int                  totalResults   = 0;
            List <Article>       articles       = SearchHelper.PerformArticleSearch(terms, type, page, out totalResults);
            List <SearchArticle> searchArticles = new List <SearchArticle>();

            foreach (Article article in articles)
            {
                DefaultArticlePageItem articleItem = article.GetItem();
                if (articleItem == null)
                {
                    continue;
                }

                // Handle cases such as invalid link format exception
                try
                {
                    var sa = new SearchArticle
                    {
                        Title     = Common.Helpers.TextHelper.HighlightSearchTitle(terms, HttpUtility.HtmlDecode(articleItem.ContentPage.PageTitle.Rendered)),
                        Url       = articleItem.GetUrl(),
                        Thumbnail = articleItem.GetArticleThumbnailUrl(230, 129),
                        Blurb     = articleItem.GetSearchResultBlurb(blurbLimit),
                        Type      = articleItem.GetArticleType()
                    };

                    searchArticles.Add(sa);
                }
                catch (Exception ex)
                {
                    Sitecore.Diagnostics.Log.Error("Error populating search result", ex, this);
                }
            }

            results.Articles     = searchArticles;
            results.TotalMatches = totalResults;

            results.HasMoreResults = HasMoreResults(page, Constants.SEARCH_RESULTS_ENTRIES_PER_PAGE, results.Articles.Count(), totalResults);

            return(results);
        }
        protected void rptAuthorArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem article = (DefaultArticlePageItem)e.Item.DataItem;

                if (article != null)
                {
                    HyperLink hypImageLink        = e.FindControlAs <HyperLink>("hypImageLink");
                    HyperLink hypAuthor           = e.FindControlAs <HyperLink>("hypAuthor");
                    HyperLink hypReadMore         = e.FindControlAs <HyperLink>("hypReadMore");
                    HyperLink hypArticleTitleLink = e.FindControlAs <HyperLink>("hypArticleTitleLink");
                    Literal   litCommentCount     = e.FindControlAs <Literal>("litCommentCount");
                    Literal   litArticleTitle     = e.FindControlAs <Literal>("litArticleTitle");
                    Literal   litDatePosted       = e.FindControlAs <Literal>("litDatePosted");
                    Literal   litAbstract         = e.FindControlAs <Literal>("litAbstract");
                    ArticleRecommendationIcons articleRecommendationIcons = e.FindControlAs <ArticleRecommendationIcons>("articleRecommendationIcons");

                    if (article.AuthorName.Item != null)
                    {
                        hypAuthor.Text        = article.AuthorName.Item.DisplayName;
                        hypAuthor.NavigateUrl = Sitecore.Context.Item.GetUrl();

                        hypImageLink.NavigateUrl = hypReadMore.NavigateUrl = hypArticleTitleLink.NavigateUrl = article.GetUrl();
                        hypImageLink.ImageUrl    = article.GetArticleThumbnailUrl(230, 129);

                        litArticleTitle.Text = article.DisplayName;
                        litDatePosted.Text   = article.InnerItem.Statistics.Created.ToString("MMM dd, yyyy");
                        litAbstract.Text     = UnderstoodDotOrg.Common.Helpers.TextHelper.TruncateText(
                            Sitecore.StringUtil.RemoveTags(HttpUtility.HtmlDecode(article.ContentPage.BodyContent.Raw)), 150);

                        bool hasMoreResults;
                        int  totalComments;

                        List <Comment> dataSource = TelligentService.ReadComments(
                            article.BlogId.ToString(), article.BlogPostId.ToString(), 1, Constants.ARTICLE_COMMENTS_PER_PAGE, "CreatedUtcDate", true, out totalComments, out hasMoreResults);

                        litCommentCount.Text = totalComments.ToString();

                        if (IsUserLoggedIn)
                        {
                            articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                            articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
                        }
                    }
                    else
                    {
                        e.Item.Visible = false;
                    }
                }
            }
        }
Пример #5
0
        private void BindContent()
        {
            if (DataSource != null)
            {
                DefaultArticlePageItem article = DataSource;

                frPageTitle.Item        = article;
                imgThumbnail.ImageUrl   = article.GetArticleThumbnailUrl(190, 107);
                hlThumbnail.NavigateUrl = hlTitle.NavigateUrl = article.GetUrl();

                articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
            }
        }
Пример #6
0
        void rptArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = (DefaultArticlePageItem)e.Item.DataItem;

                HyperLink hlArticleDetail = e.FindControlAs <HyperLink>("hlArticleDetail");
                hlArticleDetail.NavigateUrl = item.GetUrl();

                System.Web.UI.WebControls.Image imgThumbnail = e.FindControlAs <System.Web.UI.WebControls.Image>("imgThumbnail");
                imgThumbnail.ImageUrl = item.GetArticleThumbnailUrl(230, 129);

                FieldRenderer frPageTitle = e.FindControlAs <FieldRenderer>("frPageTitle");
                frPageTitle.Item = item;
            }
        }
        protected void rptTryMoreQuizzes_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem context = (DefaultArticlePageItem)e.Item.DataItem;

                System.Web.UI.WebControls.Image imgImage = e.FindControlAs <System.Web.UI.WebControls.Image>("imgImage");
                FieldRenderer frQuizName  = e.FindControlAs <FieldRenderer>("frQuizName");
                HyperLink     hypMoreLink = e.FindControlAs <HyperLink>("hypMoreLink");

                if (context != null)
                {
                    imgImage.ImageUrl = context.GetArticleThumbnailUrl(230, 129);;
                    frQuizName.Item   = context.InnerItem;

                    hypMoreLink.NavigateUrl = context.GetUrl();
                }
            }
        }
Пример #8
0
        protected void rptChildRelatedArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = (DefaultArticlePageItem)e.Item.DataItem;
                {
                    HyperLink hlArticleImage = e.FindControlAs <HyperLink>("hlArticleImage");
                    HyperLink hlArticleTitle = e.FindControlAs <HyperLink>("hlArticleTitle");

                    hlArticleImage.NavigateUrl = hlArticleTitle.NavigateUrl = item.InnerItem.GetUrl();

                    Image imgThumbnail = e.FindControlAs <Image>("imgThumbnail");
                    imgThumbnail.ImageUrl = item.GetArticleThumbnailUrl(150, 85);

                    // DEBUG - START
                    Literal litDebugTag = e.FindControlAs <Literal>("litDebugTag");

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("");
                    sb.AppendLine("Sitecore web db tagging:");
                    sb.AppendLine("Grades:");

                    foreach (var grade in item.ChildGrades.ListItems)
                    {
                        GradeLevelItem gli = grade;
                        sb.AppendLine(HttpUtility.HtmlDecode(gli.Name.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Issues:");

                    foreach (var issue in item.ChildIssues.ListItems)
                    {
                        ChildIssueItem cii = issue;
                        sb.AppendLine(HttpUtility.HtmlDecode(cii.IssueName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Child Diagnoses:");

                    foreach (var diagnosis in item.ChildDiagnoses.ListItems)
                    {
                        ChildDiagnosisItem cdi = diagnosis;
                        sb.AppendLine(HttpUtility.HtmlDecode(cdi.DiagnosisName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Interests:");

                    foreach (var interest in item.ApplicableInterests.ListItems)
                    {
                        ParentInterestItem pii = interest;
                        sb.AppendLine(HttpUtility.HtmlDecode(pii.InterestName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Evaluations:");

                    foreach (var itemEval in item.OtherApplicableEvaluations.ListItems)
                    {
                        sb.AppendLine(itemEval.Name);
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Diagnosed:");

                    foreach (var diag in item.DiagnosedCondition.ListItems)
                    {
                        sb.AppendLine(diag.Name);
                    }

                    sb.AppendLine("");

                    bool excluded = item.OverrideType.ListItems
                                    .Where(x => x.ID == Sitecore.Data.ID.Parse(Constants.ArticleTags.ExcludeFromPersonalization))
                                    .FirstOrDefault() != null;

                    sb.AppendLine(String.Format("Exclude from Personalization: {0}", excluded.ToString().ToLower()));

                    bool mustRead = item.ImportanceLevel.ListItems
                                    .Where(x => x.ID == Sitecore.Data.ID.Parse(Constants.ArticleTags.MustRead))
                                    .FirstOrDefault() != null;

                    sb.AppendLine(String.Format("Must read: {0}", mustRead.ToString().ToLower()));

                    sb.AppendLine(String.Format("Timely: {0}", IsTimely(item.DateStart.DateTime, item.DateEnd.DateTime).ToString()));

                    sb.AppendLine("");



                    Article article = SearchHelper.GetArticle(item.ID);
                    if (article != null)
                    {
                        sb.AppendLine("Solr index:");
                        sb.AppendLine("Grades:");

                        foreach (var grade in article.ChildGrades)
                        {
                            GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Guid);
                            if (gli != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(gli.Name.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Issues:");

                        foreach (var issue in article.ChildIssues)
                        {
                            ChildIssueItem cii = Sitecore.Context.Database.GetItem(issue.Guid);
                            if (cii != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(cii.IssueName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Child Diagnoses:");

                        foreach (var diagnosis in article.ChildDiagnoses)
                        {
                            ChildDiagnosisItem cdi = Sitecore.Context.Database.GetItem(diagnosis.Guid);
                            if (cdi != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(cdi.DiagnosisName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Interests:");

                        foreach (var interest in article.ParentInterests)
                        {
                            ParentInterestItem pii = Sitecore.Context.Database.GetItem(interest.Guid);
                            if (pii != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(pii.InterestName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Evaluations:");

                        foreach (var itemEval in article.ApplicableEvaluations)
                        {
                            Item i = Sitecore.Context.Database.GetItem(itemEval);
                            if (i != null)
                            {
                                sb.AppendLine(i.Name);
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Diagnosed:");

                        foreach (var diag in article.DiagnosedConditions)
                        {
                            Item i = Sitecore.Context.Database.GetItem(diag);
                            if (i != null)
                            {
                                sb.AppendLine(i.Name);
                            }
                        }

                        sb.AppendLine("");

                        bool excludedTag = article.OverrideTypes.Contains(Sitecore.Data.ID.Parse(Constants.ArticleTags.ExcludeFromPersonalization));

                        sb.AppendLine(String.Format("Exclude from Personalization: {0}", excludedTag.ToString().ToLower()));

                        bool mustReadTag = article.ImportanceLevels.Contains(Sitecore.Data.ID.Parse(Constants.ArticleTags.MustRead));
                        sb.AppendLine(String.Format("Must read: {0}", mustReadTag.ToString().ToLower()));

                        sb.AppendLine(String.Format("Timely: {0}", IsTimely(article.TimelyStart, article.TimelyEnd)));
                    }

                    litDebugTag.Text = String.Format("<!--{0}-->", sb.ToString());
                    // DEBUG - END
                }
            }
        }