You are here

function biblio_citekey_generate in Bibliography Module 6

Same name and namespace in other branches
  1. 5 biblio.module \biblio_citekey_generate()
  2. 6.2 biblio.module \biblio_citekey_generate()
  3. 7 biblio.module \biblio_citekey_generate()
  4. 7.2 biblio.module \biblio_citekey_generate()
1 call to biblio_citekey_generate()
_biblio_prepare_submit in ./biblio.module
Prepare a node for submit to database. Contains code common to insert and update.

File

./biblio.module, line 1755

Code

function biblio_citekey_generate($node) {
  $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($node->{$primary_field}) ? $node->{$primary_field} : (!empty($node->{$secondary_field}) ? $node->{$secondary_field} : $node->nid);
    return check_plain($prefix . $citekey);
  }
  else {
    ob_start();
    $return = eval($php);
    ob_end_clean();
    return check_plain(strip_tags((string) $return));
  }
}