action.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Icons Action Plugin
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  7. * @copyright (C) 2015-2016, Giuseppe Di Terlizzi
  8. */
  9. // must be run within Dokuwiki
  10. if(!defined('DOKU_INC')) die();
  11. /**
  12. * Class Icons Action Plugin
  13. *
  14. * Add external CSS file to DokuWiki
  15. */
  16. class action_plugin_icons extends DokuWiki_Action_Plugin {
  17. /**
  18. * Register events
  19. *
  20. * @param Doku_Event_Handler $controller
  21. */
  22. public function register(Doku_Event_Handler $controller) {
  23. $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_hookcss');
  24. }
  25. /**
  26. * Event handler
  27. *
  28. * @param Doku_Event &$event
  29. */
  30. public function _hookcss(Doku_Event &$event, $param) {
  31. $font_icons = array();
  32. if ($this->getConf('loadFontAwesome')) {
  33. $font_icons[] = $this->getConf('fontAwesomeURL');
  34. }
  35. if ($this->getConf('loadTypicon')) {
  36. $font_icons[] = $this->getConf('typiconURL');
  37. }
  38. foreach ($font_icons as $font_icon) {
  39. $event->data['link'][] = array(
  40. 'type' => 'text/css',
  41. 'rel' => 'stylesheet',
  42. 'href' => $font_icon);
  43. }
  44. }
  45. }