::xotcl::Class
::xowiki::Category
Class Hierarchy of ::xowiki::Category
- ::xotcl::Object
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __api_make_doc, __api_make_forward_doc, __nextC, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, checkC, classC, cleanupC, configureC, contains, copy, db_1rowC, debug, defaultmethod, destroyC, destroy_on_cleanup, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearchC, forwardC, hasclass, incrC, infoC, init, instvarC, invarC, isclassC, ismetaclassC, ismixinC, isobjectC, istypeC, lappendC, log, method, mixinC, mixinguardC, move, msg, noinitC, parametercmdC, procC, procsearchC, qn, requireNamespaceC, self, serialize, setC, substC, traceC, unsetC, uplevelC, upvarC, volatileC, vwaitC
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- __exitHandler, getExitHandler, setExitHandler, unsetExitHandler
- ::xo::OrderedComposite
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __compare, add, children, contains, delete, destroy, last_child, orderby, show
- Methods to be applied on the class:
- Methods provided by the meta-class
- ::xowiki::Category
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- category_id, count, href (default ""), label, level, open_requests (default "0"), package_id, pos
- Methods for instances:
- open_tree, render, render_category, render_item, some_child_has_items
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- get_category_infos, get_mapped_trees
Class Relations
- superclass: ::xo::OrderedComposite
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xowiki::Category \
-superclass ::xo::OrderedComposite \
-parameter {category_id count {href ""} label level {open_requests 0} package_id pos}
Methods
proc get_category_infos
::xowiki::Category proc get_category_infos {{-all false} {-subtree_id {}} {-locale {}} -tree_id} {
#
# provide a common interface to older versions of categories
#
# provide compatibility with earlier versions of categories
set have_locale [expr {[lsearch [info args category_tree::get_tree] locale] > -1}]
set all_arg [expr {$all ? "-all" : ""}]
return [expr {$have_locale ?
[eval category_tree::get_tree $all_arg -subtree_id [list $subtree_id] $tree_id $locale] :
[eval category_tree::get_tree $all_arg -subtree_id [list $subtree_id] $tree_id]}]
}
proc get_mapped_trees
::xowiki::Category proc get_mapped_trees {-object_id {-locale {}} {-names {}} {-output {tree_id tree_name subtree_category_id assign_single_p require_category_p}}} {
# Return matched category trees matching the specified names (or all)
# provide compatibility with earlier versions of categories
set have_locale [expr {[lsearch [info args category_tree::get_mapped_trees] locale] > -1}]
set mapped_trees [expr {$have_locale ?
[category_tree::get_mapped_trees $object_id $locale] :
[category_tree::get_mapped_trees $object_id]}]
set trees [list]
foreach tree $mapped_trees {
foreach {tree_id my_tree_name ...} $tree {break}
# "names" is a list of category names
if {$names ne ""} {
# Check, if the current name matches any of the given
# names. If the name contains wild-cards, perform a string
# match, otherwise a string equal.
set match 0
foreach n $names {
if {[string first * $n] > -1} {
if {![string match $n $my_tree_name]} {
set match 1
break
}
} elseif {$n eq $my_tree_name} {
set match 1
break
}
}
if {!$match} continue
}
# Get the values from info in "tree" into separate variables given by output.
# Note, that the order matters!
foreach $output $tree break
set l [list]
foreach __var $output {lappend l [set $__var]}
lappend trees $l
}
return $trees
}
instproc open_tree
::xowiki::Category instproc open_tree {} {
my set open_requests 1
if {[my exists __parent]} {[my set __parent] open_tree}
}
instproc render
::xowiki::Category instproc render {} {
set content ""
if {[my isobject [self]::items]} {
foreach i [[self]::items children] {
$i instvar name title prefix suffix
set entry "$prefix<a href='[::[my package_id] pretty_link $name]'>$title</a>$suffix"
append cat_content [my render_item -highlight [$i exists open_item] $entry]
}
foreach c [my children] {append cat_content [$c render] \n}
append content [my render_category -open [expr {[my set open_requests]>0}] $cat_content]
} elseif {[my open_requests]>0 || [my some_child_has_items]} {
set cat_content ""
foreach c [my children] {append cat_content [$c render] \n}
append content [my render_category -open true $cat_content]
}
return $content
}
instproc render_category
::xowiki::Category instproc render_category {{-open:boolean false} cat_content} {
set open_state [expr {[my set open_requests]>0?"class='liOpen'" : "class='liClosed'"}]
set c [expr {[my exists count] ? "<a href='[my href]'>([my count])</a>" : ""}]
return "<li $open_state>[my label] $c\n <ul>$cat_content</ul>\n"
}
instproc render_item
::xowiki::Category instproc render_item {{-highlight:boolean false} item} {
if {$highlight} {
return "<li class='liItem'><b>$item</b></li>\n"
} else {
return "<li class='liItem'>$item</li>\n"
}
}
instproc some_child_has_items
::xowiki::Category instproc some_child_has_items {} {
foreach i [my children] {
if {[my isobject ${i}::items]} {return 1}
if {[$i some_child_has_items]} {return 1}
}
return 0
}