forked from houshuang/folders2web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sbibtex.php
39 lines (33 loc) · 1.17 KB
/
sbibtex.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/*
Plugin Name: SBibtex
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: 0.1
Author: Stian Haklev
Author URI: http://URI_Of_The_Plugin_Author
License: GPL2
*/
function filter_bibtex($text) {
$pattern = '/\\[\\@(.*)\\]/sU';
preg_match_all($pattern, $text, $hits);
if($hits[0][0]) { // only load bibtex file if there are some citations
$json =file_get_contents("/home/houshuan/public_html/wiki/lib/plugins/dokuresearchr/json.tmp");
$t = json_decode($json,true);
foreach($hits[1] as $hit) {
$entry = $t[$hit];
if($entry[1] == ""){
$text = str_replace('[@' . $hit . ']',"<a href=http://wiki/ref:".$hit.">".$hit."</a>",$text);
} else {
$text = str_replace('[@' . $hit . ']',"<span class='tooltip_winlike'><a href='/wiki/ref:" . $hit . "'>".$entry[0].", ".$entry[1]."</u></a><span class=\"tip\">".$entry[2]."</span></span></span>",$text);
}
}
return $text;
}
}
function add_my_stylesheet() {
wp_enqueue_style( 'sbibtex', WP_PLUGIN_URL .'/sbibtex/sbibtex.css');
}
add_filter ( 'the_content', 'filter_bibtex');
add_action('wp_print_styles', 'add_my_stylesheet');
?>