You are here

function biblio_form_get_contributors in Bibliography Module 7.2

Get an array of contributors that were submitted from the biblio add form

Parameters

array $form The full form array:

Return value

array an iterative array of contributors, sorted by rank

File

./biblio.module, line 3110

Code

function biblio_form_get_contributors($form) {
  $i = 0;
  foreach ($form['biblio_tabs']['contributors']['biblio_contributors'] as $key => $value) {

    // Contributors are keyed by a standard numeric iteration, but are mixed
    // in with other form array values.
    if (is_numeric($key)) {

      // Get the name that the user entered in the name field
      $name_value = $value['name']['#value'];

      // If user didn't set rankings for the contributors, the value defaults
      // to an empty string
      $rank_value = $value['rank']['#value'] == '' ? $i : $value['rank']['#value'];

      // Name fields left blank are empty strings
      if (isset($name_value) && $name_value != '') {
        $contributors[$rank_value] = $name_value;
        $i++;
      }
    }
  }

  // Sort contributors in order of rank
  ksort($contributors);
  return $contributors;
}