You are here

function biblio_citekey_generate in Bibliography Module 7.2

Same name and namespace in other branches
  1. 5 biblio.module \biblio_citekey_generate()
  2. 6.2 biblio.module \biblio_citekey_generate()
  3. 6 biblio.module \biblio_citekey_generate()
  4. 7 biblio.module \biblio_citekey_generate()

Generates automated citation keys

Parameters

object $biblio:

Return value

string The citation key data

1 call to biblio_citekey_generate()
_biblio_prepare_submit in ./biblio.module
Prepare a biblio for submit to database. Contains code common to insert and update.

File

./biblio.module, line 1807

Code

function biblio_citekey_generate($biblio) {
  $php = check_plain(variable_get('biblio_citekey_phpcode', ''));
  if (empty($php)) {
    $prefix = variable_get('biblio_citekey_prefix', '');
    $primary_field = variable_get('biblio_citekey_field1', 'nid');
    $secondary_field = variable_get('biblio_citekey_field2', 'nid');
    $citekey = !empty($biblio->{$primary_field}) ? $biblio->{$primary_field} : (!empty($biblio->{$secondary_field}) ? $biblio->{$secondary_field} : $biblio->bid);
    return check_plain($prefix . $citekey);
  }
  else {
    ob_start();
    $return = eval($php);
    ob_end_clean();
    return check_plain(strip_tags((string) $return));
  }
}