protected void DoSearch() { string defaultNamespace = Request.QueryString["QuickLinkNamespace"]; ContentBase cb = TheFederation.ContentBaseForNamespace(defaultNamespace); LinkMaker lm = TheLinkMaker; RelativeTopicName topic = new RelativeTopicName(Request.Form["QuickLink"]); IList hits = cb.AllAbsoluteTopicNamesThatExist(topic); string target = null; if (hits.Count == 0) { // No hits, create it in the default namespace target = lm.LinkToEditTopic(topic.AsAbsoluteTopicName(defaultNamespace)); } else if (hits.Count == 1) { // 1 hit; take it! NameValueCollection extras = new NameValueCollection(); extras.Add("DelayRedirect", "1"); target = lm.LinkToTopic((TopicName)(hits[0]), false, extras); } // If we have a target, go there if (target != null) { // Response.Write(target); Response.Redirect(target); return; } // Uh, oh -- we're here because the name is ambiguous Response.Write(@" <!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"" > <HTML> <HEAD> <title id='title'>Topic is ambiguous</title> <LINK href='<%= RootUrl(Request) %>wiki.css' type='text/css' rel='stylesheet'> </HEAD> <p>The topic name you selected is ambiguous because it already exists in multiple namespaces. Please select the one you want: <ul>"); foreach (AbsoluteTopicName each in hits) Response.Write("<li><a href='" + lm.LinkToTopic(each) + "'>" + each.Fullname + "</a></li>"); Response.Write(@" </ul> </body> </HTML> "); }
protected void DoPage() { LinkMaker lm = TheLinkMaker; string [] topics = ((string)(Request.QueryString["topics"])).Split (new char[] {','}); string [] fields = ((string)(Request.QueryString["properties"])).Split (new char[] {','}); foreach (string topic in topics) { RelativeTopicName rel = new RelativeTopicName(topic); AbsoluteTopicName abs; IList tops = DefaultContentBase.AllAbsoluteTopicNamesThatExist(rel); if (tops.Count == 0) { abs = rel.AsAbsoluteTopicName(DefaultContentBase.Namespace); // topic doesn't exist, assume in the wiki's home content base } else if (tops.Count > 1) { throw TopicIsAmbiguousException.ForTopic(rel); } else // we got just one! { abs = (AbsoluteTopicName)tops[0]; } foreach (string field in fields) { string fieldName; string fieldClass; fieldName = field; fieldClass = null; if (fieldAndClass.IsMatch(field)) { Match fieldAndClassMatch = fieldAndClass.Match(field); fieldName = fieldAndClassMatch.Groups["name"].Value; fieldClass = fieldAndClassMatch.Groups["class"].Value; } string ns = DefaultContentBase.UnambiguousTopicNamespace(abs); string fieldValue = TheFederation.GetTopicProperty(abs, fieldName); string s1; if (fieldName == "_Body") s1 = Formatter.FormattedString(abs, fieldValue, OutputFormat.HTML, TheFederation.ContentBaseForNamespace(ns), TheLinkMaker, null); else s1 = fieldValue; // YUCK! We need to wrap the enclosing <p> (if present) and replace it with the <div> s1 = s1.Trim(); if (s1.StartsWith("<p>")) s1 = s1.Substring(3); if (s1.EndsWith("</p>")) s1 = s1.Substring(0, s1.Length - 4); Response.Write("<div"); if (fieldClass != null) Response.Write(" class='" + fieldClass + "'"); Response.Write(">" + s1 + "</div>"); } } }