Exemple #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectModule orderModule   = new ArticleModule();
            NinjectModule serviceModule = new ServiceModule("DefaultConnection");
            var           kernel        = new StandardKernel(orderModule, serviceModule);

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
        public static ArticlePartialViewModel CreateArticlePartialViewModel(ArticleItem articleItem, ArticleModule articleModule,
            ArrayList categoryNamesList, ArrayList attributeNamesList, PortalType portalType,
            Dictionary<string, string> resources, int clientId, int portalId, string adminURL)
        {
            ArticlePartialViewModel articlePartialViewModel = new ArticlePartialViewModel();
            DataConfigurationRepository dataConfigurationRepository = new
                            DataConfigurationRepository(HttpContext.Current.Application["KBDataPath"].ToString(), HttpContext.Current.Application["KBInstallPath"].ToString());
            articlePartialViewModel.Resources = resources;
            articlePartialViewModel.ArticleItem = articleItem;
            articlePartialViewModel.clientId = clientId;
            articlePartialViewModel.portalId = portalId;
            if (articleModule != null)
            {
                articlePartialViewModel.ArticleConfiguration = articleModule;
            }
            else
            {
                //---- set defaults ------

            }
            List<BreadcrumbViewModel> categories = new List<BreadcrumbViewModel>();
            foreach (List<string> names in categoryNamesList)
            {
                BreadcrumbViewModel itemList = new BreadcrumbViewModel();
                itemList.NavigationList = new List<SelectListItem>();
                foreach (string name in names)
                {
                    itemList.NavigationList.Add(new SelectListItem() { Text = name, Value = string.Empty, Selected = false });
                }
                categories.Add(itemList);
            }
            articlePartialViewModel.Categories = categories;
            articlePartialViewModel.Attributes = new List<BreadcrumbViewModel>();
            List<BreadcrumbViewModel> attr = new List<BreadcrumbViewModel>();
            foreach (List<string> names in attributeNamesList)
            {
                BreadcrumbViewModel itemList = new BreadcrumbViewModel();
                itemList.NavigationList = new List<SelectListItem>();
                foreach (string name in names)
                {
                    itemList.NavigationList.Add(new SelectListItem() { Text = name, Value = string.Empty, Selected = false });
                }
                attr.Add(itemList);
            }
            articlePartialViewModel.Attributes = attr;
            articlePartialViewModel.ImageLinks = new List<ImageLinkViewModel>();
            ImageLinkViewModel imageLinkViewModel;

            //check Favorite is enabled
            if (articlePartialViewModel.ArticleConfiguration.articleControlsProperties.ArticleFavoriteDisplay)
            {
                imageLinkViewModel = new ImageLinkViewModel() { Icon = (articlePartialViewModel.ArticleItem.Favorite == true &&
                    (portalType != PortalType.Open && portalType != PortalType.Registration)) ?
                    @Utilities.GetImageUrl(clientId, portalId, "favoriteactive.png") : @Utilities.GetImageUrl(clientId, portalId, "favorite.png"),
                                                                Link = "/Article/FavoriteArticle/" + clientId + "/" + portalId,
                                                                Title = Utilities.GetResourceText(resources, "CONTROLS_FAVORITELABEL"),
                                                                ToggleIcon = (articlePartialViewModel.ArticleItem.Favorite == true ||
                                                                portalType == PortalType.Open || portalType == PortalType.Registration) ?
                                                                @Utilities.GetImageUrl(clientId, portalId, "favorite.png") :
                                                                @Utilities.GetImageUrl(clientId, portalId, "favoriteactive.png")
                };
                imageLinkViewModel.Id = "favorites";
                articlePartialViewModel.ImageLinks.Add(imageLinkViewModel);
            }

            //check Subscription is enabled
            if (articlePartialViewModel.ArticleConfiguration.articleControlsProperties.ArticleSubscribeDisplay)
            {
                imageLinkViewModel = new ImageLinkViewModel() { Icon = @Utilities.GetImageUrl(clientId, portalId, "subscribe.png"),
                    Link = "", Title = Utilities.GetResourceText(resources, "CONTROLS_SUBSCRIBELABEL"),
                    ToggleIcon = @Utilities.GetImageUrl(clientId, portalId, "subscribe_selected.png") };
                // imageLinkViewModel = new ImageLinkViewModel() { Icon = (articlesViewModel.ArticlePartialViewModel.ArticleItem.SubscriptionStatus == true && (_portal.PortalType != PortalType.Open && _portal.PortalType != PortalType.Registration)) ? @Utilities.GetImageUrl(clientId, portalId, "subscribe_select.png") : @Utilities.GetImageUrl(clientId, portalId, "subscribe.png"), Link = "/Article/ToggleArticleSubscription/" + clientId + "/" + portalId, Title = Utilities.GetResourceText(resources, "CONTROLS_SUBSCRIBELABEL"), ToggleIcon = (articlesViewModel.ArticlePartialViewModel.ArticleItem.SubscriptionStatus == true || _portal.PortalType == PortalType.Open || _portal.PortalType == PortalType.Registration) ? @Utilities.GetImageUrl(clientId, portalId, "subscribe.png") : @Utilities.GetImageUrl(clientId, portalId, "subscribe.png") };
                //imageLinkViewModel = new ImageLinkViewModel() { Icon = @Utilities.GetImageUrl(clientId, portalId, "subscribe.png"), Link = "", Title = Utilities.GetResourceText(resources,"CONTROLS_SUBSCRIBELABEL"), ToggleIcon = @Utilities.GetImageUrl(clientId, portalId, "subscribe.png") };
                imageLinkViewModel.Id = "subscribe";
                articlePartialViewModel.ImageLinks.Add(imageLinkViewModel);
            }
            //Check share is enabled
            if (articlePartialViewModel.ArticleConfiguration.articleControlsProperties.ArticleShareDisplay)
            {
                imageLinkViewModel = new ImageLinkViewModel() { Icon = @Utilities.GetImageUrl(clientId, portalId, "share.png"),
                    Link = "", Title = Utilities.GetResourceText(resources, "CONTROLS_SHARELABEL"),
                    ToggleIcon = @Utilities.GetImageUrl(clientId, portalId, "share_selected.png") };
                imageLinkViewModel.Id = "share";
                articlePartialViewModel.ImageLinks.Add(imageLinkViewModel);
            }
            if (articlePartialViewModel.ArticleConfiguration.articleControlsProperties.ArticleEditDisplay)
            {
                imageLinkViewModel = new ImageLinkViewModel() { Icon = @Utilities.GetImageUrl(clientId, portalId, "edit.png"),
                                                                Link = adminURL + "/index.aspx?aid=",
                                                                Title = Utilities.GetResourceText(resources, "CONTROLS_EDITLABEL"),
                    ToggleIcon = @Utilities.GetImageUrl(clientId, portalId, "edit.png") };
                imageLinkViewModel.Id = "edit";
                articlePartialViewModel.ImageLinks.Add(imageLinkViewModel);
            }
            articlePartialViewModel.Attachments = articleItem.Attachments;
            return articlePartialViewModel;
        }
