From: Michael M Slusarz Date: Wed, 28 Jul 2010 00:26:36 +0000 (-0600) Subject: Add preference to define default font family/size for the HTML compose editor X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=757e6eafe65f6718646e7d2200431601da202020;p=horde.git Add preference to define default font family/size for the HTML compose editor Essentially makes HTML compose mode a WYSIWYG editor, since it now will send th message using the same default font as appears on the screen. --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index a17d91fe2..6f4f328b5 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -392,7 +392,8 @@ $prefGroups['compose'] = array( 'members' => array( 'stationery_link', 'mailto_handler', 'compose_cc', 'compose_bcc', 'compose_spellcheck', 'compose_confirm', 'set_priority', - 'compose_popup', 'compose_html', 'mail_domain', 'compose_cursor', + 'compose_popup', 'compose_html', 'compose_html_font_family', + 'compose_html_font_size', 'mail_domain', 'compose_cursor', 'sending_charset', 'encryptselect', 'save_attachments', 'disposition_request_read' ) @@ -469,6 +470,25 @@ $_prefs['compose_html'] = array( 'desc' => _("Compose messages with an HTML editor by default?") ); +// For the HTML editor, this is the default font family. +// This needs to be in CSS-parseable format. +$_prefs['compose_html_font_family'] = array( + 'value' => 'Arial', + 'advanced' => true, + 'locked' => true, + 'type' => 'string', + 'desc' => _("The default font family to use in the HTML editor.") +); + +// For the HTML editor, this is the default font size. +$_prefs['compose_html_font_size'] = array( + 'value' => 14, + 'advanced' => true, + 'locked' => true, + 'type' => 'number', + 'desc' => _("The default font size to use in the HTML editor (in pixels).") +); + // default outgoing mail domain and address completion $_prefs['mail_domain'] = array( 'value' => '', diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 79255dedc..532f17626 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[mms] Add preference to define default font family/size for the HTML compose + editor. [mms] Honor nav_expanded preference (DIMP). [mms] Allow admin to define list of safe e-mail addresses that will not experience HTML image blocking (Request #9129). diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 22a876adb..48dc42ae4 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -1072,6 +1072,24 @@ class IMP_Compose $htmlBody->setCharset($charset); $htmlBody->setDisposition('inline'); $htmlBody->setDescription(Horde_String::convertCharset(_("HTML Version"), $nls_charset, $charset)); + + /* Add default font CSS information here. The data comes to us + * with no HTML body tag - so simply wrap the data in a body + * tag with the CSS information. */ + $styles = array(); + if ($font_family = $GLOBALS['prefs']->getValue('compose_html_font_family')) { + $styles[] = 'font-family:' . $font_family; + } + if ($font_size = intval($GLOBALS['prefs']->getValue('compose_html_font_size'))) { + $styles[] = 'font-size:' . $font_size . 'px'; + } + + if (!empty($styles)) { + $body_html = '' . + $body_html . + ''; + } + $htmlBody->setContents($GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($body_html, 'cleanhtml', array('charset' => $charset))); $textBody->setDescription(Horde_String::convertCharset(_("Plaintext Version"), $nls_charset, $charset)); diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 5e8217a0c..e2d58e960 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -87,6 +87,11 @@ class IMP_Prefs_Ui $ui->suppress[] = 'disposition_request_read'; } + if (!$prefs->getValue('compose_html')) { + $ui->suppress[] = 'compose_html_font_family'; + $ui->suppress[] = 'compose_html_font_size'; + } + /* Sort encodings. */ if (!$prefs->isLocked('sending_charset')) { asort($registry->nlsconfig['encodings']); diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index 26f8e8416..0df1b8eb8 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -149,6 +149,18 @@ class IMP_Ui_Compose { $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('basic' => $basic)); + $font_family = $GLOBALS['prefs']->getValue('compose_html_font_family'); + if (!$font_family) { + $font_family = 'Arial'; + } + + $font_size = intval($GLOBALS['prefs']->getValue('compose_html_font_size')); + $font_size = $font_size + /* Font size should be between 8 and 24 pixels. Or else recipients + * will hate us. Default to 14px. */ + ? min(24, max(8, $font_size)) . 'px' + : '14px'; + $config = array( /* To more closely match "normal" textarea behavior, send
on * enter instead of

. */ @@ -174,9 +186,9 @@ class IMP_Ui_Compose /* Default display font. This is NOT the font used to send * the message, however. */ - 'contentsCss: "body { font-family: Arial; font-size: 12px; }"', - 'font_defaultLabel: "Arial"', - 'fontSize_defaultLabel: "12px"' + 'contentsCss: "body { font-family: ' . $font_family . '; font-size: ' . $font_size . '; }"', + 'font_defaultLabel: "' . $font_family . '"', + 'fontSize_defaultLabel: "' . $font_size . '"' ); $buttons = $GLOBALS['prefs']->getValue('ckeditor_buttons');