protected override void OnSubmit() { var isNew = _module == null; if (isNew) { _module = new ModuleBoxes(); _pageModule = new PageModule(); _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_BOXES]; _pageModule.PageId = _page.Id; _pageModule.Position = _page.PageModules.Count + 1; Position = _pageModule.Position; } _module.Text = Text; _pageModule.Title = Title; _pageModule.BlueTitle = BlueTitle; _pageModule.Theme = Theme; _pageModule.TransparentBackground = TransparentBackground; _pageModule.LootBox = LootBox; _pageModule.LootBoxLeft = LootBoxLeft; _pageModule.LootBoxTop = LootBoxTop; _pageModule.State = State; using (var conn = new NTGDBTransactional()) { _module.Save(conn); var subFormSuccess = true; var subForm = new CreateEditModuleBoxesBoxSubFormModel(); var positionReduction = 0; foreach (var box in Boxes.OrderBy(b => b.Position)) { if (box.IsDelete) { positionReduction++; } else if (positionReduction > 0) { box.IsModified = true; box.Position -= positionReduction; } if (box.IsModified || box.IsDelete) { subForm.Id = box.Id; subForm.Title = box.Title; subForm.Icon = box.Icon; subForm.Color = box.Color; subForm.Text = box.Text; subForm.Url = box.Url; subForm.Position = box.Position; subForm.ModuleBoxes = _module; subForm.IsDelete = box.IsDelete; subForm.IsNewModule = Id == 0; subForm.Submit(conn, Messages); subFormSuccess = subFormSuccess && subForm.Success; box.Id = subForm.Id; box.ModuleBoxesId = subForm.ModuleBoxes.Id; box.IsModified = false; } } if (subFormSuccess) { _pageModule.ModuleId = _module.Id; _pageModule.Save(conn); NTGLogger.LogSiteAction(HttpContext.Current.Request, SessionVariables.User, (isNew ? "Created" : "Editted") + " Module", _page.Id, _page.Name, _module.Id, ModuleService.MODULE_BOXES, conn); conn.Commit(); Id = _module.Id; PageModuleId = _pageModule.Id; Boxes.RemoveAll(b => b.IsDelete); ModuleService.RefreshCacheModule(_pageModule.Id); AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success)); } } }
/// <summary> /// This method is called when the site index is rebuilt /// </summary> /// <param name="pageSettings"></param> /// <param name="indexPath"></param> public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if (pageSettings == null) { if (log.IsErrorEnabled) { log.Error("pageSettings object passed to OfferSearchIndexBuilder.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info(Resources.WebStoreResources.WebStoreName + " indexing page - " + pageSettings.PageName); Guid webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593"); ModuleDefinition webStoreFeature = new ModuleDefinition(webStoreFeatureGuid); List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); // adding a try catch here because this is invoked even for non-implemented db platforms and it causes an error try { DataTable dataTable = Offer.GetBySitePage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"], CultureInfo.InvariantCulture); Hashtable moduleSettings = ModuleSettings.GetModuleSettings(indexItem.ModuleId); WebStoreConfiguration config = new WebStoreConfiguration(); if (moduleSettings != null) { config = new WebStoreConfiguration(moduleSettings); } if (!config.IndexOffersInSearch) { continue; } indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = webStoreFeatureGuid.ToString(); indexItem.FeatureName = webStoreFeature.FeatureName; indexItem.FeatureResourceFile = webStoreFeature.ResourceFile; indexItem.ItemKey = row["Guid"].ToString(); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Name"].ToString(); indexItem.ViewPage = row["Url"].ToString().Replace("/", string.Empty); if (indexItem.ViewPage.Length > 0) { indexItem.UseQueryStringParams = false; } else { indexItem.ViewPage = "WebStore/OfferDetail.aspx"; } indexItem.PageMetaDescription = row["MetaDescription"].ToString(); indexItem.PageMetaKeywords = row["MetaKeywords"].ToString(); indexItem.CreatedUtc = Convert.ToDateTime(row["Created"]); indexItem.LastModUtc = Convert.ToDateTime(row["LastModified"]); indexItem.Content = row["Abstract"].ToString() + " " + row["Description"].ToString() + " " + row["MetaDescription"].ToString() + " " + row["MetaKeywords"].ToString(); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } catch { } }
//public async Task<string> GetModuleEditResultAsString(ActionContext actionContext, PageModule pageModule, Guid moduleEditActionId) //{ // string actionResult = string.Empty; // try // { // var module = _moduleRepository.Get(pageModule.ModuleId); // ModuleView moduleView = module.ModuleView.FirstOrDefault(ma => ma.Id == moduleEditActionId); //It refers PageModule's Edit ModuleViewType // ModuleContext moduleContext = new ModuleContext(); // moduleContext.ModuleInfo = module; //Context should be PageModule's instance, but not Edit ModuleViewType // moduleContext.PageModuleId = pageModule.Id; // if (module != null && moduleView != null) // { // actionResult = await ExecuteModuleControllerAsString(actionContext, moduleContext, moduleView); // actionResult = $"<div class=\"dev-module-container\" data-module=\"{moduleContext.ModuleInfo.Name}\" data-page-module-id=\"{moduleContext.PageModuleId}\">{actionResult}</div>"; // } // } // catch (Exception ex) // { // actionResult = "Module load exception has been occured"; // _logger.LogError("Module load exception has been occured", ex); // } // return actionResult; //} public async Task <IHtmlContent> GetModuleEditResult(ActionContext actionContext, PageModule pageModule, Guid moduleEditActionId) { IHtmlContent editResult = new HtmlString(string.Empty); try { var module = _moduleRepository.GetModule(pageModule.ModuleId); var moduleView = module.ModuleView.FirstOrDefault(ma => ma.Id == moduleEditActionId); //It refers PageModule's Edit ModuleViewType var moduleContext = new ModuleContext(module, pageModule); //Context should be PageModule's instance, but not Edit ModuleViewType if (moduleView != null) { var actionResult = await ExecuteModuleController(actionContext, moduleContext, moduleView); editResult = GetModuleResult(actionResult, moduleContext); } } catch (Exception ex) { editResult = new HtmlString("Module load exception has been occured"); _logger.LogError("Module load exception has been occured", ex); } return(editResult); }
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.GetRelativeSiteRoot() + config.InstanceFeaturedImage; string jsonObjName = "sflexi" + moduleId.ToString() + (config.IsGlobalView ? "Modules" : "Items"); string currentSkin = string.Empty; string siteRoot = WebUtils.GetRelativeSiteRoot(); 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); }
private void CreateSite(Site site) { List <Role> roles = RoleRepository.GetRoles(site.SiteId, true).ToList(); if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any()) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true }); } if (!roles.Where(item => item.Name == Constants.HostRole).Any()) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true }); } RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); List <ModuleDefinition> moduledefinitions = ModuleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in SiteTemplate) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = PageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Path = pagetemplate.Path, Order = 1, IsNavigation = pagetemplate.IsNavigation, EditMode = pagetemplate.EditMode, ThemeType = "", LayoutType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions }; page = PageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Models.Module module = new Models.Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, Permissions = pagetemplatemodule.ModulePermissions, }; module = ModuleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; PageModuleRepository.AddPageModule(pagemodule); } } } } }
private static void IndexItem(ForumThread forumThread) { if (WebConfigSettings.DisableSearchIndex) { return; } if (forumThread == null) { if (log.IsErrorEnabled) { log.Error("forumThread object passed in ForumThreadIndexBuilderProvider.IndexItem was null"); } return; } Forum forum = new Forum(forumThread.ForumId); Module module = new Module(forum.ModuleId); Guid forumFeatureGuid = new Guid("38aa5a84-9f5c-42eb-8f4c-105983d419fb"); ModuleDefinition forumFeature = new ModuleDefinition(forumFeatureGuid); // get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(forum.ModuleId); // must update index for all pages containing // this module foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( forumThread.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); if (forumThread.SearchIndexPath.Length > 0) { indexItem.IndexPath = forumThread.SearchIndexPath; } indexItem.SiteId = forumThread.SiteId; indexItem.PageId = pageModule.PageId; indexItem.PageName = pageSettings.PageName; // permissions are kept in sync in search index // so that results are filtered by role correctly indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; indexItem.ItemId = forumThread.ForumId; indexItem.ModuleId = forum.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.FeatureId = forumFeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.Title = forumThread.Subject; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; indexItem.ViewPage = "Forums/Thread.aspx"; indexItem.CreatedUtc = forumThread.ThreadDate; indexItem.LastModUtc = forumThread.MostRecentPostDate; if (ForumConfiguration.AggregateSearchIndexPerThread) { indexItem.PublishBeginDate = forumThread.MostRecentPostDate; StringBuilder threadContent = new StringBuilder(); DataTable threadPosts = ForumThread.GetPostsByThread(forumThread.ThreadId); foreach (DataRow r in threadPosts.Rows) { threadContent.Append(r["Post"].ToString()); } //aggregate contents of posts into one indexable content item indexItem.Content = threadContent.ToString(); if (ForumConfiguration.CombineUrlParams) { indexItem.ViewPage = "Forums/Thread.aspx?pageid=" + pageModule.PageId.ToInvariantString() + "&t=" + forumThread.ThreadId.ToInvariantString() + "~1"; indexItem.UseQueryStringParams = false; } indexItem.QueryStringAddendum = "&thread=" + forumThread.ThreadId.ToInvariantString(); } else { //older implementation indexItem.Content = forumThread.PostMessage; indexItem.QueryStringAddendum = "&thread=" + forumThread.ThreadId.ToString() + "&postid=" + forumThread.PostId.ToString(); } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); if (debugLog) { log.Debug("Indexed " + forumThread.Subject); } } }
public static string NavigatePageURL(string pageId, string keyName, string keyValue, params string[] additionalParams) { string navigateUrl = DefaultPage.DEFAULT_PAGE; List <string> urlBuilder = new List <string>(); // add page id parameter if (!String.IsNullOrEmpty(pageId)) { urlBuilder.Add(String.Concat(DefaultPage.PAGE_ID_PARAM, "=", pageId)); } // add specified key if (!String.IsNullOrEmpty(keyName) && !String.IsNullOrEmpty(keyValue)) { urlBuilder.Add(String.Concat(keyName, "=", keyValue)); } // load additional params if (additionalParams != null) { string controlId = null; string moduleDefinitionId = null; // foreach (string paramStr in additionalParams) { if (paramStr.StartsWith("ctl=", StringComparison.InvariantCultureIgnoreCase)) { // ensure page exists and avoid unnecessary exceptions throw if (PortalConfiguration.Site.Pages.ContainsKey(pageId)) { string[] pair = paramStr.Split('='); controlId = pair[1]; } } else if (paramStr.StartsWith("moduleDefId=", StringComparison.InvariantCultureIgnoreCase)) { // ensure page exists and avoid unnecessary exceptions throw if (PortalConfiguration.Site.Pages.ContainsKey(pageId)) { string[] pair = paramStr.Split('='); moduleDefinitionId = pair[1]; } continue; } urlBuilder.Add(paramStr); } if (!String.IsNullOrEmpty(moduleDefinitionId) && !String.IsNullOrEmpty(controlId)) { // 1. Read module controls first information first foreach (ModuleDefinition md in PortalConfiguration.ModuleDefinitions.Values) { if (String.Equals(md.Id, moduleDefinitionId, StringComparison.InvariantCultureIgnoreCase)) { // 2. Lookup for module control foreach (ModuleControl mc in md.Controls.Values) { // 3. Compare against ctl parameter value if (mc.Key.Equals(controlId, StringComparison.InvariantCultureIgnoreCase)) { // 4. Lookup for module id foreach (int pmKey in PortalConfiguration.Site.Modules.Keys) { PageModule pm = PortalConfiguration.Site.Modules[pmKey]; if (String.Equals(pm.ModuleDefinitionID, md.Id, StringComparison.InvariantCultureIgnoreCase)) { // 5. Append module id parameter urlBuilder.Add("mid=" + pmKey); goto End; } } } } } } } } End: if (urlBuilder.Count > 0) { navigateUrl += String.Concat("?", String.Join("&", urlBuilder.ToArray())); } return(navigateUrl); }
public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if (pageSettings == null) { log.Error("pageSettings object passed to BlogIndexBuilderProvider.RebuildIndex was null"); return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("BlogIndexBuilderProvider indexing page - " + pageSettings.PageName); //try //{ Guid blogFeatureGuid = new Guid("026cbead-2b80-4491-906d-b83e37179ccf"); ModuleDefinition blogFeature = new ModuleDefinition(blogFeatureGuid); List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); DataTable dataTable = Blog.GetBlogsByPage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { bool includeInSearch = Convert.ToBoolean(row["IncludeInSearch"], CultureInfo.InvariantCulture); if (!includeInSearch) { continue; } DateTime postEndDate = DateTime.MaxValue; if (row["EndDate"] != DBNull.Value) { postEndDate = Convert.ToDateTime(row["EndDate"]); if (postEndDate < DateTime.UtcNow) { continue; } } bool excludeFromRecentContent = Convert.ToBoolean(row["ExcludeFromRecentContent"], CultureInfo.InvariantCulture); mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.ExcludeFromRecentContent = excludeFromRecentContent; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = blogFeatureGuid.ToString(); indexItem.FeatureName = blogFeature.FeatureName; indexItem.FeatureResourceFile = blogFeature.ResourceFile; indexItem.ItemId = Convert.ToInt32(row["ItemID"], CultureInfo.InvariantCulture); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"], CultureInfo.InvariantCulture); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Heading"].ToString(); string authorName = row["Name"].ToString(); string authorFirstName = row["FirstName"].ToString(); string authorLastName = row["LastName"].ToString(); if ((authorFirstName.Length > 0) && (authorLastName.Length > 0)) { indexItem.Author = string.Format(CultureInfo.InvariantCulture, BlogResources.FirstLastFormat, authorFirstName, authorLastName); } else { indexItem.Author = authorName; } if ((!WebConfigSettings.UseUrlReWriting) || (!BlogConfiguration.UseFriendlyUrls(indexItem.ModuleId))) { indexItem.ViewPage = "Blog/ViewPost.aspx?pageid=" + indexItem.PageId.ToInvariantString() + "&mid=" + indexItem.ModuleId.ToInvariantString() + "&ItemID=" + indexItem.ItemId.ToInvariantString() ; } else { indexItem.ViewPage = row["ItemUrl"].ToString().Replace("~/", string.Empty); } indexItem.PageMetaDescription = row["MetaDescription"].ToString(); indexItem.PageMetaKeywords = row["MetaKeywords"].ToString(); DateTime blogStart = Convert.ToDateTime(row["StartDate"]); indexItem.CreatedUtc = blogStart; indexItem.LastModUtc = Convert.ToDateTime(row["LastModUtc"]); //if (indexItem.ViewPage.Length > 0) //{ indexItem.UseQueryStringParams = false; //} //else //{ // indexItem.ViewPage = "Blog/ViewPost.aspx"; //} indexItem.Content = row["Description"].ToString(); indexItem.ContentAbstract = row["Abstract"].ToString(); int commentCount = Convert.ToInt32(row["CommentCount"]); if (commentCount > 0) { // index comments StringBuilder stringBuilder = new StringBuilder(); DataTable comments = Blog.GetBlogCommentsTable(indexItem.ModuleId, indexItem.ItemId); foreach (DataRow commentRow in comments.Rows) { stringBuilder.Append(" " + commentRow["Comment"].ToString()); stringBuilder.Append(" " + commentRow["Name"].ToString()); if (debugLog) { log.Debug("BlogIndexBuilderProvider.RebuildIndex add comment "); } } indexItem.OtherContent = stringBuilder.ToString(); } // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } if (blogStart > indexItem.PublishBeginDate) { indexItem.PublishBeginDate = blogStart; } if (postEndDate < indexItem.PublishEndDate) { indexItem.PublishEndDate = postEndDate; } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } //} //catch (Exception ex) //{ // log.Error(ex); //} }
private static void IndexItem(HtmlContent content) { bool disableSearchIndex = ConfigHelper.GetBoolProperty("DisableSearchIndex", false); if (disableSearchIndex) { return; } Module module = new Module(content.ModuleId); Guid htmlFeatureGuid = new Guid("881e4e00-93e4-444c-b7b0-6672fb55de10"); ModuleDefinition htmlFeature = new ModuleDefinition(htmlFeatureGuid); // get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(content.ModuleId); foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( content.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } IndexItem indexItem = new IndexItem(); if (content.SearchIndexPath.Length > 0) { indexItem.IndexPath = content.SearchIndexPath; } indexItem.SiteId = content.SiteId; indexItem.ExcludeFromRecentContent = content.ExcludeFromRecentContent; indexItem.PageId = pageModule.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; if (pageSettings.UseUrl) { indexItem.ViewPage = pageSettings.Url.Replace("~/", string.Empty); indexItem.UseQueryStringParams = false; } // generally we should not include the page meta because it can result in duplicate results // one for each instance of html content on the page because they all use the smae page meta. // since page meta should reflect the content of the page it is sufficient to just index the content if ((ConfigurationManager.AppSettings["IndexPageMeta"] != null) && (ConfigurationManager.AppSettings["IndexPageMeta"] == "true")) { indexItem.PageMetaDescription = pageSettings.PageMetaDescription; indexItem.PageMetaKeywords = pageSettings.PageMetaKeyWords; } indexItem.FeatureId = htmlFeatureGuid.ToString(); indexItem.FeatureName = htmlFeature.FeatureName; indexItem.FeatureResourceFile = htmlFeature.ResourceFile; indexItem.ItemId = content.ItemId; indexItem.ModuleId = content.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.Title = content.Title; indexItem.Content = SecurityHelper.RemoveMarkup(content.Body); indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; if ((content.CreatedByFirstName.Length > 0) && (content.CreatedByLastName.Length > 0)) { indexItem.Author = string.Format(CultureInfo.InvariantCulture, Resource.FirstLastFormat, content.CreatedByFirstName, content.CreatedByLastName); } else { indexItem.Author = content.CreatedByName; } indexItem.CreatedUtc = content.CreatedDate; indexItem.LastModUtc = content.LastModUtc; if (!module.IncludeInSearch) { indexItem.RemoveOnly = true; } IndexHelper.RebuildIndex(indexItem); } log.Debug("Indexed " + content.Title); }
public async Task <PageModule> UpdatePageModuleAsync(PageModule pageModule) { return(await PutJsonAsync <PageModule>($"{Apiurl}/{pageModule.PageModuleId}", pageModule)); }
private static void IndexItem(Blog blog) { if (WebConfigSettings.DisableSearchIndex) { return; } if (blog == null) { if (log.IsErrorEnabled) { log.Error("blog object passed to BlogIndexBuilderProvider.IndexItem was null"); } return; } if (!blog.IncludeInSearch) { return; } Module module = new Module(blog.ModuleId); Guid blogFeatureGuid = new Guid("026cbead-2b80-4491-906d-b83e37179ccf"); ModuleDefinition blogFeature = new ModuleDefinition(blogFeatureGuid); // get comments so they can be indexed too StringBuilder stringBuilder = new StringBuilder(); using (IDataReader comments = Blog.GetBlogComments(blog.ModuleId, blog.ItemId)) { while (comments.Read()) { stringBuilder.Append(" " + comments["Comment"].ToString()); stringBuilder.Append(" " + comments["Name"].ToString()); if (debugLog) { log.Debug("BlogIndexBuilderProvider.IndexItem add comment "); } } } // get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(blog.ModuleId); foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( blog.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); if (blog.SearchIndexPath.Length > 0) { indexItem.IndexPath = blog.SearchIndexPath; } indexItem.SiteId = blog.SiteId; indexItem.ExcludeFromRecentContent = blog.ExcludeFromRecentContent; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; indexItem.PageMetaDescription = blog.MetaDescription; indexItem.PageMetaKeywords = blog.MetaKeywords; indexItem.ItemId = blog.ItemId; indexItem.ModuleId = blog.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.Title = blog.Title; indexItem.Content = blog.Description + " " + blog.MetaDescription + " " + blog.MetaKeywords; indexItem.ContentAbstract = blog.Excerpt; indexItem.FeatureId = blogFeatureGuid.ToString(); indexItem.FeatureName = blogFeature.FeatureName; indexItem.FeatureResourceFile = blogFeature.ResourceFile; indexItem.OtherContent = stringBuilder.ToString(); indexItem.PublishBeginDate = pageModule.PublishBeginDate; if (blog.StartDate > pageModule.PublishBeginDate) { indexItem.PublishBeginDate = blog.StartDate; } indexItem.PublishEndDate = pageModule.PublishEndDate; if (blog.EndDate < pageModule.PublishEndDate) { indexItem.PublishEndDate = blog.EndDate; } if ((blog.UserFirstName.Length > 0) && (blog.UserLastName.Length > 0)) { indexItem.Author = string.Format(CultureInfo.InvariantCulture, BlogResources.FirstLastFormat, blog.UserFirstName, blog.UserLastName); } else { indexItem.Author = blog.UserName; } indexItem.CreatedUtc = blog.StartDate; indexItem.LastModUtc = blog.LastModUtc; if ((!WebConfigSettings.UseUrlReWriting) || (!BlogConfiguration.UseFriendlyUrls(indexItem.ModuleId))) { indexItem.ViewPage = "Blog/ViewPost.aspx?pageid=" + indexItem.PageId.ToInvariantString() + "&mid=" + indexItem.ModuleId.ToInvariantString() + "&ItemID=" + indexItem.ItemId.ToInvariantString() ; } else { indexItem.ViewPage = blog.ItemUrl.Replace("~/", string.Empty); } indexItem.UseQueryStringParams = false; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); } if (debugLog) { log.Debug("Indexed " + blog.Title); } }
public async Task <PageModule> AddPageModuleAsync(PageModule pageModule) { return(await PostJsonAsync <PageModule>(Apiurl, pageModule)); }
public override void RebuildIndex(PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if ((pageSettings == null) || (indexPath == null)) { if (log.IsErrorEnabled) { log.Error("pageSettings object or index path passed to KalturaIndexBuilderProvider.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("KalturaIndexBuilderProvider indexing page - " + pageSettings.PageName); try { List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); //1. Get Century21_Kaltura_PlayVideos data from mp_ModuleDefinitions table using GUID Guid kalturaVideoGuid = new Guid("40C79626-E229-4CBA-B9B1-52745734FE44"); ModuleDefinition forumFeature = new ModuleDefinition(kalturaVideoGuid); //2. Get all Kaltura videos which are saved in Usr_TblKalturaVideo table List <KalturaVideoNotification> lstVideos = KalturaVideoNotification.GetKalturaVideoByPage(pageSettings.SiteId, pageSettings.PageId); foreach (KalturaVideoNotification video in lstVideos) { IndexItem indexItem = new IndexItem(); indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = video.ViewRoles; indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.ItemId = video.KalturaVideoID; indexItem.ModuleId = video.ModuleID; indexItem.ModuleTitle = "Play Videos"; indexItem.Title = video.Name; indexItem.Content = video.Description + " --> " + video.Tags; indexItem.OtherContent = video.ThumnailURL; indexItem.ViewPage = "/play-video?mediaId=" + video.EntryId; var pageModule = pageModules.Where(p => p.ModuleId == indexItem.ModuleId).FirstOrDefault(); if (pageModule != null) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } catch (System.Data.Common.DbException ex) { log.Error(ex); } }
private static void IndexItem(KalturaVideoNotification video) { if (WebConfigSettings.DisableSearchIndex) { return; } if (video == null) { if (log.IsErrorEnabled) { log.Error("forumThread object passed in KalturaIndexBuilderProvider.IndexItem was null"); } return; } Module module = new Module(video.ModuleID); Guid FeatureGuid = new Guid("40C79626-E229-4CBA-B9B1-52745734FE44"); ModuleDefinition forumFeature = new ModuleDefinition(FeatureGuid); // get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(video.ModuleID); // must update index for all pages contained in this module foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings(video.SiteId, pageModule.PageId); if (pageSettings.IsPending) { continue; } IndexItem indexItem = new IndexItem(); if (video.SearchIndexPath.Length > 0) { indexItem.IndexPath = video.SearchIndexPath; } indexItem.SiteId = video.SiteId; indexItem.PageId = pageModule.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; indexItem.ModuleId = video.ModuleID; indexItem.ModuleTitle = module.ModuleTitle; indexItem.FeatureId = FeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.ItemId = video.KalturaVideoID; indexItem.Title = video.Name; indexItem.Content = video.Description + " --> " + video.Tags; indexItem.OtherContent = video.ThumnailURL; indexItem.ViewPage = "/play-video?mediaId=" + video.EntryId; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; IndexHelper.RebuildIndex(indexItem); if (debugLog) { log.Debug("Indexed " + video.Name); } } }
protected override void OnSubmit() { var isNew = _module == null; if (isNew) { _module = new ModuleGallery(); _pageModule = new PageModule(); _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_GALLERY]; _pageModule.PageId = _page.Id; _pageModule.Position = _page.PageModules.Count + 1; Position = _pageModule.Position; } _pageModule.Title = Title; _pageModule.BlueTitle = BlueTitle; _pageModule.Theme = Theme; _pageModule.TransparentBackground = TransparentBackground; _pageModule.LootBox = LootBox; _pageModule.LootBoxTop = LootBoxTop; _pageModule.LootBoxLeft = LootBoxLeft; _pageModule.State = State; using (var conn = new NTGDBTransactional()) { _module.Save(conn); var subFormSuccess = true; var subForm = new CreateEditModuleGalleryImageSubFormModel(); var positionReduction = 0; foreach (var image in Images.OrderBy(i => i.Position)) { if (image.IsDelete) { positionReduction++; } else if (positionReduction > 0) { image.IsModified = true; image.Position -= positionReduction; } if (image.IsModified || image.IsDelete) { subForm.Id = image.Id; subForm.Image = image.Image; subForm.Position = image.Position; subForm.ModuleGallery = _module; subForm.IsDelete = image.IsDelete; subForm.IsNewModule = Id == 0; subForm.Links = image.ModuleGalleryImageLinks.ToList(); subForm.Submit(conn, Messages); subFormSuccess = subFormSuccess && subForm.Success; image.Id = subForm.Id; image.ModuleGalleryId = subForm.ModuleGallery.Id; image.ModuleGalleryImageLinks = subForm.Links; image.IsModified = false; } } if (subFormSuccess) { _pageModule.ModuleId = _module.Id; _pageModule.Save(conn); NTGLogger.LogSiteAction(HttpContext.Current.Request, SessionVariables.User, (isNew ? "Created" : "Editted") + " Module", _page.Id, _page.Name, _module.Id, ModuleService.MODULE_GALLERY, conn); conn.Commit(); Id = _module.Id; PageModuleId = _pageModule.Id; Images.RemoveAll(c => c.IsDelete); ModuleService.RefreshCacheModule(_pageModule.Id); AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success)); } } }
public override void RebuildIndex( PageSettings pageSettings, string indexPath) { bool disableSearchIndex = ConfigHelper.GetBoolProperty("DisableSearchIndex", false); if (disableSearchIndex) { return; } if (pageSettings == null) { log.Error("pageSettings passed in to HtmlContentIndexBuilderProvider.RebuildIndex was null"); return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("HtmlContentIndexBuilderProvider indexing page - " + pageSettings.PageName); try { Guid htmlFeatureGuid = new Guid("881e4e00-93e4-444c-b7b0-6672fb55de10"); ModuleDefinition htmlFeature = new ModuleDefinition(htmlFeatureGuid); List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); HtmlRepository repository = new HtmlRepository(); DataTable dataTable = repository.GetHtmlContentByPage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { bool includeInSearch = Convert.ToBoolean(row["IncludeInSearch"]); bool excludeFromRecentContent = Convert.ToBoolean(row["ExcludeFromRecentContent"]); IndexItem indexItem = new IndexItem(); indexItem.ExcludeFromRecentContent = excludeFromRecentContent; indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; string authorName = row["CreatedByName"].ToString(); string authorFirstName = row["CreatedByFirstName"].ToString(); string authorLastName = row["CreatedByLastName"].ToString(); if ((authorFirstName.Length > 0) && (authorLastName.Length > 0)) { indexItem.Author = string.Format(CultureInfo.InvariantCulture, Resource.FirstNameLastNameFormat, authorFirstName, authorLastName); } else { indexItem.Author = authorName; } if (!includeInSearch) { indexItem.RemoveOnly = true; } // generally we should not include the page meta because it can result in duplicate results // one for each instance of html content on the page because they all use the smae page meta. // since page meta should reflect the content of the page it is sufficient to just index the content if (WebConfigSettings.IndexPageKeywordsWithHtmlArticleContent) { indexItem.PageMetaDescription = pageSettings.PageMetaDescription; indexItem.PageMetaKeywords = pageSettings.PageMetaKeyWords; } indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); if (pageSettings.UseUrl) { if (pageSettings.UrlHasBeenAdjustedForFolderSites) { indexItem.ViewPage = pageSettings.UnmodifiedUrl.Replace("~/", string.Empty); } else { indexItem.ViewPage = pageSettings.Url.Replace("~/", string.Empty); } indexItem.UseQueryStringParams = false; } indexItem.FeatureId = htmlFeatureGuid.ToString(); indexItem.FeatureName = htmlFeature.FeatureName; indexItem.FeatureResourceFile = htmlFeature.ResourceFile; indexItem.ItemId = Convert.ToInt32(row["ItemID"]); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"]); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Title"].ToString(); // added the remove markup 2010-01-30 because some javascript strings like ]]> were apearing in search results if the content conatined jacvascript indexItem.Content = SecurityHelper.RemoveMarkup(row["Body"].ToString()); indexItem.CreatedUtc = Convert.ToDateTime(row["CreatedDate"]); indexItem.LastModUtc = Convert.ToDateTime(row["LastModUtc"]); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } IndexHelper.RebuildIndex(indexItem, indexPath); log.Debug("Indexed " + indexItem.Title); } } catch (System.Data.Common.DbException ex) { log.Error(ex); } }
public Page Post(int id, string userid) { Page page = null; Page parent = _pages.GetPage(id); if (parent != null && parent.SiteId == _alias.SiteId && parent.IsPersonalizable && _userPermissions.GetUser(User).UserId == int.Parse(userid)) { page = new Page(); page.SiteId = parent.SiteId; page.Name = parent.Name; page.Title = parent.Title; page.Path = parent.Path; page.ParentId = parent.PageId; page.Order = 0; page.IsNavigation = false; page.Url = ""; page.ThemeType = parent.ThemeType; page.DefaultContainerType = parent.DefaultContainerType; page.Icon = parent.Icon; page.Permissions = new List <Permission> { new Permission(PermissionNames.View, int.Parse(userid), true), new Permission(PermissionNames.Edit, int.Parse(userid), true) }.EncodePermissions(); page.IsPersonalizable = false; page.UserId = int.Parse(userid); page = _pages.AddPage(page); _syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Site, page.SiteId); // copy modules List <PageModule> pagemodules = _pageModules.GetPageModules(page.SiteId).ToList(); foreach (PageModule pm in pagemodules.Where(item => item.PageId == parent.PageId && !item.IsDeleted)) { Module module = new Module(); module.SiteId = page.SiteId; module.PageId = page.PageId; module.ModuleDefinitionName = pm.Module.ModuleDefinitionName; module.AllPages = false; module.Permissions = new List <Permission> { new Permission(PermissionNames.View, int.Parse(userid), true), new Permission(PermissionNames.Edit, int.Parse(userid), true) }.EncodePermissions(); module = _modules.AddModule(module); string content = _modules.ExportModule(pm.ModuleId); if (content != "") { _modules.ImportModule(module.ModuleId, content); } PageModule pagemodule = new PageModule(); pagemodule.PageId = page.PageId; pagemodule.ModuleId = module.ModuleId; pagemodule.Title = pm.Title; pagemodule.Pane = pm.Pane; pagemodule.Order = pm.Order; pagemodule.ContainerType = pm.ContainerType; _pageModules.AddPageModule(pagemodule); } } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Post Attempt {PageId} By User {UserId}", id, userid); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; page = null; } return(page); }
public PageModule AddPageModule(PageModule pageModule) { _db.PageModule.Add(pageModule); _db.SaveChanges(); return(pageModule); }
public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if ((pageSettings == null) || (indexPath == null)) { if (log.IsErrorEnabled) { log.Error("pageSettings object or index path passed to ForumThreadIndexBuilderProvider.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("ForumThreadIndexBuilderProvider indexing page - " + pageSettings.PageName); try { List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); Guid forumFeatureGuid = new Guid("38aa5a84-9f5c-42eb-8f4c-105983d419fb"); ModuleDefinition forumFeature = new ModuleDefinition(forumFeatureGuid); // new implementation 2012-05-22: get threads by page, then for each thread concat the posts into one item for indexing // previously were indexing individual posts but this makes multiple results in search results for the same thread if (ForumConfiguration.AggregateSearchIndexPerThread) { DataTable threads = ForumThread.GetThreadsByPage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in threads.Rows) { StringBuilder threadContent = new StringBuilder(); int threadId = Convert.ToInt32(row["ThreadID"]); DateTime threadDate = Convert.ToDateTime(row["ThreadDate"]); DataTable threadPosts = ForumThread.GetPostsByThread(threadId); foreach (DataRow r in threadPosts.Rows) { threadContent.Append(r["Post"].ToString()); } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } indexItem.CreatedUtc = threadDate; if (row["MostRecentPostDate"] != DBNull.Value) { indexItem.LastModUtc = Convert.ToDateTime(row["MostRecentPostDate"]); } else { indexItem.LastModUtc = threadDate; } indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = forumFeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.ItemId = Convert.ToInt32(row["ItemID"]); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"]); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Subject"].ToString(); indexItem.Content = threadContent.ToString(); if (ForumConfiguration.CombineUrlParams) { indexItem.ViewPage = "Forums/Thread.aspx?pageid=" + pageSettings.PageId.ToInvariantString() + "&t=" + row["ThreadID"].ToString() + "~1"; indexItem.UseQueryStringParams = false; // still need this since it is aprt of the key indexItem.QueryStringAddendum = "&thread=" + row["ThreadID"].ToString(); } else { indexItem.ViewPage = "Forums/Thread.aspx"; indexItem.QueryStringAddendum = "&thread=" + row["ThreadID"].ToString(); } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } else { //older implementation indexed posts individually DataTable dataTable = ForumThread.GetPostsByPage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = forumFeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.ItemId = Convert.ToInt32(row["ItemID"]); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"]); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Subject"].ToString(); indexItem.Content = row["Post"].ToString(); indexItem.ViewPage = "Forums/Thread.aspx"; indexItem.QueryStringAddendum = "&thread=" + row["ThreadID"].ToString() + "&postid=" + row["PostID"].ToString(); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } //indexItem.PublishBeginDate = Convert.ToDateTime(row["PostDate"]); //indexItem.PublishEndDate = DateTime.MaxValue; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } } catch (System.Data.Common.DbException ex) { log.Error(ex); } }
public PageModule UpdatePageModule(PageModule pageModule) { _db.Entry(pageModule).State = EntityState.Modified; _db.SaveChanges(); return(pageModule); }
public Page Post(int id, string userid) { Page page = null; Page parent = _pages.GetPage(id); if (parent != null && parent.IsPersonalizable && _userPermissions.GetUser(User).UserId == int.Parse(userid)) { page = new Page(); page.SiteId = parent.SiteId; page.Name = parent.Name; page.Title = parent.Title; page.Path = parent.Path; page.ParentId = parent.PageId; page.Order = 0; page.IsNavigation = false; page.Url = ""; page.EditMode = false; page.ThemeType = parent.ThemeType; page.LayoutType = parent.LayoutType; page.Icon = parent.Icon; page.Permissions = _permissionRepository.EncodePermissions(new List <Permission> { new Permission(PermissionNames.View, userid, true), new Permission(PermissionNames.Edit, userid, true) }); page.IsPersonalizable = false; page.UserId = int.Parse(userid); page = _pages.AddPage(page); _syncManager.AddSyncEvent(EntityNames.Site, page.SiteId); // copy modules List <PageModule> pagemodules = _pageModules.GetPageModules(page.SiteId).ToList(); foreach (PageModule pm in pagemodules.Where(item => item.PageId == parent.PageId && !item.IsDeleted)) { Module module = new Module(); module.SiteId = page.SiteId; module.PageId = page.PageId; module.ModuleDefinitionName = pm.Module.ModuleDefinitionName; module.Permissions = _permissionRepository.EncodePermissions(new List <Permission> { new Permission(PermissionNames.View, userid, true), new Permission(PermissionNames.Edit, userid, true) }); module = _modules.AddModule(module); string content = _modules.ExportModule(pm.ModuleId); if (content != "") { _modules.ImportModule(module.ModuleId, content); } PageModule pagemodule = new PageModule(); pagemodule.PageId = page.PageId; pagemodule.ModuleId = module.ModuleId; pagemodule.Title = pm.Title; pagemodule.Pane = pm.Pane; pagemodule.Order = pm.Order; pagemodule.ContainerType = pm.ContainerType; _pageModules.AddPageModule(pagemodule); } } return(page); }
private static void IndexItem(GalleryImage galleryImage) { if (WebConfigSettings.DisableSearchIndex) { return; } SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if ((siteSettings == null) || (galleryImage == null)) { return; } Guid galleryFeatureGuid = new Guid("d572f6b4-d0ed-465d-ad60-60433893b401"); ModuleDefinition galleryFeature = new ModuleDefinition(galleryFeatureGuid); Module module = new Module(galleryImage.ModuleId); // get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(galleryImage.ModuleId); foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( siteSettings.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.SiteId = siteSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; indexItem.FeatureId = galleryFeatureGuid.ToString(); indexItem.FeatureName = galleryFeature.FeatureName; indexItem.FeatureResourceFile = galleryFeature.ResourceFile; indexItem.CreatedUtc = galleryImage.UploadDate; indexItem.LastModUtc = galleryImage.UploadDate; indexItem.ItemId = galleryImage.ItemId; indexItem.ModuleId = galleryImage.ModuleId; indexItem.QueryStringAddendum = "&ItemID" + galleryImage.ModuleId.ToString() + "=" + galleryImage.ItemId.ToString(); indexItem.ModuleTitle = module.ModuleTitle; indexItem.Title = galleryImage.Caption; indexItem.Content = galleryImage.Description; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); if (debugLog) { log.Debug("Indexed " + galleryImage.Caption); } } }
protected override void RenderContents(HtmlTextWriter output) { DataSet dsBlogs = null; // Check for Featured Post, if it exists grab one less post to keep the count correct if (blogConfig.FeaturedPostId == 0) { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, pageSize, out totalPages); } else { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, (pageSize - 1), out totalPages); } DataRow featuredRow = dsBlogs.Tables["Posts"].NewRow(); if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { using (IDataReader reader = Blog.GetSingleBlog(blogConfig.FeaturedPostId)) { while (reader.Read()) { featuredRow["ItemID"] = Convert.ToInt32(reader["ItemID"]); featuredRow["ModuleID"] = Convert.ToInt32(reader["ModuleID"]); featuredRow["BlogGuid"] = reader["BlogGuid"].ToString(); featuredRow["CreatedDate"] = Convert.ToDateTime(reader["CreatedDate"]); featuredRow["Heading"] = reader["Heading"].ToString(); featuredRow["SubTitle"] = reader["SubTitle"].ToString(); featuredRow["StartDate"] = Convert.ToDateTime(reader["StartDate"]); featuredRow["Description"] = reader["Description"].ToString(); featuredRow["Abstract"] = reader["Abstract"].ToString(); featuredRow["ItemUrl"] = reader["ItemUrl"].ToString(); featuredRow["Location"] = reader["Location"].ToString(); featuredRow["MetaKeywords"] = reader["MetaKeywords"].ToString(); featuredRow["MetaDescription"] = reader["MetaDescription"].ToString(); featuredRow["LastModUtc"] = Convert.ToDateTime(reader["LastModUtc"]); featuredRow["IsPublished"] = true; featuredRow["IncludeInFeed"] = Convert.ToBoolean(reader["IncludeInFeed"]); featuredRow["CommentCount"] = Convert.ToInt32(reader["CommentCount"]); featuredRow["CommentCount"] = 0; featuredRow["UserID"] = Convert.ToInt32(reader["UserID"]); featuredRow["UserID"] = -1; featuredRow["Name"] = reader["Name"].ToString(); featuredRow["FirstName"] = reader["FirstName"].ToString(); featuredRow["LastName"] = reader["LastName"].ToString(); featuredRow["LoginName"] = reader["LoginName"].ToString(); featuredRow["Email"] = reader["Email"].ToString(); featuredRow["AvatarUrl"] = reader["AvatarUrl"].ToString(); featuredRow["AuthorBio"] = reader["AuthorBio"].ToString(); featuredRow["AllowCommentsForDays"] = Convert.ToInt32(reader["AllowCommentsForDays"]); if (reader["ShowAuthorName"] != DBNull.Value) { featuredRow["ShowAuthorName"] = Convert.ToBoolean(reader["ShowAuthorName"]); } else { featuredRow["ShowAuthorName"] = true; } if (reader["ShowAuthorAvatar"] != DBNull.Value) { featuredRow["ShowAuthorAvatar"] = Convert.ToBoolean(reader["ShowAuthorAvatar"]); } else { featuredRow["ShowAuthorAvatar"] = true; } if (reader["ShowAuthorBio"] != DBNull.Value) { featuredRow["ShowAuthorBio"] = Convert.ToBoolean(reader["ShowAuthorBio"]); } else { featuredRow["ShowAuthorBio"] = true; } if (reader["UseBingMap"] != DBNull.Value) { featuredRow["UseBingMap"] = Convert.ToBoolean(reader["UseBingMap"]); } else { featuredRow["UseBingMap"] = false; } featuredRow["MapHeight"] = reader["MapHeight"].ToString(); featuredRow["MapWidth"] = reader["MapWidth"].ToString(); featuredRow["MapType"] = reader["MapType"].ToString(); if (reader["MapZoom"] != DBNull.Value) { featuredRow["MapZoom"] = Convert.ToInt32(reader["MapZoom"]); } else { featuredRow["MapZoom"] = 13; } if (reader["ShowMapOptions"] != DBNull.Value) { featuredRow["ShowMapOptions"] = Convert.ToBoolean(reader["ShowMapOptions"]); } else { featuredRow["ShowMapOptions"] = false; } if (reader["ShowZoomTool"] != DBNull.Value) { featuredRow["ShowZoomTool"] = Convert.ToBoolean(reader["ShowZoomTool"]); } else { featuredRow["ShowZoomTool"] = false; } if (reader["ShowLocationInfo"] != DBNull.Value) { featuredRow["ShowLocationInfo"] = Convert.ToBoolean(reader["ShowLocationInfo"]); } else { featuredRow["ShowLocationInfo"] = false; } if (reader["UseDrivingDirections"] != DBNull.Value) { featuredRow["UseDrivingDirections"] = Convert.ToBoolean(reader["UseDrivingDirections"]); } else { featuredRow["UseDrivingDirections"] = false; } if (reader["ShowDownloadLink"] != DBNull.Value) { featuredRow["ShowDownloadLink"] = Convert.ToBoolean(reader["ShowDownloadLink"]); } else { featuredRow["ShowDownloadLink"] = false; } featuredRow["HeadlineImageUrl"] = reader["HeadlineImageUrl"].ToString(); if (reader["IncludeImageInExcerpt"] != DBNull.Value) { featuredRow["IncludeImageInExcerpt"] = Convert.ToBoolean(reader["IncludeImageInExcerpt"]); } else { featuredRow["IncludeImageInExcerpt"] = true; } if (reader["IncludeImageInPost"] != DBNull.Value) { featuredRow["IncludeImageInPost"] = Convert.ToBoolean(reader["IncludeImageInPost"]); } else { featuredRow["IncludeImageInPost"] = true; } } } } //look for featured post in datable DataRow found = dsBlogs.Tables["Posts"].Rows.Find(blogConfig.FeaturedPostId); if (found != null) { //remove featured post from datatable so we can insert it at the top if we're on "page" number 1 dsBlogs.Tables["Posts"].Rows.Remove(found); } if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { //insert the featured post into the datatable at the top //we only want to do this if the current "page" is number 1, don't want the featured post on other pages. dsBlogs.Tables["Posts"].Rows.InsertAt(featuredRow, 0); } List <PageModule> pageModules = PageModule.GetPageModulesByModule(config.BlogModuleId); string blogPageUrl = string.Empty; if (pageModules.Count > 0) { blogPageUrl = pageModules[0].PageUrl; } List <BlogPostModel> models = new List <BlogPostModel>(); foreach (DataRow postRow in dsBlogs.Tables["posts"].Rows) { BlogPostModel model = new BlogPostModel(); if (useFriendlyUrls && (postRow["ItemUrl"].ToString().Length > 0)) { model.ItemUrl = navigationSiteRoot + postRow["ItemUrl"].ToString().Replace("~", string.Empty); } else { model.ItemUrl = postRow["ItemID"].ToString() + "&mid=" + postRow["ModuleID"].ToString(); } if (blogConfig.FeaturedPostId == Convert.ToInt32(postRow["ItemID"]) && pageNumber == 1) { model.FeaturedPost = true; } else { model.FeaturedPost = false; } model.Title = postRow["Heading"].ToString(); model.SubTitle = postRow["SubTitle"].ToString(); model.Body = postRow["Description"].ToString(); model.AuthorAvatar = postRow["AvatarUrl"].ToString(); model.AuthorDisplayName = postRow["Name"].ToString(); model.AuthorFirstName = postRow["FirstName"].ToString(); model.AuthorLastName = postRow["LastName"].ToString(); model.AuthorBio = postRow["AuthorBio"].ToString(); model.Excerpt = postRow["Abstract"].ToString(); model.PostDate = Convert.ToDateTime(postRow["StartDate"].ToString()); model.HeadlineImageUrl = postRow["HeadlineImageUrl"].ToString(); model.CommentCount = Convert.ToInt32(postRow["CommentCount"]); model.AllowCommentsForDays = Convert.ToInt32(postRow["AllowCommentsForDays"]); model.ShowAuthorName = Convert.ToBoolean(postRow["ShowAuthorName"]); model.ShowAuthorAvatar = Convert.ToBoolean(postRow["ShowAuthorAvatar"]); model.ShowAuthorBio = Convert.ToBoolean(postRow["ShowAuthorBio"]); model.AuthorUserId = Convert.ToInt32(postRow["UserID"]); models.Add(model); } PostListModel postListObject = new PostListModel(); if (module != null) { postListObject.ModuleTitle = module.ModuleTitle; postListObject.Module = module; } else { postListObject.ModuleTitle = ""; } //postListObject.ModuleTitle = module == null ? "" : module.ModuleTitle; postListObject.ModulePageUrl = Page.ResolveUrl(blogPageUrl); postListObject.Posts = models; string text = string.Empty; try { text = RazorBridge.RenderPartialToString(config.Layout, postListObject, "Blog"); } //catch (System.Web.HttpException ex) //{ // renderDefaultView(ex.ToString()); //} //catch (ArgumentNullException ex) //{ // renderDefaultView(ex.ToString()); //} catch (Exception ex) { renderDefaultView(ex.ToString()); } void renderDefaultView(string error = "") { if (!string.IsNullOrWhiteSpace(error)) { log.ErrorFormat( "chosen layout ({0}) for _BlogPostList was not found in skin {1}. perhaps it is in a different skin. Error was: {2}", config.Layout, SiteUtils.GetSkinBaseUrl(true, Page), error ); } text = RazorBridge.RenderPartialToString("_BlogPostList", postListObject, "Blog"); } output.Write(text); }
public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if (pageSettings == null) { return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info(Resources.GalleryResources.ImageGalleryFeatureName + " indexing page - " + pageSettings.PageName); try { Guid galleryFeatureGuid = new Guid("d572f6b4-d0ed-465d-ad60-60433893b401"); ModuleDefinition galleryFeature = new ModuleDefinition(galleryFeatureGuid); List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); DataTable dataTable = GalleryImage.GetImagesByPage(pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); if (pageSettings.UseUrl) { indexItem.ViewPage = pageSettings.Url.Replace("~/", string.Empty); indexItem.UseQueryStringParams = false; } indexItem.FeatureId = galleryFeatureGuid.ToString(); indexItem.FeatureName = galleryFeature.FeatureName; indexItem.FeatureResourceFile = galleryFeature.ResourceFile; // TODO: it would be good to check the module settings and if not // in compact mode use the GalleryBrowse.aspx page //indexItem.ViewPage = "GalleryBrowse.aspx"; indexItem.ItemId = Convert.ToInt32(row["ItemID"]); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"]); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Caption"].ToString(); indexItem.Content = row["Description"].ToString(); indexItem.QueryStringAddendum = "&ItemID" + row["ModuleID"].ToString() + "=" + row["ItemID"].ToString(); indexItem.CreatedUtc = Convert.ToDateTime(row["UploadDate"]); indexItem.LastModUtc = indexItem.CreatedUtc; // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } catch (System.Data.Common.DbException ex) { log.Error(ex); } }
private static void IndexItem(Offer offer) { if (WebConfigSettings.DisableSearchIndex) { return; } if (offer == null) { if (log.IsErrorEnabled) { log.Error("product object passed to OfferSearchIndexBuilder.IndexItem was null"); } return; } Store store = new Store(offer.StoreGuid); Module module = new Module(store.ModuleId); Guid webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593"); ModuleDefinition webStoreFeature = new ModuleDefinition(webStoreFeatureGuid); //// get list of pages where this module is published List <PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( offer.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); if (offer.SearchIndexPath.Length > 0) { indexItem.IndexPath = offer.SearchIndexPath; } indexItem.SiteId = offer.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; if (offer.Url.Length > 0) { indexItem.ViewPage = offer.Url.Replace("~/", string.Empty); indexItem.UseQueryStringParams = false; } else { indexItem.ViewPage = "/WebStore/OfferDetail.aspx"; } indexItem.ItemKey = offer.Guid.ToString(); indexItem.ModuleId = store.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.Title = offer.Name; indexItem.PageMetaDescription = offer.MetaDescription; indexItem.PageMetaKeywords = offer.MetaKeywords; indexItem.CreatedUtc = offer.Created; indexItem.LastModUtc = offer.LastModified; indexItem.Content = offer.Teaser + " " + offer.Description.Replace(tabScript, string.Empty) + " " + offer.MetaDescription + " " + offer.MetaKeywords; indexItem.FeatureId = webStoreFeatureGuid.ToString(); indexItem.FeatureName = webStoreFeature.FeatureName; indexItem.FeatureResourceFile = webStoreFeature.ResourceFile; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); } if (debugLog) { log.Debug("Indexed " + offer.Name); } }
protected override void OnSubmit() { var isNew = _module == null; if (isNew) { _module = new ModuleProfileCards(); _pageModule = new PageModule(); _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_PROFILE_CARDS]; _pageModule.PageId = _page.Id; _pageModule.Position = _page.PageModules.Count + 1; Position = _pageModule.Position; } _pageModule.Title = Title; _pageModule.BlueTitle = BlueTitle; _pageModule.Theme = Theme; _pageModule.TransparentBackground = TransparentBackground; _pageModule.LootBox = LootBox; _pageModule.LootBoxTop = LootBoxTop; _pageModule.LootBoxLeft = LootBoxLeft; _pageModule.State = State; using (var conn = new NTGDBTransactional()) { _module.Save(conn); var subFormSuccess = true; var subForm = new CreateEditModuleProfileCardsCardSubFormModel(); var positionReduction = 0; foreach (var card in Cards.OrderBy(c => c.Position)) { if (card.IsDelete) { positionReduction++; } else if (positionReduction > 0) { card.IsModified = true; card.Position -= positionReduction; } if (card.IsModified || card.IsDelete) { subForm.Id = card.Id; subForm.Name = card.Name; subForm.FacebookUrl = card.FacebookUrl; subForm.TwitterUrl = card.TwitterUrl; subForm.TwitchUrl = card.TwitchUrl; subForm.InstagramUrl = card.InstagramUrl; subForm.YouTubeUrl = card.YouTubeUrl; subForm.Image = card.Image; subForm.Position = card.Position; subForm.ModuleProfileCards = _module; subForm.IsNewModule = Id == 0; subForm.IsDelete = card.IsDelete; subForm.Links = card.ModuleProfileCardsCardLinks.ToList(); subForm.Submit(conn, Messages); subFormSuccess = subFormSuccess && subForm.Success; card.Id = subForm.Id; card.ModuleProfileCardsId = subForm.ModuleProfileCards.Id; card.ModuleProfileCardsCardLinks = subForm.Links; card.IsModified = false; } } if (subFormSuccess) { _pageModule.ModuleId = _module.Id; _pageModule.Save(conn); NTGLogger.LogSiteAction(HttpContext.Current.Request, SessionVariables.User, (isNew ? "Created" : "Editted") + " Module", _page.Id, _page.Name, _module.Id, ModuleService.MODULE_PROFILE_CARDS, conn); conn.Commit(); Id = _module.Id; PageModuleId = _pageModule.Id; Cards.RemoveAll(c => c.IsDelete); ModuleService.RefreshCacheModule(_pageModule.Id); AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success)); } } }
public void CreatePages(Site site, List <PageTemplate> pageTemplates) { List <ModuleDefinition> moduledefinitions = _moduleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in pageTemplates) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = _pageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Title = "", Path = pagetemplate.Path, Order = (pagetemplate.Order == 0) ? 1 : pagetemplate.Order, Url = "", IsNavigation = pagetemplate.IsNavigation, ThemeType = "", DefaultContainerType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions, IsPersonalizable = pagetemplate.IsPersonalizable, UserId = null, IsClickable = true }; page = _pageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, AllPages = false, Permissions = pagetemplatemodule.ModulePermissions, }; module = _moduleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerManagerType != "") { Type moduletype = Type.GetType(moduledefinition.ServerManagerType); if (moduletype != null && moduletype.GetInterface("IPortable") != null) { try { var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } catch { // error in IPortable implementation } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; _pageModuleRepository.AddPageModule(pagemodule); } } } } }
private void CreatePages(Site site, List <PageTemplate> pageTemplates) { List <ModuleDefinition> moduledefinitions = _moduleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in pageTemplates) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = _pageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Title = "", Path = pagetemplate.Path, Order = 1, Url = "", IsNavigation = pagetemplate.IsNavigation, EditMode = pagetemplate.EditMode, ThemeType = "", LayoutType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions, IsPersonalizable = pagetemplate.IsPersonalizable, UserId = null }; page = _pageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, Permissions = pagetemplatemodule.ModulePermissions, }; module = _moduleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; _pageModuleRepository.AddPageModule(pagemodule); } } } } }
private void CreateSite(Site site) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); foreach (PageTemplate pagetemplate in SiteTemplate) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = PageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Path = pagetemplate.Path, Order = pagetemplate.Order, IsNavigation = pagetemplate.IsNavigation, ThemeType = site.DefaultThemeType, LayoutType = site.DefaultLayoutType, Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions }; Type type = Type.GetType(page.ThemeType); System.Reflection.PropertyInfo property = type.GetProperty("Panes"); page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null); page = PageRepository.AddPage(page); if (pagetemplate.ModuleDefinitionName != "") { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplate.ModuleDefinitionName, Permissions = pagetemplate.ModulePermissions, }; module = ModuleRepository.AddModule(module); PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplate.Title, Pane = pagetemplate.Pane, Order = 1, ContainerType = pagetemplate.ContainerType }; PageModuleRepository.AddPageModule(pagemodule); } } }
public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if ((pageSettings == null) || (indexPath == null)) { if (log.IsErrorEnabled) { log.Error("pageSettings object or index path passed to BrowseCoursesIndexBuilderProvider.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("BrowseCoursesIndexBuilderProvider indexing page - " + pageSettings.PageName); try { List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); Guid scheduleFeatureGuid = new Guid("dc873d76-5bf2-4ac5-bff7-434a86a3fc9e"); ModuleDefinition forumFeature = new ModuleDefinition(scheduleFeatureGuid); List <CourseModule> lstSchedules = CourseModule.GetCoursesByPage(pageSettings.SiteId, pageSettings.PageId); DataTable dataTable = ConvertToDatatable(lstSchedules); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = scheduleFeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.ItemId = Convert.ToInt32(row["CourseID"]); indexItem.ModuleId = Convert.ToInt32(row["ModuleId"]); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["CourseName"].ToString(); indexItem.Content = row["Description"].ToString() + " " + row["Metatags"].ToString() + " " + row["LeadInstructor"].ToString(); indexItem.ViewPage = WebConfigSettings.CourseSearchUrl; //"browse-course"; // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } //indexItem.PublishBeginDate = Convert.ToDateTime(row["PostDate"]); //indexItem.PublishEndDate = DateTime.MaxValue; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } catch (System.Data.Common.DbException ex) { log.Error(ex); } }