Пример #1
0
        /// <summary>
        /// Answer a list of the wikitext components (IBELObjects) of the given border.  If nothing specifies any border; answer the system default
        /// </summary>
        /// <param name="name"></param>
        /// <param name="border"></param>
        /// <param name="rule"></param> 
        /// <returns></returns>
        private IEnumerable BorderText(QualifiedTopicRevision name, Border border)
        {
            ArrayList answer = new ArrayList();
            NamespaceManager namespaceManager;
            string bordersTopicsProperty = "Borders";

            ArrayList borderTopics = new ArrayList();


            // Start with whatever the namespace defines
            if (Borders != null)
            {
                foreach (string at in ParseListPropertyValue(Borders))
                {
                    QualifiedTopicRevision abs = new QualifiedTopicRevision(at);
                    namespaceManager = NamespaceManagerForTopic(abs);
                    if (abs == null || namespaceManager == null)
                    {
                        throw new Exception("Unknown namespace listed in border topic (" + at + ") listed in federation configuration Borders property.");
                    }
                    borderTopics.Add(at);
                }
            }


            // If the namespace, specifies border topics, get them
            namespaceManager = NamespaceManagerForTopic(name);
            if (namespaceManager != null)
            {
                borderTopics.AddRange(GetTopicListPropertyValue(
                    new QualifiedTopicRevision(namespaceManager.DefinitionTopicName), 
                    bordersTopicsProperty));
            }

            // If there are no border topics specified for the federation or the namespace, add the default (_NormalBorders from the local namespace)
            if (borderTopics.Count == 0)
            {
                borderTopics.Add("_NormalBorders");
            }


            // Finally, any border elements form the topic itself (skip the def topic so we don't get double borders!)
            if (namespaceManager == null || namespaceManager.DefinitionTopicName.ToString() != name.ToString())
            {
                borderTopics.AddRange(GetTopicListPropertyValue(name, bordersTopicsProperty));
            }


            Set done = new Set();
            foreach (string borderTopicName in borderTopics)
            {
                // Figure out what the qualified topic name is that we're going to get this topic from
                TopicRevision rel = new TopicRevision(borderTopicName);
                if (!rel.IsQualified)
                {
                    rel = new TopicRevision(borderTopicName, name.Namespace);
                }
                QualifiedTopicRevision abs = new QualifiedTopicRevision(rel.LocalName, rel.Namespace);
                if (done.Contains(abs))
                {
                    continue;
                }
                done.Add(abs);
                IBELObject s = BorderPropertyFromTopic(name, abs, border);
                if (s != null)
                {
                    answer.Add(s);
                }
            }

            return answer;
        }
Пример #2
0
 /// <summary>
 /// Restores the passed in Topic version as the current version
 /// </summary>
 /// <param name="topic">Topic Version to Restore</param>
 /// <returns></returns>
 protected TopicRevision RestorePreviousVersion(QualifiedTopicRevision topic)
 {
     LogEvent e = Federation.LogEventFactory.CreateAndStartEvent(Request.UserHostAddress, VisitorIdentityString, topic.ToString(), LogEventType.WriteTopic);
     try
     {
         QualifiedTopicRevision newVersionName = new QualifiedTopicRevision(topic.LocalName, topic.Namespace);
         newVersionName.Version = TopicRevision.NewVersionStringForUser(VisitorIdentityString, Federation.TimeProvider);
         NamespaceManager namespaceManager = Federation.NamespaceManagerForNamespace(topic.Namespace);
         namespaceManager.WriteTopicAndNewVersion(newVersionName.LocalName,
             Federation.Read(topic), VisitorIdentityString);
     }
     finally
     {
         e.Record();
     }
     return new QualifiedTopicRevision(topic.LocalName, topic.Namespace);
 }