public ActionResult News(BackEndNewsList backEndNewsList) { News news = new News(); backEndNewsList.NewsList = news.GetNews(ConfigurationManager.AppSettings["AdminLanguageCode"], newsTitle: backEndNewsList.NewsTitle, isActive: backEndNewsList.IsActive, categoryId: backEndNewsList.CategoryId, newsDateFrom: backEndNewsList.NewsDateFrom, newsDateTo: backEndNewsList.NewsDateTo); if (backEndNewsList.NewsList.IsNull() || backEndNewsList.NewsList.Count == 0) { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.NoDataFound); } else { NewsConfiguration newsConfiguration = new NewsConfigurations().GetNewsConfiguration(); if (newsConfiguration.IsNewsActive && newsConfiguration.NewsPageId.IsNotNull()) { CmsPages cmsPages = new CmsPages(); CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(newsConfiguration.NewsPageId, ConfigurationManager.AppSettings["AdminLanguageCode"]); backEndNewsList.FrontEndUrl = cmsPageActionlink.Url; } } return(View(backEndNewsList)); }
private SyndicationFeed GetSyndicationFeed(string langCode) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(langCode); SyndicationFeed result = new SyndicationFeed(); NewsConfiguration newsConfiguration = new NewsConfigurations().GetNewsConfiguration(); if (newsConfiguration.IsNewsActive && newsConfiguration.NewsPageId.IsNotNull()) { CmsPages cmsPages = new CmsPages(); CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(newsConfiguration.NewsPageId, langCode); News news = new News(); List <SingleNews> newsList = news.GetNews( langCode, isActive: true, isCategoryActive: true ).OrderByDescending(i => i.NewsDate).Take(10).ToList(); if (newsList.IsNotNull()) { GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); result = new SyndicationFeed( Resources.Strings_News.NewsFeedTitle.Replace("{$SiteName}", globalConfiguration.SiteName), Resources.Strings_News.NewsFeedDescription.Replace("{$SiteName}", globalConfiguration.SiteName), Request.Url, Guid.NewGuid().ToString(), DateTime.Now); List <SyndicationItem> items = new List <SyndicationItem>(); SyndicationItem item; foreach (SingleNews singleNews in newsList) { item = new SyndicationItem( singleNews.NewsTitle, singleNews.NewsContent.StripHtml().TrimToMaxLength(255, "..."), new Uri(Request.Url.Scheme + "://" + Request.Url.Authority + cmsPageActionlink.Url + singleNews.NewsId + "-" + singleNews.NewsTitle.ToFriendlyUrlDashedString() + "/"), singleNews.NewsId.ToString(), singleNews.NewsDate); items.Add(item); } result.Items = items; } } return(result); }
public static IHtmlString GetSubscriptionPanel(this HtmlHelper htmlHelper, FrontEndCmsPage model) { StringBuilder result = new StringBuilder(); SubscriptionConfiguration subscriptionConfiguration = new SubscriptionConfigurations().GetSubscriptionConfiguration(); if (subscriptionConfiguration.IsSubscriptionActive) { CmsPages cmsPages = new CmsPages(); result.AppendLine("<ul class=\"nav navbar-nav navbar-right navbar-underline-hover\">"); if (FrontEndSessions.CurrentSubscription.IsNull()) { if (subscriptionConfiguration.RegisterPageId.IsNotNull()) { CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.RegisterPageId, model.LanguageCode); result.AppendLine(" <li><a href=\"" + cmsPageActionlink.Url + "\"><i class=\"fa fa-check-square-o\"></i> " + cmsPageActionlink.Title + "</a></li>"); } if (subscriptionConfiguration.SignInPageId.IsNotNull()) { CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.SignInPageId, model.LanguageCode); result.AppendLine(" <li><a href=\"" + cmsPageActionlink.Url + "\"><i class=\"fa fa-sign-in\"></i> " + cmsPageActionlink.Title + "</a></li>"); } } else { result.AppendLine(" <li class=\"dropdown\">"); result.AppendLine(" <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">" + FrontEndSessions.CurrentSubscription.FirstName + " <i class=\"fa fa-user\"></i> <b class=\"caret\"></b></a>"); result.AppendLine(" <ul class=\"dropdown-menu\">"); if (subscriptionConfiguration.ProfilePageId.IsNotNull()) { CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.ProfilePageId, model.LanguageCode); result.AppendLine(" <li><a href=\"" + cmsPageActionlink.Url + "\"><i class=\"fa fa-cog\"></i> " + cmsPageActionlink.Title + "</a></li>"); } if (subscriptionConfiguration.ChangePasswordPageId.IsNotNull()) { CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.ChangePasswordPageId, model.LanguageCode); result.AppendLine(" <li><a href=\"" + cmsPageActionlink.Url + "\"><i class=\"fa fa-lock\"></i> " + cmsPageActionlink.Title + "</a></li>"); } if (subscriptionConfiguration.SignInPageId.IsNotNull()) { CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.SignInPageId, model.LanguageCode); result.AppendLine(" <li class=\"divider\"></li>"); result.AppendLine(" <li><a href=\"" + cmsPageActionlink.Url + "?a=sign-out\"><i class=\"fa fa-sign-out\"></i> " + Event304.Resources.Strings.SignOut + "</a></li>"); } result.AppendLine(" </ul>"); result.AppendLine(" </li>"); } result.AppendLine("</ul>"); } return(htmlHelper.Raw(result.ToString())); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { FrontEndCmsPage page = filterContext.ActionParameters["page"] as FrontEndCmsPage; if (page.IsNotNull()) { CmsPages cmsPages = new CmsPages(); if (FrontEndSessions.CurrentSubscription.IsNull()) { SubscriptionConfiguration subscriptionConfiguration = new SubscriptionConfigurations().GetSubscriptionConfiguration(); CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.SignInPageId, page.LanguageCode); if (cmsPageActionlink.IsNotNull()) { filterContext.Result = new ChildActionRedirectResult(cmsPageActionlink.Url + "?ReturnUrl=" + HttpUtility.UrlEncode(filterContext.RequestContext.HttpContext.Request.Url.AbsoluteUri)); } } } }
public ActionResult Index(string languageCode, string segments) { GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); if (!globalConfiguration.IsOffline || Request["OfflineCode"] == globalConfiguration.OfflineCode || Session["OfflineCode"].ConvertTo <string>(null, true) == globalConfiguration.OfflineCode) { if (Session["OfflineCode"].IsNull()) { Session["OfflineCode"] = Request["OfflineCode"]; } FrontEndCmsPage page = new FrontEndCmsPage() { PageId = null, LanguageCode = globalConfiguration.DefaultLanguageCode, LanguageFolder = "", Parameter = string.Empty, MetaTagTitle = globalConfiguration.MetaTitle, MetaTagKeywords = globalConfiguration.MetaKeywords, MetaTagDescription = globalConfiguration.MetaDescription, Robots = globalConfiguration.Robots, PageTemplateId = null, StatusCode = null }; CmsPages cmsPages = new CmsPages(); CmsPage cmsPage = cmsPages.GetHomePage(); bool isHomePageDefined = cmsPage.IsNotNull(); if (segments.IsNotEmptyOrWhiteSpace()) { segments = segments.TrimEnd('/'); cmsPage = cmsPages.GetPageBySegments(segments); if (cmsPage.IsNull() && segments.Contains('/')) { cmsPage = cmsPages.GetPageBySegments(segments.Remove(segments.LastIndexOf('/'))); page.Parameter = segments.Substring(segments.LastIndexOf('/') + 1); //the parameter can be a dash separated list of parameters. E.g. 2-today_the_weather_is_nice } } Language language = new Languages().GetLanguageByCode(languageCode); if ( cmsPage.IsNotNull() && //The page exists (cmsPage.IsActive || (Request["preview"] == "true" && BackEndSessions.CurrentUser.IsNotNull())) && //The page is active or the page is in preview mode with a user logged in the admin area language.IsNotNull() && //The language exists language.IsActive //The language is active ) { if (cmsPage.IsAccessRestricted && FrontEndSessions.CurrentSubscription.IsNull()) { SubscriptionConfiguration subscriptionConfiguration = new SubscriptionConfigurations().GetSubscriptionConfiguration(); CmsPageActionlink cmsPageActionlink = cmsPages.GetCmsPageActionlink(subscriptionConfiguration.SignInPageId, language.LanguageCode); if (cmsPageActionlink.IsNotNull()) { return(Redirect(cmsPageActionlink.Url + "?ReturnUrl=" + HttpUtility.UrlEncode(Request.Url.AbsoluteUri))); } } page.PageId = cmsPage.PageId; page.LanguageCode = language.LanguageCode; page.LanguageFolder = language.LanguageCode == globalConfiguration.DefaultLanguageCode ? "" : language.LanguageCode; page.PageTemplateId = cmsPage.PageTemplateId; PageLanguage pageLanguage = new PagesLanguages().GetPageLanguage(cmsPage.PageId, language.LanguageCode); if (pageLanguage.IsNotNull()) { if (pageLanguage.MetaTagTitle.IsNotEmptyOrWhiteSpace()) { page.MetaTagTitle = pageLanguage.MetaTagTitle.ReplaceGlobalTokens(); } if (pageLanguage.MetaTagKeywords.IsNotEmptyOrWhiteSpace()) { page.MetaTagKeywords = pageLanguage.MetaTagKeywords.ReplaceGlobalTokens(); } if (pageLanguage.MetaTagDescription.IsNotEmptyOrWhiteSpace()) { page.MetaTagDescription = pageLanguage.MetaTagDescription.ReplaceGlobalTokens(); } if (pageLanguage.Robots.IsNotEmptyOrWhiteSpace()) { page.Robots = pageLanguage.Robots; } } } else { if (language.IsNotNull()) { page.LanguageCode = language.LanguageCode; page.LanguageFolder = language.LanguageCode == globalConfiguration.DefaultLanguageCode ? "" : language.LanguageCode; } page.PageTemplateId = globalConfiguration.DefaultErrorPageTemplateId; if (isHomePageDefined) { page.StatusCode = 404; } else { page.StatusCode = 501; //Home page not defined in the database table tb_cms_pages } } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture((language.IsNotNull() && language.IsActive) ? language.LanguageCode : page.LanguageCode); return(View(page)); } else { return(Redirect("~/_app_offline.htm")); } }