You are here

function quotes_author_form in Quotes 6

Same name and namespace in other branches
  1. 5 quotes.module \quotes_author_form()
  2. 7 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 1518
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 = array();
  $max_name_length = 78;
  $authors = quotes_get_authors();
  $author_names = array();
  foreach ($authors as $aid => $name) {

    // Make it safe to display (with no HTML).
    $name = filter_xss($name, array());

    // Limit the length.
    if (drupal_strlen($name) > $max_name_length) {
      $name = drupal_substr($name, 0, $max_name_length - 3) . '...';
    }
    $author_names[$aid] = $name;
  }
  $form['author'] = array(
    '#type' => 'select',
    '#options' => $author_names,
    '#size' => min(25, count($authors)),
    '#description' => t('Choose an author from the list.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Select'),
  );
  return $form;
}