Contains methods for formatting content using a pipeline paradigm.
예제 #1
0
        /// <summary>
        /// Prints the header.
        /// </summary>
        public void PrintHeader()
        {
            string h = Content.GetPseudoCacheValue(GetPseudoCacheItemName("Header"));

            if (h == null)
            {
                h = FormattingPipeline.FormatWithPhase1And2(Settings.Provider.GetMetaDataItem(MetaDataItem.Header, currentNamespace),
                                                            false, FormattingContext.Header, currentPage);
                Content.SetPseudoCacheValue(GetPseudoCacheItemName("Header"), h);
            }
            lblHeaderDiv.Text = FormattingPipeline.FormatWithPhase3(h, FormattingContext.Header, currentPage);
        }
예제 #2
0
        /// <summary>
        /// Prints the sidebar.
        /// </summary>
        public void PrintSidebar()
        {
            string s = Content.GetPseudoCacheValue(GetPseudoCacheItemName("Sidebar"));

            if (s == null)
            {
                s = FormattingPipeline.FormatWithPhase1And2(Settings.Provider.GetMetaDataItem(MetaDataItem.Sidebar, currentNamespace),
                                                            false, FormattingContext.Sidebar, currentPage);
                Content.SetPseudoCacheValue(GetPseudoCacheItemName("Sidebar"), s);
            }
            lblSidebarDiv.Text = FormattingPipeline.FormatWithPhase3(s, FormattingContext.Sidebar, currentPage);
        }
예제 #3
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            lstAvailablePage.Items.Clear();
            btnAddPage.Enabled = false;

            txtPageName.Text = txtPageName.Text.Trim();

            if (txtPageName.Text.Length == 0)
            {
                return;
            }

            List <SearchResult> similarPages = SearchClass.Search(new SearchField[] { SearchField.PageFullName }, txtPageName.Text, SearchOptions.AtLeastOneWord);

            List <PageInfo> pages = new List <PageInfo>();

            foreach (SearchResult page in similarPages)
            {
                if (page.DocumentType == DocumentType.Page)
                {
                    PageDocument pageDocument = page.Document as PageDocument;
                    PageInfo     pageInfo     = Pages.FindPage(pageDocument.PageFullName);
                    pages.Add(pageInfo);
                }
            }

            string cp = CurrentProvider;

            foreach (PageInfo page in
                     from p in pages
                     where p.Provider.GetType().FullName == cp
                     select p)
            {
                // Filter pages already in the list
                bool found = false;
                foreach (ListItem item in lstPages.Items)
                {
                    if (item.Value == page.FullName)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    PageContent content = Content.GetPageContent(page, false);
                    lstAvailablePage.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.Other, page), page.FullName));
                }
            }

            btnAddPage.Enabled = lstAvailablePage.Items.Count > 0;
        }
예제 #4
0
        /// <summary>
        /// Prints the footer.
        /// </summary>
        public void PrintFooter()
        {
            string f = Content.GetPseudoCacheValue(GetPseudoCacheItemName("Footer"));

            if (f == null)
            {
                f = FormattingPipeline.FormatWithPhase1And2(Settings.Provider.GetMetaDataItem(MetaDataItem.Footer, currentNamespace),
                                                            false, FormattingContext.Footer, currentPage);
                Content.SetPseudoCacheValue(GetPseudoCacheItemName("Footer"), f);
            }
            lblFooterDiv.Text = FormattingPipeline.FormatWithPhase3(f, FormattingContext.Footer, currentPage);
        }
예제 #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string currentWiki = DetectWiki();

            PageContent page = Pages.FindPage(currentWiki, lstAvailablePage.SelectedValue);

            lstPages.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(currentWiki, page.Title, false, FormattingContext.Other, page.FullName), page.FullName));

            txtPageName.Text = "";
            lstAvailablePage.Items.Clear();
            btnAdd.Enabled = false;
        }
