コード例 #1
0
ファイル: TopicRevision.cs プロジェクト: nuxleus/flexwiki
        public TopicRevision(string revision)
        {
            if (revision == null)
            {
                throw new ArgumentException("topic cannot be null"); 
            }

            // start by triming off the version if present
            _version = null;
            if (revision.EndsWith(")"))
            {
                int open = revision.IndexOf("(");
                if (open >= 0)
                {
                    _version = revision.Substring(open + 1, revision.Length - open - 2);
                    if (_version == "")
                    {
                        _version = null;
                    }
                    revision = revision.Substring(0, open);
                }
            }

            _topicName = new TopicName(revision); 

        }
コード例 #2
0
ファイル: DynamicNamespace.cs プロジェクト: nuxleus/flexwiki
		public DynamicTopic DynamicTopicFor(string topic)
		{
            if (_topics == null)
            {
                _topics = new Hashtable();
            }
			DynamicTopic answer = (DynamicTopic)(_topics[topic]);
            if (answer != null)
            {
                return answer;
            }

            TopicName topicName = new TopicName(topic); 

            NamespaceManager manager = CurrentFederation.NamespaceManagerForNamespace(Namespace);
            QualifiedTopicNameCollection alternatives = manager.AllPossibleQualifiedTopicNames(topicName); 

			foreach (QualifiedTopicName tn in alternatives)
			{
				NamespaceManager namespaceManager = CurrentFederation.NamespaceManagerForTopic(tn);
				if (!namespaceManager.TopicExists(tn.LocalName, ImportPolicy.DoNotIncludeImports))
					continue;
				answer = new DynamicTopic(CurrentFederation, new QualifiedTopicRevision(tn));
				_topics[topic] = answer;
				return answer;
			}
			return null;
		}
コード例 #3
0
 internal static FlexWikiException NamespaceDoesNotExist(TopicName topic)
 {
     if (topic == null)
     {
         return new FlexWikiException("A null topic name was specified.");
     }
     return new FlexWikiException("The namespace " + (topic.Namespace ?? "<<null>>") +
         " does not exist.");
 }
コード例 #4
0
 internal static FlexWikiException VersionDoesNotExist(TopicName topic, string version)
 {
     if (topic == null)
     {
         return new FlexWikiException("A null topic name was specified.");
     }
     return new FlexWikiException(string.Format("Topic {0} does not have a version {1}.",
         topic.DottedName,
         version ?? "<<null>>"));
 }
コード例 #5
0
        internal static FlexWikiException QualifiedTopicNameExpected(TopicName topicName)
        {
            if (topicName == null)
            {
                return new FlexWikiException("A null topic name was specified where a fully qualified topic name was expected.");
            }

            return new FlexWikiException("A topic name without a namespace was specified where a fully-qualified topic name was expected. The topic name was " +
                topicName.LocalName ?? "<<null>>");
        }
コード例 #6
0
ファイル: PrintTopic.cs プロジェクト: nuxleus/flexwikicore
        static void Print(Federation federation, TopicName topic)
        {
            string formattedBody = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);

            // Now calculate the borders
            string leftBorder = federation.GetTopicFormattedBorder(topic, Border.Left);
            string rightBorder =federation.GetTopicFormattedBorder(topic, Border.Right);
            string topBorder = federation.GetTopicFormattedBorder(topic, Border.Top);
            string bottomBorder = federation.GetTopicFormattedBorder(topic, Border.Bottom);

            //			Console.Out.WriteLine(formattedBody);
        }
コード例 #7
0
        // Constructors
        public TopicVersionKey(string name)
        {
            if (name == null)
            {
                throw new ArgumentException("topic cannot be null", "topic");
            }

            // start by triming off the version if present
            _version = null;
            if (name.EndsWith(")"))
            {
                int open = name.IndexOf("(");
                if (open >= 0)
                {
                    _version = name.Substring(open + 1, name.Length - open - 2);
                    if (_version == "")
                        _version = null;
                    name = name.Substring(0, open);
                }
            }

            _topicName = new TopicName(name);
        }
