aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/isso/isso.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-10-18 08:14:09 +0200
committerGitHub <noreply@github.com>2016-10-18 08:14:09 +0200
commitc1c21028503f2c05206481b2b0cb7ac8d6c16a71 (patch)
treebe74b08810c6160ab0e85863febd9605201b7ad9 /plugins/isso/isso.php
parent8406a4b670957b7d0450f6ea5e4f2e61c7114e8f (diff)
parentbf26e7ebcb5ee69523b93a5ec7b7a65b39acb916 (diff)
downloadShaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.tar.gz
Shaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.tar.zst
Shaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.zip
Merge pull request #651 from ArthurHoaro/plugin-isso2
Isso comments plugin
Diffstat (limited to 'plugins/isso/isso.php')
-rw-r--r--plugins/isso/isso.php54
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 */
15function 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 */
34function 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}