private void InitDefaultEditorForBlog()
 {
     using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
     {
         // initialize the editing template based on the last used view
         bool useStyles = EditUsingWebLayout(editSettings);
         commandViewUseStyles.Latched = useStyles;
     }
 }
 public void ApplySettings(BlogSettings settings)
 {
     //blog template
     using (PostHtmlEditingSettings editingSettings = new PostHtmlEditingSettings(settings.Id))
     {
         editingSettings.EditorTemplateHtmlFile = _templateFile;
         editingSettings.EditorTemplateHtml     = textBoxTemplate.Text;
     }
 }
        private bool EditUsingWebLayout(PostHtmlEditingSettings editSettings)
        {
            if (!editSettings.EditUsingBlogStylesIsSet && string.IsNullOrEmpty(editSettings.LastEditingView))
            {
                editSettings.EditUsingBlogStyles = _currentBlog.DefaultView != EditingViews.Normal;
            }

            return(editSettings.EditUsingBlogStyles);
        }
 internal void LoadSettings(BlogSettings settings)
 {
     //blog template
     _id = settings.Id;
     using (PostHtmlEditingSettings blogTemplate = new PostHtmlEditingSettings(settings.Id))
     {
         _templateFile        = blogTemplate.EditorTemplateHtmlFile;
         textBoxTemplate.Text = blogTemplate.EditorTemplateHtml;
     }
 }
        public static TemporaryBlogSettings ForBlogId(string blogId)
        {
            using (BlogSettings blogSettings = BlogSettings.ForBlogId(blogId))
            {
                TemporaryBlogSettings tempSettings = new TemporaryBlogSettings(blogId);
                tempSettings.IsNewWeblog = false;
                tempSettings.IsSpacesBlog = blogSettings.IsSpacesBlog;
                tempSettings.IsSharePointBlog = blogSettings.IsSharePointBlog;
                tempSettings.IsGoogleBloggerBlog = blogSettings.IsGoogleBloggerBlog;
                tempSettings.HostBlogId = blogSettings.HostBlogId;
                tempSettings.BlogName = blogSettings.BlogName;
                tempSettings.HomepageUrl = blogSettings.HomepageUrl;
                tempSettings.ForceManualConfig = blogSettings.ForceManualConfig;
                tempSettings.ManifestDownloadInfo = blogSettings.ManifestDownloadInfo;
                tempSettings.SetProvider(blogSettings.ProviderId, blogSettings.ServiceName, blogSettings.PostApiUrl, blogSettings.ClientType);
                tempSettings.Credentials = blogSettings.Credentials;
                tempSettings.LastPublishFailed = blogSettings.LastPublishFailed;
                tempSettings.Categories = blogSettings.Categories;
                tempSettings.Keywords = blogSettings.Keywords;
                tempSettings.Authors = blogSettings.Authors;
                tempSettings.Pages = blogSettings.Pages;
                tempSettings.FavIcon = blogSettings.FavIcon;
                tempSettings.Image = blogSettings.Image;
                tempSettings.WatermarkImage = blogSettings.WatermarkImage;
                tempSettings.OptionOverrides = blogSettings.OptionOverrides;
                tempSettings.UserOptionOverrides = blogSettings.UserOptionOverrides;
                tempSettings.ButtonDescriptions = blogSettings.ButtonDescriptions;
                tempSettings.HomePageOverrides = blogSettings.HomePageOverrides;

                //set the save password flag
                tempSettings.SavePassword = blogSettings.Credentials.Password != null &&
                    blogSettings.Credentials.Password != String.Empty;

                // file upload support
                tempSettings.FileUploadSupport = blogSettings.FileUploadSupport;

                // get ftp settings if necessary
                if (blogSettings.FileUploadSupport == FileUploadSupport.FTP)
                {
                    FtpUploaderSettings.Copy(blogSettings.FileUploadSettings, tempSettings.FileUploadSettings);
                }

                blogSettings.PublishingPluginSettings.CopyTo(tempSettings.PublishingPluginSettings);

                using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(blogId))
                {
                    tempSettings.TemplateFiles = editSettings.EditorTemplateHtmlFiles;
                }
                return tempSettings;
            }
        }
 private void commandViewUseStyles_Execute(object sender, EventArgs e)
 {
     using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
     {
         commandViewUseStyles.Latched     = !commandViewUseStyles.Latched;
         editSettings.EditUsingBlogStyles = commandViewUseStyles.Latched;
         ShowWebLayoutWarningIfNecessary();
         // When we update the editors theme because the user toggled 'Edit using Themes'
         // we suppress the editor reload.  The reload will happen in the following call to ChangeToWysiwygMode()
         using (SuppressEditorLoad())
             UpdateTemplateToBlogTheme();
         ReloadEditor();
     }
 }
 internal static void CleanupUnusedTemplates()
 {
     try
     {
         foreach (string blogId in BlogSettings.GetBlogIds())
         {
             using (PostHtmlEditingSettings templateSettings = new PostHtmlEditingSettings(blogId))
                 templateSettings.CleanupUnusedTemplates();
         }
     }
     catch (Exception ex)
     {
         Trace.Fail("Unexpected exception occurred cleaning up unused templates: " + ex.ToString());
     }
 }
        /// <summary>
        /// Loads the blog editing template.
        /// </summary>
        /// <param name="blogId"></param>
        /// <returns></returns>
        internal static string LoadBlogTemplate(string blogId, BlogEditingTemplateType templateType, bool forceRTL)
        {
            using (PostHtmlEditingSettings templateSettings = new PostHtmlEditingSettings(blogId))
            {
                string html = templateSettings.GetEditorTemplateHtml(templateType, forceRTL);
                if (html == null || html == String.Empty ||
                    html.IndexOf(BlogEditingTemplate.POST_TITLE_MARKER) == -1 ||
                    html.IndexOf(BlogEditingTemplate.POST_BODY_MARKER) == -1)
                {
                    html = BlogEditingTemplate.GetDefaultTemplateHtml(forceRTL, true);
                }

                return html;
            }
        }
        /// <summary>
        /// Loads the blog editing template.
        /// </summary>
        /// <param name="blogId"></param>
        /// <returns></returns>
        internal static string LoadBlogTemplate(string blogId, BlogEditingTemplateType templateType, bool forceRTL)
        {
            using (PostHtmlEditingSettings templateSettings = new PostHtmlEditingSettings(blogId))
            {
                string html = templateSettings.GetEditorTemplateHtml(templateType, forceRTL);
                if (html == null || html == String.Empty ||
                    html.IndexOf(BlogEditingTemplate.POST_TITLE_MARKER) == -1 ||
                    html.IndexOf(BlogEditingTemplate.POST_BODY_MARKER) == -1)
                {
                    html = BlogEditingTemplate.GetDefaultTemplateHtml(forceRTL, true);
                }

                return(html);
            }
        }
 internal static void CleanupUnusedTemplates()
 {
     try
     {
         foreach (string blogId in BlogSettings.GetBlogIds())
         {
             using (PostHtmlEditingSettings templateSettings = new PostHtmlEditingSettings(blogId))
                 templateSettings.CleanupUnusedTemplates();
         }
     }
     catch (Exception ex)
     {
         Trace.Fail("Unexpected exception occurred cleaning up unused templates: " + ex.ToString());
     }
 }
 private void ShowWebLayoutWarningIfNecessary()
 {
     // if the blog's DefaultView is not WebLayout and the user has not chosen
     // to supress the web-layout warning dialog then show a warning prior
     // to proceeding
     if (_currentBlog.DefaultView != EditingViews.WebLayout)
     {
         using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
         {
             if (editSettings.DisplayWebLayoutWarning)
             {
                 using (WebLayoutViewWarningForm warningForm = new WebLayoutViewWarningForm())
                 {
                     warningForm.ShowDialog(_mainFrameWindow);
                     if (warningForm.DontShowMessageAgain)
                     {
                         editSettings.DisplayWebLayoutWarning = false;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
        public void Save(BlogSettings settings)
        {
            settings.HostBlogId = this.HostBlogId;
            settings.IsSpacesBlog = this.IsSpacesBlog;
            settings.IsSharePointBlog = this.IsSharePointBlog;
            settings.BlogName = this.BlogName;
            settings.HomepageUrl = this.HomepageUrl;
            settings.ForceManualConfig = this.ForceManualConfig;
            settings.ManifestDownloadInfo = this.ManifestDownloadInfo;
            settings.SetProvider(this.ProviderId, this.ServiceName);
            settings.ClientType = this.ClientType;
            settings.PostApiUrl = this.PostApiUrl;
            if (IsSpacesBlog || !(SavePassword ?? false)) // clear out password so we don't save it
                Credentials.Password = "";

            settings.Credentials = this.Credentials;

            if (Categories != null)
                settings.Categories = this.Categories;

            if (Keywords != null)
                settings.Keywords = this.Keywords;

            settings.Authors = this.Authors;
            settings.Pages = this.Pages;

            settings.FavIcon = this.FavIcon;
            settings.Image = this.Image;
            settings.WatermarkImage = this.WatermarkImage;

            if (OptionOverrides != null)
                settings.OptionOverrides = this.OptionOverrides;

            if (UserOptionOverrides != null)
                settings.UserOptionOverrides = this.UserOptionOverrides;

            if (HomePageOverrides != null)
                settings.HomePageOverrides = this.HomePageOverrides;

            settings.ButtonDescriptions = this.ButtonDescriptions;

            // file upload support
            settings.FileUploadSupport = this.FileUploadSupport;

            // save ftp settings if necessary
            if (FileUploadSupport == FileUploadSupport.FTP)
            {
                FtpUploaderSettings.Copy(FileUploadSettings, settings.FileUploadSettings);
            }

            PublishingPluginSettings.CopyTo(settings.PublishingPluginSettings);

            using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(settings.Id))
            {
                editSettings.EditorTemplateHtmlFiles = TemplateFiles;
            }
        }
Ejemplo n.º 13
0
        bool IBlogPostEditingSite.UpdateWeblogTemplate(string blogID)
        {
            if (_editingManager.VerifyBlogCredentials())
            {
                using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(blogID))
                {
                    using (BlogSettings settings = BlogSettings.ForBlogId(blogID))
                    {
                        Color? backgroundColor;
                        BlogEditingTemplateFile[] templates = BlogEditingTemplateDetector.DetectTemplate(
                            new BlogClientUIContextImpl(_mainFrameWindow, _mainFrameWindow),
                            this,
                            settings,
                            !_editingManager.BlogIsAutoUpdatable,
                            out backgroundColor); // only probe if we do not support auto-update

                        if (templates.Length != 0)
                        {
                            editSettings.EditorTemplateHtmlFiles = templates;
                            if (backgroundColor != null)
                            {
                                IDictionary hpo = settings.HomePageOverrides ?? new Hashtable();
                                hpo[BlogClientOptions.POST_BODY_BACKGROUND_COLOR] =
                                    backgroundColor.Value.ToArgb().ToString(CultureInfo.InvariantCulture);

                                settings.HomePageOverrides = hpo;
                            }
                            FireWeblogSettingsChangedEvent(blogID, true);
                            return true;
                        }

                    }
                }
            }

            return false;
        }
Ejemplo n.º 14
0
 private void commandViewUseStyles_Execute(object sender, EventArgs e)
 {
     using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
     {
         commandViewUseStyles.Latched = !commandViewUseStyles.Latched;
         editSettings.EditUsingBlogStyles = commandViewUseStyles.Latched;
         ShowWebLayoutWarningIfNecessary();
         // When we update the editors theme because the user toggled 'Edit using Themes'
         // we suppress the editor reload.  The reload will happen in the following call to ChangeToWysiwygMode()
         using (SuppressEditorLoad())
             UpdateTemplateToBlogTheme();
         ReloadEditor();
     }
 }
Ejemplo n.º 15
0
 private void InitDefaultEditorForBlog()
 {
     using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
     {
         // initialize the editing template based on the last used view
         bool useStyles = EditUsingWebLayout(editSettings);
         commandViewUseStyles.Latched = useStyles;
     }
 }
Ejemplo n.º 16
0
        private bool EditUsingWebLayout(PostHtmlEditingSettings editSettings)
        {
            if (!editSettings.EditUsingBlogStylesIsSet && string.IsNullOrEmpty(editSettings.LastEditingView))
                editSettings.EditUsingBlogStyles = _currentBlog.DefaultView != EditingViews.Normal;

            return editSettings.EditUsingBlogStyles;
        }
Ejemplo n.º 17
0
 private void ShowWebLayoutWarningIfNecessary()
 {
     // if the blog's DefaultView is not WebLayout and the user has not chosen
     // to supress the web-layout warning dialog then show a warning prior
     // to proceeding
     if (_currentBlog.DefaultView != EditingViews.WebLayout)
     {
         using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(_currentBlog.Id))
         {
             if (editSettings.DisplayWebLayoutWarning)
             {
                 using (WebLayoutViewWarningForm warningForm = new WebLayoutViewWarningForm())
                 {
                     warningForm.ShowDialog(_mainFrameWindow);
                     if (warningForm.DontShowMessageAgain)
                         editSettings.DisplayWebLayoutWarning = false;
                 }
             }
         }
     }
 }
 internal void LoadSettings(BlogSettings settings)
 {
     //blog template
     _id = settings.Id;
     using(PostHtmlEditingSettings blogTemplate = new PostHtmlEditingSettings(settings.Id))
     {
         _templateFile = blogTemplate.EditorTemplateHtmlFile;
         textBoxTemplate.Text = blogTemplate.EditorTemplateHtml;
     }
 }
 public void ApplySettings(BlogSettings settings)
 {
     //blog template
     using(PostHtmlEditingSettings editingSettings = new PostHtmlEditingSettings(settings.Id))
     {
         editingSettings.EditorTemplateHtmlFile = _templateFile;
         editingSettings.EditorTemplateHtml = textBoxTemplate.Text;
     }
 }