action.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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, '_loadcss');
  24. $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, '_toolbarButton', array ());
  25. $controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, '_popularity');
  26. }
  27. /**
  28. * Event handler
  29. *
  30. * @param Doku_Event &$event
  31. */
  32. public function _toolbarButton(Doku_Event $event, $param) {
  33. $event->data[] = array(
  34. 'type' => 'mediapopup',
  35. 'title' => 'Icons',
  36. 'icon' => '../../tpl/dokuwiki/images/logo.png',
  37. 'url' => 'lib/plugins/icons/exe/popup.php?ns=',
  38. 'name' => 'icons',
  39. 'options'=> 'width=800,height=600,left=20,top=20,toolbar=no,menubar=no,scrollbars=yes,resizable=yes',
  40. 'block' => false
  41. );
  42. }
  43. /**
  44. * Event handler
  45. *
  46. * @param Doku_Event &$event
  47. */
  48. public function _popularity(Doku_Event $event, $param) {
  49. $plugin_info = $this->getInfo();
  50. $event->data['icon']['version'] = $plugin_info['date'];
  51. }
  52. /**
  53. * Event handler
  54. *
  55. * @param Doku_Event &$event
  56. */
  57. public function _loadcss(Doku_Event &$event, $param) {
  58. global $conf;
  59. $base_url = DOKU_BASE . 'lib/plugins/icons/assets';
  60. $font_icons = array();
  61. # Load Font-Awesome (skipped for Bootstrap3 template)
  62. if ($this->getConf('loadFontAwesome') && $conf['template'] !== 'bootstrap3') {
  63. $font_icons[] = "$base_url/font-awesome/css/font-awesome.min.css";
  64. }
  65. # Load Typicons
  66. if ($this->getConf('loadTypicons')) {
  67. $font_icons[] = "$base_url/typicons/typicons.min.css";
  68. }
  69. # Load RPG-Awesome
  70. if ($this->getConf('loadRpgAwesome')) {
  71. $font_icons[] = "$base_url/rpg-awesome/css/rpg-awesome.min.css";
  72. }
  73. # Load Font Linux
  74. if ($this->getConf('loadFontlinux')) {
  75. $font_icons[] = "$base_url/font-linux/font-linux.css";
  76. }
  77. # Load Material Icons
  78. if ($this->getConf('loadMaterialIcons')) {
  79. $font_icons[] = "$base_url/material-icons/material-icons.css";
  80. }
  81. foreach ($font_icons as $font_icon) {
  82. $event->data['link'][] = array(
  83. 'type' => 'text/css',
  84. 'rel' => 'stylesheet',
  85. 'href' => $font_icon);
  86. }
  87. }
  88. }