You are here

function fckeditor_admin_profile_form in FCKeditor - WYSIWYG HTML editor 6.2

Form builder for a normal profile

1 call to fckeditor_admin_profile_form()
fckeditor_admin_profile_clone_form in ./fckeditor.admin.inc
Clone profile
1 string reference to 'fckeditor_admin_profile_form'
fckeditor_menu in ./fckeditor.module
Implementation of hook_menu().

File

./fckeditor.admin.inc, line 195
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

Code

function fckeditor_admin_profile_form($form_state, $profile = NULL) {
  if ($profile != NULL) {
    $form['_profile'] = array(
      '#type' => 'value',
      '#value' => $profile,
    );
  }
  else {
    $profile = new stdClass();
  }
  module_load_include('lib.inc', 'fckeditor');
  $toolbar_options = fckeditor_load_toolbar_options();
  $skin_options = fckeditor_load_skin_options();
  $lang_options = fckeditor_load_lang_options();

  // Only display the roles that currently don't have a fckeditor profile. One
  // profile per role.
  $orig_roles = user_roles(FALSE, 'access fckeditor');
  $roles = $orig_roles;
  if (!empty($profile->rids) && !user_roles(FALSE, 'access fckeditor')) {
    drupal_set_message(t('You haven\'t assigned %accesspermission !permissionslink yet. It is recommended to assign the %accesspermission !permissionslink before updating FCKeditor profiles.', array(
      '%accesspermission' => t('access fckeditor'),
      '!permissionslink' => l(t('permission'), 'admin/user/permissions'),
    )), 'warning');
  }
  if (empty($profile->name)) {
    $result = db_query("SELECT DISTINCT(rid) FROM {fckeditor_role}");
    while ($data = db_fetch_object($result)) {
      if ((empty($profile->rids) || !in_array($data->rid, array_keys((array) $profile->rids))) && !form_get_errors()) {
        unset($roles[$data->rid]);
      }
    }
    if (count($orig_roles) != count($roles)) {
      drupal_set_message(t('Not all user roles are shown since they already have FCKeditor profiles. You must first unassign profiles in order to add them to a new one.'));
    }
  }
  $form['basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic setup'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  if (arg(3) == 'clone') {

    //load all profiles to check their names
    $profiles = fckeditor_profile_load();
    $oldname = $profile->name;
    $maxsize = 128;

    //default max name length
    $res = array();
    $pat = "/^(?P<name>.*?)_(?P<n>[0-9]*)\$/";
    if (preg_match_all($pat, $oldname, $res)) {

      // oldname like 'name_nr'
      $name = $res['name'][0];
      $num = $res['n'][0] + 1;
    }
    else {
      $name = $oldname;
      $num = 2;
    }
    $newname = substr($name, 0, $maxsize - 3) . '_' . $num;

    // +limit
    while (isset($profiles[$newname])) {

      //find next free number
      $num++;
      $newname = substr($name, 0, $maxsize - 3) . '_' . $num;
    }

    //dont clone rids
    $profile->settings['rids'] = array();
    $profile->rids = array();
  }
  else {
    $newname = $profile->name;
  }
  $form['basic']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Profile name'),
    '#default_value' => !empty($profile->name) ? $newname : '',
    '#size' => 40,
    '#maxlength' => 128,
    '#description' => t('Enter a name for this profile. This name is only visible within the fckeditor administration page.'),
    '#required' => TRUE,
  );
  $form['basic']['rids'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles allowed to use this profile'),
    '#default_value' => !empty($profile->rids) ? array_keys((array) $profile->rids) : array(),
    '#options' => $roles,
    '#description' => t('Only roles with %accesspermission permission will be shown here. If no role is available, make sure that you have assigned the %accesspermission !permissionslink.', array(
      '%accesspermission' => t('access fckeditor'),
      '!permissionslink' => l(t('permission'), 'admin/user/permissions'),
    )),
    '#required' => TRUE,
  );
  $form['basic']['allow_user_conf'] = array(
    '#type' => 'radios',
    '#title' => t('Allow users to customize FCKeditor appearance'),
    '#default_value' => !empty($profile->settings['allow_user_conf']) ? $profile->settings['allow_user_conf'] : 'f',
    '#options' => array(
      'f' => t('No'),
      't' => t('Yes'),
    ),
    '#description' => t('If allowed, users will be able to override the %appearancesection by visiting their profile page.', array(
      '%appearancesection' => t('Editor appearance'),
    )),
  );
  $form['security'] = array(
    '#type' => 'fieldset',
    '#title' => t('Security'),
    '#description' => '<p>' . t('The FCKeditor security system protects you from executing malicious code that is already in your database. In plain text areas database content is harmless because it is not executed, but the FCKeditor WYSIWYG editor evaluates HTML like a web browser and content needs to be filtered before it is loaded.') . '</p>',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $all = filter_list_all();
  $form['security']['filters'] = array(
    '#type' => 'fieldset',
    '#title' => t('Security filters'),
    '#description' => t('Please choose carefully all filters that protect your content (probably not all filters listed below are security filters).'),
    '#tree' => TRUE,
  );

  //don't bother administrator with filters that definitely are not security filters
  $modules_with_filters_to_skip = array(
    'amazon_filter',
    'asy',
    'bbcode',
    'biblio',
    'blockquote',
    'bookpost',
    'chessboard',
    'citation_filter',
    'codefilter',
    'collapse_text',
    'contextlinks',
    'coolfilter',
    'dialectic',
    'dript',
    'dme',
    'drutex',
    'embedfilter',
    'ext_link_page',
    'extlink',
    'elf',
    'flickr',
    'flickrstickr',
    'footnotes',
    'formdefaults',
    'freelinking',
    'gallery',
    'geogebra',
    'geshifilter',
    'gotwo',
    'googtube',
    'gotcha',
    'gtspam',
    'hidden_content',
    'img_assist',
    'image_filter',
    'inlinetags',
    'insert_view',
    'insertframe',
    'insertnode',
    'interwiki',
    'jlightbox',
    'jsmath',
    'language_sections',
    'link_node',
    'lootz',
    'markdown',
    'marksmarty',
    'mobile_codes',
    'mykml',
    'nofollowlist',
    'oagwt',
    'paging',
    'pathfilter',
    'pearwiki_filter',
    'php',
    'pirate',
    'reptag',
    'scrippet',
    'scripturefilter',
    'signwriter',
    'slideshowpro',
    'smartlinebreakconverter',
    'smartypants',
    'smileys',
    'spamspan',
    'spam_tokens',
    'spoiler',
    'table_altrow',
    'tablemanager',
    'tableofcontents',
    'textile',
    'tooltips',
    'twikifilter',
    'typogrify',
    'unwrap',
    'urlclass',
    'urlicon',
    'url_replace_filter',
    'username_highlighter',
    'video_filter',
    'quote',
    'insert_block',
    'insert_view',
  );
  if (!isset($profile->settings['ss'])) {
    $profile->settings['filters']['filter/0'] = 1;
  }
  foreach ($all as $id => $filter) {
    if (in_array(strtolower($filter->module), $modules_with_filters_to_skip)) {
      continue;
    }

    //skip line break converter and email -> link
    if ($filter->module == 'filter' && in_array($filter->delta, array(
      1,
      2,
    ))) {
      continue;
    }
    $form['security']['filters'][$id] = array(
      '#type' => 'checkbox',
      '#title' => $filter->name,
      '#default_value' => !empty($profile->settings['filters'][$id]),
      '#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta),
    );
  }
  $form['security']['ss'] = array(
    '#type' => 'radios',
    '#title' => t('Security settings'),
    '#default_value' => isset($profile->settings['ss']) ? $profile->settings['ss'] : '2',
    '#options' => array(
      '2' => t('Always run security filters for FCKeditor.'),
      '1' => t('Run security filters only when FCKeditor is set to start automatically.'),
    ),
    '#description' => t('There are two ways of starting FCKeditor: automatically and manually (via toggle or in a popup). If you decide to apply security filters only when FCKeditor starts automatically, you will not be protected when toggling manually from plain text area to FCKeditor or when using FCKeditor in a popup mode. So choose this option only, if you can detect various attacks (mainly XSS) by yourself just by looking at the HTML code.'),
  );
  $form['fckeditor_exclude_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Visibility settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('The following settings are combined with the visibility settings of the global profile.'),
  );
  $form['fckeditor_exclude_settings']['min_rows'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum rows'),
    '#default_value' => !empty($profile->settings['min_rows']) ? $profile->settings['min_rows'] : '5',
    '#description' => t('FCKeditor will be triggered if the textarea has more rows than entered here. Enter \'1\' if you do not want to use this feature.'),
  );
  $form['fckeditor_exclude_settings']['excl_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Use inclusion or exclusion mode'),
    '#default_value' => empty($profile->settings['excl_mode']) || in_array($profile->settings['excl_mode'], array(
      0,
      2,
    )) ? 0 : 1,
    '#options' => array(
      '0' => t('Exclude'),
      '1' => t('Include'),
    ),
    '#description' => t('Choose the way of disabling/enabling FCKeditor on selected fields/paths (see below). Use exclude to disable FCKeditor on selected fields/paths. Use include if you want to load FCKeditor only on selected paths/fields.'),
  );

  /**
   * get excluded fields - so we can have normal textareas too
   * split the phrase by any number of commas or space characters,
   * which include " ", \r, \t, \n and \f
   */
  $form['fckeditor_exclude_settings']['excl'] = array(
    '#type' => 'textarea',
    '#title' => t('Fields to exclude/include'),
    '#cols' => 60,
    '#rows' => 5,
    '#prefix' => '<div style="margin-left:20px">',
    '#suffix' => '</div>',
    '#default_value' => !empty($profile->settings['excl']) ? $profile->settings['excl'] : '',
    '#description' => t('Enter the paths to the textarea fields on which you want to enable or disable FCKeditor.') . ' ' . t('Please see the !helppagelink for more information about defining field names. Short instruction is available below.', array(
      '!helppagelink' => l(t('help page'), 'admin/help/fckeditor', array(
        'fragment' => 'fieldinclexcl',
      )),
    )) . ' <ul>' . '<li>' . t('Path structure') . ': <strong>content_type@path.element_id</strong></li>' . '<li>' . t('The following wildcards are available: *, ?') . '</li>' . '<li>' . t('Content type is optional. You may even specify only path or field id') . '</li>' . '<li>' . t('Examples') . ':<ul>' . '<li><em>blog@*.edit-body</em> - ' . t('matches all fields of type %type called %field, on any page', array(
      '%type' => 'blog',
      '%field' => 'edit-body',
    )) . '<li><em>node/add/*.edit-user-*</em> - ' . t('matches fields starting with %field on pages starting with %path', array(
      '%field' => 'edit-user-',
      '%path' => 'node/add/',
    )) . '</li></ul>' . '</li></ul>',
    '#wysiwyg' => FALSE,
  );
  $form['fckeditor_exclude_settings']['simple_incl'] = array(
    '#type' => 'textarea',
    '#title' => t('Force simplified toolbar on the following fields'),
    '#cols' => 60,
    '#rows' => 5,
    '#default_value' => !empty($profile->settings['simple_incl']) ? $profile->settings['simple_incl'] : '',
    '#description' => t('Enter the paths to the textarea fields on which you want to force the simplified toolbar (%toolbarname).', array(
      '%toolbarname' => FCKEDITOR_FORCE_SIMPLE_TOOLBAR_NAME,
    )) . ' ' . t('Please see the !helppagelink for more information about defining field names. Take a look at the exclusion settings (above) for short instruction.', array(
      '!helppagelink' => l(t('help page'), 'admin/help/fckeditor', array(
        'fragment' => 'fieldinclexcl',
      )),
    )),
    '#wysiwyg' => FALSE,
  );
  $form['appearance'] = array(
    '#type' => 'fieldset',
    '#title' => t('Editor appearance'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['appearance']['default'] = array(
    '#type' => 'radios',
    '#title' => t('Default state'),
    '#default_value' => !empty($profile->settings['default']) ? $profile->settings['default'] : 't',
    '#options' => array(
      't' => t('Enabled'),
      'f' => t('Disabled'),
    ),
    '#description' => t('Default editor state. If disabled, rich text editor may still be enabled using toggle or popup window.'),
  );
  $form['appearance']['show_toggle'] = array(
    '#type' => 'radios',
    '#title' => t('Show disable/enable rich text editor toggle'),
    '#default_value' => !empty($profile->settings['show_toggle']) ? $profile->settings['show_toggle'] : 't',
    '#options' => array(
      't' => t('Show'),
      'f' => t('Hide'),
    ),
    '#description' => t('Whether or not to show the disable/enable rich text editor toggle below the textarea. Works only if FCKeditor is not running in a popup window (see below).'),
  );
  $form['appearance']['popup'] = array(
    '#type' => 'radios',
    '#title' => t('Use FCKeditor in a popup window'),
    '#default_value' => !empty($profile->settings['popup']) ? $profile->settings['popup'] : 'f',
    '#options' => array(
      'f' => t('No'),
      't' => t('Yes'),
    ),
    '#description' => t('If this option is enabled a link to a popup window will be used instead of a textarea replace.'),
  );
  $form['appearance']['skin'] = array(
    '#type' => 'select',
    '#title' => t('Skin'),
    '#default_value' => !empty($profile->settings['skin']) ? $profile->settings['skin'] : 'default',
    '#options' => $skin_options,
    '#description' => t('Choose a default skin.'),
  );
  $form['appearance']['toolbar'] = array(
    '#type' => 'select',
    '#title' => t('Toolbar'),
    '#default_value' => !empty($profile->settings['toolbar']) ? $profile->settings['toolbar'] : 'default',
    '#options' => $toolbar_options,
    '#description' => t('Choose a default toolbar set. To define new toolbar, edit %configfile located in %module_path.', array(
      '%configfile' => 'fckeditor.config.js',
      '%module_path' => drupal_get_path('module', 'fckeditor'),
    )),
  );
  $form['appearance']['expand'] = array(
    '#type' => 'radios',
    '#title' => t('Start the toolbar expanded'),
    '#default_value' => !empty($profile->settings['expand']) ? $profile->settings['expand'] : 't',
    '#options' => array(
      't' => t('Expanded'),
      'f' => t('Collapsed'),
    ),
    '#description' => t('The toolbar start expanded or collapsed.'),
  );
  $form['appearance']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => !empty($profile->settings['width']) ? $profile->settings['width'] : '100%',
    '#description' => t('Width in pixels or percent.') . ' ' . t('Example') . ': 400 ' . t('or') . ' 100%.',
    '#size' => 40,
    '#maxlength' => 128,
  );
  $form['appearance']['lang'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#default_value' => !empty($profile->settings['lang']) ? $profile->settings['lang'] : 'en',
    '#options' => $lang_options,
    '#description' => t('The language for the FCKeditor interface.'),
  );
  $form['appearance']['auto_lang'] = array(
    '#type' => 'radios',
    '#title' => t('Auto-detect language'),
    '#default_value' => !empty($profile->settings['auto_lang']) ? $profile->settings['auto_lang'] : 't',
    '#options' => array(
      't' => t('Enabled'),
      'f' => t('Disabled'),
    ),
    '#description' => t('Use auto detect user language feature.'),
  );
  $form['output'] = array(
    '#type' => 'fieldset',
    '#title' => t('Cleanup and output'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['output']['enter_mode'] = array(
    '#type' => 'select',
    '#title' => t('Enter mode'),
    '#default_value' => !empty($profile->settings['enter_mode']) ? $profile->settings['enter_mode'] : 'p',
    '#options' => array(
      'p' => '<p>',
      'br' => '<br />',
      'div' => '<div>',
    ),
    '#description' => t('Set which tag FCKeditor should use when [Enter] key is pressed.'),
  );
  $form['output']['shift_enter_mode'] = array(
    '#type' => 'select',
    '#title' => t('Shift + Enter mode'),
    '#default_value' => !empty($profile->settings['shift_enter_mode']) ? $profile->settings['shift_enter_mode'] : 'br',
    '#options' => array(
      'p' => '<p>',
      'br' => '<br />',
      'div' => '<div>',
    ),
    '#description' => t('Set which tag FCKeditor should use when [Shift] + [Enter] is pressed.'),
  );
  $form['output']['font_format'] = array(
    '#type' => 'textfield',
    '#title' => t('Font formats'),
    '#default_value' => !empty($profile->settings['font_format']) ? $profile->settings['font_format'] : 'p;div;pre;address;h1;h2;h3;h4;h5;h6',
    '#size' => 40,
    '#maxlength' => 250,
    '#description' => t('Semicolon separated list of HTML font formats.') . ' ' . t('Allowed values are') . ': p;div;pre;address;h1;h2;h3;h4;h5;h6',
  );
  $form['output']['format_source'] = array(
    '#type' => 'radios',
    '#title' => t('Apply source formatting'),
    '#default_value' => !empty($profile->settings['format_source']) ? $profile->settings['format_source'] : 't',
    '#options' => array(
      't' => t('Yes'),
      'f' => t('No'),
    ),
    '#description' => t('When set to %true the editor will format the XHTML when switching from WYSIWYG view to Source view, by inserting line breaks on some tags endings and indenting paragraphs, tables and lists.', array(
      '%true' => t('Yes'),
    )),
  );
  $form['output']['format_output'] = array(
    '#type' => 'radios',
    '#title' => t('Format output'),
    '#default_value' => !empty($profile->settings['format_output']) ? $profile->settings['format_output'] : 't',
    '#options' => array(
      't' => t('Yes'),
      'f' => t('No'),
    ),
    '#description' => t('When set to %true the editor will format the XHTML output by inserting line breaks on some tags endings and indenting paragraphs, tables and lists.', array(
      '%true' => t('Yes'),
    )),
  );
  $form['output']['autofixplaintext'] = array(
    '#type' => 'radios',
    '#title' => t('Automatically detect and convert plain text'),
    '#default_value' => !empty($profile->settings['autofixplaintext']) ? $profile->settings['autofixplaintext'] : 'f',
    '#options' => array(
      't' => t('Yes'),
      'f' => t('No'),
    ),
    '#description' => t('When set to %true the editor will try to detect if a field was created using the plain text editor and convert line breaks to &lt;br /&gt; and &lt;p&gt; tags. This will alter the field contents and is not reversible.', array(
      '%true' => t('Yes'),
    )),
  );
  $form['css'] = array(
    '#type' => 'fieldset',
    '#title' => t('Style and template files'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['css']['css_mode'] = array(
    '#type' => 'select',
    '#title' => t('Editor CSS'),
    '#default_value' => !empty($profile->settings['css_mode']) ? $profile->settings['css_mode'] : 'theme',
    '#options' => array(
      'theme' => t('Use theme CSS'),
      'self' => t('Define CSS'),
      'none' => t('FCKeditor default'),
    ),
    '#description' => t('Defines the CSS to be used in the editor area.') . '<br />' . t('Use theme CSS') . ': ' . t('load style.css from current site theme.') . '<br/>' . t('Define CSS') . ': ' . t('enter path for CSS file below.') . '<br />' . t('FCKeditor default') . ': ' . t('uses default CSS from editor.'),
  );
  $form['css']['css_path'] = array(
    '#type' => 'textfield',
    '#title' => t('CSS path'),
    '#default_value' => !empty($profile->settings['css_path']) ? $profile->settings['css_path'] : "",
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Enter path to CSS file (Example: %cssexample1) or a list of CSS files separated by a comma (Example: %cssexample2). Make sure to select %defcss above.', array(
      '%cssexample1' => 'css/editor.css',
      '%cssexample2' => '/themes/garland/style.css,http://example.com/style.css',
      '%defcss' => 'Define css',
    )) . '<br />' . t('Available placeholders') . ':<br />' . '<strong>%h</strong> - ' . t('host name (%host)', array(
      '%host' => base_path(),
    )) . '<br />' . '<strong>%t</strong> - ' . t('path to theme (%theme)', array(
      '%theme' => base_path() . fckeditor_path_to_theme() . '/',
    )),
  );
  $form['css']['css_style'] = array(
    '#type' => 'select',
    '#title' => t('Predefined styles'),
    '#default_value' => !empty($profile->settings['css_style']) ? $profile->settings['css_style'] : 'theme',
    '#options' => array(
      'theme' => t('Use theme fckstyles.xml'),
      'self' => t('Define path to fckstyles.xml'),
      'default' => t('FCKeditor default'),
    ),
    '#description' => t('Define the location of %file file. It is used by the %setting dropdown list available in the default toolbar. Copy %sourcefile inside your theme directory (%themefile) and adjust it to your needs.', array(
      '%file' => 'fckstyles.xml',
      '%setting' => t('Style'),
      '%sourcefile' => fckeditor_path(TRUE) . '/fckstyles.xml',
      '%themefile' => fckeditor_path_to_theme() . '/fckstyles.xml',
    )),
  );
  $form['css']['styles_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Predefined styles path'),
    '#default_value' => !empty($profile->settings['styles_path']) ? $profile->settings['styles_path'] : "",
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Enter the path to XML file with predefined @type (Example: %example). Be sure to select %setting above.', array(
      '@type' => t('styles'),
      '%example' => '/fckstyles.xml',
      '%setting' => t('Define path to fckstyles.xml'),
    )) . '<br />' . t('Available placeholders') . ':<br />' . '<strong>%h</strong> - ' . t('host name (%host)', array(
      '%host' => base_path(),
    )) . '<br />' . '<strong>%t</strong> - ' . t('path to theme (%theme)', array(
      '%theme' => base_path() . fckeditor_path_to_theme() . '/',
    )) . '<br />' . '<strong>%m</strong> - ' . t('path to FCKeditor module (%module)', array(
      '%module' => drupal_get_path('module', 'fckeditor'),
    )),
  );
  $form['css']['templatefile_mode'] = array(
    '#type' => 'select',
    '#title' => t('Predefined templates'),
    '#default_value' => !empty($profile->settings['templatefile_mode']) ? $profile->settings['templatefile_mode'] : 'default',
    '#options' => array(
      'default' => t('FCKeditor default'),
      'theme' => t('Use theme fcktemplates.xml'),
      'self' => t('Define path to fcktemplates.xml'),
    ),
    '#description' => t('Define the location of %file file. It is used by the %setting dropdown list available in the default toolbar. Copy %sourcefile inside your theme directory (%themefile) and adjust it to your needs.', array(
      '%file' => 'fcktemplates.xml',
      '%setting' => t('Templates'),
      '%sourcefile' => fckeditor_path(TRUE) . '/fcktemplates.xml',
      '%themefile' => fckeditor_path_to_theme() . '/fcktemplates.xml',
    )),
  );
  $form['css']['templatefile_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Predefined templates path'),
    '#default_value' => !empty($profile->settings['templatefile_path']) ? $profile->settings['templatefile_path'] : '',
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Enter the path to XML file with predefined @type (Example: %example). Be sure to select %setting above.', array(
      '@type' => t('templates'),
      '%example' => '/fckstyles.xml',
      '%setting' => t('Define path to fckstyles.xml'),
    )) . '<br />' . t('Available placeholders') . ':<br />' . '<strong>%h</strong> - ' . t('host name (%host)', array(
      '%host' => base_path(),
    )) . '<br />' . '<strong>%t</strong> - ' . t('path to theme (%theme)', array(
      '%theme' => base_path() . fckeditor_path_to_theme() . '/',
    )) . '<br />' . '<strong>%m</strong> - ' . t('path to FCKeditor module (%module)', array(
      '%module' => drupal_get_path('module', 'fckeditor'),
    )),
  );
  $form['fckeditor_upload_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('File browser settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Set file browser settings. A file browser will allow you to explore the files contained on the server and embed them as links, images or flash movies. Besides the built-in FCKeditor file browser, you can also use a contributed module like !imcelink, !iblink or !webfmlink. The quick upload setting controls whether images, flash movies and files can be uploaded using the upload tab of the respective dialogs. Please note that these options require manual configuration, check !readmelink for more information.', array(
      '!imcelink' => l(t('IMCE'), 'http://drupal.org/project/imce'),
      '!iblink' => l(t('Image Browser'), 'http://drupal.org/project/imagebrowser'),
      '!webfmlink' => l(t('Web File Manager'), 'http://drupal.org/project/webfm'),
      '!readmelink' => l(t('readme.txt'), 'admin/help/fckeditor'),
    )),
  );
  $filebrowsers = array(
    'none' => t('None'),
    'builtin' => t('Built-in file browser'),
  );
  if (module_exists('imce')) {
    $filebrowsers['imce'] = t('IMCE');
  }
  if (module_exists('imagebrowser')) {
    $filebrowsers['ib'] = t('Image Browser');
  }
  if (module_exists('webfm_popup')) {
    $filebrowsers['webfm'] = t('Web File Manager');
  }
  if (file_exists(_fckeditor_ckfinder_path())) {
    $filebrowsers['ckfinder'] = t('CKFinder');
  }
  $form['fckeditor_upload_settings']['filebrowser'] = array(
    '#type' => 'select',
    '#title' => t('File browser type'),
    '#default_value' => !empty($profile->settings['filebrowser']) ? $profile->settings['filebrowser'] : 'none',
    '#options' => $filebrowsers,
    '#description' => t('Select the file browser that you would like to use to upload files, images and flash movies.'),
  );
  $form['fckeditor_upload_settings']['quickupload'] = array(
    '#type' => 'radios',
    '#title' => t('Allow quick uploads'),
    '#default_value' => !empty($profile->settings['quickupload']) ? $profile->settings['quickupload'] : 'f',
    '#options' => array(
      'f' => t('No'),
      't' => t('Yes'),
    ),
    '#description' => t('The quick upload functionality can be disabled and enabled independently of the file browser. It will always use the settings below. To enable quick uploads you must follow the same configuration procedure as when enabling the built-in file browser.'),
  );
  $current_user_files_path = empty($profile->settings['UserFilesPath']) ? "" : strtr($profile->settings['UserFilesPath'], array(
    "%f" => file_directory_path(),
    "%u" => "UID",
    "%b" => base_path(),
    "%n" => "UNAME",
  ));
  $current_user_files_absolute_path = empty($profile->settings['UserFilesAbsolutePath']) ? "" : strtr($profile->settings['UserFilesAbsolutePath'], array(
    "%f" => file_directory_path(),
    "%u" => "UID",
    "%b" => base_path(),
    "%d" => $_SERVER['DOCUMENT_ROOT'],
    "%n" => "UNAME",
  ));
  $form['fckeditor_upload_settings']['UserFilesPath'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to uploaded files'),
    '#default_value' => !empty($profile->settings['UserFilesPath']) ? $profile->settings['UserFilesPath'] : "%b%f/",
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Path to uploaded files relative to the document root.') . '<br />' . t('Available placeholders') . ':<br/>' . '<strong>%b</strong> - ' . t('base URL path of the Drupal installation (%base)', array(
      '%base' => base_path(),
    )) . '<br/>' . '<strong>%f</strong> - ' . t('Drupal file system path where the files are stored (%files)', array(
      '%files' => file_directory_path(),
    )) . '<br />' . '<strong>%u</strong> - ' . t('User ID') . '<br />' . '<strong>%n</strong> - ' . t('Username') . '<br />' . t('Current path: %path', array(
      '%path' => $current_user_files_path,
    )),
  );
  $form['fckeditor_upload_settings']['UserFilesAbsolutePath'] = array(
    '#type' => 'textfield',
    '#title' => t('Absolute path to uploaded files'),
    '#default_value' => !empty($profile->settings['UserFilesAbsolutePath']) ? $profile->settings['UserFilesAbsolutePath'] : "%d%b%f/",
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('The path to the local directory (in the server) which points to the path defined above. If empty, FCKeditor will try to discover the right path.') . '<br />' . t('Available placeholders') . ':<br/>' . '<strong>%d</strong> - ' . t('server path to document root (%root)', array(
      '%root' => $_SERVER['DOCUMENT_ROOT'],
    )) . '<br />' . '<strong>%b</strong> - ' . t('base URL path of the Drupal installation (%base)', array(
      '%base' => base_path(),
    )) . '<br/>' . '<strong>%f</strong> - ' . t('Drupal file system path where the files are stored (%files)', array(
      '%files' => file_directory_path(),
    )) . '<br />' . '<strong>%u</strong> - ' . t('User ID') . '<br />' . '<strong>%n</strong> - ' . t('Username') . '<br />' . t('Current path: %path', array(
      '%path' => $current_user_files_absolute_path,
    )),
  );
  if (variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE) {
    $form['fckeditor_upload_settings']['UserFilesPath']['#description'] = t('Setting relative path to uploaded files has been disabled because private downloads are enabled and this path is calculated automatically. To change the location of uploaded files in the private file system, edit the !globallink.', array(
      '!globallink' => l(t('FCKeditor Global Profile'), 'admin/settings/fckeditor/editg'),
    ));
    $form['fckeditor_upload_settings']['UserFilesPath']['#disabled'] = TRUE;
    $form['fckeditor_upload_settings']['UserFilesAbsolutePath']['#description'] = t('Setting path to uploaded files has been disabled because private downloads are enabled and this path is calculated automatically. To change the location of uploaded files in the private file system, edit the !globallink.', array(
      '!globallink' => l(t('FCKeditor Global Profile'), 'admin/settings/fckeditor/editg'),
    ));
    $form['fckeditor_upload_settings']['UserFilesAbsolutePath']['#disabled'] = TRUE;
  }
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['advanced']['theme_config_js'] = array(
    '#type' => 'radios',
    '#title' => t('Load fckeditor.config.js from theme path'),
    '#default_value' => !empty($profile->settings['theme_config_js']) ? $profile->settings['theme_config_js'] : 'f',
    '#options' => array(
      't' => t('Yes'),
      'f' => t('No'),
    ),
    '#description' => t('When set to %true the editor will try to load the %configfile file from theme directory (%theme_path).', array(
      '%true' => t('Yes'),
      '%configfile' => 'fckeditor.config.js',
      '%theme_path' => base_path() . fckeditor_path_to_theme(),
    )),
  );
  $form['advanced']['js_conf'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom javascript configuration'),
    '#default_value' => !empty($profile->settings['js_conf']) ? $profile->settings['js_conf'] : "",
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('To change FCKeditor configuration globally, you should modify the config file: %fckeditor_config. Sometimes it is required to change the FCKeditor configuration for a single profile only. Use this box to define settings that are unique for this profile. Available options are listed in the !docslink. Add the following code snippet to disable some advanced tabs in dialog windows of FCKeditor.', array(
      '%fckeditor_config' => drupal_get_path('module', 'fckeditor') . '/fckeditor.config.js',
      '!docslink' => l(t('FCKeditor documentation'), 'http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options'),
    )) . "<pre>LinkDlgHideTarget = true;\nLinkDlgHideAdvanced = true;\nImageDlgHideLink = true;\nImageDlgHideAdvanced = true;\nFlashDlgHideAdvanced = true;</pre>" . '<strong>' . t('Warning') . '</strong>: ' . t('If you do something wrong here, FCKeditor may fail to load.'),
    '#wysiwyg' => FALSE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}