Exemplo n.º 1
0
        /// <summary>
        /// Generates HTML link tags to include CSS for all stylesheets needed on the page (coming from the theme).
        /// Provides an alternative for MVC where resources are inserted as pure HTML link tags instead of a ResourceLinks control, which is the case in the
        /// WebForms and hybrid modes.
        /// </summary>
        /// <param name="theme">The name of the theme</param>
        /// <returns></returns>
        private string ResourceRegistrations(string theme)
        {
            var pageProxy = new PageProxy(theme);
            var resources = ThemeController.GetGlobalStyles(pageProxy);

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

            StringBuilder sb = new StringBuilder();

            this.AppendStylesheetResourceTag(pageProxy, ref sb, "Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Themes.LayoutsBasics.css");

            foreach (var link in resources.Links)
            {
                this.AppendStylesheetResourceTag(pageProxy, ref sb, link.AssemblyInfo, link.Name);
            }

            string appPath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;

            if (!appPath.EndsWith("/"))
            {
                appPath = string.Concat(appPath, "/");
            }

            sb.Append(String.Concat("\t<script type=\"text/javascript\">var sf_appPath='", appPath, "';</script>"));

            // add the scripts for personalization in the page
            sb.Append("\t<script src=\"");
            sb.Append(pageProxy.ClientScript.GetWebResourceUrl(typeof(PageStatisticsJSClient), "Telerik.Sitefinity.Clients.JS.StatsClient.min.js"));
            sb.Append("\" type=\"text/javascript\"></script>");

            return(sb.ToString());
        }