You are here

function ckeditor_profile_overview in CKEditor - WYSIWYG HTML editor 6

Same name and namespace in other branches
  1. 7 includes/ckeditor.admin.inc \ckeditor_profile_overview()

Controller for CKEditor profiles.

1 call to ckeditor_profile_overview()
ckeditor_admin_main in includes/ckeditor.admin.inc
Main administrative page

File

includes/ckeditor.admin.inc, line 134
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_profile_overview() {
  $output = '';
  $profiles = ckeditor_profile_load();
  if ($profiles) {
    $access_ckeditor_roles = user_roles(FALSE, 'access ckeditor');
    $header = array(
      t('Profile'),
      t('Roles'),
      t('Operations'),
    );
    $skins = ckeditor_load_skin_options();
    $plugins = ckeditor_load_plugins();
    $disabled_plugins = array();
    foreach ($profiles as $p) {
      $rids = $p->rids;
      if ($p->name !== "CKEditor Global Profile") {
        if (isset($p->settings['loadPlugins']) && is_array($p->settings['loadPlugins']) && count($p->settings['loadPlugins']) > 0) {
          $changed = FALSE;
          foreach ($p->settings['loadPlugins'] as $plugin_name => $plugin_settings) {
            if (!array_key_exists($plugin_name, $plugins)) {
              if (isset($plugin_settings['active']) && $plugin_settings['active'] == 0) {
                continue;
              }
              if (!isset($disabled_plugins[$p->name])) {
                $disabled_plugins[$p->name] = array();
              }
              $p->settings['loadPlugins'][$plugin_name]['active'] = 0;
              $disabled_plugins[$p->name][] = $plugin_name;
              $changed = TRUE;
            }
          }
          if ($changed === TRUE) {
            db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", serialize($p->settings), $p->name);
          }
        }
        foreach (array_keys($p->rids) as $rid) {
          if (!isset($access_ckeditor_roles[$rid])) {
            unset($rids[$rid]);
          }
        }
        if (isset($p->settings['skin']) && !array_key_exists($p->settings['skin'], $skins)) {
          drupal_set_message(t('The `!profile` profile is using `!skin` skin which cannot be found. Please !profile_settings.', array(
            '!profile' => $p->name,
            '!skin' => $p->settings['skin'],
            '!profile_settings' => l(t('update your settings'), 'admin/settings/ckeditor/edit/' . urlencode($p->name)),
          )), 'warning');
        }
        $rows[] = array(
          array(
            'data' => $p->name,
            'valign' => 'top',
          ),
          array(
            'data' => implode("<br />\n", $rids),
          ),
          array(
            'data' => l(t('edit'), 'admin/settings/ckeditor/edit/' . urlencode($p->name)) . ' ' . l(t('clone'), 'admin/settings/ckeditor/clone/' . urlencode($p->name)) . ' ' . l(t('delete'), 'admin/settings/ckeditor/delete/' . urlencode($p->name)),
            'valign' => 'top',
          ),
        );
      }
    }
    if (count($disabled_plugins) > 0) {
      $msg = t("The following plugins could not be found and were automatically disabled in CKEditor profiles:");
      foreach ($disabled_plugins as $profile_name => $profile_plugins) {
        $msg .= "<br/><br/>";
        $msg .= t("<b>Profile</b>: %profile_name", array(
          "%profile_name" => $profile_name,
        ));
        $msg .= "<br/>";
        $msg .= t("<b>Plugins</b>: %profile_plugins", array(
          "%profile_plugins" => implode(', ', $profile_plugins),
        ));
      }
      drupal_set_message($msg, 'warning');
    }
    $output .= '<h3>' . t('Profiles') . '</h3>';
    $output .= theme('table', $header, $rows);
    $output .= '<p>' . l(t('Create a new profile'), 'admin/settings/ckeditor/add') . '</p>';
  }
  else {
    drupal_set_message(t('No profiles found. Click here to !create.', array(
      '!create' => l(t('create a new profile'), 'admin/settings/ckeditor/add'),
    )));
  }
  $rows = array();
  if (!isset($profiles['CKEditor Global Profile'])) {
    drupal_set_message(t('The global profile can not be found. Click here to !create.', array(
      '!create' => l(t('create the global profile'), 'admin/settings/ckeditor/addg'),
    )));
  }
  else {
    $output .= "<h3>" . t("Global settings") . "</h3>";
    $rows[] = array(
      array(
        'data' => t('CKEditor Global Profile'),
        'valign' => 'top',
      ),
      array(
        'data' => l(t('edit'), 'admin/settings/ckeditor/editg') . " " . l(t('delete'), 'admin/settings/ckeditor/delete/CKEditor Global Profile'),
        'valign' => 'top',
      ),
    );
    $output .= theme('table', array(
      t('Profile'),
      t('Operations'),
    ), $rows);
  }
  return $output;
}