Fixed and closed #499 : SpecialTagRegex is not processed if Format is called with forIndexing=true.

This commit is contained in:
Matteo Tomasini 2010-04-09 14:56:34 +00:00
parent bb4229e60a
commit acfc1ad983
2 changed files with 70 additions and 68 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.2.531")] [assembly: AssemblyVersion("3.0.2.532")]
[assembly: AssemblyFileVersion("3.0.2.531")] [assembly: AssemblyFileVersion("3.0.2.532")]

View file

@ -278,73 +278,75 @@ namespace ScrewTurn.Wiki {
while(match.Success) { while(match.Success) {
if(!IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end)) { if(!IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end)) {
sb.Remove(match.Index, match.Length); sb.Remove(match.Index, match.Length);
switch(match.Value.Substring(1, match.Value.Length - 2).ToUpperInvariant()) { if(!forIndexing) {
case "WIKITITLE": switch(match.Value.Substring(1, match.Value.Length - 2).ToUpperInvariant()) {
sb.Insert(match.Index, Settings.WikiTitle); case "WIKITITLE":
break; sb.Insert(match.Index, Settings.WikiTitle);
case "WIKIVERSION": break;
sb.Insert(match.Index, Settings.WikiVersion); case "WIKIVERSION":
break; sb.Insert(match.Index, Settings.WikiVersion);
case "MAINURL": break;
sb.Insert(match.Index, Settings.MainUrl); case "MAINURL":
break; sb.Insert(match.Index, Settings.MainUrl);
case "RSSPAGE": break;
if(current != null) { case "RSSPAGE":
sb.Insert(match.Index, @"<a href=""" + if(current != null) {
UrlTools.BuildUrl("RSS.aspx?Page=", Tools.UrlEncode(current.FullName)) + sb.Insert(match.Index, @"<a href=""" +
@""" title=""" + Exchanger.ResourceExchanger.GetResource("RssForThisPage") + @"""><img src=""" + UrlTools.BuildUrl("RSS.aspx?Page=", Tools.UrlEncode(current.FullName)) +
Settings.GetThemePath(Tools.DetectCurrentNamespace()) + @"Images/RSS.png"" alt=""RSS"" /></a>"); @""" title=""" + Exchanger.ResourceExchanger.GetResource("RssForThisPage") + @"""><img src=""" +
} Settings.GetThemePath(Tools.DetectCurrentNamespace()) + @"Images/RSS.png"" alt=""RSS"" /></a>");
break; }
case "THEMEPATH": break;
sb.Insert(match.Index, Settings.GetThemePath(Tools.DetectCurrentNamespace())); case "THEMEPATH":
break; sb.Insert(match.Index, Settings.GetThemePath(Tools.DetectCurrentNamespace()));
case "CLEAR": break;
sb.Insert(match.Index, @"<div style=""clear: both;""></div>"); case "CLEAR":
break; sb.Insert(match.Index, @"<div style=""clear: both;""></div>");
case "BR": break;
//if(!AreSingleLineBreaksToBeProcessed()) sb.Insert(match.Index, "<br />"); case "BR":
sb.Insert(match.Index, "<br />"); //if(!AreSingleLineBreaksToBeProcessed()) sb.Insert(match.Index, "<br />");
break; sb.Insert(match.Index, "<br />");
case "TOP": break;
sb.Insert(match.Index, @"<a href=""#PageTop"">" + Exchanger.ResourceExchanger.GetResource("Top") + "</a>"); case "TOP":
break; sb.Insert(match.Index, @"<a href=""#PageTop"">" + Exchanger.ResourceExchanger.GetResource("Top") + "</a>");
case "SEARCHBOX": break;
string textBoxId = "SB" + Guid.NewGuid().ToString("N"); case "SEARCHBOX":
string textBoxId = "SB" + Guid.NewGuid().ToString("N");
string nsstring = ns != null ? NameTools.GetFullName(ns.Name, "Search") + ".aspx" : "Search.aspx"; string nsstring = ns != null ? NameTools.GetFullName(ns.Name, "Search") + ".aspx" : "Search.aspx";
string doSearchFunction = "<nowiki><nobr><script type=\"text/javascript\"><!--\r\n" + @"function _DoSearch_" + textBoxId + "() { document.location = '" + nsstring + @"?AllNamespaces=1&FilesAndAttachments=1&Query=' + encodeURI(document.getElementById('" + textBoxId + "').value); }" + "\r\n// -->\r\n</script>"; string doSearchFunction = "<nowiki><nobr><script type=\"text/javascript\"><!--\r\n" + @"function _DoSearch_" + textBoxId + "() { document.location = '" + nsstring + @"?AllNamespaces=1&FilesAndAttachments=1&Query=' + encodeURI(document.getElementById('" + textBoxId + "').value); }" + "\r\n// -->\r\n</script>";
sb.Insert(match.Index, doSearchFunction + sb.Insert(match.Index, doSearchFunction +
@"<input class=""txtsearchbox"" type=""text"" id=""" + textBoxId + @""" onkeydown=""javascript:var keycode; if(window.event) keycode = event.keyCode; else keycode = event.which; if(keycode == 10 || keycode == 13) { _DoSearch_" + textBoxId + @"(); return false; }"" /> <big><a href=""#"" onclick=""javascript:_DoSearch_" + textBoxId + @"(); return false;"">&raquo;</a></big></nowiki></nobr>"); @"<input class=""txtsearchbox"" type=""text"" id=""" + textBoxId + @""" onkeydown=""javascript:var keycode; if(window.event) keycode = event.keyCode; else keycode = event.which; if(keycode == 10 || keycode == 13) { _DoSearch_" + textBoxId + @"(); return false; }"" /> <big><a href=""#"" onclick=""javascript:_DoSearch_" + textBoxId + @"(); return false;"">&raquo;</a></big></nowiki></nobr>");
break; break;
case "CATEGORIES": case "CATEGORIES":
List<CategoryInfo> cats = Pages.GetCategories(ns); List<CategoryInfo> cats = Pages.GetCategories(ns);
string pageName = ns != null ? NameTools.GetFullName(ns.Name, "AllPages") + ".aspx" : "AllPages.aspx"; string pageName = ns != null ? NameTools.GetFullName(ns.Name, "AllPages") + ".aspx" : "AllPages.aspx";
pageName += "?Cat="; pageName += "?Cat=";
string categories = "<ul><li>" + string.Join("</li><li>", string categories = "<ul><li>" + string.Join("</li><li>",
(from c in cats (from c in cats
select "<a href=\"" + pageName + Tools.UrlEncode(c.FullName) + "\">" + NameTools.GetLocalName(c.FullName) + "</a>").ToArray()) + "</li></ul>"; select "<a href=\"" + pageName + Tools.UrlEncode(c.FullName) + "\">" + NameTools.GetLocalName(c.FullName) + "</a>").ToArray()) + "</li></ul>";
sb.Insert(match.Index, categories); sb.Insert(match.Index, categories);
break; break;
case "CLOUD": case "CLOUD":
string cloud = BuildCloud(DetectNamespaceInfo(current)); string cloud = BuildCloud(DetectNamespaceInfo(current));
sb.Insert(match.Index, cloud); sb.Insert(match.Index, cloud);
break; break;
case "PAGECOUNT": case "PAGECOUNT":
sb.Insert(match.Index, Pages.GetPages(DetectNamespaceInfo(current)).Count.ToString()); sb.Insert(match.Index, Pages.GetPages(DetectNamespaceInfo(current)).Count.ToString());
break; break;
case "PAGECOUNT(*)": case "PAGECOUNT(*)":
sb.Insert(match.Index, Pages.GetGlobalPageCount().ToString()); sb.Insert(match.Index, Pages.GetGlobalPageCount().ToString());
break; break;
case "ORPHANS": case "ORPHANS":
if(!forIndexing) sb.Insert(match.Index, BuildOrphanedPagesList(DetectNamespaceInfo(current), context, current)); sb.Insert(match.Index, BuildOrphanedPagesList(DetectNamespaceInfo(current), context, current));
break; break;
case "WANTED": case "WANTED":
sb.Insert(match.Index, BuildWantedPagesList(DetectNamespaceInfo(current))); sb.Insert(match.Index, BuildWantedPagesList(DetectNamespaceInfo(current)));
break; break;
case "NAMESPACELIST": case "NAMESPACELIST":
sb.Insert(match.Index, BuildNamespaceList()); sb.Insert(match.Index, BuildNamespaceList());
break; break;
}
} }
} }
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd); ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);