public ActionResult ConfigureTheme(string theme, int StoreId, string selectedTab)
        {
            if (theme.HasValue())
            {
                this.ControllerContext.RouteData.DataTokens["ThemeOverride"] = theme;
            }

            var model = TempData["OverriddenThemeVars"] ?? _themeVarService.GetThemeVariables(theme, StoreId);

            ViewData["SelectedTab"] = selectedTab;
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Configure(string theme, int storeId, IDictionary <string, object> values, bool continueEditing)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageThemes))
            {
                return(AccessDeniedView());
            }

            if (!_themeRegistry.ThemeManifestExists(theme))
            {
                return(RedirectToAction("List", new { storeId = storeId }));
            }

            // get current for later restore on parse error
            var currentVars = _themeVarService.GetThemeVariables(theme, storeId);

            // save now
            values = FixThemeVarValues(values);
            _themeVarService.SaveThemeVariables(theme, storeId, values);

            // check for parsing error
            var    manifest = _themeRegistry.GetThemeManifest(theme);
            string error    = ValidateLess(manifest, storeId);

            if (error.HasValue())
            {
                // restore previous vars
                try
                {
                    _themeVarService.DeleteThemeVariables(theme, storeId);
                }
                finally
                {
                    // we do it here to absolutely ensure that this gets called
                    _themeVarService.SaveThemeVariables(theme, storeId, currentVars);
                }

                TempData["LessParsingError"]    = error.Trim().TrimStart('\r', '\n', '/', '*').TrimEnd('*', '/', '\r', '\n');
                TempData["OverriddenThemeVars"] = values;
                NotifyError(T("Admin.Configuration.Themes.Notifications.ConfigureError"));
                return(RedirectToAction("Configure", new { theme = theme, storeId = storeId }));
            }

            // activity log
            _services.CustomerActivity.InsertActivity("EditThemeVars", T("ActivityLog.EditThemeVars"), theme);

            NotifySuccess(T("Admin.Configuration.Themes.Notifications.ConfigureSuccess"));

            return(continueEditing ?
                   RedirectToAction("Configure", new { theme = theme, storeId = storeId }) :
                   RedirectToAction("List", new { storeId = storeId }));
        }
Beispiel #3
0
        public ActionResult ConfigureTheme(string theme, int storeId)
        {
            if (theme.HasValue())
            {
                _themeContext.SetRequestTheme(theme);
            }

            if (storeId > 0)
            {
                _storeContext.SetRequestStore(storeId);
            }

            var model = TempData["OverriddenThemeVars"] ?? _themeVarService.GetThemeVariables(theme, storeId);

            return(View(model));
        }