コード例 #8
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwikicore
        private string LinkWikiNames(string input)
        {
            StringBuilder answer = new StringBuilder();

            string str = input;
            ArrayList processed = new ArrayList();
            while (str.Length > 0)
            {
                Match m = extractWikiLinks.Match(str);
                if (!m.Success)
                    break;
                string each = m.Groups["topic"].ToString();
                string before = m.Groups["before"].ToString();
                string after = m.Groups["after"].ToString();
                string relabel = m.Groups["relabel"].ToString();
                string anchor = m.Groups["anchor"].ToString();

                TopicName relName = new TopicName(TopicParser.StripTopicNameEscapes(each));

                // Ignore apparent links to non-existent namespaces.
                if ((null == relName.Namespace) || (null != Federation.NamespaceManagerForNamespace(relName.Namespace)))
                {
                    // Build a list of all the possible qualified names for this topic
                    QualifiedTopicNameCollection qualifiedNames = new QualifiedTopicNameCollection();
                    // Start with the singulars in the various reachable namespaces, then add the plurals
                    qualifiedNames.AddRange(Federation.AllQualifiedTopicNamesThatExist(relName, NamespaceManager.Namespace, AlternatesPolicy.IncludeAlternates));

                    // Now see if we got any hits or not
                    string rep = beforeOrRelabel + "(" + RegexEscapeTopic(each) + ")" + s_afterWikiName;
                    TopicRevision appearedAs = new TopicRevision(each);  // in case it was a plural form, be sure to show it as it appeared
                    string displayname = TopicParser.StripTopicNameEscapes((NamespaceManager.DisplaySpacesInWikiLinks ? appearedAs.FormattedName : appearedAs.LocalName));
                    if (relabel.Length > 0)
                    {
                        displayname = relabel;
                    }

                    if (qualifiedNames.Count == 0)
                    {
                        if (!IsUnbracketedOneWordName(each))
                        {
                            // It doesn't exist, so give the option to create it
                            TopicName abs = relName.ResolveRelativeTo(NamespaceManager.Namespace);
                            //XHTML bug when str is enclosed in an wrapping anchor - property with undefined WikiTopic
                            str = ReplaceMatch(answer, str, m, before + "<a title=\"Click here to create this topic\" class=\"create\" href=\"" + LinkMaker().LinkToEditTopic(abs) + "\">" + displayname + "</a>" + after);
                        }
                        else
                        {
                            str = ReplaceMatch(answer, str, m, m.Value);
                        }
                    }
                    else
                    {
                        // We got hits, let's add links

                        if (qualifiedNames.Count == 1)
                        {
                            // The simple case is that there's only one link to point to, so we output just a normal link
                            TopicName abs = qualifiedNames[0];
                            string tip = TipForTopic(abs);
                            string tipid = null;
                            string tipHTML = null;
                            bool defaultTip = tip == null;
                            if (defaultTip)
                            {
                                tip = "Click to read this topic";
                            }
                            tipid = NewUniqueIdentifier();
                            tipHTML = Formatter.EscapeHTML(tip);
                            if (defaultTip)
                            {
                                tipHTML = "<span class=\"DefaultTopicTipText\">" + tipHTML + "</span>";
                            }
                            // No point in trying to show author and modification time if we don't have
                            // read permission on the link target: it'll just throw an exception if we
                            // try to get them.
                            if (Federation.HasPermission(new QualifiedTopicRevision(abs.DottedName), TopicPermission.Read))
                            {
                                tipHTML += "<div class=\"TopicTipStats\">" + Federation.GetTopicLastModificationTime(abs).ToString();
                                string lastAuthor = Federation.GetTopicLastModifiedBy(abs);
                                if (string.IsNullOrEmpty(lastAuthor))
                                {
                                    lastAuthor = "author unknown";
                                }
                                tipHTML += " - " + lastAuthor + "</div>";
                            }
                            tipHTML = "<div id=\"" + tipid + "\" style=\"display: none\">" + tipHTML + "</div>";
                            Output.AddToFooter(tipHTML);
                            string replacement = "<a ";
                            if (tip != null)
                            {
                                replacement += "onmouseover=\"TopicTipOn(this, '" + tipid + "', event);\" onmouseout=\"TopicTipOff();\" ";
                            }
                            replacement += "href=\"" + LinkMaker().LinkToTopic(abs.DottedName);
                            if (anchor.Length > 0)
                            {
                                replacement += "#" + anchor;
                                if (0 == relabel.Length)
                                {
                                    displayname += "#" + anchor;
                                }
                            }
                            replacement += "\">" + displayname + "</a>";
                            str = ReplaceMatch(answer, str, m, before + replacement + after);
                        }
                        else
                        {
                            // There's more than one; we need to generate a dynamic menu
                            string clickEvent;
                            clickEvent = "onclick=\"javascript:LinkMenu(new Array(";
                            bool first = true;
                            foreach (TopicName eachAbs in qualifiedNames)
                            {
                                if (!first)
                                    clickEvent += ", ";
                                first = false;
                                clickEvent += "new Array('" + eachAbs + "', '" + LinkMaker().LinkToTopic(eachAbs) + "')";
                            }
                            clickEvent += "), event);\"";

                            str = ReplaceMatch(answer, str, m, before + "<a title=\"Different versions of this topic exist.  Click to pick one.\" " + clickEvent + ">" + displayname + "</a>" + after);
                        }
                    }
                }
                else
                {
                    str = ReplaceMatch(answer, str, m, before + relName.DottedName + after);
                }
            }

            // Add on whatever's not yet been consumed
            answer.Append(str);
            return answer.ToString();
        }
