function fckeditor_user in FCKeditor - WYSIWYG HTML editor 5.2
Same name and namespace in other branches
- 6.2 fckeditor.module \fckeditor_user()
- 6 fckeditor.module \fckeditor_user()
Implementation of hook_user().
File
- ./
fckeditor.module, line 1154 - FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2007 Frederico Caldeira Knabben
Code
function fckeditor_user($type, &$edit, &$user, $category = NULL) {
if ($type == 'form' && $category == 'account' && user_access('access fckeditor')) {
$profile = fckeditor_user_get_profile($user);
$toolbar_options = fckeditor_load_toolbar_options();
$skin_options = fckeditor_load_skin_options();
$lang_options = fckeditor_load_lang_options();
// because the settings are saved as strings we need to test for the string 'true'
if ($profile->settings['allow_user_conf'] == 't') {
$form['fckeditor'] = array(
'#type' => 'fieldset',
'#title' => t('Rich Text Editor settings'),
'#weight' => 10,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['fckeditor']['fckeditor_default'] = array(
'#type' => 'select',
'#title' => t('Default state'),
'#default_value' => isset($user->fckeditor_default) ? $user->fckeditor_default : (isset($profile->settings['default']) ? $profile->settings['default'] : 'f'),
'#options' => array(
't' => t('enabled'),
'f' => t('disabled'),
),
'#description' => t('Should rich-text editing be enabled or disabled by default in textarea fields? If disabled, rich text editor may still be enabled using toggle or popup window.'),
);
$form['fckeditor']['fckeditor_show_toggle'] = array(
'#type' => 'select',
'#title' => t('Show disable/enable rich text editor toggle'),
'#default_value' => isset($user->fckeditor_show_toggle) ? $user->fckeditor_show_toggle : (isset($profile->settings['show_toggle']) ? $profile->settings['show_toggle'] : 't'),
'#options' => array(
't' => t('true'),
'f' => t('false'),
),
'#description' => t('Whether or not to show the disable/enable rich text editor toggle below the textarea. Works only if FCKeditor is not running a popup window (see below).'),
);
$form['fckeditor']['fckeditor_popup'] = array(
'#type' => 'select',
'#title' => t('Use FCKeditor in a popup window'),
'#default_value' => isset($user->fckeditor_popup) ? $user->fckeditor_popup : (isset($profile->settings['popup']) ? $profile->settings['popup'] : 'f'),
'#options' => array(
'f' => t('false'),
't' => t('true'),
),
'#description' => t('If this option is enabled a link to a popup window will be used instead of a textarea replace.'),
);
$form['fckeditor']['fckeditor_skin'] = array(
'#type' => 'select',
'#title' => t('Skin'),
'#default_value' => isset($user->fckeditor_skin) ? $user->fckeditor_skin : (isset($profile->settings['skin']) ? $profile->settings['skin'] : 'default'),
'#options' => $skin_options,
'#description' => t('Choose a FCKeditor skin.'),
);
$form['fckeditor']['fckeditor_toolbar'] = array(
'#type' => 'select',
'#title' => t('Toolbar'),
'#default_value' => isset($user->fckeditor_toolbar) ? $user->fckeditor_toolbar : (isset($profile->settings['toolbar']) ? $profile->settings['toolbar'] : 'default'),
'#options' => $toolbar_options,
'#description' => t('Choose a FCKeditor toolbar set.'),
);
$form['fckeditor']['fckeditor_expand'] = array(
'#type' => 'select',
'#title' => t('Start the toolbar expanded'),
'#default_value' => isset($user->fckeditor_expand) ? $user->fckeditor_expand : (isset($profile->settings['expand']) ? $profile->settings['expand'] : 't'),
'#options' => array(
't' => t('enabled'),
'f' => t('disabled'),
),
'#description' => t('The toolbar start expanded or collapsed.'),
);
$form['fckeditor']['fckeditor_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => isset($user->fckeditor_width) ? $user->fckeditor_width : (isset($profile->settings['width']) ? $profile->settings['width'] : '100%'),
'#description' => t("Width in pixels or percent. Ex: 400 or 100%"),
'#size' => 40,
'#maxlength' => 128,
);
$form['fckeditor']['fckeditor_lang'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#default_value' => isset($user->fckeditor_lang) ? $user->fckeditor_lang : (isset($profile->settings['lang']) ? $profile->settings['lang'] : 'en'),
'#options' => $lang_options,
'#description' => t('The language for the FCKeditor interface.'),
);
$form['fckeditor']['fckeditor_auto_lang'] = array(
'#type' => 'select',
'#title' => t('Auto-detect language'),
'#default_value' => isset($user->fckeditor_auto_lang) ? $user->fckeditor_auto_lang : (isset($profile->settings['auto_lang']) ? $profile->settings['auto_lang'] : 't'),
'#options' => array(
't' => t('true'),
'f' => t('false'),
),
'#description' => t('Use auto detect user language feature.'),
);
return array(
'fckeditor' => $form,
);
}
}
if ($type == 'validate') {
if (isset($edit['fckeditor_default'], $edit['fckeditor_popup']) && $edit['fckeditor_default'] == 't' && $edit['fckeditor_popup'] == 't') {
form_set_error('fckeditor_popup', t('If FCKeditor is enabled by default, popup window must be disabled.'));
}
if (isset($edit['fckeditor_show_toggle'], $edit['fckeditor_popup']) && $edit['fckeditor_show_toggle'] == 't' && $edit['fckeditor_popup'] == 't') {
form_set_error('fckeditor_popup', t('If toggle is enabled, popup window must be disabled.'));
}
if (isset($edit['fckeditor_width']) && !preg_match('/^\\d+%?$/', $edit['fckeditor_width'])) {
form_set_error('fckeditor_width', t('Enter valid width. Example: 400 or 100%.'));
}
}
}