Exemple #3
0
 public void SetUp()
 {
     _articleServiceMock = new Mock <IArticleService>();
     _module             = new ArticleModule(_articleServiceMock.Object);
     _browser            = new Browser(x => x.Module(_module));
 }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this._module = this.Module as ArticleModule;

            if (this._module.CurrentArticleId > 0 && (!base.HasCachedOutput || this.Page.IsPostBack) || this.Page.User.Identity.IsAuthenticated)
            {
                // Article view
                this._activeArticle = this._module.GetArticleById(this._module.CurrentArticleId);
                this.litTitle.Text = this._activeArticle.Title;
                this.litContent.Text = this._activeArticle.Content;

                if (this._module.AllowComments || this._module.ShowAuthor || this._module.ShowCategory || this._module.ShowDateTime)
                {
                    this.pnlArticleInfo.Visible = true;

                    this.lblDateOnline.Text = TimeZoneUtil.AdjustDateToUserTimeZone(this._activeArticle.DateOnline, this.Page.User.Identity).ToString();
                    this.lblDateOnline.Visible = this._module.ShowDateTime;

                    this.litAuthor.Text = base.GetText("PUBLISHED") + " " + base.GetText("BY");
                    this.litAuthor.Visible = this._module.ShowAuthor;
                    this.hplAuthor.NavigateUrl = this._module.GetProfileUrl(this._activeArticle.CreatedBy.Id);
                    this.hplAuthor.Text = this._activeArticle.CreatedBy.FullName;
                    this.hplAuthor.Visible = this._module.ShowAuthor;

                    this.litCategory.Text = base.GetText("CATEGORY");
                    this.litCategory.Visible = this._module.ShowCategory;
                    if (this._activeArticle.Category != null)
                    {
                        this.hplCategory.NavigateUrl = UrlHelper.GetUrlFromSection(this.Module.Section) +
                            String.Format("/category/{0}", this._activeArticle.Category.Id);
                        this.hplCategory.Text = this._activeArticle.Category.Title;
                    }
                    else
                    {
                        this.hplCategory.Text = String.Empty;
                    }
                    this.hplCategory.Visible = this._module.ShowCategory;

                    if (this._module.AllowComments)
                    {
                        this.hplComments.NavigateUrl = UrlHelper.GetUrlFromSection(this._module.Section)
                            + String.Format("/{0}#comments", this._activeArticle.Id);
                        this.hplComments.Text = base.GetText("COMMENTS") + " " + this._activeArticle.Comments.Count.ToString();
                    }
                    else
                    {
                        this.hplComments.Visible = false;
                    }
                }
                else
                {
                    this.pnlArticleInfo.Visible = false;
                }

                this.hplBack.NavigateUrl = UrlHelper.GetUrlFromSection(this._module.Section);
                this.hplBack.Text = base.GetText("BACK");
                this.btnSaveComment.Text = base.GetText("BTNSAVECOMMENT");
                this.rfvName.ErrorMessage = base.GetText("NAMEREQUIRED");
                this.rfvComment.ErrorMessage = base.GetText("COMMENTREQUIRED");

                this.pnlArticleDetails.Visible = true;
                this.pnlComments.Visible = this._module.AllowComments && this._activeArticle.Comments.Count > 0;
                if (this._module.AllowAnonymousComments || (this.Page.User.Identity.IsAuthenticated && this._module.AllowComments))
                {
                    this.pnlComment.Visible = true;
                    this.pnlAnonymous.Visible = (!this.Page.User.Identity.IsAuthenticated);
                }
                else
                {
                    this.pnlComment.Visible = false;
                }
                // Comments
                this.rptComments.DataSource = this._activeArticle.Comments;
                this.rptComments.ItemDataBound += new RepeaterItemEventHandler(rptComments_ItemDataBound);
                this.rptComments.DataBind();
            }
        }