1<?php 2 3 4// must be run within Dokuwiki 5use ComboStrap\Analytics; 6use ComboStrap\PluginUtility; 7 8if (!defined('DOKU_INC')) die(); 9 10/** 11 * Class syntax_plugin_combo_analytics 12 * This class was just created to add syntax analytics 13 * to the metadata. 14 */ 15class syntax_plugin_combo_analytics extends DokuWiki_Syntax_Plugin 16{ 17 18 const TAG = "analytics"; 19 20 /** 21 * Syntax Type. 22 * @see DokuWiki_Syntax_Plugin::getType() 23 */ 24 function getType() 25 { 26 return 'formatting'; 27 } 28 29 /** 30 * How Dokuwiki will add P element 31 * 32 * * 'normal' - The plugin can be used inside paragraphs 33 * * 'block' - Open paragraphs need to be closed before plugin output - block should not be inside paragraphs 34 * * 'stack' - Special case. Plugin wraps other paragraphs. - Stacks can contain paragraphs 35 * 36 * @see DokuWiki_Syntax_Plugin::getPType() 37 */ 38 function getPType() 39 { 40 return 'normal'; 41 } 42 43 /** 44 * @return array 45 * Allow which kind of plugin inside 46 * 47 * array('container', 'baseonly', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs') 48 * 49 */ 50 function getAllowedTypes() 51 { 52 return array(); 53 } 54 55 function getSort() 56 { 57 return 201; 58 } 59 60 61 /** 62 * Create a pattern that will called this plugin 63 * 64 * @param string $mode 65 * @see Doku_Parser_Mode::connectTo() 66 */ 67 function connectTo($mode) 68 { 69 /** 70 * The instruction `calls` are not created via syntax 71 * but dynamically via {@link action_plugin_combo_pluginanalytics::_extract_plugin_info()} 72 */ 73 74 } 75 76 function postConnect() 77 { 78 79 /** 80 * The instruction `calls` are not created via syntax 81 * but dynamically via {@link action_plugin_combo_pluginanalytics::_extract_plugin_info()} 82 */ 83 84 } 85 86 function handle($match, $state, $pos, Doku_Handler $handler) 87 { 88 89 /** 90 * The instruction `calls` are not created via syntax 91 * but dynamically via {@link action_plugin_combo_pluginanalytics::_extract_plugin_info()} 92 */ 93 94 } 95 96 /** 97 * Render the output 98 * @param string $format 99 * @param Doku_Renderer $renderer 100 * @param array $data - what the function handle() return'ed 101 * @return boolean - rendered correctly? (however, returned value is not used at the moment) 102 * @see DokuWiki_Syntax_Plugin::render() 103 * 104 * 105 */ 106 function render($format, Doku_Renderer $renderer, $data) 107 { 108 109 if ($format == renderer_plugin_combo_analytics::RENDERER_FORMAT) { 110 111 /** @var renderer_plugin_combo_analytics $renderer */ 112 $state = $data[PluginUtility::STATE]; 113 if ($state == DOKU_LEXER_SPECIAL) { 114 $attributes = $data[PluginUtility::ATTRIBUTES]; 115 $renderer->stats[Analytics::SYNTAX_COUNT] = $attributes; 116 return true; 117 } 118 119 } 120 121 return false; 122 } 123 124 125} 126 127