예제 #1
0
        public SiteResourceViewModel Build(Item renderingContextItem, ID resourceLocationId, ID deviceId, string siteScriptFieldName, string pageScriptFieldName)
        {
            var model = new SiteResourceViewModel();

            if (!string.IsNullOrWhiteSpace(siteScriptFieldName))
            {
                var home = SiteContext.GetHomeItem();
                if (home != null)
                {
                    model.SiteResources = new HtmlString(home[siteScriptFieldName] ?? "");
                }
            }

            if (renderingContextItem != null)
            {
                if (!string.IsNullOrWhiteSpace(pageScriptFieldName))
                {
                    model.PageResources = new HtmlString(renderingContextItem[pageScriptFieldName] ?? "");
                }

                var theme = _themeRetriever.GetThemeFromContextItem(renderingContextItem);
                model.ThemeResources = new HtmlString(theme == null
                                                          ? ""
                                                          : _themeRetriever.GetThemeResources(theme, deviceId,
                                                                                              resourceLocationId)
                                                      );
            }

            return(model);
        }
예제 #2
0
        public string Resolve(RenderRenderingArgs args)
        {
            var theme    = _themeRetriever.GetThemeFromContextItem(args.PageContext.Item);
            var areaName = theme?[Templates.Theme.FieldNames.MvcAreaName];

            return(string.IsNullOrWhiteSpace(areaName)
                ? null
                : areaName);
        }
        protected virtual string ReplaceThemeToken(string query, Item contextItem)
        {
            var token = "{Theme}";

            if (!query.Contains(token))
            {
                return(query);
            }

            var themeItem = _themeRetriever.GetThemeFromContextItem(contextItem);

            if (themeItem == null)
            {
                return(query);
            }

            return(query.Replace(token, themeItem.Paths.FullPath));
        }
예제 #4
0
        public virtual string FindAreaByFolder(RenderRenderingArgs args)
        {
            var theme = _themeRetriever.GetThemeFromContextItem(args.PageContext.Item);

            if (theme == null)
            {
                return(null);
            }

            var areaName = theme[ThemeFieldNames.MvcAreaName];

            if (string.IsNullOrWhiteSpace(areaName))
            {
                return(null);
            }

            return(areaName);
        }
예제 #5
0
        public void Process(GetSiteResourcesArgs args)
        {
            if (args.ContextItem == null)
            {
                return;
            }

            var theme = _themeRetriever.GetThemeFromContextItem(args.ContextItem);

            if (theme == null)
            {
                return;
            }

            var themeScripts = _themeRetriever.GetThemeResources(theme, args.DeviceId, args.ResourceLocationId);

            if (string.IsNullOrWhiteSpace(themeScripts))
            {
                return;
            }

            args.Results.Add(new SiteResource("ThemeResources", themeScripts));
        }