Example #1
0
        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);
            QualifiedTopicNameCollection alternatives = new QualifiedTopicNameCollection();
            if (topicName.IsQualified)
            {
                alternatives.Add(new QualifiedTopicName(topicName.LocalName, topicName.Namespace));
            }
            else
            {
                alternatives.Add(new QualifiedTopicName(topicName.LocalName, Namespace));
                NamespaceManager manager = CurrentFederation.NamespaceManagerForNamespace(Namespace);
                alternatives.AddRange(manager.AllPossibleQualifiedTopicNames(new UnqualifiedTopicName(topicName.LocalName)));
            }

            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;
        }
Example #2
0
        /// <summary>
        /// Answer an (unsorted) enumeration of all topic in the ContentProviderChain (doesn't include imports)
        /// </summary>
        /// <returns>Enumeration of AbsoluteTopicNames</returns>
        public override QualifiedTopicNameCollection AllTopics()
        {
            QualifiedTopicNameCollection results = new QualifiedTopicNameCollection();
            SqlInfoForTopic[] topicInfos = _sqlHelper.GetSqlTopicInfoForNonArchiveTopics(Namespace, false);

            foreach (SqlInfoForTopic topicInfo in topicInfos)
            {
                results.Add(new QualifiedTopicName(topicInfo.Name, Namespace));
            }

            return results;
        }
