diff --git a/includes/ckeditor.lib.inc b/includes/ckeditor.lib.inc index b143718..9028237 100644 --- a/includes/ckeditor.lib.inc +++ b/includes/ckeditor.lib.inc @@ -662,7 +662,7 @@ function ckeditor_user_get_setting($user, $profile, $setting) { $default = ckeditor_user_get_setting_default(); if (user_access('customize ckeditor')) { - $status = isset($user->data['ckeditor_' . $setting]) ? $user->data['ckeditor_' . $setting] : (isset($profile->settings[$setting]) ? $profile->settings[$setting] : $default[$setting]); + $status = (isset($user->data['ckeditor_' . $setting]) && $user->data['ckeditor_' . $setting] !== FALSE) ? $user->data['ckeditor_' . $setting] : (isset($profile->settings[$setting]) ? $profile->settings[$setting] : $default[$setting]); } else { $status = isset($profile->settings[$setting]) ? $profile->settings[$setting] : $default[$setting]; @@ -1202,7 +1202,7 @@ function ckeditor_profile_settings_compile($global_profile, $profile) { // add custom stylesheet if configured // lets hope it exists but we'll leave that to the site admin - $query_string = '?' . variable_get('css_js_query_string', '0'); + $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1); $css_files = array(); switch ($conf['css_mode']) { case 'theme': diff --git a/includes/ckeditor.user.inc b/includes/ckeditor.user.inc index 11c667d..5f06087 100644 --- a/includes/ckeditor.user.inc +++ b/includes/ckeditor.user.inc @@ -39,7 +39,6 @@ function ckeditor_user_customize(&$form, &$form_state, $form_id) { $data = $form['#user']->data; - $default = ckeditor_user_get_setting_default(); $lang_options = ckeditor_load_lang_options(); // because the settings are saved as strings we need to test for the string 'true' @@ -55,10 +54,10 @@ function ckeditor_user_customize(&$form, &$form_state, $form_id) { $form['ckeditor']['ckeditor_default'] = array( '#type' => 'radios', '#title' => t('Default state'), - '#default_value' => isset($data['ckeditor_default']) ? $data['ckeditor_default'] : $default['default'], + '#default_value' => isset($data['ckeditor_default']) ? $data['ckeditor_default'] : FALSE, '#options' => array( 't' => t('Enabled'), - 'f' => t('Disabled') + 'f' => t('Disabled'), ), '#description' => t('Should rich text editing be enabled or disabled by default in textarea fields? If disabled, the rich text editor may still be enabled by using toggle.'), ); @@ -66,10 +65,10 @@ function ckeditor_user_customize(&$form, &$form_state, $form_id) { $form['ckeditor']['ckeditor_show_toggle'] = array( '#type' => 'radios', '#title' => t('Show the disable/enable rich text editor toggle'), - '#default_value' => isset($data['ckeditor_show_toggle']) ? $data['ckeditor_show_toggle'] : $default['show_toggle'], + '#default_value' => isset($data['ckeditor_show_toggle']) ? $data['ckeditor_show_toggle'] : FALSE, '#options' => array( 't' => t('Yes'), - 'f' => t('No') + 'f' => t('No'), ), '#description' => t('Whether or not to show the disable/enable rich text editor toggle below the textarea.'), ); @@ -77,8 +76,8 @@ function ckeditor_user_customize(&$form, &$form_state, $form_id) { $form['ckeditor']['ckeditor_width'] = array( '#type' => 'textfield', '#title' => t('Editor width'), - '#default_value' => isset($data['ckeditor_width']) ? $data['ckeditor_width'] : $default['width'], - '#description' => t('Editor interface width in pixels or percent.') . ' ' . t('Examples') . ': 400 ' . t('or') . ' 100%.', + '#default_value' => !empty($data['ckeditor_width']) ? $data['ckeditor_width'] : '', + '#description' => t('Editor interface width in pixels or percent.') . ' ' . t('Examples') . ': 400 ' . t('or') . ' 100%. ' . t('Leave blank to use site default.'), '#size' => 40, '#maxlength' => 128, ); @@ -86,18 +85,18 @@ function ckeditor_user_customize(&$form, &$form_state, $form_id) { $form['ckeditor']['ckeditor_lang'] = array( '#type' => 'select', '#title' => t('Language'), - '#default_value' => isset($data['ckeditor_lang']) ? $data['ckeditor_lang'] : $default['lang'], - '#options' => $lang_options, + '#default_value' => isset($data['ckeditor_lang']) ? $data['ckeditor_lang'] : '', + '#options' => $lang_options + array('' => t('Use site default')), '#description' => t('The language for the CKEditor interface.') ); $form['ckeditor']['ckeditor_auto_lang'] = array( '#type' => 'radios', '#title' => t('Auto-detect language'), - '#default_value' => isset($data['ckeditor_auto_lang']) ? $data['ckeditor_auto_lang'] : $default['auto_lang'], + '#default_value' => isset($data['ckeditor_auto_lang']) ? $data['ckeditor_auto_lang'] : FALSE, '#options' => array( 't' => t('Yes'), - 'f' => t('No') + 'f' => t('No'), ), '#description' => t('Automatically detect the user language.') ); @@ -116,7 +115,7 @@ function ckeditor_user_customize_form_validate(&$form, &$form_state) { form_set_error('ckeditor_popup', t('If toggle is enabled, the popup window must be disabled.')); } */ - if (isset($form_state['values']['ckeditor_width']) && !preg_match('/^\d+%?$/', $form_state['values']['ckeditor_width'])) { + if (isset($form_state['values']['ckeditor_width']) && !empty($form_state['values']['ckeditor_width']) && !preg_match('/^\d+%?$/', $form_state['values']['ckeditor_width'])) { form_set_error('ckeditor_width', t('Enter a valid width value.') . ' ' . t('Examples:') . ': 400 ' . t('or') . ' 100%.'); } } @@ -124,12 +123,11 @@ function ckeditor_user_customize_form_validate(&$form, &$form_state) { function ckeditor_user_presave(&$edit, $account, $category) { if (user_access('customize ckeditor')) { module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib'); - $default = ckeditor_user_get_setting_default(); - $edit['data']['ckeditor_default'] = isset($edit['ckeditor_default']) ? $edit['ckeditor_default'] : $default['default']; - $edit['data']['ckeditor_show_toggle'] = isset($edit['ckeditor_show_toggle']) ? $edit['ckeditor_show_toggle'] : $default['show_toggle']; - $edit['data']['ckeditor_width'] = isset($edit['ckeditor_width']) ? $edit['ckeditor_width'] : $default['width']; - $edit['data']['ckeditor_lang'] = isset($edit['ckeditor_lang']) ? $edit['ckeditor_lang'] : $default['lang']; - $edit['data']['ckeditor_auto_lang'] = isset($edit['ckeditor_auto_lang']) ? $edit['ckeditor_auto_lang'] : $default['auto_lang']; + $edit['data']['ckeditor_default'] = !empty($edit['ckeditor_default']) ? $edit['ckeditor_default'] : FALSE; + $edit['data']['ckeditor_show_toggle'] = !empty($edit['ckeditor_show_toggle']) ? $edit['ckeditor_show_toggle'] : FALSE; + $edit['data']['ckeditor_width'] = !empty($edit['ckeditor_width']) ? $edit['ckeditor_width'] : FALSE; + $edit['data']['ckeditor_lang'] = !empty($edit['ckeditor_lang']) ? $edit['ckeditor_lang'] : FALSE; + $edit['data']['ckeditor_auto_lang'] = !empty($edit['ckeditor_auto_lang']) ? $edit['ckeditor_auto_lang'] : FALSE; } }