/// <summary>
        /// Loads the content configuration.
        /// </summary>
        /// <param name="currentWiki">The wiki.</param>
        private void LoadContentConfig(string currentWiki)
        {
            string[] theme = Settings.GetTheme(currentWiki, null).Split(new char[] { '|' });
            ThemeRootSelector.SelectedProvider = theme[0];
            ThemeRootSelector.SelectedThemes   = theme[1];
            PopulateMainPages(Settings.GetDefaultPage(currentWiki));
            txtDateTimeFormat.Text = Settings.GetDateTimeFormat(currentWiki);
            PopulateDateTimeFormats();
            PopulateLanguages(Settings.GetDefaultLanguage(currentWiki));
            PopulateTimeZones(Settings.GetDefaultTimezone(currentWiki));
            txtMaxRecentChangesToDisplay.Text = Settings.GetMaxRecentChangesToDisplay(currentWiki).ToString();

            lstRssFeedsMode.SelectedIndex = -1;
            switch (Settings.GetRssFeedsMode(currentWiki))
            {
            case RssFeedsMode.FullText:
                lstRssFeedsMode.SelectedIndex = 0;
                break;

            case RssFeedsMode.Summary:
                lstRssFeedsMode.SelectedIndex = 1;
                break;

            case RssFeedsMode.Disabled:
                lstRssFeedsMode.SelectedIndex = 2;
                break;
            }

            chkEnableDoubleClickEditing.Checked = Settings.GetEnableDoubleClickEditing(currentWiki);
            chkEnableSectionEditing.Checked     = Settings.GetEnableSectionEditing(currentWiki);
            chkEnableSectionAnchors.Checked     = Settings.GetEnableSectionAnchors(currentWiki);
            chkEnablePageToolbar.Checked        = Settings.GetEnablePageToolbar(currentWiki);
            chkEnableViewPageCode.Checked       = Settings.GetEnableViewPageCodeFeature(currentWiki);
            chkEnablePageInfoDiv.Checked        = Settings.GetEnablePageInfoDiv(currentWiki);
            chkEnableBreadcrumbsTrail.Checked   = !Settings.GetDisableBreadcrumbsTrail(currentWiki);
            chkAutoGeneratePageNames.Checked    = Settings.GetAutoGeneratePageNames(currentWiki);
            chkProcessSingleLineBreaks.Checked  = Settings.GetProcessSingleLineBreaks(currentWiki);
            chkUseVisualEditorAsDefault.Checked = Settings.GetUseVisualEditorAsDefault(currentWiki);
            if (Settings.GetKeptBackupNumber(currentWiki) == -1)
            {
                txtKeptBackupNumber.Text = "";
            }
            else
            {
                txtKeptBackupNumber.Text = Settings.GetKeptBackupNumber(currentWiki).ToString();
            }
            chkDisplayGravatars.Checked = Settings.GetDisplayGravatars(currentWiki);
            txtListSize.Text            = Settings.GetListSize(currentWiki).ToString();
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:UserRow" /> class.
        /// </summary>
        /// <param name="user">The original user.</param>
        /// <param name="groups">The groups the user is member of.</param>
        /// <param name="selected">A value indicating whether the user is selected.</param>
        public UserRow(UserInfo user, List <UserGroup> groups, bool selected)
        {
            username    = user.Username;
            displayName = Users.GetDisplayName(user);
            email       = user.Email;

            StringBuilder sb = new StringBuilder(50);

            for (int i = 0; i < groups.Count; i++)
            {
                sb.Append(groups[i].Name);
                if (i != groups.Count - 1)
                {
                    sb.Append(", ");
                }
            }
            memberOf = sb.ToString();

            regDateTime     = user.DateTime.ToString(Settings.GetDateTimeFormat(Tools.DetectCurrentWiki()));
            provider        = user.Provider.Information.Name;
            additionalClass = (selected ? " selected" : "") + (!user.Active ? " inactive" : "");
        }
Exemple #3
0
        /// <summary>
        /// Prints the history.
        /// </summary>
        public void PrintHistory()
        {
            if (page == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            if (Request["Revision"] == null)
            {
                // Show version list
                List <int> revisions = Pages.GetBackups(page);
                revisions.Reverse();

                List <RevisionRow> result = new List <RevisionRow>(revisions.Count + 1);

                result.Add(new RevisionRow(-1, page, false));

                foreach (int rev in revisions)
                {
                    PageContent content = Pages.GetBackupContent(page, rev);

                    result.Add(new RevisionRow(rev, content, canRollback));
                }

                rptHistory.DataSource = result;
                rptHistory.DataBind();
            }
            else
            {
                int rev = -1;
                if (!int.TryParse(Request["Revision"], out rev))
                {
                    UrlTools.Redirect(page.FullName + GlobalSettings.PageExtension);
                }

                List <int> backups = Pages.GetBackups(page);
                if (!backups.Contains(rev))
                {
                    UrlTools.Redirect(page.FullName + GlobalSettings.PageExtension);
                    return;
                }
                PageContent revision = Pages.GetBackupContent(page, rev);
                sb.Append(@"<table class=""box"" cellpadding=""0"" cellspacing=""0""><tr><td>");
                sb.Append(@"<p style=""text-align: center;""><b>");
                if (rev > 0)
                {
                    sb.Append(@"<a href=""");
                    UrlTools.BuildUrl(currentWiki, sb, "History.aspx?Page=", Tools.UrlEncode(page.FullName),
                                      "&amp;Revision=", Tools.GetVersionString((int)(rev - 1)));

                    sb.Append(@""">&laquo; ");
                    sb.Append(Properties.Messages.OlderRevision);
                    sb.Append("</a>");
                }
                else
                {
                    sb.Append("&laquo; ");
                    sb.Append(Properties.Messages.OlderRevision);
                }

                sb.Append(@" - <a href=""");
                UrlTools.BuildUrl(currentWiki, sb, "History.aspx?Page=", Tools.UrlEncode(page.FullName));
                sb.Append(@""">");
                sb.Append(Properties.Messages.BackToHistory);
                sb.Append("</a> - ");

                if (rev < backups.Count - 1)
                {
                    sb.Append(@"<a href=""");
                    UrlTools.BuildUrl(currentWiki, sb, "History.aspx?Page=", Tools.UrlEncode(page.FullName),
                                      "&amp;Revision=", Tools.GetVersionString((int)(rev + 1)));

                    sb.Append(@""">");
                    sb.Append(Properties.Messages.NewerRevision);
                    sb.Append(" &raquo;</a>");
                }
                else
                {
                    sb.Append(@"<a href=""");
                    UrlTools.BuildUrl(currentWiki, sb, Tools.UrlEncode(page.FullName), GlobalSettings.PageExtension);
                    sb.Append(@""">");
                    sb.Append(Properties.Messages.CurrentRevision);
                    sb.Append("</a>");
                }
                sb.Append("</b></p></td></tr></table><br />");

                sb.Append(@"<h3 class=""separator"">");
                sb.Append(Properties.Messages.PageRevision);
                sb.Append(": ");
                sb.Append(Preferences.AlignWithTimezone(currentWiki, revision.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki)));
                sb.Append("</h3><br />");

                sb.Append(FormattingPipeline.FormatWithPhase3(currentWiki, FormattingPipeline.FormatWithPhase1And2(currentWiki, revision.Content,
                                                                                                                   false, FormattingContext.PageContent, page.FullName).Replace(Formatter.EditSectionPlaceHolder, ""), FormattingContext.PageContent, page.FullName));
            }

            lblHistory.Text = sb.ToString();
        }
Exemple #4
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)
        {
            string currentWiki = Tools.DetectCurrentWiki();

            this.wiki = currentWiki;
            this.page = content.FullName;
            if (revision == -1)
            {
                this.revision = Properties.Messages.Current;
            }
            else
            {
                this.revision = revision.ToString();
            }
            title            = FormattingPipeline.PrepareTitle(currentWiki, content.Title, false, FormattingContext.PageContent, content.FullName);
            savedOn          = Preferences.AlignWithTimezone(currentWiki, content.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki));
            savedBy          = Users.UserLink(currentWiki, content.User);
            comment          = content.Comment;
            this.canRollback = canRollback;
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:LogEntryRow" /> class.
        /// </summary>
        /// <param name="entry">The original log entry.</param>
        public LogEntryRow(LogEntry entry)
        {
            string currentWiki = Tools.DetectCurrentWiki();

            imageTag = entry.EntryType.ToString();
            dateTime = Preferences.AlignWithTimezone(currentWiki, entry.DateTime).ToString(Settings.GetDateTimeFormat(currentWiki)).Replace(" ", "&nbsp;");
            user     = entry.User.Replace(" ", "&nbsp;");
            wiki     = string.IsNullOrEmpty(entry.Wiki) ? "" : entry.Wiki.Replace(" ", "&nbsp;");
            message  = entry.Message.Replace("&", "&amp;");

            if (entry.EntryType == EntryType.Error)
            {
                additionalClass = " error";
            }
            else if (entry.EntryType == EntryType.Warning)
            {
                additionalClass = " warning";
            }
            else
            {
                additionalClass = "";
            }
        }
Exemple #6
0
        /// <summary>
        /// Loads the backups for a page and populates the backups and revisions drop-down lists.
        /// </summary>
        /// <param name="pageName">The page.</param>
        private void LoadBackups(string pageName)
        {
            PageContent page    = Pages.FindPage(currentWiki, pageName);
            List <int>  backups = Pages.GetBackups(page);

            lstRevision.Items.Clear();
            lstBackup.Items.Clear();

            foreach (int bak in backups)
            {
                PageContent bakContent = Pages.GetBackupContent(page, bak);

                ListItem item = new ListItem(bak.ToString() + ": " +
                                             Preferences.AlignWithTimezone(currentWiki, bakContent.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki)) +
                                             " " + Properties.Messages.By + " " + bakContent.User,
                                             bak.ToString());

                // Add in reverse order - newer revisions at the top
                lstRevision.Items.Insert(0, item);
                lstBackup.Items.Insert(0, item);
            }
        }
Exemple #7
0
        /// <summary>
        /// Loads the draft information, if any.
        /// </summary>
        /// <param name="currentPage">The current page name.</param>
        private void LoadDraft(string currentPage)
        {
            PageContent page  = Pages.FindPage(currentWiki, currentPage);
            PageContent draft = Pages.GetDraft(page);

            if (draft != null)
            {
                pnlApproveRevision.Visible = true;
                lblDateTime.Text           = Preferences.AlignWithTimezone(currentWiki, draft.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki));
                lblUser.Text = Users.UserLink(currentWiki, 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(
                    currentWiki, FormattingPipeline.FormatWithPhase1And2(currentWiki, draft.Content, false, FormattingContext.PageContent, page.FullName), FormattingContext.PageContent, page.FullName);
            }
            else
            {
                pnlApproveRevision.Visible = false;
            }
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PageRow" /> class.
        /// </summary>
        /// <param name="page">The page 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(PageContent page, PageContent firstContent, int discussionCount, int revisionCount,
                       bool isOrphan, bool canEdit, bool canSelect, bool canSetPermissions, bool selected)
        {
            string currentWiki = Tools.DetectCurrentWiki();

            fullName       = page.FullName;
            title          = FormattingPipeline.PrepareTitle(currentWiki, page.Title, false, FormattingContext.Other, page.FullName);
            createdBy      = firstContent.User;
            createdOn      = Preferences.AlignWithTimezone(currentWiki, page.CreationDateTime).ToString(Settings.GetDateTimeFormat(currentWiki));
            lastModifiedBy = page.User;
            lastModifiedOn = Preferences.AlignWithTimezone(currentWiki, page.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki));
            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" : "";
        }
Exemple #9
0
 /// <summary>
 /// Manages the draft status display.
 /// </summary>
 private void ManageDraft()
 {
     if (isDraft)
     {
         chkSaveAsDraft.Checked = true;
         chkMinorChange.Enabled = false;
         pnlDraft.Visible       = true;
         lblDraftInfo.Text      = lblDraftInfo.Text.Replace("##USER##",
                                                            Users.UserLink(currentWiki, currentPage.User, true)).Replace("##DATETIME##",
                                                                                                                         Preferences.AlignWithTimezone(currentWiki, currentPage.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki))).Replace("##VIEWCHANGES##",
                                                                                                                                                                                                                                                         string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", UrlTools.BuildUrl(currentWiki, "Diff.aspx?Page=",
                                                                                                                                                                                                                                                                                                                                      Tools.UrlEncode(currentPage.FullName), "&amp;Rev1=Current&amp;Rev2=Draft"),
                                                                                                                                                                                                                                                                       Properties.Messages.ViewChanges));
     }
     else
     {
         pnlDraft.Visible = false;
     }
 }
Exemple #10
0
        /// <summary>
        /// Prepares the message deletion GUI.
        /// </summary>
        private void PrepareDeleteMessage()
        {
            string ms = Request["Message"];
            string pg = Request["Page"];

            if (ms == null || ms.Length == 0 || pg == null || pg.Length == 0)
            {
                UrlTools.RedirectHome(currentWiki);
            }

            PageContent page = Pages.FindPage(currentWiki, pg);

            if (page == null)
            {
                UrlTools.RedirectHome(currentWiki);
            }
            if (page.Provider.ReadOnly)
            {
                UrlTools.Redirect(UrlTools.BuildUrl(currentWiki, page.FullName, GlobalSettings.PageExtension));
            }

            AuthChecker authChecker         = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));
            bool        canManageDiscussion = authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ManageDiscussion,
                                                                             SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki));

            if (!canManageDiscussion)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            int id = -1;

            try {
                id = int.Parse(ms);
            }
            catch {
                UrlTools.RedirectHome(currentWiki);
            }

            Message message = Pages.FindMessage(Pages.GetPageMessages(page), id);

            if (message == null)
            {
                UrlTools.RedirectHome(currentWiki);
            }

            StringBuilder sb = new StringBuilder(500);

            sb.Append("<b>");
            sb.Append(FormattingPipeline.PrepareTitle(currentWiki, message.Subject, false, FormattingContext.MessageBody, page.FullName));
            sb.Append("</b><br /><small>");
            sb.Append(Properties.Messages.Posted);
            sb.Append(" ");
            sb.Append(Preferences.AlignWithTimezone(currentWiki, message.DateTime).ToString(Settings.GetDateTimeFormat(currentWiki)));
            sb.Append(" ");
            sb.Append(Properties.Messages.By);
            sb.Append(" ");
            sb.Append(Users.UserLink(currentWiki, message.Username));
            sb.Append("</small><br /><br />");
            sb.Append(FormattingPipeline.FormatWithPhase3(currentWiki, FormattingPipeline.FormatWithPhase1And2(currentWiki, message.Body, false, FormattingContext.MessageBody, page.FullName),
                                                          FormattingContext.MessageBody, page.FullName));

            lblDeleteMessageContent.Text = sb.ToString();
        }
Exemple #11
0
        /// <summary>
        /// Prints the pages.
        /// </summary>
        public void PrintPages()
        {
            StringBuilder sb = new StringBuilder(65536);

            if (currentPages == null)
            {
                currentPages = GetAllPages();
            }

            string currentWiki = DetectWiki();

            // Prepare ExtendedPageInfo array
            ExtendedPageInfo[] tempPageList = new ExtendedPageInfo[rangeEnd - rangeBegin + 1];
            for (int i = 0; i < tempPageList.Length; i++)
            {
                tempPageList[i] = new ExtendedPageInfo(currentPages[rangeBegin + i], GetCreator(currentPages[rangeBegin + i]), currentPages[rangeBegin + i].User);
            }

            // Prepare for sorting
            bool          reverse = false;
            SortingMethod sortBy  = SortingMethod.Title;

            if (Request["SortBy"] != null)
            {
                try {
                    sortBy = (SortingMethod)Enum.Parse(typeof(SortingMethod), Request["SortBy"], true);
                }
                catch {
                    // Backwards compatibility
                    if (Request["SortBy"].ToLowerInvariant() == "date")
                    {
                        sortBy = SortingMethod.DateTime;
                    }
                }
                if (Request["Reverse"] != null)
                {
                    reverse = true;
                }
            }

            SortedDictionary <SortingGroup, List <ExtendedPageInfo> > sortedPages = PageSortingTools.Sort(tempPageList, sortBy, reverse);

            sb.Append(@"<table id=""PageListTable"" class=""generic"" cellpadding=""0"" cellspacing=""0"">");
            sb.Append("<thead>");
            sb.Append(@"<tr class=""tableheader"">");

            // Page title
            sb.Append(@"<th><a rel=""nofollow"" href=""");
            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?SortBy=Title",
                              (!reverse && sortBy == SortingMethod.Title ? "&amp;Reverse=1" : ""),
                              (Request["Cat"] != null ? "&amp;Cat=" + Tools.UrlEncode(Request["Cat"]) : ""),
                              "&amp;Page=", selectedPage.ToString());

            sb.Append(@""" title=""");
            sb.Append(Properties.Messages.SortByTitle);
            sb.Append(@""">");
            sb.Append(Properties.Messages.PageTitle);
            sb.Append((reverse && sortBy.Equals("title") ? " &uarr;" : ""));
            sb.Append((!reverse && sortBy.Equals("title") ? " &darr;" : ""));
            sb.Append("</a></th>");

            // Message count
            sb.Append(@"<th><img src=""Images/Comment.png"" alt=""Comments"" /></th>");

            // Creation date/time
            sb.Append(@"<th><a rel=""nofollow"" href=""");
            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?SortBy=Creation",
                              (!reverse && sortBy == SortingMethod.Creation ? "&amp;Reverse=1" : ""),
                              (Request["Cat"] != null ? "&amp;Cat=" + Tools.UrlEncode(Request["Cat"]) : ""),
                              "&amp;Page=", selectedPage.ToString());

            sb.Append(@""" title=""");
            sb.Append(Properties.Messages.SortByDate);
            sb.Append(@""">");
            sb.Append(Properties.Messages.CreatedOn);
            sb.Append((reverse && sortBy.Equals("creation") ? " &uarr;" : ""));
            sb.Append((!reverse && sortBy.Equals("creation") ? " &darr;" : ""));
            sb.Append("</a></th>");

            // Mod. date/time
            sb.Append(@"<th><a rel=""nofollow"" href=""");
            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?SortBy=DateTime",
                              (!reverse && sortBy == SortingMethod.DateTime ? "&amp;Reverse=1" : ""),
                              (Request["Cat"] != null ? "&amp;Cat=" + Tools.UrlEncode(Request["Cat"]) : ""),
                              "&amp;Page=", selectedPage.ToString());

            sb.Append(@""" title=""");
            sb.Append(Properties.Messages.SortByDate);
            sb.Append(@""">");
            sb.Append(Properties.Messages.ModifiedOn);
            sb.Append((reverse && sortBy.Equals("date") ? " &uarr;" : ""));
            sb.Append((!reverse && sortBy.Equals("date") ? " &darr;" : ""));
            sb.Append("</a></th>");

            // Creator
            sb.Append(@"<th><a rel=""nofollow"" href=""");
            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?SortBy=Creator",
                              (!reverse && sortBy == SortingMethod.Creator ? "&amp;Reverse=1" : ""),
                              (Request["Cat"] != null ? "&amp;Cat=" + Tools.UrlEncode(Request["Cat"]) : ""),
                              "&amp;Page=", selectedPage.ToString());

            sb.Append(@""" title=""");
            sb.Append(Properties.Messages.SortByUser);
            sb.Append(@""">");
            sb.Append(Properties.Messages.CreatedBy);
            sb.Append((reverse && sortBy.Equals("creator") ? " &uarr;" : ""));
            sb.Append((!reverse && sortBy.Equals("creator") ? " &darr;" : ""));
            sb.Append("</a></th>");

            // Last author
            sb.Append(@"<th><a rel=""nofollow"" href=""");
            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?SortBy=User",
                              (!reverse && sortBy == SortingMethod.User ? "&amp;Reverse=1" : ""),
                              (Request["Cat"] != null ? "&amp;Cat=" + Tools.UrlEncode(Request["Cat"]) : ""),
                              "&amp;Page=", selectedPage.ToString());

            sb.Append(@""" title=""");
            sb.Append(Properties.Messages.SortByUser);
            sb.Append(@""">");
            sb.Append(Properties.Messages.ModifiedBy);
            sb.Append((reverse && sortBy.Equals("user") ? " &uarr;" : ""));
            sb.Append((!reverse && sortBy.Equals("user") ? " &darr;" : ""));
            sb.Append("</a></th>");

            // Categories
            sb.Append("<th>");
            sb.Append(Properties.Messages.Categories);
            sb.Append("</th>");

            sb.Append("</tr>");
            sb.Append("</thead><tbody>");

            foreach (SortingGroup key in sortedPages.Keys)
            {
                List <ExtendedPageInfo> pageList = sortedPages[key];
                for (int i = 0; i < pageList.Count; i++)
                {
                    if (i == 0)
                    {
                        // Add group header
                        sb.Append(@"<tr class=""tablerow"">");
                        if (sortBy == SortingMethod.Title)
                        {
                            sb.AppendFormat("<td colspan=\"7\"><b>{0}</b></td>", key.Label);
                        }
                        else if (sortBy == SortingMethod.Creation)
                        {
                            sb.AppendFormat("<td colspan=\"2\"></td><td colspan=\"5\"><b>{0}</b></td>", key.Label);
                        }
                        else if (sortBy == SortingMethod.DateTime)
                        {
                            sb.AppendFormat("<td colspan=\"3\"></td><td colspan=\"4\"><b>{0}</b></td>", key.Label);
                        }
                        else if (sortBy == SortingMethod.Creator)
                        {
                            sb.AppendFormat("<td colspan=\"4\"></td><td colspan=\"3\"><b>{0}</b></td>", key.Label);
                        }
                        else if (sortBy == SortingMethod.User)
                        {
                            sb.AppendFormat("<td colspan=\"5\"></td><td colspan=\"2\"><b>{0}</b></td>", key.Label);
                        }
                        sb.Append("</tr>");
                    }

                    sb.Append(@"<tr class=""tablerow");
                    if ((i + 1) % 2 == 0)
                    {
                        sb.Append("alternate");
                    }
                    sb.Append(@""">");

                    // Page title
                    sb.Append(@"<td>");
                    sb.Append(@"<a href=""");
                    UrlTools.BuildUrl(currentWiki, sb, Tools.UrlEncode(pageList[i].PageContent.FullName), GlobalSettings.PageExtension);
                    sb.Append(@""">");
                    sb.Append(pageList[i].Title);
                    sb.Append("</a>");
                    sb.Append("</td>");

                    // Message count
                    sb.Append(@"<td>");
                    int msg = pageList[i].MessageCount;
                    if (msg > 0)
                    {
                        sb.Append(@"<a href=""");
                        UrlTools.BuildUrl(currentWiki, sb, Tools.UrlEncode(pageList[i].PageContent.FullName), GlobalSettings.PageExtension, "?Discuss=1");
                        sb.Append(@""" title=""");
                        sb.Append(Properties.Messages.Discuss);
                        sb.Append(@""">");
                        sb.Append(msg.ToString());
                        sb.Append("</a>");
                    }
                    else
                    {
                        sb.Append("&nbsp;");
                    }
                    sb.Append("</td>");

                    // Creation date/time
                    sb.Append(@"<td>");
                    sb.Append(Preferences.AlignWithTimezone(currentWiki, pageList[i].CreationDateTime).ToString(Settings.GetDateTimeFormat(currentWiki)) + "&nbsp;");
                    sb.Append("</td>");

                    // Mod. date/time
                    sb.Append(@"<td>");
                    sb.Append(Preferences.AlignWithTimezone(currentWiki, pageList[i].PageContent.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki)) + "&nbsp;");
                    sb.Append("</td>");

                    // Creator
                    sb.Append(@"<td>");
                    sb.Append(Users.UserLink(currentWiki, pageList[i].Creator));
                    sb.Append("</td>");

                    // Last author
                    sb.Append(@"<td>");
                    sb.Append(Users.UserLink(currentWiki, pageList[i].LastAuthor));
                    sb.Append("</td>");

                    // Categories
                    CategoryInfo[] cats = Pages.GetCategoriesForPage(pageList[i].PageContent);
                    sb.Append(@"<td>");
                    if (cats.Length == 0)
                    {
                        sb.Append(@"<a href=""");
                        UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?Cat=-");
                        sb.Append(@""">");
                        sb.Append(Properties.Messages.NC);
                        sb.Append("</a>");
                    }
                    else
                    {
                        for (int k = 0; k < cats.Length; k++)
                        {
                            sb.Append(@"<a href=""");
                            UrlTools.BuildUrl(currentWiki, sb, "AllPages.aspx?Cat=", Tools.UrlEncode(cats[k].FullName));
                            sb.Append(@""">");
                            sb.Append(NameTools.GetLocalName(cats[k].FullName));
                            sb.Append("</a>");
                            if (k != cats.Length - 1)
                            {
                                sb.Append(", ");
                            }
                        }
                    }
                    sb.Append("</td>");

                    sb.Append("</tr>");
                }
            }
            sb.Append("</tbody>");
            sb.Append("</table>");

            Literal lbl = new Literal();

            lbl.Text = sb.ToString();
            pnlPageList.Controls.Clear();
            pnlPageList.Controls.Add(lbl);
        }
Exemple #12
0
        /// <summary>
        /// Prints a message.
        /// </summary>
        /// <param name="message">The message to print.</param>
        /// <param name="parent">The parent message, or <c>null</c>.</param>
        /// <param name="sb">The output <see cref="T:StringBuilder" />.</param>
        private void PrintMessage(Message message, Message parent, StringBuilder sb)
        {
            string currentWiki = Tools.DetectCurrentWiki();

            // Print header
            sb.Append(@"<div class=""messageheader"">");
            //sb.AppendFormat(@"<a id=""MSG_{0}""></a>", message.ID);

            if (!currentPage.Provider.ReadOnly)
            {
                // Print reply/edit/delete buttons only if provider is not read-only
                sb.Append(@"<div class=""reply"">");

                if (canPostMessages)
                {
                    sb.Append(@"<a class=""reply"" href=""");
                    sb.Append(UrlTools.BuildUrl(currentWiki, "Post.aspx?Page=", Tools.UrlEncode(currentPage.FullName), "&amp;Parent=", message.ID.ToString()));

                    sb.Append(@""">");
                    sb.Append(Properties.Messages.Reply);
                    sb.Append("</a>");
                }

                // If current user is the author of the message or is an admin, print the edit hyperLink
                // A message can be edited only if the user is authenticated - anonymous users cannot edit their messages
                if (SessionFacade.LoginKey != null && ((message.Username == SessionFacade.CurrentUsername && canPostMessages) || canManageDiscussion))
                {
                    sb.Append(@" <a class=""edit"" href=""");
                    sb.Append(UrlTools.BuildUrl(currentWiki, "Post.aspx?Page=", Tools.UrlEncode(currentPage.FullName), "&amp;Edit=", message.ID.ToString()));

                    sb.Append(@""">");
                    sb.Append(Properties.Messages.Edit);
                    sb.Append("</a>");
                }

                // If the current user is an admin, print the delete hyperLink
                if (SessionFacade.LoginKey != null && canManageDiscussion)
                {
                    sb.Append(@" <a class=""delete"" href=""");
                    sb.Append(UrlTools.BuildUrl(currentWiki, "Operation.aspx?Operation=DeleteMessage&amp;Message=", message.ID.ToString(),
                                                "&amp;Page=", Tools.UrlEncode(currentPage.FullName)));

                    sb.Append(@""">");
                    sb.Append(Properties.Messages.Delete);
                    sb.Append("</a>");
                }
                sb.Append("</div>");
            }

            sb.Append(@"<div>");
            sb.AppendFormat(@"<a id=""{0}"" href=""#{0}"" title=""Permalink"">&#0182;</a> ", Tools.GetMessageIdForAnchor(message.DateTime));

            // Print subject
            if (message.Subject.Length > 0)
            {
                sb.Append(@"<span class=""messagesubject"">");
                sb.Append(FormattingPipeline.PrepareTitle(currentWiki, message.Subject, false, FormattingContext.MessageBody, currentPage.FullName));
                sb.Append("</span>");
            }

            // Print message date/time
            sb.Append(@"<span class=""messagedatetime"">");
            sb.Append(Preferences.AlignWithTimezone(currentWiki, message.DateTime).ToString(Settings.GetDateTimeFormat(currentWiki)));
            sb.Append(" ");
            sb.Append(Properties.Messages.By);
            sb.Append(" ");
            sb.Append(Users.UserLink(currentWiki, message.Username));
            sb.Append("</span>");

            sb.Append("</div>");

            sb.Append("</div>");

            // Print body
            sb.Append(@"<div class=""messagebody"">");
            sb.Append(FormattingPipeline.FormatWithPhase3(currentWiki, FormattingPipeline.FormatWithPhase1And2(currentWiki, message.Body, false, FormattingContext.MessageBody, currentPage.FullName),
                                                          FormattingContext.MessageBody, currentPage.FullName));
            sb.Append("</div>");
        }
Exemple #13
0
        /// <summary>
        /// Prints the content.
        /// </summary>
        public void PrintContent()
        {
            StringBuilder sb    = new StringBuilder(5000);
            string        title = FormattingPipeline.PrepareTitle(currentWiki, page.Title, false, FormattingContext.PageContent, page.FullName);

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

                UserInfo user = Users.FindUser(currentWiki, page.User);

                sb.Append(@"<h1 class=""pagetitle"">");
                sb.Append(title);
                sb.Append("</h1>");
                if (Settings.GetEnablePageInfoDiv(currentWiki))
                {
                    sb.AppendFormat("<small>{0} {1} {2} {3} &mdash; {4}: {5}</small><br /><br />",
                                    Properties.Messages.ModifiedOn,
                                    Preferences.AlignWithTimezone(currentWiki, page.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki)),
                                    Properties.Messages.By,
                                    user != null ? Users.GetDisplayName(user) : page.User,
                                    Properties.Messages.CategorizedAs,
                                    categories.Length == 0 ? Properties.Messages.Uncategorized : string.Join(", ", categories));
                }
                sb.Append(FormattedContent.GetFormattedPageContent(currentWiki, page));
            }
            else
            {
                sb.Append(@"<h1 class=""pagetitle"">");
                sb.Append(title);
                sb.Append(" - Discussion</h1>");
                PrintDiscussion(sb);
            }
            lblContent.Text = sb.ToString();
        }
Exemple #14
0
        /// <summary>
        /// Prints a message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="parent">The parent message.</param>
        /// <param name="sb">The output <see cref="T:StringBuilder" />.</param>
        private void PrintMessage(Message message, Message parent, StringBuilder sb)
        {
            // Header
            sb.Append(@"<div class=""messageheader"">");
            sb.Append(Preferences.AlignWithTimezone(currentWiki, message.DateTime).ToString(Settings.GetDateTimeFormat(currentWiki)));
            sb.Append(" ");
            sb.Append(Properties.Messages.By);
            sb.Append(" ");
            sb.Append(Users.UserLink(currentWiki, message.Username));

            // Subject
            if (message.Subject.Length > 0)
            {
                sb.Append(@"<br /><span class=""messagesubject"">");
                sb.Append(FormattingPipeline.PrepareTitle(currentWiki, message.Subject, false, FormattingContext.MessageBody, page.FullName));
                sb.Append("</span>");
            }

            sb.Append("</div>");

            // Body
            sb.Append(@"<div class=""messagebody"">");
            sb.Append(FormattingPipeline.FormatWithPhase3(currentWiki, FormattingPipeline.FormatWithPhase1And2(currentWiki, message.Body, false, FormattingContext.MessageBody, page.FullName),
                                                          FormattingContext.MessageBody, page.FullName));
            sb.Append("</div>");
        }
Exemple #15
0
        /// <summary>
        /// Sets the content and visibility of all labels used in the page.
        /// </summary>
        private void SetupLabels()
        {
            if (discussMode)
            {
                lblModified.Visible         = false;
                lblModifiedDateTime.Visible = false;
                lblBy.Visible              = false;
                lblAuthor.Visible          = false;
                lblCategorizedAs.Visible   = false;
                lblPageCategories.Visible  = false;
                lblNavigationPaths.Visible = false;
                lblDiscussedPage.Text      = "<b>" + FormattingPipeline.PrepareTitle(currentWiki, currentPage.Title, false, FormattingContext.PageContent, currentPage.FullName) + "</b>";
            }
            else
            {
                lblPageDiscussionFor.Visible = false;
                lblDiscussedPage.Visible     = false;

                lblModifiedDateTime.Text =
                    Preferences.AlignWithTimezone(currentWiki, currentPage.LastModified).ToString(Settings.GetDateTimeFormat(currentWiki));
                lblAuthor.Text         = Users.UserLink(currentWiki, currentPage.User);
                lblPageCategories.Text = GetFormattedPageCategories();
            }
        }