category::list::prepare_display (public)
category::list::prepare_display \ [ -category_delimiter category_delimiter ] \ [ -category_link category_link ] \ [ -category_link_eval category_link_eval ] \ [ -category_link_html category_link_html ] \ [ -tree_delimiter tree_delimiter ] [ -tree_colon tree_colon ] \ [ -tree_link tree_link ] [ -tree_link_eval tree_link_eval ] \ [ -tree_link_html tree_link_html ] \ [ -category_varname category_varname ] \ [ -tree_varname tree_varname ] \ [ -category_column category_column ] \ [ -categories_column categories_column ] [ -tree_ids tree_ids ] \ [ -exclude_tree_ids exclude_tree_ids ] \ [ -container_object_id container_object_id ] [ -locale locale ] \ [ -one_category_list ] -name name
Defined in packages/categories/tcl/category-list-procs.tcl
Extends a given multirow with either one extra column holding a pretty list of the tree-names and category-names or one column per tree holding a pretty list of category-names. These extra column can then be used in the listbuilder to display a pretty list of categorized objects.
- Switches:
- -category_delimiter (optional, defaults to
", "
)- string that separates the categories in the pretty list
- -category_link (optional)
- optional link for every category-name
- -category_link_eval (optional)
- optional command that returns the link for every category-name. normally this would be a export_vars command that could contain __category_id and __tree_id which refer to category_id and tree_id of the category-name the link will wrap.
- -category_link_html (optional)
- optional list of key value pairs for additional html in a link.
- -tree_delimiter (optional, defaults to
"; "
)- string that separates the tree-names in the pretty list
- -tree_colon (optional, defaults to
": "
)- string that separates a tree-name from the category-names in that tree.
- -tree_link (optional)
- optional link for every tree-name
- -tree_link_eval (optional)
- optional command that returns the link for every tree-name. normally this would be a export_vars command that could contain __tree_id which refer to tree_id of the tree-name the link will wrap.
- -tree_link_html (optional)
- optional list of key value pairs for additional html in a link.
- -category_varname (optional, defaults to
"__category_id"
)- name of the variable that will hold the category_id for category link generation.
- -tree_varname (optional, defaults to
"__tree_id"
)- name of the variable that will hold the tree_id for category and tree link generation.
- -category_column (optional, defaults to
"category_id"
)- name of the column in the multirow holding the tcl-list of mapped categories.
- -categories_column (optional, defaults to
"categories"
)- beginning of the names of the multirow columns holding the category names.
- -tree_ids (optional)
- tcl-list of trees that should be displayed.
- -exclude_tree_ids (optional)
- tcl-list of trees that should not be displayed.
- -container_object_id (optional)
- object the trees are mapped to (instead of providing tree_ids).
- -locale (optional)
- locale of the category-names and tree-names.
- -one_category_list (optional, boolean)
- switch to generate only one additional column in the multirow that holds a pretty list of tree-names and category-names.
- -name (required)
- name of the multirow to extend.
- Author:
- Timo Hentschel <timo@timohentschel.de>
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {$category_link_eval ne ""} { upvar 1 $category_varname category_id $tree_varname tree_id } elseif {$tree_link_eval ne ""} { upvar 1 $tree_varname tree_id } set cat_link_html "" foreach {key value} $category_link_html { append cat_link_html " $key=\"$value\"" } set cat_tree_link_html "" foreach {key value} $tree_link_html { append cat_tree_link_html " $key=\"$value\"" } # get trees to display if {$tree_ids eq ""} { foreach mapped_tree [category_tree::get_mapped_trees $container_object_id] { lappend tree_ids [lindex $mapped_tree 0] } } set valid_tree_ids "" foreach tree_id $tree_ids { if {$tree_id ni $exclude_tree_ids} { lappend valid_tree_ids $tree_id } } template::multirow upvar $name list_data # check for existing multirow if {![info exists list_data:rowcount] || ![info exists list_data:columns]} { return } if {!$one_category_list_p} { # extend multirow with a variable per tree foreach tree_id $valid_tree_ids { uplevel 1 template::multirow extend $name $categories_column\_$tree_id } # loop over multirow for {set i 1} {$i <= ${list_data:rowcount}} {incr i} { upvar 1 $name:$i row if {$category_link_eval ne ""} { foreach column_name ${list_data:columns} { upvar 1 $column_name column_value if { [info exists row($column_name)] } { set column_value $row($column_name) } else { set column_value "" } } } # get categories per tree foreach tree_id $valid_tree_ids { set tree_categories($tree_id) "" } foreach category_id $row($category_column) { set tree_id [category::get_tree $category_id] if {$tree_id in $valid_tree_ids} { lappend tree_categories($tree_id) [list $category_id [category::get_name $category_id $locale]] } } # generate pretty category list per tree foreach tree_id [array names tree_categories] { set tree_categories($tree_id) [lsort -dictionary -index 1 $tree_categories($tree_id)] set pretty_category_list "" foreach category $tree_categories($tree_id) { lassign $category category_id category_name set category_name [ns_quotehtml $category_name] if {$category_link_eval ne ""} { set category_link [uplevel 1 concat $category_link_eval] } if {$category_link ne ""} { set category_name "<a href=\"[ns_quotehtml $category_link]\"$cat_link_html>$category_name</a>" } if {$pretty_category_list ne ""} { append pretty_category_list "$category_delimiter$category_name" } else { set pretty_category_list $category_name } } # set multirow columns with pretty category lists set row($categories_column\_$tree_id) $pretty_category_list } unset tree_categories } ############ } else { ############ # extend multirow with one variable for pretty list of trees and categories template::multirow extend list_data $categories_column\_all # loop over multirow for {set i 1} {$i <= ${list_data:rowcount}} {incr i} { upvar 1 $name:$i row if {$category_link_eval ne ""} { foreach column_name ${list_data:columns} { upvar 1 $column_name column_value if { [info exists row($column_name)] } { set column_value $row($column_name) } else { set column_value "" } } } # get categories of given trees set valid_categories "" foreach category_id $row($category_column) { set tree_id [category::get_tree $category_id] if {$tree_id in $valid_tree_ids} { lappend valid_categories $category_id } } # set multirow column with pretty list of trees and categories set row($categories_column\_all) [category::list::get_pretty_list -category_delimiter $category_delimiter -category_link $category_link -category_link_eval $category_link_eval -category_link_html $category_link_html -tree_delimiter $tree_delimiter -tree_colon $tree_colon -tree_link $tree_link -tree_link_eval $tree_link_eval -tree_link_html $tree_link_html -category_varname $category_varname -tree_varname $tree_varname -uplevel 2 $valid_categories $locale] } }XQL Not present: Generic, PostgreSQL, Oracle