diff --git a/felamimail/inc/class.uicompose.inc.php b/felamimail/inc/class.uicompose.inc.php index 64356d7b52..21c78a5d48 100644 --- a/felamimail/inc/class.uicompose.inc.php +++ b/felamimail/inc/class.uicompose.inc.php @@ -668,7 +668,7 @@ if($sessionData['mimeType'] == 'html' /*&& trim($sessionData['body'])==''*/) { // User preferences for style $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; - $font_size = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size']; + $font_size = egw_ckeditor_config::font_size_from_prefs(); $font_span = ''.' '.''; if (empty($font) && empty($font_size)) $font_span = ''; } diff --git a/phpgwapi/inc/class.egw_ckeditor_config.inc.php b/phpgwapi/inc/class.egw_ckeditor_config.inc.php index 305c1c091f..5ee250e181 100644 --- a/phpgwapi/inc/class.egw_ckeditor_config.inc.php +++ b/phpgwapi/inc/class.egw_ckeditor_config.inc.php @@ -49,10 +49,32 @@ class egw_ckeditor_config 72 => '72', ); public static $font_unit_options = array( - 'px' => 'px: display pixels', 'pt' => 'pt: points (1/72 inch)', + 'px' => 'px: display pixels', ); + /** + * Get font size from preferences + * + * @param array $prefs=null default $GLOBALS['egw_info']['user']['preferences'] + * @param string &$size=null on return just size, without unit + * @param string &$unit=null on return just unit + * @return string font-size including unit + */ + public static function font_size_from_prefs(array $prefs=null, &$size=null, &$unit=null) + { + if (is_null($prefs)) $prefs = $GLOBALS['egw_info']['user']['preferences']; + + $size = $prefs['common']['rte_font_size']; + $unit = $prefs['common']['rte_font_unit']; + if (substr($size, -2) == 'px') + { + $unit = 'px'; + $size = (string)(int)$size; + } + return $size.$unit; + } + /** * Read language and country settings for the ckeditor and store them in static * variables diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 2a4db989e1..e0eb2ac9e7 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -525,7 +525,7 @@ class html // User preferences $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; - $font_size = (string)(int)$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size']; + $font_size = egw_ckeditor_config::font_size_from_prefs(); // we need to enable double encoding here, as ckEditor has to undo one level of encoding // otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html! diff --git a/preferences/inc/class.preferences_hooks.inc.php b/preferences/inc/class.preferences_hooks.inc.php index a1726b1b32..73c1d8eb3c 100644 --- a/preferences/inc/class.preferences_hooks.inc.php +++ b/preferences/inc/class.preferences_hooks.inc.php @@ -97,20 +97,23 @@ class preferences_hooks list(,$country) = explode('-',$lang); if (empty($country)) $country = $lang; } - // check for old rte_font_size pref including px and remove unit, px is default unit anyway - if (substr($GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'], -2) == 'px') + // check for old rte_font_size pref including px and split it in size and unit + if (!isset($GLOBALS['egw_setup']) && + substr($GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'], -2) == 'px') { - $prefs = new preferences($GLOBALS['egw_info']['user']['account_id']); + $prefs = $GLOBALS['egw']->preferences; foreach(array('user','default','forced') as $type) { if (substr($prefs->{$type}['common']['rte_font_size'], -2) == 'px') { - $prefs->{$type}['common']['rte_font_size'] = (string)(int)$prefs->{$type}['common']['rte_font_size']; + egw_ckeditor_config::font_size_from_prefs($prefs->{$type}, $prefs->{$type}['common']['rte_font_size'], + $prefs->{$type}['common']['rte_font_unit']); $prefs->save_repository(false, $type); } } - $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'] = - (string)(int)$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size']; + egw_ckeditor_config::font_size_from_prefs($GLOBALS['egw_info']['user']['preferences'], + $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'], + $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit']); } // Settings array for this app $settings = array( @@ -372,7 +375,7 @@ class preferences_hooks 'name' => 'rte_font_unit', 'values' => array_map('lang', egw_ckeditor_config::$font_unit_options), 'help' => 'Unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as used in text processing.', - 'default'=> 'px', + 'default'=> 'pt', 'xmlrpc' => True, 'admin' => false ),