7 use Shaarli\Config\ConfigManager
;
8 use Shaarli\Plugin\PluginManager
;
9 use Shaarli\Render\TemplatePage
;
12 * Display an error everywhere if the plugin is enabled without configuration.
14 * @param $conf ConfigManager instance
16 * @return mixed - linklist data with Isso plugin.
18 function isso_init($conf)
20 $issoUrl = $conf->get('plugins.ISSO_SERVER');
21 if (empty($issoUrl)) {
22 $error = t('Isso plugin error: '.
23 'Please define the "ISSO_SERVER" setting in the plugin administration page.');
29 * Render linklist hook.
30 * Will only display Isso comments on permalinks.
32 * @param $data array List of links
33 * @param $conf ConfigManager instance
35 * @return mixed - linklist data with Isso plugin.
37 function hook_isso_render_linklist($data, $conf)
39 $issoUrl = $conf->get('plugins.ISSO_SERVER');
40 if (empty($issoUrl)) {
44 // Only display comments for permalinks.
45 if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) {
46 $link = reset($data['links']);
47 $issoHtml = file_get_contents(PluginManager
::$PLUGINS_PATH . '/isso/isso.html');
49 $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']);
50 $data['plugin_end_zone'][] = $isso;
52 $button = '<span><a href="'. ($data['_BASE_PATH_'] ?? '') . '/shaare/%s#isso-thread">';
53 // For the default theme we use a FontAwesome icon which is better than an image
54 if ($conf->get('resource.theme') === 'default') {
55 $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
57 $button .= '<img class="linklist-plugin-icon" src="'. $data['_ROOT_PATH_'].'/plugins/isso/comment.png" ';
58 $button .= 'title="Comment on this shaare" alt="Comments" />';
60 $button .= '</a></span>';
61 foreach ($data['links'] as &$value) {
62 $commentLink = sprintf($button, $value['shorturl']);
63 $value['link_plugin'][] = $commentLink;
71 * When linklist is displayed, include isso CSS file.
73 * @param array $data - header data.
75 * @return mixed - header data with isso CSS file added.
77 function hook_isso_render_includes($data)
79 if ($data['_PAGE_'] == TemplatePage
::LINKLIST
) {
80 $data['css_files'][] = PluginManager
::$PLUGINS_PATH . '/isso/isso.css';
87 * This function is never called, but contains translation calls for GNU gettext extraction.
89 function isso_dummy_translation()
92 t('Let visitor comment your shaares on permalinks with Isso.');
93 t('Isso server URL (without \'http://\')');