adds support for dynamic Bibtex data
This commit is contained in:
@@ -286,7 +286,7 @@ This comment field can also be used to add acceptance rates and impact factors.
|
|||||||
====How to localize bibtexbrowser?====
|
====How to localize bibtexbrowser?====
|
||||||
Add in ''bibtexbrowser.local.php'':
|
Add in ''bibtexbrowser.local.php'':
|
||||||
<pre>
|
<pre>
|
||||||
<?
|
<?php
|
||||||
global $BIBTEXBROWSER_LANG;
|
global $BIBTEXBROWSER_LANG;
|
||||||
$BIBTEXBROWSER_LANG=array();
|
$BIBTEXBROWSER_LANG=array();
|
||||||
$BIBTEXBROWSER_LANG['Refereed Conference Papers']="Conférences avec comité de lecture";
|
$BIBTEXBROWSER_LANG['Refereed Conference Papers']="Conférences avec comité de lecture";
|
||||||
@@ -298,7 +298,7 @@ $BIBTEXBROWSER_LANG['Year']="Année";
|
|||||||
====How to change the default frame?====
|
====How to change the default frame?====
|
||||||
Add in ''bibtexbrowser.local.php'':
|
Add in ''bibtexbrowser.local.php'':
|
||||||
<pre>
|
<pre>
|
||||||
<?
|
<?php
|
||||||
// or any valid query: year=2010, author=Jane, etc.
|
// or any valid query: year=2010, author=Jane, etc.
|
||||||
@define('BIBTEXBROWSER_DEFAULT_FRAME','all');
|
@define('BIBTEXBROWSER_DEFAULT_FRAME','all');
|
||||||
?>
|
?>
|
||||||
@@ -306,7 +306,7 @@ Add in ''bibtexbrowser.local.php'':
|
|||||||
|
|
||||||
====How to order a list of Bibtex entries?====
|
====How to order a list of Bibtex entries?====
|
||||||
<pre>
|
<pre>
|
||||||
<?
|
<?php
|
||||||
$_GET['library']=1;
|
$_GET['library']=1;
|
||||||
require_once('bibtexbrowser.php');
|
require_once('bibtexbrowser.php');
|
||||||
$db = new BibDataBase();
|
$db = new BibDataBase();
|
||||||
@@ -340,13 +340,27 @@ define('BIBTEXBROWSER_ROBOTS_NOINDEX', true);
|
|||||||
|
|
||||||
====How to load Bibtex from a dynamic string?====
|
====How to load Bibtex from a dynamic string?====
|
||||||
|
|
||||||
You can use the special ''php://memory'' feature as follows:
|
You can use the special ''php://memory'' feature in a new dispatcher.
|
||||||
|
Add in ''bibtexbrowser.local.php'':
|
||||||
<pre>
|
<pre>
|
||||||
$test_data = fopen('php://memory','x+');
|
define("BIBTEXBROWSER_MAIN", 'DynamicDispatcher');
|
||||||
fwrite($test_data, "@book{aKey,title={A Book},author={Jan Doe},publisher={Springer},year=2009}\n");
|
</pre>
|
||||||
fseek($test_data,0);
|
|
||||||
$this->btb = new BibDataBase();
|
and then in ''bibtexbrowser.after.php'':
|
||||||
$this->btb->update_internal("inline", $test_data);
|
<pre>
|
||||||
|
<?php
|
||||||
|
class DynamicDispatcher extends Dispatcher {
|
||||||
|
function getDB() {
|
||||||
|
$data = fopen('php://memory','x+');
|
||||||
|
$dynamic_string = "@book{aKey,title={A Book},author={Jan Doe},publisher={Springer},year=2009}\n";
|
||||||
|
fwrite($data, $dynamic_string);
|
||||||
|
fseek($data,0);
|
||||||
|
$db = new BibDataBase();
|
||||||
|
$db->update_internal("inline", $data);
|
||||||
|
return $db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+23
-13
@@ -2233,13 +2233,12 @@ usage:
|
|||||||
$_GET['all']=1;
|
$_GET['all']=1;
|
||||||
include( 'bibtexbrowser.php' );
|
include( 'bibtexbrowser.php' );
|
||||||
setDB();
|
setDB();
|
||||||
new IndependentYearMenu();
|
new IndependentYearMenu($_GET[Q_DB]);
|
||||||
</pre>
|
</pre>
|
||||||
*/
|
*/
|
||||||
class IndependentYearMenu {
|
class IndependentYearMenu {
|
||||||
function IndependentYearMenu() {
|
function IndependentYearMenu($db) {
|
||||||
if (!isset($_GET[Q_DB])) {die('Did you forget to call setDB() before instantiating this class?');}
|
$yearIndex = $db->yearIndex();
|
||||||
$yearIndex = $_GET[Q_DB]->yearIndex();
|
|
||||||
echo '<div id="yearmenu">Year: ';
|
echo '<div id="yearmenu">Year: ';
|
||||||
$formatedYearIndex = array();
|
$formatedYearIndex = array();
|
||||||
$formatedYearIndex[] = '<a '.makeHref(array(Q_YEAR=>'.*')).'>All</a>';
|
$formatedYearIndex[] = '<a '.makeHref(array(Q_YEAR=>'.*')).'>All</a>';
|
||||||
@@ -2329,7 +2328,7 @@ class MenuManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** sets the database that is used to create the menu */
|
/** sets the database that is used to create the menu */
|
||||||
function setDB(&$db) {
|
function setDB($db) {
|
||||||
$this->db =$db;
|
$this->db =$db;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -3947,8 +3946,22 @@ class Dispatcher {
|
|||||||
*/
|
*/
|
||||||
var $wrapper = BIBTEXBROWSER_DEFAULT_TEMPLATE;
|
var $wrapper = BIBTEXBROWSER_DEFAULT_TEMPLATE;
|
||||||
|
|
||||||
|
/** The BibDataBase object */
|
||||||
|
var $db = null;
|
||||||
|
|
||||||
function Dispatcher() {}
|
function Dispatcher() {}
|
||||||
|
|
||||||
|
/** returns the underlying BibDataBase object */
|
||||||
|
function getDB() {
|
||||||
|
// by default set it from $_GET[Q_FILE]
|
||||||
|
// first we set the database (load from disk or parse the bibtex file)
|
||||||
|
if ($this->db == null) {
|
||||||
|
list($db, $parsed, $updated, $saved) = _zetDB($_GET[Q_FILE]);
|
||||||
|
$this->db = $db;
|
||||||
|
}
|
||||||
|
return $this->db;
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
// are we in test mode, or libray mode
|
// are we in test mode, or libray mode
|
||||||
// then this file is just a library
|
// then this file is just a library
|
||||||
@@ -3961,9 +3974,6 @@ class Dispatcher {
|
|||||||
|
|
||||||
if (!isset($_GET[Q_FILE])) { die('$_GET[\''.Q_FILE.'\'] is not set!'); }
|
if (!isset($_GET[Q_FILE])) { die('$_GET[\''.Q_FILE.'\'] is not set!'); }
|
||||||
|
|
||||||
// first we set the database (load from disk or parse the bibtex file)
|
|
||||||
if (!isset($_GET[Q_DB]) || !$_GET[Q_DB]->is_already_loaded($_GET[Q_FILE])) { setDB(); }
|
|
||||||
|
|
||||||
// is the publication list included in another page?
|
// is the publication list included in another page?
|
||||||
// strtr is used for Windows where __FILE__ contains C:\toto and SCRIPT_FILENAME contains C:/toto (bug reported by Marco)
|
// strtr is used for Windows where __FILE__ contains C:\toto and SCRIPT_FILENAME contains C:/toto (bug reported by Marco)
|
||||||
// realpath is required if the path contains sym-linked directories (bug found by Mark Hereld)
|
// realpath is required if the path contains sym-linked directories (bug found by Mark Hereld)
|
||||||
@@ -3988,7 +3998,7 @@ class Dispatcher {
|
|||||||
unset($this->query[Q_ALL]);
|
unset($this->query[Q_ALL]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectedEntries = $_GET[Q_DB]->multisearch($this->query);
|
$selectedEntries = $this->getDB()->multisearch($this->query);
|
||||||
|
|
||||||
if (count($selectedEntries)==0) {
|
if (count($selectedEntries)==0) {
|
||||||
$this->displayer = 'NotFoundDisplay';
|
$this->displayer = 'NotFoundDisplay';
|
||||||
@@ -4080,7 +4090,7 @@ class Dispatcher {
|
|||||||
function year() {
|
function year() {
|
||||||
// we may want the latest
|
// we may want the latest
|
||||||
if ($_GET[Q_YEAR]=='latest') {
|
if ($_GET[Q_YEAR]=='latest') {
|
||||||
$years = $_GET[Q_DB]->yearIndex();
|
$years = $this->getDB()->yearIndex();
|
||||||
$_GET[Q_YEAR]=array_shift($years);
|
$_GET[Q_YEAR]=array_shift($years);
|
||||||
}
|
}
|
||||||
$this->query[Q_YEAR]=$_GET[Q_YEAR];
|
$this->query[Q_YEAR]=$_GET[Q_YEAR];
|
||||||
@@ -4165,7 +4175,7 @@ class Dispatcher {
|
|||||||
|
|
||||||
function menu() {
|
function menu() {
|
||||||
$menu = createMenuManager();
|
$menu = createMenuManager();
|
||||||
$menu->setDB($_GET[Q_DB]);
|
$menu->setDB($this->getDB());
|
||||||
$fun = $this->wrapper;
|
$fun = $this->wrapper;
|
||||||
$fun($menu);
|
$fun($menu);
|
||||||
return 'END_DISPATCH';
|
return 'END_DISPATCH';
|
||||||
@@ -4195,8 +4205,8 @@ class Dispatcher {
|
|||||||
function key() {
|
function key() {
|
||||||
$entries = array();
|
$entries = array();
|
||||||
// case 1: this is a single key
|
// case 1: this is a single key
|
||||||
if ($_GET[Q_DB]->contains($_GET[Q_KEY])) {
|
if ($this->getDB()->contains($_GET[Q_KEY])) {
|
||||||
$entries[] = $_GET[Q_DB]->getEntryByKey($_GET[Q_KEY]);
|
$entries[] = $this->getDB()->getEntryByKey($_GET[Q_KEY]);
|
||||||
if (isset($_GET['astext'])) {
|
if (isset($_GET['astext'])) {
|
||||||
$bibdisplay = new BibtexDisplay();
|
$bibdisplay = new BibtexDisplay();
|
||||||
$bibdisplay->setEntries($entries);
|
$bibdisplay->setEntries($entries);
|
||||||
|
|||||||
Reference in New Issue
Block a user