function wysiwyg_profile_overview in Wysiwyg 6.2
Same name and namespace in other branches
- 5.2 wysiwyg.admin.inc \wysiwyg_profile_overview()
- 5 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 529 - 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();
$editor_options = array();
foreach ($editors as $name => $editor) {
$status[$name] = array(
'severity' => 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' => t('Not installed.'),
'description' => isset($editor['error']) ? $editor['error'] : '',
);
if (isset($editor['error'])) {
$status[$name]['severity'] = REQUIREMENT_ERROR;
}
elseif ($editor['installed']) {
$editor_options[$name] = check_plain($editor['title']) . ' ' . check_plain($editor['installed version']);
if (!$editor['installed version verified']) {
$status[$name]['severity'] = REQUIREMENT_WARNING;
}
else {
$status[$name]['severity'] = REQUIREMENT_OK;
}
$status[$name]['value'] = $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']($editor) . '</div>';
}
$status[$name]['description'] .= $instructions;
$count--;
}
if (!empty($editor['verified version range'])) {
$status[$name]['value'] .= '<br />(' . $editor['verified version range'][0] . ' - ' . $editor['verified version range'][1] . ')*';
}
// 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' => t('A complete list of <a href="@url">supported editor versions</a> for all Wysiwyg module versions can be found on drupal.org.', array(
'@url' => url('https://www.drupal.org/node/596966'),
)) . (!$count ? ' ' . t('There are no editor libraries installed currently. The following list contains a list of currently supported editors:') : '') . '<br>' . t('The instructions apply to the latest supported editor version. Paths for previous versions may differ.') . '<br>' . t('In general: Unpack the downloaded library archive directly into the libraries folder. You may need to rename the top folder to exactly match the plain library name.'),
'#weight' => 10,
);
$form['status']['report'] = array(
'#value' => theme('status_report', $status),
);
$form['status']['notes'] = array(
'#prefix' => '<div>',
'#value' => '* ' . t('The lowest and highest editor library version the current release of Wysiwyg module was last tested by the module maintainers.<br />Using a verified editor version is not a guaratee that any version of Wysiwyg module or an editor library is without problems. The verified version range only indicates a few manual tests have been performed on the first and last editor versions in the range together with the current Wysiwyg module version. <u>Always try the latest verified version before reporting bugs.</u> Unless otherwise noted; the testing was performed using the <strong>"default" or "full" package</strong> available for download from the editor\'s official website. Wysiwyg will <em>try</em> to use any recognized version above the verified version range, but proceed with caution. Editor versions lower than the verified range are <u>not supported at all</u>.<br /> More information about supported editor libraries and the verified versions can be found on the <a target="_blank" title="Supported editors" href="@project-url">wiki</a>.', array(
'@project-url' => url('https://www.drupal.org/node/596966'),
)),
'#suffix' => '</div>',
);
if (!$count) {
return $form;
}
$formats = filter_formats();
wysiwyg_profile_cache_clear();
$profiles = wysiwyg_profile_load_all();
$form['formats'] = array(
'#type' => 'item',
'#description' => t('To assign a different editor to a text format, click "delete" to remove the existing first.'),
'#tree' => TRUE,
);
$format_options = array();
foreach ($formats as $id => $format) {
if ($profile = !empty($profiles[$id]) ? $profiles[$id] : FALSE) {
$form['formats'][$id]['name'] = array(
'#value' => check_plain($format->name),
);
$editor_name = $profile->editor;
$installed = !empty($editors[$editor_name]['installed']);
$profile_version = isset($profile->preferences['version']) ? $profile->preferences['version'] : NULL;
$editor_message = '';
if ($installed) {
if ($profile_version != $editors[$editor_name]['installed version']) {
$editor_message = '<div class="messages warning">' . check_plain($editors[$editor_name]['title']) . ' (' . t('Expected version: %profile_version but found %installed_version.', array(
'%profile_version' => $profile_version,
'%installed_version' => $editors[$editor_name]['installed version'],
)) . ')</div>';
}
elseif (!$editors[$editor_name]['installed version verified']) {
$editor_message = '<div class="messages warning">' . check_plain($editors[$editor_name]['title']) . ' (' . t('Version %installed_version is not verified', array(
'%installed_version' => $editors[$editor_name]['installed version'],
)) . ')</div>';
}
else {
$editor_message = t('@library @profile_version', array(
'@library' => $editors[$editor_name]['title'],
'@profile_version' => $profile_version,
));
}
}
else {
$editor_message = '<div class="messages error">' . t('Unable to find @library. Expected version: %profile_version. Reinstall the library to edit this profile.', array(
'@library' => $editors[$editor_name]['title'],
'%profile_version' => $profile_version,
)) . '</div>';
}
if (!empty($editors[$editor_name]['deprecation message'])) {
$editor_message .= '<div class="messages warning">' . $editors[$editor_name]['deprecation message'] . '</div>';
}
$form['formats'][$id]['editor']['#value'] = $editor_message;
if ($editors[$profile->editor]['installed']) {
$form['formats'][$id]['edit'] = array(
'#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/{$id}"),
);
}
$form['formats'][$id]['delete'] = array(
'#value' => l(t('Delete'), "admin/settings/wysiwyg/profile/{$id}/delete"),
);
}
else {
$format_options[$id] = $format->name;
}
}
$form['formats']['_new_profile']['name'] = array(
'#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Assign an editor profile to a format') . '</div>',
'#suffix' => '</div>',
);
if (!empty($format_options)) {
$form['formats']['_new_profile']['name'] += array(
'#type' => 'select',
'#title' => t('Select a format'),
'#title_display' => 'invisible',
'#empty_option' => t('- Select a format -'),
'#default_value' => '',
'#options' => $format_options,
);
}
else {
$form['formats']['_new_profile']['name'] += array(
'#value' => t('All formats have been assigned an editor profile'),
);
}
if (!empty($editor_options)) {
$form['formats']['_new_profile']['editor'] = array(
'#type' => 'select',
'#title' => t('Select an editor'),
'#title_display' => 'invisible',
'#empty_option' => t('- Select an editor -'),
'#default_value' => '',
'#options' => $editor_options,
);
}
else {
$form['formats']['_new_profile']['editor'] = array(
'#value' => t('No editors installed.'),
);
}
$form['formats']['_new_profile']['editor']['#prefix'] = '<div class="add-new-placeholder"> </div>';
$form['formats']['_new_profile']['submit'] = array(
'#type' => 'submit',
'#value' => t('Create profile'),
'#prefix' => '<div class="add-new-placeholder"> </div>',
);
return $form;
}