SetTheme() public static method

Sets the theme for a namespace.
public static SetTheme ( string nspace, string theme ) : void
nspace string The namespace (null for the root).
theme string The theme name.
return void
Ejemplo n.º 1
0
        protected void btnRename_Click(object sender, EventArgs e)
        {
            lblRenameResult.CssClass = "";
            lblRenameResult.Text     = "";

            txtNewName.Text = txtNewName.Text.Trim();

            Page.Validate("rename");
            if (!Page.IsValid)
            {
                return;
            }

            NamespaceInfo nspace = Pages.FindNamespace(txtCurrentNamespace.Value);
            string        theme  = Settings.GetTheme(nspace.Name);

            if (Pages.RenameNamespace(nspace, txtNewName.Text))
            {
                Settings.SetTheme(txtNewName.Text, theme);
                RefreshList();
                lblRenameResult.CssClass = "resultok";
                lblRenameResult.Text     = Properties.Messages.NamespaceRenamed;
                ReturnToList();
            }
            else
            {
                lblRenameResult.CssClass = "resulterror";
                lblRenameResult.Text     = Properties.Messages.CouldNotRenameNamespace;
            }
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // This can rarely occur
            if (string.IsNullOrEmpty(lstDefaultPage.SelectedValue))
            {
                return;
            }

            string currentWiki = DetectWiki();

            NamespaceInfo nspace = txtCurrentNamespace.Value != RootName?
                                   Pages.FindNamespace(currentWiki, txtCurrentNamespace.Value) : null;

            bool done = Pages.SetNamespaceDefaultPage(currentWiki, nspace, Pages.FindPage(currentWiki, lstDefaultPage.SelectedValue));

            if (done)
            {
                if (string.IsNullOrEmpty(providerThSelector.SelectedThemes))
                {
                    done = false;
                }

                if (done)
                {
                    Settings.SetTheme(currentWiki, nspace != null ? nspace.Name : null, providerThSelector.SelectedProvider + "|" + providerThSelector.SelectedThemes);
                    RefreshList();
                    lblResult.CssClass = "resultok";
                    lblResult.Text     = Properties.Messages.NamespaceSaved;
                    ReturnToList();
                }
                else
                {
                    lblResult.CssClass = "resulterror";
                    lblResult.Text     = Properties.Messages.CouldNotSetNamespaceTheme;
                }
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotSetNamespaceDefaultPage;
            }
        }
