diff options
Diffstat (limited to 'plugins/isso/isso.php')
-rw-r--r-- | plugins/isso/isso.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php new file mode 100644 index 00000000..ffb7cfac --- /dev/null +++ b/plugins/isso/isso.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Plugin Isso. | ||
5 | */ | ||
6 | |||
7 | /** | ||
8 | * Display an error everywhere if the plugin is enabled without configuration. | ||
9 | * | ||
10 | * @param $data array List of links | ||
11 | * @param $conf ConfigManager instance | ||
12 | * | ||
13 | * @return mixed - linklist data with Isso plugin. | ||
14 | */ | ||
15 | function isso_init($conf) | ||
16 | { | ||
17 | $issoUrl = $conf->get('plugins.ISSO_SERVER'); | ||
18 | if (empty($issoUrl)) { | ||
19 | $error = 'Isso plugin error: '. | ||
20 | 'Please define the "ISSO_SERVER" setting in the plugin administration page.'; | ||
21 | return array($error); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Render linklist hook. | ||
27 | * Will only display Isso comments on permalinks. | ||
28 | * | ||
29 | * @param $data array List of links | ||
30 | * @param $conf ConfigManager instance | ||
31 | * | ||
32 | * @return mixed - linklist data with Isso plugin. | ||
33 | */ | ||
34 | function hook_isso_render_linklist($data, $conf) | ||
35 | { | ||
36 | $issoUrl = $conf->get('plugins.ISSO_SERVER'); | ||
37 | if (empty($issoUrl)) { | ||
38 | return $data; | ||
39 | } | ||
40 | |||
41 | // Only display comments for permalinks. | ||
42 | if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) { | ||
43 | $link = reset($data['links']); | ||
44 | $isso_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html'); | ||
45 | |||
46 | $isso = sprintf($isso_html, $issoUrl, $issoUrl, $link['linkdate'], $link['linkdate']); | ||
47 | $data['plugin_end_zone'][] = $isso; | ||
48 | |||
49 | // Hackish way to include this CSS file only when necessary. | ||
50 | $data['plugins_includes']['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css'; | ||
51 | } | ||
52 | |||
53 | return $data; | ||
54 | } | ||