Example #3
0
        private void ShowEditPage(bool preserveContent)
        {
            StringBuilder strbldr = new StringBuilder();

            //Response.Write("<body onload=\"javascript:ResizeEditBox()\" onresize=\"javascript:ResizeEditBox()\" class=\"EditBody\" width=\"100%\" height=\"100%\" scroll=\"no\">");
            strbldr.AppendLine("<body onload=\"javascript:ResizeEditBox()\" >");

            strbldr.AppendLine("<table width=\"100%\" id=\"MasterTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\">");
            strbldr.AppendLine("<div id=\"MainRegion\" class=\"EditMain\">");

            strbldr.AppendLine("<div style=\"display: none\">");
            strbldr.AppendLine("<form id=\"Form2\" method=\"post\" target=\"previewWindow\" action=\"Preview.aspx\">");
            strbldr.AppendLine("<textarea id=\"body\" name=\"body\" rows=\"20\" cols=\"60\"></textarea>");
            strbldr.AppendFormat("<input  type=\"text\" id=\"Text1\" name=\"defaultNamespace\" value =\"{0}\" />", TheTopic.Namespace);
            strbldr.AppendFormat("<input  type=\"text\" id=\"Text2\" name=\"topic\" value =\"{0}\" />", TheTopic.LocalName);

            strbldr.AppendLine("</form>");
            strbldr.AppendLine("</div>");
            strbldr.AppendLine("<div class=\"EditZone\" id=\"EditZone\" >");
            strbldr.AppendLine("<form id=\"Form1\" method=\"post\" action=\"\">");
            strbldr.AppendLine("<textarea class=\"EditBox\" onkeydown=\"javascript:textarea_OnKeyPress(event)\" rows=\"20\" cols=\"50\" id=\"EditBox\" name=\"EditBox\" onfocus=\"javascript:textArea_OnFocus(event)\" onblur=\"javascript:textArea_OnBlur(event)\">");
            Response.Write(strbldr.ToString());

            string defaultContent = @"
            Check out the formatting tips on the right for help formatting and making links.

            Use the template below:

            ----

            Summary: add a one or paragraph summary or description of what's discussed here;  put yours after 'Summary:'

            Add your wiki text here.

            ";
            string content = null;
            bool isValidName = Formatter.extractWikiNames.IsMatch("[" + TheTopic.Name.LocalName + "]");
            if (!isValidName)
            {
                content = String.Format("Topic Name not valid for this wiki: {0}\nPlease go back and choose a different name.", TheTopic.Name);
            }
            if (Federation.TopicExists(TheTopic))
            {
                content = Federation.Read(TheTopic);
            }
            if (IsPost && IsBanned)
            {
                content = PostedTopicText;		// preserve what they asked for, even though we won't let them save
            }

            if (preserveContent)
            {
                content = PostedTopicText;
            }

            #region Build up the list of templates and set the content accordingly
            string templateSelect = string.Empty;
            NamespaceManager currentContentBase = Federation.NamespaceManagerForNamespace(TheTopic.Namespace);

            // Process the topics looking for topics beginning with '_Template'.
            QualifiedTopicNameCollection templates = new QualifiedTopicNameCollection();
            foreach (QualifiedTopicName topic in currentContentBase.AllTopics(ImportPolicy.DoNotIncludeImports))
            {
                if (topic.LocalName.StartsWith("_Template"))
                {
                    templates.Add(topic);

                    if ("_templatedefault" == topic.LocalName.ToLower())
                    {
                        defaultContent = Federation.Read(topic);
                    }
                }
            }

            if (0 != templates.Count)
            {
                // Build up a combo box for selecting the template.
                StringBuilder builder = new StringBuilder("<select name=\"templateSelect\" id=\"templateSelect\">\n");
                foreach (QualifiedTopicName topic in templates)
                {
                    builder.AppendLine("\t<option value=\"");
                    builder.AppendLine(Formatter.EscapeHTML(Federation.Read(topic)));
                    builder.AppendLine("\">");
                    string topicStart = "_ Template";
                    string name = topic.FormattedName;
                    builder.AppendLine(name.Substring(topicStart.Length));
                    builder.AppendLine("</option>\n");
                }
                builder.AppendLine("</select>\n");

                templateSelect = builder.ToString();

                // Check to see if a template was specified in the request.
                if (null != this.Request.QueryString["template"])
                {
                    string templateName = this.Request["template"];
                    QualifiedTopicRevision topicVersionKey = new QualifiedTopicRevision(templateName, currentContentBase.Namespace);
                    if ((content == null) && (true == currentContentBase.TopicExists(topicVersionKey.LocalName,
                        ImportPolicy.DoNotIncludeImports)))
                    {
                        content = Federation.Read(topicVersionKey);
                    }
                }
            }
            #endregion

            if (content == null)
            {
                content = defaultContent;
            }

            Response.Write(Formatter.EscapeHTML(content));

            Response.Write(@"</textarea>");
            bool isWritable = this.IsWritable && isValidName;
            if (isWritable)
            {
                Response.Write("<input type=\"text\" style=\"display:none\" name=\"CaptchaEnteredSubmitted\" value =\"\" />");
                Response.Write("<input type=\"text\" style=\"display:none\" name=\"CaptchaContextSubmitted\" value =\"\" />");
                Response.Write("<input type=\"text\" style=\"display:none\" id=\"SaveButtonPressed\" name=\"SaveButtonPressed\" value=\"\" />");
                Response.Write("<input type=\"text\" style=\"display:none\" name=\"UserSuppliedName\" value =\"" + Formatter.EscapeHTML(UserPrefix == null ? "" : UserPrefix) + "\" />");
                if (Federation.TopicExists(TheTopic))
                {
                    Response.Write("<input type=\"text\" style=\"display:none\" name=\"TopicLastWrite\" value =\"" + Formatter.EscapeHTML(Federation.GetTopicModificationTime(TheTopic).ToString("s")) + "\" />");
                }
                Response.Write("<input type=\"text\" style=\"display:none\" name=\"Topic\" value =\"" + Formatter.EscapeHTML(TheTopic.ToString()) + "\" />");
                if (ReturnTopic != null)
                {
                    Response.Write("<input type=\"text\" style=\"display:none\" name=\"ReturnTopic\" value =\"" + Formatter.EscapeHTML(ReturnTopic) + "\" />");
                }
            }

            //set up protection from Cross Site Request Forgery (XSRF)
            Random rand = new Random();
            string nonce = rand.Next().ToString();
            string cookieId = Guid.NewGuid().ToString();
            string nonceKey = FlexWikiWebApplication.ApplicationConfiguration.XsrfProtectionNoncePassphrase;
            string cookieKey = FlexWikiWebApplication.ApplicationConfiguration.XsrfProtectionCookiePassphrase;
            string encryptedNonce = FlexWiki.Web.Security.Encrypt(nonce, nonceKey);
            string encryptedCookie = FlexWiki.Web.Security.Encrypt(nonce, cookieKey);
            Response.Write("<input type=\"text\" style=\"display:none\" name=\"CookieId\" value =\"" + cookieId + "\" />");
            Response.Write("<input type=\"text\" style=\"display:none\" name=\"Nonce\" value =\"" + encryptedNonce + "\" />");
            HttpCookie xsrf = new HttpCookie(cookieId);
            xsrf.HttpOnly = true;
            xsrf.Value = encryptedCookie;
            xsrf.Expires = DateTime.Now.AddMinutes(FlexWikiWebApplication.ApplicationConfiguration.XsrfProtectionWikiEditTimeout);
            Response.Cookies.Add(xsrf);

            Response.Write(@"</form></div>");

            Response.Write("</div></td>");
            Response.Write("<td valign=\"top\" id=\"Sidebar\" class=\"Sidebar\">");

            Response.Write("<table style=\"height: 100%\"><tr><td height=\"100%\" valign=\"top\">");

            /////////////////////////////
            OpenPane(Response.Output, "Edit&nbsp;" + BELString.MaxLengthString2(Formatter.EscapeHTML(TheTopic.ToString()), 20, "..."));
            if (isWritable)
            {
                NamespaceManager storeManager = Federation.NamespaceManagerForTopic(TheTopic);
                if (storeManager.TopicExists(TheTopic.LocalName, ImportPolicy.DoNotIncludeImports))
                {
                    Response.Write("Make your changes to the text on the left and then select Save.");
                }
                else
                {
                    Response.Write(@"
            <div class=""CreateTopicWarning"">
                You are about to create a new topic called <b>" + TheTopic.LocalName + @"</b> in the <b>" +
                        storeManager.FriendlyTitle + @"</b> namespace.");
                    Response.Write("<P>Please be sure you are creating this topic in the desired namespace.</p>");
                    Response.Write(@"</div>");
                }
            }
            else
            {
                Response.Write("<span class=\"ReadOnlyStripe\">You do not have permission to change this topic.</span>");
            }

            ClosePane(Response.Output);

            if (IsConflictingChange)
            {
                OpenPane(Response.Output, "Conflicting Change");
                Response.Write("<div class=\"ConflictingChange\">Your change can not be saved.</div>");
                Response.Write("The topic has been changed since you started to edit it and if you saved your changes, the other changes would be lost.");
                Response.Write(" Please save your changes somewhere and edit again (no merge functionality yet).  You are now being shown the new version on the left.  To recover your previous edits, use the Back button.");
                ClosePane(Response.Output);
            }

            if (IsPost && IsBanned)
            {
                OpenPane(Response.Output, "Banned URLs");
                Response.Write("<div class=\"BannedChange\">Your change can not be saved.</div>");
                Response.Write("The changes you are trying to save include banned URLs.");
                ClosePane(Response.Output);
                LogBannedAttempt();
            }

            if (Federation.NoFollowExternalHyperlinks)
            {
                OpenPane(Response.Output, "External Hyperlinks");
                Response.Write("<img src=\"" + TheLinkMaker.LinkToImage("images/NoFollowNoSpam.gif") + "\" align=\"right\" />External hyperlinks will not be indexed by search engines.");
                ClosePane(Response.Output);
            }

            ///////////////////////////////
            if (isWritable)
            {
                OpenPane(Response.Output, "Attribution");
                if (User.Identity.IsAuthenticated)
                {
                    Response.Write("Your edit will be attributed to: <b>" + Formatter.EscapeHTML(VisitorIdentityString) + "</b>.");
                }
                else
                {
                    Response.Write("Your edit will be attributed to: <b>" + Formatter.EscapeHTML(VisitorIdentityString) + "</b>.<br />");

                    Response.Write("<div id=\"ShowAttribution\" style=\"display: block\"><a onclick=\"javascript:Swap('ShowAttribution', 'HideAttribution')\">Change this...</a></div>");
                    Response.Write("<div id=\"HideAttribution\" style=\"display: none\">");
                    Response.Write("<a onclick=\"javascript:Swap('ShowAttribution', 'HideAttribution')\">Hide this...</a><br />");

                    Response.Write("You can change part of this by entering your preferred user identity here (e.g., an email address):<br />");
                    Response.Write(@"<input style=""font-size: x-small"" type=""text"" id=""UserNameEntryField"" value =""" +
                        (UserPrefix == null ? "" : Formatter.EscapeHTML(UserPrefix)) + "\" />");
                    Response.Write("</div>");

                }
                ClosePane(Response.Output);
            }

            ///////////////////////////////

            if (isWritable)
            {
                OpenPane(Response.Output, "Formatting Tips");
                Response.Write("<div id=\"ShowTips\" style=\"display: block\"><a onclick=\"javascript:Swap('ShowTips', 'HideTips')\">Show tips...</a></div>");
                Response.Write("<div id=\"HideTips\" style=\"display: none\">");
                Response.Write("<a onclick=\"javascript:Swap('ShowTips', 'HideTips')\">Hide tips...</a><br />");

                Response.Write("Click on a subject for more information about formatting rules: ");
                WriteTip("tip_boldtip", "Bold");
                WriteTip("tip_italicstip", "Italics");
                WriteTip("tip_headingtip", "Headings");
                WriteTip("tip_hypertip", "Hyperlinks");
                WriteTip("tip_linestip", "Lines");
                WriteTip("tip_liststip", "Lists");
                WriteTip("tip_tablestip", "Tables");
                WriteTip("tip_emoticonstip", "Emoticons");
                WriteTip("tip_pretip", "Preformatted");
                WriteTip("tip_imagetip", "Images");
                WriteTip("tip_proptip", "Properties");

                strbldr = new StringBuilder();
                strbldr.AppendLine("<br /><div class=\"TipArea\" id=\"TipArea\"></div>");

                strbldr.AppendLine("<div style=\"display: none\">");
                strbldr.AppendLine("<div id=\"tip_proptip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("A line that starts with a wiki word and a colon identifies a property.");
                strbldr.AppendLine("The value of the property is everything on the line after the colon.");
                strbldr.AppendLine("Multiline imports use PropertyName:[ and then multiple lines and then ] on a");
                strbldr.AppendLine("blank line to mark the end.");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_imagetip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Any URL that ends with .gif, .jpeg, .jpg or .png will be turned into an image");
                strbldr.AppendLine("tag to display the actual image.");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_pretip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Any line that starts with at least one space will be fixed-width formatted.");
                strbldr.AppendLine("Good for code and simple tables.");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_liststip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Start a line with a tab (or 8 spaces) followed by a star \"*\".");
                strbldr.AppendLine("Two tabs (or 16 spaces) indents to the next level, etc.");
                strbldr.AppendLine("For ordered lists, use \"1.\" instead of \"*\"");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_linestip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Four hyphens makes a horizontal rule.");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_boldtip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Surround the text with three ticks (''').");
                strbldr.AppendLine("For example, '''<b>this text will be bold</b>'''");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_italicstip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Surround the text with two ticks ('').");
                strbldr.AppendLine("For example, ''<i>this text will be italic</i>''");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_headingtip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Bang (!) at the start of a line for H1.");
                strbldr.AppendLine("Bang Bang (!!) at the start of a line for H2.");
                strbldr.AppendLine("And so on...");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_hypertip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("Any PascalCased word becomes a link.");
                strbldr.AppendLine("Surrounding a word with square brackets [ word ] will make non-pascalcased");
                strbldr.AppendLine("words into links; generally this is considered \"odd\".");
                strbldr.AppendLine("Any URL becomes a link (http://www.msn.com)");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_emoticonstip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("All the common emoticons like :-) and :-( are turned into the apprpriate");
                strbldr.AppendLine("graphical images (like in messenger).");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("<div id=\"tip_tablestip\">");
                strbldr.AppendLine("<div class=\"tipBody\">");
                strbldr.AppendLine("A line that starts and ends with || is a table row.  Cells are divided by ||.");
                strbldr.AppendLine("For example: <br />");
                strbldr.AppendLine("||Region || Sales||<br />");
                strbldr.AppendLine("||East || $100||<br />");
                strbldr.AppendLine("||West || $100||<br />");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");
                strbldr.AppendLine("</div>");

                strbldr.AppendLine("</div>");
                Response.Write(strbldr.ToString());
                ClosePane(Response.Output);
            }

            //////////////////////////////
            if (isWritable && templateSelect.Length > 0)
            {
                // Render the template selection dropdown.
                OpenPane(Response.Output, "Topic Templates");
                Response.Write("Select a new template:<br/>\n");
                Response.Write(templateSelect);
                Response.Write("&nbsp;<input type=\"image\" src=\"" + TheLinkMaker.LinkToImage("images/go-dark.gif") + "\" title=\"Change Template\" onclick=\"javascript:ChangeTemplate('templateSelect');\" />");
                ClosePane(Response.Output);
            }

            //////////////////////////////

            strbldr = new StringBuilder();
            if (isWritable)
            {
                if (IsCaptchaRequired())
                {
                    strbldr.AppendLine("<table class=\"SidebarTile\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">");
                    strbldr.AppendLine("<tbody>");
                    strbldr.AppendLine("<tr>");
                    strbldr.AppendLine("<td class=\"SidebarTileTitle\" valign=\"middle\">Spam Prevention</td>");
                    strbldr.AppendLine("</tr>");
                    strbldr.AppendLine("<tr class=\"SidebarTileBody\" valign=\"middle\">");
                    strbldr.AppendLine("<td>");
                    strbldr.AppendLine("<div>");
                    string captchaCode = GenerateNewCaptchaCode();
                    string aboutHref = TheLinkMaker.SimpleLinkTo("AboutCaptcha.html");
                    if (IsPost && !IsXsrfProtected)
                    {
                        strbldr.AppendLine("<span class=\"ErrorMessageBody\">Form submission exceed XSRF protection timeout. Please resubmit by clicking Save. </span>");
                    }
                    if (IsPost && !IsCaptchaVerified)
                    {
                        strbldr.AppendLine("<span class=\"ErrorMessageBody\">To prevent automated spam attacks, you must properly enter the code shown below. Please enter the number you see in the box and then click Save. </span>");
                    }
                    else
                    {
                        strbldr.AppendLine("<span>Before saving, please enter the code you see below. </span>");
                    }
                    strbldr.AppendLine("<br />");
                    strbldr.AppendFormat("<a href=\"{0}\" target=\"_blank\">What's this?</a>", aboutHref);
                    strbldr.AppendLine("<br />");
                    string captchaHref = TheLinkMaker.SimpleLinkTo("CaptchaImage.ashx/" + captchaCode);
                    strbldr.AppendFormat("<img src=\"{0}\" alt=\"Enter this code in the box to the right.\" />", captchaHref);
                    strbldr.AppendLine("<br />");
                    strbldr.AppendFormat("<input type=\"hidden\" name=\"CaptchaContext\" id=\"CaptchaContext\" value=\"{0}\" />", captchaCode);
                    strbldr.AppendLine("<input type=\"text\" name=\"CaptchaEntered\" id=\"CaptchaEntered\" value=\"\" />");
                    strbldr.AppendLine("</div>");
                    strbldr.AppendLine("</td>");
                    strbldr.AppendLine("</tr>");
                    strbldr.AppendLine("</tbody>");
                    strbldr.AppendLine("</table>");
                }
                if (IsPost && !IsXsrfProtected)
                {
                    strbldr.AppendLine("<span class=\"ErrorMessageBody\">Form submission exceeded XSRF protection timeout. Please resubmit by clicking Save. </span>");
                }

                // generate cancel, save, search, preview, and Save&Return buttons
                strbldr.AppendLine("<div style=\"margin-top: 12px; text-align: center\"><table>");
                strbldr.AppendLine("<tr><td><button onclick=\"javascript:Cancel()\" name=\"CancelButton\">Cancel</button></td>");
                strbldr.AppendLine("<td><button onclick=\"javascript:Save()\" name=\"SaveButton\">Save</button></td></tr>");
                strbldr.AppendLine("<tr><td><button onclick=\"javascript:search()\" id=\"button3\">Search</button></td>");
                strbldr.AppendLine("<td><button onclick=\"javascript:preview()\" id=\"button1\">Preview</button></td></tr>");

                if (ReturnTopic != null)
                {
                    strbldr.AppendLine("<tr><td colspan=\"2\"><button onclick=\"javascript:SaveAndReturn()\"  name=\"SaveButton\">Save and Back</button></td></tr>");
                }

            }

            strbldr.AppendLine("</table></div>");

            if (IsUploadable && isWritable)
            {
                strbldr.AppendLine("<div id=\"AttachFile\" style=\"display: block\">");
            }
            else
            {
                strbldr.AppendLine("<div id=\"AttachFile\" style=\"display: none\">");
            }
            strbldr.AppendLine("<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" class=\"SidebarTile\">");
            strbldr.AppendLine("<tr>");
            strbldr.AppendLine("<td valign=\"middle\" class=\"SidebarTileTitle\">");
            strbldr.AppendLine("File Upload &amp; Attachment");
            strbldr.AppendLine("</td>");
            strbldr.AppendLine("</tr>");
            strbldr.AppendLine("<tr class=\"SidebarTileBody\"><td>");

            if (IsAttachment)
            {
                strbldr.AppendLine("<div id=\"ShowAttachmentControls\" style=\"display: none\" >");
                strbldr.AppendLine("<a onclick=\"javascript:Swap('ShowAttachmentControls', 'HideAttachmentControls')\">Show Attachment Controls...</a> </div>");
                strbldr.AppendLine("<div id=\"HideAttachmentControls\" style=\"display: block\" >");
                strbldr.AppendLine("<a onclick=\"javascript:Swap('HideAttachmentControls', 'ShowAttachmentControls')\" >Hide Attachment Controls...</a>");
            }
            else
            {
                strbldr.AppendLine("<div id=\"ShowAttachmentControls\" style=\"display: block\" >");
                strbldr.AppendLine("<a onclick=\"javascript:Swap('ShowAttachmentControls', 'HideAttachmentControls')\">Show Attachment Controls...</a> </div>");
                strbldr.AppendLine("<div id=\"HideAttachmentControls\" style=\"display: none\" >");
                strbldr.AppendLine("<a onclick=\"javascript:Swap('HideAttachmentControls', 'ShowAttachmentControls')\" >Hide Attachment Controls...</a>");
            }
            strbldr.AppendLine("<table><tr><td>");
            Response.Write(strbldr.ToString());
        }
        private QualifiedTopicNameCollection GetBuiltInTopics()
        {
            // We need to build this every time, because the name of the HomePage can change dynamically.
            QualifiedTopicNameCollection builtInTopics = new QualifiedTopicNameCollection();

            builtInTopics.Add(NamespaceManager.HomePageTopicName);
            builtInTopics.Add(NamespaceManager.BordersTopicName);

            return builtInTopics;
        }
