You are here

function bueditor_form_editor in BUEditor 5

Editor form.

1 string reference to 'bueditor_form_editor'
bueditor_get_form_editor in ./bueditor.module
Editor form processed.

File

./bueditor.module, line 157

Code

function bueditor_form_editor() {
  $editors = bueditor_editors('all');
  $new = ($eid = arg(3)) == 'new';
  $editor = $editors[$eid];
  $form = array(
    '#tree' => TRUE,
    '#attributes' => array(
      'enctype' => 'multipart/form-data',
    ),
  );
  $form['editor']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Editor name'),
    '#default_value' => $editor->name,
    '#required' => TRUE,
  );
  $form['editor']['pages'] = array(
    '#type' => 'textarea',
    '#title' => t('Show the editor on specific pages'),
    '#default_value' => $new ? "node/add/*\nnode/*/edit\ncomment/reply/*" : $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' => $new ? 'edit-log' : $editor->excludes,
    '#description' => t('Enter one textarea ID per line. The * character is a wildcard.'),
  );
  $form['editor']['eid'] = array(
    '#type' => 'hidden',
    '#value' => $eid,
  );

  //buttons
  foreach (bueditor_buttons($eid) as $bid => $button) {
    $form['button'][$bid] = bueditor_form_button($button);
    $form['checks'][$bid] = array(
      '#type' => 'checkbox',
    );
  }

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

  //there is always a new button form.
  $form['button']['new'] = bueditor_form_button();

  //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'),
    '#id' => 'edit-go',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['buecsv'] = array(
    '#type' => 'file',
    '#title' => t('CSV file containing the buttons'),
  );
  $form['import'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
  );
  return $form;
}