function ckeditor_admin_global_profile_form in CKEditor - WYSIWYG HTML editor 6
Same name and namespace in other branches
- 7 includes/ckeditor.admin.inc \ckeditor_admin_global_profile_form()
1 string reference to 'ckeditor_admin_global_profile_form'
- ckeditor_menu in ./
ckeditor.module - Implementation of hook_menu().
File
- includes/
ckeditor.admin.inc, line 1418 - 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($form_state, $mode = 'add') {
module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
if ($mode == 'edit') {
$profile = ckeditor_profile_load('CKEditor Global Profile');
$form['_profile'] = array(
'#type' => 'value',
'#value' => $profile,
);
}
else {
$profile = new stdClass();
}
if ($mode == 'add') {
$data = ckeditor_profile_load('CKEditor Global Profile');
if (!empty($data)) {
drupal_set_message(t('The global profile already exists. Only one global profile is allowed.'), 'error');
drupal_not_found();
}
$btn = t('Create a global profile');
}
else {
$btn = t('Update the global profile');
}
$toolbar_wizard = !empty($profile->settings['toolbar_wizard']) ? $profile->settings['toolbar_wizard'] : 't';
drupal_add_js(array(
'ckeditor_toolbar_wizard' => $toolbar_wizard,
), 'setting');
$form['common'] = array(
'#type' => 'fieldset',
'#title' => t('Main setup'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$roles = ckeditor_sorted_roles();
$rids = $rtext = array();
foreach ($roles as $rid => $name) {
$rids[] = $rid;
$rtext[] = '<strong>' . $rid . ' - </strong>' . $name;
}
$form['common']['rank'] = array(
'#type' => 'textfield',
'#title' => t('Role precedence'),
'#default_value' => implode('>', $rids),
'#description' => t('A user with <strong>multiple roles</strong> gets the permissions of the highest one. Sort role IDs according to their <strong>precedence from higher to lower</strong> by putting the ">" character in between.'),
);
if ($rids) {
$form['common']['rank']['#description'] .= '<br />' . t('The following list contains the ID-name pairs of roles with access to CKEditor:') . '<div>' . implode('<br />', $rtext) . '</div>';
}
else {
$form['common']['rank']['#description'] .= '<br />' . t('You have not assigned the "access ckeditor" !permissions yet.', array(
'!permissions' => l(t('permissions'), 'admin/user/permissions'),
));
}
$form['appearance'] = array(
'#type' => 'fieldset',
'#title' => t('Editor appearance'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['ckeditor_exclude_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Visibility settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('The following settings are combined with the visibility settings of the specific profile.'),
);
$form['ckeditor_exclude_settings']['excl_mode'] = array(
'#type' => 'radios',
'#title' => t('Use inclusion or exclusion mode'),
'#default_value' => empty($profile->settings['excl_mode']) || in_array($profile->settings['excl_mode'], array(
0,
2,
)) ? 0 : 1,
'#options' => array(
'0' => t('Exclude'),
'1' => t('Include'),
),
'#description' => t('Choose the way of disabling/enabling CKEditor on selected fields/paths (see below). Use <strong>Exclude</strong> to disable CKEditor on selected fields/paths. Use <strong>Include</strong> if you want to load CKEditor only on selected paths/fields.'),
);
/**
* get excluded fields - so we can have normal textareas too
* split the phrase by any number of commas or space characters,
* which include " ", \r, \t, \n and \f
*/
$form['ckeditor_exclude_settings']['excl'] = array(
'#type' => 'textarea',
'#title' => t('Fields to exclude/include'),
'#cols' => 60,
'#rows' => 5,
'#prefix' => '<div style="margin-left:20px">',
'#suffix' => '</div>',
'#default_value' => !empty($profile->settings['excl']) ? $profile->settings['excl'] : '',
'#description' => t('Enter the paths to the textarea fields for which you want to enable or disable CKEditor.') . ' ' . t('See the !helppagelink for more information about defining field names. Short instruction is available below.', array(
'!helppagelink' => l(t('Help page'), 'admin/help/ckeditor', array(
'fragment' => 'fieldinclexcl',
)),
)) . ' <ul><li>' . t('Path structure: <strong>theme_name:content_type@path.element_id</strong>') . '</li><li>' . t('The following wildcards are available: "*", "?".') . '</li><li>' . t('Content type and theme name is optional. You may even specify only path or field id.') . '</li><li>' . t('Examples:') . '<ul><li><em>garland:blog@*.edit-body</em> - ' . t('matches all fields of type "blog" called edit-body in garland theme, on any page.') . '<li><em>node/add/*.edit-user-*</em> - ' . t('matches fields starting with "edit-user-" on pages starting with "node/add/') . '</li></ul></li></ul>',
'#wysiwyg' => FALSE,
);
$form['ckeditor_exclude_settings']['simple_incl'] = array(
'#type' => 'textarea',
'#title' => t('Force simplified toolbar on the following fields'),
'#cols' => 60,
'#rows' => 5,
'#default_value' => !empty($profile->settings['simple_incl']) ? $profile->settings['simple_incl'] : '',
'#description' => t('Enter the paths to the textarea fields for which you want to force the simplified toolbar.') . ' ' . t('See the !helppagelink for more information about defining field names. Take a look at the exclusion settings (above) for a short instruction.', array(
'!helppagelink' => l(t('Help page'), 'admin/help/ckeditor', array(
'fragment' => 'fieldinclexcl',
)),
)),
'#wysiwyg' => FALSE,
);
$module_drupal_path = drupal_get_path('module', 'ckeditor');
drupal_add_js($module_drupal_path . '/includes/ckeditor.admin.js', 'file');
if ($toolbar_wizard == 't') {
if (module_exists('jquery_ui')) {
if (!module_exists('jquery_update') || jquery_update_get_version() <= 1.2) {
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery-1.4.4.min.js', 'core');
}
if (jquery_ui_get_version() > 1.6) {
jquery_ui_add(array(
'ui.sortable',
));
}
else {
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery-ui.min.js', 'file');
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery.ui.widget.min.js', 'file');
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery.ui.sortable.min.js', 'file');
}
}
else {
if (!module_exists('jquery_update') || jquery_update_get_version() <= 1.2) {
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery-1.4.4.min.js', 'core');
}
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery-ui.min.js', 'file');
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery.ui.widget.min.js', 'file');
drupal_add_js($module_drupal_path . '/includes/jqueryUI/jquery.ui.sortable.min.js', 'file');
}
drupal_add_js($module_drupal_path . '/includes/jqueryUI/sort.js', 'file');
}
$form['ckeditor_exclude_settings']['simple_toolbar'] = array(
'#id' => 'edit-toolbar',
'#type' => 'textarea',
'#title' => t('Simplified toolbar'),
'#default_value' => isset($profile->settings['simple_toolbar']) ? $profile->settings['simple_toolbar'] : "[ [ 'Format', 'Bold', 'Italic', '-', 'NumberedList','BulletedList', '-', 'Link', 'Unlink', 'Image' ] ]",
'#wysiwyg' => FALSE,
'#rows' => 15,
);
if ($toolbar_wizard == 't') {
$form['ckeditor_exclude_settings']['toolbar_wizzard_used'] = array(
'#type' => 'markup',
'#value' => '<div>' . t('Used buttons') . '</div><div class="sortableList" id="groupLayout"></div><br/>',
'#description' => t('Currently used buttons'),
);
drupal_add_js(array(
'cke_toolbar_buttons_all' => ckeditor_toolbar_buttons_all(FALSE),
), 'setting');
$form['ckeditor_exclude_settings']['toolbar_wizzard_all'] = array(
'#type' => 'markup',
'#value' => '<div>' . t('All buttons') . '</div><div id="allButtons" class="sortableList"></div><br/>',
'#description' => t('All available buttons'),
);
}
$form['ckeditor_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$module_drupal_path = drupal_get_path('module', 'ckeditor');
$form['ckeditor_advanced_settings']['ckeditor_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to CKEditor'),
'#default_value' => !empty($profile->settings['ckeditor_path']) ? $profile->settings['ckeditor_path'] : '%m/ckeditor',
'#size' => 40,
'#maxlength' => 128,
'#description' => t('The path to CKEditor (the WYSIWYG rich text editor downloaded from !ckeditorcom) relative to the document root.', array(
'!ckeditorcom' => l(t('ckeditor.com'), 'http://ckeditor.com/download'),
)) . '<br />' . t('Available placeholders:!b – base URL path of the Drupal installation (!base).!m – base URL path where the CKEditor module is stored (!files).!l – base URL path to the libraries directory (!library).<br />Current path: !path', array(
'!b' => '<br /><code>%b</code>',
'!m' => '<br /><code>%m</code>',
'!l' => '<br /><code>%l</code>',
'!path' => '<code>' . ckeditor_path(FALSE) . '</code>',
'!base' => '<code>' . base_path() . '</code>',
'!files' => '<code>' . base_path() . $module_drupal_path . '</code>',
'!library' => '<code>' . base_path() . 'sites/all/libraries/</code>',
)),
'#required' => TRUE,
);
$form['ckeditor_advanced_settings']['ckeditor_local_path'] = array(
'#type' => 'textfield',
'#title' => t('Local path to CKEditor'),
'#default_value' => isset($profile->settings['ckeditor_local_path']) ? $profile->settings['ckeditor_local_path'] : '',
'#size' => 40,
'#maxlength' => 128,
'#description' => t('The path to the local directory (on the server) that points to the path defined above. Enter either an absolute server path or a path relative to the !indexphp file. If left empty, the CKEditor module will try to find the right path.', array(
'!indexphp' => '<code>index.php</code>',
)) . '<br />' . t('Current path: !path', array(
'!path' => '<code>' . ckeditor_path(TRUE) . '</code>',
)),
);
$form['ckeditor_advanced_settings']['ckeditor_plugins_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to the CKEditor plugins directory'),
'#default_value' => !empty($profile->settings['ckeditor_plugins_path']) ? $profile->settings['ckeditor_plugins_path'] : '%m/plugins',
'#size' => 40,
'#maxlength' => 128,
'#description' => t('Path to the CKEditor plugins directory relative to the document root.') . '<br />' . t('Available placeholders:!b – the base URL path of the Drupal installation (!base).!m – the base URL path where the CKEditor module is stored (!files).!l – the base URL path to the libraries directory (!library).', array(
'!b' => '<br /><code>%b</code>',
'!m' => '<br /><code>%m</code>',
'!l' => '<br /><code>%l</code>',
'!base' => '<code>' . base_path() . '</code>',
'!files' => '<code>' . base_path() . $module_drupal_path . '</code>',
'!library' => '<code>' . base_path() . 'sites/all/libraries/</code>',
)) . '<br />' . t('Current path: !path', array(
'!path' => '<code>' . ckeditor_plugins_path() . '</code>',
)),
);
$form['ckeditor_advanced_settings']['ckeditor_plugins_local_path'] = array(
'#type' => 'textfield',
'#title' => t('Local path to the CKEditor plugins directory'),
'#default_value' => isset($profile->settings['ckeditor_plugins_local_path']) ? $profile->settings['ckeditor_plugins_local_path'] : '',
'#size' => 40,
'#maxlength' => 128,
'#description' => t('The path to the local directory (on the server) that points to the path defined above. Enter either an absolute server path or a path relative to the !indexphp file. If left empty, the CKEditor module will try to find the right path.<br />Current path: !path', array(
'!indexphp' => '<code>index.php</code>',
)) . '<br />' . t('Current path: !path', array(
'!path' => '<code>' . ckeditor_plugins_path(TRUE) . '</code>',
)),
);
$form['ckeditor_advanced_settings']['ckfinder_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to CKFinder'),
'#default_value' => !empty($profile->settings['ckfinder_path']) ? $profile->settings['ckfinder_path'] : '%m/ckfinder',
'#size' => 40,
'#maxlength' => 128,
'#description' => t('The path to CKFinder (AJAX based file manager downloaded from !ckfindercom) relative to the document root.', array(
'!ckfindercom' => l(t('ckfinder.com'), 'http://cksource.com/ckfinder'),
)) . '<br />' . t('Available placeholders:!b – the base URL path of the Drupal installation (!base).!m – path where the CKEditor module is stored (!files).!l – path to the libraries directory (!library).', array(
'!b' => '<br /><code>%b</code>',
'!m' => '<br /><code>%m</code>',
'!l' => '<br /><code>%l</code>',
'!base' => '<code>' . base_path() . '</code>',
'!files' => '<code>' . base_path() . $module_drupal_path . '</code>',
'!library' => '<code>' . base_path() . 'sites/all/libraries/</code>',
)) . '<br />' . t('Current path: !path', array(
'!path' => '<code>' . ckfinder_path() . '</code>',
)),
);
$form['ckeditor_advanced_settings']['show_fieldnamehint'] = array(
'#type' => 'radios',
'#title' => t('Show field name hint below each rich text editor'),
'#default_value' => !empty($profile->settings['show_fieldnamehint']) ? $profile->settings['show_fieldnamehint'] : 't',
'#options' => array(
't' => t('Yes'),
'f' => t('No'),
),
'#description' => t('This only applies to users with the "administer ckeditor" permissions.'),
);
if (variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE) {
$form['ckeditor_advanced_settings']['ckeditor_allow_download_private_files'] = array(
'#type' => 'checkbox',
'#title' => t('Enable access to files located in the private folder'),
'#default_value' => !empty($profile->settings['ckeditor_allow_download_private_files']),
'#return_value' => 't',
'#description' => t('<strong>Use this option with care.</strong> If checked, CKEditor will allow anyone knowing the URL to view a file located inside of the private path (!private_path), but only if there is no information about the file in the Drupal database. If the path below is specified, anyone will have access only to that location.', array(
'!private_path' => '<code>' . realpath(file_directory_path()) . '</code>',
)),
'#required' => FALSE,
);
$current_private_dir = !empty($profile->settings['private_dir']) ? $profile->settings['private_dir'] : '';
$form['ckeditor_advanced_settings']['private_dir'] = array(
'#type' => 'textfield',
'#title' => t('Location of files uploaded with CKEditor in the private folder'),
'#default_value' => !empty($profile->settings['private_dir']) ? $profile->settings['private_dir'] : '',
'#size' => 40,
'#maxlength' => 255,
'#description' => t('The path relative to the location of the private directory where CKEditor should store uploaded files.') . '<br />' . t('System path to the private folder is: !system_path.', array(
'!system_path' => '<code>' . realpath(file_directory_path()) . DIRECTORY_SEPARATOR . '</code>',
)) . '<br />' . t('Available wildcard characters: !u – User ID.!n – Username', array(
'!u' => '<br/><code>%u</code>',
'!n' => '<br /><code>%n</code>',
)) . '<br />' . t('Current path: !path', array(
'!path' => '<code>' . $current_private_dir . ' (' . str_replace('/', DIRECTORY_SEPARATOR, file_create_path(str_replace(array(
'%u',
'%n',
), array(
'UID',
'UNAME',
), $current_private_dir))) . ')</code>',
)),
);
}
if (function_exists('linktocontent_node_menu') && function_exists('pathfilter_filter')) {
$form['ckeditor_advanced_settings']['linktoc'] = array(
'#type' => 'select',
'#options' => array(
'p' => t('Link to paths only'),
'n' => t('Link using internal: links'),
'pn' => t('Allow the user to select between paths and internal links'),
),
'#title' => t('Path Filter & Link To Content integration'),
'#default_value' => empty($profile->settings['linktoc']) ? 'p' : $profile->settings['linktoc'],
'#description' => t('With the !plink extension it is possible to use internal: links. By default the !link extension is linking to nodes using paths.', array(
'!plink' => l(t('Path Filter'), 'http://drupal.org/project/pathfilter'),
'!link' => l(t('Link To Content'), 'http://drupal.org/project/linktocontent'),
)),
);
}
$form['ckeditor_advanced_settings']['ckeditor_aggregate'] = array(
'#type' => 'radios',
'#title' => t('Aggregate <code>ckeditor.js</code>'),
'#default_value' => !empty($profile->settings['ckeditor_aggregate']) ? $profile->settings['ckeditor_aggregate'] : 'f',
'#options' => array(
't' => t('Enabled'),
'f' => t('Disabled'),
),
'#description' => t('When enabled, <code>ckeditor.js</code> will be aggregated if JavaScript aggregation is enabled. <strong>Not recommended</strong>.'),
);
$form['ckeditor_advanced_settings']['toolbar_wizard'] = array(
'#type' => 'radios',
'#title' => t('Use toolbar Drag&Drop feature'),
'#default_value' => !empty($profile->settings['toolbar_wizard']) ? $profile->settings['toolbar_wizard'] : 't',
'#options' => array(
't' => t('Enabled'),
'f' => t('Disabled'),
),
'#description' => t('When enabled, the toolbar can be built by using the drag-and-drop feature. Otherwise you will need to enter the toolbar configuration manually to the text box.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => $btn,
);
return $form;
}