Skip to content

Commit

Permalink
Merge pull request #56 from LarsGit223/master
Browse files Browse the repository at this point in the history
Added syntax tag option 'showCount'.
  • Loading branch information
LarsGit223 authored Aug 5, 2017
2 parents 4710604 + af1dbc4 commit 2392286
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
require_once(DOKU_PLUGIN.'syntax.php');

class syntax_plugin_cloud extends DokuWiki_Syntax_Plugin {
protected $knownFlags = array('showCount');
protected $stopwords = null;

/**
Expand Down Expand Up @@ -45,19 +46,31 @@ function handle($match, $state, $pos, Doku_Handler $handler) {

list($num, $ns) = explode('>', $match, 2);
list($junk, $num) = explode(':', $num, 2);
$flags = null;
if (preg_match ('/\[.*\]/', $junk, $flags) === 1) {
$flags = trim ($flags [0], '[]');
$found = explode(',', $flags);
$flags = array();
foreach ($found as $flag) {
if (in_array($flag, $this->knownFlags)) {
// Actually we just set flags as present
// Later we might add values to flags like key=value pairs
$flags [$flag] = true;
}
}
}

if (!is_numeric($num)) $num = 50;
if(!is_null($ns)) $namespaces = explode('|', $ns);
else $namespaces = null;

return array($type, $num, $namespaces);
return array($type, $num, $namespaces, $flags);
}

function render($mode, Doku_Renderer $renderer, $data) {
global $conf;

list($type, $num, $namespaces) = $data;

list($type, $num, $namespaces, $flags) = $data;
if ($mode == 'xhtml') {

if ($type == 'tag') { // we need the tag helper plugin
Expand Down Expand Up @@ -130,6 +143,9 @@ function render($mode, Doku_Renderer $renderer, $data) {
}
}

if ($flags ['showCount'] === true) {
$name .= '('.$size.')';
}
$renderer->doc .= DOKU_TAB . '<a href="' . $link . '" class="' . $class .'"'
.' title="' . $title . '">' . hsc($name) . '</a>' . DOKU_LF;
}
Expand Down

0 comments on commit 2392286

Please sign in to comment.