You are here

function tinymce_admin in TinyMCE 6

Same name and namespace in other branches
  1. 5.2 tinymce.module \tinymce_admin()
  2. 5 tinymce.module \tinymce_admin()
  3. 6.2 tinymce.admin.inc \tinymce_admin()

Controller for tinymce administrative settings.

1 string reference to 'tinymce_admin'
tinymce_menu in ./tinymce.module
Implementation of hook_menu().

File

./tinymce.admin.inc, line 13
Admin interface for TinyMCE module.

Code

function tinymce_admin($arg = NULL) {
  $edit = $_POST;
  $op = isset($_POST['op']) ? $_POST['op'] : NULL;
  $op = $arg && !$op ? $arg : $op;
  switch ($op) {
    case 'add':
      $breadcrumb[] = l(t('Home'), NULL);
      $breadcrumb[] = l(t('Administer'), 'admin');
      $breadcrumb[] = l(t('Site configuration'), 'admin/settings');
      $breadcrumb[] = l(t('TinyMCE'), 'admin/settings/tinymce');
      $breadcrumb[] = l(t('Add new TinyMCE profile'), 'admin/settings/tinymce/add');
      drupal_set_breadcrumb($breadcrumb);
      $output = tinymce_profile_form($edit);
      break;
    case 'edit':
      drupal_set_title(t('Edit tinymce profile'));
      $output = tinymce_profile_form(tinymce_profile_load(urldecode(arg(4))));
      break;
    case 'delete':
      tinymce_profile_delete(urldecode(arg(4)));
      drupal_set_message(t('Deleted profile'));
      drupal_goto('admin/settings/tinymce');
      break;
    case t('Create profile'):
    case t('Update profile'):
      if (tinymce_profile_validate($edit)) {
        tinymce_profile_save($edit);
        $edit['old_name'] ? drupal_set_message(t('Your TinyMCE profile has been updated.')) : drupal_set_message(t('Your TinyMCE profile has been created.'));
        drupal_goto('admin/settings/tinymce');
      }
      else {
        $output = tinymce_profile_form($edit);
      }
      break;
    default:
      drupal_set_title(t('TinyMCE settings'));

      //Check if TinyMCE is installed.
      $tinymce_loc = drupal_get_path('module', 'tinymce') . '/tinymce/';
      if (!is_dir($tinymce_loc)) {
        drupal_set_message(t('Could not find the TinyMCE engine installed at <strong>!tinymce-directory</strong>. Please <a href="http://tinymce.moxiecode.com/">download TinyMCE</a>, uncompress it and copy the folder into !tinymce-path.', array(
          '!tinymce-path' => drupal_get_path('module', 'tinymce'),
          '!tinymce-directory' => $tinymce_loc,
        )), 'error');
      }
      $output = tinymce_profile_overview();
  }
  return $output;
}