Example #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);
                    }
                }
            }
        }
Example #2
0
        protected void rptTopicListItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = (DefaultArticlePageItem)e.Item.DataItem;

                HyperLink hlTopicTitle = e.FindControlAs <HyperLink>("hlTopicTitle");
                hlTopicTitle.NavigateUrl = item.GetUrl();
                hlTopicTitle.Text        = item.ContentPage.PageTitle.Rendered;

                PlaceHolder phThumbnail = e.FindControlAs <PlaceHolder>("phThumbnail");

                var icons = e.FindControlAs <UnderstoodDotOrg.Web.Presentation.Sublayouts.Recommendation.ArticleRecommendationIcons>("ArticleRecommendationIcons");
                if (icons != null)
                {
                    icons.MatchingChildrenIds       = item.GetMatchingChildrenIds(CurrentMember);
                    icons.HasMatchingParentInterest = item.HasMatchingParentInterest(CurrentMember);
                }

                // Handle first image
                if (e.Item.ItemIndex == 0)
                {
                    Image  imgThumbnail = e.FindControlAs <Image>("imgThumbnail");
                    string source       = item.GetArticleFeaturedThumbnailUrl(190, 107);
                    imgThumbnail.ImageUrl = source;
                    phThumbnail.Visible   = !String.IsNullOrEmpty(source);
                }
                else
                {
                    phThumbnail.Visible = false;
                }
            }
        }
Example #3
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;
                    }
                }
            }
        }
Example #4
0
        protected void rptArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Article article = (Article)e.Item.DataItem;

                DefaultArticlePageItem item = article.GetItem();

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

                Literal litTitle = e.FindControlAs <Literal>("litTitle");
                litTitle.Text = item.ContentPage.PageTitle.Rendered;

                Repeater rptArticleIssues = e.FindControlAs <Repeater>("rptArticleIssues");
                var      issues           = article.ChildIssues.Select(i => Sitecore.Context.Database.GetItem(i.Guid))
                                            .Where(i => i != null)
                                            .Select(i => new ChildIssueItem(i));
                if (issues.Any())
                {
                    rptArticleIssues.DataSource = issues;
                    rptArticleIssues.DataBind();
                }

                Repeater rptArticleGrades = e.FindControlAs <Repeater>("rptArticleGrades");
                var      grades           = article.ChildGrades.Select(i => Sitecore.Context.Database.GetItem(i.Guid))
                                            .Where(i => i != null)
                                            .Select(i => new GradeLevelItem(i));
                if (grades.Any())
                {
                    rptArticleGrades.DataSource = grades;
                    rptArticleGrades.DataBind();
                }

                Repeater rptArticleInterests = e.FindControlAs <Repeater>("rptArticleInterests");
                var      interests           = article.ParentInterests.Select(i => Sitecore.Context.Database.GetItem(i.Guid))
                                               .Where(i => i != null)
                                               .Select(i => new ParentInterestItem(i));
                if (interests.Any())
                {
                    rptArticleInterests.DataSource = interests;
                    rptArticleInterests.DataBind();
                }

                var overrides = article.OverrideTypes.Select(i => Sitecore.Context.Database.GetItem(i.Guid))
                                .Where(i => i != null);
                Repeater rptArticleOverrides = e.FindControlAs <Repeater>("rptArticleOverrides");
                if (overrides.Any())
                {
                    rptArticleOverrides.DataSource = overrides;
                    rptArticleOverrides.DataBind();
                }
            }
        }
Example #5
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");
                    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 = article.GetUrl();
                        hypImageLink.ImageUrl    = article.GetArticleThumbnailUrl(230, 129);

                        litArticleTitle.Text = article.DisplayName;
                        litDatePosted.Text   = article.InnerItem.Statistics.Created.ToString("mm 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;
                    }
                }
            }
        }
Example #7
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);
            }
        }
Example #8
0
        protected void rptFeaturedArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem article = e.Item.DataItem as DefaultArticlePageItem;

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

                hypArticleLink.NavigateUrl = article.GetUrl();
                // TODO: verify this truncation is allowed
                ltArticleText.Text    = article.ContentPage.BasePageNEW.NavigationTitle.Raw.Truncate(50, true, true);
                imgThumbnail.ImageUrl = article.GetArticleFeaturedThumbnailUrl(230, 129);
            }
        }
        protected void rptTopicCarousel_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = e.Item.DataItem as DefaultArticlePageItem;

                System.Web.UI.WebControls.Image imgFeatured = e.FindControlAs <System.Web.UI.WebControls.Image>("imgFeatured");
                imgFeatured.ImageUrl = item.GetArticleFeaturedThumbnailUrl(630, 354);

                Literal litNavigationTitle = e.FindControlAs <Literal>("litNavigationTitle");
                litNavigationTitle.Text = item.ContentPage.BasePageNEW.NavigationTitle.Rendered;

                HyperLink hlImageLink = e.FindControlAs <HyperLink>("hlImageLink");
                hlImageLink.NavigateUrl = item.GetUrl();
            }
        }
Example #10
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();
                }
            }
        }