Browse Source

*** empty log message ***

replace/c24a8d1de403113542ba0936e844151de2785013
Martin Monperrus 17 years ago
parent
commit
a3678dea0c
  1. 71
      bibtexbrowser.php

71
bibtexbrowser.php

@ -18,6 +18,9 @@ Thanks to all [[#Users]] of bibtexbrowser :-)
=====Features=====
* **New (02/2009)** bibtexbrowser can display all entries for an author with an academic style [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&academic=Martin+Monperrus|demo]]
* **New (01/2009)** bibtexbrowser allows multi criteria search, e.g. ?type=inproceedings&year=2004
* **HOT: bibtexbrowser can be used to include your publication list into your home page** [[http://www.monperrus.net/martin/|demo]]
* bibtexbrowser can display the menu and all entries without filtering from the $filename hardcoded in the script [[http://www.monperrus.net/martin/bibtexbrowser.php|demo]]
* bibtexbrowser can display the menu and all entries without filtering from the file name passed as parameter [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib|demo]]
* bibtexbrowser can display all entries out of a bibtex file [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&all|demo]]
@ -25,12 +28,9 @@ Thanks to all [[#Users]] of bibtexbrowser :-)
* bibtexbrowser can display a single entry [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&key=monperrus08phd|demo]]
* bibtexbrowser can display all entries with a bib keyword [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&keywords=mda|demo]]
* bibtexbrowser can display found entries with a search word (it can be in any bib field) [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&search=ocl|demo]]
* bibtexbrowser allows multi criteria search, e.g. ?type=inproceedings&year=2004
* bibtexbrowser outputs valid XHTML 1.0 Transitional
* bibtexbrowser in designed to be search engine friendly.
* bibtexbrowser can display all entries for an author [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&author=Barbara+A.+Kitchenham|demo]]
* bibtexbrowser can display all entries for an author with an academic style [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&academic=Martin+Monperrus|demo]]
* bibtexbrowser can be used to include your publication list into your home page [[http://www.monperrus.net/martin/|demo]]
* bibtexbrowser can be used with different encodings (change the default iso-8859-1 encoding if your bib file is in utf-8 ''define('ENCODING','utf-8')'' )
=====How to include your publication list in your home page=====
@ -152,11 +152,6 @@ define('YEAR', 'year');
// if future versions of PHP change warning mechanisms...
@error_reporting(E_ERROR);
// we use sessions to avoid reparsing the bib file for each request
// the session may be already started
// by an external script that includes bibtexbrowser
@session_start();
// default bib file, if no file is specified in the query string.
global $filename;
$filename = "biblio_monperrus.bib";
@ -179,15 +174,41 @@ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (strtotime($_SERVER['HTTP_IF_MO
}
// parse a new bib file, if this file has not been already parsed
if (!isset($_SESSION[$filename]) ) {
// for sake of performance, once the bibtex file is parsed
// the object that represents the database is stored in $_SESSION
// we use serialize in order to be able to get a session correctly set up
// without bibtexbrowser loaded in PHP
$_SESSION[$filename] = serialize(new BibDataBase($filename));
// we try to save a "compiled" in a txt file
$compiledbib = $filename.'.txt';
// do we have a compiled version ?
if (is_file($compiledbib) && is_readable($compiledbib)) {
// is it up to date ?
if (filemtime($filename)>filemtime($compiledbib)) {
// no, then reparse
$bibdb = new BibDataBase($filename);
}
else {
// yes then take it
$bibdb = unserialize(file_get_contents($compiledbib));
}
}
// we don't have a compiled version
else {
// then parsing the file
$bibdb = new BibDataBase($filename);
// are we able to save the compiled version ?
if ((!is_file($compiledbib) && is_writable(dirname($compiledbib))) || (is_file($compiledbib) && is_writable($compiledbib)) ) {
// we can use file_put_contents
// but don't do it for compatibility with PHP 4.3
$f = fopen($compiledbib,'w');
fwrite($f,serialize(new BibDataBase($filename)));
fclose($f);
}
$displaymanager=new DisplayManager(unserialize($_SESSION[$filename]));
}
$displaymanager=new DisplayManager($bibdb);
////////////////////////////////////////////////////////
@ -401,6 +422,7 @@ class XMLPrettyPrinter {
print '<bibfile>';
}
function endFile() {
print '</bibfile>';
}
@ -541,6 +563,8 @@ function latex2html($line) {
class BibEntry {
/** The fields (fieldName -> value) of this bib entry. */
var $fields;
/** The verbatim copy (i.e., whole text) of this bib entry. */
@ -983,6 +1007,7 @@ else $page = 1;
if (isset($this->display) && isset($_GET[Q_RESULT])) {
$this->display->setPage($_GET[Q_RESULT]);
// we add the page number to the title
// in order to have unique titles
// google prefers that
$this->display->header.=' - page '.$_GET[Q_RESULT];
@ -1367,6 +1392,18 @@ class AcademicDisplay extends Display {
echo '</table>';
}
// misc and thesis
$entries = $this->db->multisearch(array(Q_AUTHOR=>$this->author, Q_TYPE=>'misc|phdthesis|mastersthesis'));
if (count($entries)>0) {
echo '<div class="header">Other Publications</div>';
echo '<table class="result" >';
foreach ($entries as $bib) {
$bib->id = $bib->getYear();
$bib->toString();
} // end foreach
echo '</table>';
}
echo $this->poweredby();
@ -1380,8 +1417,8 @@ class AcademicDisplay extends Display {
class BibEntryDisplay extends Display {
/** the bib entry to display */
var $bib;
/** Creates an instance with the given bib entry and header.
* It the object is an instance of BibIndexEntry, it may be
* mutated to read the rest of the fields.
@ -1700,7 +1737,7 @@ if (isset($_GET['menu']))
} // end isset($_GET['menu']
else if ($displaymanager->processRequest()) {
if (!$included) printHTMLHeaders($displaymanager->result->header);
if (!$included) printHTMLHeaders($displaymanager->display->header);
$displaymanager->mainVC();
if (!$included) echo '</body></html>';

Loading…
Cancel
Save