function ueditor_settings_form in UEditor - 百度编辑器 7.2
Same name and namespace in other branches
- 7.3 editors/ueditor.inc \ueditor_settings_form()
- 7 editors/ueditor.inc \ueditor_settings_form()
Enhances the editor profile settings form for UEditor.
1 string reference to 'ueditor_settings_form'
- ueditor_ueditor_editor in editors/
ueditor.inc - Plugin implementation of hook_editor().
File
- editors/
ueditor.inc, line 63 - Editor integration functions for ueditor.
Code
function ueditor_settings_form(&$form, &$form_state) {
global $base_path;
//load config js and css.
if (module_exists('libraries')) {
$lib_path = libraries_get_path('ueditor');
drupal_add_css($lib_path . '/themes/default/css/ueditor.css');
}
drupal_add_js(array(
'ueditor' => array(
'ueditor_enable_formula_editor' => variable_get('ueditor_enable_formula_editor', 0),
),
), 'setting');
drupal_add_js(drupal_get_path('module', 'ueditor') . '/editors/js/ueditor.toolbars.js');
// If enable kityformula support, add the icon css.
if (variable_get('ueditor_enable_formula_editor', 0)) {
drupal_add_css('.edui-default .edui-toolbar #id_kityformula .edui-icon {background: url("' . $base_path . $lib_path . '/kityformula-plugin/kf-icon.png") !important;}', 'inline');
}
if (!empty($form_state['wysiwyg_profile']->settings['toolbars'])) {
$settings = $form_state['wysiwyg_profile']->settings;
}
else {
$settings = ueditor_config_default($form_state['wysiwyg_profile']->settings);
$settings['toolbars'] = _ueditor_toolbars($settings['toolbars']);
}
$form['basic']['zindex'] = array(
'#type' => 'textfield',
'#title' => t('Editor zindex'),
'#description' => t('The official website of the default zindex 900,<br />
and Drupal overlay module ( #overlay= page ) conflict,
so default change from 900 to 90 or you can customize.'),
'#default_value' => $settings['zindex'],
'#size' => 5,
'#maxlength' => 4,
'#required' => TRUE,
);
$form['basic']['initialFrameHeight'] = array(
'#type' => 'textfield',
'#title' => t('Editor Height'),
'#description' => t('The default height is 320, you can change it.'),
'#default_value' => $settings['initialFrameHeight'],
'#size' => 5,
'#maxlength' => 4,
'#required' => TRUE,
);
$form['basic']['initial_content'] = array(
'#type' => 'textfield',
'#title' => t('Editor initial content'),
'#description' => t('Editor initial content, after editor loading in the textarea.'),
'#default_value' => $settings['initial_content'],
'#maxlength' => 255,
);
$form['basic']['allowdivtop'] = array(
'#type' => 'checkbox',
'#title' => t('Allow Div Convert to P'),
'#default_value' => $settings['allowdivtop'],
'#description' => t('If enable, the Div tags converted to P tag.'),
);
$form['basic']['auto_height'] = array(
'#type' => 'checkbox',
'#title' => t('Auto Height'),
'#default_value' => $settings['auto_height'],
'#description' => t('If enable, the editor will auto height.'),
);
$form['basic']['auto_float'] = array(
'#type' => 'checkbox',
'#title' => t('Auto Float'),
'#default_value' => $settings['auto_float'],
'#description' => t('If enable, the editor will auto float.'),
);
$form['basic']['show_elementpath'] = array(
'#type' => 'checkbox',
'#title' => t('Show element path'),
'#default_value' => $settings['show_elementpath'],
'#description' => t('If enable, It will show the element path under the editor.'),
);
$form['basic']['show_wordcount'] = array(
'#type' => 'checkbox',
'#title' => t('Show word count'),
'#default_value' => $settings['show_wordcount'],
'#description' => t('If enable, It will show the word count under the editor.'),
);
$form['basic']['appearance'] = array(
'#type' => 'fieldset',
'#title' => t('Appearance'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => array(
'edui-default',
),
),
);
$form['basic']['appearance']['toolbars'] = array(
'#type' => 'textarea',
'#title' => t('Toolbars'),
'#default_value' => isset($settings['toolbars']) ? $settings['toolbars'] : '',
'#description' => t('Enter a comma separated list of toolbars.'),
);
drupal_add_js('Drupal.ueditor.admin_profile_form();', array(
'scope' => 'footer',
'type' => 'inline',
));
// config the upload path.
$form['basic']['uploadpath'] = array(
'#type' => 'fieldset',
'#title' => t('Custom Upload Path'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['basic']['uploadpath']['path_help'] = array(
'#markup' => implode('<br>', array(
'%b' => '<code>%b</code> - the base URL path of the Drupal installation (<code>' . _ueditor_realpath('%b') . '</code>)',
'%m' => '<code>%m</code> - path where the UEditor module is stored (<code>' . _ueditor_realpath('%m') . '</code>)',
'%l' => '<code>%l</code> - path to the libraries directory (<code>' . _ueditor_realpath('%l') . '</code>)',
'%f' => '<code>%f</code> - the Drupal file system path where the files are stored (<code>' . _ueditor_realpath('%f') . '</code>)',
'%d' => '<code>%d</code> - the server path to the document root (<code>' . _ueditor_realpath('%d') . '</code>)',
'%u' => '<code>%u</code> - User ID (<code>' . _ueditor_realpath('%u') . '</code>)',
'{yyyy}' => '<code>{yyyy}</code> - <a href="http://www.php.net/manual/en/function.date.php">The php date format</a>',
'{mm}' => '<code>{mm}</code> - <a href="http://www.php.net/manual/en/function.date.php">The php date format</a>',
'{dd}' => '<code>{dd}</code> - <a href="http://www.php.net/manual/en/function.date.php">The php date format</a>',
'{time}' => '<code>{time}</code> - A timestamp',
'{rand:6}' => '<code>{rand:6}</code> - A random number',
'{transliteration_filename}' => '<code>{transliteration_filename}</code> - you need install <a href="https://www.drupal.org/project/transliteration">Transliteration</a> module',
'<br>',
)),
'#prefix' => '<div class="region region-help"><div class="block block-system"><div class="content">',
'#suffix' => '</div></div></div>',
);
$imagePathFormat = !empty($settings['imagePathFormat']) ? $settings['imagePathFormat'] : '';
$form['basic']['uploadpath']['imagePathFormat'] = array(
'#type' => 'textfield',
'#title' => t('imagePathFormat'),
'#default_value' => $imagePathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($imagePathFormat) . '</code>',
);
$scrawlPathFormat = !empty($settings['scrawlPathFormat']) ? $settings['scrawlPathFormat'] : '';
$form['basic']['uploadpath']['scrawlPathFormat'] = array(
'#type' => 'textfield',
'#title' => t('scrawlPathFormat'),
'#default_value' => $scrawlPathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($scrawlPathFormat) . '</code>',
);
$filePathFormat = !empty($settings['filePathFormat']) ? $settings['filePathFormat'] : '';
$form['basic']['uploadpath']['filePathFormat'] = array(
'#type' => 'textfield',
'#title' => t('filePathFormat'),
'#default_value' => $filePathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($filePathFormat) . '</code>',
);
$fileManagerListPath = !empty($settings['fileManagerListPath']) ? $settings['fileManagerListPath'] : '';
$form['basic']['uploadpath']['fileManagerListPath'] = array(
'#type' => 'textfield',
'#title' => t('fileManagerListPath'),
'#default_value' => $fileManagerListPath,
'#description' => 'Current path:<code>' . _ueditor_realpath($fileManagerListPath) . '</code>',
);
$catcherPathFormat = !empty($settings['catcherPathFormat']) ? $settings['catcherPathFormat'] : '';
$form['basic']['uploadpath']['catcherPathFormat'] = array(
'#type' => 'textfield',
'#title' => t('catcherPathFormat'),
'#default_value' => $catcherPathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($catcherPathFormat) . '</code>',
);
$imageManagerListPath = !empty($settings['imageManagerListPath']) ? $settings['imageManagerListPath'] : '';
$form['basic']['uploadpath']['imageManagerListPath'] = array(
'#type' => 'textfield',
'#title' => t('imageManagerListPath'),
'#default_value' => $imageManagerListPath,
'#description' => 'Current path:<code>' . _ueditor_realpath($imageManagerListPath) . '</code>',
);
$snapscreenPathFormat = !empty($settings['snapscreenPathFormat']) ? $settings['snapscreenPathFormat'] : '';
$form['basic']['uploadpath']['snapscreenPathFormat'] = array(
'#type' => 'textfield',
'#title' => t('snapscreenPathFormat'),
'#default_value' => $snapscreenPathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($snapscreenPathFormat) . '</code>',
);
$videoPathFormat = !empty($settings['videoPathFormat']) ? $settings['videoPathFormat'] : '';
$form['basic']['uploadpath']['videoPathFormat'] = array(
'#type' => 'textfield',
'#title' => t('videoPathFormat'),
'#default_value' => $videoPathFormat,
'#description' => 'Current path:<code>' . _ueditor_realpath($videoPathFormat) . '</code>',
);
$form['basic']['uploadpath']['#element_validate'][] = 'ueditor_settings_form_validate_uploadpath';
}