You are here

function bueditor_editor_form in BUEditor 6

Same name and namespace in other branches
  1. 6.2 admin/bueditor.admin.inc \bueditor_editor_form()
  2. 7 admin/bueditor.admin.inc \bueditor_editor_form()

Editor form.

1 string reference to 'bueditor_editor_form'
bueditor_menu in ./bueditor.module
Implementation of hook_menu().

File

./bueditor.admin.inc, line 177

Code

function bueditor_editor_form($form_state, $editor = NULL) {
  $editor = (object) ($editor ? $editor : array(
    'eid' => '',
    'name' => '',
    'pages' => "node/*\ncomment/*",
    'excludes' => 'edit-log',
    'iconpath' => '%BUEDITOR/icons',
    'librarypath' => '%BUEDITOR/library',
  ));
  $form = array(
    '#cache' => TRUE,
    '#tree' => TRUE,
    '#theme' => 'bueditor_editor',
    '#attributes' => array(
      'enctype' => 'multipart/form-data',
    ),
  );
  $form['editor']['eid'] = array(
    '#type' => 'hidden',
    '#value' => $editor->eid,
  );
  $form['editor']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Editor name'),
    '#maxlength' => 255,
    '#default_value' => $editor->name,
    '#required' => TRUE,
  );
  $form['editor']['pages'] = array(
    '#type' => 'textarea',
    '#title' => t('Show the editor on specific pages'),
    '#default_value' => $editor->pages,
    '#description' => t('Enter one page per line as Drupal paths. The * character is a wildcard.'),
  );
  $form['editor']['excludes'] = array(
    '#type' => 'textarea',
    '#title' => t('Hide the editor for specific textareas'),
    '#default_value' => $editor->excludes,
    '#description' => t('Enter one textarea ID per line. The * character is a wildcard.'),
  );
  $form['editor']['iconpath'] = array(
    '#type' => 'textfield',
    '#title' => t('Directory of editor icons'),
    '#maxlength' => 255,
    '#default_value' => $editor->iconpath,
    '#description' => t('Web accessible directory path where editor icons reside.') . ' ' . t('Placeholders that you can use are; %BUEDITOR (bueditor path), %FILES (drupal files path), and %THEME (current theme\'s path).'),
  );
  $form['editor']['librarypath'] = array(
    '#type' => 'textfield',
    '#title' => t('Directory of editor library'),
    '#maxlength' => 255,
    '#default_value' => $editor->librarypath,
    '#description' => t('Web accessible directory path where external javascript files reside.') . ' ' . t('Placeholders that you can use are; %BUEDITOR (bueditor path), %FILES (drupal files path), and %THEME (current theme\'s path).'),
  );

  //buttons
  $icons = bueditor_icons(bueditor_path_tr($form['editor']['iconpath']['#default_value']));
  foreach (bueditor_buttons($editor->eid) as $bid => $button) {
    $form['buttons'][$bid] = bueditor_button_form($button, $icons);
    $form['checks'][$bid] = array(
      '#type' => 'checkbox',
    );
  }

  //imported buttons are previewed. not saved yet.
  if (isset($_SESSION['buecsv']) && ($csvpath = $_SESSION['buecsv'])) {
    $import = bueditor_import_buttons($csvpath);
    for ($i = 0; $button = $import[$i]; $i++) {
      $form['buttons']['new' . $i] = bueditor_button_form($button, $icons);
    }
    drupal_set_message($i > 0 ? t('New buttons are ready to be saved.') : t('There is no button to be imported.'));
    unset($_SESSION['buecsv']);
  }

  //there is always a new button.
  $form['buttons']['new'] = bueditor_button_form(NULL, $icons);

  //action for selected buttons
  $form['selaction'] = array(
    '#type' => 'select',
    '#options' => array(
      '' => t('... selecteds'),
      'delete' => t('Delete'),
      'export' => t('Export'),
    ),
  );
  $form['go'] = array(
    '#type' => 'submit',
    '#value' => t('Go'),
    '#submit' => array(
      'bueditor_selaction_submit',
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
    '#submit' => array(
      'bueditor_editor_submit',
    ),
  );
  $form['buecsv'] = array(
    '#type' => 'file',
    '#title' => t('CSV file containing the buttons'),
  );
  $form['import'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
    '#submit' => array(
      'bueditor_csv_submit',
    ),
  );
  return $form;
}