示例#1
0
        /// <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();
        }
示例#2
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();
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentWiki = DetectWiki();

            discussMode  = Request["Discuss"] != null;
            viewCodeMode = Request["Code"] != null && !discussMode;
            if (!Settings.GetEnableViewPageCodeFeature(currentWiki))
            {
                viewCodeMode = false;
            }

            currentPage = Pages.FindPage(currentWiki, DetectPage(true));

            VerifyAndPerformRedirects();

            // The following actions are verified:
            // - View content (redirect to AccessDenied)
            // - Edit or Edit with Approval (for button display)
            // - Any Administrative activity (Rollback/Admin/Perms) (for button display)
            // - Download attachments (for button display - download permissions are also checked in GetFile)
            // - View discussion (for button display in content mode)
            // - Post discussion (for button display in discuss mode)

            string currentUsername = SessionFacade.GetCurrentUsername();

            string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki);

            AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            bool canView             = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ReadPage, currentUsername, currentGroups);
            bool canEdit             = false;
            bool canEditWithApproval = false;

            Pages.CanEditPage(currentWiki, currentPage.FullName, currentUsername, currentGroups, out canEdit, out canEditWithApproval);
            if (canEditWithApproval && canEdit)
            {
                canEditWithApproval = false;
            }
            bool canDownloadAttachments = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.DownloadAttachments, currentUsername, currentGroups);
            bool canSetPerms            = authChecker.CheckActionForGlobals(Actions.ForGlobals.ManagePermissions, currentUsername, currentGroups);
            bool canAdmin            = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ManagePage, currentUsername, currentGroups);
            bool canViewDiscussion   = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ReadDiscussion, currentUsername, currentGroups);
            bool canPostDiscussion   = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.PostDiscussion, currentUsername, currentGroups);
            bool canManageDiscussion = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ManageDiscussion, currentUsername, currentGroups);

            if (!canView)
            {
                if (SessionFacade.LoginKey == null)
                {
                    UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
                }
                else
                {
                    UrlTools.Redirect(UrlTools.BuildUrl(currentWiki, "AccessDenied.aspx"));
                }
            }
            attachmentViewer.Visible = canDownloadAttachments;

            attachmentViewer.PageFullName = currentPage.FullName;

            pnlPageInfo.Visible = Settings.GetEnablePageInfoDiv(currentWiki);

            SetupTitles();

            SetupToolbarLinks(canEdit || canEditWithApproval, canViewDiscussion, canPostDiscussion, canDownloadAttachments, canAdmin, canAdmin, canSetPerms);

            SetupLabels();
            SetupPrintAndRssLinks();
            SetupMetaInformation();
            VerifyAndPerformPageRedirection();
            SetupRedirectionSource();
            SetupNavigationPaths();
            SetupAdjacentPages();

            SessionFacade.Breadcrumbs(currentWiki).AddPage(currentPage.FullName);
            SetupBreadcrumbsTrail();

            SetupDoubleClickHandler();

            SetupEmailNotification();

            SetupPageContent(canPostDiscussion, canManageDiscussion);

            if (currentPage != null)
            {
                Literal canonical = new Literal();
                canonical.Text = Tools.GetCanonicalUrlTag(Request.Url.ToString(), currentPage.FullName, Pages.FindNamespace(currentWiki, NameTools.GetNamespace(currentPage.FullName)));
                Page.Header.Controls.Add(canonical);
            }
        }