action.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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-2018, 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('loadTypicons')) {
  36. $font_icons[] = $this->getConf('typiconsURL');
  37. }
  38. if ($this->getConf('loadFontlinux')) {
  39. $font_icons[] = $this->getConf('fontlinuxURL');
  40. }
  41. foreach ($font_icons as $font_icon) {
  42. $event->data['link'][] = array(
  43. 'type' => 'text/css',
  44. 'rel' => 'stylesheet',
  45. 'href' => $font_icon);
  46. }
  47. }
  48. }