예제 #6
0
        /// <summary>
        /// Prints the page header and page footer.
        /// </summary>
        public void PrintPageHeaderAndFooter()
        {
            string h = Settings.GetProvider(currentWiki).GetMetaDataItem(MetaDataItem.PageHeader, currentNamespace);

            h = @"<div id=""PageInternalHeaderDiv"">" + FormattingPipeline.FormatWithPhase1And2(currentWiki, h, false, FormattingContext.PageHeader, currentPageFullName) + "</div>";

            lblPageHeaderDiv.Text = FormattingPipeline.FormatWithPhase3(currentWiki, h, FormattingContext.PageHeader, currentPageFullName);

            h = Settings.GetProvider(currentWiki).GetMetaDataItem(MetaDataItem.PageFooter, currentNamespace);
            h = @"<div id=""PageInternalFooterDiv"">" + FormattingPipeline.FormatWithPhase1And2(currentWiki, h, false, FormattingContext.PageFooter, currentPageFullName) + "</div>";

            lblPageFooterDiv.Text = FormattingPipeline.FormatWithPhase3(currentWiki, h, FormattingContext.PageFooter, currentPageFullName);
        }
예제 #7
0
        /// <summary>
        /// Prints the register notice.
        /// </summary>
        private void PrintRegisterNotice()
        {
            string n = Settings.GetProvider(currentWiki).GetMetaDataItem(MetaDataItem.RegisterNotice, null);

            if (!string.IsNullOrEmpty(n))
            {
                n = FormattingPipeline.FormatWithPhase1And2(currentWiki, n, false, FormattingContext.Other, null);
            }
            if (!string.IsNullOrEmpty(n))
            {
                lblRegisterDescription.Text = FormattingPipeline.FormatWithPhase3(currentWiki, n, FormattingContext.Other, null);
            }
        }
