You are here

function fckeditor_global_profile_form_build in FCKeditor - WYSIWYG HTML editor 6

Same name and namespace in other branches
  1. 5.2 fckeditor.module \fckeditor_global_profile_form_build()
1 string reference to 'fckeditor_global_profile_form_build'
fckeditor_global_profile_form in ./fckeditor.module
Return an HTML form for global profile configuration.

File

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

Code

function fckeditor_global_profile_form_build($sth, $edit) {
  $edit = (object) $edit;
  if (arg(3) == 'addg') {
    drupal_set_breadcrumb(array(
      l(t('administer'), 'admin'),
      l(t('fckeditor'), 'admin/settings/fckeditor'),
      l(t('Add new FCKeditor Global Profile'), 'admin/settings/fckeditor/addg'),
    ));
    $result = db_query("SELECT DISTINCT(rid) FROM {fckeditor_role} WHERE name='FCKeditor Global Profile'");
    $data = db_fetch_object($result);
    if (!empty($data->rid)) {
      drupal_set_message(t("Global profile already exist. Only one global profile is allowed."), "error");
      return array();
    }
    $btn = t('Create global profile');
  }
  else {
    $form['old_name'] = array(
      '#type' => 'hidden',
      '#value' => $edit->name,
    );
    $btn = t('Update global profile');
  }
  $form['common'] = array(
    '#type' => 'fieldset',
    '#title' => t('Main setup'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $roles = fckeditor_sorted_roles();
  $rids = $rtext = array();
  foreach ($roles as $rid => $name) {
    $rids[] = $rid;
    $rtext[] = '<strong>' . $rid . ' - </strong>' . $name;
  }
  $form['common']['rank'] = array(
    '#type' => 'textfield',
    '#title' => t('Role precedence'),
    '#default_value' => implode('>', $rids),
    '#description' => t('A user having <strong>multiple roles</strong> gets the permissions of the highest one. Sort role IDs according to their <strong>precedence from higher to lower</strong> by putting > in between.<br />'),
  );
  if ($rids) {
    $form['common']['rank']['#description'] .= t('Here is the id-name pairs of roles having access to FCKeditor:') . '<div>' . implode('<br />', $rtext) . '</div>';
  }
  else {
    $form['common']['rank']['#description'] .= t('You haven\'t assigned the <code>!access1</code> !permissions yet.', array(
      '!access1' => t('access fckeditor'),
      '!permissions' => l(t('permissions'), 'admin/user/permissions'),
    ));
  }
  $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 specific profile.'),
  );
  $form['fckeditor_exclude_settings']['excl_mode'] = array(
    '#type' => 'select',
    '#title' => t('Use inclusion or exclusion mode'),
    '#default_value' => empty($edit->settings['excl_mode']) || 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' => !empty($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' => !empty($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,
    '#default_value' => !empty($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,
    '#default_value' => !empty($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,
    )),
  );
  if (variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE) {
    $form['fckeditor_advanced_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $current_private_dir = !isset($edit->settings['private_dir']) ? "" : $edit->settings['private_dir'];
    $form['fckeditor_advanced_settings']['private_dir'] = array(
      '#type' => 'textfield',
      '#title' => t('Location of files uploaded with FCKeditor in the private folder'),
      '#default_value' => $current_private_dir,
      '#size' => 40,
      '#maxlength' => 255,
      '#description' => t('The path relative to the location of the private directory where FCKeditor should store uploaded files.') . '<br />' . t('<strong>Warning:</strong> FCKeditor does not implement any kind of access protection on files available in this location. All files stored in the directory defined above might be accessible by unauthenticated users if there is no information about the file in the Drupal\'s database.') . '<br />' . t('System path to the private folder is: !system_path.', array(
        '!system_path' => realpath(file_directory_path()) . DIRECTORY_SEPARATOR,
      )) . '<br />' . t('Available wildcard characters:<br /><strong>%u</strong> - User ID.') . '<br />' . t('Current path: !path', array(
        '!path' => $current_private_dir . ' (' . file_create_path($current_private_dir) . ')',
      )),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $btn,
  );
  return $form;
}