Permalink
Browse files

Discard space after &-symbol / Output error message when the result i…

…s empty
  • Loading branch information...
1 parent 5148541 commit 2adff9720223b19106f20d2e5f09638bfa19e754 @lupo49 lupo49 committed Aug 19, 2011
Showing with 26 additions and 7 deletions.
  1. +4 −3 helper.php
  2. +1 −0 lang/de/lang.php
  3. +1 −0 lang/en/lang.php
  4. +20 −4 syntax/count.php
View
@@ -296,16 +296,17 @@ function tagOccurences($tags, $ns = NULL) {
foreach($tags as $index => $tagname) {
// get pages for $tagname
$pages = $this->topic_idx[$tagname];
- $deleteID = false;
// $pages is null when non-existing tags are specified
if($pages != null) {
foreach($pages as $key => $page) {
+ $deleteID = false;
+
// check if the namespace of the current page is in a given namespace
if(getNS($page) != false && !in_array(getNS($page), $ns)) $deleteID = true;
- // condition for root namespace
- if(getNS($page) == false && in_array('.', $ns)) $deleteID = false;
+ // condition for root namespace
+ if(getNS($page) == false && !in_array('.', $ns)) $deleteID = true;
// remove the page in the array
if($deleteID) unset($pages[$key]);
View
@@ -11,6 +11,7 @@
$lang['topic'] = 'Thema';
$lang['rebuildindex'] = 'Tagindex neu aufbauen';
$lang['toolbar_icon'] = 'Tag-Syntax einfügen';
+$lang['empty_output'] = 'Leere Ausgabe';
$lang['missing_pagelistplugin'] = 'Ohne Pagelist Plugin können Themenlisten nicht angezeigt werden.';
View
@@ -11,6 +11,7 @@
$lang['topic'] = 'Topic';
$lang['rebuildindex'] = 'Rebuild Tagindex';
$lang['toolbar_icon'] = 'Insert Tag-Syntax';
+$lang['empty_output'] = 'Empty Output';
$lang['missing_pagelistplugin'] = 'The Pagelist Plugin must be installed for topic lists.';
View
@@ -48,6 +48,11 @@ function handle($match, $state, $pos, &$handler) {
$tags = $dump[0];
$allowedNamespaces = explode(' ', $dump[1]); // split given namespaces into an array
+ if($allowedNamespaces && $allowedNamespaces[0] == '') {
+ unset($allowedNamespaces[0]); // When exists, remove leading space after the delimiter
+ $allowedNamespaces = array_values(($allowedNamespaces));
+ }
+
if (!$tags) return false;
if(!($my = plugin_load('helper', 'tag'))) return false;
@@ -105,12 +110,23 @@ function render($mode, &$renderer, $data) {
$renderer->doc .= '<th class="'.$col.'">#</th>';
$renderer->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
- foreach($data as $key => $tag) {
- if($tag <= 0) continue;
+ // skip output, if the individual occurences of the tags is zero
+ // if the amount of tags with count == 0 is equal to the overall count of tags then skip output
+ $countTags = array_keys($data, 0);
+
+ if(sizeof($countTags) == sizeof($data)) {
+ // Skip output
$renderer->doc .= DOKU_TAB.'<tr>'.DOKU_LF.DOKU_TAB.DOKU_TAB;
- $renderer->doc .= DOKU_TAB.DOKU_TAB.'<td class="'.$class.'">'.$tl[$key].'</td>'.DOKU_LF;
- $renderer->doc .= DOKU_TAB.DOKU_TAB.'<td class="'.$class.'">'.$tag.'</td>'.DOKU_LF;
+ $renderer->doc .= DOKU_TAB.DOKU_TAB.'<td class="'.$class.'" colspan="2">'.$this->getLang('empty_output').'</td>'.DOKU_LF;
$renderer->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
+ } else {
+ foreach($data as $key => $tag) {
+ if($tag <= 0) continue; // don't display tags with zero occurences
+ $renderer->doc .= DOKU_TAB.'<tr>'.DOKU_LF.DOKU_TAB.DOKU_TAB;
+ $renderer->doc .= DOKU_TAB.DOKU_TAB.'<td class="'.$class.'">'.$tl[$key].'</td>'.DOKU_LF;
+ $renderer->doc .= DOKU_TAB.DOKU_TAB.'<td class="'.$class.'">'.$tag.'</td>'.DOKU_LF;
+ $renderer->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
+ }
}
$renderer->doc .= '</table>'.DOKU_LF;
}

0 comments on commit 2adff97

Please sign in to comment.