Exemplo n.º 1
0
		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>
");
		}
Exemplo n.º 2
0
		protected void DoHead()
		{
			AbsoluteTopicName topic = GetTopicName();	 
			LinkMaker lm = TheLinkMaker;

			if (Request.QueryString["version"] == null || Request.QueryString["version"] == "")
			{
				// Consider establishing a redirect if there's a redirect to a topic or an URL
				string redir = TheFederation.GetTopicProperty(GetTopicName(), "Redirect");
				if (redir != "")
				{
					string URI = null;
					if (IsAbsoluteURL(redir))
						URI = redir;
					else
					{
						// Might be a topic
						Regex name = new Regex(Formatter.wikiName);
						string trimmed = redir.Trim();
						if (name.IsMatch(trimmed))
						{
							RelativeTopicName rel = new RelativeTopicName(trimmed);
							IList all = TheFederation.ContentBaseForTopic(GetTopicName()).AllAbsoluteTopicNamesThatExist(rel);
							if (all.Count == 1)
								URI = lm.LinkToTopic((TopicName)(all[0]));
							else
							{
								if (all.Count == 0)
									Response.Write("<!-- Redirect topic does not exist -->\n");
								else
									Response.Write("<!-- Redirect topic is ambiguous -->\n");
							}
						}
					}
					if (URI != null)
					{
						if (Request.QueryString["DelayRedirect"] == "1")
							Response.Write(@"<meta http-equiv='refresh' content='10;URL=" + URI + "'>\n");
						else
							Response.Redirect(URI);
					}
				}

				string keywords = TheFederation.GetTopicProperty(GetTopicName(), "Keywords");
				if (keywords != "")
					Response.Write("<META name=\"keywords\" content=\"" + keywords + "\">\n");
				string description = TheFederation.GetTopicProperty(GetTopicName(), "Summary");
				if (description != "")
					Response.Write("<META name=\"description\" content=\"" + description + "\">\n");
				Response.Write("<META name=\"author\" content=\"" + TheFederation.GetTopicLastModifiedBy(GetTopicName()) + "\">\n");

			}
			else
			{
				// Don't index the versions
				Response.Write("<meta name=\"Robots\" content=\"NOINDEX, NOFOLLOW\">");
			}
        
			urlForDiffs = lm.LinkToTopic(topic, true);
			urlForNoDiffs = lm.LinkToTopic(topic, false);
		}
Exemplo n.º 3
0
		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>");
				}
			}
		}