예제 #8
0
        private void ProcessPlugin(XmlNode node, StringBuilder sb)
        {
            IList <IFormatterProviderV50> providers = FormattingPipeline.GetSortedFormatters(_wiki);

            foreach (IFormatterProviderV50 provider in providers)
            {
                if (provider.EnablePluginsEditor)
                {
                    provider.WysiwygReverseFormat(node, sb);
                    break;
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Appends the drop-down menu DIV with outgoing links for a page.
        /// </summary>
        /// <param name="sb">The destination <see cref="T:StringBuilder" />.</param>
        /// <param name="page">The page.</param>
        /// <param name="dbPrefix">The drop-down menu DIV ID prefix.</param>
        /// <returns>The DIV ID, or <c>null</c> if no target pages were found.</returns>
        private string AppendBreadcrumbDropDown(StringBuilder sb, PageInfo page, string dbPrefix)
        {
            // Build outgoing links list
            // Generate list DIV
            // Return DIV's ID

            var outgoingLinks = Pages.GetPageOutgoingLinks(page);

            if (outgoingLinks == null || outgoingLinks.Length == 0)
            {
                return(null);
            }

            var id = dbPrefix + Guid.NewGuid().ToString();

            var buffer = new StringBuilder(300);

            buffer.AppendFormat(@"<div id=""{0}"" style=""display: none;"" class=""pageoutgoinglinksmenu"" onmouseover=""javascript:return __CancelHideTimer();"" onmouseout=""javascript:return __HideDropDown('{0}');"">", id);
            var count = 0;

            foreach (var link in outgoingLinks)
            {
                PageInfo target = Pages.FindPage(link);
                if (target != null)
                {
                    count++;
                    PageContent cont = Content.GetPageContent(target, true);

                    var title = FormattingPipeline.PrepareTitle(cont.Title, false, FormattingContext.PageContent, currentPage);

                    buffer.AppendFormat(@"<a href=""{0}{1}"" title=""{2}"">{2}</a>", link, Settings.PageExtension, title, title);
                }
                if (count >= 20)
                {
                    break;
                }
            }
            buffer.Append("</div>");

            sb.Insert(0, buffer.ToString());

            if (count > 0)
            {
                return(id);
            }
            else
            {
                return(null);
            }
        }
예제 #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Text"] != null)
     {
         // Context should be available by parsing the UrlReferrer, which
         // might not be available depending on the browser (this page is invoked via XmlHttpRequest)
         Response.Write(FormattingPipeline.FormatWithPhase3(FormattingPipeline.FormatWithPhase1And2(Request["Text"],
                                                                                                    false, ScrewTurn.Wiki.PluginFramework.FormattingContext.Unknown, null), ScrewTurn.Wiki.PluginFramework.FormattingContext.Unknown, null));
         //Response.Write(Formatter.Format(Request["Text"], null));
     }
     else
     {
         Response.Write("No input text.");
     }
 }
예제 #11
0
        /// <summary>
        /// Prints the results of the automatic search.
        /// </summary>
        public void PrintSearchResults()
        {
            StringBuilder sb = new StringBuilder(1000);

            PageInfo[] results = SearchTools.SearchSimilarPages(Request["Page"], DetectNamespace());
            if (results.Length > 0)
            {
                sb.Append("<p>");
                sb.Append(Properties.Messages.WereYouLookingFor);
                sb.Append("</p>");
                sb.Append("<ul>");
                PageContent c;
                for (int i = 0; i < results.Length; i++)
                {
                    c = Content.GetPageContent(results[i], true);
                    sb.Append(@"<li><a href=""");
                    UrlTools.BuildUrl(sb, Tools.UrlEncode(results[i].FullName), Settings.PageExtension);
                    sb.Append(@""">");
                    sb.Append(FormattingPipeline.PrepareTitle(c.Title, false, FormattingContext.PageContent, c.PageInfo));
                    sb.Append("</a></li>");
                }
                sb.Append("</ul>");
            }
            else
            {
                sb.Append("<p>");
                sb.Append(Properties.Messages.NoSimilarPages);
                sb.Append("</p>");
            }
            sb.Append(@"<br /><p>");
            sb.Append(Properties.Messages.YouCanAlso);
            sb.Append(@" <a href=""");
            UrlTools.BuildUrl(sb, "Search.aspx?Query=", Tools.UrlEncode(Request["Page"]));
            sb.Append(@""">");
            sb.Append(Properties.Messages.PerformASearch);
            sb.Append("</a> ");
            sb.Append(Properties.Messages.Or);
            sb.Append(@" <a href=""");
            UrlTools.BuildUrl(sb, "Edit.aspx?Page=", Tools.UrlEncode(Request["Page"]));
            sb.Append(@"""><b>");
            sb.Append(Properties.Messages.CreateThePage);
            sb.Append("</b></a> (");
            sb.Append(Properties.Messages.CouldRequireLogin);
            sb.Append(").</p>");

            lblSearchResults.Text = sb.ToString();
        }
예제 #12
0
        /// <summary>
        /// Creates a new instance of the <see cref="T:SearchResultRow" /> class.
        /// </summary>
        /// <param name="result">The result to use.</param>
        /// <returns>The instance.</returns>
        public static SearchResultRow CreateInstance(SearchResult result)
        {
            //string queryStringKeywords = "HL=" + GetKeywordsForQueryString(result.Matches);
            string queryStringKeywords = "HL=";

            if (result.DocumentType == DocumentType.Page)
            {
                PageDocument doc = result.Document as PageDocument;
                return(new SearchResultRow(doc.PageFullName + GlobalSettings.PageExtension + "?" + queryStringKeywords, Page,
                                           FormattingPipeline.PrepareTitle(Tools.DetectCurrentWiki(), doc.Title, false, FormattingContext.PageContent, doc.PageFullName),
                                           string.IsNullOrEmpty(doc.HighlightedContent) ? doc.Content : doc.HighlightedContent));
            }
            else if (result.DocumentType == DocumentType.Message)
            {
                MessageDocument doc     = result.Document as MessageDocument;
                PageContent     content = Pages.FindPage(doc.Wiki, doc.PageFullName);

                return(new SearchResultRow(content.FullName + GlobalSettings.PageExtension + "?" + queryStringKeywords + "&amp;Discuss=1#" + Tools.GetMessageIdForAnchor(doc.DateTime), Message,
                                           FormattingPipeline.PrepareTitle(Tools.DetectCurrentWiki(), doc.Subject, false, FormattingContext.MessageBody, content.FullName) + " (" +
                                           FormattingPipeline.PrepareTitle(Tools.DetectCurrentWiki(), content.Title, false, FormattingContext.MessageBody, content.FullName) +
                                           ")", doc.HighlightedBody));
            }
            else if (result.DocumentType == DocumentType.File)
            {
                FileDocument fileDoc = result.Document as FileDocument;

                string[] fileParts = fileDoc.FileName.Split(new char[] { '|' });

                return(new SearchResultRow("GetFile.aspx?File=" + Tools.UrlEncode(fileDoc.FileName.Substring(fileParts[0].Length + 1)) +
                                           "&amp;Provider=" + Tools.UrlEncode(fileParts[0]),
                                           File, fileParts[1], fileDoc.HighlightedFileContent));
            }
            else if (result.DocumentType == DocumentType.Attachment)
            {
                PageAttachmentDocument attnDoc = result.Document as PageAttachmentDocument;
                PageContent            content = Pages.FindPage(attnDoc.Wiki, attnDoc.PageFullName);

                return(new SearchResultRow(content.FullName + GlobalSettings.PageExtension, Attachment,
                                           attnDoc.FileName + " (" +
                                           FormattingPipeline.PrepareTitle(Tools.DetectCurrentWiki(), content.Title, false, FormattingContext.PageContent, content.FullName) +
                                           ")", attnDoc.HighlightedFileContent));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
예제 #13
0
        /// <summary>
        /// Creates a new instance of the <see cref="T:SearchResultRow" /> class.
        /// </summary>
        /// <param name="result">The result to use.</param>
        /// <returns>The instance.</returns>
        public static SearchResultRow CreateInstance(SearchResult result)
        {
            var queryStringKeywords = "HL=" + GetKeywordsForQueryString(result.Matches);

            if (result.Document.TypeTag == PageDocument.StandardTypeTag)
            {
                var pageDoc = result.Document as PageDocument;

                return(new SearchResultRow(pageDoc.PageInfo.FullName + Settings.PageExtension + "?" + queryStringKeywords, Page,
                                           FormattingPipeline.PrepareTitle(pageDoc.Title, false, FormattingContext.PageContent, pageDoc.PageInfo),
                                           result.Relevance.Value, GetExcerpt(pageDoc.PageInfo, result.Matches)));
            }
            else if (result.Document.TypeTag == MessageDocument.StandardTypeTag)
            {
                var msgDoc = result.Document as MessageDocument;

                PageContent content = Content.GetPageContent(msgDoc.PageInfo, true);

                return(new SearchResultRow(msgDoc.PageInfo.FullName + Settings.PageExtension + "?" + queryStringKeywords + "&amp;Discuss=1#" + Tools.GetMessageIdForAnchor(msgDoc.DateTime), Message,
                                           FormattingPipeline.PrepareTitle(msgDoc.Title, false, FormattingContext.MessageBody, content.PageInfo) + " (" +
                                           FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.MessageBody, content.PageInfo) +
                                           ")", result.Relevance.Value, GetExcerpt(msgDoc.PageInfo, msgDoc.MessageID, result.Matches)));
            }
            else if (result.Document.TypeTag == FileDocument.StandardTypeTag)
            {
                var fileDoc = result.Document as FileDocument;

                return(new SearchResultRow("GetFile.aspx?File=" + Tools.UrlEncode(fileDoc.Name.Substring(fileDoc.Provider.Length + 1)) +
                                           "&amp;Provider=" + Tools.UrlEncode(fileDoc.Provider),
                                           File, fileDoc.Title, result.Relevance.Value, ""));
            }
            else if (result.Document.TypeTag == PageAttachmentDocument.StandardTypeTag)
            {
                var         attnDoc = result.Document as PageAttachmentDocument;
                PageContent content = Content.GetPageContent(attnDoc.Page, false);

                return(new SearchResultRow(attnDoc.Page.FullName + Settings.PageExtension, Attachment,
                                           attnDoc.Title + " (" +
                                           FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, content.PageInfo) +
                                           ")", result.Relevance.Value, ""));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
예제 #14
0
        /// <summary>
        /// Gets the formatted Page Content, properly handling content caching and the Formatting Pipeline.
        /// </summary>
        /// <param name="page">The Page to get the formatted Content of.</param>
        /// <param name="cached">Specifies whether the formatted content has to be cached or not.</param>
        /// <returns>The formatted content.</returns>
        public static string GetFormattedPageContent(PageInfo page, bool cached)
        {
            string content = Cache.GetFormattedPageContent(page);

            if (content == null)
            {
                PageContent pg = GetPageContent(page, cached);
                string[]    linkedPages;
                content        = FormattingPipeline.FormatWithPhase1And2(pg.Content, false, FormattingContext.PageContent, page, out linkedPages);
                pg.LinkedPages = linkedPages;
                if (!pg.IsEmpty() && cached && !page.NonCached && !Settings.DisableCache)
                {
                    Cache.SetFormattedPageContent(page, content);
                }
            }
            return(FormattingPipeline.FormatWithPhase3(content, FormattingContext.PageContent, page));
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RevisionRow" /> class.
 /// </summary>
 /// <param name="revision">The revision (<b>-1</b> for current).</param>
 /// <param name="content">The original page content.</param>
 /// <param name="canRollback">A value indicating whether the current user can rollback the page.</param>
 public RevisionRow(int revision, PageContent content, bool canRollback)
 {
     this.page = content.PageInfo.FullName;
     if (revision == -1)
     {
         this.revision = Properties.Messages.Current;
     }
     else
     {
         this.revision = revision.ToString();
     }
     title            = FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, content.PageInfo);
     savedOn          = Preferences.AlignWithTimezone(content.LastModified).ToString(Settings.DateTimeFormat);
     savedBy          = Users.UserLink(content.User);
     comment          = content.Comment;
     this.canRollback = canRollback;
 }
예제 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string currentWiki = DetectWiki();

            Page.Title = Properties.Messages.AccessDeniedTitle + " - " + Settings.GetWikiTitle(currentWiki);

            string n = Settings.GetProvider(currentWiki).GetMetaDataItem(MetaDataItem.AccessDeniedNotice, null);

            if (!string.IsNullOrEmpty(n))
            {
                n = FormattingPipeline.FormatWithPhase1And2(currentWiki, n, false, FormattingContext.Other, null);
            }
            if (!string.IsNullOrEmpty(n))
            {
                lblDescription.Text = FormattingPipeline.FormatWithPhase3(currentWiki, n, FormattingContext.Other, null);
            }
        }
예제 #17
0
        /// <summary>
        /// Prints the login notice.
        /// </summary>
        public void PrintLoginNotice()
        {
            string n = Content.GetPseudoCacheValue("LoginNotice");

            if (n == null)
            {
                n = Settings.Provider.GetMetaDataItem(MetaDataItem.LoginNotice, null);
                if (!string.IsNullOrEmpty(n))
                {
                    n = FormattingPipeline.FormatWithPhase1And2(n, false, FormattingContext.Other, null);
                    Content.SetPseudoCacheValue("LoginNotice", n);
                }
            }
            if (!string.IsNullOrEmpty(n))
            {
                lblDescription.Text = FormattingPipeline.FormatWithPhase3(n, FormattingContext.Other, null);
            }
        }
예제 #18
0
        protected List <TreeElement> ctPages_Populate(object sender, PopulateEventArgs e)
        {
            string currentNamespace = DetectNamespace();

            if (string.IsNullOrEmpty(currentNamespace))
            {
                currentNamespace = null;
            }

            List <TreeElement> result = new List <TreeElement>(100);

            foreach (PageInfo pi in Pages.GetPages(Pages.FindNamespace(lstNamespace.SelectedValue)))
            {
                string pageNamespace = NameTools.GetNamespace(pi.FullName);
                if (string.IsNullOrEmpty(pageNamespace))
                {
                    pageNamespace = null;
                }

                PageContent cont              = Content.GetPageContent(pi, true);
                string      formattedTitle    = FormattingPipeline.PrepareTitle(cont.Title, false, FormattingContext.Other, pi);
                string      onClickJavascript = "javascript:";
                // Populate the page title box if the title is different to the page name
                if (pi.FullName != cont.Title)
                {
                    // Supply the page title to the Javascript that sets the page title on the page
                    // We can safely escape the \ and ' characters, but the " character is interpreted by the browser even if it is escaped to Javascript, so we can't allow it.
                    // Instead we replace it with an escaped single quote.
                    // Similarly, < on it's own is fine, but causes problems when combined with text and > to form a tag.  Safest to remove < characters to prevent
                    // breaking the drop-down.
                    onClickJavascript += "SetValue('txtPageTitle', '" + cont.Title.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\'").Replace("<", "") + "');";
                }
                else
                {
                    onClickJavascript += "SetValue('txtPageTitle', '');";
                }
                // Populate the page name
                onClickJavascript += "return SetValue('txtPageName', '" +
                                     ((pageNamespace == currentNamespace ? NameTools.GetLocalName(pi.FullName) : ("++" + pi.FullName))).Replace("++++", "++") + "');";
                TreeElement item = new TreeElement(pi.FullName, formattedTitle, onClickJavascript);
                result.Add(item);
            }
            return(result);
        }
예제 #19
0
        /// <summary>
        /// Verifies the need for a page redirection, and performs it when appropriate.
        /// </summary>
        private void VerifyAndPerformPageRedirection()
        {
            if (currentPage == null)
            {
                return;
            }

            // Force formatting so that the destination can be detected
            Content.GetFormattedPageContent(currentPage, true);

            PageInfo dest = Redirections.GetDestination(currentPage);

            if (dest == null)
            {
                return;
            }

            if (dest != null)
            {
                if (Request["NoRedirect"] != "1")
                {
                    UrlTools.Redirect(dest.FullName + Settings.PageExtension + "?From=" + currentPage.FullName, false);
                }
                else
                {
                    // Write redirection hint
                    StringBuilder sb = new StringBuilder();
                    sb.Append(@"<div id=""RedirectionDiv"">");
                    sb.Append(Properties.Messages.ThisPageRedirectsTo);
                    sb.Append(": ");
                    sb.Append(@"<a href=""");
                    UrlTools.BuildUrl(sb, "++", Tools.UrlEncode(dest.FullName), Settings.PageExtension, "?From=", Tools.UrlEncode(currentPage.FullName));
                    sb.Append(@""">");
                    PageContent k = Content.GetPageContent(dest, true);
                    sb.Append(FormattingPipeline.PrepareTitle(k.Title, false, FormattingContext.PageContent, currentPage));
                    sb.Append("</a></div>");
                    Literal literal = new Literal();
                    literal.Text = sb.ToString();
                    plhContent.Controls.Add(literal);
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PageRow" /> class.
        /// </summary>
        /// <param name="page">The original page.</param>
        /// <param name="currentContent">The current content.</param>
        /// <param name="firstContent">The first revision content.</param>
        /// <param name="discussionCount">The number of messages in the discussion.</param>
        /// <param name="revisionCount">The number of revisions.</param>
        /// <param name="isOrphan">A value indicating whether the page is orphan.</param>
        /// <param name="canEdit">A value indicating whether the current user can edit the page.</param>
        /// <param name="canSelect">A value indicating whether the current user can select the page.</param>
        /// <param name="canSetPermissions">A value indicating whether the current user can set permissions for the page.</param>
        /// <param name="selected">A value indicating whether the page is selected.</param>
        public PageRow(PageInfo page, PageContent currentContent, PageContent firstContent, int discussionCount, int revisionCount,
                       bool isOrphan, bool canEdit, bool canSelect, bool canSetPermissions, bool selected)
        {
            fullName       = page.FullName;
            title          = FormattingPipeline.PrepareTitle(currentContent.Title, false, FormattingContext.Other, page);
            createdBy      = firstContent.User;
            createdOn      = Preferences.AlignWithTimezone(page.CreationDateTime).ToString(Settings.DateTimeFormat);
            lastModifiedBy = currentContent.User;
            lastModifiedOn = Preferences.AlignWithTimezone(currentContent.LastModified).ToString(Settings.DateTimeFormat);
            discussion     = discussionCount.ToString();
            revisions      = revisionCount.ToString();
            provider       = page.Provider.Information.Name;

            this.isOrphan = isOrphan;

            this.canEdit           = canEdit;
            this.canSelect         = canSelect;
            this.canSetPermissions = canSetPermissions;
            additionalClass        = selected ? " selected" : "";
        }
예제 #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Properties.Messages.AccessDeniedTitle + " - " + Settings.WikiTitle;

            string n = Content.GetPseudoCacheValue("AccessDeniedNotice");

            if (n == null)
            {
                n = Settings.Provider.GetMetaDataItem(MetaDataItem.AccessDeniedNotice, null);
                if (!string.IsNullOrEmpty(n))
                {
                    n = FormattingPipeline.FormatWithPhase1And2(n, false, FormattingContext.Other, null);
                    Content.SetPseudoCacheValue("AccessDeniedNotice", n);
                }
            }
            if (!string.IsNullOrEmpty(n))
            {
                lblDescription.Text = FormattingPipeline.FormatWithPhase3(n, FormattingContext.Other, null);
            }
        }
예제 #22
0
        protected void btnPreview_Click(object sender, EventArgs e)
        {
            SelectTab(2);

            //added for WYSIWYG
            //if last view was WYSIWYG take text from WYSIWYG to Preview
            //in both cases I need to synchronize WYSIWYG and Markup view
            if (inWYSIWYG)
            {
                lblPreview.Text = lblWYSIWYG.Text.Replace("&lt;", "<").Replace("&gt;", ">");
                txtMarkup.Text  = ReverseFormatter.ReverseFormat(lblWYSIWYG.Text);
            }
            else
            {
                lblPreview.Text = FormattingPipeline.FormatWithPhase3(FormattingPipeline.FormatWithPhase1And2(txtMarkup.Text, false, FormattingContext.Unknown, null), FormattingContext.Unknown, null);
                //lblWYSIWYG.Text = lblPreview.Text;
                lblWYSIWYG.Text = Formatter.Format(txtMarkup.Text, false, FormattingContext.Unknown, null, out var links, true);
            }
            //end
        }
예제 #23
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            lstAvailablePage.Items.Clear();
            btnAddPage.Enabled = false;

            txtPageName.Text = txtPageName.Text.Trim();

            if (txtPageName.Text.Length == 0)
            {
                return;
            }

            PageInfo[] pages = SearchTools.SearchSimilarPages(txtPageName.Text, CurrentNamespace);

            string cp = CurrentProvider;

            foreach (PageInfo page in
                     from p in pages
                     where p.Provider.GetType().FullName == cp
                     select p)
            {
                // Filter pages already in the list
                bool found = false;
                foreach (ListItem item in lstPages.Items)
                {
                    if (item.Value == page.FullName)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    PageContent content = Content.GetPageContent(page, false);
                    lstAvailablePage.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.Other, page), page.FullName));
                }
            }

            btnAddPage.Enabled = lstAvailablePage.Items.Count > 0;
        }
예제 #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PageRow" /> class.
        /// </summary>
        /// <param name="nspace">The namespace.</param>
        /// <param name="nspacePrefix">The namespace prefix.</param>
        /// <param name="name">The full name.</param>
        /// <param name="linkingPages">The pages that link the wanted page.</param>
        public WantedPageRow(string nspace, string nspacePrefix, string name, List <string> linkingPages)
        {
            this.nspace       = nspace;
            this.nspacePrefix = nspacePrefix;
            this.name         = name;

            StringBuilder sb = new StringBuilder(100);

            for (int i = 0; i < linkingPages.Count; i++)
            {
                PageInfo page = Pages.FindPage(linkingPages[i]);
                if (page != null)
                {
                    PageContent content = Content.GetPageContent(page, false);

                    sb.AppendFormat(@"<a href=""{0}{1}"" title=""{2}"" target=""_blank"">{2}</a>, ", page.FullName, Settings.PageExtension,
                                    FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.Other, page));
                }
            }
            this.linkingPages = sb.ToString().TrimEnd(' ', ',');
        }
예제 #25
0
        /// <summary>
        /// Prints the page header and page footer.
        /// </summary>
        public void PrintPageHeaderAndFooter()
        {
            string h = Content.GetPseudoCacheValue(GetPseudoCacheItemName("PageHeader"));

            if (h == null)
            {
                h = GetMetadataItemWithFallback(MetaDataItem.PageHeader, currentNamespace);
                h = @"<div id=""PageInternalHeaderDiv"">" + FormattingPipeline.FormatWithPhase1And2(h, false, FormattingContext.PageHeader, currentPage) + "</div>";
                Content.SetPseudoCacheValue(GetPseudoCacheItemName("PageHeader"), h);
            }
            lblPageHeaderDiv.Text = FormattingPipeline.FormatWithPhase3(h, FormattingContext.PageHeader, currentPage);

            h = Content.GetPseudoCacheValue(GetPseudoCacheItemName("PageFooter"));
            if (h == null)
            {
                h = GetMetadataItemWithFallback(MetaDataItem.PageFooter, currentNamespace);
                h = @"<div id=""PageInternalFooterDiv"">" + FormattingPipeline.FormatWithPhase1And2(h, false, FormattingContext.PageFooter, currentPage) + "</div>";
                Content.SetPseudoCacheValue(GetPseudoCacheItemName("PageFooter"), h);
            }
            lblPageFooterDiv.Text = FormattingPipeline.FormatWithPhase3(h, FormattingContext.PageFooter, currentPage);
        }
예제 #26
0
        /// <summary>
        /// Loads the draft information, if any.
        /// </summary>
        /// <param name="currentPage">The current page name.</param>
        private void LoadDraft(string currentPage)
        {
            PageInfo    page  = Pages.FindPage(currentPage);
            PageContent draft = Pages.GetDraft(page);

            if (draft != null)
            {
                pnlApproveRevision.Visible = true;
                lblDateTime.Text           = Preferences.AlignWithTimezone(draft.LastModified).ToString(Settings.DateTimeFormat);
                lblUser.Text = Users.UserLink(draft.User, true);

                // Ampersands are escaped automatically
                lnkEdit.NavigateUrl  = "Edit.aspx?Page=" + Tools.UrlEncode(currentPage);
                lnkDiff.NavigateUrl  = "Diff.aspx?Page=" + Tools.UrlEncode(currentPage) + "&Rev1=Current&Rev2=Draft";
                lblDraftPreview.Text = FormattingPipeline.FormatWithPhase3(
                    FormattingPipeline.FormatWithPhase1And2(draft.Content, false, FormattingContext.PageContent, page), FormattingContext.PageContent, page);
            }
            else
            {
                pnlApproveRevision.Visible = false;
            }
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentWiki = DetectWiki();

            page = Pages.FindPage(currentWiki, Request["Page"]);
            if (page == null)
            {
                UrlTools.RedirectHome(currentWiki);
            }

            // Check permissions
            bool        canView     = false;
            AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            if (Request["Discuss"] == null)
            {
                canView = authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ReadPage,
                                                         SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki));
            }
            else
            {
                canView = authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ReadDiscussion,
                                                         SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki));
            }
            if (!canView)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            Page.Title = FormattingPipeline.PrepareTitle(currentWiki, page.Title, false, FormattingContext.PageContent, page.FullName) + " - " + Settings.GetWikiTitle(currentWiki);

            Literal canonical = new Literal();

            canonical.Text = Tools.GetCanonicalUrlTag(Request.Url.ToString(), page.FullName, Pages.FindNamespace(currentWiki, NameTools.GetNamespace(page.FullName)));
            Page.Header.Controls.Add(canonical);

            PrintContent();
        }
예제 #28
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            txtPageName.Text = txtPageName.Text.Trim();

            if (txtPageName.Text.Length == 0)
            {
                lstAvailablePage.Items.Clear();
                btnAdd.Enabled = false;
                return;
            }

            PageInfo[] pages = SearchTools.SearchSimilarPages(txtPageName.Text, lstNamespace.SelectedValue);

            lstAvailablePage.Items.Clear();

            foreach (PageInfo page in pages)
            {
                PageContent content = Content.GetPageContent(page, false);
                lstAvailablePage.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.Other, page), page.FullName));
            }

            btnAdd.Enabled = pages.Length > 0;
        }
예제 #29
0
        /// <summary>
        /// Prints the content.
        /// </summary>
        public void PrintContent()
        {
            StringBuilder sb    = new StringBuilder(5000);
            string        title = FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page);

            if (Request["Discuss"] == null)
            {
                string[] categories =
                    (from c in Pages.GetCategoriesForPage(page)
                     select NameTools.GetLocalName(c.FullName)).ToArray();

                UserInfo user = Users.FindUser(content.User);

                sb.Append(@"<h1 class=""pagetitle"">");
                sb.Append(title);
                sb.Append("</h1>");
                if (Settings.EnablePageInfoDiv)
                {
                    sb.AppendFormat("<small>{0} {1} {2} {3} &mdash; {4}: {5}</small><br /><br />",
                                    Properties.Messages.ModifiedOn,
                                    Preferences.AlignWithTimezone(content.LastModified).ToString(Settings.DateTimeFormat),
                                    Properties.Messages.By,
                                    user != null ? Users.GetDisplayName(user) : content.User,
                                    Properties.Messages.CategorizedAs,
                                    categories.Length == 0 ? Properties.Messages.Uncategorized : string.Join(", ", categories));
                }
                sb.Append(Content.GetFormattedPageContent(page, true));
            }
            else
            {
                sb.Append(@"<h1 class=""pagetitle"">");
                sb.Append(title);
                sb.Append(" - Discussion</h1>");
                PrintDiscussion(sb);
            }
            lblContent.Text = sb.ToString();
        }
예제 #30
0
        protected void rptNavPaths_ItemCommand(object sender, CommandEventArgs e)
        {
            txtCurrentNavPath.Value = e.CommandArgument as string;

            if (e.CommandName == "Select")
            {
                if (!CanManagePagesInCurrentNamespace())
                {
                    return;
                }

                string currentWiki = DetectWiki();

                txtName.Text    = txtCurrentNavPath.Value;
                txtName.Enabled = false;

                NavigationPath path = NavigationPaths.Find(currentWiki, txtCurrentNavPath.Value);
                foreach (string page in path.Pages)
                {
                    PageContent pageContent = Pages.FindPage(currentWiki, page);
                    if (pageContent != null)
                    {
                        lstPages.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(currentWiki, pageContent.Title, false, FormattingContext.Other, pageContent.FullName), pageContent.FullName));
                    }
                }

                cvName2.Enabled   = false;
                btnCreate.Visible = false;
                btnSave.Visible   = true;
                btnDelete.Visible = true;

                pnlList.Visible        = false;
                pnlEditNavPath.Visible = true;

                lblResult.Text = "";
            }
        }