Ejemplo n.º 3
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            txtName.Text = txtName.Text.Trim();

            Page.Validate("namespace");
            if (!Page.IsValid)
            {
                return;
            }

            // Create new namespace and the default page (MainPage)
            bool done = Pages.CreateNamespace(txtName.Text,
                                              Collectors.PagesProviderCollector.GetProvider(providerSelector.SelectedProvider));

            if (done)
            {
                NamespaceInfo nspace = Pages.FindNamespace(txtName.Text);
                done = Pages.CreatePage(nspace, "MainPage");
                PageInfo page = Pages.FindPage(NameTools.GetFullName(nspace.Name, "MainPage"));

                if (done)
                {
                    done = Pages.ModifyPage(page, "Main Page", Log.SystemUsername,
                                            DateTime.Now, "", Defaults.MainPageContentForSubNamespace,
                                            new string[0], "", SaveMode.Normal);

                    if (done)
                    {
                        done = Pages.SetNamespaceDefaultPage(nspace, page);

                        if (done)
                        {
                            Settings.SetTheme(nspace.Name, lstTheme.SelectedValue);

                            if (done)
                            {
                                RefreshList();
                                lblResult.CssClass = "resultok";
                                lblResult.Text     = Properties.Messages.NamespaceCreated;
                                ReturnToList();
                            }
                            else
                            {
                                lblResult.CssClass = "resulterror";
                                lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotSetTheme;
                            }
                        }
                        else
                        {
                            lblResult.CssClass = "resulterror";
                            lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotSetDefaultPage;
                        }
                    }
                    else
                    {
                        lblResult.CssClass = "resulterror";
                        lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotStoreDefaultPageContent;
                    }
                }
                else
                {
                    lblResult.CssClass = "resulterror";
                    lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotCreateDefaultPage;
                }
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotCreateNamespace;
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblResult.CssClass = "";
            lblResult.Text     = "";

            Page.Validate();

            if (!Page.IsValid)
            {
                return;
            }

            Log.LogEntry("Wiki Configuration change requested", EntryType.General, SessionFacade.CurrentUsername);

            Settings.BeginBulkUpdate();

            // Save general configuration
            Settings.WikiTitle    = txtWikiTitle.Text;
            Settings.MainUrl      = txtMainUrl.Text;
            Settings.ContactEmail = txtContactEmail.Text;
            Settings.SenderEmail  = txtSenderEmail.Text;
            Settings.ErrorsEmails = GetErrorsEmails();
            Settings.SmtpServer   = txtSmtpServer.Text;

            txtSmtpPort.Text = txtSmtpPort.Text.Trim();
            if (txtSmtpPort.Text.Length > 0)
            {
                Settings.SmtpPort = int.Parse(txtSmtpPort.Text);
            }
            else
            {
                Settings.SmtpPort = -1;
            }
            if (txtUsername.Text.Length > 0)
            {
                Settings.SmtpUsername = txtUsername.Text;
                Settings.SmtpPassword = txtPassword.Text;
            }
            else
            {
                Settings.SmtpUsername = "";
                Settings.SmtpPassword = "";
            }
            Settings.SmtpSsl = chkEnableSslForSmtp.Checked;

            // Save content configuration
            Settings.SetTheme(null, lstRootTheme.SelectedValue);
            Settings.DefaultPage               = lstMainPage.SelectedValue;
            Settings.DateTimeFormat            = txtDateTimeFormat.Text;
            Settings.DefaultLanguage           = lstDefaultLanguage.SelectedValue;
            Settings.DefaultTimezone           = int.Parse(lstDefaultTimeZone.SelectedValue);
            Settings.MaxRecentChangesToDisplay = int.Parse(txtMaxRecentChangesToDisplay.Text);
            Settings.RssFeedsMode              = (RssFeedsMode)Enum.Parse(typeof(RssFeedsMode), lstRssFeedsMode.SelectedValue);
            Settings.EnableDoubleClickEditing  = chkEnableDoubleClickEditing.Checked;
            Settings.EnableSectionEditing      = chkEnableSectionEditing.Checked;
            Settings.EnableSectionAnchors      = chkEnableSectionAnchors.Checked;
            Settings.EnablePageToolbar         = chkEnablePageToolbar.Checked;
            Settings.EnableViewPageCodeFeature = chkEnableViewPageCode.Checked;
            Settings.EnablePageInfoDiv         = chkEnablePageInfoDiv.Checked;
            Settings.DisableBreadcrumbsTrail   = !chkEnableBreadcrumbsTrail.Checked;
            Settings.AutoGeneratePageNames     = chkAutoGeneratePageNames.Checked;
            Settings.ProcessSingleLineBreaks   = chkProcessSingleLineBreaks.Checked;
            Settings.UseVisualEditorAsDefault  = chkUseVisualEditorAsDefault.Checked;
            if (txtKeptBackupNumber.Text == "")
            {
                Settings.KeptBackupNumber = -1;
            }
            else
            {
                Settings.KeptBackupNumber = int.Parse(txtKeptBackupNumber.Text);
            }
            Settings.DisplayGravatars = chkDisplayGravatars.Checked;
            Settings.ListSize         = int.Parse(txtListSize.Text);

            // Save security configuration
            Settings.UsersCanRegister = chkAllowUsersToRegister.Checked;
            Settings.UsernameRegex    = txtUsernameRegEx.Text;
            Settings.PasswordRegex    = txtPasswordRegEx.Text;
            AccountActivationMode mode = AccountActivationMode.Email;

            switch (lstAccountActivationMode.SelectedValue.ToLowerInvariant())
            {
            case "email":
                mode = AccountActivationMode.Email;
                break;

            case "admin":
                mode = AccountActivationMode.Administrator;
                break;

            case "auto":
                mode = AccountActivationMode.Auto;
                break;
            }
            Settings.AccountActivationMode    = mode;
            Settings.UsersGroup               = lstDefaultUsersGroup.SelectedValue;
            Settings.AdministratorsGroup      = lstDefaultAdministratorsGroup.SelectedValue;
            Settings.AnonymousGroup           = lstDefaultAnonymousGroup.SelectedValue;
            Settings.DisableCaptchaControl    = !chkEnableCaptchaControl.Checked;
            Settings.DisableConcurrentEditing = chkPreventConcurrentEditing.Checked;

            if (rdoNoModeration.Checked)
            {
                Settings.ChangeModerationMode = ChangeModerationMode.None;
            }
            else if (rdoRequirePageViewingPermissions.Checked)
            {
                Settings.ChangeModerationMode = ChangeModerationMode.RequirePageViewingPermissions;
            }
            else if (rdoRequirePageEditingPermissions.Checked)
            {
                Settings.ChangeModerationMode = ChangeModerationMode.RequirePageEditingPermissions;
            }

            Settings.AllowedFileTypes = GetAllowedFileExtensions();

            Settings.FileDownloadCountFilterMode = (FileDownloadCountFilterMode)Enum.Parse(typeof(FileDownloadCountFilterMode), lstFileDownloadCountFilterMode.SelectedValue);
            Settings.FileDownloadCountFilter     = txtFileDownloadCountFilter.Text.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            Settings.MaxFileSize       = int.Parse(txtMaxFileSize.Text);
            Settings.ScriptTagsAllowed = chkAllowScriptTags.Checked;
            LoggingLevel level = LoggingLevel.AllMessages;

            if (rdoAllMessages.Checked)
            {
                level = LoggingLevel.AllMessages;
            }
            else if (rdoWarningsAndErrors.Checked)
            {
                level = LoggingLevel.WarningsAndErrors;
            }
            else if (rdoErrorsOnly.Checked)
            {
                level = LoggingLevel.ErrorsOnly;
            }
            else
            {
                level = LoggingLevel.DisableLog;
            }
            Settings.LoggingLevel = level;
            Settings.MaxLogSize   = int.Parse(txtMaxLogSize.Text);
            Settings.IpHostFilter = txtIpHostFilter.Text;

            // Save advanced configuration
            Settings.DisableAutomaticVersionCheck = !chkEnableAutomaticUpdateChecks.Checked;
            Settings.DisableCache = chkDisableCache.Checked;
            Settings.CacheSize    = int.Parse(txtCacheSize.Text);
            Settings.CacheCutSize = int.Parse(txtCacheCutSize.Text);
            Settings.EnableViewStateCompression = chkEnableViewStateCompression.Checked;
            Settings.EnableHttpCompression      = chkEnableHttpCompression.Checked;

            Settings.EndBulkUpdate();

            Content.InvalidateAllPages();
            Content.ClearPseudoCache();

            lblResult.CssClass = "resultok";
            lblResult.Text     = Properties.Messages.ConfigSaved;
        }
