Documentation
This function is called by the
RenderPlugin to implement the REST handler
for the hierarchy browsers.
Parameters
- web: name of the web where to extract the hierarchy from, defaults to BASEWEB
- root: top category inside the hierarchy to start extracting information from, defaults to TopCategory
- exclude: pattern of categories to be excluded from the tree
- depth: number of levels to extract, defaults to 2
- format: one of "browser", "sidebar", or "editor", defaults to "browser"
- open: categories to be expanded
- hidenull: hides empty categories
- nrleafs: list of
cat:count
items that specify the number of leafs per category; these values are used instead of computing them by HIERARCHY itself
- nrtopics: list of
cat:count
items that specify the number of topics per category; these values are used instead of computing them by HIERARCHY itself
Implementation
%STARTINCLUDE%[
%HIERARCHY{
web="%IF{"defined web" then="%web%" else="%BASEWEB%"}%"
top="%IF{"defined root" then="%root%" else="TopCategory"}%"
depth="%IF{"defined depth" then="%depth%"}%"
exclude="%IF{"defined root" then="%root%" else="TopCategory"}%%IF{"defined exclude" then="|%exclude%"}%"
hidenull="%IF{"defined hidenull" then="%hidenull%" else="off"}%"
%IF{"defined nrleafs" then="nrleafs=\"%nrleafs%\""}%
%IF{"defined nrtopics" then="nrtopics=\"%nrtopics%\""}%
%IF{"defined search" then="hideclosed=\"on\""}%
open="%IF{"defined root"
then="%root%"
else="TopCategory"
}%%IF{"defined open"
then=", %open%"
}%%IF{"defined search"
then="$percntCATINFO{
web=\"%IF{"defined web" then="%web%" else="%BASEWEB%"}%\"
include=\".*%search%.*\"
matchcase=\"off\"
matchattr=\"title\"
header=\", \"
format=\"$topic\"
separator=\", \"
}$percnt"
}%"
separator=",$n"
format="$indent{
$indent \"text\": \"%DBCALL{
"%WEB%.%TOPIC%"
section="%IF{"not isempty format" then="%format%" else="browser"}%"
depth="%depth%"
fieldname="%fieldname%"
}%\",
$indent \"expanded\": $isexpanded,
$indent \"hasChildren\": $subcats,
$indent \"id\": \"$name\",
$indent \"children\": [$children]
$indent}"
}%
]%STOPINCLUDE%
Browser format
%STARTSECTION{"browser"}%<a href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' />$percntENCODE{\"$title\" type=\"quote\"}$percnt</a>$percntIF{
\"'$cyclic' = '1'\"
then=\" <span class='foswikiAlert'>C</span>\"}$percnt$percntIF{
\"'$count' != '0'\"
then=\" ($count)\"
}$percnt%ENDSECTION{"browser"}%
Plain format
%STARTSECTION{"plain"}%<a href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"plain"}%
Sidebar format
%STARTSECTION{"sidebar"}%<a class='clsCategoryLink' style='background-image:url($icon);' href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"sidebar"}%
Editor format
%STARTSECTION{"editor"}%<a href='#' class='$name clsCategory {depth:$depth}' title='$title' value='$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"editor"}%
Leaf select format
%STARTSECTION{"leafselect"}%$percntIF{\"$leafs>0 and $depth <= %depth%\"
then=\"<img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink>\"
else=\"<a href='#' title='$title' value='$name' class='$name clsCategory {depth:$depth}'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>\"
}%%ENDSECTION{"leafselect"}%
Solr facet format
%STARTSECTION{"solrfacet"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$title' value='category:$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a> $percntIF{\"$count>0\" then=\"($count)\"}$percnt%ENDSECTION{"solrfacet"}%
Solr facet format (no counts)
%STARTSECTION{"solrfacet_nocounts"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$title' value='category:$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"solrfacet_nocounts"}%
Test
Plain
[
{
"text": "Intranet",
"expanded": false,
"hasChildren": 4,
"id": "IntranetDirectory",
"children": []
},
{
"text": "TestCategory",
"expanded": false,
"hasChildren": 3,
"id": "TestCategory",
"children": []
},
{
"text": "TestCategory5",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory5",
"children": []
}
]
Browser
[
{
"text": "Intranet (1)",
"expanded": false,
"hasChildren": 4,
"id": "IntranetDirectory",
"children": []
},
{
"text": "TestCategory (1)",
"expanded": false,
"hasChildren": 3,
"id": "TestCategory",
"children": []
},
{
"text": "TestCategory5",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory5",
"children": []
}
]
Editor
[
{
"text": "Intranet",
"expanded": false,
"hasChildren": 4,
"id": "IntranetDirectory",
"children": []
},
{
"text": "TestCategory",
"expanded": false,
"hasChildren": 3,
"id": "TestCategory",
"children": []
}
]
Leaf select
[
{
"text": "TestCategory12",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory12",
"children": []
},
{
"text": "TestCategory4",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory4",
"children": []
}
]
Solr facet
[
{
"text": "Intranet (1)",
"expanded": false,
"hasChildren": 4,
"id": "IntranetDirectory",
"children": []
},
{
"text": "TestCategory (1)",
"expanded": false,
"hasChildren": 3,
"id": "TestCategory",
"children": []
},
{
"text": "TestCategory5 ",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory5",
"children": []
}
]
Calls to 'RenderHierarchyAsJSON'
Copyright
© 2008-2013 Michael Daum
http://michaeldaumconsulting.com
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read the
LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.