]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - plugins/isso/isso.php
namespacing: \Shaarli\Router
[github/shaarli/Shaarli.git] / plugins / isso / isso.php
CommitLineData
bf26e7eb
A
1<?php
2
3/**
4 * Plugin Isso.
5 */
6
12266213 7use Shaarli\Config\ConfigManager;
a932f486 8use Shaarli\Router;
12266213 9
bf26e7eb
A
10/**
11 * Display an error everywhere if the plugin is enabled without configuration.
12 *
bf26e7eb
A
13 * @param $conf ConfigManager instance
14 *
15 * @return mixed - linklist data with Isso plugin.
16 */
17function isso_init($conf)
18{
19 $issoUrl = $conf->get('plugins.ISSO_SERVER');
20 if (empty($issoUrl)) {
12266213
A
21 $error = t('Isso plugin error: '.
22 'Please define the "ISSO_SERVER" setting in the plugin administration page.');
bf26e7eb
A
23 return array($error);
24 }
25}
26
27/**
28 * Render linklist hook.
29 * Will only display Isso comments on permalinks.
30 *
31 * @param $data array List of links
32 * @param $conf ConfigManager instance
33 *
34 * @return mixed - linklist data with Isso plugin.
35 */
36function hook_isso_render_linklist($data, $conf)
37{
38 $issoUrl = $conf->get('plugins.ISSO_SERVER');
39 if (empty($issoUrl)) {
40 return $data;
41 }
42
43 // Only display comments for permalinks.
44 if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) {
45 $link = reset($data['links']);
01878a75 46 $issoHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html');
bf26e7eb 47
d592daea 48 $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']);
bf26e7eb 49 $data['plugin_end_zone'][] = $isso;
0e54e105
A
50 } else {
51 $button = '<span><a href="?%s#isso-thread">';
52 // For the default theme we use a FontAwesome icon which is better than an image
53 if ($conf->get('resource.theme') === 'default') {
54 $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
55 } else {
56 $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" ';
57 $button .= 'title="Comment on this shaare" alt="Comments" />';
58 }
59 $button .= '</a></span>';
60 foreach ($data['links'] as &$value) {
61 $commentLink = sprintf($button, $value['shorturl']);
62 $value['link_plugin'][] = $commentLink;
63 }
64 }
bf26e7eb 65
0e54e105
A
66 return $data;
67}
68
69/**
70 * When linklist is displayed, include isso CSS file.
71 *
72 * @param array $data - header data.
73 *
74 * @return mixed - header data with isso CSS file added.
75 */
76function hook_isso_render_includes($data)
77{
78 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
79 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css';
bf26e7eb
A
80 }
81
82 return $data;
83}
12266213
A
84
85/**
86 * This function is never called, but contains translation calls for GNU gettext extraction.
87 */
88function isso_dummy_translation()
89{
90 // meta
91 t('Let visitor comment your shaares on permalinks with Isso.');
92 t('Isso server URL (without \'http://\')');
93}