diff --git a/bibtexbrowser.local.php b/bibtexbrowser.local.php new file mode 100644 index 0000000..d949c64 --- /dev/null +++ b/bibtexbrowser.local.php @@ -0,0 +1,279 @@ +getTitle(); + $type = $bibentry->getType(); + + // later on, all values of $entry will be joined by a comma + $entry=array(); + + + // thumbnail + if (USEBIBTHUMBNAIL && $bibentry->hasField(BIBTHUMBNAIL)) { + $thumb = '';} + else $thumb = ''; + + // title + // usually in bold: .bibtitle { font-weight:bold; } + $title = ''.$title.'
'."\n"; + if ($bibentry->hasField('url')) $title = ''.$title.''; + + + // author + if ($bibentry->hasField('author')) { + $coreInfo = $title . ''.$bibentry->getFormattedAuthorsImproved().'';} + else $coreInfo = $title; + + // core info usually contains title + author + $entry[] = $thumb.$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");} + + //// we may add the editor names to the booktitle + $editor=''; + if ($bibentry->hasField(EDITOR)) { + $editor = $bibentry->getFormattedEditors(); + } + 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(); + $result .= "
\n"; + + // we add biburl and title to be able to retrieve this important information + // using Xpath expressions on the XHTML source + $result .= $bibentry->getBibLink(); + // returns an empty string if no pdf present + $result .= $bibentry->getLink('pdf'); + // returns an empty string if no url present + $result .= $bibentry->getLink('url'); + // returns an empty string if no slides present + $result .= $bibentry->getLink('slides'); + // returns an empty string if no poster present + $result .= $bibentry->getLink('poster'); + // Google Scholar ID. empty string if no gsid present + $result .= $bibentry->getGSLink(); + // returns an empty string if no doi present + $result .= $bibentry->getDoiLink(); + + $result .= '
'; + + return $result; +} + +/** Class to display a bibliography of a page. */ +class BibliographyDisplay { + /** the bib entries to display. */ + var $result; + + /** the content strategy (cf. pattern strategy) */ + var $contentStrategy; + + /** the query to reinject in links to different pages */ + var $filter; + + /** Creates an instance with the given entries and header. */ + function BibliographyDisplay(&$result, $filter) { + $this->result = $result; + $this->filter = $filter; + // requesting a different page of the result view? + $this->setTitle(); + $this->contentStrategy = new BibliographyContentStrategy(); + } + + /** sets the $this->title of BibtexBrowserDisplay based on the $filter */ + function setTitle() { + $this->title = query2title($this->filter); + } + + /** overrides */ + function formatedHeader() { return '
'.$this->title.' '.createRSSLink($this->filter).'
';} + + /** overrides */ + function getURL() { return '?'.createQueryString($this->filter);} + + /** overrides */ + function getRSS() { return BIBTEXBROWSER_URL.'?'.createQueryString($this->filter).'&rss';} + + /** Displays the entries preceded with the header. */ + function display() { + // print error message if no entry. + if (empty($this->result)) { + echo "No references.\n"; + return; + } + $this->contentStrategy->display($this); + echo $this->poweredby(); + if (BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT) { + $this->javascript(); + } + } + + + function poweredby() { + $poweredby = "\n".'
'; + $poweredby .= ''; + $poweredby .= 'Powered by bibtexbrowser'; + $poweredby .= '
'."\n"; + return $poweredby; + } + + /** Adds a touch of AJAX in bibtexbrowser to display bibtex entries inline. + * It uses the HIJAX design pattern: the Javascript code fetches the normal bibtex HTML page + * and extracts the bibtex. + * In other terms, URLs and content are left perfectly optimized for crawlers + * Note how beautiful is this piece of code thanks to JQuery. + */ + function javascript() { + // we use jquery with the official content delivery URLs + // Microsoft and Google also provide jquery with their content delivery networks +?> + +
    + + + +
    + result; + $refnum = count($display->result); + + foreach ($entries as $value => $bib) { + $bib->setAbbrv($value); + switch(LAYOUT) { + case 'list': $bib->toLI(); break; + case 'table': $bib->toTR(); break; + case 'deflist': $bib->toDD(); break; + } + } // end foreach + + switch(LAYOUT) { + case 'list': + ?> + + +
    + + + + diff --git a/bibtexbrowser_bibliography.php b/bibtexbrowser_bibliography.php new file mode 100644 index 0000000..8cdbc30 --- /dev/null +++ b/bibtexbrowser_bibliography.php @@ -0,0 +1,37 @@ +' . $a . '' ; +} + +// Create citations from bibtex entries. One argument per bibtex entry. +/* Example: As shown in , one can cite +*/ +function cite() { + global $citations; + $entries = func_get_args(); // list of bibtex entries + $refs = array(); // corresponding references + foreach ($entries as $entry) { + if ( array_key_exists ( $entry , $citations ) ) { + $ref = $citations[$entry] ; + } else { + $ref = count( $citations ) + 1 ; + $citations[$entry] = $ref ; + } + $refs[] = $ref; + } + sort( $refs ); + $links = array_map( 'linkify', $refs ); + echo "[" . implode(",",$links) . "]" ; +} + +function make_bibtexbrowser_bibliography() { + global $citations; + return json_encode($citations) ; +} + +?>