You are here

function quotes_bios in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.admin.inc \quotes_bios()
  2. 7 quotes.admin.inc \quotes_bios()

Bios maintenance page.

Return value

A form with a tab-delimited list of quotes.

1 string reference to 'quotes_bios'
quotes_menu in ./quotes.module
Implementation of hook_menu().

File

./quotes.module, line 1723

Code

function quotes_bios($aid = NULL) {
  $form = array();
  $first_pass = is_null($aid);
  if ($first_pass) {
    $auths = quotes_get_authors();
    $count = count($auths);
    $data = array(
      'name' => NULL,
      'bio' => NULL,
    );
  }
  else {

    // Get the data.
    $data = db_fetch_array(db_query("SELECT * FROM {quotes_authors} WHERE aid=%d", $aid));
  }
  $form['aid'] = array(
    '#type' => 'hidden',
    '#value' => $aid,
  );
  $form['author'] = array(
    '#type' => 'select',
    '#options' => $auths,
    '#size' => min(20, $count),
    '#description' => t('Pick the author whose biography you wish to update.'),
  );
  $form['name'] = array(
    '#type' => 'markup',
    '#value' => '<h3>' . t('Biography for %name', array(
      '%name' => $data['name'],
    )) . '</h3>',
  );
  $form['bio'] = array(
    '#type' => 'textarea',
    '#description' => t("This is the author's biography."),
    '#default_value' => $data['bio'],
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $first_pass ? t('Get biography') : t('Update'),
  );

  // Show the fields at the right time.
  if ($first_pass) {
    $form['name']['#type'] = 'hidden';
    $form['bio']['#type'] = 'hidden';
  }
  else {
    $form['author']['#type'] = 'hidden';
  }
  return $form;
}