*** empty log message ***
This commit is contained in:
+218
-166
@@ -1,23 +1,32 @@
|
|||||||
<?php /* bibtexbrowser: a PHP script to browse and search bib entries from BibTex files
|
<?php /* bibtexbrowser: a PHP script to browse and search bib entries from BibTex files
|
||||||
|
|
||||||
[[#Features]]
|
[[#Download]] | [[#Screenshot]] | [[#Features]] | [[#Related_tools]] | [[#Users]] | [[#Copyright]]
|
||||||
|
|
||||||
===== Features =====
|
|
||||||
|
|
||||||
bibtexbrowser is a PHP script to browse and search bib entries from BibTex files. For instance, on the [[http://www.monperrus.net/martin/bibtexbrowser.php|bibtexbrowser demonstration site]], you can browse my main bibtex file.
|
bibtexbrowser is a PHP script to browse and search bib entries from BibTex files. For instance, on the [[http://www.monperrus.net/martin/bibtexbrowser.php|bibtexbrowser demonstration site]], you can browse my main bibtex file.
|
||||||
|
|
||||||
|
For feature requests or bug reports, [[http://www.monperrus.net/martin/|please drop me an email ]].
|
||||||
|
|
||||||
|
Thanks to all [[#Users]] of bibtexbrowser :-)
|
||||||
|
|
||||||
|
=====Download=====
|
||||||
|
|
||||||
**[[http://www.monperrus.net/martin/bibtexbrowser.php.txt|Download bibtexbrowser]]**
|
**[[http://www.monperrus.net/martin/bibtexbrowser.php.txt|Download bibtexbrowser]]**
|
||||||
|
|
||||||
|
=====Screenshot=====
|
||||||
|
|
||||||
<a href="bibtexbrowser-screenshot.png"><img height="500" src="bibtexbrowser-screenshot.png" alt="bibtexbrowser screenshot"/><br/></a>
|
<a href="bibtexbrowser-screenshot.png"><img height="500" src="bibtexbrowser-screenshot.png" alt="bibtexbrowser screenshot"/><br/></a>
|
||||||
|
|
||||||
|
=====Features=====
|
||||||
|
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php|bibtexbrowser can display the menu and all entries without filtering from the $filename hardcoded in the script ]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php|bibtexbrowser can display the menu and all entries without filtering from the $filename hardcoded in the script ]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib|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|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&all|bibtexbrowser can display all entries out of a bibtex file]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&all|bibtexbrowser can display all entries out of a bibtex file]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&year=2004|bibtexbrowser can display all entries for a given year]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&year=2004|bibtexbrowser can display all entries for a given year]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&author=Barbara+A.+Kitchenham|bibtexbrowser can display all entries for an author]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&author=Barbara+A.+Kitchenham|bibtexbrowser can display all entries for an author]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&key=monperrus08phd|bibtexbrowser can display a single entry]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&key=monperrus08phd|bibtexbrowser can display a single entry]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&tag=mda|bibtexbrowser can display all entries with a bib keyword]]
|
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&keywords=mda|bibtexbrowser can display all entries with a bib keyword]]
|
||||||
* [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=biblio_monperrus.bib&search=ocl|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|bibtexbrowser can display found entries with a search word (it can be in any bib field)]]
|
||||||
|
* bibtexbrowser allows multi criteria search, e.g. ?type=inproceedings&year=2004
|
||||||
* bibtexbrowser outputs valid XHTML 1.0 Transitional
|
* bibtexbrowser outputs valid XHTML 1.0 Transitional
|
||||||
* bibtexbrowser in designed to be search engine friendly.
|
* bibtexbrowser in designed to be search engine friendly.
|
||||||
* You can include your publications list into your home page:
|
* You can include your publications list into your home page:
|
||||||
@@ -26,7 +35,7 @@ session_start(); //to avoid reparsing the bib file; should be at the very top of
|
|||||||
// the bib file
|
// the bib file
|
||||||
$_GET['bib']='mybib.bib';
|
$_GET['bib']='mybib.bib';
|
||||||
// the request
|
// the request
|
||||||
$_GET['author']='Martin+Monperrus';
|
$_GET['author']='Martin Monperrus';
|
||||||
include('bibtexbrowser.php');
|
include('bibtexbrowser.php');
|
||||||
?>
|
?>
|
||||||
And tailor it with a CSS style!
|
And tailor it with a CSS style!
|
||||||
@@ -47,10 +56,21 @@ And tailor it with a CSS style!
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
Warning: you may change the default iso-8859-1 encoding if your bib file is in utf-8
|
Warning: you may change the default iso-8859-1 encoding if your bib file is in utf-8 (define('ENCODING','iso-8859-1') below);
|
||||||
|
|
||||||
|
=====Users=====
|
||||||
|
Don't hesitate to [[http://www.monperrus.net/martin/|contact me]] to be added in the list!
|
||||||
|
|
||||||
===== Related tools =====
|
* [[http://telecom.inescporto.pt/~jsc/bibtexbrowser.php|Jaime dos Santos Cardoso, INESC, Portugal]]
|
||||||
|
* [[http://ccm.uma.pt/bibtexbrowser.php|Centro de Ciências Matemáticas, Portugal]]
|
||||||
|
* [[http://bioinfo.lri.fr/publi/bibtexbrowser.php|Bioinformatics Group of LRI, Paris, France]]
|
||||||
|
* [[http://grapple.dcs.warwick.ac.uk/bibtexbrowser/bibtexbrowser.php|M. Hendrix, University of Warwick, UK]]
|
||||||
|
* [[http://www.cs.usask.ca/home/eramian/bib/Refereed_Journal_Articles.php|Mark Eramian, University of Saskatchewan, Canada]]
|
||||||
|
* [[https://www.cs.tcd.ie/~marined/publications.php|Dan Marinescu, Trinity College Dublin, Ireland]]
|
||||||
|
* [[http://kom.aau.dk/~gpp/publications.php?l=EN|Gian Paolo Perrucci, University of Aalborg, Denmark]]
|
||||||
|
* [[http://dme.uma.pt/luis/page5/bibtexbrowser.php?bib=jluisbib.bib|José Luís da Silva, Universidade da madeira, Portugal]]
|
||||||
|
|
||||||
|
=====Related_tools=====
|
||||||
|
|
||||||
Old-fashioned:
|
Old-fashioned:
|
||||||
[[http://nxg.me.uk/dist/bibhtml/|bibhtml]], [[http://www.litech.org/~wkiri/bib2html/|bib2html]], [[http://ilab.usc.edu/bibTOhtml/|bibtohtml]], [[http://people.csail.mit.edu/rahimi/bibtex/|bibtextohtml]], [[http://www.lri.fr/~filliatr/bibtex2html/|bibtex2html]], [[http://people.csail.mit.edu/mernst/software/bibtex2web.html |bibtex2web]], [[http://strategoxt.org/Stratego/BibtexTools|stratego bibtex module]]
|
[[http://nxg.me.uk/dist/bibhtml/|bibhtml]], [[http://www.litech.org/~wkiri/bib2html/|bib2html]], [[http://ilab.usc.edu/bibTOhtml/|bibtohtml]], [[http://people.csail.mit.edu/rahimi/bibtex/|bibtextohtml]], [[http://www.lri.fr/~filliatr/bibtex2html/|bibtex2html]], [[http://people.csail.mit.edu/mernst/software/bibtex2web.html |bibtex2web]], [[http://strategoxt.org/Stratego/BibtexTools|stratego bibtex module]]
|
||||||
@@ -71,18 +91,17 @@ Main competitors:
|
|||||||
Misc:
|
Misc:
|
||||||
[[http://www.sat.ltu.se/publications/publications.m|This matlab ;-) script is similar ]]
|
[[http://www.sat.ltu.se/publications/publications.m|This matlab ;-) script is similar ]]
|
||||||
|
|
||||||
===== Copyright =====
|
=====Copyright=====
|
||||||
|
|
||||||
This script is a fork from an excellent script of the University of Texas at El Paso.
|
This script is a fork from an excellent script of the University of Texas at El Paso.
|
||||||
|
|
||||||
(C) 2006-2007-2008 [[http://www.monperrus.net/martin/|Martin Monperrus]] - Don't hesitate to contact me :-)
|
(C) 2006-2007-2008-2009 Martin Monperrus
|
||||||
(C) 2005-2006 The University of Texas at El Paso / Joel Garcia, Leonardo Ruiz, and Yoonsik Cheon
|
(C) 2005-2006 The University of Texas at El Paso / Joel Garcia, Leonardo Ruiz, and Yoonsik Cheon
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the
|
published by the Free Software Foundation; either version 2 of the
|
||||||
License, or (at your option) any later version.
|
License, or (at your option) any later version.
|
||||||
Current version: v20081111
|
Current version: v__DATE__
|
||||||
Past deprecated versions: v20080111, v20080229, v20080303, v20080515, v20080709, v20081027
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -103,8 +122,8 @@ define('Q_AUTHOR', 'author');
|
|||||||
define('Q_AUTHOR_PAGE', 'author_page');
|
define('Q_AUTHOR_PAGE', 'author_page');
|
||||||
|
|
||||||
define('TAGS_SIZE',20);
|
define('TAGS_SIZE',20);
|
||||||
define('Q_TAG', 'tag');
|
define('Q_TAG', 'keywords');
|
||||||
define('Q_TAG_PAGE', 'tag_page');
|
define('Q_TAG_PAGE', 'keywords_page');
|
||||||
|
|
||||||
define('Q_TYPE', 'type');
|
define('Q_TYPE', 'type');
|
||||||
define('Q_TYPE_PAGE', 'type_page');
|
define('Q_TYPE_PAGE', 'type_page');
|
||||||
@@ -164,7 +183,7 @@ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (strtotime($_SERVER['HTTP_IF_MO
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse a new bib file, if this this file has not been already parsed
|
// parse a new bib file, if this file has not been already parsed
|
||||||
if (!isset($_SESSION[$filename]) ) {
|
if (!isset($_SESSION[$filename]) ) {
|
||||||
echo '<!-- parsing '.$filename.'-->';
|
echo '<!-- parsing '.$filename.'-->';
|
||||||
// we use serialize in order to be able to get a session correctly set up
|
// we use serialize in order to be able to get a session correctly set up
|
||||||
@@ -200,6 +219,7 @@ class BibParser {
|
|||||||
//print_r($this->bibdb);
|
//print_r($this->bibdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Returns the array of parsed bib entires. */
|
/** Returns the array of parsed bib entires. */
|
||||||
function getEntries() {
|
function getEntries() {
|
||||||
return $this->bibdb;
|
return $this->bibdb;
|
||||||
@@ -213,16 +233,16 @@ class BibParser {
|
|||||||
$raw_line = $this->nextLine($file);
|
$raw_line = $this->nextLine($file);
|
||||||
//echo 'RAW: ' . $raw_line;
|
//echo 'RAW: ' . $raw_line;
|
||||||
if (!$raw_line) { // EOF?
|
if (!$raw_line) { // EOF?
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
$line = trim($raw_line);
|
$line = trim($raw_line);
|
||||||
if (ereg('^[[:space:]]*@.*\{[[:space:]]*([^,]*)', $line,$regs)) {
|
if (ereg('^[[:space:]]*@.*\{[[:space:]]*([^,]*)', $line,$regs)) {
|
||||||
//echo 'NEW: ' . $regs[1] . "\n";
|
//echo 'NEW: ' . $regs[1] . "\n";
|
||||||
$type = trim(substr($line, 1, strpos($line,'{') - 1));
|
$type = trim(substr($line, 1, strpos($line,'{') - 1));
|
||||||
$fields = array();
|
$fields = array();
|
||||||
$fields['key']= $regs[1];
|
$fields['key']= $regs[1];
|
||||||
$raw_bib = $raw_line;
|
$raw_bib = $raw_line;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,36 +253,36 @@ class BibParser {
|
|||||||
|
|
||||||
$line = trim($raw_line);
|
$line = trim($raw_line);
|
||||||
if (ereg("^.*=", $line)) { // new field?
|
if (ereg("^.*=", $line)) { // new field?
|
||||||
//echo 'FIELD: ' . $line . "\n";
|
//echo 'FIELD: ' . $line . "\n";
|
||||||
//get the field type
|
//get the field type
|
||||||
$ps = strpos($line, '=');
|
$ps = strpos($line, '=');
|
||||||
$fkey = strtolower(trim(substr($line,0,$ps)));
|
$fkey = strtolower(trim(substr($line,0,$ps)));
|
||||||
$fval = $this->extractFieldValue($line);
|
$fval = $this->extractFieldValue($line);
|
||||||
if (strlen($fval)) {
|
if (strlen($fval)) {
|
||||||
$fields[$fkey] = $fval;
|
$fields[$fkey] = $fval;
|
||||||
}
|
}
|
||||||
if (ereg(",[:space:]*}$",$line)) return $this->makeBibEntry($type, $fields, $raw_bib);
|
if (ereg(",[:space:]*}$",$line)) return $this->makeBibEntry($type, $fields, $raw_bib);
|
||||||
if (ereg("=[^{]*}$",$line)) return $this->makeBibEntry($type, $fields, $raw_bib);
|
if (ereg("=[^{]*}$",$line)) return $this->makeBibEntry($type, $fields, $raw_bib);
|
||||||
} else if ($line == "}") { // end of entry?
|
} else if ($line == "}") { // end of entry?
|
||||||
//echo 'END: ' . $line . "\n";
|
//echo 'END: ' . $line . "\n";
|
||||||
return $this->makeBibEntry($type, $fields, $raw_bib);
|
return $this->makeBibEntry($type, $fields, $raw_bib);
|
||||||
} else { // continued field?
|
} else { // continued field?
|
||||||
$fval = $this->extractFieldValue($line);
|
$fval = $this->extractFieldValue($line);
|
||||||
if (strlen($fval) > 0) {
|
if (strlen($fval) > 0) {
|
||||||
if (!isset($fields[$fkey])) { // no value seen so far?
|
if (!isset($fields[$fkey])) { // no value seen so far?
|
||||||
// remove starting " if exists
|
// remove starting " if exists
|
||||||
if ($fval[0] == '"') {
|
if ($fval[0] == '"') {
|
||||||
$fval = ltrim(substr($fval, 1));
|
$fval = ltrim(substr($fval, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strlen($fval)) {
|
if (strlen($fval)) {
|
||||||
if (isset($fields[$fkey])) {
|
if (isset($fields[$fkey])) {
|
||||||
$fields[$fkey] = $fields[$fkey].' '.$fval;
|
$fields[$fkey] = $fields[$fkey].' '.$fval;
|
||||||
} else {
|
} else {
|
||||||
$fields[$fkey] = $fval;
|
$fields[$fkey] = $fval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$raw_line = $this->nextLine($file);
|
$raw_line = $this->nextLine($file);
|
||||||
@@ -287,7 +307,7 @@ class BibParser {
|
|||||||
static $types = array();
|
static $types = array();
|
||||||
foreach ($types as $t) {
|
foreach ($types as $t) {
|
||||||
if (strcasecmp($t, $type) == 0) {
|
if (strcasecmp($t, $type) == 0) {
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$type = ucfirst($type);
|
$type = ucfirst($type);
|
||||||
@@ -302,7 +322,8 @@ class BibParser {
|
|||||||
// clean out tex stuff
|
// clean out tex stuff
|
||||||
$result = str_replace('}','', $result);
|
$result = str_replace('}','', $result);
|
||||||
$result = str_replace('{','', $result);
|
$result = str_replace('{','', $result);
|
||||||
$result = str_replace(',','', $result);
|
// comas are important to recognize the author name format
|
||||||
|
//$result = str_replace(',','', $result);
|
||||||
$result = str_replace("\'", '', $result); // e.g., \'{e}
|
$result = str_replace("\'", '', $result); // e.g., \'{e}
|
||||||
$result = str_replace('\`', '', $result);
|
$result = str_replace('\`', '', $result);
|
||||||
$result = str_replace('\^', '', $result);
|
$result = str_replace('\^', '', $result);
|
||||||
@@ -331,8 +352,8 @@ class BibParser {
|
|||||||
//echo "RAW: " . $rawline;
|
//echo "RAW: " . $rawline;
|
||||||
$line = trim($rawline);
|
$line = trim($rawline);
|
||||||
if (strpos($line, '@string') === false // !FIXME!@string ignored!
|
if (strpos($line, '@string') === false // !FIXME!@string ignored!
|
||||||
&& strlen($line) != 0 && $line[0] != '%') {
|
&& strlen($line) != 0 && $line[0] != '%') {
|
||||||
return $rawline;
|
return $rawline;
|
||||||
}
|
}
|
||||||
$rawline = fgets($file, READLINE_LIMIT);
|
$rawline = fgets($file, READLINE_LIMIT);
|
||||||
}
|
}
|
||||||
@@ -415,7 +436,7 @@ class BibEntry {
|
|||||||
/** Returns the value of the given field? */
|
/** Returns the value of the given field? */
|
||||||
function getField($name) {
|
function getField($name) {
|
||||||
if ($this->hasField($name))
|
if ($this->hasField($name))
|
||||||
{return $this->fields[$name];}
|
{return $this->fields[$name];}
|
||||||
else return 'missing '.$name;
|
else return 'missing '.$name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,8 +466,8 @@ class BibEntry {
|
|||||||
}
|
}
|
||||||
foreach ($fields as $f) {
|
foreach ($fields as $f) {
|
||||||
if ($this->hasField($f) &&
|
if ($this->hasField($f) &&
|
||||||
strpos(strtolower($this->getField($f)), $phrase) !== false) {
|
strpos(strtolower($this->getField($f)), $phrase) !== false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -456,11 +477,11 @@ class BibEntry {
|
|||||||
/** Outputs an HTML string
|
/** Outputs an HTML string
|
||||||
*/
|
*/
|
||||||
function toString() {
|
function toString() {
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
$key = $this->getKey();
|
$key = $this->getKey();
|
||||||
$title = $this->getField(TITLE);
|
$title = $this->getField(TITLE);
|
||||||
$type = $this->getType();
|
$type = $this->getType();
|
||||||
$href = makeHref(array(Q_KEY => urlencode($key)));
|
$href = makeHref(array(Q_KEY => urlencode($key)));
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo '<td class="bibline"><a name="'.$id.'"></a>['.$id.']</td> ';
|
echo '<td class="bibline"><a name="'.$id.'"></a>['.$id.']</td> ';
|
||||||
|
|
||||||
@@ -553,15 +574,30 @@ function makeHref($query = NULL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the formated author name. The argument is assumed to be
|
* Returns the last name of an author name. The argument is assumed to be
|
||||||
* <FirstName LastName>, and the return value is <LastName, FirstName>.
|
* <FirstName LastName> or <LastName, FirstName>.
|
||||||
|
*/
|
||||||
|
function getLastName($author){
|
||||||
|
$author = trim($author);
|
||||||
|
// the author format is "Joe Dupont"
|
||||||
|
if (strpos($author,',')===false) {
|
||||||
|
$parts=explode(' ', $author);
|
||||||
|
// get the last name
|
||||||
|
return array_pop($parts);
|
||||||
|
}
|
||||||
|
// the author format is "Dupont, J."
|
||||||
|
else {
|
||||||
|
$parts=explode(',', $author);
|
||||||
|
// get the last name
|
||||||
|
return array_shift($parts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the formated author name.
|
||||||
*/
|
*/
|
||||||
function formatAuthor($author){
|
function formatAuthor($author){
|
||||||
return trim($author);
|
return trim($author);
|
||||||
/*return trim(!strrchr($author, ' ') ?
|
|
||||||
$author :
|
|
||||||
strrchr($author, ' ') . ', '
|
|
||||||
.substr($author, 0, strrpos($author, " ")));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -639,7 +675,7 @@ class DisplayManager {
|
|||||||
|
|
||||||
$types = array();
|
$types = array();
|
||||||
foreach ($this->db->getTypes() as $type) {
|
foreach ($this->db->getTypes() as $type) {
|
||||||
$types[$type] = $type;
|
$types[$type] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retreive or calculate page number to display
|
// retreive or calculate page number to display
|
||||||
@@ -664,7 +700,7 @@ class DisplayManager {
|
|||||||
|
|
||||||
|
|
||||||
$this->displayMenu('Authors', $authors, $page, AUTHORS_SIZE, Q_AUTHOR_PAGE,
|
$this->displayMenu('Authors', $authors, $page, AUTHORS_SIZE, Q_AUTHOR_PAGE,
|
||||||
Q_AUTHOR);
|
Q_AUTHOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Displays and controls the tag menu in a table. */
|
/** Displays and controls the tag menu in a table. */
|
||||||
@@ -679,7 +715,7 @@ class DisplayManager {
|
|||||||
|
|
||||||
|
|
||||||
$this->displayMenu('Keywords', $tags, $page, TAGS_SIZE, Q_TAG_PAGE,
|
$this->displayMenu('Keywords', $tags, $page, TAGS_SIZE, Q_TAG_PAGE,
|
||||||
Q_TAG);
|
Q_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Displays and controls the tag menu in a table. */
|
/** Displays and controls the tag menu in a table. */
|
||||||
@@ -695,7 +731,7 @@ else $page = 1;
|
|||||||
|
|
||||||
|
|
||||||
$this->displayMenu('Years', $years, $page, YEAR_SIZE, Q_YEAR_PAGE,
|
$this->displayMenu('Years', $years, $page, YEAR_SIZE, Q_YEAR_PAGE,
|
||||||
Q_YEAR);
|
Q_YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Displays the main contents . */
|
/** Displays the main contents . */
|
||||||
@@ -706,66 +742,59 @@ else $page = 1;
|
|||||||
/** Process the GET parameters */
|
/** Process the GET parameters */
|
||||||
function processRequest() {
|
function processRequest() {
|
||||||
|
|
||||||
global $filename;
|
global $filename;
|
||||||
$this->result = null;
|
$this->result = null;
|
||||||
|
|
||||||
if (isset($_GET[Q_KEY])){
|
if ($_GET[Q_KEY]!=''){
|
||||||
|
|
||||||
if (isset($this->db->bibdb[$_GET[Q_KEY]])) {
|
if (isset($this->db->bibdb[$_GET[Q_KEY]])) {
|
||||||
$this->result = new SingleResultDisplay(
|
$this->result = new SingleResultDisplay(
|
||||||
$this->db->getEntryByKey(
|
$this->db->getEntryByKey(
|
||||||
urldecode($_GET[Q_KEY])));
|
urldecode($_GET[Q_KEY])));
|
||||||
}
|
|
||||||
else { header('HTTP/1.1 404 Not found'); $this->result = new ErrorDisplay(); }
|
|
||||||
} else if (isset($_GET[Q_SEARCH])){ // search?
|
|
||||||
$to_find = $_GET[Q_SEARCH];
|
|
||||||
$searched = $this->db->search($to_find);
|
|
||||||
if (count($searched)==1)
|
|
||||||
$this->result = new SingleResultDisplay($searched[0]);
|
|
||||||
else {
|
|
||||||
$header = 'Search: ' . trim($to_find);
|
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_SEARCH => $to_find));
|
|
||||||
}
|
|
||||||
// clicking an author, a menu item from the authors menu?
|
|
||||||
} else if (isset($_GET[Q_AUTHOR])) {
|
|
||||||
$to_find = urldecode($_GET[Q_AUTHOR]);
|
|
||||||
$searched = $this->db->search($to_find, array('author'));
|
|
||||||
$header = 'Publications of ' . ucwords($to_find).' in '.$filename ;
|
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_AUTHOR => $to_find));
|
|
||||||
// clicking a type, a menu item from the types menu?
|
|
||||||
} else if(isset($_GET[Q_TAG])) {
|
|
||||||
$to_find = $_GET[Q_TAG];
|
|
||||||
$searched = $this->db->search($to_find, array('keywords'));
|
|
||||||
$header = 'Keyword: ' . ucwords($to_find);
|
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_TAG => $to_find));
|
|
||||||
}
|
}
|
||||||
else if(isset($_GET[Q_YEAR])) {
|
else { header('HTTP/1.1 404 Not found'); $this->result = new ErrorDisplay(); }
|
||||||
$to_find = $_GET[Q_YEAR];
|
} else if ($_GET[Q_SEARCH]!=''){ // search?
|
||||||
$searched = $this->db->search($to_find, array('year'));
|
$to_find = $_GET[Q_SEARCH];
|
||||||
$header = 'Year: ' . ucwords($to_find);
|
$searched = $this->db->search($to_find);
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_YEAR => $to_find));
|
if (count($searched)==1)
|
||||||
}
|
$this->result = new SingleResultDisplay($searched[0]);
|
||||||
else if(isset($_GET[Q_TYPE])) {
|
else {
|
||||||
$to_find = $_GET[Q_TYPE];
|
$header = 'Search: ' . trim($to_find);
|
||||||
$searched = $this->db->searchType($to_find);
|
$this->result = new ResultDisplay($searched, $header,array(Q_SEARCH => $to_find));
|
||||||
$header = 'Type: ' . ucwords($to_find);
|
}
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_TYPE => $to_find));
|
// clicking an author, a menu item from the authors menu?
|
||||||
}
|
} else if(isset($_GET[Q_ALL])) {
|
||||||
else if(isset($_GET[Q_ALL])) {
|
$to_find = $_GET[Q_ALL];
|
||||||
$to_find = $_GET[Q_ALL];
|
$searched = array_values($this->db->bibdb);
|
||||||
$searched = array_values($this->db->bibdb);
|
$header = 'Bibtex entries';
|
||||||
$header = 'Bibtex entries in '.$filename ;
|
$this->result = new ResultDisplay($searched, $header,array(Q_ALL =>''));
|
||||||
$this->result = new ResultDisplay($searched, $header,array(Q_ALL =>''));
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$query = array();
|
||||||
|
if ($_GET[Q_AUTHOR]!='') { $query[Q_AUTHOR]=$_GET[Q_AUTHOR]; }
|
||||||
|
if ($_GET[Q_TAG]!='') { $query[Q_TAG]=$_GET[Q_TAG]; }
|
||||||
|
if ($_GET[Q_YEAR]!='') { $query[Q_YEAR]=$_GET[Q_YEAR]; }
|
||||||
|
if ($_GET[Q_TYPE]!='') { $query[Q_TYPE]=$_GET[Q_TYPE]; }
|
||||||
|
//print_r($query);
|
||||||
|
if (count($query)<1) return false;
|
||||||
|
$searched = $this->db->multisearch($query);
|
||||||
|
$headers = array();
|
||||||
|
foreach($query as $k=>$v) $headers[] = ucwords($k).': '.ucwords($v);
|
||||||
|
$header = join(' & ',$headers);
|
||||||
|
$this->result = new ResultDisplay($searched, $header, $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// adding the bibtex filename
|
||||||
|
if (isset($this->result)) $this->result->header.=' in '.$filename;
|
||||||
|
|
||||||
// requesting a different page of the result view?
|
// requesting a different page of the result view?
|
||||||
if (isset($this->result) && isset($_GET[Q_RESULT])) {
|
if (isset($this->result) && isset($_GET[Q_RESULT])) {
|
||||||
$this->result->setPage($_GET[Q_RESULT]);
|
$this->result->setPage($_GET[Q_RESULT]);
|
||||||
// we had the page number to the title
|
// we add the page number to the title
|
||||||
// in order to have unique titles
|
// in order to have unique titles
|
||||||
// google prefers that
|
// google prefers that
|
||||||
$this->result->header.=' - page '.$_GET[Q_RESULT];
|
$this->result->header.=' - page '.$_GET[Q_RESULT];
|
||||||
// requesting a differen page of type or author menus?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -783,7 +812,7 @@ else $page = 1;
|
|||||||
* $targetKey: URL query name to send the target of the menu item
|
* $targetKey: URL query name to send the target of the menu item
|
||||||
*/
|
*/
|
||||||
function displayMenu($title, $list, $page, $pageSize, $pageKey,
|
function displayMenu($title, $list, $page, $pageSize, $pageKey,
|
||||||
$targetKey) {
|
$targetKey) {
|
||||||
$numEntries = count($list);
|
$numEntries = count($list);
|
||||||
$startIndex = ($page - 1) * $pageSize;
|
$startIndex = ($page - 1) * $pageSize;
|
||||||
$endIndex = $startIndex + $pageSize;
|
$endIndex = $startIndex + $pageSize;
|
||||||
@@ -796,15 +825,15 @@ else $page = 1;
|
|||||||
<td class="header"><b><?php echo $title; ?></b></td>
|
<td class="header"><b><?php echo $title; ?></b></td>
|
||||||
<td class="header" align="right"><b>
|
<td class="header" align="right"><b>
|
||||||
<?php echo $this->menuPageBar($pageKey, $numEntries, $page,
|
<?php echo $this->menuPageBar($pageKey, $numEntries, $page,
|
||||||
$pageSize, $startIndex, $endIndex);?></b></td>
|
$pageSize, $startIndex, $endIndex);?></b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php $this->displayMenuItems($list, $startIndex, $endIndex,
|
<?php $this->displayMenuItems($list, $startIndex, $endIndex,
|
||||||
$targetKey); ?>
|
$targetKey); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -820,7 +849,7 @@ else $page = 1;
|
|||||||
* $end: end index of the current page
|
* $end: end index of the current page
|
||||||
*/
|
*/
|
||||||
function menuPageBar($queryKey, $numEntries, $page, $pageSize,
|
function menuPageBar($queryKey, $numEntries, $page, $pageSize,
|
||||||
$start, $end) {
|
$start, $end) {
|
||||||
// fast (2 pages) reverse (<<)
|
// fast (2 pages) reverse (<<)
|
||||||
$result = '';
|
$result = '';
|
||||||
if ($start - $pageSize > 0) {
|
if ($start - $pageSize > 0) {
|
||||||
@@ -861,9 +890,9 @@ else $page = 1;
|
|||||||
$index = 0;
|
$index = 0;
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
if ($index >= $startIndex && $index < $endIndex) {
|
if ($index >= $startIndex && $index < $endIndex) {
|
||||||
$href = makeHref(array($queryKey => urlencode($key)));
|
$href = makeHref(array($queryKey => urlencode($key)));
|
||||||
echo '<a '. $href .' target="main">'. $item ."</a>\n";
|
echo '<a '. $href .' target="main">'. $item ."</a>\n";
|
||||||
echo "<div class=\"mini_se\"></div>\n";
|
echo "<div class=\"mini_se\"></div>\n";
|
||||||
}
|
}
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
@@ -984,9 +1013,9 @@ class ResultDisplay {
|
|||||||
$href = makeHref($this->filter);
|
$href = makeHref($this->filter);
|
||||||
if ($i == $page) {
|
if ($i == $page) {
|
||||||
// don't make links for current page
|
// don't make links for current page
|
||||||
echo '<b>['. $i .']</b>';
|
echo '<b>['. $i .']</b>';
|
||||||
} else {
|
} else {
|
||||||
echo '<a '. $href .'>['. $i .']</a>';
|
echo '<a '. $href .'>['. $i .']</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,13 +1039,13 @@ class ResultDisplay {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the summary information of each bib entries of the
|
* Displays the summary information of each bib entries of the
|
||||||
* current page. For each entry, this method displays the author,
|
* current page. For each entry, this method displays the author,
|
||||||
* title; the bib entries are displayed grouped by the
|
* title; the bib entries are displayed grouped by the
|
||||||
* publication years. If the bib list is empty, an error message is
|
* publication years. If the bib list is empty, an error message is
|
||||||
* displayed.
|
* displayed.
|
||||||
*/
|
*/
|
||||||
class DefaultContentStrategy {
|
class DefaultContentStrategy {
|
||||||
|
|
||||||
function display($display) {
|
function display($display) {
|
||||||
@@ -1048,11 +1077,11 @@ class DefaultContentStrategy {
|
|||||||
// sort by keys, enable a nice sorting as Dupont2008a, Dupont2008b, Dupont2008c
|
// sort by keys, enable a nice sorting as Dupont2008a, Dupont2008b, Dupont2008c
|
||||||
krsort($entries);
|
krsort($entries);
|
||||||
foreach ($entries as $bib) {
|
foreach ($entries as $bib) {
|
||||||
if ($display->isDisplayed($index)) {
|
if ($display->isDisplayed($index)) {
|
||||||
$bib->id = $refnum--;
|
$bib->id = $refnum--;
|
||||||
$bib->toString();
|
$bib->toString();
|
||||||
}
|
}
|
||||||
$index++;
|
$index++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1112,15 +1141,15 @@ class SingleResultDisplay extends ResultDisplay {
|
|||||||
* bibliographic entries and maintain them.
|
* bibliographic entries and maintain them.
|
||||||
*/
|
*/
|
||||||
class BibDataBase {
|
class BibDataBase {
|
||||||
/** A hash table from IDs (number) to bib entries (BibEntry). */
|
/** A hash table from keys (e.g. Goody1994) to bib entries (BibEntry instances). */
|
||||||
var $bibdb;
|
var $bibdb;
|
||||||
|
|
||||||
/** Creates a new database by parsing bib entries from the given
|
/** Creates a new database by parsing bib entries from the given
|
||||||
* file. */
|
* file. */
|
||||||
function BibDataBase($filename) {
|
function BibDataBase($filename) {
|
||||||
$parser = new BibParser($filename);
|
$parser = new BibParser($filename);
|
||||||
//print_r($parser);
|
//print_r($parser);
|
||||||
$this->bibdb =$parser->getEntries();
|
$this->bibdb =$parser->getEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns all entries as an array. Each entry is an instance of
|
/** Returns all entries as an array. Each entry is an instance of
|
||||||
@@ -1159,18 +1188,19 @@ class BibDataBase {
|
|||||||
foreach ($this->bibdb as $bib) {
|
foreach ($this->bibdb as $bib) {
|
||||||
$authors =explode(' and ', $bib->getAuthor());
|
$authors =explode(' and ', $bib->getAuthor());
|
||||||
foreach($authors as $a){
|
foreach($authors as $a){
|
||||||
$ta = trim($a);
|
//we use an array because several authors can have the same lastname
|
||||||
$parts=explode(' ', $ta);
|
@$result[getLastName($a)][$a]++;
|
||||||
// get the last name
|
|
||||||
$key = array_pop($parts);
|
|
||||||
$result[$key] = $ta;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ksort($result);
|
ksort($result);
|
||||||
|
|
||||||
// now authors are sorted by last name
|
// now authors are sorted by last name
|
||||||
// we rebuild a new array for having good keys in author page
|
// we rebuild a new array for having good keys in author page
|
||||||
$realresult = array();
|
$realresult = array();
|
||||||
foreach($result as $v) $realresult[$v] = formatAuthor($v);
|
foreach($result as $x) {
|
||||||
|
ksort($x);
|
||||||
|
foreach($x as $v => $tmp) $realresult[$v] = formatAuthor($v);
|
||||||
|
}
|
||||||
|
|
||||||
return $realresult;
|
return $realresult;
|
||||||
}
|
}
|
||||||
@@ -1182,8 +1212,8 @@ class BibDataBase {
|
|||||||
foreach ($this->bibdb as $bib) {
|
foreach ($this->bibdb as $bib) {
|
||||||
$tags =explode(' and ', $bib->getField("keywords"));
|
$tags =explode(' and ', $bib->getField("keywords"));
|
||||||
foreach($tags as $a){
|
foreach($tags as $a){
|
||||||
$ta = trim($a);
|
$ta = trim($a);
|
||||||
$result[$ta] = $ta;
|
$result[$ta] = $ta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asort($result);
|
asort($result);
|
||||||
@@ -1197,8 +1227,8 @@ class BibDataBase {
|
|||||||
foreach ($this->bibdb as $bib) {
|
foreach ($this->bibdb as $bib) {
|
||||||
$tags =explode(' and ', $bib->getField("year"));
|
$tags =explode(' and ', $bib->getField("year"));
|
||||||
foreach($tags as $a){
|
foreach($tags as $a){
|
||||||
$ta = trim($a);
|
$ta = trim($a);
|
||||||
$result[$ta] = $ta;
|
$result[$ta] = $ta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arsort($result);
|
arsort($result);
|
||||||
@@ -1209,7 +1239,7 @@ class BibDataBase {
|
|||||||
function getEntry($id){
|
function getEntry($id){
|
||||||
foreach($this->bibdb as $bib) {
|
foreach($this->bibdb as $bib) {
|
||||||
if($bib->getId() == $id)
|
if($bib->getId() == $id)
|
||||||
return $bib;
|
return $bib;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1227,15 +1257,36 @@ class BibDataBase {
|
|||||||
$result = array();
|
$result = array();
|
||||||
foreach($this->bibdb as $bib) {
|
foreach($this->bibdb as $bib) {
|
||||||
if($bib->getType() == $type)
|
if($bib->getType() == $type)
|
||||||
$result[] = $bib;
|
$result[] = $bib;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns an array of bib entries (BibEntry) that
|
||||||
|
* satisfy the query
|
||||||
|
* $query is an hash with entry type as key and searched fragment as value
|
||||||
|
*/
|
||||||
|
|
||||||
|
function multisearch($query) {
|
||||||
|
if (count($query)<1) {return array();}
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach ($this->bibdb as $bib) {
|
||||||
|
$entryisselected = true;
|
||||||
|
foreach ($query as $field => $fragment) {
|
||||||
|
if (($field!='type' && !$bib->hasPhrase(strtolower($fragment), array($field))) || ($field=='type' && $bib->getType()!=$fragment)) {
|
||||||
|
$entryisselected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($entryisselected) $result[] = $bib;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns an array of bib entries (BibEntry) that contains the
|
/** Returns an array of bib entries (BibEntry) that contains the
|
||||||
* given phrase in the given fields. If the fields are empty, all
|
* given phrase.
|
||||||
* fields are searched. */
|
*/
|
||||||
function search($phrase, $fields = NULL) {
|
function search($phrase) {
|
||||||
$phrase = strtolower(trim($phrase));
|
$phrase = strtolower(trim($phrase));
|
||||||
if (empty($phrase)) {
|
if (empty($phrase)) {
|
||||||
return array();
|
return array();
|
||||||
@@ -1243,14 +1294,14 @@ class BibDataBase {
|
|||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($this->bibdb as $bib) {
|
foreach ($this->bibdb as $bib) {
|
||||||
if ($bib->hasPhrase($phrase, $fields)) {
|
if ($bib->hasPhrase(strtolower($phrase))) {
|
||||||
$result[] = $bib;
|
$result[] = $bib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print_r($result);
|
//print_r($result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
} // end class
|
||||||
|
|
||||||
|
|
||||||
function printHTMLHeaders($title,$noindex_metatag=false) {
|
function printHTMLHeaders($title,$noindex_metatag=false) {
|
||||||
@@ -1260,7 +1311,7 @@ function printHTMLHeaders($title,$noindex_metatag=false) {
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo ENCODING ?>"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo ENCODING ?>"/>
|
||||||
<meta name="generator" content="bibtexbrowser v20081111" />
|
<meta name="generator" content="bibtexbrowser v__DATE__" />
|
||||||
<?php if ($noindex_metatag) echo '<meta name="robots" content="noindex"/>' ?>
|
<?php if ($noindex_metatag) echo '<meta name="robots" content="noindex"/>' ?>
|
||||||
<title><?php echo $title; ?></title>
|
<title><?php echo $title; ?></title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@@ -1356,6 +1407,7 @@ pre {
|
|||||||
.a_name a {
|
.a_name a {
|
||||||
color:#469AF8;
|
color:#469AF8;
|
||||||
width:130px;
|
width:130px;
|
||||||
|
|
||||||
}
|
}
|
||||||
.bit_big{
|
.bit_big{
|
||||||
font-size: small;
|
font-size: small;
|
||||||
@@ -1376,7 +1428,7 @@ $included=(__FILE__!=$_SERVER['SCRIPT_FILENAME']);
|
|||||||
if (isset($_GET['menu']))
|
if (isset($_GET['menu']))
|
||||||
{
|
{
|
||||||
// menu pages don't need to be indexed by search engines
|
// menu pages don't need to be indexed by search engines
|
||||||
// we don't set the title and set noindex_metatag to true
|
// we don't set the title and set noindex metatag to true
|
||||||
printHTMLHeaders("",true);
|
printHTMLHeaders("",true);
|
||||||
echo $displaymanager->searchView();
|
echo $displaymanager->searchView();
|
||||||
echo $displaymanager->typeVC().'<br/>';
|
echo $displaymanager->typeVC().'<br/>';
|
||||||
@@ -1401,7 +1453,7 @@ else if (!$included) {
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="bibtexbrowser v20081111" />
|
<meta name="generator" content="bibtexbrowser v__DATE__" />
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo ENCODING ?>"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo ENCODING ?>"/>
|
||||||
<title>You are browsing <?php echo $filename; ?> with bibtexbrowser</title>
|
<title>You are browsing <?php echo $filename; ?> with bibtexbrowser</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user