isso.php 1.7 KB

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