function ckeditor_admin_global_profile_form_submit in CKEditor - WYSIWYG HTML editor 6
Same name and namespace in other branches
- 7 includes/ckeditor.admin.inc \ckeditor_admin_global_profile_form_submit()
File
- includes/
ckeditor.admin.inc, line 1866 - CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
Code
function ckeditor_admin_global_profile_form_submit($form, &$form_state) {
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
$edit =& $form_state['values'];
$edit['name'] = 'CKEditor Global Profile';
if (isset($edit['rank'])) {
$edit['rank'] = explode('>', str_replace(' ', '', $edit['rank']));
}
if (isset($edit['_profile'])) {
db_query("DELETE FROM {ckeditor_settings} WHERE name = '%s'", $edit['_profile']->name);
db_query("DELETE FROM {ckeditor_role} WHERE name = '%s'", $edit['_profile']->name);
}
//strip whitespaces
if (empty($edit['ckeditor_local_path'])) {
$edit['ckeditor_local_path'] = '';
}
else {
$edit['ckeditor_local_path'] = trim($edit['ckeditor_local_path']);
}
//strip slash from the end
if (empty($edit['ckeditor_path'])) {
$edit['ckeditor_path'] = '';
}
$edit['ckeditor_path'] = trim(rtrim($edit['ckeditor_path'], "/"));
if ($edit['ckeditor_path'] && 0 !== strpos($edit['ckeditor_path'], "/") && 0 !== strpos($edit['ckeditor_path'], "%")) {
//ensure that slash is at the beginning
$edit['ckeditor_path'] = "/" . $edit['ckeditor_path'];
}
//no slash at the end
$edit['ckeditor_local_path'] = trim(rtrim($edit['ckeditor_local_path'], "/"));
//strip whitespaces
if (empty($edit['ckeditor_plugins_local_path'])) {
$edit['ckeditor_plugins_local_path'] = '';
}
else {
$edit['ckeditor_plugins_local_path'] = trim($edit['ckeditor_plugins_local_path']);
}
//strip slash from the end
if (empty($edit['ckeditor_plugins_path'])) {
$edit['ckeditor_plugins_path'] = '';
}
$edit['ckeditor_plugins_path'] = trim(rtrim($edit['ckeditor_plugins_path'], "/"));
if ($edit['ckeditor_plugins_path'] && 0 !== strpos($edit['ckeditor_plugins_path'], "/") && 0 !== strpos($edit['ckeditor_plugins_path'], "%")) {
//ensure that slash is at the beginning
$edit['ckeditor_plugins_path'] = "/" . $edit['ckeditor_plugins_path'];
}
//no slash at the end
$edit['ckeditor_plugins_path'] = trim(rtrim($edit['ckeditor_plugins_path'], "/"));
//strip slash from the end
if (empty($edit['ckfinder_path'])) {
$edit['ckfinder_path'] = '';
}
$edit['ckfinder_path'] = trim(rtrim($edit['ckfinder_path'], "/"));
if ($edit['ckfinder_path'] && 0 !== strpos($edit['ckfinder_path'], "/") && 0 !== strpos($edit['ckfinder_path'], "%")) {
//ensure that slash is at the beginning
$edit['ckfinder_path'] = "/" . $edit['ckfinder_path'];
}
$settings = ckeditor_admin_values_to_settings($edit);
db_query("INSERT INTO {ckeditor_settings} (name, settings) VALUES ('%s', '%s')", $edit['name'], $settings);
ckeditor_rebuild_selectors($edit['name']);
drupal_set_message(t('The CKEditor Global Profile was saved.'));
$form_state['redirect'] = 'admin/settings/ckeditor';
}