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="%web{default="%BASEWEB%"}%"
top="%root{default="TopCategory"}%"
depth="%depth{default="2"}%"
exclude="%root{default="TopCategory"}%%IF{"defined exclude" then="|%exclude%"}%"
hidenull="%hidenull{default="off"}%"%IF{"defined nrleafs"
then="nrleafs=\"%nrleafs%\""
}%%IF{"defined nrtopics"
then="nrtopics=\"%nrtopics%\""
}%%IF{"defined search"
then="hideclosed=\"on\""
}% open="%root{default="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="%format{default="browser"}%"
depth="%depth{default="2"}%"
fieldname="%fieldname%"
}%\",
$indent \"expanded\": $isexpanded,
$indent \"hasChildren\": $subcats,
$indent \"id\": \"$name\",
$indent \"children\": [$children]
$indent}"
}%
]%STOPINCLUDE%
%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"}%
%STARTSECTION{"plain"}%<a href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"plain"}%
%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"}%
%STARTSECTION{"editor"}%<a href='#' class='$name clsCategory {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' value='$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"editor"}%
%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='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' 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"}%
%STARTSECTION{"solrfacet"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' 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"}%
%STARTSECTION{"solrfacet_nocounts"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' 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
run test1
%STARTSECTION{"test1"}%
%DBCALL{"%TOPIC%" format="plain"}%
%ENDSECTION{"test1"}%
Browser
run test2
%STARTSECTION{"test2"}%
%DBCALL{"%TOPIC%" format="browser"}%
%ENDSECTION{"test2"}%
Editor
run test3
%STARTSECTION{"test3"}%
%DBCALL{"%TOPIC%" format="editor" exclude="TestCategory5"}%
%ENDSECTION{"test3"}%
Leaf select
[
{
"text": "' alt='TestCategory12' />TestCategory12",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory12",
"children": []
},
{
"text": "' alt='TestCategory4' />TestCategory4",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory4",
"children": []
}
]
Solr facet
[
{
"text": "' alt='Intranet' />Intranet (2)",
"expanded": false,
"hasChildren": 4,
"id": "IntranetDirectory",
"children": []
},
{
"text": "' alt='Test Category Five' />Test Category Five ",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory5",
"children": []
},
{
"text": "' alt='TestCategory' />TestCategory (1)",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory",
"children": []
},
{
"text": "' alt='TestCategory0' />TestCategory0 (1)",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory0",
"children": []
},
{
"text": "' alt='TestCategory16' />TestCategory16 (1)",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory16",
"children": []
},
{
"text": "' alt='TestCategory2' />TestCategory2 ",
"expanded": false,
"hasChildren": 2,
"id": "TestCategory2",
"children": []
}
]
Calls to 'RenderHierarchyAsJSON'
Copyright
© 2006-2019 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.