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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
        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());
        }
        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;
        }
Beispiel #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;
        }
        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);
        }
        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();
        }
Beispiel #10
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;
        }
        /// <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;
        }