コード例 #9
0
 public QualifiedTopicRevision(TopicName topic) : this(topic.LocalName, topic.Namespace)
 {
 }
コード例 #10
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
 public string LinkToTopic(TopicName topic)
 {
     return LinkToTopic(topic.DottedName); 
 }
コード例 #11
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToRestore(TopicName topic)
		{
			return RestoreLink(topic.FullnameWithVersion);
		}
コード例 #12
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToLogoff(TopicName topic)
		{
			return LinkToLogoff(topic);
		}
コード例 #13
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToTopic(TopicName topic, bool showDiffs, NameValueCollection extraQueryParms)
		{
			return TopicLink(topic.FullnameWithVersion, showDiffs, extraQueryParms);
		}
コード例 #14
0
ファイル: Federation.cs プロジェクト: nuxleus/flexwiki
 public string GetTopicPropertyValue(TopicName topic, string property)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
ファイル: Federation.cs プロジェクト: nuxleus/flexwiki
        public TopicProperty GetTopicProperty(TopicName topic, string property)
        {
            NamespaceManager manager = NamespaceManagerForTopic(topic);

            if (manager == null)
            {
                throw FlexWikiException.NamespaceDoesNotExist(topic); 
            }

            return manager.GetTopicProperty(topic.LocalName, property); 
        }
コード例 #16
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToTopic(TopicName topic)
		{
			return LinkToTopic(topic, false);
		}
コード例 #17
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToTopic(TopicName topic, bool showDiffs)
		{
			return TopicLink(topic.FullnameWithVersion, showDiffs, null);
		}
コード例 #18
0
ファイル: Federation.cs プロジェクト: nuxleus/flexwiki
        public string Read(TopicName topic)
        {
            if (topic.IsQualified)
            {
                return Read(new QualifiedTopicRevision(topic)); 
            }

            throw FlexWikiException.QualifiedTopicNameExpected(topic); 
        }
コード例 #19
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToLogin(TopicName topic)
		{
			return LinkToLogin(topic.FullnameWithVersion);
		}
コード例 #20
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer true if the given topic exists in this ContentBase or in an imported namespace (if it's relative), or any namespace (if it's absolute)
		/// </summary>
		/// <param name="topic">The topic to check for</param>
		/// <returns>true if the topic exists</returns>
		public bool TopicExists(TopicName topic)
		{
			// Is it here?
			if (topic.Namespace == Namespace)
				return TopicExistsLocally(topic.LocalName);

			// Is it absolute, so we can just ask the Fed?
			if (topic.Namespace != null)
				return Federation.TopicExists(topic.AsAbsoluteTopicName(Namespace));

			// If the namespace is unspecified, it could just be in this one
			if (topic.Namespace == null && TopicExistsLocally(topic.LocalName))
				return true;

			// Is it in an imported namespace?
			foreach (string ns in ImportedNamespaces)
			{
				if (topic.Namespace != null && ns != topic.Namespace)
					continue;
				ContentBase cb = Federation.ContentBaseForNamespace(ns);
				if (cb == null)
					continue;
				if (cb.TopicExistsLocally(topic.LocalName))
					return true;
			}
			return false;
		}
コード例 #21
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
		public string LinkToPrintView(TopicName topic)
		{
			return PrintLink(topic.FullnameWithVersion);
		}
コード例 #22
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer a collection of namespaces in which the topic actually exists
		/// </summary>
		/// <param name="topic">The topic you want to search for in all namespaces (might be relative, in which case it's relative to this content base)</param>
		/// <returns>A list of namespaces (as strings); empty if none</returns>
		public IList TopicNamespaces(TopicName topic)
		{
			ArrayList answer = new ArrayList();
			foreach (AbsoluteTopicName each in topic.AllAbsoluteTopicNamesFor(this))
			{
				if (TopicExists(each))
					answer.Add(each.Namespace);
			}
			return answer;
		}
