コード例 #1
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            string clientID,
            int moduleID,
            int pageID,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(String.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleName, config, false, displaySettings, moduleID, pageID, out sbStyleName);
                string scriptName = sbStyleName.ToString();
                if (!String.IsNullOrWhiteSpace(style.Url))
                {
                    sbStyleText.Append(string.Format(styleLinkFormat,
                                                     style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/"),
                                                     scriptName, style.Media));
                }
                else if (!String.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, scriptName, style.Media));
                }

                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleText, config, false, displaySettings, moduleID, pageID, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
コード例 #2
0
        public static string GetModuleLinks(ModuleConfiguration config, SuperFlexiDisplaySettings displaySettings, int moduleId, int pageId)
        {
            StringBuilder litExtraMarkup = new StringBuilder();
            string        settings       = string.Empty;
            string        add            = string.Empty;
            string        header         = string.Empty;
            string        footer         = string.Empty;

            try
            {
                settings = String.Format(
                    displaySettings.ModuleSettingsLinkFormat,
                    WebUtils.GetSiteRoot() + "/Admin/ModuleSettings.aspx?pageid=" + pageId.ToString() + "&amp;mid=" + moduleId.ToString(),
                    SuperFlexiResources.SettingsLinkLabel);

                if (!String.IsNullOrWhiteSpace(config.MarkupDefinitionName) && config.MarkupDefinitionName != "Please Select")
                {
                    if (!config.IsGlobalView)
                    {
                        add = String.Format(
                            displaySettings.AddItemLinkFormat,
                            WebUtils.GetSiteRoot() + "/SuperFlexi/Edit.aspx?pageid=" + pageId.ToString() + "&amp;mid=" + moduleId.ToString(),
                            SuperFlexiResources.AddItem);
                    }

                    if (config.UseHeader)
                    {
                        header = String.Format(
                            displaySettings.EditHeaderLinkFormat,
                            WebUtils.GetSiteRoot() + "/SuperFlexi/EditHeader.aspx?pageid=" + pageId.ToString() + "&amp;mid=" + moduleId.ToString(),
                            SuperFlexiResources.EditHeader);
                    }

                    if (config.UseFooter)
                    {
                        footer = String.Format(
                            displaySettings.EditFooterLinkFormat,
                            WebUtils.GetSiteRoot() + "/SuperFlexi/EditHeader.aspx?f=true&pageid=" + pageId.ToString() + "&amp;mid=" + moduleId.ToString(),
                            SuperFlexiResources.EditFooter);
                    }
                }

                litExtraMarkup.AppendFormat(displaySettings.ModuleLinksFormat, settings, add, header, footer);
            }
            catch (System.FormatException ex)
            {
                Module module      = new Module(moduleId);
                string moduleTitle = "unknown";
                if (module != null)
                {
                    moduleTitle = module.ModuleTitle;
                }
                log.ErrorFormat("Error rendering \"{0}\", with moduleID={1}, pageid={2}. Error was:\r\n{3}", moduleTitle, moduleId.ToString(), pageId.ToString(), ex);
            }
            return(litExtraMarkup.ToString());
        }
コード例 #3
0
        public static void ReplaceStaticTokens(
            StringBuilder stringBuilder,
            ModuleConfiguration config,
            bool isEditable,
            SuperFlexiDisplaySettings displaySettings,
            int moduleId,
            int pageId,
            out StringBuilder sb)
        {
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null)
            {
                siteSettings = new SiteSettings(SiteSettings.GetRootSiteGuid());
            }

            PageSettings pageSettings = new PageSettings(siteSettings.SiteId, pageId);

            ReplaceStaticTokens(stringBuilder, config, isEditable, displaySettings, moduleId, pageSettings, siteSettings, out sb);
        }