Example #5
0
        protected void DoSearch()
        {
            LinkMaker lm = TheLinkMaker;

            NamespaceManager storeManager = Federation.NamespaceManagerForNamespace(_preferredNamespace);

            // Get the complete list of topics and authors
            QualifiedTopicNameCollection topics = storeManager.AllTopicsSortedLastModifiedDescending();

            // Omit topics for which we don't have read permission - we're not going to be able
            // to access information about them anyway.
            QualifiedTopicNameCollection permittedTopics = new QualifiedTopicNameCollection();
            foreach (QualifiedTopicName topic in topics)
            {
                if (storeManager.HasPermission(new UnqualifiedTopicName(topic.LocalName), TopicPermission.Read))
                {
                    permittedTopics.Add(topic);
                }
            }

            Dictionary<QualifiedTopicName, string> authorMap = new Dictionary<QualifiedTopicName, string>();
            SortedList<string, string> authors = new SortedList<string, string>();
            foreach (QualifiedTopicName topic in permittedTopics)
            {
                string author = storeManager.GetTopicLastAuthor(topic.LocalName);
                authorMap[topic] = author;
                // Overwrites the entry for author if it already exists, thus giving
                // us only unique authors.
                authors[author] = author;
            }
            StringBuilder strbldr = new StringBuilder();

            strbldr.AppendLine("<table cellspacing='0' cellpadding='2' border='0'>");
            strbldr.AppendLine("<thead>");
            strbldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"300\">Topic</td>");
            strbldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"100\">Modified</td>");
            strbldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"100\">File Lock Status</td>");
            if (storeManager.HasNamespacePermission(NamespacePermission.Manage))
            {
                strbldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"300\">Change File Lock</td>");
            }
            strbldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"200\">Author: ");
            strbldr.AppendLine("<select  onchange='filter()' class='SearchColumnFilterBox' id='AuthorFilter'>");
            strbldr.AppendLine("<option value='" + All + "'>" + All + "</option>");
            foreach (string author in authors.Values)
            {
                strbldr.AppendLine("<option value='" + author + "'>" + author + "</option>");
            }
            strbldr.AppendLine(@"</select>");
            strbldr.AppendLine("</td>");

            strbldr.AppendLine("</thead><tbody id=\"MainTable\">");

            int row = 0;
            foreach (QualifiedTopicName topic in permittedTopics)
            {
                strbldr.AppendLine("<tr id=\"row" + row + "\" class=\"" + (((row & 1) == 0) ? "SearchOddRow" : "SearchEvenRow") + "\">");
                row++;

                strbldr.AppendLine("<td>");
                strbldr.AppendLine("<b><a title=\"" + topic.DottedName + "\"  href=\"" + lm.LinkToTopic(topic) + "\">");
                strbldr.AppendLine(topic.LocalName);
                strbldr.AppendLine("</a></b>");
                strbldr.AppendLine("</td>");

                strbldr.AppendLine("<td>");
                DateTime stamp = storeManager.GetTopicLastModificationTime(topic.LocalName);
                if (stamp.Date == DateTime.Now.Date)
                {
                    strbldr.AppendLine(stamp.ToString("h:mm tt"));
                }
                else
                {
                    strbldr.AppendLine(stamp.ToString("MM/dd/yyyy h:mm tt"));
                }
                strbldr.AppendLine("</td>");
                strbldr.AppendLine("<td>");
                strbldr.AppendLine(storeManager.GetTopicInfo(topic.LocalName).IsTopicLocked ? "Is Locked" : "Is Unlocked");
                strbldr.AppendLine("</td>");
                if (storeManager.HasNamespacePermission(NamespacePermission.Manage))
                {
                    strbldr.AppendLine("<td>");
                    if (!storeManager.GetTopicInfo(topic.LocalName).IsTopicLocked)
                    {
                        strbldr.AppendLine("<input type=\"button\" value=\"Create Lock\" id=\"" + topic.LocalName + "_Btn\" ");
                        strbldr.AppendLine("onclick=\"javascript:FileAction_Click('" + topic.DottedName + "','Lock')\" />");
                    }
                    else
                    {
                        strbldr.AppendLine("<input type=\"button\" value=\"Remove Lock\" id=\"" + topic.LocalName + "_Btn\" ");
                        strbldr.AppendLine("onclick=\"javascript:FileAction_Click('" + topic.DottedName + "','Unlock')\" />");
                    }
                    strbldr.AppendLine("</td>");
                }
                strbldr.AppendLine("<td>");
                strbldr.AppendLine(Escape((string)(authorMap[topic])));
                strbldr.AppendLine("</td>");
                strbldr.AppendLine("</tr>");
                strbldr.AppendLine();
            }
            strbldr.AppendLine("</tbody></table>");
            Response.Write(strbldr.ToString());
        }
