Adding LTER site field to biblio bibtex output and fixing thesis export

In preparing a bibtex export of publications for the 40th LTER anniversity review the export needs to include in the keywords - LTER-XXX, where XXX=  three-letter site acronym.

UPDATE #2:

So now we are not adding the ltersite field but we will need to add LTER-XXX as a keyword.  So a simple wayis to:

In file .../profiles/deims/modules/contrib/biblio/modules/bibtexParse/biblio_bibtex.module after:
  $kw_array = array();
Add:
  $kw_array[] = 'LTER-'.token_replace('[site:station-acronym]');
 

Note this will add it to a bibtex export only.

Another refinement:

citekey is use for the bibtex export as the id.  In the biblo settings it is set to node ID.  It can be changed to another field but the change will on be for new or updated entries.  One trick is to use VBO to update all the biblio nodes by selecting  change value, status and then next without changing the status and all the nodes will be updated but with no changes other then the new citekey will be generated.

UPDATE: After searching and looking at the biblio module I found 2  3 ways to accumblish this. And I would guess that below is the best way.

1. An even simpler way to add ltersite and a fix to the export of thesis

Fisrt:  a simple less site specfic way of adding ltersite which will work for any DEIMS site:
In file .../profiles/deims/modules/contrib/biblio/modules/bibtexParse/biblio_bibtex.module line 365  add

  $bibtex .= _biblio_bibtex_format_entry('ltersite',  'NSF-LTER-'.token_replace('[site:station-acronym]'));

Second: a fix for how theses are exported.  In bibtex there are two types of thesis - @mastersthesis and @phpthesis.  Although I see references to using @thesis.  (For the ARC and PIE site we also have BS honors thesis). In the biblio_bibtex.module there is a bug in how thesis records are exported.
In function _biblio_bibtex_export($node) for case 108 (the number biblio uses for type "thesis") the code

if (stripos($node->biblio_type_of_work, 'masters')) {
        $type = "mastersthesis";
      }

will evaluate to 0 (i.e. false) for biblio_type_of_work = 'masters' since stripos function is zero base and will find 'masters' in the first position hence 0. See stripos()  Following is the how I modified the code (line 330) to fix this and to add in checks for PhD theses. Anything else will get @thesis:

      if (stripos($node->biblio_type_of_work, 'masters')!== false) {
        $type = "mastersthesis";
      } elseif (stripos($node->biblio_type_of_work, 'ph')!== false)     {
        $type = "phdthesis";
      } else {
         $type = "thesis";
      }

We will need to go through our biblo thesis records to make sure that "Thesis Type" contains "masters" for any Masters of Science or Arts and "ph" for any PhD theses. Note that stripos() is not case sensitive.
I will  general a patch file later once it has been tested on more sites.
 

2. Simple way - adding code into the biblo module .../profiles/deims/modules/contrib/biblio/modules/bibtexParse  line 365 add .= _biblio_bibtex_format_entry('ltersite','NFS-LTER-ARC');   This of course is for the Arctic LTER.

3. More of a drupal way by adding a field to the biblo content that uses the token for the site acronym.  Below are screen shots of the added field and how to modified the biblio module

Adding a token field to the Biblo module.

And the Token value: NSF-LTER-[site:station-acronym]

Code to add to the biblo module .../profiles/deims/modules/contrib/biblio/modules/bibtexParse 

After Line 364 - .= _biblio_bibtex_format_entry('abstract', ->biblio_abst_e);

Add:  .= _biblio_bibtex_format_entry('ltersite', ->field_ltersite['und'][0]['value_token_filtered']);