]> git.immae.eu Git - github/shaarli/Shaarli.git/blame_incremental - plugins/isso/isso.php
doc: server config: basic usage of robots.txt/HTML robots meta-tag/crawler control...
[github/shaarli/Shaarli.git] / plugins / isso / isso.php
... / ...
CommitLineData
1<?php
2
3/**
4 * Plugin Isso.
5 */
6
7use Shaarli\Config\ConfigManager;
8
9/**
10 * Display an error everywhere if the plugin is enabled without configuration.
11 *
12 * @param $conf ConfigManager instance
13 *
14 * @return mixed - linklist data with Isso plugin.
15 */
16function isso_init($conf)
17{
18 $issoUrl = $conf->get('plugins.ISSO_SERVER');
19 if (empty($issoUrl)) {
20 $error = t('Isso plugin error: '.
21 'Please define the "ISSO_SERVER" setting in the plugin administration page.');
22 return array($error);
23 }
24}
25
26/**
27 * Render linklist hook.
28 * Will only display Isso comments on permalinks.
29 *
30 * @param $data array List of links
31 * @param $conf ConfigManager instance
32 *
33 * @return mixed - linklist data with Isso plugin.
34 */
35function hook_isso_render_linklist($data, $conf)
36{
37 $issoUrl = $conf->get('plugins.ISSO_SERVER');
38 if (empty($issoUrl)) {
39 return $data;
40 }
41
42 // Only display comments for permalinks.
43 if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) {
44 $link = reset($data['links']);
45 $issoHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html');
46
47 $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']);
48 $data['plugin_end_zone'][] = $isso;
49
50 // Hackish way to include this CSS file only when necessary.
51 $data['plugins_includes']['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css';
52 }
53
54 return $data;
55}
56
57/**
58 * This function is never called, but contains translation calls for GNU gettext extraction.
59 */
60function isso_dummy_translation()
61{
62 // meta
63 t('Let visitor comment your shaares on permalinks with Isso.');
64 t('Isso server URL (without \'http://\')');
65}