15
15
require_once (DOKU_PLUGIN .'syntax.php ' );
16
16
17
17
class syntax_plugin_cloud extends DokuWiki_Syntax_Plugin {
18
+ protected $ knownFlags = array ('showCount ' );
18
19
19
20
function getType () { return 'substition ' ; }
20
21
function getPType () { return 'block ' ; }
@@ -37,19 +38,31 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
37
38
38
39
list ($ num , $ ns ) = explode ('> ' , $ match , 2 );
39
40
list ($ junk , $ num ) = explode (': ' , $ num , 2 );
41
+ $ flags = null ;
42
+ if (preg_match ('/\[.*\]/ ' , $ junk , $ flags ) === 1 ) {
43
+ $ flags = trim ($ flags [0 ], '[] ' );
44
+ $ found = explode (', ' , $ flags );
45
+ $ flags = array ();
46
+ foreach ($ found as $ flag ) {
47
+ if (in_array ($ flag , $ this ->knownFlags )) {
48
+ // Actually we just set flags as present
49
+ // Later we might add values to flags like key=value pairs
50
+ $ flags [$ flag ] = true ;
51
+ }
52
+ }
53
+ }
40
54
41
55
if (!is_numeric ($ num )) $ num = 50 ;
42
56
if (!is_null ($ ns )) $ namespaces = explode ('| ' , $ ns );
43
57
else $ namespaces = null ;
44
58
45
- return array ($ type , $ num , $ namespaces );
59
+ return array ($ type , $ num , $ namespaces, $ flags );
46
60
}
47
61
48
62
function render ($ mode , Doku_Renderer $ renderer , $ data ) {
49
63
global $ conf ;
50
64
51
- list ($ type , $ num , $ namespaces ) = $ data ;
52
-
65
+ list ($ type , $ num , $ namespaces , $ flags ) = $ data ;
53
66
if ($ mode == 'xhtml ' ) {
54
67
55
68
if ($ type == 'tag ' ) { // we need the tag helper plugin
@@ -122,6 +135,9 @@ function render($mode, Doku_Renderer $renderer, $data) {
122
135
}
123
136
}
124
137
138
+ if ($ flags ['showCount ' ] === true ) {
139
+ $ name .= '( ' .$ size .') ' ;
140
+ }
125
141
$ renderer ->doc .= DOKU_TAB . '<a href=" ' . $ link . '" class=" ' . $ class .'" '
126
142
.' title=" ' . $ title . '"> ' . hsc ($ name ) . '</a> ' . DOKU_LF ;
127
143
}
0 commit comments