Example #6
0
        public override QualifiedTopicNameCollection AllTopics()
        {
            _allTopicsCalled = true;

            QualifiedTopicNameCollection topics = new QualifiedTopicNameCollection();

            foreach (MockTopic topic in AllTopics(ExistencePolicy.ExistingOnly))
            {
                topics.Add(new QualifiedTopicName(topic.Name, this.Namespace));
            }

            return topics;
        }
Example #7
0
        /// <summary>
        /// Given a local topic name, answer all of the qualified topic names that actually exist
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public QualifiedTopicNameCollection AllQualifiedTopicNamesThatExist(string topicName)
        {
            QualifiedTopicNameCollection answer = new QualifiedTopicNameCollection();

            if (TopicExists(topicName, ImportPolicy.DoNotIncludeImports))
            {
                answer.Add(QualifiedTopicNameFor(topicName));
            }

            foreach (NamespaceManager manager in ImportedNamespaceManagers)
            {
                if (manager.TopicExists(topicName, ImportPolicy.DoNotIncludeImports))
                {
                    answer.Add(manager.QualifiedTopicNameFor(topicName));
                }
            }

            return answer;
        }
Example #8
0
        protected string DoHead()
        {
            StringBuilder headbldr = new StringBuilder();
            QualifiedTopicRevision topic = GetTopicVersionKey();
            LinkMaker lm = TheLinkMaker;

            // Consider establishing a redirect if there's a redirect to a topic or an URL
            string redir = Federation.GetTopicPropertyValue(GetTopicVersionKey(), "Redirect");
            if (redir != "")
            {
                UriBuilder uri = null;
                if (IsAbsoluteURL(redir))
                {
                    uri = new UriBuilder(redir);
                }
                else
                {
                    // Must be a topic name
                    string trimmed = redir.Trim();
                    QualifiedTopicNameCollection all = new QualifiedTopicNameCollection();
                    if (trimmed.Contains("."))
                    {
                        try
                        {
                            string topicName = trimmed.Substring(trimmed.IndexOf(".") + 1);
                            string nsName = trimmed.Substring(0, trimmed.IndexOf("."));
                            TopicName redirTopic = new TopicName(topicName, nsName);
                            NamespaceManager redirMgr = Federation.NamespaceManagerForNamespace(nsName);
                            all = redirMgr.AllQualifiedTopicNamesThatExist(topicName);
                        }
                        catch (Exception ex)
                        {
                            headbldr.AppendLine("<!-- Exception: " + ex.Message + " -->\n");
                        }
                    }
                    else
                    {
                        all = Federation.NamespaceManagerForTopic(GetTopicVersionKey()).AllQualifiedTopicNamesThatExist(trimmed);
                    }

                    if (all.Count == 1)
                    {
                        uri = new UriBuilder(
                            new Uri(
                                new Uri(FullRootUrl(Request)),
                                lm.LinkToTopic(
                                    new QualifiedTopicRevision(all[0]),
                                    false,
                                    Request.QueryString)));
                    }
                    else
                    {
                        if (all.Count == 0)
                            headbldr.AppendLine("<!-- Redirect topic does not exist -->\n");
                        else
                            headbldr.AppendLine("<!-- Redirect topic is ambiguous -->\n");
                    }
                }
                if (uri != null)
                {
                    if (Request.QueryString["DelayRedirect"] == "1")
                    {
                        headbldr.AppendLine("<meta http-equiv=\"refresh\" content=\"10;URL=\"" + uri + "\" />");
                    }
                    else
                    {
                        Response.Redirect(uri.Uri.ToString());
                        return "";
                    }
                }
            }

            headbldr.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />");

            if (_metaTags)
            {
                string keywords = Federation.GetTopicPropertyValue(GetTopicVersionKey(), "Keywords");
                if (keywords != "")
                {
                    headbldr.AppendLine("<meta name=\"keywords\" content=\"" + keywords + "\" />");
                }
                string description = Federation.GetTopicPropertyValue(GetTopicVersionKey(), "Summary");
                if (description != "")
                {
                    headbldr.AppendLine("<meta name=\"description\" content=\"" + description + "\" />");
                }
                headbldr.AppendLine("<meta name=\"author\" content=\"" +
                    Federation.GetTopicLastModifiedBy(GetTopicVersionKey().AsQualifiedTopicName()) +
                    "\" />");

                if (GetTopicVersionKey().Version != null)
                {
                    // Don't index the versions
                    headbldr.AppendLine("<meta name=\"Robots\" content=\"NOINDEX, NOFOLLOW\" />");
                }
            }

            if (_javaScript)
            {
                headbldr.AppendFormat("<script language=\"javascript\" src=\"{0}WikiDefault.js\" type=\"text/javascript\"></script>\r\n", RootUrl);
                headbldr.AppendFormat("<script language=\"javascript\" src=\"{0}WikiTopicBar.js\" type=\"text/javascript\"></script>\r\n", RootUrl);
                headbldr.AppendFormat("<script language=\"javascript\" src=\"{0}WikiMenu.js\" type=\"text/javascript\"></script>\r\n", RootUrl);
                headbldr.AppendFormat("<script language=\"javascript\" src=\"{0}WikiThreads.js\" type=\"text/javascript\"></script>\r\n", RootUrl);
                if (!String.IsNullOrEmpty(FlexWikiWebApplication.ApplicationConfiguration.LocalJavascript))
                {
                    headbldr.AppendFormat("<script language=\"javascript\" src=\"{0}{1}\" type=\"text/javascript\"></script>\r\n", RootUrl,
                        FlexWikiWebApplication.ApplicationConfiguration.LocalJavascript);
                }
                if (manager.GetTopicInfo(topic.LocalName).HasProperty("CreateAtomFeedLink"))
                {
                    if (manager.GetTopicProperty(topic.LocalName, "CreateAtomFeedLink").LastValue.ToLower() == "true")
                    {
                        string atomLink = BaseUrl + RootUrl + "AtomFeed.aspx/" + topic.DottedName;
                        headbldr.AppendLine(@"<link rel=""alternate"" type=""application/atom+xml"" title=""" + topic.FormattedName + @""" href=""" + atomLink + @""" />");
                    }
                }
                headbldr.AppendLine("<script type=\"text/javascript\">");
                headbldr.AppendLine("function showChanges()");
                headbldr.AppendLine("{");
                headbldr.AppendLine("    nav(\"" + urlForDiffs + "\");");
                headbldr.AppendLine("}");
                headbldr.AppendLine();
                headbldr.AppendLine("function hideChanges()");
                headbldr.AppendLine("{");
                headbldr.AppendLine("	nav(\"" + urlForNoDiffs + "\");");
                headbldr.AppendLine("}");
                headbldr.AppendLine("function BodyClick()");
                headbldr.AppendLine("{");
                headbldr.AppendLine("   SetEditing(false);");
                headbldr.AppendLine("}");
                headbldr.AppendLine("function BodyDblClick()");
                headbldr.AppendLine("{");

                bool editOnDoubleClick = true;
                editOnDoubleClick = FlexWikiWebApplication.ApplicationConfiguration.EditOnDoubleClick;

                if (editOnDoubleClick)
                {
                    headbldr.AppendLine("location.href=\"" + this.TheLinkMaker.LinkToEditTopic(topic.AsQualifiedTopicName()) + "\";");
                }
                headbldr.AppendLine("}");
                headbldr.AppendLine("</script>");
            }
            string head = headbldr.ToString();

            return head;
        }
        private void AssertTopicsCorrectUnordered(ArrayList actualTopics, params TopicName[] expectedTopics)
        {
            QualifiedTopicNameCollection topics = new QualifiedTopicNameCollection();

            foreach (TopicVersionInfo actualTopic in actualTopics)
            {
                QualifiedTopicName topic = new QualifiedTopicName(actualTopic.ExposedFullname);
                topics.Add(topic);
            }

            AssertTopicsCorrectUnordered(topics, expectedTopics);
        }
Example #10
0
        private void AssertTopicsCorrectUnordered(QualifiedTopicNameCollection actualTopics,
            params TopicName[] expectedTopics)
        {
            Assert.AreEqual(expectedTopics.Length, actualTopics.Count,
                "Checking that the right number of topics were returned.");

            for (int i = 0; i < expectedTopics.Length; i++)
            {
                TopicName expectedTopic = expectedTopics[i];
                string message = string.Format("Checking that topic {0} was present.", expectedTopic);

                bool found = false;
                foreach (TopicName actualTopic in actualTopics)
                {
                    if (expectedTopic.DottedName == actualTopic.DottedName)
                    {
                        found = true;
                        break;
                    }
                }

                Assert.IsTrue(found, message);
            }
        }
Example #11
0
        private void AssertTopicsCorrectOrdered(QualifiedTopicNameCollection actualTopics,
            params TopicName[] expectedTopics)
        {
            Assert.AreEqual(expectedTopics.Length, actualTopics.Count,
                "Checking that the right number of topics were returned.");

            for (int i = 0; i < expectedTopics.Length; i++)
            {
                string message = string.Format("Checking that topic {0} was present.", expectedTopics[i]);
                Assert.AreEqual(expectedTopics[i].DottedName, actualTopics[i].DottedName, message);
            }
        }
Example #12
0
        protected string DoSearch()
        {
            LinkMaker lm = TheLinkMaker;
            StringBuilder strBldr = new StringBuilder();
            int counter = 0;

            NamespaceManager storeManager = Federation.NamespaceManagerForNamespace(_preferredNamespace);

            // Get the complete list of topics and authors
            QualifiedTopicNameCollection topics = storeManager.AllTopicsSortedLastModifiedDescending();

            // Omit topics for which we don't have read permission - we're not going to be able
            // to access information about them anyway.
            QualifiedTopicNameCollection permittedTopics = new QualifiedTopicNameCollection();
            foreach (QualifiedTopicName topic in topics)
            {
                if (storeManager.HasPermission(new UnqualifiedTopicName(topic.LocalName), TopicPermission.Read))
                {
                    if (_recordLimit > 0)
                    {
                        if (counter < _recordLimit)
                        {
                            permittedTopics.Add(topic);
                            counter++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        permittedTopics.Add(topic);
                    }
                }
            }

            Dictionary<QualifiedTopicName, string> authorMap = new Dictionary<QualifiedTopicName, string>();
            SortedList<string, string> authors = new SortedList<string, string>();
            foreach (QualifiedTopicName topic in permittedTopics)
            {
                string author = storeManager.GetTopicLastAuthor(topic.LocalName);
                authorMap[topic] = author;
                // Overwrites the entry for author if it already exists, thus giving
                // us only unique authors.
                authors[author] = author;
            }

            strBldr.AppendLine("<table cellspacing='0' cellpadding='2' border='0'>");
            strBldr.AppendLine("<thead>");
            strBldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"300\">Topic</td>");
            strBldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"100\">Modified</td>");
            strBldr.AppendLine("<td class=\"SearchColumnHeading\" width=\"200\">Author: ");
            strBldr.AppendLine("<select  onchange='filter()' class='SearchColumnFilterBox' id='AuthorFilter'>");
            strBldr.AppendLine("<option value='" + All + "'>" + All + "</option>");
            foreach (string author in authors.Values)
            {
                strBldr.AppendLine("<option value='" + author + "'>" + author + "</option>");
            }
            strBldr.AppendLine("</select>");
            strBldr.AppendLine("</td>");

            strBldr.AppendLine("</thead><tbody id=\"MainTable\">");

            int row = 0;
            foreach (QualifiedTopicName topic in permittedTopics)
            {
                strBldr.AppendLine("<tr id=\"row" + row + "\" class=\"" + (((row & 1) == 0) ? "SearchOddRow" : "SearchEvenRow") + "\">");
                row++;

                strBldr.AppendLine("<td>");
                strBldr.Append("<b><a title=\"" + topic.DottedName + "\"  href=\"" + lm.LinkToTopic(topic) + "\">");
                strBldr.Append(topic.LocalName);
                strBldr.Append("</a></b>");
                strBldr.AppendLine("</td>");

                strBldr.AppendLine("<td>");
                DateTime stamp = storeManager.GetTopicLastModificationTime(topic.LocalName);
                string timeFormat = WikiApplication.FederationConfiguration.LocalTimeFormat;
                string dateFormat = WikiApplication.FederationConfiguration.LocalDateFormat;
                if (stamp.Date == DateTime.Now.Date)
                {
                    strBldr.Append(stamp.ToString(timeFormat));
                }
                else
                {
                    strBldr.Append(stamp.ToString(dateFormat + " - " + timeFormat));
                }
                strBldr.AppendLine("</td>");
                strBldr.AppendLine("<td>");
                strBldr.AppendLine(Escape((string)(authorMap[topic])));
                strBldr.AppendLine("</td>");
                strBldr.AppendLine("</tr>");
            }
            strBldr.AppendLine("</tbody></table>");
            return strBldr.ToString();
        }
Example #13
0
        public override QualifiedTopicNameCollection AllTopics()
        {
            QualifiedTopicNameCollection topics = new QualifiedTopicNameCollection();
            foreach (IFileInformation file in FileSystem.GetFiles(Root, "*.wiki"))
            {
                FileInfoTopicData topicData = new FileInfoTopicData(file, Namespace);
                topics.Add(new QualifiedTopicName(topicData.Name, topicData.Namespace));
            }

            return topics;
        }
Example #14
0
        /// <summary>
        /// Delete a topic
        /// </summary>
        /// <param name="topic"></param>
        public override void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory)
        {
            if (!_sqlHelper.TopicExists(Namespace, topic.LocalName))
            {
                return;
            }

            _sqlHelper.DeleteTopic(Namespace, topic.LocalName);

            if (removeHistory)
            {
                QualifiedTopicNameCollection results = new QualifiedTopicNameCollection();
                SqlInfoForTopic[] topicInfos = _sqlHelper.GetSqlTopicInfosForTopic(Namespace, topic.LocalName);

                foreach (SqlInfoForTopic topicInfo in topicInfos)
                {
                    _sqlHelper.DeleteTopic(Namespace, topicInfo.Name);
                }
            }
        }
Example #15
0
        /// <summary>
        /// Returns a list of all topics in the namespace, sorted using the specified comparison. 
        /// </summary>
        /// <param name="importPolicy">Indicates whether topics in imported namespaces
        /// should be included in the details.</param>
        /// <param name="sortCriterion">A <see cref="Comparision&gt;QualifiedTopicName&lt;"/> to use to
        /// sort the output, or null not to sort.</param>
        /// <returns>A (potentially sorted) list of <see cref="QualifiedTopicName"/> objects.</returns>
        /// <remarks>Order is not guaranteed in the absence of a sortCriteria.</remarks>
        public QualifiedTopicNameCollection AllTopics(ImportPolicy importPolicy, Comparison<QualifiedTopicName> sortCriterion)
        {
            QualifiedTopicNameCollection answer = new QualifiedTopicNameCollection();

            QualifiedTopicNameCollection unsortedTopics = ContentProviderChain.AllTopics();

            answer.AddRange(unsortedTopics); 

            if (importPolicy == ImportPolicy.IncludeImports)
            {
                foreach (NamespaceManager namespaceManager in ImportedNamespaceManagers)
                {
                    answer.AddRange(namespaceManager.AllTopics(ImportPolicy.DoNotIncludeImports));
                }
            }

            if (sortCriterion != null)
            {
                answer.Sort(sortCriterion);
            }

            return answer;
        }
Example #16
0
        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();
        }
Example #17
0
        /// <summary>
        /// Return all possible qualified names given a local name, even ones that don't exist.
        /// </summary>
        /// <param name="name">The unqualified name of a topic.</param>
        /// <returns>A collection of <see cref="QualifiedTopicName"/> objects, one for each 
        /// possible namespace the topic might exist in.</returns>
        public QualifiedTopicNameCollection AllPossibleQualifiedTopicNames(UnqualifiedTopicName name)
        {
            QualifiedTopicNameCollection names = new QualifiedTopicNameCollection();

            // Always add this namespace first.
            names.Add(new QualifiedTopicName(name.LocalName, Namespace));

            foreach (string ns in ImportedNamespaces)
            {
                names.Add(new QualifiedTopicName(name.LocalName, ns));
            }

            return names;
        }