You are here

function fckeditor_profile_form_build in FCKeditor - WYSIWYG HTML editor 5.2

Same name and namespace in other branches
  1. 6 fckeditor.module \fckeditor_profile_form_build()

Return an HTML form for profile configuration.

1 string reference to 'fckeditor_profile_form_build'
fckeditor_profile_form in ./fckeditor.module
Return an HTML form for profile configuration.

File

./fckeditor.module, line 1634
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2007 Frederico Caldeira Knabben

Code

function fckeditor_profile_form_build($edit) {
  $edit = (object) $edit;
  $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 ($edit->rids && !user_roles(false, 'access fckeditor')) {
    drupal_set_message(t('You haven\'t assigned <code>!access1</code> !permissions yet.<br/>It is recommended to assign the <code>!access1</code> !permissions before updating FCKeditor profiles.', array(
      '!access1' => t('access fckeditor'),
      '!permissions' => l(t('permissions'), 'admin/user/access'),
    )), 'warning');
  }
  if (arg(3) == 'add') {
    $breadcrumb[] = array(
      'path' => 'admin',
      'title' => t('administer'),
    );
    $breadcrumb[] = array(
      'path' => 'admin/settings/fckeditor',
      'title' => t('fckeditor'),
    );
    $breadcrumb[] = array(
      'path' => 'admin/settings/fckeditor/add',
      'title' => t('Add new FCKeditor profile'),
    );
    menu_set_location($breadcrumb);
    $result = db_query('SELECT DISTINCT(rid) FROM {fckeditor_role}');
    while ($data = db_fetch_object($result)) {
      if (!in_array($data->rid, array_keys((array) $edit->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.'));
    }
    $btn = t('Create profile');
  }
  else {
    $form['old_name'] = array(
      '#type' => 'hidden',
      '#value' => $edit->name,
    );
    $btn = t('Update profile');
  }
  $form['basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic setup'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['basic']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Profile name'),
    '#default_value' => $edit->name,
    '#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' => array_keys((array) $edit->rids),
    '#options' => $roles,
    '#description' => t('Only roles with \'!access1\' permission will be shown here. If no role is available, make sure that you have assigned the \'!access1\' !permission.', array(
      '!access1' => t('access fckeditor'),
      '!permission' => l(t("permission"), "admin/user/access"),
    )),
    '#required' => TRUE,
  );
  $form['basic']['allow_user_conf'] = array(
    '#type' => 'select',
    '#title' => t('Allow users to customize FCKeditor appearance'),
    '#default_value' => $edit->settings['allow_user_conf'] ? $edit->settings['allow_user_conf'] : 'f',
    '#options' => array(
      'f' => t('false'),
      't' => t('true'),
    ),
    '#description' => t('If allowed, users will be able to override <code>Editor appearance</code> by visiting their profile page.'),
  );
  $form['security'] = array(
    '#type' => 'fieldset',
    '#title' => t('Security'),
    '#description' => '<p>' . t("When Drupal saves user data input through a textarea, it's saved in the database in unmodified form. That's why all untrusted textarea input should be run through an input format filter before outputting it to the screen.") . '</p>' . '<p>' . t("Drupal will not, however, filter data for content editors editing a textarea. Normally, there is no security risk because the unmodified code is displayed as text and will not be rendered as HTML. But with FCKeditor installed, this is not the case, and content editors are subject to having raw, untrusted code running inside their browsers.") . '</p>' . '<p>' . t("To address this issue, you should select a security filters below to prevent FCKeditor from rendering malicious code. Note that if a textarea's input format is set to \"Full HTML\" (or if the input format of the node doesn't include the filter), FCKeditor will properly ignore the setting below and will not run the code through the security filter.") . '</p>' . '<p>' . t("If any textareas on your site are accessible to unwanted users, we recommend checking the \"HTML Filter\". You may have other modules installed that provide other kinds of security filters and you may use those as long as you trust them to properly filter out malicious code. Note that not all the filters below are security filters and will provide no protection.") . '</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',
  );
  if (!isset($edit->settings['ss'])) {
    $edit->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,
      3,
    ))) {
      continue;
    }
    $form['security']['filters'][$id] = array(
      '#type' => 'checkbox',
      '#title' => $filter->name,
      '#default_value' => isset($edit->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($edit->settings['ss']) ? $edit->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\'ll not be protected when toggling manually from plain textarea 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' => $edit->settings['min_rows'] ? $edit->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' => 'select',
    '#title' => t('Use inclusion or exclusion mode'),
    '#default_value' => in_array($edit->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_fields'] = array(
    '#type' => 'textarea',
    '#title' => t('Fields to exclude/include'),
    '#cols' => 60,
    '#rows' => 5,
    '#prefix' => '<div style="margin-left:20px">',
    '#suffix' => '</div>',
    '#default_value' => $edit->settings['excl_fields'] ? $edit->settings['excl_fields'] : '',
    '#description' => t("Enter names (HTML ID's) of fields that may or may not have an FCKeditor, depending on the chosen option for the inclusion/exclusion mode.<br />You may separate the different entries by commas, spaces or newlines.<br />You may also use * as a wildcard character."),
  );

  /**
   * get excluded paths - 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_paths'] = array(
    '#type' => 'textarea',
    '#title' => t('Paths to exclude/include'),
    '#prefix' => '<div style="margin-left:20px">',
    '#suffix' => '</div>',
    '#cols' => 60,
    '#rows' => 5,
    '#default_value' => $edit->settings['excl_paths'] ? $edit->settings['excl_paths'] : '',
    '#description' => t("Enter drupal paths here, depending on the chosen option for the inclusion/exclusion mode.<br />Paths may be used the same way as in the drupal blocks configuration.<br />You may separate the different entries by commas, spaces or newlines. <br />You may also use * as a wildcard character (for example <code>comment/*</code>)."),
  );
  $form['fckeditor_exclude_settings']['simple_incl_fields'] = array(
    '#type' => 'textarea',
    '#title' => t('Force simplified toolbar on the following fields'),
    '#cols' => 60,
    '#rows' => 5,
    //'#prefix' => t('Here you can define where FCKeditor should force the <code>!simple</code> toolbar.<br/>Useful for smaller textareas where we usually don\'t use very complicated HTML code, like in signatures.', array('!simple' => FCKEDITOR_FORCE_SIMPLE_TOOLBAR_NAME)),
    '#default_value' => $edit->settings['simple_incl_fields'] ? $edit->settings['simple_incl_fields'] : '',
    '#description' => t("Enter names (HTML ID's) of fields that should have the simplified toolbar (!name).<br />If you don't want to use this feature, simply leave this field empty.<br />You may separate the different entries by commas, spaces or newlines.", array(
      "!name" => FCKEDITOR_FORCE_SIMPLE_TOOLBAR_NAME,
    )),
  );
  $form['fckeditor_exclude_settings']['simple_incl_paths'] = array(
    '#type' => 'textarea',
    '#title' => t('Force simplified toolbar on the following paths'),
    '#cols' => 60,
    '#rows' => 5,
    //'#prefix' => t('Here you can define where FCKeditor should force the <code>!simple</code> toolbar.<br/>Useful for smaller textareas where we usually don\'t use very complicated HTML code, like in signatures.', array('!simple' => FCKEDITOR_FORCE_SIMPLE_TOOLBAR_NAME)),
    '#default_value' => $edit->settings['simple_incl_paths'] ? $edit->settings['simple_incl_paths'] : '',
    '#description' => t("Enter drupal paths that should have the simplified toolbar (!name).<br />If you don't want to use this feature, simply leave this field empty.<br />Paths may be used the same way as in the drupal blocks configuration.<br />You may separate the different entries by commas, spaces or newlines.<br />You may also use * as a wildcard character (for example <code>comment/*</code>).", array(
      "!name" => FCKEDITOR_FORCE_SIMPLE_TOOLBAR_NAME,
    )),
  );
  $form['appearance'] = array(
    '#type' => 'fieldset',
    '#title' => t('Editor appearance'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['appearance']['default'] = array(
    '#type' => 'select',
    '#title' => t('Default state'),
    '#default_value' => $edit->settings['default'] ? $edit->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' => 'select',
    '#title' => t('Show disable/enable rich text editor toggle'),
    '#default_value' => $edit->settings['show_toggle'] ? $edit->settings['show_toggle'] : 't',
    '#options' => array(
      't' => t('true'),
      'f' => t('false'),
    ),
    '#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' => 'select',
    '#title' => t('Use FCKeditor in a popup window'),
    '#default_value' => $edit->settings['popup'] ? $edit->settings['popup'] : 'f',
    '#options' => array(
      'f' => t('false'),
      't' => t('true'),
    ),
    '#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' => $edit->settings['skin'] ? $edit->settings['skin'] : 'default',
    '#options' => $skin_options,
    '#description' => t('Choose a default skin.'),
  );
  $form['appearance']['toolbar'] = array(
    '#type' => 'select',
    '#title' => t('Toolbar'),
    '#default_value' => $edit->settings['toolbar'] ? $edit->settings['toolbar'] : 'default',
    '#options' => $toolbar_options,
    '#description' => t('Choose a default toolbar set. To define new toolbar, edit <code>fckeditor.config.js</code> located in !module_path.', array(
      '!module_path' => drupal_get_path('module', 'fckeditor'),
    )),
  );
  $form['appearance']['expand'] = array(
    '#type' => 'select',
    '#title' => t('Start the toolbar expanded'),
    '#default_value' => $edit->settings['expand'] ? $edit->settings['expand'] : 't',
    '#options' => array(
      't' => t('enabled'),
      'f' => t('disabled'),
    ),
    '#description' => t('The toolbar start expanded or collapsed.'),
  );
  $form['appearance']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $edit->settings['width'] ? $edit->settings['width'] : '100%',
    '#description' => t("Width in pixels or percent. Ex: 400 or 100%"),
    '#size' => 40,
    '#maxlength' => 128,
  );
  $form['appearance']['lang'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#default_value' => $edit->settings['lang'] ? $edit->settings['lang'] : 'en',
    '#options' => $lang_options,
    '#description' => t('The language for the FCKeditor interface.'),
  );
  $form['appearance']['auto_lang'] = array(
    '#type' => 'select',
    '#title' => t('Auto-detect language'),
    '#default_value' => $edit->settings['auto_lang'] ? $edit->settings['auto_lang'] : 't',
    '#options' => array(
      't' => t('true'),
      'f' => t('false'),
    ),
    '#description' => t('Use auto detect user language feature.'),
  );

  /*
  $form['appearance']['appearance_conf'] = array(
  '#type' => 'select',
  '#title' => t('Ignore this section, use default settings defined in config files'),
  '#default_value' => $edit->settings['appearance_conf'] ? $edit->settings['appearance_conf'] : 'f',
  '#options' => array('f' => t('false'), 't' => t('true')),
  '#description' => t('Although it is less handy, defining settings only in config files (<code>fckconfig.js</code> and <code>fckeditor.config.js</code>) will slightly leverage your traffic and improve load time of your site. <br/>Warning: if set to true, all changes made in <code>Editor appearance</code> will have no affect on FCKeditor\'s behaviour.'),
  );
  */
  $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' => $edit->settings['enter_mode'] ? $edit->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' => $edit->settings['shift_enter_mode'] ? $edit->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' => $edit->settings['font_format'] ? $edit->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. Allowed values are: p;div;pre;address;h1;h2;h3;h4;h5;h6'),
  );
  $form['output']['format_source'] = array(
    '#type' => 'select',
    '#title' => t('Apply source formatting'),
    '#default_value' => $edit->settings['format_source'] ? $edit->settings['format_source'] : 't',
    '#options' => array(
      't' => t('true'),
      'f' => t('false'),
    ),
    '#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.'),
  );
  $form['output']['format_output'] = array(
    '#type' => 'select',
    '#title' => t('Format output'),
    '#default_value' => $edit->settings['format_output'] ? $edit->settings['format_output'] : 't',
    '#options' => array(
      't' => t('true'),
      'f' => t('false'),
    ),
    '#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.'),
  );

  /*
  $form['output']['output_conf'] = array(
  '#type' => 'select',
  '#title' => t('Ignore this section, use default settings defined in config files'),
  '#default_value' => $edit->settings['output_conf'] ? $edit->settings['output_conf'] : 'f',
  '#options' => array('f' => t('false'), 't' => t('true')),
  '#description' => t('Although it is less handy, defining settings only in config files (<code>fckconfig.js</code> and <code>fckeditor.config.js</code>) will slightly leverage your traffic and improve load time of your site. <br/>Warning: if set to true, all changes made in <code>Cleanup and output</code> will have no affect on FCKeditor\'s behaviour.'),
  );
  */
  $form['css'] = array(
    '#type' => 'fieldset',
    '#title' => t('CSS'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['css']['css_mode'] = array(
    '#type' => 'select',
    '#title' => t('Editor CSS'),
    '#default_value' => $edit->settings['css_mode'] ? $edit->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 />use theme css - load style.css from current site theme.<br/>define css - enter path for css file below.<br />FCKeditor default - uses default CSS from editor.'),
  );
  $form['css']['css_path'] = array(
    '#type' => 'textfield',
    '#title' => t('CSS path'),
    '#default_value' => $edit->settings['css_path'],
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Enter path to CSS file (<em>example: css/editor.css</em>) or a list of css files separated by a comma (<em>example: /themes/garland/style.css,http://example.com/style.css</em>).<br />Macros: %h (host name: !host), %t (path to theme: !theme)<br />Be sure to select "define css" above.', array(
      '!host' => base_path(),
      '!theme' => base_path() . path_to_theme() . '/',
    )),
  );
  $form['css']['css_style'] = array(
    '#type' => 'select',
    '#title' => t('Predefined styles'),
    '#default_value' => $edit->settings['css_style'] ? $edit->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 <code>fckstyles.xml</code> file. It is used by the &quot;Style&quot; dropdown list available in the Default toolbar.<br />Copy !fckstyles.xml inside your theme directory (<code>!theme</code>) and adjust it to your needs.', array(
      '!fckstyles.xml' => drupal_get_path('module', 'fckeditor') . '/fckeditor/fckstyles.xml',
      '!theme' => path_to_theme() . '/fckstyles.xml',
    )),
  );
  $form['css']['styles_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Predefined styles path'),
    '#default_value' => $edit->settings['styles_path'],
    '#size' => 40,
    '#maxlength' => 255,
    '#description' => t('Enter path to XML file with predefined styles (<em>example: /fckstyles.xml</em>).<br />Macros: %h (host name: !host), %t (path to theme: !theme), %m (path to FCKeditor module: !module)<br />Be sure to select "define path to fckstyles.xml" above.', array(
      '!host' => base_path(),
      '!theme' => base_path() . path_to_theme() . '/',
      '!module' => drupal_get_path('module', 'fckeditor'),
    )),
  );

  // don't show useless options if IMCE is preferred
  if (function_exists('imce_integrate') && variable_get('imce_settings_fck', 0)) {
    $form['fckeditor_upload_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('File browser settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('The file browser settings are not diplayed because you have configured IMCE to handle file browsing.'),
    );
  }
  else {
    $form['fckeditor_upload_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('File browser settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Set file browser settings. If you enable file uploads and disable basic and advanced file management, you will need to manage your images and other files with the core upload module or a contrib module like !imce. Please note that these options require manual configuration, check !readme for more information.<br />', array(
        '!imce' => l(t('IMCE'), 'http://drupal.org/project/imce'),
        '!readme' => l('readme.txt', 'admin/help/fckeditor'),
      )),
    );
    $form['fckeditor_upload_settings']['upload_basic'] = array(
      '#type' => 'select',
      '#options' => array(
        'f' => t('false'),
        't' => t('true'),
      ),
      '#title' => t('Allow basic file management'),
      '#default_value' => $edit->settings['upload_basic'] ? $edit->settings['upload_basic'] : 'f',
      '#description' => t("Allow quick uploads."),
    );
    $form['fckeditor_upload_settings']['upload_advanced'] = array(
      '#type' => 'select',
      '#options' => array(
        'f' => t('false'),
        't' => t('true'),
      ),
      '#title' => t('Allow advanced file management'),
      '#default_value' => $edit->settings['upload_advanced'] ? $edit->settings['upload_advanced'] : 'f',
      '#description' => t('Allow file management in the advanced file manager.'),
    );
    $current_user_files_path = strtr($edit->settings['UserFilesPath'], array(
      "%f" => file_directory_path(),
      "%u" => "UID",
      "%b" => base_path(),
    ));
    $current_user_files_absolute_path = strtr($edit->settings['UserFilesAbsolutePath'], array(
      "%f" => file_directory_path(),
      "%u" => "UID",
      "%b" => base_path(),
      "%d" => $_SERVER['DOCUMENT_ROOT'],
    ));
    $form['fckeditor_upload_settings']['UserFilesPath'] = array(
      '#type' => 'textfield',
      '#title' => t('Path to uploaded files'),
      '#default_value' => $edit->settings['UserFilesPath'] ? $edit->settings['UserFilesPath'] : "%b%f/",
      '#size' => 40,
      '#maxlength' => 255,
      '#description' => t('Path to uploaded files relative to the document root.<br />Available wildcard characters:<br/><strong>%b</strong> - base URL path of the Drupal installation (!base).<br/><strong>%f</strong> - Drupal file system path where the files are stored (!files).<br /><strong>%u</strong> - User ID.<br />Current path: !path', array(
        '!path' => $current_user_files_path,
        '!files' => file_directory_path(),
        '!base' => base_path(),
      )),
    );
    $form['fckeditor_upload_settings']['UserFilesAbsolutePath'] = array(
      '#type' => 'textfield',
      '#title' => t('Absolute path to uploaded files'),
      '#default_value' => $edit->settings['UserFilesAbsolutePath'] ? $edit->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 />Available wildcard characters:<br/><strong>%d</strong> - server path to document root (!root).<br /><strong>%b</strong> - base URL path of the Drupal installation (!base).<br/><strong>%f</strong> - Drupal file system path where the files are stored (!files).<br /><strong>%u</strong> - User ID.<br />Current path: !path', array(
        '!path' => $current_user_files_absolute_path,
        '!files' => file_directory_path(),
        '!base' => base_path(),
        '!root' => $_SERVER['DOCUMENT_ROOT'],
      )),
    );
    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 <a href="!url">FCKeditor Global Profile</a>.', array(
        '!url' => url('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 <a href="!url">FCKeditor Global Profile</a>.', array(
        '!global' => url('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(
    '#title' => t('Load fckeditor.config.js from theme path'),
    '#default_value' => !empty($edit->settings['theme_config_js']) ? $edit->settings['theme_config_js'] : 'f',
    '#type' => 'select',
    '#options' => array(
      'f' => t('false'),
      't' => t('true'),
    ),
    '#description' => t('When set to "true" the editor will try to load the fckeditor.config.js file from theme directory.'),
  );
  if (function_exists('linktocontent_node_menu') && function_exists('pathfilter_filter')) {
    $form['advanced']['linktoc'] = array(
      '#type' => 'select',
      '#options' => array(
        'p' => t('Link to paths only'),
        'n' => t('Link using internal: links'),
        'pn' => t('Allow user to select between paths and internal links'),
      ),
      '#title' => t('Path Filter & Link To Content integration'),
      '#default_value' => empty($edit->settings['linktoc']) ? 'p' : $edit->settings['linktoc'],
      '#description' => t('With !plink extension it is possible to use :internal links. By default !link extension is linking to nodes using paths.', array(
        '!plink' => l(t('Path Filter'), 'http://drupal.org/project/pathfilter'),
        '!link' => l(t('Link To Content'), 'http://drupal.org/project/linktocontent'),
      )),
    );
  }
  $form['advanced']['js_conf'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom javascript configuration'),
    '#default_value' => $edit->settings['js_conf'],
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('Warning: to change FCKeditor configuration globally, you should modify the config file: <code>!fckeditor_config</code>.<br/>Sometimes it is required to change the FCKeditor configuration for selected profile. Use this box to define settings that are unique for this profile.<br/>Available options are listed in the !docs.<br/>Warning: if you make something wrong here, FCKeditor may fail to load.<br/>For example to disable some advanced tabs in dialog windows in FCKeditor, add the following: !example', array(
      '!fckeditor_config' => drupal_get_path('module', 'fckeditor') . "/fckeditor.config.js",
      '!docs' => l(t("FCKeditor documentation"), "http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options"),
      "!example" => "<pre>LinkDlgHideTarget = true ;\nLinkDlgHideAdvanced = true ;\nImageDlgHideLink = true ;\nImageDlgHideAdvanced = true ;\nFlashDlgHideAdvanced = true ;</pre>",
    )),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $btn,
  );
  return $form;
}