You are here

function quotes_author_form in Quotes 7

Same name and namespace in other branches
  1. 5 quotes.module \quotes_author_form()
  2. 6 quotes.module \quotes_author_form()

Form to select an author.

1 string reference to 'quotes_author_form'
quotes_author in ./quotes.module
Menu callback that selects quotes based on author.

File

./quotes.module, line 2138
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_author_form($form, $form_state) {
  $form = array();
  $max_name_length = 78;
  $authors = quotes_get_authors();
  if (!is_array($authors) || empty($authors)) {
    form_set_error('body', t('No Authors Found'));
    return $form;
  }
  $author_names = array();
  foreach ($authors as $aid => $name) {

    // Limit the length.
    if (drupal_strlen($name) > $max_name_length) {
      $name = drupal_substr($name, 0, $max_name_length - 3) . '...';
    }

    // TODO - check why when we check_plain $name ',",etc. get stripped
    // use filter_xss for now.
    $author_names[$aid] = filter_xss($name);
  }
  $form['author'] = array(
    '#type' => 'select',
    '#options' => $author_names,
    '#size' => min(20, count($authors)),
    '#description' => t('Choose an author from the list.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Select'),
  );
  return $form;
}