From 10c1978ccb923e978811f10e7fc6ada983070099 Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Wed, 1 Sep 2010 00:52:51 +0200 Subject: [PATCH] now under version control --- bibtexbrowser-style-default.php | 115 ++++++++++++++++++++++++++++++++ bibtexbrowser-style-janos.php | 109 ++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 bibtexbrowser-style-default.php create mode 100755 bibtexbrowser-style-janos.php diff --git a/bibtexbrowser-style-default.php b/bibtexbrowser-style-default.php new file mode 100644 index 0000000..400c743 --- /dev/null +++ b/bibtexbrowser-style-default.php @@ -0,0 +1,115 @@ +getTitle(); + $type = $bibentry->getType(); + + // later on, all values of $entry will be joined by a comma + $entry=array(); + + // title + // usually in bold: .bibtitle { font-weight:bold; } + $title = ''.$title.''; + if ($bibentry->hasField('url')) $title = ' '.$title.''; + + + // author + if ($bibentry->hasField('author')) { + $coreInfo = $title . ' ('.$bibentry->formattedAuthors().')';} + else $coreInfo = $title; + + // core info usually contains title + author + $entry[] = $coreInfo; + + // now the book title + $booktitle = ''; + if ($type=="inproceedings") { + $booktitle = 'In '.$bibentry->getField(BOOKTITLE); } + if ($type=="incollection") { + $booktitle = 'Chapter in '.$bibentry->getField(BOOKTITLE);} + if ($type=="inbook") { + $booktitle = 'Chapter in '.$bibentry->getField('chapter');} + if ($type=="article") { + $booktitle = 'In '.$bibentry->getField("journal");} + if (($type=="misc") && $bibentry->hasField("note")) { + $booktitle = $bibentry->getField("note");} + + //// we may add the editor names to the booktitle + $editor=''; + if ($bibentry->hasField(EDITOR)) { + $editors = array(); + foreach ($bibentry->getEditors() as $ed) { + $editors[]=formatAuthor($ed); + } + $editor = implode(', ',$editors).', '.(count($editors)>1?'eds.':'ed.'); + } + if ($editor!='') $booktitle .=' ('.$editor.')'; + // end editor section + + // is the booktitle available + if ($booktitle!='') { + $entry[] = ''.$booktitle.''; + } + + + $publisher=''; + if ($type=="phdthesis") { + $publisher = 'PhD thesis, '.$bibentry->getField(SCHOOL); + } + if ($type=="mastersthesis") { + $publisher = 'Master\'s thesis, '.$bibentry->getField(SCHOOL); + } + if ($type=="bachelorsthesis") { + $publisher = 'Bachelor\'s thesis, '.$bibentry->getField(SCHOOL); + } + if ($type=="techreport") { + $publisher = 'Technical report, '.$bibentry->getField("institution"); + } + + if ($type=="misc") { + $publisher = $bibentry->getField('howpublished'); + } + + if ($bibentry->hasField("publisher")) { + $publisher = $bibentry->getField("publisher"); + } + + if ($publisher!='') $entry[] = ''.$publisher.''; + + + if ($bibentry->hasField('volume')) $entry[] = "volume ".$bibentry->getField("volume"); + + + if ($bibentry->hasField(YEAR)) $entry[] = $bibentry->getYear(); + + $result = implode(", ",$entry).'.'; + + // some comments (e.g. acceptance rate)? + if ($bibentry->hasField('comment')) { + $result .= " (".$bibentry->getField("comment").")"; + } + if ($bibentry->hasField('note')) { + $result .= " (".$bibentry->getField("note").")"; + } + + // add the Coin URL + $result .= "\n".$bibentry->toCoins(); + + return $result; +} + + +?> \ No newline at end of file diff --git a/bibtexbrowser-style-janos.php b/bibtexbrowser-style-janos.php new file mode 100755 index 0000000..ac8a678 --- /dev/null +++ b/bibtexbrowser-style-janos.php @@ -0,0 +1,109 @@ + +include( 'bibtexbrowser-style-janos.php' ); +define('BIBLIOGRAPHYSTYLE','JanosBibliographyStyle'); + + +[[http://www.monperrus.net/martin/bibtexbrowser-style-janos.php.txt]] + +*/ +function JanosBibliographyStyle(&$bibentry) { + $title = $bibentry->getTitle(); + $type = $bibentry->getType(); + + $entry=array(); + + // author + if ($bibentry->hasField('author')) { + $entry[] = $bibentry->formattedAuthors(); + } + + // title + $title = '"'.$title.'"'; + if ($bibentry->hasField('url')) $title = ' '.$title.''; + $entry[] = $title; + + + // now the origin of the publication is in italic + $booktitle = ''; + + if (($type=="misc") && $bibentry->hasField("note")) { + $booktitle = $bibentry->getField("note"); + } + + if ($type=="inproceedings") { + $booktitle = 'In '.$bibentry->getField(BOOKTITLE); + } + + if ($type=="incollection") { + $booktitle = 'Chapter in '.$bibentry->getField(BOOKTITLE); + } + + if ($type=="article") { + $booktitle = 'In '.$bibentry->getField("journal"); + } + + + + //// ******* EDITOR + $editor=''; + if ($bibentry->hasField(EDITOR)) { + $editors = array(); + foreach ($bibentry->getEditors() as $ed) { + $editors[]=formatAuthor($ed); + } + $editor = implode(', ',$editors).', '.(count($editors)>1?'eds.':'ed.'); + } + + if ($booktitle!='') { + if ($editor!='') $booktitle .=' ('.$editor.')'; + $entry[] = ''.$booktitle.''; + } + + + $publisher=''; + if ($type=="phdthesis") { + $publisher = 'PhD thesis, '.$bibentry->getField(SCHOOL); + } + + if ($type=="mastersthesis") { + $publisher = 'Master\'s thesis, '.$bibentry->getField(SCHOOL); + } + if ($type=="techreport") { + $publisher = 'Technical report, '.$bibentry->getField("institution"); + } + if ($bibentry->hasField("publisher")) { + $publisher = $bibentry->getField("publisher"); + } + + if ($publisher!='') $entry[] = $publisher; + + if ($bibentry->hasField('volume')) $entry[] = "vol. ".$bibentry->getField("volume"); + if ($bibentry->hasField('number')) $entry[] = 'no. '.$bibentry->getField("number"); + + if ($bibentry->hasField('address')) $entry[] = $bibentry->getField("address"); + + if ($bibentry->hasField('pages')) $entry[] = str_replace("--", "-", "pp. ".$bibentry->getField("pages")); + + + if ($bibentry->hasField(YEAR)) $entry[] = $bibentry->getYear(); + + $result = implode(", ",$entry).'.'; + + // some comments (e.g. acceptance rate)? + if ($bibentry->hasField('comment')) { + $result .= " (".$bibentry->getField("comment").")"; + } + + // add the Coin URL + $result .= "\n".$bibentry->toCoins(); + + return $result; +} + +?> \ No newline at end of file