/// <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
private string getItemDisplay(IndexableFileInfo fileInfo, string defaultOutputTemplate) { /* * Item Output Template String Format: * {0} = Page's Title * {1} = Page's MenuTitle * {2} = Page's relative URL * {3} = the search string snippet to display for this page * {4} = Page's breadcrumb created using MenuTitle's, concatenated using ' > ' spacers * {5} = "odd" or "even" * */ CmsPage targetPage = getPageFromIndex(fileInfo); // allow per-template ItemTemplates string itemOutputTemplate = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "ItemTemplate_" + targetPage.TemplateName, defaultOutputTemplate); string url = targetPage.Url; if (fileInfo.FilenameParameters != "") { if (url.IndexOf("?") > -1) { url += "&" + fileInfo.FilenameParameters; } else { url += "?" + fileInfo.FilenameParameters; } } string ItemBreadcrumb = getItemBreadcrumbOutput(targetPage); string OddOrEven = "even"; if (oddItem) { OddOrEven = "odd"; } oddItem = !oddItem; try { string ret = String.Format(itemOutputTemplate, targetPage.Title, targetPage.MenuTitle, url, StringUtils.StripHTMLTags(fileInfo.Contents), ItemBreadcrumb, OddOrEven); return(ret); } catch (Exception fEx) { throw new Exception("Search Item Display Template error (url: \"" + url + "\"); template: (" + itemOutputTemplate + ")"); } return(""); }
protected override void Render(HtmlTextWriter writer) { StringBuilder html = new StringBuilder(); string swh = "http://www.sadcwaterhub.org/glossary/feed?lang_tid[0]=2"; string url = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "rssurl", swh); int cacheDuration_hours = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "cacheduration_hours", 12); System.Web.Caching.Cache Cache = System.Web.Hosting.HostingEnvironment.Cache; Rss.RssFeed glossaryRss; // the RSS feed is cached to improve performance. if (cacheDuration_hours >= 0 && Cache[url] != null) { glossaryRss = (Rss.RssFeed)Cache[url]; } else { glossaryRss = Rss.RssFeed.Read(url); // add it to the cache if (cacheDuration_hours >= 0) { Cache.Insert(url, glossaryRss, null, DateTime.Now.AddHours(cacheDuration_hours), System.Web.Caching.Cache.NoSlidingExpiration); } } if (glossaryRss.Channels.Count == 0) { html.Append("<em>Error: could not retrieve Glossary from SADC Water Hub</em>"); } else { GlossaryData[] items = ToGlossaryData(glossaryRss.Channels[0].Items); GlossaryPlaceholderData phData = new GlossaryPlaceholderData(); phData.SortOrder = GlossaryPlaceholderData.GlossarySortOrder.byWord; phData.ViewMode = GlossaryPlaceholderData.GlossaryViewMode.PagePerLetter; string[] charsWithData = getCharsWithData(items); string letterToDisplay = Glossary.getLetterToDisplay(phData); if (letterToDisplay != "") { items = GlossaryData.getItemsStartingWithChar(items, letterToDisplay[0]); } html.Append(Glossary.GetHtmlDisplay(CmsContext.currentPage, items, phData, charsWithData, letterToDisplay)); } // else writer.Write(html.ToString()); }
protected override void Render(HtmlTextWriter writer) { StringBuilder html = new StringBuilder(); /// ORASECOM river basin SWISH documents: http://www.sadcwaterhub.org/documents/feed?source_tid_op=or&type_tid_op=or&icp_tid_op=or&rbo_tid_op=or&river_basin_tid_op=or&river_basin_tid[0]=68&title= string swh = "http://www.sadcwaterhub.org/documents/feed"; //all documents feed string url = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "rssurl", swh); int cacheDuration_hours = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "cacheduration_hours", 12); Rss.RssFeed documentsRss; // the RSS feed is cached to improve performance. System.Web.Caching.Cache Cache = System.Web.Hosting.HostingEnvironment.Cache; if (cacheDuration_hours >= 0 && Cache[url] != null) { documentsRss = (Rss.RssFeed)Cache[url]; } else { documentsRss = Rss.RssFeed.Read(url); // add it to the cache if (cacheDuration_hours >= 0) { Cache.Insert(url, documentsRss, null, DateTime.Now.AddHours(cacheDuration_hours), System.Web.Caching.Cache.NoSlidingExpiration); } } if (documentsRss.Channels.Count == 0) { html.Append("<em>Error: could not retrieve Documents RSS from " + url + "</em>"); } else { FileLibraryAggregator2.FileAggItem[] files = FileLibraryAggregator2.FileAggItem.FromRSSItems(documentsRss.Channels[0].Items); files = FileLibraryAggregator2.FileAggItem.RemoveDuplicates(new List <FileLibraryAggregator2.FileAggItem>(files)); files = FileLibraryAggregator2.FileAggItem.SortFilesByTitle(files); FileLibraryAggregator2.RenderParameters renderParameters = new FileLibraryAggregator2.RenderParameters(); renderParameters.fileLinkMode = FileLibraryAggregator2.RenderParameters.FileLinkMode.LinkToFile; renderParameters.ListingTitle = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "listingtitle", renderParameters.ListingTitle); renderParameters.ShowByCategory = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "showbycategory", renderParameters.ShowByCategory); html.Append(FileLibraryAggregator2.RenderToHtmlList(files, renderParameters, false)); } // else writer.Write(html.ToString()); }
protected override void Render(HtmlTextWriter writer) { DateTime currDateTime = DateTime.Now; int count = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "count", 3); CmsLanguage lang = CmsContext.currentLanguage; List <EventCalendarDb.EventCalendarDetailsData> list = new EventCalendarDb().fetchUpcomingEventDetails(currDateTime, lang, count); StringBuilder html = new StringBuilder("<div class=\"UpcomingEvents\">"); html.Append(renderUpcomingEventsHeader(lang)); html.Append(renderUpcomingEventsContent(lang, list)); html.Append("</div>"); writer.Write(html.ToString()); }
/// <summary> /// Retrieve the CmsPage (should be a calendar page) by reading the page ID from /// ##RenderControl(_system/SimpleCalendar calendarpage="...")## /// </summary> /// <returns></returns> protected CmsPage getCalendarPage() { int calendarPageId = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "calendarpage", -1); if (calendarPageId == -1) { throw new Exception("CMS Control parameter for 'SimpleCalendar' not found: 'calendarpage'"); } CmsPage page = CmsContext.getPageById(calendarPageId); if (page == null || page.TemplateName == null || !page.hasPlaceholder("EventCalendarAggregator")) { throw new Exception("##RenderControl(_system/SimpleCalendar calendarpage=\"...\")## is not a EventCalendarAggregator."); } return(page); }
/// <summary> /// renders the MostRecentNewsItem control to the HtmlTextWriter /// </summary> /// <param name="writer"></param> /// <param name="page"></param> /// <param name="identifier"></param> /// <param name="paramList"></param> protected override void Render(HtmlTextWriter writer) { /// Parameters: /// [newsIndex] index to display (integer) /// [template]: Output Template /// template parameters: url, summaryOutput, newsArticleDetailsPage.Title, dateOfNews /// {0} = url /// {1} = snippet /// {2} = title /// {3} = date /// [dateOutputFormat]: dateOutputFormat /// [summaryLength]: maxLengthOfSummary (integer) int indexToDisplay = 0; string template = "{3}: <a href=\"{0}\">{2}</a><br>{1}"; string dateOutputFormat = "MMMM d, yyyy"; int maxLengthOfSummary = 115; if (CmsConfig.TemplateEngineVersion == CmsTemplateEngineVersion.v2) { indexToDisplay = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "newsIndex", indexToDisplay); template = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "template", template); dateOutputFormat = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "dateFormat", dateOutputFormat); maxLengthOfSummary = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "summaryLength", maxLengthOfSummary); dateOutputFormat = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "dateOutputFormat", dateOutputFormat); } else { throw new ArgumentException("Invalid CmsTemplateEngineVersion"); } CmsLanguage lang = CmsContext.currentLanguage; int count = CmsConfig.getConfigValue("MostRecentNews.Count", 1); List <NewsArticleDb.NewsArticleDetailsData> articleArray = new NewsArticleDb().fetchNewsDetailsByCount(lang, indexToDisplay, count); StringBuilder html = new StringBuilder(); html.Append(renderHeader(lang)); html.Append(renderContent(articleArray, lang, template, maxLengthOfSummary, dateOutputFormat)); writer.Write(html.ToString()); } // Render
/// <summary> /// crawls up the page path to see if anything has been configured for that page. /// if nothing found, returns String.Empty. /// </summary> /// <param name="page"></param> /// <returns></returns> private string getImageByPagePath(CmsPage page) { CmsPage currPage = page; string notFoundValue = Guid.NewGuid().ToString(); while (currPage.ID != -1) { string PagePath = currPage.Path; string keyVal = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, PagePath, notFoundValue); if (keyVal != notFoundValue) { return(keyVal); } currPage = currPage.ParentPage; } // while return(String.Empty); } // getImageByPagePath
} // getImageByPagePath /// <summary> /// if nothing found, returns String.Empty /// </summary> /// <returns></returns> private string getRandomImage() { // -- get all the configured image vals string[] configKeys = CmsControlUtils.getControlParameterKeys(CmsContext.currentPage, this); ArrayList imgUrls = new ArrayList(); string notFoundValue = Guid.NewGuid().ToString(); foreach (string key in configKeys) { string val = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, key, notFoundValue); if (val != "" && val != notFoundValue && String.Compare(val, RandomImageKeyValue, true) != 0) { imgUrls.Add(val); } } // foreach // -- select the image at random if (imgUrls.Count > 0) { int randomUrlIndex = (new System.Random()).Next(0, imgUrls.Count - 1); return(imgUrls[randomUrlIndex].ToString()); } return(String.Empty); } // getRandomImage
protected override void Render(HtmlTextWriter writer) { StringBuilder html = new StringBuilder(); /// ORASECOM river basin SWISH news: http://www.sadcwaterhub.org/articles/feed?keywords=orange%20OR%20ORASECOM%20OR%20%22Orange-Senqu%22 string rssurl = "http://www.sadcwaterhub.org/articles/feed"; //all articles feed int cacheDuration_hours = 12; /// [template]: Output Template /// template parameters: url, summaryOutput, newsArticleDetailsPage.Title, dateOfNews /// {0} = url /// {1} = snippet /// {2} = title /// {3} = date /// [dateOutputFormat]: dateOutputFormat /// [summaryLength]: maxLengthOfSummary (integer) string itemTemplate = "<div class=\"RSSNewsItem\">{3}: <a href=\"{0}\">{2}</a><br>{1}</div>"; string dateOutputFormat = "MMMM d, yyyy"; int maxLengthOfSummary = 115; if (CmsConfig.TemplateEngineVersion == CmsTemplateEngineVersion.v2) { rssurl = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "rssurl", rssurl); cacheDuration_hours = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "cacheduration_hours", cacheDuration_hours); itemTemplate = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "template", itemTemplate); dateOutputFormat = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "dateFormat", dateOutputFormat); maxLengthOfSummary = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "summaryLength", maxLengthOfSummary); dateOutputFormat = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "dateOutputFormat", dateOutputFormat); } else { throw new ArgumentException("Invalid CmsTemplateEngineVersion"); } System.Web.Caching.Cache Cache = System.Web.Hosting.HostingEnvironment.Cache; Rss.RssFeed newsRss; // the RSS feed is cached to improve performance. if (cacheDuration_hours >= 0 && Cache[rssurl] != null) { newsRss = (Rss.RssFeed)Cache[rssurl]; } else { newsRss = Rss.RssFeed.Read(rssurl); // add it to the cache if (cacheDuration_hours >= 0) { Cache.Insert(rssurl, newsRss, null, DateTime.Now.AddHours(cacheDuration_hours), System.Web.Caching.Cache.NoSlidingExpiration); } } if (newsRss.Channels.Count == 0) { html.Append("<em>Error: could not retrieve News RSS from " + rssurl + "</em>"); } else if (newsRss.Channels.Count > 0 && newsRss.Channels[0].Items.Count == 0) { html.Append("<em>There are no news items available to view</em>"); } else { html.Append(GetArticleListHtml(newsRss.Channels[0].Items, itemTemplate, maxLengthOfSummary, dateOutputFormat)); } // else writer.Write(html.ToString()); }
public override bool controlExists(string controlNameOrPath) { return(CmsControlUtils.ControlExists(controlNameOrPath)); }
public override DateTime getControlLastModifiedDate(string controlNameOrPath) { return(CmsControlUtils.getControlLastModifiedDate(controlNameOrPath)); }
private string getSelectedParentPagePath(CmsPage controlsPage) { return(CmsControlUtils.getControlParameterKeyValue(controlsPage, this, "SelectedParentPagePath", "")); }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { CmsPage currentPage = CmsContext.currentPage; /* * Item Output Template String Format: * {0} = Page's Title * {1} = Page's MenuTitle * {2} = Page's relative URL * {3} = the search string snippet to display for this page * {4} = Page's breadcrumb created using MenuTitle's, concatenated using ' > ' spacers * {5} = "odd" or "even" * */ string defaultItemTemplate = "<div class=\"SearchResultItem {5}\"><a class=\"SearchResultItemLink\" href=\"{2}\">{0}</a><br/><blockquote class=\"SearchResultInfo\"><div class=\"Snippet\">{3}</div><div class=\"SearchResultItemBreadcrumb\">{4}</div></blockquote></div>"; string itemOutputTemplate = CmsControlUtils.getControlParameterKeyValue(CmsContext.currentPage, this, "ItemTemplate", defaultItemTemplate); string action = PageUtils.getFromForm("action", ""); StringBuilder html = new StringBuilder(); html.Append("<div class=\"SearchResults\">"); if (action == "re-Index All Pages" || action.ToLower() == "reindexall") { ReIndexAllPages(); html.Append("<p><strong>All Pages have been re-indexed</strong><p>"); } string noQuery = Guid.NewGuid().ToString(); string query = PageUtils.getFromForm("q", noQuery); html.Append("<div class=\"SearchBox\">"); // -- output search box string formId = "SearchResults"; html.Append(currentPage.getFormStartHtml(formId)); if (query == noQuery) { html.Append(PageUtils.getInputTextHtml("q", "queryBox", "", 20, 255)); } else { html.Append(PageUtils.getInputTextHtml("q", "queryBox", query, 20, 255)); } html.Append("<input type=\"submit\" value=\"search\">"); // -- output doIndex button if (CmsContext.currentUserIsSuperAdmin) { html.Append(" Admin:<input type=\"submit\" name=\"action\" value=\"re-Index All Pages\">"); } html.Append(currentPage.getFormCloseHtml(formId)); html.Append("</div>"); html.Append("<p>"); LuceneKeywordSearch search = new LuceneKeywordSearch(IndexStorageDirectory, SpellCheckIndexStorageDirectory); if (query != noQuery) { // -- do the search with keyword highlighting IndexableFileInfo[] fileInfos = search.doSearch(query, query); fileInfos = getFileInfosForCurrentLanguage(fileInfos); // -- output the results if (fileInfos.Length < 1) { // -- no results html.Append("<strong>Your search for \"" + query + "\" returned no results</strong>"); // -- get spelling suggestion string spellingSuggestion = search.getSpellingSuggestion(query); if (spellingSuggestion.Trim() != query.Trim()) { NameValueCollection p = new NameValueCollection(); p.Add("q", spellingSuggestion); string newSearchUrl = CmsContext.getUrlByPagePath(CmsContext.currentPage.Path, p); html.Append("<p><font color=\"#cc0000\">Did you mean:</font> \"<a href=\"" + newSearchUrl + "\">" + spellingSuggestion + "</a>\" <font color=\"#cc0000\">?</font></p>"); } } else { html.Append("<strong>Your search for \"" + query + "\" returned " + fileInfos.Length + " results</strong><p>"); html.Append("<p>" + getPagerOutput(fileInfos) + "</p>"); int startAtItemNumber = PageUtils.getFromForm("num", 0); if (startAtItemNumber >= fileInfos.Length) { startAtItemNumber = fileInfos.Length - 1; } int endAt = Math.Min(startAtItemNumber + numItemsPerPage - 1, fileInfos.Length - 1); if (startAtItemNumber == 0 && endAt == 0 && fileInfos.Length == 1) { html.Append(getItemDisplay(fileInfos[0], itemOutputTemplate)); } else { for (int i = startAtItemNumber; i <= endAt; i++) { if (endAt <= 0) { break; } IndexableFileInfo fileInfo = fileInfos[i]; html.Append(getItemDisplay(fileInfo, itemOutputTemplate)); } // for html.Append("<p>" + getPagerOutput(fileInfos) + "</p>"); } // else } } // if query != noQuery html.Append("</div>"); writer.WriteLine(html.ToString()); } // Render
private string getUnSelectedImage(CmsPage controlsPage) { return(CmsControlUtils.getControlParameterKeyValue(controlsPage, this, "UnSelectedImage", "")); }
private void renderCommand(System.Web.UI.UserControl parentUserControl, string command) { // command is the full command, such as ##Placeholder(HtmlContent id="1")## or ##RenderContro(_system/PageTitle)##. int parseFrom = command.IndexOf("(", StringComparison.CurrentCultureIgnoreCase); int parseTo = command.Length - ")".Length - COMMAND_DELIMITER.Length; string rawParameters = ""; Dictionary <string, string> parameters = new Dictionary <string, string>(); if (command.IndexOf("StartPageBody", StringComparison.CurrentCultureIgnoreCase) < 0 && command.IndexOf("EndPageBody", StringComparison.CurrentCultureIgnoreCase) < 0) { if (parseFrom < 0 || parseTo < 0) { throw new TemplateExecutionException(templateName, "Template statement \"" + command + "\" is not formatted properly."); } parseFrom += "(".Length; rawParameters = command.Substring(parseFrom, (parseTo - parseFrom)); parameters = tokenizeCommandParameters(rawParameters); } string langShortCode = ""; if (currentLangIndex < CmsConfig.Languages.Length) { langShortCode = CmsConfig.Languages[currentLangIndex].shortCode.ToLower().Trim(); } string langDivId = "lang_" + langShortCode; // note: this divId is used (hard-coded) all over the place!!! // -- only output multiple languages if we are in Edit mode bool outputMultipleLanguages = (CmsContext.currentEditMode == CmsEditMode.Edit); if (outputMultipleLanguages && command.StartsWith(COMMAND_DELIMITER + "StartPageBody", StringComparison.CurrentCultureIgnoreCase)) { // -- if the first StartPageBody, start the form - the same as in StartEditForm.ascx if (currentLangIndex == 0) { RenderTextToPage(parentUserControl, COMMAND_DELIMITER + "RenderControl(_system/StartEditForm)" + COMMAND_DELIMITER); } string cssStyle = "display: none;"; CmsLanguage langToRender = CmsConfig.Languages[currentLangIndex]; // -- default to view the current Language first if (langToRender == CmsContext.currentLanguage) { cssStyle = "display: block;"; } parentUserControl.Controls.Add(new LiteralControl("<!-- Start Language " + langDivId + " --> ")); parentUserControl.Controls.Add(new LiteralControl("<div id=\"" + langDivId + "\" class=\"" + langDivId + " PageLanguageBody\" style=\"" + cssStyle + "\">")); } else if (outputMultipleLanguages && command.StartsWith(COMMAND_DELIMITER + "EndPageBody", StringComparison.CurrentCultureIgnoreCase)) { parentUserControl.Controls.Add(new LiteralControl("</div>")); parentUserControl.Controls.Add(new LiteralControl("<!-- End Language " + langDivId + " --> ")); currentLangIndex++; // increment to the next language if (currentLangIndex < CmsConfig.Languages.Length) { string pageBody = getPageBodyText(); RenderTextToPage(parentUserControl, pageBody); } else { // -- the last EndPageBody, so close the edit form using the EndEditForm control RenderTextToPage(parentUserControl, COMMAND_DELIMITER + "RenderControl(_system/EndEditForm)" + COMMAND_DELIMITER); } } else if (command.StartsWith(COMMAND_DELIMITER + "PlaceholderRegion", StringComparison.CurrentCultureIgnoreCase)) { if (!parameters.ContainsKey("##commandname##")) { throw new TemplateExecutionException(templateName, "Template statement \"" + command + "\" must have at least one parameter!"); } string regionName = parameters["##commandname##"]; string regionCommands = getTemplatePlaceholderRegionText(regionName); RenderTextToPage(parentUserControl, regionCommands); } else if (command.StartsWith(COMMAND_DELIMITER + "placeholder", StringComparison.CurrentCultureIgnoreCase)) { // AddControlToPage(new LiteralControl("placeholder: " + rawParameters)); if (!parameters.ContainsKey("##commandname##")) { throw new TemplateExecutionException(templateName, "Template statement \"" + command + "\" must have at least one parameter!"); } string placeholderName = parameters["##commandname##"]; if (!parameters.ContainsKey("id")) { throw new TemplateExecutionException(templateName, "The placeholder statement must have an id attribute (\"" + command + "\")."); } int identifier = -1; try { identifier = Convert.ToInt32(parameters["id"]); } catch { throw new TemplateExecutionException(templateName, "The placeholder statement must have an integer id attribute (\"" + command + "\")."); } // do not output if: // 1) we are making a printer friendly version, and the placeholder has its printer friendly parameter name set to false. // 2) we are making an offline version, and the placeholder has its offline version parameter name set to false. bool doNotOutput = ( /* print friendly version: */ (CmsContext.currentUserIsRequestingPrintFriendlyVersion && parameters.ContainsKey(PRINTER_FRIENDLY_VERSION_OUTPUT_CONTROL_PARAMETERNAME) && String.Compare(parameters[PRINTER_FRIENDLY_VERSION_OUTPUT_CONTROL_PARAMETERNAME], "false", true) == 0) || /* offline version: */ (CmsContext.currentUserIsRequestingPrintFriendlyVersion && parameters.ContainsKey(OFFLINE_VERSION_OUTPUT_CONTROL_PARAMETERNAME) && String.Compare(parameters[OFFLINE_VERSION_OUTPUT_CONTROL_PARAMETERNAME], "false", true) == 0)); if (!doNotOutput) { // params[0] contains the rawParameters string[] subParamsArray = new string[] { rawParameters }; System.Text.StringBuilder sb = new System.Text.StringBuilder(); HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(sb)); CmsLanguage langToRender = CmsConfig.Languages[currentLangIndex]; // the currentLangIndex is incremented when the EndPageBody statement is found in the template // dynamically load the Placeholder class and call its Render method switch (CmsContext.currentEditMode) { case CmsEditMode.Edit: PlaceholderUtils.RenderInEditMode(placeholderName, writer, page, identifier, langToRender, subParamsArray, templateName); break; case CmsEditMode.View: PlaceholderUtils.RenderInViewMode(placeholderName, writer, page, identifier, langToRender, subParamsArray, templateName); break; } string txt = sb.ToString(); // -- Run Placeholder Filters txt = CmsOutputFilterUtils.RunPlaceholderFilters(placeholderName, page, txt); LiteralControl literal = new LiteralControl(txt); parentUserControl.Controls.Add(literal); } } else if (command.StartsWith(COMMAND_DELIMITER + "rendercontrol", StringComparison.CurrentCultureIgnoreCase)) { if (!parameters.ContainsKey("##commandname##")) { throw new TemplateExecutionException(templateName, "Template statement \"" + command + "\" must have at least one parameter!"); } string controlNameOrPath = parameters["##commandname##"]; // -- try to dynamically load the control onto the page from the ASCX file. // if the ASCX file is not found, we try to load the control as a class. If that fails, throw an Exception if (CmsControlUtils.ControlExists(controlNameOrPath)) { // do not output if: // 1) we are making a printer friendly version, and the control has its printer friendly parameter name set to false. // 2) we are making an offline version, and the control has its offline version parameter name set to false. bool doNotOutput = ( /* print friendly version: */ (CmsContext.currentUserIsRequestingPrintFriendlyVersion && parameters.ContainsKey(PRINTER_FRIENDLY_VERSION_OUTPUT_CONTROL_PARAMETERNAME) && String.Compare(parameters[PRINTER_FRIENDLY_VERSION_OUTPUT_CONTROL_PARAMETERNAME], "false", true) == 0) || /* offline version: */ (CmsContext.currentUserIsRequestingPrintFriendlyVersion && parameters.ContainsKey(OFFLINE_VERSION_OUTPUT_CONTROL_PARAMETERNAME) && String.Compare(parameters[OFFLINE_VERSION_OUTPUT_CONTROL_PARAMETERNAME], "false", true) == 0)); if (!doNotOutput) { int langIndex = currentLangIndex; if (langIndex >= CmsConfig.Languages.Length) { langIndex = 0; } CmsLanguage langToRender = CmsConfig.Languages[langIndex]; // the currentLangIndex is incremented when the EndPageBody statement is found in the template CmsControlDefinition controlDef = new CmsControlDefinition(controlNameOrPath, rawParameters); CmsControlUtils.AddControlToPage(controlNameOrPath, controlDef, parentUserControl, langToRender); } } else { string ControlNotFoundMessage = "Could not find or load Control: \"" + controlNameOrPath + "\""; throw new TemplateExecutionException(templateName, ControlNotFoundMessage); } } // renderRonctol }
} // getControlParameterKeys public bool parameterKeyExists(CmsPage page, CmsControlDefinition controlDefinition, string keyNameToFind) { return(CmsControlUtils.hasControlParameterKey(page, controlDefinition, keyNameToFind)); }
public static string[] getParameterKeys(CmsPage page, CmsControlDefinition controlDefinition) { return(CmsControlUtils.getControlParameterKeys(page, controlDefinition)); } // getControlParameterKeys
} // getParameterValue public static string getParameterValue(CmsPage page, CmsControlDefinition controlDefinition, string key, string defaultValue) { return(CmsControlUtils.getControlParameterKeyValue(page, controlDefinition, key, defaultValue)); }