function wysiwyg_profile_overview in Wysiwyg 5.2
Same name and namespace in other branches
- 5 wysiwyg.admin.inc \wysiwyg_profile_overview()
- 6.2 wysiwyg.admin.inc \wysiwyg_profile_overview()
- 6 wysiwyg.admin.inc \wysiwyg_profile_overview()
- 7.2 wysiwyg.admin.inc \wysiwyg_profile_overview()
Display overview of setup Wysiwyg Editor profiles; menu callback.
1 string reference to 'wysiwyg_profile_overview'
- wysiwyg_menu in ./
wysiwyg.module - Implementation of hook_menu().
File
- ./
wysiwyg.admin.inc, line 365 - Integrate Wysiwyg editors into Drupal.
Code
function wysiwyg_profile_overview() {
include_once './includes/install.inc';
// Check which wysiwyg editors are installed.
$editors = wysiwyg_get_all_editors();
$count = count($editors);
$status = array();
$options = array(
'' => t('No editor'),
);
foreach ($editors as $name => $editor) {
$status[$name] = array(
'severity' => isset($editor['error']) ? REQUIREMENT_ERROR : ($editor['installed'] ? REQUIREMENT_OK : REQUIREMENT_INFO),
'title' => t('<a href="!vendor-url">@editor</a> (<a href="!download-url">Download</a>)', array(
'!vendor-url' => $editor['vendor url'],
'@editor' => $editor['title'],
'!download-url' => $editor['download url'],
)),
'value' => isset($editor['installed version']) ? $editor['installed version'] : t('Not installed.'),
'description' => isset($editor['error']) ? $editor['error'] : '',
);
if ($editor['installed']) {
$options[$name] = $editor['title'] . (isset($editor['installed version']) ? ' ' . $editor['installed version'] : '');
}
else {
// Build on-site installation instructions.
// @todo Setup $library in wysiwyg_load_editor() already.
$library = isset($editor['library']) ? $editor['library'] : key($editor['libraries']);
$targs = array(
'@editor-path' => $editor['editor path'],
'@library-filepath' => $editor['library path'] . '/' . (isset($editor['libraries'][$library]['files'][0]) ? $editor['libraries'][$library]['files'][0] : key($editor['libraries'][$library]['files'])),
);
$instructions = '<p>' . t('Extract the archive and copy its contents into a new folder in the following location:<br /><code>@editor-path</code>', $targs) . '</p>';
$instructions .= '<p>' . t('So the actual library can be found at:<br /><code>@library-filepath</code>', $targs) . '</p>';
// Add any install notes.
if (!empty($editor['install note callback']) && function_exists($editor['install note callback'])) {
$instructions .= '<div class="editor-install-note">' . $editor['install note callback']() . '</div>';
}
$status[$name]['description'] .= $instructions;
$count--;
}
// In case there is an error, always show installation instructions.
if (isset($editor['error'])) {
$show_instructions = TRUE;
}
}
if (!$count) {
$show_instructions = TRUE;
}
$form['status'] = array(
'#type' => 'fieldset',
'#title' => t('Installation instructions'),
'#collapsible' => TRUE,
'#collapsed' => !isset($show_instructions),
'#description' => !$count ? t('There are no editor libraries installed currently. The following list contains a list of currently supported editors:') : '',
'#weight' => 10,
);
$form['status']['report'] = array(
'#type' => 'markup',
'#value' => theme('status_report', $status),
);
if (!$count) {
return $form;
}
$formats = filter_formats();
$profiles = wysiwyg_profile_load_all();
$form['formats'] = array(
'#type' => 'fieldset',
'#title' => t('Wysiwyg profiles'),
'#description' => t('Once an editor has been associated with an input format, the editor association cannot be changed without first deleting the profile and then creating a new one. Delete a profile by clicking on the "delete" link and afterwards, set up a new profile as usual.'),
'#tree' => TRUE,
);
$enable_save = FALSE;
foreach ($formats as $id => $format) {
$form['formats'][$id]['name'] = array(
'#value' => check_plain($format->name),
);
// Only display editor selection for associated input formats to avoid
// confusion about disabled selection.
if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) {
$form['formats'][$id]['editor'] = array(
'#type' => 'markup',
'#value' => $options[$profiles[$id]->editor],
);
}
else {
$form['formats'][$id]['editor'] = array(
'#type' => 'select',
'#default_value' => '',
'#options' => $options,
);
$enable_save = TRUE;
}
if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) {
$form['formats'][$id]['edit'] = array(
'#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/{$id}/edit"),
);
$form['formats'][$id]['delete'] = array(
'#value' => l(t('Delete'), "admin/settings/wysiwyg/profile/{$id}/delete"),
);
}
}
// Submitting the form when no editors can be selected causes errors.
if ($enable_save) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}