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