isso.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Plugin Isso.
  4. */
  5. /**
  6. * Display an error everywhere if the plugin is enabled without configuration.
  7. *
  8. * @param $data array List of links
  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 = '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. $isso_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html');
  41. $isso = sprintf($isso_html, $issoUrl, $issoUrl, $link['linkdate'], $link['linkdate']);
  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. }