Exemple #1
0
        private void ConfigureChildControls()
        {
            if (VersionInfoObject.IsNew)
            {
                return;
            }

            //check if items are enabled.
            if (DisplayEmailAFriend && VersionInfoObject.IsNew == false)
            {
                ea = (EmailAFriend)LoadControl(EmailControlToLoad);
                ea.ModuleConfiguration = ModuleConfiguration;
                ea.ID = Path.GetFileNameWithoutExtension(EmailControlToLoad);
                ea.VersionInfoObject = VersionInfoObject;
                phEmailAFriend.Controls.Add(ea);
            }
            if (DisplayPrinterFriendly && VersionInfoObject.IsNew == false)
            {
                pf = (PrinterFriendlyButton)LoadControl(PrinterControlToLoad);
                pf.ModuleConfiguration = ModuleConfiguration;
                pf.ID = Path.GetFileNameWithoutExtension(PrinterControlToLoad);
                phPrinterFriendly.Controls.Add(pf);
            }

            if (DisplayRelatedLinks)
            {
                ral = (RelatedArticleLinksBase)LoadControl(RelatedArticlesControlToLoad);
                ral.ModuleConfiguration = ModuleConfiguration;
                ral.ID = Path.GetFileNameWithoutExtension(RelatedArticlesControlToLoad);
                phRelatedArticles.Controls.Add(ral);
            }

            if (DisplayRelatedArticle)
            {
                Article a = VersionInfoObject.GetRelatedArticle(PortalId);
                if (a != null)
                {
                    ad = (ArticleDisplay)LoadControl(ArticleControlToLoad);
                    ad.ModuleConfiguration = ModuleConfiguration;
                    ad.ID                     = Path.GetFileNameWithoutExtension(ArticleControlToLoad);
                    ad.Overrideable           = false;
                    ad.UseCache               = true;
                    ad.DisplayPrinterFriendly = false;
                    ad.DisplayRelatedArticle  = false;
                    ad.DisplayRelatedLinks    = false;
                    ad.DisplayEmailAFriend    = false;



                    ad.SetItemId(a.ItemId);
                    ad.DisplayTitle = false;
                    phRelatedArticle.Controls.Add(ad);
                    divRelatedArticle.Visible = true;
                }
                else
                {
                    divRelatedArticle.Visible = false;
                }
            }

            if (RatingDisplayOption.Equals(RatingDisplayOption.Enable) || RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly))
            {
                //get the upnlRating setting
                ItemVersionSetting rtSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "upnlRating", "Visible", PortalId);
                if (rtSetting != null)
                {
                    upnlRating.Visible = Convert.ToBoolean(rtSetting.PropertyValue, CultureInfo.InvariantCulture);
                }
                if (upnlRating.Visible)
                {
                    //lblRatingMessage.Visible = true; //TODO: re-enable ratings
                    lblRatingMessage.Visible = false; //TODO: re-enable ratings

                    //ajaxRating.MaxRating = MaximumRating;

                    var avgRating = (int)Math.Round(((Article)VersionInfoObject).AverageRating);
                    //ajaxRating.CurrentRating = (avgRating > MaximumRating ? MaximumRating : (avgRating < 0 ? 0 : avgRating));

                    //ajaxRating.ReadOnly = RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly);
                }
            }

            btnComment.Visible = DisplayCommentsLink;
            if (IsCommentsEnabled)
            {
                btnComment.NavigateUrl = Request.RawUrl + "#CommentEntry";
                if (!UseForumComments || (DisplayPublishComments && !VersionInfoObject.IsNew))
                {
                    pnlComments.Visible = pnlCommentDisplay.Visible = true;
                    commentDisplay      = (CommentDisplayBase)LoadControl(CommentsControlToLoad);
                    commentDisplay.ModuleConfiguration = ModuleConfiguration;
                    commentDisplay.ID        = Path.GetFileNameWithoutExtension(CommentsControlToLoad);
                    commentDisplay.ArticleId = VersionInfoObject.ItemId;
                    phCommentsDisplay.Controls.Add(commentDisplay);
                }

                if (UseForumComments)
                {
                    pnlComments.Visible = true;
                    mvCommentDisplay.SetActiveView(vwForumComments);
                    ItemVersionSetting forumThreadIdSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "ArticleSetting", "CommentForumThreadId", PortalId);
                    if (forumThreadIdSetting != null)
                    {
                        lnkGoToForum.Visible     = true;
                        lnkGoToForum.NavigateUrl = ForumProvider.GetInstance(PortalId).GetThreadUrl(Convert.ToInt32(forumThreadIdSetting.PropertyValue, CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        btnForumComment.Visible = true;
                    }
                }
            }
            ConfigureTags();
        }
        private void ConfigureChildControls()
        {
            if (VersionInfoObject.IsNew) return;

            //check if items are enabled.
            if (DisplayEmailAFriend && VersionInfoObject.IsNew == false)
            {
                ea = (EmailAFriend)LoadControl(EmailControlToLoad);
                ea.ModuleConfiguration = ModuleConfiguration;
                ea.ID = Path.GetFileNameWithoutExtension(EmailControlToLoad);
                ea.VersionInfoObject = VersionInfoObject;
                phEmailAFriend.Controls.Add(ea);
            }
            if (DisplayPrinterFriendly && VersionInfoObject.IsNew == false)
            {
                pf = (PrinterFriendlyButton)LoadControl(PrinterControlToLoad);
                pf.ModuleConfiguration = ModuleConfiguration;
                pf.ID = Path.GetFileNameWithoutExtension(PrinterControlToLoad);
                phPrinterFriendly.Controls.Add(pf);
            }

            if (DisplayRelatedLinks)
            {
                ral = (RelatedArticleLinksBase)LoadControl(RelatedArticlesControlToLoad);
                ral.ModuleConfiguration = ModuleConfiguration;
                ral.ID = Path.GetFileNameWithoutExtension(RelatedArticlesControlToLoad);
                phRelatedArticles.Controls.Add(ral);
            }

            if (DisplayRelatedArticle)
            {
                Article a = VersionInfoObject.GetRelatedArticle(PortalId);
                if (a != null)
                {
                    ad = (ArticleDisplay)LoadControl(ArticleControlToLoad);
                    ad.ModuleConfiguration = ModuleConfiguration;
                    ad.ID = Path.GetFileNameWithoutExtension(ArticleControlToLoad);
                    ad.Overrideable = false;
                    ad.UseCache = true;
                    ad.DisplayPrinterFriendly = false;
                    ad.DisplayRelatedArticle = false;
                    ad.DisplayRelatedLinks = false;
                    ad.DisplayEmailAFriend = false;

                    ad.SetItemId(a.ItemId);
                    ad.DisplayTitle = false;
                    phRelatedArticle.Controls.Add(ad);
                    divRelatedArticle.Visible = true;
                }
                else
                {
                    divRelatedArticle.Visible = false;
                }
            }

            if (RatingDisplayOption.Equals(RatingDisplayOption.Enable) || RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly))
            {
                //get the upnlRating setting
                ItemVersionSetting rtSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "upnlRating", "Visible", PortalId);
                if (rtSetting != null)
                {

                    upnlRating.Visible = Convert.ToBoolean(rtSetting.PropertyValue, CultureInfo.InvariantCulture);
                }
                if (upnlRating.Visible)
                {
                    //lblRatingMessage.Visible = true; //TODO: re-enable ratings
                    lblRatingMessage.Visible = false; //TODO: re-enable ratings

                    //ajaxRating.MaxRating = MaximumRating;

                    var avgRating = (int)Math.Round(((Article)VersionInfoObject).AverageRating);
                    //ajaxRating.CurrentRating = (avgRating > MaximumRating ? MaximumRating : (avgRating < 0 ? 0 : avgRating));

                    //ajaxRating.ReadOnly = RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly);
                }
            }

            btnComment.Visible = DisplayCommentsLink;
            if (IsCommentsEnabled)
            {
                btnComment.NavigateUrl = Request.RawUrl + "#CommentEntry";
                if (!UseForumComments || (DisplayPublishComments && !VersionInfoObject.IsNew))
                {
                    pnlComments.Visible = pnlCommentDisplay.Visible = true;
                    commentDisplay = (CommentDisplayBase)LoadControl(CommentsControlToLoad);
                    commentDisplay.ModuleConfiguration = ModuleConfiguration;
                    commentDisplay.ID = Path.GetFileNameWithoutExtension(CommentsControlToLoad);
                    commentDisplay.ArticleId = VersionInfoObject.ItemId;
                    phCommentsDisplay.Controls.Add(commentDisplay);
                }

                if (UseForumComments)
                {
                    pnlComments.Visible = true;
                    mvCommentDisplay.SetActiveView(vwForumComments);
                    ItemVersionSetting forumThreadIdSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "ArticleSetting", "CommentForumThreadId", PortalId);
                    if (forumThreadIdSetting != null)
                    {
                        lnkGoToForum.Visible = true;
                        lnkGoToForum.NavigateUrl = ForumProvider.GetInstance(PortalId).GetThreadUrl(Convert.ToInt32(forumThreadIdSetting.PropertyValue, CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        btnForumComment.Visible = true;
                    }
                }
            }
            ConfigureTags();
        }