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?====
|
||||
Add in ''bibtexbrowser.local.php'':
|
||||
<pre>
|
||||
<?
|
||||
<?php
|
||||
global $BIBTEXBROWSER_LANG;
|
||||
$BIBTEXBROWSER_LANG=array();
|
||||
$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?====
|
||||
Add in ''bibtexbrowser.local.php'':
|
||||
<pre>
|
||||
<?
|
||||
<?php
|
||||
// or any valid query: year=2010, author=Jane, etc.
|
||||
@define('BIBTEXBROWSER_DEFAULT_FRAME','all');
|
||||
?>
|
||||
@@ -306,7 +306,7 @@ Add in ''bibtexbrowser.local.php'':
|
||||
|
||||
====How to order a list of Bibtex entries?====
|
||||
<pre>
|
||||
<?
|
||||
<?php
|
||||
$_GET['library']=1;
|
||||
require_once('bibtexbrowser.php');
|
||||
$db = new BibDataBase();
|
||||
@@ -340,13 +340,27 @@ define('BIBTEXBROWSER_ROBOTS_NOINDEX', true);
|
||||
|
||||
====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>
|
||||
$test_data = fopen('php://memory','x+');
|
||||
fwrite($test_data, "@book{aKey,title={A Book},author={Jan Doe},publisher={Springer},year=2009}\n");
|
||||
fseek($test_data,0);
|
||||
$this->btb = new BibDataBase();
|
||||
$this->btb->update_internal("inline", $test_data);
|
||||
define("BIBTEXBROWSER_MAIN", 'DynamicDispatcher');
|
||||
</pre>
|
||||
|
||||
and then in ''bibtexbrowser.after.php'':
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
+23
-13
@@ -2233,13 +2233,12 @@ usage:
|
||||
$_GET['all']=1;
|
||||
include( 'bibtexbrowser.php' );
|
||||
setDB();
|
||||
new IndependentYearMenu();
|
||||
new IndependentYearMenu($_GET[Q_DB]);
|
||||
</pre>
|
||||
*/
|
||||
class IndependentYearMenu {
|
||||
function IndependentYearMenu() {
|
||||
if (!isset($_GET[Q_DB])) {die('Did you forget to call setDB() before instantiating this class?');}
|
||||
$yearIndex = $_GET[Q_DB]->yearIndex();
|
||||
function IndependentYearMenu($db) {
|
||||
$yearIndex = $db->yearIndex();
|
||||
echo '<div id="yearmenu">Year: ';
|
||||
$formatedYearIndex = array();
|
||||
$formatedYearIndex[] = '<a '.makeHref(array(Q_YEAR=>'.*')).'>All</a>';
|
||||
@@ -2329,7 +2328,7 @@ class MenuManager {
|
||||
}
|
||||
|
||||
/** sets the database that is used to create the menu */
|
||||
function setDB(&$db) {
|
||||
function setDB($db) {
|
||||
$this->db =$db;
|
||||
return $this;
|
||||
}
|
||||
@@ -3947,8 +3946,22 @@ class Dispatcher {
|
||||
*/
|
||||
var $wrapper = BIBTEXBROWSER_DEFAULT_TEMPLATE;
|
||||
|
||||
/** The BibDataBase object */
|
||||
var $db = null;
|
||||
|
||||
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() {
|
||||
// are we in test mode, or libray mode
|
||||
// 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!'); }
|
||||
|
||||
// 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?
|
||||
// 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)
|
||||
@@ -3988,7 +3998,7 @@ class Dispatcher {
|
||||
unset($this->query[Q_ALL]);
|
||||
}
|
||||
|
||||
$selectedEntries = $_GET[Q_DB]->multisearch($this->query);
|
||||
$selectedEntries = $this->getDB()->multisearch($this->query);
|
||||
|
||||
if (count($selectedEntries)==0) {
|
||||
$this->displayer = 'NotFoundDisplay';
|
||||
@@ -4080,7 +4090,7 @@ class Dispatcher {
|
||||
function year() {
|
||||
// we may want the latest
|
||||
if ($_GET[Q_YEAR]=='latest') {
|
||||
$years = $_GET[Q_DB]->yearIndex();
|
||||
$years = $this->getDB()->yearIndex();
|
||||
$_GET[Q_YEAR]=array_shift($years);
|
||||
}
|
||||
$this->query[Q_YEAR]=$_GET[Q_YEAR];
|
||||
@@ -4165,7 +4175,7 @@ class Dispatcher {
|
||||
|
||||
function menu() {
|
||||
$menu = createMenuManager();
|
||||
$menu->setDB($_GET[Q_DB]);
|
||||
$menu->setDB($this->getDB());
|
||||
$fun = $this->wrapper;
|
||||
$fun($menu);
|
||||
return 'END_DISPATCH';
|
||||
@@ -4195,8 +4205,8 @@ class Dispatcher {
|
||||
function key() {
|
||||
$entries = array();
|
||||
// case 1: this is a single key
|
||||
if ($_GET[Q_DB]->contains($_GET[Q_KEY])) {
|
||||
$entries[] = $_GET[Q_DB]->getEntryByKey($_GET[Q_KEY]);
|
||||
if ($this->getDB()->contains($_GET[Q_KEY])) {
|
||||
$entries[] = $this->getDB()->getEntryByKey($_GET[Q_KEY]);
|
||||
if (isset($_GET['astext'])) {
|
||||
$bibdisplay = new BibtexDisplay();
|
||||
$bibdisplay->setEntries($entries);
|
||||
|
||||
Reference in New Issue
Block a user