/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void ContentItemNoticeModule_After(ContentItem sender, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) { long toUserId = sender.UserId; NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>(); Notice notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = CmsConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Manage(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.ContentItemId; notice.RelativeObjectName = sender.Title; notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ContentItemDetail(sender.ContentItemId)); notice.TemplateName = NoticeTemplateNames.Instance().ContributeAccepted(); noticeService.Create(notice); } }
/// <summary> /// Create the default home page zone and zone user role during setup. /// </summary> /// <returns></returns> private void InsertHomePageZone(int HomePageId) { CmsPageSecurityZone z = new CmsPageSecurityZone(); z.ZoneName = "Default zone"; z.StartingPage = pagerepository.Get(HomePageId); if (new CmsPageSecurityZoneDb().insert(z) == false) { throw new Exception("Cannot insert Home Page Zone"); } // anonymous users can read, but not write pages in this zone CmsPageSecurityZoneUserRole anonZoneRole = new CmsPageSecurityZoneUserRole(z.Id, WebPortalUserRole.DUMMY_PUBLIC_ROLE_ID, true, false); if (new CmsPageSecurityZoneUserRoleDb().insert(anonZoneRole) == false) { throw new Exception("Cannot insert anonymous ZoneUserRole"); } // authors can write and read all pages in this zone WebPortalUserRole authorRole = WebPortalUserRole.Fetch(CmsConfig.getConfigValue("AuthorAccessUserRole", "Author")); if (authorRole.RoleID >= 0) { CmsPageSecurityZoneUserRole authorZoneRole = new CmsPageSecurityZoneUserRole(z.Id, authorRole.RoleID, true, true); if (new CmsPageSecurityZoneUserRoleDb().insert(authorZoneRole) == false) { throw new Exception("Cannot insert author ZoneUserRole"); } } }
public CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); bool printerVer = CmsConfig.getConfigValue("PrinterAndPdfVer.printerVer", false); bool pdfVer = CmsConfig.getConfigValue("PrinterAndPdfVer.pdfVer", false); ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.pdfVer")); if (pdfVer) { ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.pdfIcon")); } ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.printerVer")); if (printerVer) { ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.printerIcon")); } ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.placeAfterDom", CmsDependency.ExistsMode.MustNotExist)); // this file should not exist ret.Add(CmsFileDependency.UnderAppPath("js/_system/printerAndPdfVersion.js", CmsDependency.ExistsMode.MustNotExist)); return(ret.ToArray()); }
public override CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); string[] removedCols = new string[] { "LocationToDisplay", "HtmlHeader" }; ret.Add(new CmsDatabaseTableDependency(@" CREATE TABLE `jobsummary` ( `JobSummaryId` int(10) unsigned NOT NULL AUTO_INCREMENT, `PageId` int(10) unsigned NOT NULL, `Identifier` int(10) unsigned NOT NULL, `langShortCode` varchar(255) NOT NULL, `locationId` int(11) NOT NULL, `Deleted` datetime DEFAULT NULL, PRIMARY KEY (`JobSummaryId`), KEY `jobsummary_secondary` (`PageId`,`Identifier`,`Deleted`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ", removedCols)); ret.Add(new CmsConfigItemDependency("JobPosting.DetailsTemplateName", CmsDependency.ExistsMode.MustExist)); ret.Add(new CmsConfigItemDependency("JobPosting.FullJobDescriptionText", CmsDependency.ExistsMode.MustExist)); ret.Add(new CmsTemplateDependency(CmsConfig.getConfigValue("JobPosting.DetailsTemplateName", "_JobPosting"), "JobPosting.DetailsTemplateName configuration entry")); ret.Add(CmsFileDependency.UnderAppPath("images/_system/calendar/arrowRight.jpg", new DateTime(2011, 3, 1))); return(ret.ToArray()); }
public override void RunBackgroundTask() { bool enabled = CmsConfig.getConfigValue("EmailAdminEveryHourEnabled", false); if (enabled) { string techEmail = CmsConfig.getConfigValue("TechnicalAdministratorEmail", ""); string smtpServer = CmsConfig.getConfigValue("smtpServer", ""); if (techEmail.IndexOf("@") < 1 || smtpServer.Trim() == "") { return; // don't run anything if there's no email address or smtp server defined. } string configSiteName = CmsConfig.getConfigValue("SiteName", ""); if (configSiteName != "") { configSiteName = " [" + configSiteName + "] "; } string msgBody = "Hourly email from " + System.Web.Hosting.HostingEnvironment.SiteName + configSiteName + ": " + DateTime.Now.ToString("MMM d yyyy HH:mm:ss"); MailMessage msg = new MailMessage(techEmail, techEmail, msgBody, msgBody); msg.IsBodyHtml = true; SmtpClient smtpclient = new SmtpClient(smtpServer); smtpclient.Send(msg); } }
private static CmsConfig GetRootConfig(Action <ICmsConfig>?config = null) { var rootConfig = new CmsConfig(); config?.Invoke(rootConfig); return(rootConfig); }
/// <summary> /// Render the Zone Authority interface /// </summary> /// <returns></returns> public override string Render() { string controlId = "zoneAuthority_"; StringBuilder html = new StringBuilder(); List <CmsPageSecurityZone> zoneList = db.fetchAll(); List <WebPortalUserRole> roleList = getRoleList(); html.Append(handleZoneAuthorityUpdate(zoneList, roleList)); string adminRoleName = CmsConfig.getConfigValue("AdminUserRole", "?"); if (zoneList.Count == 0) { return("<p><em>No Zone defined</em></p>"); } CmsPage p = CmsContext.currentPage; html.Append(p.getFormStartHtml(controlId + "Form") + EOL); html.Append(TABLE_START_HTML + EOL); html.Append(RenderZoneAuthorityHeader(roleList)); html.Append(RenderZoneAuthorityContent(zoneList, roleList, adminRoleName)); html.Append(TABLE_END_HTML + EOL); html.Append("<input type=\"submit\" value=\"Update\" />" + EOL); html.Append(generateFormHiddenField()); html.Append(p.getFormCloseHtml(controlId + "Form")); return(html.ToString()); }
private void InsertAdminAreaZone(int AdminPageId) { CmsPageSecurityZone z = new CmsPageSecurityZone(); z.ZoneName = "Internal Author Tools Zone"; z.StartingPageId = AdminPageId; if (new CmsZoneDb().insert(z) == false) { throw new Exception("Cannot insert Zone"); } // anonymous users cannot read or write in this zone CmsZoneUserRole anonZoneRole = new CmsZoneUserRole(z.ZoneId, WebPortalUserRole.DUMMY_PUBLIC_ROLE_ID, false, false); if (new CmsZoneUserRoleDb().insert(anonZoneRole) == false) { throw new Exception("Cannot insert anonymous ZoneUserRole"); } // authors can write and read all pages in this zone WebPortalUserRole authorRole = WebPortalUserRole.Fetch(CmsConfig.getConfigValue("AuthorAccessUserRole", "Author")); if (authorRole.RoleID >= 0) { CmsZoneUserRole authorZoneRole = new CmsZoneUserRole(z.ZoneId, authorRole.RoleID, true, true); if (new CmsZoneUserRoleDb().insert(authorZoneRole) == false) { throw new Exception("Cannot insert author ZoneUserRole"); } } }
/// <summary> /// Renders the SideNavigation control to the HtmlTextWriter /// </summary> /// <param name="writer"></param> protected override void Render(System.Web.UI.HtmlTextWriter writer) { CmsPage currentPage = CmsContext.currentPage; CmsPage homePage = CmsContext.HomePage; if (currentPage.Id == homePage.Id) { writer.Write("<div id=\"SideNav\"></div>"); return; } // -- get the secondLevelMainPage CmsPage secondLevelMainPage = currentPage; while (secondLevelMainPage.Level > 1) { secondLevelMainPage = secondLevelMainPage.ParentPage; } int maxLevels = 100; maxLevels = CmsConfig.getConfigValue("SideNavMaxLevels", maxLevels); bool outputAllChildren = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "OutputAllChildren", false); string html = "<div id=\"SideNav\">"; if (secondLevelMainPage.ChildPages.Length > 0) { html += "<ul class=\"level0\">" + Environment.NewLine + recursiveRender(secondLevelMainPage, 0, maxLevels, outputAllChildren) + "\n</ul>" + Environment.NewLine; } html += "</div>"; writer.Write(html); } // Render
} // resolveUrl private void RenderViewStatus(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList) { PageRedirectDb db = new PageRedirectDb(); string url = db.getPageRedirectUrl(page, identifier, langToRenderFor.shortCode, true); string resolvedUrl = resolveRedirectUrl(url); string width = "100%"; string height = "1.5em"; if (CmsConfig.TemplateEngineVersion == CmsTemplateEngineVersion.v2) { width = PlaceholderUtils.getParameterValue("width", width, paramList); height = PlaceholderUtils.getParameterValue("height", height, paramList); } else { throw new NotImplementedException("Error: invalid TemplateEngine version"); } System.Text.StringBuilder html = new System.Text.StringBuilder(); html.Append("<div style=\"background: #CCC; padding: 0.2em;\">"); html.Append("Normal site viewers (people who are not site authors) will be automatically redirected to :"); html.Append("<a href=\"" + resolvedUrl + "\" style=\"font-size: " + height + ";\">"); html.Append(url); html.Append("</a>"); if (resolvedUrl != "") { StringBuilder js = new StringBuilder(); js.Append("var start=new Date();" + Environment.NewLine); js.Append("start=Date.parse(start)/1000;" + Environment.NewLine); js.Append("var counts=10;" + Environment.NewLine); js.Append("function CountDownToRedirect(){" + Environment.NewLine); js.Append(" var now=new Date();" + Environment.NewLine); js.Append(" now=Date.parse(now)/1000;" + Environment.NewLine); js.Append(" var x=parseInt(counts-(now-start),10);" + Environment.NewLine); js.Append(" document.getElementById('redirectCountDown').value = x;" + Environment.NewLine); js.Append(" if(x>0){" + Environment.NewLine); js.Append(" timerID=setTimeout(\"CountDownToRedirect()\", 100)"+ Environment.NewLine); js.Append(" }else{" + Environment.NewLine); js.Append(" location.href=\""+ resolvedUrl + "\"" + Environment.NewLine); js.Append(" }" + Environment.NewLine); js.Append("} // CountDownToRedirect" + Environment.NewLine); page.HeadSection.AddJSStatements(js.ToString()); page.HeadSection.AddJSOnReady("CountDownToRedirect();"); page.HeadSection.registerBlockForOutput("RedirectTimer"); int numSecondsToWait = CmsConfig.getConfigValue("RedirectPlaceholder_autoRedirectAfterSeconds", 10);; html.Append("<p>You are being redirected in <input type=\"text\" name=\"clock\" id=\"redirectCountDown\" size=\"2\" value=\"" + numSecondsToWait.ToString() + "\"> seconds.</p>" + Environment.NewLine); } html.Append("</div>"); writer.WriteLine(html); } // RenderViewStatus
public override CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); ret.Add(new CmsPageDependency(CmsConfig.getConfigValue("GotoEditModePath", "/_admin/action/gotoEdit"), CmsConfig.Languages)); return(ret.ToArray()); }
public static string getRssDataSourceUrl() { // SADC water hub glossary via RSS: "http://www.sadcwaterhub.org/glossary/feed?lang_tid[0]=2" string url = CmsConfig.getConfigValue("Glossary:RSSUrl", ""); return(url.Trim()); }
public CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); string cssUrl = CmsConfig.getConfigValue("cssUrl", "").Replace("~", ""); if (cssUrl != "") { ret.Add(CmsFileDependency.UnderAppPath(cssUrl)); } bool printerVer = CmsConfig.getConfigValue("PrinterAndPdfVer.printerVer", false); ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.printerVer")); if (printerVer) { ret.Add(new CmsConfigItemDependency("PrinterAndPdfVer.printerCss")); string printcssUrl = CmsConfig.getConfigValue("PrinterAndPdfVer.printerCss", "").Replace("~", ""); if (printcssUrl != "") { ret.Add(CmsFileDependency.UnderAppPath(printcssUrl)); } } return(ret.ToArray()); }
protected string getRandomImageUrl() { string ConfUrls = CmsConfig.getConfigValue("RandomImageUrls", ""); if (ConfUrls.Trim() == "") { return(""); } // -- split on | (pipe) character string[] urls = ConfUrls.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int randomUrlIndex = (new System.Random()).Next(0, urls.Length - 1); // -- let's try to actually rotate through the images (it's not random) if (Session["lastRandomImageIndex"] != null) { randomUrlIndex = Convert.ToInt32(Session["lastRandomImageIndex"]); randomUrlIndex++; } if (randomUrlIndex >= urls.Length || randomUrlIndex < 0) // wrap { randomUrlIndex = 0; } string imgUrl = urls[randomUrlIndex]; Session["lastRandomImageIndex"] = randomUrlIndex; return(imgUrl); }
/// <summary> /// Read the role names define in config file, and select the role /// entitys from database by the role names. /// </summary> /// <returns></returns> protected List <WebPortalUserRole> getRoleList() { List <WebPortalUserRole> roleList = new List <WebPortalUserRole>(); WebPortalUserDB db = new WebPortalUserDB(); WebPortalUserRole r; r = db.FetchUserRole(CmsConfig.getConfigValue("AdminUserRole", "")); if (r != null) { roleList.Add(r); } r = db.FetchUserRole(CmsConfig.getConfigValue("AuthorAccessUserRole", "")); if (r != null) { roleList.Add(r); } r = db.FetchUserRole(CmsConfig.getConfigValue("LoginUserRole", "")); if (r != null) { roleList.Add(r); } r = WebPortalUserRole.dummyPublicUserRole; // dummy public role, not from web portal DB roleList.Add(r); return(roleList); }
internal CmsSetup(CmsConfig config) { SiteName = config.SiteName; IsDevelopment = config.IsDevelopment; CollectionsAndPages = ConfigProcessingHelper.ProcessCollections(config); if (config.CustomLoginScreenRegistration != null) { CustomLoginScreenRegistration = new CustomTypeRegistrationSetup(config.CustomLoginScreenRegistration); } if (config.CustomLoginStatusRegistration != null) { CustomLoginStatusRegistration = new CustomTypeRegistrationSetup(config.CustomLoginStatusRegistration); } MapCollections(CollectionsAndPages.SelectNotNull(x => x as CollectionSetup)); void MapCollections(IEnumerable <CollectionSetup> collections) { foreach (var collection in collections.Where(col => !col.Recursive)) { if (!_collectionMap.TryAdd(collection.Alias, collection)) { throw new InvalidOperationException($"Duplicate collection alias '{collection.Alias}' not allowed."); } if (collection.Collections.Any()) { MapCollections(collection.Collections); } } } }
private WebPortalUserRole[] getAllAvailableRoles() { List <WebPortalUserRole> ret = new List <WebPortalUserRole>(); string adminUserRoleName = CmsConfig.getConfigValue("AdminUserRole", "Administrator"); ret.Add(WebPortalUserRole.Fetch(adminUserRoleName)); string authorUserRoleName = CmsConfig.getConfigValue("AuthorAccessUserRole", "Author"); if (String.Compare(adminUserRoleName, authorUserRoleName, true) != 0) { ret.Add(WebPortalUserRole.Fetch(authorUserRoleName)); } string nothing = Guid.NewGuid().ToString(); CmsPageSecurityZone homePageZone = (new CmsPageSecurityZoneDb()).fetchByPage(CmsContext.HomePage); bool requireAnonLogin = homePageZone.canRead(WebPortalUser.dummyPublicUser); string loginRole = CmsConfig.getConfigValue("LoginUserRole", nothing); if (!requireAnonLogin && loginRole != nothing && String.Compare(loginRole, authorUserRoleName, true) != 0 && String.Compare(loginRole, adminUserRoleName, true) != 0) { ret.Add(WebPortalUserRole.Fetch(loginRole)); } return(ret.ToArray()); }
public override CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); ret.Add(new CmsPageDependency(CmsConfig.getConfigValue("ChangeMenuVisibilityPath", "/_admin/actions/MenuVisibilityPopup"), CmsConfig.Languages)); return(ret.ToArray()); }
protected override void Render(HtmlTextWriter writer) { int ImageId = PageUtils.getFromForm("i", -1); if (ImageId < 0) { writer.Write("Error: invalid image specified"); return; } SingleImageDb db = new SingleImageDb(); SingleImageData image = db.getSingleImage(ImageId); if (image == null) { writer.Write("Error: invalid image specified"); return; } int imageBoxWidth = CmsConfig.getConfigValue("SingleImage.FullSizeDisplayWidth", -1); int imageBoxHeight = CmsConfig.getConfigValue("SingleImage.FullSizeDisplayHeight", -1); // -- prepare the output string largeImageUrl = showThumbPage.getThumbDisplayUrl(image.ImagePath, imageBoxWidth, imageBoxHeight); System.Drawing.Size LargeImageSize = showThumbPage.getDisplayWidthAndHeight(image.ImagePath, imageBoxWidth, imageBoxHeight); string width = ""; string height = ""; if (!LargeImageSize.IsEmpty) { width = " width=\"" + LargeImageSize.Width + "\""; height = " height=\"" + LargeImageSize.Height.ToString() + "\""; } string EOL = Environment.NewLine; System.Text.StringBuilder html = new System.Text.StringBuilder(); // -- do the output html.Append("<div class=\"SingleImageDisplay\">" + EOL); html.Append("<img src=\"" + largeImageUrl + "\"" + width + "" + height + ">" + EOL); html.Append("<div class=\"Caption\">"); html.Append(image.Caption); html.Append("</div>" + EOL); if (image.Credits.Trim() != "") { html.Append("<div class=\"credits\">"); string creditsPrefix = CmsConfig.getConfigValue("SingleImage.CreditsPrefix", ""); html.Append(creditsPrefix + image.Credits); html.Append("</div>"); // credits } html.Append("</div>"); writer.Write(html.ToString()); }
protected override void Render(HtmlTextWriter writer) { CmsLanguage lang = CmsContext.currentLanguage; string imgText = CmsConfig.getConfigValue("UserImageGallery.ImageText", "Number of images", lang); string noGalleryText = CmsConfig.getConfigValue("UserImageGallery.NoGalleryText", "No image galleries are currently available", lang); CmsPage galleryPage = CmsContext.currentPage; int numGalleriesOutput = 0; StringBuilder html = new StringBuilder(); CmsPage[] sortedPages = CmsPage.SortPagesBySortOrdinal(galleryPage.ChildPages); for (int i = sortedPages.Length - 1; i >= 0; i--) { CmsPage g = sortedPages[i]; if (true) // g.showInMenu { UserImageGalleryDb db = new UserImageGalleryDb(); UserImageGalleryPlaceholderData data = new UserImageGalleryPlaceholderData(); data = db.getUserImageGalleryPlaceholderData(g, 1, CmsContext.currentLanguage, true); string dirOnDiskToView = data.getImageStorageDirectory(g); if (Directory.Exists(dirOnDiskToView)) { DirectoryInfo di = new DirectoryInfo(dirOnDiskToView); int update = Hatfield.Web.Portal.PageUtils.getFromForm("update", 0); if (update == 1 && g.currentUserCanWrite) { CmsLocalImageOnDisk[] updates = CmsLocalImageOnDisk.UpdateFolderInDatabase(di); } CmsLocalImageOnDisk[] allResources = CmsLocalImageOnDisk.FetchAllImagesInDirectory(di, UserImageGalleryPlaceholderData.ImageExtensionsToDisplay); if (allResources.Length >= 1) { numGalleriesOutput++; string thumbUrl = showThumbPage.getThumbDisplayUrl(allResources[0], 100, 100);; html.Append("<tr><td><a href=\"" + g.Url + "\"><img border=\"0\" src=\"" + thumbUrl + "\"></a></td><td><a href=\"" + g.Url + "\">" + g.Title + "</a><br />(" + allResources.Length + " images)</td></tr>"); } } } } // foreach if (numGalleriesOutput > 0) { writer.Write("<table cellspacing=\"10\">"); writer.Write(html.ToString()); writer.Write("</table>"); } else { writer.Write("<em>" + noGalleryText + "</em>"); } }
public CmsSetup( CmsConfig config, ISetupResolver <TypeRegistrationSetup, CustomTypeRegistrationConfig> typeRegistrationSetupResolver) { _config = config; _typeRegistrationSetupResolver = typeRegistrationSetupResolver; SiteName = config.SiteName; IsDevelopment = config.IsDevelopment; }
public static IServiceCollection AddRapidCMS(this IServiceCollection services, Action <ICmsConfig>?config = null) { var rootConfig = new CmsConfig(); config?.Invoke(rootConfig); if (rootConfig.AllowAnonymousUsage) { services.AddSingleton <IAuthorizationHandler, AllowAllAuthorizationHandler>(); } services.AddSingleton(rootConfig); // providers for delivering config objects services.AddTransient <ICustomRegistrationProvider, CustomRegistrationProvider>(); services.AddTransient <ICollectionProvider, CollectionProvider>(); services.AddTransient <IMetadataProvider, MetadataProvider>(); services.AddTransient <IAuthenticationStateProvider, AuthenticationStateProvider>(); // UI + Repository services services.AddTransient <IDataProviderService, DataProviderService>(); services.AddScoped <IEditContextService, EditContextService>(); services.AddTransient <IEditorService, EditorService>(); services.AddTransient <ITreeService, TreeService>(); services.AddTransient <IParentService, ParentService>(); // Data exchange services services.AddScoped <ISidePaneService, SidePaneService>(); services.AddScoped <IMessageService, MessageService>(); // Button handlers services.AddScoped <DefaultButtonActionHandler>(); services.AddScoped(typeof(OpenPaneButtonActionHandler <>)); // Debug helpers services.AddScoped <IExceptionHelper, ExceptionHelper>(); // Stock data providers services.AddScoped(typeof(EnumDataProvider <>), typeof(EnumDataProvider <>)); // UI requirements services.AddHttpContextAccessor(); services.AddScoped <HttpContextAccessor>(); services.AddHttpClient(); services.AddScoped <HttpClient>(); // Scoped semaphore for repositories services.AddScoped(serviceProvider => new SemaphoreSlim(rootConfig.SemaphoreMaxCount, rootConfig.SemaphoreMaxCount)); services.AddMemoryCache(); return(services); }
public ActionResult _RecommendComments(string recommendTypeId = null, int topNumber = 5) { if (CmsConfig.Instance().EnableSocialComment) { return(new EmptyResult()); } IEnumerable <RecommendItem> recommendItems = new RecommendService().GetTops(topNumber, recommendTypeId); ViewData["recommendTypeId"] = recommendTypeId; return(View(recommendItems)); }
/// <summary> /// Initialize components and plugins in the nop environment. /// </summary> /// <param name="config">Config</param> public void Initialize(CmsConfig config) { //register dependencies RegisterDependencies(config); //startup tasks if (!config.IgnoreStartupTasks) { RunStartupTasks(); } }
public override CmsDependency[] getDependencies() { List <CmsDependency> ret = new List <CmsDependency>(); ret.Add(new CmsPageDependency(CmsConfig.getConfigValue("GotoEditModePath", "/_admin/action/gotoEdit"), CmsConfig.Languages)); ret.Add(CmsFileDependency.UnderAppPath("js/_system/jquery/jquery-1.4.1.min.js")); // AdminTools.css is now embedded in this project's Assembly. ret.Add(CmsFileDependency.UnderAppPath("css/_system/AdminTools.css", CmsDependency.ExistsMode.MustNotExist)); return(ret.ToArray()); }
public ActionResult _Tops(ContentItemSortBy sortBy = ContentItemSortBy.ReleaseDate_Desc, int?contentFolderId = null, string viewName = null, int topNumber = 5) { var items = contentItemService.GetTops(5, contentFolderId, sortBy); if (CmsConfig.Instance().EnableSocialComment&& (sortBy == ContentItemSortBy.StageCommentCount || sortBy == ContentItemSortBy.CommentCount)) { return(new EmptyResult()); } ViewData["sortBy"] = sortBy; ViewData["contentFolderId"] = contentFolderId; return(View(viewName ?? "_Tops", items)); }
/// <summary> /// Format the main content /// </summary> /// <param name="articleArray"></param> /// <param name="lang"></param> /// <returns></returns> protected string renderContent(List <NewsArticleDb.NewsArticleDetailsData> articleArray, CmsLanguage lang, string template, int maxLengthOfSummary, string dateOfNewsToStringFormat) { StringBuilder html = new StringBuilder(); int count = CmsConfig.getConfigValue("MostRecentNews.Count", 1); if (articleArray.Count == 0) { return(getNoNewsText(lang)); } foreach (NewsArticleDb.NewsArticleDetailsData article in articleArray) { CmsPage newsArticleDetailsPage = CmsContext.getPageById(article.DetailsPageId); if (newsArticleDetailsPage.Id < 0) { continue; } string url = newsArticleDetailsPage.getUrl(lang); string articleContent = newsArticleDetailsPage.renderPlaceholdersToString("HtmlContent", lang, CmsPage.RenderPlaceholderFilterAction.ReturnUnfiltered); string summary = StringUtils.StripHTMLTags(articleContent).Trim(); string summaryOutput = summary; if (maxLengthOfSummary > 0 && summary.Length > maxLengthOfSummary) { StringBuilder sb = new StringBuilder(); string[] words = summary.Split(new char[] { ' ' }); foreach (string word in words) { if (sb.ToString().Length > maxLengthOfSummary) { break; } sb.Append(word.Trim() + " "); } summaryOutput = sb.ToString() + "..."; } string dateOfNews = article.DateOfNews.ToString(dateOfNewsToStringFormat); string output = String.Format(template, new string[] { url, summaryOutput, newsArticleDetailsPage.Title, dateOfNews }); html.Append(output); string readArticleText = getReadArticleText(lang); if (readArticleText.Trim() != "") { string extraAnchor = "<div style=\"text-align: right; padding-right: 3px; margin-top: -10px; margin-bottom: 5px;\"><a href=\"{0}\" class=\"readNewsArticle\">{1}</a></div>"; html.Append(string.Format(extraAnchor, new string[] { url, readArticleText })); } } return(html.ToString()); }
private string getHtml(CmsPage page) { string titlePrefix = CmsConfig.getConfigValue("pageTitlePrefix", ""); string titlePostfix = CmsConfig.getConfigValue("pageTitlePostfix", ""); System.Text.StringBuilder html = new System.Text.StringBuilder(); html.Append(Environment.NewLine + "<title>" + titlePrefix + getDisplayTitle(page) + titlePostfix + "</title>" + Environment.NewLine); string cssUrl = CmsConfig.getConfigValue("cssUrl", ""); if (cssUrl != null && cssUrl != "") { cssUrl = cssUrl.Replace("~", ""); page.HeadSection.AddCSSFile(CSSGroup.FrontEnd, cssUrl); } string printCss = CmsConfig.getConfigValue("PrinterAndPdfVer.printerCss", ""); if (CmsContext.currentUserIsRequestingPrintFriendlyVersion && printCss != null && printCss.Trim() != "") { printCss = printCss.Replace("~", CmsContext.ApplicationPath); page.HeadSection.AddCSSFile(CSSGroup.FrontEnd, printCss); } // -- output any meta tags string description = CmsContext.currentPage.SearchEngineDescription.Trim(); if (description != "") { html.Append(Environment.NewLine); html.Append("<meta name=\"description\" content=\"" + Server.HtmlEncode(description) + "\">" + Environment.NewLine); html.Append(Environment.NewLine); } if (CmsConfig.Languages.Length > 1) { // -- output mulitlingual links (useful for Google: http://googlewebmastercentral.blogspot.com/2010/09/unifying-content-under-multilingual.htm) foreach (CmsLanguage lang in CmsConfig.Languages) { if (CmsContext.currentLanguage.shortCode != lang.shortCode) { html.Append("<link rel=\"alternate\" hreflang=\"" + lang.shortCode + "\" href=\"" + page.getUrl(lang) + "\" />" + Environment.NewLine); } } } // -- generator meta tag (bug #134) html.Append("<meta name=\"generator\" content=\"HatCMS " + CmsContext.currentHatCMSCoreVersion.ToString() + " - Open Source Content Management\" />" + Environment.NewLine); return(html.ToString()); }
protected string getText(CmsLanguage lang, string configKey, string dftValue) { string[] msgArray = CmsConfig.getConfigValue(configKey, dftValue).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); CmsLanguage[] langArray = CmsConfig.Languages; int x = CmsLanguage.IndexOf(lang.shortCode, langArray); if (msgArray.Length < langArray.Length || x < 0) { throw new Exception("Missing entry for " + configKey + "!"); } return(msgArray[x]); }
/// <summary> /// derive the file name on the web server disk /// </summary> /// <param name="aggregatorPage"></param> /// <param name="identifier"></param> /// <param name="fileName"></param> /// <returns></returns> public static string getTargetNameOnDisk(CmsPage fileDetailsPage, int identifier, CmsLanguage language, string fileName) { StringBuilder sb = new StringBuilder(getFileStorageFolderUrl(fileDetailsPage, identifier, language)); if (CmsConfig.getConfigValue("DMSFileStorageLocationVersion", "V1") == "V1") { sb.Append(fileDetailsPage.Id); sb.Append(identifier); } sb.Append(fileName); return(System.Web.Hosting.HostingEnvironment.MapPath(sb.ToString())); }