TRUE
(PHP-mode, experts only).');
$description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => ''));
}
$form['visibility']['access'] = array(
'#type' => 'radios',
'#title' => t('Show Wysiwyg Editor on specific pages'),
'#default_value' => $edit->settings['access'],
'#options' => $options,
);
$form['visibility']['access_pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $edit->settings['access_pages'],
'#description' => $description,
'#wysiwyg' => FALSE,
);
}
$form['buttons'] = array(
'#type' => 'fieldset',
'#title' => t('Buttons and plugins'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
'#theme' => 'wysiwyg_editor_admin_button_table',
);
$plugins = _wysiwyg_editor_get_buttons(TRUE);
// Generate the button list.
foreach ($plugins as $name => $meta) {
if (isset($meta['buttons']) && is_array($meta['buttons'])) {
foreach ($meta['buttons'] as $button => $title) {
$img_src = $meta['path'] ."/images/$name.gif";
// Handle plugins that have more than one button.
if (!file_exists($img_src)) {
$img_src = $meta['path'] ."/images/$button.gif";
}
$b = file_exists($img_src) ? '' : '';
if (isset($meta['url'])) {
$title = $b .' '. l($title, $meta['url'], array('target' => '_blank'));
}
else {
$title = $b .' '. $title;
}
$form['buttons'][$name][$button] = array(
'#type' => 'checkbox',
'#title' => $title,
'#default_value' => isset($edit->settings['buttons'][$name][$button]) ? $edit->settings['buttons'][$name][$button] : NULL,
);
}
}
else if (isset($meta['extensions']) && is_array($meta['extensions'])) {
foreach ($meta['extensions'] as $extension => $title) {
if (isset($meta['url'])) {
$title = l($title, $meta['url'], array('target' => '_blank'));
}
else {
$title = $title;
}
$form['buttons'][$name][$extension] = array(
'#type' => 'checkbox',
'#title' => $title,
'#default_value' => isset($edit->settings['buttons'][$name][$extension]) ? $edit->settings['buttons'][$name][$extension] : NULL,
);
}
}
}
$form['appearance'] = array(
'#type' => 'fieldset',
'#title' => t('Editor appearance'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['appearance']['toolbar_loc'] = array(
'#type' => 'select',
'#title' => t('Toolbar location'),
'#default_value' => $edit->settings['toolbar_loc'],
'#options' => array('bottom' => t('Bottom'), 'top' => t('Top')),
'#description' => t('Show toolbar at the top or bottom of the editor area?'),
);
$form['appearance']['toolbar_align'] = array(
'#type' => 'select',
'#title' => t('Toolbar alignment'),
'#default_value' => $edit->settings['toolbar_align'],
'#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')),
'#description' => t('Align tool icons left, center, or right within the toolbar.'),
);
$form['appearance']['path_loc'] = array(
'#type' => 'select',
'#title' => t('Path location'),
'#default_value' => $edit->settings['path_loc'],
'#options' => array('none' => t('None'), 'top' => t('Top'), 'bottom' => t('Bottom')),
'#description' => t('Path to html elements (i.e. "body>table>tr>td"). Show at top, bottom, or not at all.'),
);
$form['appearance']['resizing'] = array(
'#type' => 'select',
'#title' => t('Enable resizing button'),
'#default_value' => $edit->settings['resizing'],
'#options' => array(FALSE => t('Disabled'), TRUE => t('Enabled')),
'#description' => t(' This option gives you the ability to enable/disable the resizing button. If enabled the Path location toolbar must be set to "top" or "bottom" in order to display the resize icon.'),
);
$form['output'] = array(
'#type' => 'fieldset',
'#title' => t('Cleanup and output'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['output']['verify_html'] = array(
'#type' => 'select',
'#title' => t('Verify HTML'),
'#default_value' => $edit->settings['verify_html'],
'#options' => array(FALSE => t('Disabled'), TRUE => t('Enabled')),
'#description' => t('Should the HTML contents be verified or not? Verifying will strip <head> tags, so choose false if you will be editing full page HTML.'),
);
$form['output']['preformatted'] = array(
'#type' => 'select',
'#title' => t('Preformatted'),
'#default_value' => $edit->settings['preformatted'],
'#options' => array(FALSE => t('Disabled'), TRUE => t('Enabled')),
'#description' => t('If this option is set to true, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE HTML element does.'),
);
$form['output']['convert_fonts_to_spans'] = array(
'#type' => 'select',
'#title' => t('Convert <font> tags to styles'),
'#default_value' => $edit->settings['convert_fonts_to_spans'],
'#options' => array(TRUE => t('Enabled'), FALSE => t('Disabled')),
'#description' => t('If you set this option to true, font size, font family, font color and font background color will be replaced by inline styles.'),
);
$form['output']['remove_linebreaks'] = array(
'#type' => 'select',
'#title' => t('Remove linebreaks'),
'#default_value' => $edit->settings['remove_linebreaks'],
'#options' => array(TRUE => t('Enabled'), FALSE => t('Disabled')),
'#description' => t('Set this option to false to prevent TinyMCE from removing linebreaks from existing nodes. True avoids conflicts with some filters.'),
);
$form['output']['apply_source_formatting'] = array(
'#type' => 'select',
'#title' => t('Apply source formatting'),
'#default_value' => $edit->settings['apply_source_formatting'],
'#options' => array(TRUE => t('Enabled'), FALSE => t('Disabled')),
'#description' => t('This option makes TinyMCE apply source formatting. Set this to true for a cleaner HTML source. Choose false to avoid conflicts with some filters.'),
);
$form['css'] = array(
'#type' => 'fieldset',
'#title' => t('CSS'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['css']['block_formats'] = array(
'#type' => 'textfield',
'#title' => t('Block formats'),
'#default_value' => $edit->settings['block_formats'],
'#size' => 40,
'#maxlength' => 250,
'#description' => t('Comma separated list of HTML block formats. You can only remove elements, not add.'),
);
$form['css']['css_setting'] = array(
'#type' => 'select',
'#title' => t('Editor CSS'),
'#default_value' => $edit->settings['css_setting'],
'#options' => array('theme' => t('Use theme CSS'), 'self' => t('Define CSS'), 'none' => t('TinyMCE default CSS')),
'#description' => t('Defines the CSS to be used in the editor area.[title]=[class]
', '!example' => 'My heading=header1')),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => $btn,
);
return $form;
}
/**
* Form submit callback for wysiwyg_editor_profile_form_build().
*
* @see wysiwyg_editor_profile_form_build()
*/
function wysiwyg_editor_profile_form_submit($form, &$form_state) {
// Count enabled plugins for this profile.
$plugin_count = 0;
foreach ($form_state['values']['buttons'] as $plugin => $buttons) {
$form_state['values']['buttons'][$plugin] = array_filter($form_state['values']['buttons'][$plugin]);
$plugin_count += count($form_state['values']['buttons'][$plugin]);
}
$form_state['values']['buttons'] = array_filter($form_state['values']['buttons']);
// Filter enabled roles for this profile.
$form_state['values']['rids'] = array_filter($form_state['values']['rids']);
// Delete existing profile(s) with the current profile name.
if (!empty($form_state['values']['old_name'])) {
db_query("DELETE FROM {wysiwyg_editor_profile} WHERE name = '%s' OR name = '%s'", $form_state['values']['name'], $form_state['values']['old_name']);
db_query("DELETE FROM {wysiwyg_editor_role} WHERE name = '%s' OR name = '%s'", $form_state['values']['name'], $form_state['values']['old_name']);
}
// Remove FAPI values.
// @see system_settings_form_submit()
unset($form_state['values']['submit'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token']);
// Insert new profile data.
db_query("INSERT INTO {wysiwyg_editor_profile} (name, settings, plugin_count) VALUES ('%s', '%s', %d)", $form_state['values']['name'], serialize($form_state['values']), $plugin_count);
foreach ($form_state['values']['rids'] as $rid => $value) {
db_query("INSERT INTO {wysiwyg_editor_role} (name, rid) VALUES ('%s', %d)", $form_state['values']['name'], $rid);
}
if (isset($form_state['values']['old_name'])) {
drupal_set_message(t('Wysiwyg Editor profile %name has been updated.', array('%name' => $form_state['values']['name'])));
}
else {
drupal_set_message(t('Wysiwyg Editor profile %name has been created.', array('%name' => $form_state['values']['name'])));
}
drupal_goto('admin/settings/wysiwyg/profile');
}
/**
* Layout for the buttons in the Wysiwyg Editor profile form.
*/
function theme_wysiwyg_editor_admin_button_table($form) {
$buttons = array();
// Flatten forms array.
foreach (element_children($form) as $name) {
foreach (element_children($form[$name]) as $button) {
$buttons[] = drupal_render($form[$name][$button]);
}
}
// Split checkboxes into rows with 3 columns.
$total = count($buttons);
$rows = array();
for ($i = 0; $i < $total; $i++) {
$row = array();
$row[] = array('data' => $buttons[$i]);
$row[] = array('data' => $buttons[++$i]);
$row[] = array('data' => $buttons[++$i]);
$rows[] = $row;
}
$output = theme('table', array(), $rows, array('width' => '100%'));
return $output;
}
/**
* Controller for Wysiwyg Editor profiles.
*/
function wysiwyg_editor_profile_overview() {
$output = '';
$usable = TRUE;
// Check if a Wysiwyg Editor is installed.
// Hard-coded for TinyMCE for now.
$tinymce_loc = drupal_get_path('module', 'wysiwyg_editor') .'/tinymce/';
if (!is_dir($tinymce_loc)) {
drupal_set_message(t('Could not find the TinyMCE engine installed at !tinymce-directory. Please download TinyMCE, uncompress it and copy the folder into !tinymce-path.', array('!tinymce-path' => drupal_get_path('module', 'wysiwyg_editor'), '!tinymce-directory' => $tinymce_loc)), 'error');
$usable = FALSE;
}
// Check if at least one role is granted access to Wysiwyg Editor.
$access_check = user_roles(FALSE, 'access wysiwyg editor');
if (!$access_check) {
drupal_set_message(t('You must assign at least one role with the \'access wysiwyg editor\' permission before creating a profile.', array('!access-control-url' => url('admin/user/permissions'))), 'error');
$usable = FALSE;
}
if (!$usable) {
return $output;
}
$profiles = wysiwyg_editor_profile_load();
if ($profiles) {
$roles = user_roles(FALSE, 'access wysiwyg editor');
$header = array(t('Profile'), t('Roles'), t('Operations'));
foreach ($profiles as $p) {
$rows[] = array(array('data' => $p->name, 'valign' => 'top'), array('data' => implode("'. t('Create new profile', array('!create-profile-url' => url('admin/settings/wysiwyg/profile/add'))) .'
'; return $output; } /** * Remove a profile from the database. */ function wysiwyg_editor_profile_delete($name) { db_query("DELETE FROM {wysiwyg_editor_profile} WHERE name = '%s'", $name); db_query("DELETE FROM {wysiwyg_editor_role} WHERE name = '%s'", $name); }