action.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, '_popup_button', array ());
  25. }
  26. /**
  27. * Event handler
  28. *
  29. * @param Doku_Event &$event
  30. */
  31. public function _hookcss(Doku_Event &$event, $param) {
  32. $font_icons = array();
  33. if ($this->getConf('loadFontAwesome')) {
  34. $font_icons[] = $this->getConf('fontAwesomeURL');
  35. }
  36. if ($this->getConf('loadTypicon')) {
  37. $font_icons[] = $this->getConf('typiconURL');
  38. }
  39. if ($this->getConf('loadFontlinux')) {
  40. $font_icons[] = $this->getConf('fontlinuxURL');
  41. }
  42. foreach ($font_icons as $font_icon) {
  43. $event->data['link'][] = array(
  44. 'type' => 'text/css',
  45. 'rel' => 'stylesheet',
  46. 'href' => $font_icon);
  47. }
  48. }
  49. }