You are here

function quotes_form in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.node.inc \quotes_form()
  2. 6 quotes.module \quotes_form()
  3. 7 quotes.node.inc \quotes_form()
  4. 7 quotes.module \quotes_form()

Implementation of hook_form().

File

./quotes.module, line 261

Code

function quotes_form(&$node, &$param) {
  global $_quotes_importing;
  $form = array(
    'quotes_data' => array(),
  );
  if ($_quotes_importing || arg(3) != 'import') {
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => FALSE,
      '#default_value' => $node->title,
      '#description' => t('Enter the title for this quote. If you include the variable %id, it will be replaced by the newly created quote\'s node ID.', array(
        '%id' => '%id',
      )),
      '#weight' => -10,
    );
    $form['quotes_data']['body'] = array(
      '#type' => 'textarea',
      '#title' => t('Quote'),
      '#required' => TRUE,
      '#default_value' => $node->body,
    );
    $form['quotes_data']['quotes_author'] = array(
      '#type' => 'textfield',
      '#title' => t('Author'),
      '#autocomplete_path' => 'quotes/autocomplete/author',
      '#rows' => 1,
      '#maxlength' => 1023,
      '#default_value' => $node->quotes_author,
    );
    $form['quotes_data']['quotes_citation'] = array(
      '#type' => 'textfield',
      '#title' => t('Citation'),
      '#autocomplete_path' => 'quotes/autocomplete/citation',
      '#rows' => 1,
      '#default_value' => $node->quotes_citation,
    );
  }
  else {
    if (!user_access('import quotes')) {
      drupal_access_denied();
    }
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => FALSE,
      '#default_value' => $node->title,
      '#description' => t('Enter the title that will be used for all imported quotes. If you include the variable %id, it will be replaced by the newly created quote\'s node ID.', array(
        '%id' => '%id',
      )),
      '#weight' => -10,
    );
    $form['quotes_data']['quotes_format'] = array(
      '#type' => 'radios',
      '#title' => t('Format'),
      '#required' => TRUE,
      '#default_value' => $node->quotes_format ? $node->quotes_format : 'text',
      '#options' => array(
        'text' => t('Tab-separated text'),
        'fortune' => t('Fortune file'),
      ),
    );
    $form['quotes_data']['body'] = array(
      '#type' => 'textarea',
      '#title' => t('Quotes'),
      '#required' => TRUE,
      '#rows' => 20,
      '#default_value' => $node->body,
    );
  }
  if (user_access('promote quotes to block')) {
    $form['quotes_data']['quotes_promote'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display in quote blocks'),
      '#default_value' => isset($node->quotes_promote) ? $node->quotes_promote : 1,
    );
  }
  $form['quotes_data']['filter'] = filter_form($node->format);
  return $form;
}