Ejemplo n.º 5
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string currentWiki = DetectWiki();

            txtName.Text = txtName.Text.Trim();

            Page.Validate("namespace");
            if (!Page.IsValid)
            {
                return;
            }

            // Create new namespace and the default page (MainPage)
            bool done = Pages.CreateNamespace(currentWiki, txtName.Text,
                                              Collectors.CollectorsBox.PagesProviderCollector.GetProvider(providerSelector.SelectedProvider, currentWiki));

            if (done)
            {
                NamespaceInfo nspace = Pages.FindNamespace(currentWiki, txtName.Text);
                PageContent   page   = Pages.SetPageContent(currentWiki, nspace.Name, "MainPage", "Main Page", Log.SystemUsername,
                                                            DateTime.UtcNow, "", Defaults.MainPageContentForSubNamespace, new string[0], "", SaveMode.Normal);

                if (page != null)
                {
                    done = Pages.SetNamespaceDefaultPage(currentWiki, nspace, page);

                    if (done)
                    {
                        Settings.SetTheme(currentWiki, nspace.Name, providerThSelector.SelectedProvider + "|" + providerThSelector.SelectedThemes);

                        if (done)
                        {
                            RefreshList();
                            lblResult.CssClass = "resultok";
                            lblResult.Text     = Properties.Messages.NamespaceCreated;
                            ReturnToList();
                        }
                        else
                        {
                            lblResult.CssClass = "resulterror";
                            lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotSetTheme;
                        }
                    }
                    else
                    {
                        lblResult.CssClass = "resulterror";
                        lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotSetDefaultPage;
                    }
                }
                else
                {
                    lblResult.CssClass = "resulterror";
                    lblResult.Text     = Properties.Messages.NamespaceCreatedCouldNotStoreDefaultPageContent;
                }
            }
            else
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.CouldNotCreateNamespace;
            }
        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblResult.CssClass = "";
            lblResult.Text     = "";

            Page.Validate();

            if (!Page.IsValid)
            {
                return;
            }

            Log.LogEntry("Wiki Configuration change requested", EntryType.General, SessionFacade.CurrentUsername, currentWiki);

            Settings.BeginBulkUpdate(currentWiki);

            // Save general configuration
            Settings.SetWikiTitle(currentWiki, txtWikiTitle.Text);
            Settings.SetMainUrl(currentWiki, txtMainUrl.Text);

            // Save content configuration
            Settings.SetTheme(currentWiki, null, ThemeRootSelector.SelectedProvider + "|" + ThemeRootSelector.SelectedThemes);
            Settings.SetDefaultPage(currentWiki, lstMainPage.SelectedValue);
            Settings.SetDateTimeFormat(currentWiki, txtDateTimeFormat.Text);
            Settings.SetDefaultLanguage(currentWiki, lstDefaultLanguage.SelectedValue);
            Settings.SetDefaultTimezone(currentWiki, lstDefaultTimeZone.SelectedValue);
            Settings.SetMaxRecentChangesToDisplay(currentWiki, int.Parse(txtMaxRecentChangesToDisplay.Text));
            Settings.SetRssFeedsMode(currentWiki, (RssFeedsMode)Enum.Parse(typeof(RssFeedsMode), lstRssFeedsMode.SelectedValue));
            Settings.SetEnableDoubleClickEditing(currentWiki, chkEnableDoubleClickEditing.Checked);
            Settings.SetEnableSectionEditing(currentWiki, chkEnableSectionEditing.Checked);
            Settings.SetEnableSectionAnchors(currentWiki, chkEnableSectionAnchors.Checked);
            Settings.SetEnablePageToolbar(currentWiki, chkEnablePageToolbar.Checked);
            Settings.SetEnableViewPageCodeFeature(currentWiki, chkEnableViewPageCode.Checked);
            Settings.SetEnablePageInfoDiv(currentWiki, chkEnablePageInfoDiv.Checked);
            Settings.SetDisableBreadcrumbsTrail(currentWiki, !chkEnableBreadcrumbsTrail.Checked);
            Settings.SetAutoGeneratePageNames(currentWiki, chkAutoGeneratePageNames.Checked);
            Settings.SetProcessSingleLineBreaks(currentWiki, chkProcessSingleLineBreaks.Checked);
            Settings.SetUseVisualEditorAsDefault(currentWiki, chkUseVisualEditorAsDefault.Checked);
            if (txtKeptBackupNumber.Text == "")
            {
                Settings.SetKeptBackupNumber(currentWiki, -1);
            }
            else
            {
                Settings.SetKeptBackupNumber(currentWiki, int.Parse(txtKeptBackupNumber.Text));
            }
            Settings.SetDisplayGravatars(currentWiki, chkDisplayGravatars.Checked);
            Settings.SetListSize(currentWiki, int.Parse(txtListSize.Text));

            // Save security configuration
            Settings.SetUsersCanRegister(currentWiki, chkAllowUsersToRegister.Checked);
            AccountActivationMode mode = AccountActivationMode.Email;

            switch (lstAccountActivationMode.SelectedValue.ToLowerInvariant())
            {
            case "email":
                mode = AccountActivationMode.Email;
                break;

            case "admin":
                mode = AccountActivationMode.Administrator;
                break;

            case "auto":
                mode = AccountActivationMode.Auto;
                break;
            }
            Settings.SetAccountActivationMode(currentWiki, mode);
            Settings.SetUsersGroup(currentWiki, lstDefaultUsersGroup.SelectedValue);
            Settings.SetAdministratorsGroup(currentWiki, lstDefaultAdministratorsGroup.SelectedValue);
            Settings.SetAnonymousGroup(currentWiki, lstDefaultAnonymousGroup.SelectedValue);
            Settings.SetDisableCaptchaControl(currentWiki, !chkEnableCaptchaControl.Checked);
            Settings.SetDisableConcurrentEditing(currentWiki, chkPreventConcurrentEditing.Checked);

            if (rdoNoModeration.Checked)
            {
                Settings.SetModerationMode(currentWiki, ChangeModerationMode.None);
            }
            else if (rdoRequirePageViewingPermissions.Checked)
            {
                Settings.SetModerationMode(currentWiki, ChangeModerationMode.RequirePageViewingPermissions);
            }
            else if (rdoRequirePageEditingPermissions.Checked)
            {
                Settings.SetModerationMode(currentWiki, ChangeModerationMode.RequirePageEditingPermissions);
            }

            Settings.SetAllowedFileTypes(currentWiki, GetAllowedFileExtensions());

            Settings.SetFileDownloadCountFilterMode(currentWiki, (FileDownloadCountFilterMode)Enum.Parse(typeof(FileDownloadCountFilterMode), lstFileDownloadCountFilterMode.SelectedValue));
            Settings.SetFileDownloadCountFilter(currentWiki, txtFileDownloadCountFilter.Text.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));

            Settings.SetScriptTagsAllowed(currentWiki, chkAllowScriptTags.Checked);
            Settings.SetIpHostFilter(currentWiki, txtIpHostFilter.Text);

            Settings.EndBulkUpdate(currentWiki);

            lblResult.CssClass = "resultok";
            lblResult.Text     = Properties.Messages.ConfigSaved;
        }