1<?php 2/** 3 * Mikio Syntax Plugin: Icon 4 * 5 * @link http://github.com/nomadjimbob/mikioplugin 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author James Collins <james.collins@outlook.com.au> 8 */ 9if (!defined('DOKU_INC')) { die(); 10} 11if (!defined('DOKU_PLUGIN')) { define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 12} 13 14require_once __DIR__ .'/core.php'; 15 16class syntax_plugin_mikioplugin_icon extends syntax_plugin_mikioplugin_core 17{ 18 public $tag = 'icon'; 19 public $hasEndTag = false; 20 21 // not declaring $options will return all options in the $data variable in lexer functions 22 public function getType() 23 { 24 return 'substition'; 25 } 26 public function getPType() 27 { 28 return 'normal'; 29 } 30 31 public function render_lexer_special(Doku_Renderer $renderer, $data) 32 { 33 global $MIKIO_ICONS; 34 35 if(is_array($MIKIO_ICONS) && count($MIKIO_ICONS) > 0) { 36 foreach($MIKIO_ICONS as $icon) { 37 if(isset($icon['name']) && strcasecmp($icon['name'], array_key_first($data)) == 0) { 38 if(isset($icon['insert'])) { 39 $insert = $icon['insert']; 40 $keys = array_keys($data); 41 $keys = array_pad($keys, 10, ''); 42 43 for($i = 1; $i < 10; $i++) { 44 $dollarIndex = '$' . $i; 45 if (empty($keys[$i]) === false) { 46 $insert = str_replace($dollarIndex, $keys[$i], $insert); 47 } else if(empty($icon[$dollarIndex]) === false) { 48 $insert = str_replace($dollarIndex, $icon[$dollarIndex], $insert); 49 } 50 } 51 52 $dir = ''; 53 if (isset($icon['dir']) === true) { 54 $dir = DOKU_BASE . 'lib/plugins/' . basename(dirname(__DIR__)) . '/icons/' . $icon['dir'] . '/'; 55 } 56 57 $insert = str_replace('$0', $dir, $insert); 58 $renderer->doc .= $insert; 59 } 60 61 break; 62 } 63 } 64 } 65 } 66} 67?>