From 8c37fe6e3394c3ad2d034fb64c4413320a60d5b5 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 19 Jan 2009 22:57:53 -0700 Subject: [PATCH] Use new browser sniffing for Fckeditor availability RTE now able to be used w/Safari 3+ and Chrome. --- imp/compose-dimp.php | 5 +---- imp/compose.php | 2 +- imp/lib/Compose.php | 3 +-- imp/lib/Session.php | 6 ++++++ imp/lib/UI/Compose.php | 5 ++++- imp/lib/Views/Compose.php | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 1b0c17b04..d12fcbec3 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -269,10 +269,7 @@ case 'resume': break; case 'new': - $rte = ($browser->hasFeature('rte') && $prefs->getValue('compose_html')); - if ($rte) { - $show_editor = true; - } + $rte = $show_editor = ($prefs->getValue('compose_html') && $_SESSION['imp']['rteavail']); break; } diff --git a/imp/compose.php b/imp/compose.php index 73833629a..8752a7db9 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -187,7 +187,7 @@ $isPopup = (($prefs->getValue('compose_popup') || Util::getFormData('popup')) && /* Determine the composition type - text or HTML. $rtemode is null if browser does not support it. */ $rtemode = null; -if ($browser->hasFeature('rte')) { +if ($_SESSION['imp']['rteavail']) { if ($prefs->isLocked('compose_html')) { $rtemode = $prefs->getValue('compose_html'); } else { diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 89996a4e2..4ca5e3dc2 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -2163,8 +2163,7 @@ class IMP_Compose $body_id = null; $mode = 'text'; - if (!empty($options['html']) && - $GLOBALS['browser']->hasFeature('rte')) { + if (!empty($options['html']) && $_SESSION['imp']['rteavail']) { $body_id = $contents->findBody('html'); if (!is_null($body_id)) { $mode = 'html'; diff --git a/imp/lib/Session.php b/imp/lib/Session.php index 40eb08ab7..6f3e137dd 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -41,6 +41,7 @@ class IMP_Session * 'maildomain' -- See config/servers.php. * 'notepadavail' -- Is listing of notepads available? * 'protocol' -- Either 'imap' or 'pop'. + * 'rteavail' -- Is the HTML editor available? * 'search' -- Settings used by the IMP_Search library. * 'smime' -- Settings related to the S/MIME viewer. * 'smtp' -- SMTP options ('host' and 'port') @@ -168,6 +169,11 @@ class IMP_Session $sess['notepadavail'] = true; } + /* Is the HTML editor available? */ + $imp_ui = new IMP_UI_Compose(); + $editor = $imp_ui->initRTE(null, true); + $sess['rteavail'] = $editor->supportedByBrowser(); + /* Cache autologin check. */ $sess['autologin'] = self::canAutologin(); diff --git a/imp/lib/UI/Compose.php b/imp/lib/UI/Compose.php index cbf5562a4..b896bc67c 100644 --- a/imp/lib/UI/Compose.php +++ b/imp/lib/UI/Compose.php @@ -188,9 +188,12 @@ class IMP_UI_Compose /** */ - function initRTE($mode = 'imp') + function initRTE($mode = 'imp', $editoronly = false) { $editor = &Horde_Editor::singleton('Fckeditor', array('id' => 'message', 'no_notify' => true)); + if ($editoronly) { + return $editor; + } $fck_buttons = $GLOBALS['prefs']->getValue('fckeditor_buttons'); if (!empty($fck_buttons)) { diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 51ebd214b..4122d4728 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -88,7 +88,7 @@ class IMP_Views_Compose ); $compose_html = $rte = false; - if ($GLOBALS['browser']->hasFeature('rte')) { + if ($_SESSION['imp']['rteavail']) { $compose_html = $GLOBALS['prefs']->getValue('compose_html'); $rte = true; -- 2.11.0