flag.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Plugin Icons: Flag helper
  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. require_once(dirname(__FILE__).'/icon.php');
  12. class syntax_plugin_icons_flag extends syntax_plugin_icons_icon {
  13. const IS_ICON = true;
  14. const IS_FONT_ICON = false;
  15. protected $pattern = '{{flag>.+?}}';
  16. public static function makePath($icon, $size, $base_url) {
  17. if ($translation = plugin_load('helper', 'translation')) {
  18. $translation_url = rtrim(DOKU_BASE, '/') . '/lib/plugins/translation/flags';
  19. $translation_path = rtrim(DOKU_PLUGIN, '/') . '/translation/flags';
  20. if (file_exists("$translation_path/$icon.gif")) {
  21. return "$translation_url/$icon.gif";
  22. }
  23. if (file_exists("$translation_path/more/$icon.gif")) {
  24. return "$translation_url/more/$icon.gif";
  25. }
  26. }
  27. return "$base_url/$icon-icon.png";
  28. }
  29. }