You are here

function quotes_form in Quotes 7

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

Implements hook_form().

File

./quotes.module, line 663
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_form($node, $form_state) {
  $form = array(
    'quotes_data' => array(),
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#required' => FALSE,
    '#default_value' => isset($node->title) ? $node->title : '',
    '#description' => t("Enter the title for the quote(s). If you include the variable %id, it will be replaced by the new quote's ID."),
  );

  // Set default value, php 5.3 does not like undefined properties, .
  $quotes_import_format = 'single';
  if (user_access('import quotes')) {
    $form['quotes_import_format'] = array(
      '#type' => 'radios',
      '#title' => t('Format'),
      '#required' => TRUE,
      '#default_value' => $quotes_import_format,
      '#options' => array(
        'single' => t('Single quote.'),
        'text' => t('Import tab-separated text.'),
        'fortune' => t('Import Fortune file.'),
      ),
    );
  }
  else {
    $form['quotes_import_format'] = array(
      '#type' => 'value',
      '#value' => 'single',
    );
  }
  if (user_access('import quotes')) {
    $form['quotes']['body_field']['#description'] = t('Enter the text of the quote or the group of quotes to be imported. It will be filtered according to the input format. Note: The "Split summary" button cannot be used when importing a group of quotes.');
    $no_import = ' ' . t('This should not be used when importing.');
  }
  else {
    $form['quotes']['body_field']['#description'] = t('Enter the text of the quote. It will be filtered according to the input format.');
    $no_import = NULL;
  }

  // Push input format down below weight.
  $form['quotes']['format']['#weight'] = 1;
  $author = '';
  if (isset($node->quotes_author)) {
    $author = $node->quotes_author;
  }
  $form['quotes']['quotes_author'] = array(
    '#type' => 'textfield',
    '#title' => t('Author'),
    '#autocomplete_path' => 'quotes/autocomplete/author',
    '#rows' => 1,
    '#maxlength' => 254,
    '#default_value' => $author,
    '#description' => check_plain(t('This is who is credited for the quotation.') . $no_import),
  );
  $citation = '';
  if (isset($node->quotes_citation)) {
    $citation = $node->quotes_citation;
  }
  $form['quotes']['quotes_citation'] = array(
    '#type' => 'textfield',
    '#title' => t('Citation'),
    '#autocomplete_path' => 'quotes/autocomplete/citation',
    '#rows' => 1,
    '#maxlength' => 1023,
    '#default_value' => $citation,
    '#description' => check_plain(t('This is the source (book, magazine, etc.) of the quote.') . $no_import),
  );
  if (user_access('promote quotes to block')) {
    $form['quotes']['quotes_promote'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display in quote blocks'),
      '#default_value' => isset($node->quotes_promote) ? $node->quotes_promote : 1,
      '#description' => t('This option allows you to decide whether this quote will be displayable in the blocks.'),
    );
  }
  return $form;
}