Index: openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 4 Aug 2003 11:19:46 -0000 1.2 +++ openacs-4/contrib/packages/bcms/tcl/bcms-widget-procs.tcl 27 Aug 2003 17:23:27 -0000 1.3 @@ -140,20 +140,55 @@ ad_proc -public bcms::widget::item_context { - -item_id:required - {-append_list {}} + {-item_id:required} + {-root_id} } { creates a list based the folder it resides that can be used as context or trail. @param item_id id of which item to get a context + @param root_id start from which id @returns a list in {{url label} {url label}} format } { set root_url [ad_conn package_url] - set root_id [bcms::folder::get_bcms_root_folder] + if {![info exists root_id]} { + set root_id [bcms::folder::get_bcms_root_folder] + } return [bcms::widget::extract_values -list_of_ns_sets \ [bcms::item::get_item_path -item_id $item_id -root_id $root_id -prepend_path "$root_url" -return_list] \ -keys_to_extract {path title}] } + + +ad_proc -public bcms::widget::category_context { + {-category_id:required} + {-root_id} +} { + creates a list category listing from the root_id to the category_id + + @param category_id id of which item to get a context + @param root_id start from which id + + @returns a list in {{url label} {url label}} format +} { + + if {![info exists root_id]} { + # if the root_id does not exists then start from the root + array set root [bcms::category::get_root -category_id $category_id] + if {[array size root] > 0} { + set root_id $root(category_id) + } else { + ns_log notice "bcms: category does not exists" + } + } + + set root_url [ad_conn package_url] + set root_url [string range $root_url 0 [expr [string length $root_url] - 2]] + + return [bcms::widget::extract_values -list_of_ns_sets \ + [bcms::category::get_category_path -category_id $category_id -root_id $root_id -prepend_path "$root_url" -return_list] \ + -keys_to_extract {path heading}] +} +