diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 238bd48..2761365 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -153,6 +153,11 @@ All the variable parts of bibtexbrowser can be modified with a file called ''bib // disable Javascript progressive enhancement // define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',false); +// may be default/year/x-abbrv +// default => [1] The essence of metamodeling +// year => [2005] The essence of metamodeling +// x-abbrv => [SoSyM] The essence of metamodeling if the bibtex entry contains a field x-abbrv +//define('ABBRV_TYPE','default'); // see the other define(...) in the source, they are all overridable @@ -268,6 +273,8 @@ define('BIBTEXBROWSER','v__MTIME__'); // the target frame of menu links @define('BIBTEXBROWSER_MENU_TARGET','main'); // might be define('BIBTEXBROWSER_MENU_TARGET','_self'); in bibtexbrowser.local.php +@define('ABBRV_TYPE','default');// may be default/year/x-abbrv + @define('COMMA_NAMES',false);// do have authors in a comma separated form? @define('TYPES_SIZE',10); // number of entry types per table @define('YEAR_SIZE',20); // number of years per table @@ -751,7 +758,7 @@ class BibDBBuilder { function setEntryKey($entrykey) { //echo "new entry:".$entrykey."\n"; - $this->currentEntry->setField('key',$entrykey); + $this->currentEntry->setKey($entrykey); } function beginEntry() { @@ -927,8 +934,6 @@ class BibEntry { /** Creates an empty new bib entry. Each bib entry is assigned a unique * identification number. */ function BibEntry() { - static $id = 0; - $this->id = $id++; $this->fields = array(); $this->constants = array(); $this->text =''; @@ -940,6 +945,13 @@ class BibEntry { return strtolower($this->getField(Q_TYPE)); } + /** Sets the key of this bib entry. */ + function setKey($value) { + $this->setField('key',$value); + // by default the ID is the key + $this->id = $value; + } + /** Sets a field of this bib entry. */ function setField($name, $value) { $name = strtolower($name); @@ -1207,6 +1219,25 @@ class BibEntry { function getId() { return $this->id; } + + /** Returns the abbreviation. */ + function getAbbrv() { + if (ABBRV_TYPE == 'default') return $this->id; + if (ABBRV_TYPE == 'year') return $this->getYear(); + if (ABBRV_TYPE == 'x-abbrv') { + if ($this->hasField('x-abbrv')) {return $this->getField('x-abbrv');} + // otherwise + return $this->getKey(); + } + + throw new Exception('Unknown configuration value for ABBRV_TYPE'); + } + + + /** Sets the abbreviation (e.g. [OOPSLA] or [1]) */ + function setAbbrv($abbrv) { + return $this->id = $abbrv; + } function getText() { /** Returns the verbatim text of this bib entry. */ @@ -1242,7 +1273,7 @@ class BibEntry { */ function toTR() { echo '