You are here

function quotes_bios in Quotes 7

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

Bios maintenance page.

Parameters

array $form: The form that was submitted.

array $form_state: The array specifying the form values.

int $aid: The author Id of the bio.

Return value

array A form with a tab-delimited list of quotes.

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

File

./quotes.admin.inc, line 480
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_bios($form, &$form_state, $aid = NULL) {
  $form = array();
  $first_pass = is_null($aid);
  global $_quotes_auths;
  if ($first_pass) {
    $_quotes_auths = quotes_get_authors();
    $data = array(
      'name' => NULL,
      'bio' => NULL,
    );
  }
  else {

    // Get the data.
    $data = db_select('quotes_authors', 'qa')
      ->fields('qa')
      ->condition('qa.aid', $aid)
      ->execute()
      ->fetchAssoc();
  }
  $count = count($_quotes_auths);
  $form['aid'] = array(
    '#type' => 'hidden',
    '#value' => $aid,
  );
  $form['author'] = array(
    '#type' => 'select',
    '#options' => $_quotes_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 %name's biography.", array(
      '%name' => $data['name'],
    )),
    '#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;
}