You are here

function biblio_update_author_index in Bibliography Module 5

File

./biblio.module, line 3121

Code

function biblio_update_author_index() {
  global $biblio_last_nid;

  //register_shutdown_function('biblio_author_index_shutdown');
  $biblio_last_nid = variable_get('biblio_ai_last_nid', 0);
  $biblio_max_count = variable_get('biblio_ai_max_count', 100);
  $count = 0;
  $result = db_query("SELECT nid, biblio_authors FROM {biblio} WHERE nid > %d", $biblio_last_nid);
  while (($row = db_fetch_object($result)) && $count < $biblio_max_count) {
    $author_array = explode(";", $row->biblio_authors);
    $rank = 0;
    foreach ($author_array as $auth) {
      $rank++;
      if (strstr($auth, ",")) {
        $parts = split(",", $auth);
        $lastname = $parts[0];
      }
      else {
        $parts = split(" ", $auth);
        $lastname = end($parts);
      }
      _biblio_author_index_insert($row->nid, $lastname, $rank);
      $biblio_last_nid = $row->nid;
    }
    $count++;
  }
  variable_set('biblio_ai_last_nid', $biblio_last_nid);
  return;
}