コード例 #23
0
ファイル: FileSystemStore.cs プロジェクト: nuxleus/flexwiki
		static string MakeTopicFilename(TopicName topic)
		{
			if (topic.Version == null)
				return topic.Name + ".wiki";
			else
				return topic.Name + "(" + topic.Version + ").awiki";
		}
コード例 #24
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		public CacheRule CacheRuleForAllPossibleInstancesOfTopic(TopicName aName)
		{
			TopicsCacheRule rule = new TopicsCacheRule(Federation);
			foreach (AbsoluteTopicName possible in aName.AllAbsoluteTopicNamesFor(this))
				rule.AddTopic(possible);

			CompositeCacheRule answer = new CompositeCacheRule();
			answer.Add(rule);
			answer.Add(CacheRuleForDefinition);		// Add the cache rule for the content base, too, since if that changes there might be a change in imports
			return answer;
		}
コード例 #25
0
ファイル: LinkMaker.cs プロジェクト: nuxleus/flexwiki
 public string LinkToEditTopic(TopicName topic)
 {
     return EditLink(topic.DottedName);
 }
コード例 #26
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer the full name of the topic (qualified with namespace) if it exists.  If it doesn't exist at all, answer null
		/// If it does, but it's ambiguous, then throw TopicIsAmbiguousException
		/// </summary>
		/// <param name="topic"></param>
		/// <returns>Full name or null if it doesn't exist (by throw TopicIsAmbiguousException if it's ambiguous)</returns>
		public AbsoluteTopicName UnambiguousTopicNameFor(TopicName topic)
		{
			IList list = TopicNamespaces(topic);
			if (list.Count == 0)
				return null;
			if (list.Count > 1)
				throw TopicIsAmbiguousException.ForTopic(topic);
			return new AbsoluteTopicName(topic.Name, (string)list[0]);
		}
コード例 #27
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwiki
		private string IncludedTopic(TopicName topic, int headingLevelBase)
		{
			// TODO: how do we identify specific versions? [maybe this just works now? since versionids are a formal part of a wikiname???]
			// TODO: how do we show diffs?
			string ns = ContentBase.UnambiguousTopicNamespace(topic);
			ContentBase containingContentBase = TheFederation.ContentBaseForNamespace(ns);
			AbsoluteTopicName abs = new AbsoluteTopicName(topic.Name, ns);
			string content = containingContentBase.Read(abs.LocalName).TrimEnd();
			WikiOutput output = WikiOutput.ForFormat(_Output.Format, Output);
			Formatter.Format(abs, content, output, ContentBase, LinkMaker(), _ExternalWikiMap, headingLevelBase, CacheRuleAccumulator);
			return output.ToString().Trim();
		}
コード例 #28
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer the namespace that the topic lives in.  It might be unambiguous, in which case TopicIsAmbiguousException will be thrown
		/// </summary>
		/// <param name="topic"></param>
		/// <returns></returns>
		public string UnambiguousTopicNamespace(TopicName topic)
		{
			IList list = TopicNamespaces(topic);
			if (list.Count == 0)
				return null;
			if (list.Count > 1)
				throw TopicIsAmbiguousException.ForTopic(topic);
			string answer = null;
			foreach (string ns in list)
				answer = ns;
			return answer;
		}
コード例 #29
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwikicore
 private string TipForTopic(TopicName topic)
 {
     QualifiedTopicRevision revision = new QualifiedTopicRevision(topic.LocalName, topic.Namespace);
     if (!Federation.HasPermission(revision, TopicPermission.Read))
     {
         return "You do not have read permission on topic " + topic.DottedName;
     }
     string answer = Federation.GetTopicPropertyValue(revision, "Summary");
     if (answer == "")
         answer = null;
     return answer;
 }
コード例 #30
0
ファイル: ContentBase.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Given a possibly relative topic name, answer all of the absolute topic names that actually exist
		/// </summary>
		/// <param name="topic"></param>
		/// <returns></returns>
		public IList AllAbsoluteTopicNamesThatExist(TopicName topic)
		{
			ArrayList answer = new ArrayList();
			foreach (string ns in TopicNamespaces(topic))
				answer.Add(new AbsoluteTopicName(topic.Name, ns));
			return answer;
		}