You are here

function ckeditor_admin_main in CKEditor - WYSIWYG HTML editor 6

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

Main administrative page

1 string reference to 'ckeditor_admin_main'
ckeditor_menu in ./ckeditor.module
Implementation of hook_menu().

File

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

Code

function ckeditor_admin_main() {
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  $editor_path = ckeditor_path(TRUE);
  $ckconfig_file = $editor_path . '/config.js';
  if (!_ckeditor_requirements_isinstalled()) {
    drupal_set_message(t('Checking for !filename or !file.', array(
      '!filename' => '<code>' . $ckconfig_file . '</code>',
      '!file' => '<code>sites/all/libraries/ckeditor/ckeditor.js</code>',
    )));
    drupal_set_message(t('The CKEditor component is not installed correctly. Please go to the !ckeditorlink in order to download the latest version. After that you must extract the files to the !ckeditorpath or !librarypath directory and make sure that the !ckeditorfile or !ckeditorlibrary file exists. Refer to the !readme file for more information.', array(
      '!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com/download'),
      '!readme' => l(t('README.txt'), drupal_get_path('module', 'ckeditor') . '/README.txt', array(
        'absolute' => TRUE,
      )),
      '!ckeditorpath' => '<code>' . $editor_path . '</code>',
      '!ckeditorsubdir' => '<code>' . $editor_path . '/editor</code>',
      '!ckeditorfile' => '<code>' . $editor_path . '/ckeditor.js</code>',
      '!ckeditorlibrary' => '<code>sites/all/libraries/ckeditor/ckeditor.js</code>',
      '!librarypath' => '<code>sites/all/libraries/ckeditor</code>',
    )), 'error');
    drupal_set_message(t('If you have CKEditor already installed, edit the <strong>!editg</strong> and update the CKEditor path.', array(
      '!editg' => l(t('CKEditor Global Profile'), 'admin/settings/ckeditor/editg'),
    )), 'warning');
    return FALSE;
  }
  if (module_exists('wysiwyg')) {
    drupal_set_message(t('The WYSIWYG module was detected. Using both modules at the same time may cause problems. It is recommended to turn the WYSIWYG module off (!wysiwygdisablelink").', array(
      '!wysiwygdisablelink' => l(t('click here to disable'), 'ckeditor/disable/wysiwyg/' . drupal_get_token('ckeditorDisableWysiwyg')),
    )), 'warning');
  }
  $access_ckeditor_roles = user_roles(FALSE, 'access ckeditor');
  if (!$access_ckeditor_roles) {
    drupal_set_message(t('There is currently no role with the "access ckeditor" permission. Visit the !acl administration section.', array(
      '!acl' => l(t('Permissions'), 'admin/user/permissions'),
    )), 'warning');
  }
  else {
    $result = db_query_range("SELECT name FROM {ckeditor_settings} WHERE name<>'CKEditor Global Profile'", 0, 1);
    $has_profiles = FALSE;

    //find profile other than Global
    if ($obj = db_fetch_object($result)) {
      $has_profiles = TRUE;
    }

    //find roles with profiles
    $result = db_query("SELECT rid FROM {ckeditor_role}");
    $rids = array();
    while ($obj = db_fetch_object($result)) {
      $rids[] = $obj->rid;
    }
    $rids = array_unique($rids);
    if (!$has_profiles) {
      drupal_set_message(t('No CKEditor profiles found. Right now nobody is able to use CKEditor. Create a new profile below.'), 'error');
    }
    else {

      //not all roles with access ckeditor has their CKEditor profile assigned
      $diff = array_diff(array_keys($access_ckeditor_roles), $rids);
      if ($diff) {
        $list = "<ul>";
        foreach ($diff as $rid) {
          $list .= "<li>" . $access_ckeditor_roles[$rid] . "</li>";
        }
        $list .= "</ul>";
        drupal_set_message(t('Not all roles with the "!access" permission are associated with CKEditor profiles. As a result, users with the following roles may be unable to use CKEditor: !list Create new or edit existing CKEditor profiles below and check the "Roles allowed to use this profile" option in the <strong>Basic setup</strong> section.', array(
          '!access' => l(t('access ckeditor'), 'admin/user/permissions'),
          '!list' => $list,
        )), 'warning');
      }
    }
  }
  return ckeditor_profile_overview();
}