Browse Source

adds support for customizing the title

pull/28/merge
Martin Monperrus 10 years ago
parent
commit
62a9c0b3b3
  1. 12
      bibtexbrowser-documentation.wiki
  2. 40
      bibtexbrowser.php

12
bibtexbrowser-documentation.wiki

@ -235,7 +235,7 @@ The default academic mode creates four sections:
- workshop papers (for entries containing "workshop" in the field booktitle)
- others
You may create your own one in ''bibtexbrowser.local.php'' (see also "By creating a bibtexbrowser.local.php" below):
You may create your own one in ''bibtexbrowser.local.php'' (see also "creating a bibtexbrowser.local.php" below):
<pre>
define('BIBLIOGRAPHYSECTIONS','my_sectioning');
function my_sectioning() {
@ -265,6 +265,16 @@ return
}
</pre>
====How to use the change the title of the result page?====
You may create your own title function in ''bibtexbrowser.local.php'' (see "creating a bibtexbrowser.local.php" below):
<pre>
define('BIBLIOGRAPHYTITLE','my_title_function');
function my_title_function($query) {
return "Publications of the Nuclear Research Group";
}
</pre>
See function DefaultBibliographyTitle for inspiration.
====How to get the individual bib pages embedded as well?====
''define('BIBTEXBROWSER_URL',""); ''

40
bibtexbrowser.php

@ -55,6 +55,7 @@ function bibtexbrowser_configure($key, $value) {
@define('BIBTEXBROWSER_BIB_IN_NEW_WINDOW',false);
@define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function
@define('BIBLIOGRAPHYSECTIONS','DefaultBibliographySections');// this is the name of a function
@define('BIBLIOGRAPHYTITLE','DefaultBibliographyTitle');// this is the name of a function
// can we load bibtex files on external servers?
@define('BIBTEXBROWSER_LOCAL_BIB_ONLY', true);
@ -1746,6 +1747,23 @@ function _DefaultBibliographySections() {
return $function();
}
/** encapsulates the user-defined sections. @nodoc */
function _DefaultBibliographyTitle($query) {
$function = BIBLIOGRAPHYTITLE;
return $function($query);
}
function DefaultBibliographyTitle($query) {
$result = 'Publications in '.$_GET[Q_FILE];
if (isset($query['all'])) {
unset($query['all']);
}
if (count($query)>0) {
$result .= ' - '.query2title($query);
}
return $result;
}
/** compares two instances of BibEntry by modification time
*/
function compare_bib_entry_by_mtime($a, $b)
@ -2533,13 +2551,9 @@ function query2title(&$query) {
}
$headers[$k] = __(ucwords($k)).': '.ucwords(htmlspecialchars($v));
}
// special cases
if (isset($headers[Q_ALL])) $headers[Q_ALL] = __('Publications in').' '.htmlspecialchars($_GET[Q_FILE]);
if (isset($headers[Q_AUTHOR])) $headers[Q_AUTHOR] = __('Publications of')
.' '.htmlspecialchars($_GET[Q_AUTHOR]);
return join(' &amp; ',$headers);
}
return join(' &amp; ',$headers);
}
} // if (!function_exists('query2title'))
/** displays the latest modified bibtex entries.
usage:
@ -2686,8 +2700,12 @@ class SimpleDisplay {
return $this->entries;
}
function setTitle($title) { $this->title = $title; return $this; }
function getTitle() { return @$this->title ; }
function setQuery($query) {
$this->query = $query;
}
function getTitle() {
return _DefaultBibliographyTitle($this->query);
}
/** Displays a set of bibtex entries in an HTML table */
function display() {
@ -2783,10 +2801,8 @@ function nonExistentBibEntryError() {
/** handles queries with no result */
class NotFoundDisplay {
function setTitle($title) { $this->title = $title; return $this; }
function getTitle() { return @$this->title ; }
function display() {
echo '<span class="count">'.__('No results').'</span>';
echo '<span class="count">'.__('Sorry, no results for this query').'</span>';
}
}
/** displays the publication records sorted by publication types (as configured by constant BIBLIOGRAPHYSECTIONS).
@ -3726,7 +3742,7 @@ class PagedDisplay {
}
}
function setQuery($query = array()) {
function setQuery($query) {
$this->query = $query;
}

Loading…
Cancel
Save