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;
            }));
        }
예제 #2
0
 public static bool HoneypotProtectionEnabled(this IDisplayHelper displayHelper)
 {
     return(displayHelper.HttpContext.GetItem(nameof(HoneypotProtectionEnabled), () =>
     {
         return displayHelper.Resolve <SecuritySettings>().EnableHoneypotProtection;
     }));
 }
예제 #3
0
 public static bool IsMobileDevice(this IDisplayHelper displayHelper)
 {
     return(displayHelper.HttpContext.GetItem(nameof(IsMobileDevice), () =>
     {
         var userAgent = displayHelper.Resolve <IUserAgent>();
         return userAgent.IsMobileDevice && !userAgent.IsTablet;
     }));
 }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
 /// <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));
 }
예제 #8
0
 /// <summary>
 /// Gets the manifest of the current active theme
 /// </summary>
 public static ThemeManifest GetThemeManifest(this IDisplayHelper displayHelper)
 {
     return(displayHelper.Resolve <IThemeContext>().CurrentTheme);
 }
예제 #9
0
 /// <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));
 }