コード例 #4
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            string clientID,
            int moduleID,
            int pageID,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(String.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleName, config, false, displaySettings, moduleID, pageID, out sbStyleName);
                string styleName = sbStyleName.ToString();
                if (!String.IsNullOrWhiteSpace(style.Url))
                {
                    string styleUrl = string.Empty;

                    if (style.Url.StartsWith("/") ||
                        style.Url.StartsWith("http://") ||
                        style.Url.StartsWith("https://"))
                    {
                        styleUrl = style.Url;
                    }
                    else if (style.Url.StartsWith("~/"))
                    {
                        styleUrl = WebUtils.ResolveServerUrl(style.Url);
                    }
                    else if (style.Url.StartsWith("$_SitePath_$"))
                    {
                        styleUrl = style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/");
                    }
                    else
                    {
                        styleUrl = new Uri(config.SolutionLocationUrl, style.Url).ToString();
                    }
                    //else if (File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile)))
                    //{
                    //	FileInfo fileInfo = new FileInfo(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile));
                    //	styleUrl = WebUtils.ResolveServerUrl(Path.Combine(fileInfo.DirectoryName.Replace(System.Web.Hosting.HostingEnvironment.MapPath("~"), "~/"), style.Url));
                    //}

                    sbStyleText.Append(string.Format(styleLinkFormat, styleUrl, styleName, style.Media));
                }
                else if (!String.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, styleName, style.Media));
                }

                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleText, config, false, displaySettings, moduleID, pageID, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
コード例 #5
0
        public static void SetupScripts(
            List <MarkupScript> markupScripts,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            bool isEditable,
            bool isPostBack,
            string clientID,
            int moduleID,
            int pageID,
            Page page,
            Control control)
        {
            string scriptRefFormat = "\n<script type=\"text/javascript\" src=\"{0}\" data-name=\"{1}\"></script>";
            string rawScriptFormat = "\n<script type=\"text/javascript\" data-name=\"{1}\">\n{0}\n</script>";

            foreach (MarkupScript script in markupScripts)
            {
                StringBuilder sbScriptText = new StringBuilder();
                StringBuilder sbScriptName = new StringBuilder();

                sbScriptName.Append(String.IsNullOrWhiteSpace(script.ScriptName) ? clientID + "flexiScript_" + markupScripts.IndexOf(script) : "flexiScript_" + script.ScriptName);
                SuperFlexiHelpers.ReplaceStaticTokens(sbScriptName, config, isEditable, displaySettings, moduleID, pageID, out sbScriptName);
                string scriptName = sbScriptName.ToString();
                if (!String.IsNullOrWhiteSpace(script.Url))
                {
                    //string scriptUrl = string.Empty;
                    //if (script.Url.StartsWith("/") ||
                    //	script.Url.StartsWith("http://") ||
                    //	script.Url.StartsWith("https://"))
                    //{
                    //	scriptUrl = script.Url;
                    //}
                    //else if (script.Url.StartsWith("~/"))
                    //{
                    //	scriptUrl = WebUtils.ResolveServerUrl(script.Url);
                    //}
                    //else if (script.Url.StartsWith("$_SitePath_$"))
                    //{
                    //	scriptUrl = script.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/");
                    //}
                    //else
                    //{
                    //	scriptUrl = new Uri(config.SolutionLocationUrl, script.Url).ToString();
                    //}
                    //else if (File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile)))
                    //{
                    //	FileInfo fileInfo = new FileInfo(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile));
                    //	scriptUrl = WebUtils.ResolveServerUrl(Path.Combine(fileInfo.DirectoryName.Replace(System.Web.Hosting.HostingEnvironment.MapPath("~"), "~/"), script.Url));
                    //}
                    string scriptUrl = GetPathToFile(config, script.Url);
                    sbScriptText.Append(string.Format(scriptRefFormat, scriptUrl, scriptName));
                }
                else if (!String.IsNullOrWhiteSpace(script.RawScript))
                {
                    sbScriptText.Append(string.Format(rawScriptFormat, script.RawScript, scriptName));
                }

                SuperFlexiHelpers.ReplaceStaticTokens(sbScriptText, config, isEditable, displaySettings, moduleID, pageID, out sbScriptText);

                // script position options
                // inHead
                // inBody (register script) (default)
                // aboveMarkupDefinition
                // belowMarkupDefinition
                // bottomStartup (register startup script)
                switch (script.Position)
                {
                case "inHead":
                    if (!isPostBack && !page.IsCallback)
                    {
                        if (page.Header.FindControl(scriptName) == null)
                        {
                            LiteralControl headLit = new LiteralControl();
                            headLit.ID              = scriptName;
                            headLit.Text            = sbScriptText.ToString();
                            headLit.ClientIDMode    = System.Web.UI.ClientIDMode.Static;
                            headLit.EnableViewState = false;
                            page.Header.Controls.Add(headLit);
                        }
                    }
                    break;

                case "aboveMarkupDefinition":
                    if (control == null)
                    {
                        goto case "bottomStartup";
                    }
                    if (control.FindControlRecursive(scriptName) == null)
                    {
                        Control aboveMarkupDefinitionScripts = control.FindControlRecursive("aboveMarkupDefinitionScripts");
                        if (aboveMarkupDefinitionScripts != null)
                        {
                            LiteralControl aboveLit = new LiteralControl();
                            aboveLit.ID   = scriptName;
                            aboveLit.Text = sbScriptText.ToString();
                            aboveMarkupDefinitionScripts.Controls.Add(aboveLit);
                        }
                        else
                        {
                            goto case "bottomStartup";
                        }
                    }
                    break;

                case "belowMarkupDefinition":
                    if (control == null)
                    {
                        goto case "bottomStartup";
                    }
                    if (control.FindControlRecursive(scriptName) == null)
                    {
                        Control belowMarkupDefinitionScripts = control.FindControlRecursive("belowMarkupDefinitionScripts");
                        if (belowMarkupDefinitionScripts != null)
                        {
                            LiteralControl belowLit = new LiteralControl();
                            belowLit.ID   = scriptName;
                            belowLit.Text = sbScriptText.ToString();
                            belowMarkupDefinitionScripts.Controls.Add(belowLit);
                        }
                        else
                        {
                            goto case "bottomStartup";
                        }
                    }
                    //strBelowMarkupScripts.AppendLine(scriptText);
                    break;

                case "bottomStartup":
                    if (!page.ClientScript.IsStartupScriptRegistered(scriptName))
                    {
                        ScriptManager.RegisterStartupScript(
                            page,
                            typeof(Page),
                            scriptName,
                            sbScriptText.ToString(),
                            false);
                    }
                    break;

                case "inBody":
                default:
                    if (!page.ClientScript.IsClientScriptBlockRegistered(scriptName))
                    {
                        ScriptManager.RegisterClientScriptBlock(
                            page,
                            typeof(Page),
                            scriptName,
                            sbScriptText.ToString(),
                            false);
                    }
                    break;
                }
            }
        }
