monperrus/bibtexbrowser — pull request #4 by mguillau (2013-02-28 17:53:30+00:00)
Title: ICONS option

Introduces the ICONS option, which is a json-encoded associative array to provide source urls for images that should replace the usual [bib], [pdf], etc links.

e.g:
```
function e2i($e) { return "icons/".$e.".png"; }
$icons = json_encode(array("pdf" => e2i("pdf"), "bib" => e2i("bib"), "doi" => e2i("doi"), "url" => e2i("url"), "slides" => e2i("slides"), "poster" => e2i("slides"), "gsc" => e2i("google_scholar") ));
@define('ICONS',$icons);
```

the idea is to use a function getIconOrTxt(key[,txt]) which checks if the key exists in the associative array to decide whether the image or text should be printed. The text that is printed is by default the same as the key, but it can be changed by passing a second argument.

getLink(bibfield[,key[,txt]]) checks if the bibfield exists in the bib entry before calling getIconOrTxt(key,txt). If txt is not provided, it defaults to key, and if key is not provided, it defaults to bibfield.

there are some specialized cases, when the url is a function of the field value (google scholar url from goog scholar id, doi url from doi)

added a default CSS style for the icons.