public static bool IsStoreClosed(this IDisplayHelper displayHelper) { return(displayHelper.HttpContext.GetItem(nameof(IsStoreClosed), () => { var settings = displayHelper.Resolve <StoreInformationSettings>(); var customer = displayHelper.Resolve <IWorkContext>().CurrentCustomer; return settings.StoreClosedAllowForAdmins && customer.IsAdmin() ? false : settings.StoreClosed; })); }
public static bool HoneypotProtectionEnabled(this IDisplayHelper displayHelper) { return(displayHelper.HttpContext.GetItem(nameof(HoneypotProtectionEnabled), () => { return displayHelper.Resolve <SecuritySettings>().EnableHoneypotProtection; })); }
public static bool IsMobileDevice(this IDisplayHelper displayHelper) { return(displayHelper.HttpContext.GetItem(nameof(IsMobileDevice), () => { var userAgent = displayHelper.Resolve <IUserAgent>(); return userAgent.IsMobileDevice && !userAgent.IsTablet; })); }
public static string GenerateHelpUrl(this IDisplayHelper displayHelper, string path) { var seoCode = displayHelper.Resolve <IWorkContext>()?.WorkingLanguage?.UniqueSeoCode; if (seoCode.IsEmpty()) { return(path); } return(SmartstoreVersion.GenerateHelpUrl(seoCode, path)); }
private static IEnumerable <string> ResolveNotifications(IDisplayHelper displayHelper, NotifyType?type) { var allNotifications = displayHelper.HttpContext.GetItem("AllNotifications", () => { var result = Enumerable.Empty <NotifyEntry>(); string key = NotifyFilterAttribute.NotificationsAccessKey; NotifyEntriesHolder holder; var tempData = displayHelper.Resolve <ITempDataDictionaryFactory>().GetTempData(displayHelper.HttpContext); if (tempData.ContainsKey(key)) { holder = tempData[key] as NotifyEntriesHolder; if (holder != null) { result = result.Concat(holder.Entries); } } var viewData = displayHelper.Resolve <IViewDataAccessor>().ViewData; if (viewData != null && viewData.ContainsKey(key)) { holder = viewData[key] as NotifyEntriesHolder; if (holder != null) { result = result.Concat(holder.Entries); } } return(new HashSet <NotifyEntry>(result)); }); if (type == null) { return(allNotifications.Select(x => x.Message)); } return(allNotifications.Where(x => x.Type == type.Value).Select(x => x.Message)); }
/// <summary> /// Modifies a URL (appends/updates a query string part and optionally removes another query string). /// </summary> /// <param name="url">The URL to modifiy. If <c>null</c>, the current page's URL is resolved.</param> /// <param name="query">The new query string part.</param> /// <param name="removeQueryName">A query string name to remove.</param> /// <returns>The modified URL.</returns> public static string ModifyUrl(this IDisplayHelper displayHelper, string url, string query, string removeQueryName = null) { var webHelper = displayHelper.Resolve <IWebHelper>(); if (webHelper == null) { return(url); } url = url.NullEmpty() ?? webHelper.GetCurrentPageUrl(true); var url2 = webHelper.ModifyQueryString(url, query, null); if (removeQueryName.HasValue()) { url2 = webHelper.RemoveQueryParam(url2, removeQueryName); } return(url2); }
/// <summary> /// Modifies query string /// </summary> /// <param name="url">Url to modify</param> /// <param name="queryStringModification">Query string modification</param> /// <param name="anchor">Anchor</param> /// <returns>New url</returns> public static string ModifyQueryString(this IDisplayHelper displayHelper, string url, string query, string removeQueryName = null) { return(displayHelper.Resolve <IWebHelper>().ModifyQueryString(url, query, removeQueryName)); }
/// <summary> /// Gets the manifest of the current active theme /// </summary> public static ThemeManifest GetThemeManifest(this IDisplayHelper displayHelper) { return(displayHelper.Resolve <IThemeContext>().CurrentTheme); }
/// <summary> /// Checks whether a given zone has content (contains at least one widget), /// </summary> /// <param name="zone">The zone name to check.</param> public static bool ZoneHasContent(this IDisplayHelper displayHelper, string zone) { return(displayHelper.Resolve <IWidgetProvider>().HasContent(zone)); }