コード例 #6
0
        public static void ReplaceStaticTokens(
            StringBuilder stringBuilder,
            ModuleConfiguration config,
            bool isEditable,
            SuperFlexiDisplaySettings displaySettings,
            int moduleId,
            PageSettings pageSettings,
            SiteSettings siteSettings,
            out StringBuilder sb)
        {
            sb = stringBuilder;
            string featuredImageUrl       = String.IsNullOrWhiteSpace(config.InstanceFeaturedImage) ? string.Empty : WebUtils.GetApplicationRoot() + config.InstanceFeaturedImage;
            string jsonObjName            = "sflexi" + moduleId.ToString() + (config.IsGlobalView ? "Modules" : "Items");
            string currentSkin            = string.Empty;
            string siteRoot               = SiteUtils.GetNavigationSiteRoot();
            bool   publishedOnCurrentPage = true;

            if (HttpContext.Current != null && HttpContext.Current.Request.Params.Get("skin") != null)
            {
                currentSkin = SiteUtils.SanitizeSkinParam(HttpContext.Current.Request.Params.Get("skin")) + "/";
            }

            if (isEditable)
            {
                var pageModules = PageModule.GetPageModulesByModule(moduleId);
                if (pageModules.Where(pm => pm.PageId == pageSettings.PageId).ToList().Count() == 0)
                {
                    publishedOnCurrentPage = false;
                }
            }

            Module module = new Module(moduleId);

            if (module != null)
            {
                sb.Replace("$_ModuleTitle_$", module.ShowTitle ? String.Format(displaySettings.ModuleTitleFormat, module.ModuleTitle) : string.Empty);
                sb.Replace("$_RawModuleTitle_$", module.ModuleTitle);
                sb.Replace("$_ModuleGuid_$", module.ModuleGuid.ToString());
                if (String.IsNullOrWhiteSpace(config.ModuleFriendlyName))
                {
                    sb.Replace("$_FriendlyName_$", module.ModuleTitle);
                }

                siteSettings = new SiteSettings(module.SiteGuid);
            }
            if (!String.IsNullOrWhiteSpace(config.ModuleFriendlyName))
            {
                sb.Replace("$_FriendlyName_$", config.ModuleFriendlyName);
            }
            sb.Replace("$_FeaturedImageUrl_$", featuredImageUrl);
            sb.Replace("$_ModuleID_$", moduleId.ToString());
            sb.Replace("$_PageID_$", pageSettings.PageId.ToString());
            sb.Replace("$_PageUrl_$", siteRoot + pageSettings.Url.Replace("~/", ""));
            sb.Replace("$_PageName_$", siteRoot + pageSettings.PageName);
            //sb.Replace("$_ModuleLinks_$", isEditable ? SuperFlexiHelpers.GetModuleLinks(config, displaySettings, moduleId, pageSettings.PageId) : string.Empty);
            sb.Replace("$_ModuleLinks_$", isEditable ? SuperFlexiHelpers.GetModuleLinks(config, displaySettings, moduleId, publishedOnCurrentPage ? pageSettings.PageId : -1) : string.Empty);
            sb.Replace("$_JSONNAME_$", jsonObjName);
            sb.Replace("$_ModuleClass_$", SiteUtils.IsMobileDevice() && !String.IsNullOrWhiteSpace(config.MobileInstanceCssClass) ? config.MobileInstanceCssClass : config.InstanceCssClass);
            sb.Replace("$_ModuleTitleElement_$", module.HeadElement);
            sb.Replace("$_SiteID_$", siteSettings.SiteId.ToString());
            sb.Replace("$_SiteRoot_$", String.IsNullOrWhiteSpace(siteRoot) ? "/" : siteRoot);
            sb.Replace("$_SitePath_$", String.IsNullOrWhiteSpace(siteRoot) ? "/" : WebUtils.GetApplicationRoot() + "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToInvariantString());
            sb.Replace("$_SkinPath_$", SiteUtils.DetermineSkinBaseUrl(currentSkin));
            sb.Replace("$_CustomSettings_$", config.CustomizableSettings); //this needs to be enhanced, a lot, right now we just dump the 'settings' where ever this token exists.
            sb.Replace("$_EditorType_$", siteSettings.EditorProviderName);
            sb.Replace("$_EditorSkin_$", siteSettings.EditorSkin.ToString());
            sb.Replace("$_EditorBasePath_$", WebUtils.ResolveUrl(ConfigurationManager.AppSettings["CKEditor:BasePath"]));
            sb.Replace("$_EditorConfigPath_$", WebUtils.ResolveUrl(ConfigurationManager.AppSettings["CKEditor:ConfigPath"]));
            sb.Replace("$_EditorToolbarSet_$", mojoPortal.Web.Editor.ToolBar.FullWithTemplates.ToString());
            sb.Replace("$_EditorTemplatesUrl_$", siteRoot + "/Services/CKeditorTemplates.ashx?cb=" + Guid.NewGuid().ToString());
            sb.Replace("$_EditorStylesUrl_$", siteRoot + "/Services/CKeditorStyles.ashx?cb=" + Guid.NewGuid().ToString().Replace("-", string.Empty));
            sb.Replace("$_DropFileUploadUrl_$", siteRoot + "/Services/FileService.ashx?cmd=uploadfromeditor&rz=true&ko=" + WebConfigSettings.KeepFullSizeImagesDroppedInEditor.ToString().ToLower()
                       + "&t=" + Global.FileSystemToken.ToString());
            sb.Replace("$_FileBrowserUrl_$", siteRoot + WebConfigSettings.FileDialogRelativeUrl);
            sb.Replace("$_HeaderContent_$", config.HeaderContent);
            sb.Replace("$_FooterContent_$", config.FooterContent);
            sb.Replace("$_SkinVersionGuid_$", siteSettings.SkinVersion.ToString());
        }
コード例 #7
0
        private IndexItem GetIndexItem(PageSettings pageSettings, int moduleID, Item item)
        {
            Module module = new Module(moduleID);

            log.Debug($"moduleid: {moduleID} for module {module.ModuleTitle}");

            ModuleConfiguration config = new ModuleConfiguration(module);

            if (!config.IncludeInSearch)
            {
                return(null);
            }
            SuperFlexiDisplaySettings displaySettings = new SuperFlexiDisplaySettings();
            ModuleDefinition          flexiFeature    = new ModuleDefinition(config.FeatureGuid);
            IndexItem indexItem = new IndexItem();

            indexItem.SiteId              = pageSettings.SiteId;
            indexItem.PageId              = pageSettings.PageId;
            indexItem.PageName            = pageSettings.PageName;
            indexItem.ViewRoles           = pageSettings.AuthorizedRoles;
            indexItem.FeatureId           = flexiFeature.FeatureGuid.ToString();
            indexItem.FeatureName         = String.IsNullOrWhiteSpace(config.ModuleFriendlyName) ? module.ModuleTitle : config.ModuleFriendlyName;
            indexItem.FeatureResourceFile = flexiFeature.ResourceFile;
            indexItem.ItemId              = item.ItemID;
            indexItem.CreatedUtc          = item.CreatedUtc;
            indexItem.LastModUtc          = item.LastModUtc;
            if (pageSettings.UseUrl)
            {
                if (pageSettings.UrlHasBeenAdjustedForFolderSites)
                {
                    indexItem.ViewPage = pageSettings.UnmodifiedUrl.Replace("~/", string.Empty);
                }
                else
                {
                    indexItem.ViewPage = pageSettings.Url.Replace("~/", string.Empty);
                }
                indexItem.UseQueryStringParams = false;
            }

            SearchDef searchDef = SearchDef.GetByFieldDefinition(item.DefinitionGuid);

            bool hasSearchDef = true;

            if (searchDef == null)
            {
                searchDef    = new SearchDef();
                hasSearchDef = false;
            }
            System.Text.StringBuilder sbTitle             = new System.Text.StringBuilder(searchDef.Title);
            System.Text.StringBuilder sbKeywords          = new System.Text.StringBuilder(searchDef.Keywords);
            System.Text.StringBuilder sbDescription       = new System.Text.StringBuilder(searchDef.Description);
            System.Text.StringBuilder sbLink              = new System.Text.StringBuilder(searchDef.Link);
            System.Text.StringBuilder sbLinkQueryAddendum = new System.Text.StringBuilder(searchDef.LinkQueryAddendum);
            SiteSettings siteSettings = new SiteSettings(pageSettings.SiteGuid);

            SuperFlexiHelpers.ReplaceStaticTokens(sbTitle, config, false, displaySettings, module, pageSettings, siteSettings, out sbTitle);
            SuperFlexiHelpers.ReplaceStaticTokens(sbKeywords, config, false, displaySettings, module, pageSettings, siteSettings, out sbKeywords);
            SuperFlexiHelpers.ReplaceStaticTokens(sbDescription, config, false, displaySettings, module, pageSettings, siteSettings, out sbDescription);
            SuperFlexiHelpers.ReplaceStaticTokens(sbLink, config, false, displaySettings, module, pageSettings, siteSettings, out sbLink);
            SuperFlexiHelpers.ReplaceStaticTokens(sbLinkQueryAddendum, config, false, displaySettings, module, pageSettings, siteSettings, out sbLinkQueryAddendum);

            var fieldValues = ItemFieldValue.GetItemValues(item.ItemGuid);

            log.Debug($"SuperFlexi Index: total field value count for ItemGuid ({item.ItemGuid}) is {fieldValues.Count}");
            foreach (ItemFieldValue fieldValue in fieldValues)
            {
                Field field = new Field(fieldValue.FieldGuid);
                if (field == null || !field.Searchable)
                {
                    continue;
                }

                if (hasSearchDef)
                {
                    sbTitle.Replace(field.Token, fieldValue.FieldValue);
                    sbKeywords.Replace(field.Token, fieldValue.FieldValue);
                    sbDescription.Replace(field.Token, fieldValue.FieldValue);
                    sbLink.Replace(field.Token, fieldValue.FieldValue);
                    sbLinkQueryAddendum.Replace(field.Token, fieldValue.FieldValue);
                }
                else
                {
                    sbKeywords.Append(fieldValue.FieldValue);
                }

                if (debugLog)
                {
                    log.DebugFormat("RebuildIndex indexing item [{0} = {1}]", field.Name, fieldValue.FieldValue);
                }
            }

            if (hasSearchDef)
            {
                sbTitle.Replace("$_ItemID_$", item.ItemID.ToString());
                sbKeywords.Replace("$_ItemID_$", item.ItemID.ToString());
                sbDescription.Replace("$_ItemID_$", item.ItemID.ToString());
                sbLink.Replace("$_ItemID_$", item.ItemID.ToString());
                sbLinkQueryAddendum.Replace("$_ItemID_$", item.ItemID.ToString());

                indexItem.Content = sbDescription.ToString();
                indexItem.Title   = sbTitle.ToString();

                if (sbLink.Length > 0)
                {
                    indexItem.ViewPage = sbLink.ToString();
                }

                if (sbLinkQueryAddendum.Length > 0)
                {
                    indexItem.QueryStringAddendum  = sbLinkQueryAddendum.ToString();
                    indexItem.UseQueryStringParams = false;
                }
            }
            else
            {
                indexItem.ModuleTitle = pageSettings.PageName;
                indexItem.Title       = String.IsNullOrWhiteSpace(config.ModuleFriendlyName) ? module.ModuleTitle : config.ModuleFriendlyName;
            }

            indexItem.PageMetaKeywords = sbKeywords.ToString();
            indexItem.Categories       = sbKeywords.ToString();

            return(indexItem);
        }
コード例 #8
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            bool isEditable,
            string clientID,
            SiteSettings siteSettings,
            Module module,
            PageSettings pageSettings,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(string.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                ReplaceStaticTokens(sbStyleName, config, false, displaySettings, module, pageSettings, siteSettings, out sbStyleName);
                string styleName = sbStyleName.ToString();
                if (!string.IsNullOrWhiteSpace(style.Url))
                {
                    string styleUrl = string.Empty;

                    if (style.Url.StartsWith("/") ||
                        style.Url.StartsWith("http://") ||
                        style.Url.StartsWith("https://"))
                    {
                        styleUrl = style.Url;
                    }
                    else if (style.Url.StartsWith("~/"))
                    {
                        styleUrl = WebUtils.ResolveServerUrl(style.Url, siteSettings.UseSslOnAllPages);
                    }
                    else if (style.Url.StartsWith("$_SitePath_$"))
                    {
                        styleUrl = style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/");
                    }
                    else
                    {
                        styleUrl = new Uri(config.SolutionLocationUrl, style.Url).ToString();
                    }

                    sbStyleText.Append(string.Format(styleLinkFormat, styleUrl, styleName, style.Media));
                }
                else if (!string.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, styleName, style.Media));
                }

                ReplaceStaticTokens(sbStyleText, config, false, displaySettings, module, pageSettings, siteSettings, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
コード例 #9
0
        public static void SetupScripts(
            List <MarkupScript> markupScripts,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            bool isEditable,
            bool isPostBack,
            string clientID,
            SiteSettings siteSettings,
            Module module,
            PageSettings pageSettings,
            Page page,
            Control control)
        {
            string scriptRefFormat = "\n<script type=\"text/javascript\" src=\"{0}\" data-name=\"{1}\"></script>";
            string rawScriptFormat = "\n<script type=\"text/javascript\" data-name=\"{1}\">\n{0}\n</script>";

            foreach (MarkupScript script in markupScripts)
            {
                StringBuilder sbScriptText = new StringBuilder();
                StringBuilder sbScriptName = new StringBuilder();

                sbScriptName.Append(string.IsNullOrWhiteSpace(script.ScriptName) ? clientID + "flexiScript_" + markupScripts.IndexOf(script) : "flexiScript_" + script.ScriptName);
                ReplaceStaticTokens(sbScriptName, config, isEditable, displaySettings, module, pageSettings, siteSettings, out sbScriptName);

                string scriptName = sbScriptName.ToString();
                if (!string.IsNullOrWhiteSpace(script.Url))
                {
                    string scriptUrl = GetPathToFile(config, script.Url, WebConfigSettings.SslisAvailable);
                    sbScriptText.Append(string.Format(scriptRefFormat, scriptUrl, scriptName));
                }
                else if (!string.IsNullOrWhiteSpace(script.RawScript))
                {
                    sbScriptText.Append(string.Format(rawScriptFormat, script.RawScript, scriptName));
                }

                ReplaceStaticTokens(sbScriptText, config, isEditable, displaySettings, module, pageSettings, siteSettings, out sbScriptName);

                // script position options
                // inHead
                // inBody (register script) (default)
                // aboveMarkupDefinition
                // belowMarkupDefinition
                // bottomStartup (register startup script)
                switch (script.Position)
                {
                case "inHead":
                    if (!isPostBack && !page.IsCallback)
                    {
                        if (page.Header.FindControl(scriptName) == null)
                        {
                            LiteralControl headLit = new LiteralControl();
                            headLit.ID              = scriptName;
                            headLit.Text            = sbScriptText.ToString();
                            headLit.ClientIDMode    = ClientIDMode.Static;
                            headLit.EnableViewState = false;
                            page.Header.Controls.Add(headLit);
                        }
                    }
                    break;

                case "aboveMarkupDefinition":
                    if (control == null)
                    {
                        goto case "bottomStartup";
                    }
                    if (control.FindControlRecursive(scriptName) == null)
                    {
                        Control aboveMarkupDefinitionScripts = control.FindControlRecursive("aboveMarkupDefinitionScripts");
                        if (aboveMarkupDefinitionScripts != null)
                        {
                            LiteralControl aboveLit = new LiteralControl();
                            aboveLit.ID   = scriptName;
                            aboveLit.Text = sbScriptText.ToString();
                            aboveMarkupDefinitionScripts.Controls.Add(aboveLit);
                        }
                        else
                        {
                            goto case "bottomStartup";
                        }
                    }
                    break;

                case "belowMarkupDefinition":
                    if (control == null)
                    {
                        goto case "bottomStartup";
                    }
                    if (control.FindControlRecursive(scriptName) == null)
                    {
                        Control belowMarkupDefinitionScripts = control.FindControlRecursive("belowMarkupDefinitionScripts");
                        if (belowMarkupDefinitionScripts != null)
                        {
                            LiteralControl belowLit = new LiteralControl();
                            belowLit.ID   = scriptName;
                            belowLit.Text = sbScriptText.ToString();
                            belowMarkupDefinitionScripts.Controls.Add(belowLit);
                        }
                        else
                        {
                            goto case "bottomStartup";
                        }
                    }
                    //strBelowMarkupScripts.AppendLine(scriptText);
                    break;

                case "bottomStartup":
                    if (!page.ClientScript.IsStartupScriptRegistered(scriptName))
                    {
                        ScriptManager.RegisterStartupScript(
                            page,
                            typeof(Page),
                            scriptName,
                            sbScriptText.ToString(),
                            false);
                    }
                    break;

                case "inBody":
                default:
                    if (!page.ClientScript.IsClientScriptBlockRegistered(scriptName))
                    {
                        ScriptManager.RegisterClientScriptBlock(
                            page,
                            typeof(Page),
                            scriptName,
                            sbScriptText.ToString(),
                            false);
                    }
                    break;
                }
            }
        }