Index: openacs-4/packages/categories/catalog/categories.de_DE.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/catalog/categories.de_DE.ISO-8859-1.xml,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/catalog/categories.de_DE.ISO-8859-1.xml	10 Dec 2007 09:12:28 -0000	1.3
+++ openacs-4/packages/categories/catalog/categories.de_DE.ISO-8859-1.xml	6 Nov 2008 15:50:44 -0000	1.4
@@ -2,6 +2,7 @@
 <message_catalog package_key="categories" locale="de_DE" charset="ISO-8859-1">
 
   <msg key="cadmin">Management der Kategorien</msg>
+  <msg key="Categories">Kategorien</msg>
   <msg key="code_export">Code zum Erstellen der Kategorieb�ume exportieren</msg>
   <msg key="code_necessary">TCL Code um ausgew�hlte Kategorieb�ume zu importieren</msg>
   <msg key="export">Export</msg>
Index: openacs-4/packages/categories/catalog/categories.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/catalog/categories.en_US.ISO-8859-1.xml,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/categories/catalog/categories.en_US.ISO-8859-1.xml	10 Dec 2007 09:12:28 -0000	1.5
+++ openacs-4/packages/categories/catalog/categories.en_US.ISO-8859-1.xml	6 Nov 2008 15:50:44 -0000	1.6
@@ -2,6 +2,7 @@
 <message_catalog package_key="categories" locale="en_US" charset="ISO-8859-1">
 
   <msg key="cadmin">Category Management</msg>
+  <msg key="Categories">Categories</msg>
   <msg key="code_export">Export code to recreate category trees</msg>
   <msg key="code_necessary">Tcl code to recreate selected category trees</msg>
   <msg key="export">Export</msg>
Index: openacs-4/packages/categories/lib/list-categories.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/list-categories.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/lib/list-categories.tcl	17 Mar 2005 08:33:59 -0000	1.2
+++ openacs-4/packages/categories/lib/list-categories.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -11,6 +11,7 @@
 set counts {}
 set node_id [ad_conn node_id]
 set packages [subsite::util::packages -node_id $node_id]
+
 db_foreach category_count "
     SELECT c.category_id as catid, count(*) as count
     FROM category_object_map c, acs_objects o
Index: openacs-4/packages/categories/lib/tree-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/tree-form.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/lib/tree-form.tcl	14 Dec 2003 15:40:04 -0000	1.1
+++ openacs-4/packages/categories/lib/tree-form.tcl	6 Nov 2008 15:50:44 -0000	1.2
@@ -1,8 +1,16 @@
-set package_id [ad_conn package_id]
+if {![info exists ctx_id]} {
+  set package_id [ad_conn package_id]
+} else {
+  set package_id $ctx_id
+}
 
 set languages [lang::system::get_locale_options]
 
-ad_form -name tree_form -mode [ad_decode [ad_form_new_p -key tree_id] 1 edit display] -action tree-form -export { locale object_id } -form {
+ad_form -name tree_form \
+    -mode [ad_decode [ad_form_new_p -key tree_id] 1 edit display] \
+    -action tree-form \
+    -export { locale object_id ctx_id } \
+    -form {
     {tree_id:key}
     {tree_name:text {label "Name"} {html {size 50 maxlength 50}}}
     {language:text(select) {label "Language"} {options $languages}}
@@ -22,14 +30,14 @@
 	category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id
 	if { [info exists object_id] } {
 	    category_tree::map -tree_id $tree_id -object_id $object_id
-	    set return_url [export_vars -base one-object { locale object_id }]
+	    set return_url [export_vars -base object-map { locale object_id ctx_id}]
 	} else {
-	    set return_url [export_vars -base tree-view { tree_id locale }]
+	    set return_url [export_vars -base tree-view { tree_id locale ctx_id}]
 	}
     }
 } -edit_data {
     category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language
-    set return_url [export_vars -base tree-view { tree_id locale object_id }]
+    set return_url [export_vars -base tree-view { tree_id locale object_id ctx_id}]
 } -after_submit {
     ad_returnredirect $return_url
     ad_script_abort
Index: openacs-4/packages/categories/tcl/categories-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/categories-procs.tcl,v
diff -u -r1.24 -r1.25
--- openacs-4/packages/categories/tcl/categories-procs.tcl	7 Oct 2007 22:36:56 -0000	1.24
+++ openacs-4/packages/categories/tcl/categories-procs.tcl	6 Nov 2008 15:50:44 -0000	1.25
@@ -498,20 +498,21 @@
     return $indent_string
 }
 
-ad_proc -private category::context_bar { tree_id locale object_id } {
+ad_proc -private category::context_bar { tree_id locale object_id {ctx_id ""}} {
     Creates the standard context bar
 
     @param tree_id
     @param locale
     @param object_id
     @author Timo Hentschel (timo@timohentschel.de)
 } {
+    if {$ctx_id eq ""} {unset ctx_id}
     if {![empty_string_p $object_id]} {
-	set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id}] "Category Management"]]
+	set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id ctx_id}] [_ categories.cadmin]]]
     } else {
-	set context_bar [list [list ".?[export_vars -no_empty {locale}]" "Category Management"]]
+	set context_bar [list [list ".?[export_vars -no_empty {locale ctx_id}]" [_ categories.cadmin]]]
     }
-    lappend context_bar [list [export_vars -no_empty -base tree-view {tree_id locale object_id}] [category_tree::get_name $tree_id $locale]]
+    lappend context_bar [list [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}] [category_tree::get_name $tree_id $locale]]
 
     return $context_bar
 }
Index: openacs-4/packages/categories/www/cadmin/category-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-2.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/categories/www/cadmin/category-delete-2.tcl	1 Mar 2005 00:01:26 -0000	1.8
+++ openacs-4/packages/categories/www/cadmin/category-delete-2.tcl	6 Nov 2008 15:50:44 -0000	1.9
@@ -9,6 +9,7 @@
     category_id:integer,multiple
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -24,4 +25,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/categories/www/cadmin/category-delete.tcl	1 Mar 2005 00:01:26 -0000	1.9
+++ openacs-4/packages/categories/www/cadmin/category-delete.tcl	6 Nov 2008 15:50:44 -0000	1.10
@@ -9,6 +9,7 @@
     category_id:integer,multiple
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -28,16 +29,18 @@
 	$id \
 	[category::get_name $id $locale] \
 	[db_string check_mapped_objects {}] \
-	[export_vars -no_empty -base category-usage { {category_id $id} tree_id locale object_id }]
+	[export_vars -no_empty -base category-usage { {category_id $id} tree_id locale object_id ctx_id}]
 }
 
 multirow sort categories -dictionary category_name
 
-set delete_url [export_vars -no_empty -base category-delete-2 { tree_id category_id:multiple locale object_id }]
-set cancel_url [export_vars -no_empty -base tree-view { tree_id locale object_id }]
+set delete_url [export_vars -no_empty -base category-delete-2 { tree_id category_id:multiple locale object_id ctx_id}]
+set cancel_url [export_vars -no_empty -base tree-view { tree_id locale object_id ctx_id}]
 set page_title "Delete categories"
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Delete categories"
 
 template::list::create \
Index: openacs-4/packages/categories/www/cadmin/category-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-form.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/categories/www/cadmin/category-form.tcl	1 Mar 2005 00:01:26 -0000	1.7
+++ openacs-4/packages/categories/www/cadmin/category-form.tcl	6 Nov 2008 15:50:44 -0000	1.8
@@ -9,6 +9,7 @@
     {parent_id:integer,optional [db_null]}
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     context_bar:onevalue
     page_title:onevalue
@@ -24,12 +25,16 @@
     set page_title "Add category"
 }
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar $page_title
 
 set languages [lang::system::get_locale_options]
 
-ad_form -name category_form -action category-form -export { tree_id parent_id locale object_id } -form {
+ad_form -name category_form -action category-form \
+  -export { tree_id parent_id locale object_id ctx_id } \
+  -form {
     {category_id:key}
     {name:text {label "Name"} {html {size 50 maxlength 200}}}
     {language:text(select) {label "Language"} {value $locale} {options $languages}}
@@ -49,7 +54,7 @@
 } -edit_data {
     category::update -category_id $category_id -locale $language -name $name -description $description
 } -after_submit {
-    ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id}]
+    ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
     ad_script_abort
 }
 
Index: openacs-4/packages/categories/www/cadmin/category-link-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-add-2.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/categories/www/cadmin/category-link-add-2.tcl	1 Mar 2005 00:01:26 -0000	1.5
+++ openacs-4/packages/categories/www/cadmin/category-link-add-2.tcl	6 Nov 2008 15:50:44 -0000	1.6
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -27,10 +28,12 @@
 set link_tree_name [category_tree::get_name $link_tree_id $locale]
 set page_title "Add link from \"$link_tree_name\" to category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar \
-    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}] "Links to $category_name"] \
-    [list [export_vars -no_empty -base category-link-add {category_id tree_id locale object_id}] "Select link target"] \
+    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id ctx_id}] "Links to $category_name"] \
+    [list [export_vars -no_empty -base category-link-add {category_id tree_id locale object_id ctx_id}] "Select link target"] \
     "Add link"
 
 
@@ -51,9 +54,9 @@
 
     template::multirow append tree $link_category_name $link_category_id $forward_exists_p $backward_exists_p \
 	[string repeat "&nbsp;" [expr ($level-1)*5]] \
-	[export_vars -no_empty -base category-links-view {{category_id $link_category_id} {tree_id $link_tree_id} locale object_id}] \
-	[export_vars -no_empty -base category-link-add-3 {link_category_id category_id tree_id locale object_id}] \
-	[export_vars -no_empty -base category-link-add-4 {link_category_id category_id tree_id locale object_id}]
+	[export_vars -no_empty -base category-links-view {{category_id $link_category_id} {tree_id $link_tree_id} locale object_id  ctx_id}] \
+	[export_vars -no_empty -base category-link-add-3 {link_category_id category_id tree_id locale object_id ctx_id}] \
+	[export_vars -no_empty -base category-link-add-4 {link_category_id category_id tree_id locale object_id ctx_id}]
     }
 
 template::list::create \
@@ -63,7 +66,7 @@
     -bulk_actions {
 	"Add links" "category-link-add-3" "Add category links to checked categories"
 	"Add bidirectional links" "category-link-add-4" "Add bidirectional category links to checked categories"
-    } -bulk_action_export_vars { category_id tree_id locale object_id } \
+    } -bulk_action_export_vars { category_id tree_id locale object_id ctx_id} \
     -elements {
 	links {
 	    sub_class narrow
Index: openacs-4/packages/categories/www/cadmin/category-link-add-3.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-add-3.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/category-link-add-3.tcl	1 Mar 2005 00:01:26 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/category-link-add-3.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -24,4 +25,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-link-add-4.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-add-4.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/category-link-add-4.tcl	1 Mar 2005 00:01:26 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/category-link-add-4.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -28,4 +29,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-link-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-add.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/category-link-add.tcl	1 Mar 2005 00:01:26 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/category-link-add.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -9,6 +9,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -23,9 +24,11 @@
 set category_name [category::get_name $category_id $locale]
 set page_title "Select target to add a link to category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar \
-    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}] "Links to $category_name"] \
+    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id  ctx_id}] "Links to $category_name"] \
     "Select link target"
 
 
@@ -34,7 +37,7 @@
 db_foreach get_trees_to_link "" {
     set tree_name [category_tree::get_name $link_tree_id $locale]
     template::multirow append trees $tree_name $link_tree_id \
-	[export_vars -no_empty -base category-link-add-2 { link_tree_id category_id tree_id locale object_id }]
+	[export_vars -no_empty -base category-link-add-2 { link_tree_id category_id tree_id locale object_id ctx_id}]
 }
 
 template::multirow sort trees -dictionary tree_name
Index: openacs-4/packages/categories/www/cadmin/category-link-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-delete-2.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/www/cadmin/category-link-delete-2.tcl	1 Mar 2005 00:01:26 -0000	1.4
+++ openacs-4/packages/categories/www/cadmin/category-link-delete-2.tcl	6 Nov 2008 15:50:44 -0000	1.5
@@ -10,6 +10,7 @@
     tree_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -24,4 +25,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-link-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-link-delete.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/www/cadmin/category-link-delete.tcl	1 Mar 2005 00:01:26 -0000	1.4
+++ openacs-4/packages/categories/www/cadmin/category-link-delete.tcl	6 Nov 2008 15:50:44 -0000	1.5
@@ -10,6 +10,7 @@
     tree_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -27,9 +28,11 @@
 set allowed_link_ids [list]
 set page_title "Delete links with category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar \
-    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id}] "Links to $category_name"] \
+    [list [export_vars -no_empty -base category-links-view {category_id tree_id locale object_id  ctx_id}] "Links to $category_name"] \
     "Delete Links"
 
 multirow create category_links linked_category_id linked_tree_id direction
@@ -43,17 +46,17 @@
 
 multirow extend category_links tree_view_url category_view_url tree_name category_name
 multirow foreach category_links {
-    set tree_view_url [export_vars -no_empty -base tree-view { {tree_id $linked_tree_id} locale object_id }]
-    set category_view_url [export_vars -no_empty -base category-links-view { {category_id $linked_category_id} {tree_id $linked_tree_id} locale object_id }]
+    set tree_view_url [export_vars -no_empty -base tree-view { {tree_id $linked_tree_id} locale object_id  ctx_id}]
+    set category_view_url [export_vars -no_empty -base category-links-view { {category_id $linked_category_id} {tree_id $linked_tree_id} locale object_id  ctx_id}]
 
     set tree_name [category_tree::get_name $linked_tree_id $locale]
     set category_name [category::get_name $linked_category_id $locale]
 }
 
 multirow sort category_links -dictionary tree_name category_name direction
 
-set delete_url [export_vars -no_empty -base category-link-delete-2 { {link_id:multiple $allowed_link_ids} category_id tree_id locale object_id }]
-set cancel_url [export_vars -no_empty -base category-links-view { category_id tree_id locale object_id }]
+set delete_url [export_vars -no_empty -base category-link-delete-2 { {link_id:multiple $allowed_link_ids} category_id tree_id locale object_id  ctx_id}]
+set cancel_url [export_vars -no_empty -base category-links-view { category_id tree_id locale object_id  ctx_id}]
 
 template::list::create \
     -name category_links \
Index: openacs-4/packages/categories/www/cadmin/category-links-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-links-view.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/www/cadmin/category-links-view.tcl	1 Mar 2005 00:01:26 -0000	1.4
+++ openacs-4/packages/categories/www/cadmin/category-links-view.tcl	6 Nov 2008 15:50:44 -0000	1.5
@@ -10,6 +10,7 @@
     {locale ""}
     object_id:integer,optional
     orderby:optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -23,7 +24,9 @@
 set category_name [category::get_name $category_id $locale]
 set page_title "Categories linked with category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Links to $category_name"
 
 
@@ -51,11 +54,12 @@
 	tree_id {}
 	locale {}
 	object_id {}
+	ctx_id {}
     } -actions [list \
-		  "Add link" [export_vars -no_empty -base category-link-add { category_id tree_id locale object_id }] "Add new category link"] \
+		  "Add link" [export_vars -no_empty -base category-link-add { category_id tree_id locale object_id ctx_id}] "Add new category link"] \
     -bulk_actions {
 	"Delete" "category-link-delete" "Delete checked category links"
-    } -bulk_action_export_vars { category_id tree_id locale object_id } \
+    } -bulk_action_export_vars { category_id tree_id locale object_id ctx_id} \
     -elements {
 	checkbox {
 	    display_template {
@@ -92,9 +96,9 @@
 
 multirow extend category_links delete_url tree_view_url category_view_url tree_name category_name
 multirow foreach category_links {
-    set delete_url [export_vars -no_empty -base category-link-delete { link_id category_id tree_id locale object_id }]
-    set tree_view_url [export_vars -no_empty -base tree-view { {tree_id $linked_tree_id} locale object_id }]
-    set category_view_url [export_vars -no_empty -base category-links-view { {category_id $linked_category_id} {tree_id $linked_tree_id} locale object_id }]
+    set delete_url [export_vars -no_empty -base category-link-delete { link_id category_id tree_id locale object_id ctx_id}]
+    set tree_view_url [export_vars -no_empty -base tree-view { {tree_id $linked_tree_id} locale object_id ctx_id}]
+    set category_view_url [export_vars -no_empty -base category-links-view { {category_id $linked_category_id} {tree_id $linked_tree_id} locale object_id ctx_id}]
 
     set tree_name [category_tree::get_name $linked_tree_id $locale]
     set category_name [category::get_name $linked_category_id $locale]
Index: openacs-4/packages/categories/www/cadmin/category-parent-change-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-parent-change-2.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/category-parent-change-2.tcl	11 Feb 2004 10:01:11 -0000	1.1
+++ openacs-4/packages/categories/www/cadmin/category-parent-change-2.tcl	6 Nov 2008 15:50:44 -0000	1.2
@@ -10,10 +10,11 @@
     {parent_id:integer,optional [db_null]}
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 permission::require_permission -object_id $tree_id -privilege category_tree_write
 
 category::change_parent -tree_id $tree_id -category_id $category_id -parent_id $parent_id
 
-ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-parent-change.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-parent-change.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/category-parent-change.tcl	1 Mar 2005 00:01:26 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/category-parent-change.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -9,6 +9,7 @@
     category_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -21,21 +22,23 @@
 
 set category_name [category::get_name $category_id $locale]
 set page_title "Change parent category of \"$category_name\""
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Change parent"
 
 
 set subtree_categories_list [db_list get_subtree ""]
 
 template::multirow create tree category_name category_id deprecated_p level left_indent parent_url
 template::multirow append tree "Root Level" 0 f 0 "" \
-    [export_vars -no_empty -base category-parent-change-2 {tree_id category_id locale object_id}]
+    [export_vars -no_empty -base category-parent-change-2 {tree_id category_id locale object_id ctx_id}]
 
 foreach category [category_tree::get_tree -all $tree_id $locale] {
     util_unlist $category parent_id category_name deprecated_p level
 
     if { [lsearch $subtree_categories_list $parent_id]==-1 } {
-	set parent_url [export_vars -no_empty -base category-parent-change-2 { parent_id tree_id category_id locale object_id }]
+	set parent_url [export_vars -no_empty -base category-parent-change-2 { parent_id tree_id category_id locale object_id ctx_id }]
     } else {
 	set parent_url ""
     }
Index: openacs-4/packages/categories/www/cadmin/category-phase-in.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-phase-in.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/www/cadmin/category-phase-in.tcl	11 Feb 2004 10:28:02 -0000	1.4
+++ openacs-4/packages/categories/www/cadmin/category-phase-in.tcl	6 Nov 2008 15:50:44 -0000	1.5
@@ -8,7 +8,8 @@
     category_id:integer,multiple
     {locale ""}
     object_id:integer,optional
-} 
+    ctx_id:integer,optional
+}
 
 permission::require_permission -object_id $tree_id -privilege category_tree_write
 
@@ -19,4 +20,4 @@
 }
 category_tree::flush_cache $tree_id
 
-ad_returnredirect [export_vars -no_empty -base tree-view { tree_id locale object_id }]
+ad_returnredirect [export_vars -no_empty -base tree-view { tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/category-phase-out.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-phase-out.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/categories/www/cadmin/category-phase-out.tcl	11 Feb 2004 10:28:02 -0000	1.5
+++ openacs-4/packages/categories/www/cadmin/category-phase-out.tcl	6 Nov 2008 15:50:44 -0000	1.6
@@ -8,6 +8,7 @@
     category_id:integer,multiple
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } 
 
 permission::require_permission -object_id $tree_id -privilege category_tree_write
@@ -19,4 +20,4 @@
 }
 category_tree::flush_cache $tree_id
 
-ad_returnredirect [export_vars -no_empty -base tree-view { tree_id locale object_id }]
+ad_returnredirect [export_vars -no_empty -base tree-view { tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/categories/www/cadmin/master.tcl	16 Apr 2008 10:27:12 -0000	1.7
+++ openacs-4/packages/categories/www/cadmin/master.tcl	6 Nov 2008 15:50:44 -0000	1.8
@@ -12,22 +12,22 @@
 }
 
 set languages [lang::system::get_locale_options]
-set vars_to_export_list {tree_id category_id}
+set vars_to_export_list {tree_id category_id }
 
 set set_id [ad_conn form]
 set varname_list [ad_ns_set_keys -exclude {
-  tree_id category_id locale form:mode form:id __confirmed_p __refreshing_p formbutton:ok
+  tree_id category_id locale form:mode form:id 
+  __confirmed_p __refreshing_p formbutton:ok
+  __submit_button_name __submit_button_value
 } $set_id]
 
 foreach name $varname_list {
-    set $name [ns_set get $set_id $name]
-    lappend vars_to_export_list $name
+  set $name [ns_set get $set_id $name]
+  lappend vars_to_export_list $name
 }
 
-ad_form -name locale_form -action [ad_conn url] -export $vars_to_export_list -html {class "inline-form"} -form {
-    {locale:text(select),optional 
-        {label "Language"} 
-        {value $locale} 
-        {options $languages}
+ad_form -name locale_form -action [ad_conn url] \
+    -export $vars_to_export_list \
+    -form {
+      {locale:text(select) {label "Language"} {value $locale} {options $languages}}
     }
-}
Index: openacs-4/packages/categories/www/cadmin/object-map.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/object-map.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/object-map.tcl	28 Aug 2007 16:30:03 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/object-map.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -8,10 +8,11 @@
     @cvs-id $Id:
 } {
     object_id:integer,notnull
+    ctx_id:integer,optional
     {locale ""}
 } -properties {
     page_title:onevalue
-    context_bar:onevalue
+    context:onevalue
     locale:onevalue
     mapped_trees:multirow
     unmapped_trees:multirow
@@ -23,21 +24,22 @@
 
 set context_bar [category::get_object_context $object_id]
 set object_name [lindex $context_bar 1]
-set page_title "Category Management"
+set page_title [_ categories.cadmin]
 set context_bar [list $context_bar $page_title]
 
-template::multirow create mapped_trees tree_name tree_id site_wide_p assign_single_p require_category_p widget view_url unmap_url edit_url
+template::multirow create mapped_trees tree_name tree_id \
+    site_wide_p assign_single_p require_category_p widget view_url unmap_url edit_url
 
 db_foreach get_mapped_trees "" {
     set tree_name [category_tree::get_name $tree_id $locale]
     if {![empty_string_p $subtree_category_id]} {
-	append tree_name " :: [category::get_name $subtree_category_id $locale]"
+      append tree_name " :: [category::get_name $subtree_category_id $locale]"
     }
     template::multirow append mapped_trees $tree_name $tree_id $site_wide_p \
 	$assign_single_p $require_category_p $widget \
-	[export_vars -no_empty -base tree-view { tree_id locale object_id }] \
-	[export_vars -no_empty -base tree-unmap { tree_id locale object_id }] \
-	[export_vars -no_empty -base tree-map-2 { tree_id locale object_id {edit_p 1}}]
+	[export_vars -no_empty -base tree-view { tree_id locale object_id ctx_id}] \
+	[export_vars -no_empty -base tree-unmap { tree_id locale object_id ctx_id}] \
+	[export_vars -no_empty -base tree-map-2 { tree_id locale object_id {edit_p 1} ctx_id}]
 }
 
 template::multirow sort mapped_trees -dictionary tree_name
@@ -49,9 +51,9 @@
 	set tree_name [category_tree::get_name $tree_id $locale]
 
 	template::multirow append unmapped_trees $tree_id $tree_name $site_wide_p \
-	[export_vars -no_empty -base tree-view { tree_id locale object_id }] \
-	[export_vars -no_empty -base tree-map-2 { tree_id locale object_id }] \
-	[export_vars -no_empty -base tree-map { tree_id locale object_id }]
+	[export_vars -no_empty -base tree-view { tree_id locale object_id ctx_id}] \
+	[export_vars -no_empty -base tree-map-2 { tree_id locale object_id ctx_id}] \
+	[export_vars -no_empty -base tree-map { tree_id locale object_id ctx_id}]
     }
 }
 
@@ -104,6 +106,6 @@
 	}
     }
 
-set create_url [export_vars -no_empty -base tree-form { locale }]
+set create_url [export_vars -no_empty -base tree-form { locale object_id ctx_id }]
 
 ad_return_template
Index: openacs-4/packages/categories/www/cadmin/synonym-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/synonym-delete-2.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/synonym-delete-2.tcl	1 Mar 2005 00:01:27 -0000	1.2
+++ openacs-4/packages/categories/www/cadmin/synonym-delete-2.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -24,4 +25,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base synonyms-view {category_id tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base synonyms-view {category_id tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/synonym-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/synonym-delete.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/synonym-delete.tcl	1 Mar 2005 00:01:27 -0000	1.2
+++ openacs-4/packages/categories/www/cadmin/synonym-delete.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -25,11 +26,13 @@
 set category_name [category::get_name $category_id $locale]
 set page_title "Delete synonyms of category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
-lappend context_bar [list [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id }] "Synonyms of $category_name"] "Delete synonyms"
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
+lappend context_bar [list [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id ctx_id}] "Synonyms of $category_name"] "Delete synonyms"
 
-set delete_url [export_vars -no_empty -base synonym-delete-2 { synonym_id:multiple category_id tree_id locale object_id }]
-set cancel_url [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id }]
+set delete_url [export_vars -no_empty -base synonym-delete-2 { synonym_id:multiple category_id tree_id locale object_id ctx_id}]
+set cancel_url [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id ctx_id}]
 
 
 db_multirow synonyms get_synonyms_to_delete ""
Index: openacs-4/packages/categories/www/cadmin/synonym-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/synonym-form.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/synonym-form.tcl	1 Mar 2005 00:01:27 -0000	1.2
+++ openacs-4/packages/categories/www/cadmin/synonym-form.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -10,6 +10,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     context_bar:onevalue
     page_title:onevalue
@@ -28,13 +29,16 @@
 }
 set page_title "$action category synonym of \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
-lappend context_bar [list [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id }] "Synonyms of $category_name"] "$action synonym"
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 
+lappend context_bar [list [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id ctx_id}] "Synonyms of $category_name"] "$action synonym"
 
+
 set languages [lang::system::get_locale_options]
 
-ad_form -name synonym_form -action synonym-form -export { category_id tree_id locale object_id } -form {
+ad_form -name synonym_form -action synonym-form -export { category_id tree_id locale object_id ctx_id} -form {
     {synonym_id:key(category_synonyms_id_seq)}
     {name:text {label "Name"} {html {size 50 maxlength 200}}}
     {language:text(select) {label "Language"} {options $languages}}
@@ -52,7 +56,7 @@
 } -edit_data {
     category_synonym::edit -name $name -locale $language -synonym_id $synonym_id
 } -after_submit {
-    ad_returnredirect [export_vars -no_empty -base synonyms-view {category_id tree_id locale object_id}]
+    ad_returnredirect [export_vars -no_empty -base synonyms-view {category_id tree_id locale object_idctx_id}]
     ad_script_abort
 }
 
Index: openacs-4/packages/categories/www/cadmin/synonyms-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/synonyms-view.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/synonyms-view.tcl	1 Mar 2005 00:01:27 -0000	1.2
+++ openacs-4/packages/categories/www/cadmin/synonyms-view.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -10,6 +10,7 @@
     {locale ""}
     object_id:integer,optional
     orderby:optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -23,7 +24,9 @@
 set category_name [category::get_name $category_id $locale]
 set page_title "Synonyms for category \"$tree_name :: $category_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Synonyms of $category_name"
 
 
@@ -35,10 +38,10 @@
     -name synonyms \
     -no_data "None" \
     -key synonym_id \
-    -actions [list "Add synonym" [export_vars -no_empty -base synonym-form { category_id tree_id locale object_id }] "Add new synonym"] \
+    -actions [list "Add synonym" [export_vars -no_empty -base synonym-form { category_id tree_id locale object_id ctx_id}] "Add new synonym"] \
     -bulk_actions {
 	"Delete" "synonym-delete" "Delete checked synonyms"
-    } -bulk_action_export_vars { category_id tree_id locale object_id
+    } -bulk_action_export_vars { category_id tree_id locale object_id ctx_id
     } -orderby {
 	default_value language,asc
 	synonym_name {
@@ -88,8 +91,8 @@
 
 multirow extend synonyms edit_url delete_url
 multirow foreach synonyms {
-    set edit_url [export_vars -no_empty -base synonym-form { synonym_id category_id tree_id locale object_id }]
-    set delete_url [export_vars -no_empty -base synonym-delete { synonym_id category_id tree_id locale object_id }]
+    set edit_url [export_vars -no_empty -base synonym-form { synonym_id category_id tree_id locale object_id ctx_id}]
+    set delete_url [export_vars -no_empty -base synonym-delete { synonym_id category_id tree_id locale object_id ctx_id}]
 }
 
 ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl	1 Mar 2005 00:01:27 -0000	1.5
+++ openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl	6 Nov 2008 15:50:44 -0000	1.6
@@ -9,6 +9,7 @@
     source_tree_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -17,4 +18,4 @@
 
 category_tree::copy -source_tree $source_tree_id -dest_tree $target_tree_id
 
-ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/tree-copy-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy-view.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/tree-copy-view.tcl	1 Mar 2005 00:01:27 -0000	1.2
+++ openacs-4/packages/categories/www/cadmin/tree-copy-view.tcl	6 Nov 2008 15:50:44 -0000	1.3
@@ -9,6 +9,7 @@
     target_tree_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -29,8 +30,10 @@
 set tree_name [category_tree::get_name $tree_id $locale]
 set page_title "Category Tree \"$tree_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
-lappend context_bar [list [export_vars -no_empty -base tree-copy { {tree_id $target_tree_id} locale object_id }] "Copy tree"] "View \"$tree_name\""
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
+lappend context_bar [list [export_vars -no_empty -base tree-copy { {tree_id $target_tree_id} locale object_id ctx_id }] "Copy tree"] "View \"$tree_name\""
 
 template::multirow create tree category_name deprecated_p level left_indent
 
Index: openacs-4/packages/categories/www/cadmin/tree-copy.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/categories/www/cadmin/tree-copy.tcl	1 Mar 2005 00:01:27 -0000	1.9
+++ openacs-4/packages/categories/www/cadmin/tree-copy.tcl	6 Nov 2008 15:50:44 -0000	1.10
@@ -8,6 +8,7 @@
     tree_id:integer
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -23,7 +24,9 @@
 set target_tree_id $tree_id
 set page_title "Copy a tree into \"$tree_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Copy tree"
 
 template::multirow create trees tree_id tree_name site_wide_p view_url copy_url
@@ -33,8 +36,8 @@
 	set source_tree_name [category_tree::get_name $source_tree_id $locale]
 
 	template::multirow append trees $source_tree_id $source_tree_name $site_wide_p \
-	[export_vars -no_empty -base tree-copy-view { source_tree_id target_tree_id locale object_id }] \
-	[export_vars -no_empty -base tree-copy-2 { source_tree_id target_tree_id locale object_id }]
+	[export_vars -no_empty -base tree-copy-view { source_tree_id target_tree_id locale object_id ctx_id }] \
+	[export_vars -no_empty -base tree-copy-2 { source_tree_id target_tree_id locale object_id ctx_id }]
     }
 }
 
Index: openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl	1 Mar 2005 00:01:27 -0000	1.6
+++ openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl	6 Nov 2008 15:50:44 -0000	1.7
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -23,7 +24,7 @@
 category_tree::delete $tree_id
 
 if {![info exists object_id]} {
-    ad_returnredirect ".?[export_vars -no_empty {locale}]"
+    ad_returnredirect ".?[export_vars -no_empty {locale ctx_id}]"
 } else {
-    ad_returnredirect [export_vars -no_empty -base object-map {locale object_id}]
+    ad_returnredirect [export_vars -no_empty -base object-map {locale object_id ctx_id}]
 }
Index: openacs-4/packages/categories/www/cadmin/tree-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/categories/www/cadmin/tree-delete.tcl	1 Mar 2005 00:01:27 -0000	1.9
+++ openacs-4/packages/categories/www/cadmin/tree-delete.tcl	6 Nov 2008 15:50:44 -0000	1.10
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -28,7 +29,9 @@
 set tree_description $tree(description)
 
 set page_title "Delete Category Tree \"$tree_name\""
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Delete"
 
 set instance_list [category_tree::usage $tree_id]
@@ -39,16 +42,16 @@
     set instances_using_p f
 }
 
-set delete_url [export_vars -no_empty -base tree-delete-2 {tree_id locale object_id}]
-set cancel_url [export_vars -no_empty -base tree-view {tree_id locale object_id}]
-set usage_url [export_vars -no_empty -base tree-usage {tree_id}]
+set delete_url [export_vars -no_empty -base tree-delete-2 {tree_id locale object_id ctx_id}]
+set cancel_url [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
+set usage_url [export_vars -no_empty -base tree-usage {tree_id ctx_id}]
 
 template::multirow create used_categories category_id category_name view_url
 
 db_foreach get_category_in_use "" {
     set category_name [category::get_name $category_id $locale]
     template::multirow append used_categories $category_id $category_name \
-	[export_vars -no_empty -base category-usage { category_id tree_id locale object_id }]
+	[export_vars -no_empty -base category-usage { category_id tree_id locale object_id ctx_id }]
 }
 
 template::multirow sort used_categories -dictionary category_name
Index: openacs-4/packages/categories/www/cadmin/tree-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/tree-form.adp	14 Dec 2003 15:36:58 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/tree-form.adp	6 Nov 2008 15:50:44 -0000	1.4
@@ -5,5 +5,5 @@
 <property name="focus">tree_form.tree_name</property>
 
 <blockquote>
-  <include src="/packages/categories/lib/tree-form" &="tree_id" &="locale">
+  <include src="/packages/categories/lib/tree-form" &="tree_id" &="locale" &="ctx_id" &="object_id">
 </blockquote>
Index: openacs-4/packages/categories/www/cadmin/tree-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/categories/www/cadmin/tree-form.tcl	11 Feb 2004 11:44:00 -0000	1.6
+++ openacs-4/packages/categories/www/cadmin/tree-form.tcl	6 Nov 2008 15:50:44 -0000	1.7
@@ -7,6 +7,7 @@
     tree_id:integer,optional
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     context_bar:onevalue
     page_title:onevalue
@@ -21,8 +22,13 @@
 }
 
 if { [info exists object_id] } {
-    set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id}] "Category Management"]]
+    set context_bar [list \
+          [category::get_object_context $object_id] \
+          [list [export_vars -no_empty -base object-map {locale ctx_id object_id}] \
+          [_ categories.cadmin]]]
 } else {
-    set context_bar [list [list ".?[export_vars -no_empty {locale}]" "Category Management"]]
+    set context_bar [list \
+          [list ".?[export_vars -no_empty {locale ctx_id}]" \
+          [_ categories.cadmin]]]
 }
 lappend context_bar $page_title
Index: openacs-4/packages/categories/www/cadmin/tree-map-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-map-2.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/www/cadmin/tree-map-2.tcl	28 Aug 2007 16:30:03 -0000	1.4
+++ openacs-4/packages/categories/www/cadmin/tree-map-2.tcl	6 Nov 2008 15:50:44 -0000	1.5
@@ -14,6 +14,7 @@
     {locale ""}
     object_id:integer,notnull
     {edit_p 0}
+    ctx_id:integer,optional
 }
 
 set user_id [auth::require_login]
@@ -25,7 +26,7 @@
     permission::require_permission -object_id $tree_id -privilege category_tree_read
 }
 
-set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id}]" "Category Management"] "Mapping Parameters"]
+set context_bar [list [category::get_object_context $object_id] [list "[export_vars -no_empty -base object-map {locale object_id ctx_id}]" [_ categories.cadmin]] "Mapping Parameters"]
 
 if {$edit_p} {
     # parameters are edited, so get old data
@@ -39,7 +40,7 @@
     set page_title "Parameters of mapping to subtree \"$tree_name :: $category_name\""
 }
 
-ad_form -name tree_map_form -action tree-map-2 -export { tree_id category_id locale object_id edit_p } -form {
+ad_form -name tree_map_form -action tree-map-2 -export { tree_id category_id locale object_id edit_p ctx_id} -form {
     {widget:text(radio) {label "Widget"} {options {
 	{"Select" select}
 	{"Multiselect - let users assign multiple categories" multiselect}
@@ -76,7 +77,7 @@
 	category_tree::map -tree_id $tree_id -subtree_category_id $category_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p -widget $widget
     }
 } -after_submit {
-    ad_returnredirect [export_vars -no_empty -base object-map {locale object_id}]
+    ad_returnredirect [export_vars -no_empty -base object-map {locale object_id ctx_id}]
     ad_script_abort
 }
 
Index: openacs-4/packages/categories/www/cadmin/tree-map.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-map.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/categories/www/cadmin/tree-map.tcl	1 Mar 2005 00:01:27 -0000	1.7
+++ openacs-4/packages/categories/www/cadmin/tree-map.tcl	6 Nov 2008 15:50:44 -0000	1.8
@@ -8,6 +8,7 @@
     tree_id:integer
     {locale ""}
     object_id:integer,notnull
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -26,16 +27,19 @@
 
 set page_title "Select subtree of \"$tree_name\" to map"
 
-set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id}] "Category Management"] "Map subtree"]
+set context_bar [list \
+   [category::get_object_context $object_id] \
+   [list [export_vars -no_empty -base object-map {locale object_id ctx_id}] [_ categories.cadmin]] \
+   "Map subtree"]
 
 template::multirow create tree category_id category_name level left_indent map_url
 
 foreach category [category_tree::get_tree -all $tree_id $locale] {
     util_unlist $category category_id category_name deprecated_p level
 
     template::multirow append tree $category_id $category_name $level \
-	[string repeat "&nbsp;" [expr ($level-1)*5]] \
-	[export_vars -no_empty -base tree-map-2 { category_id tree_id locale object_id }]
+	[string repeat "&nbsp;" [expr {($level-1)*5}]] \
+	[export_vars -no_empty -base tree-map-2 { category_id tree_id locale object_id ctx_id}]
 }
 
 template::list::create \
Index: openacs-4/packages/categories/www/cadmin/tree-order-update.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-order-update.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/tree-order-update.tcl	9 Feb 2004 19:48:44 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/tree-order-update.tcl	6 Nov 2008 15:50:44 -0000	1.4
@@ -9,6 +9,7 @@
     sort_key:array
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 }
 
 permission::require_permission -object_id $tree_id -privilege category_tree_write
@@ -30,7 +31,7 @@
             lappend child($parent_id) [list $count $category_id 0 0]
         }
     }
-    set last_ind [expr ($count / 5) + 1]
+    set last_ind [expr {($count / 5) + 1}]
 
     set count 1
     set stack [list]
@@ -54,7 +55,7 @@
             set stack [concat [lsort -integer -index 0 $child($act_category)] $stack]
         } else {
             ## this category has no children, so it is done
-            lappend done_list [list $act_category $count [expr $count + 1]]
+            lappend done_list [list $act_category $count [expr {$count + 1}]]
             incr count 1
         }
         incr count 1
@@ -77,4 +78,4 @@
     return
 }
 
-ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id}]
+ad_returnredirect [export_vars -no_empty -base tree-view {tree_id locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl	1 Mar 2005 00:01:27 -0000	1.5
+++ openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl	6 Nov 2008 15:50:44 -0000	1.6
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,notnull
+    ctx_id:integer,optional
 } 
 
 set user_id [auth::require_login]
@@ -20,4 +21,4 @@
 
 category_tree::unmap -tree_id $tree_id -object_id $object_id
 
-ad_returnredirect [export_vars -no_empty -base object-map {locale object_id}]
+ad_returnredirect [export_vars -no_empty -base object-map {locale object_id ctx_id}]
Index: openacs-4/packages/categories/www/cadmin/tree-unmap.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-unmap.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/categories/www/cadmin/tree-unmap.tcl	1 Mar 2005 00:01:27 -0000	1.6
+++ openacs-4/packages/categories/www/cadmin/tree-unmap.tcl	6 Nov 2008 15:50:44 -0000	1.7
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,notnull
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -28,13 +29,13 @@
 
 set page_title "Unmap tree"
 
-set delete_url [export_vars -no_empty -base tree-unmap-2 { tree_id locale object_id }]
-set cancel_url [export_vars -no_empty -base object-map { locale object_id }]
+set delete_url [export_vars -no_empty -base tree-unmap-2 { tree_id locale object_id ctx_id}]
+set cancel_url [export_vars -no_empty -base object-map { locale object_id ctx_id}]
 
 set object_context [category::get_object_context $object_id]
 set object_name [lindex $object_context 1]
 set tree_name $tree(tree_name)
 
-set context_bar [list $object_context [list [export_vars -no_empty -base object-map {locale object_id}] "Category Management"] "Unmap \"$tree_name\""]
+set context_bar [list $object_context [list [export_vars -no_empty -base object-map {locale object_id ctx_id}] [_ categories.cadmin]] "Unmap \"$tree_name\""]
 
 ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-usage.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-usage.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/categories/www/cadmin/tree-usage.tcl	1 Mar 2005 00:01:27 -0000	1.7
+++ openacs-4/packages/categories/www/cadmin/tree-usage.tcl	6 Nov 2008 15:50:44 -0000	1.8
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     context_bar:onevalue
@@ -29,7 +30,9 @@
 set tree_description $tree(description)
 set page_title "Modules using Category Tree \"$tree_name\""
 
-set context_bar [category::context_bar $tree_id $locale [value_if_exists object_id]]
+set context_bar [category::context_bar $tree_id $locale \
+                     [value_if_exists object_id] \
+                     [value_if_exists ctx_id]]
 lappend context_bar "Usage"
 
 
@@ -40,7 +43,7 @@
 set instances_without_permission 0
 foreach instance $instance_list {
     util_unlist $instance package object_id object_name package_id instance_name read_p
-    set unmap_url [export_vars -no_empty -base tree-unmap {tree_id object_id}]
+    set unmap_url [export_vars -no_empty -base tree-unmap {tree_id object_id ctx_id}]
 
     if {$read_p == "t"} {
 	template::multirow append modules $package $object_id $object_name $package_id $instance_name $read_p $unmap_url
Index: openacs-4/packages/categories/www/cadmin/tree-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/tree-view.adp	14 Dec 2003 15:36:58 -0000	1.3
+++ openacs-4/packages/categories/www/cadmin/tree-view.adp	6 Nov 2008 15:50:44 -0000	1.4
@@ -3,6 +3,6 @@
 <property name="context_bar">@context_bar;noquote@</property>
 <property name="locale">@locale;noquote@</property>
 
-<include src="/packages/categories/lib/tree-form" &="tree_id" &="locale">
+<include src="/packages/categories/lib/tree-form" &="tree_id" &="locale" &="ctx_id">
 
 <listtemplate name="one_tree"></listtemplate>
Index: openacs-4/packages/categories/www/cadmin/tree-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/categories/www/cadmin/tree-view.tcl	6 Jun 2005 09:43:47 -0000	1.12
+++ openacs-4/packages/categories/www/cadmin/tree-view.tcl	6 Nov 2008 15:50:44 -0000	1.13
@@ -8,6 +8,7 @@
     tree_id:integer,notnull
     {locale ""}
     object_id:integer,optional
+    ctx_id:integer,optional
 } -properties {
     page_title:onevalue
     tree_name:onevalue
@@ -31,9 +32,9 @@
 
 set page_title "Category Tree \"$tree_name\""
 if {[info exists object_id]} {
-    set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id}] "[_ categories.cadmin]"] $tree_name]
+    set context_bar [list [category::get_object_context $object_id] [list [export_vars -no_empty -base object-map {locale object_id ctx_id}] "[_ categories.cadmin]"] $tree_name]
 } else {
-    set context_bar [list [list ".?[export_vars -no_empty {locale}]" "[_ categories.cadmin]"] $tree_name]
+    set context_bar [list [list ".?[export_vars -no_empty {locale ctx_id}]" "[_ categories.cadmin]"] $tree_name]
 }
 
 set can_write_p [permission::permission_p -object_id $tree_id -privilege category_tree_write]
@@ -47,7 +48,7 @@
     util_unlist $category category_id category_name deprecated_p level
     incr sort_key 10
 
-    template::multirow append one_tree $category_name $sort_key $category_id $deprecated_p $level [string repeat "&nbsp;" [expr ($level-1)*5]]
+    template::multirow append one_tree $category_name $sort_key $category_id $deprecated_p $level [string repeat "&nbsp;" [expr {($level-1)*5}]]
 }
 
 
@@ -58,18 +59,18 @@
 
 multirow extend one_tree usage_url add_url edit_url delete_url parent_url phase_in_url phase_out_url links_view_url synonyms_view_url
 multirow foreach one_tree {
-    set usage_url [export_vars -no_empty -base category-usage { category_id tree_id locale object_id }]
+    set usage_url [export_vars -no_empty -base category-usage { category_id tree_id locale object_id ctx_id}]
     if { $can_write_p } {
-	set add_url [export_vars -no_empty -base category-form { { parent_id $category_id } tree_id locale object_id }]
-	set edit_url [export_vars -no_empty -base category-form { category_id tree_id locale object_id }]
-	set delete_url [export_vars -no_empty -base category-delete { category_id tree_id locale object_id }]
-	set parent_url [export_vars -no_empty -base category-parent-change { category_id tree_id locale object_id }]
-	set links_view_url [export_vars -no_empty -base category-links-view { category_id tree_id locale object_id }]
-	set synonyms_view_url [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id }]
+	set add_url [export_vars -no_empty -base category-form { { parent_id $category_id} tree_id locale object_id ctx_id}]
+	set edit_url [export_vars -no_empty -base category-form { category_id tree_id locale object_id ctx_id}]
+	set delete_url [export_vars -no_empty -base category-delete { category_id tree_id locale object_id ctx_id}]
+	set parent_url [export_vars -no_empty -base category-parent-change { category_id tree_id locale object_id ctx_id}]
+	set links_view_url [export_vars -no_empty -base category-links-view { category_id tree_id locale object_id ctx_id}]
+	set synonyms_view_url [export_vars -no_empty -base synonyms-view { category_id tree_id locale object_id ctx_id}]
 	if { [template::util::is_true $deprecated_p] } {
-	    set phase_in_url [export_vars -no_empty -base category-phase-in { category_id tree_id locale object_id }]
+	    set phase_in_url [export_vars -no_empty -base category-phase-in { category_id tree_id locale object_id ctx_id}]
 	} else {
-	    set phase_out_url [export_vars -no_empty -base category-phase-out { category_id tree_id locale object_id }]
+	    set phase_out_url [export_vars -no_empty -base category-phase-out { category_id tree_id locale object_id ctx_id}]
 	}
     }
 }
@@ -139,13 +140,13 @@
 	"Update ordering" "tree-order-update" "Update ordering from values in list"
     }
     set actions [list \
-		     "Add root category" [export_vars -no_empty -base category-form { tree_id locale object_id }] "Add category at the root level" \
-		     "Copy tree" [export_vars -no_empty -base tree-copy { tree_id locale object_id }] "Copy categories from other tree" \
-		     "Delete tree" [export_vars -no_empty -base tree-delete { tree_id locale object_id }] "Delete this category tree" \
-		     "Applications" [export_vars -no_empty -base tree-usage { tree_id locale object_id }] "Applications using this tree"]
+		     "Add root category" [export_vars -no_empty -base category-form { tree_id locale object_id ctx_id}] "Add category at the root level" \
+		     "Copy tree" [export_vars -no_empty -base tree-copy { tree_id locale object_id ctx_id}] "Copy categories from other tree" \
+		     "Delete tree" [export_vars -no_empty -base tree-delete { tree_id locale object_id ctx_id}] "Delete this category tree" \
+		     "Applications" [export_vars -no_empty -base tree-usage { tree_id locale object_id ctx_id}] "Applications using this tree"]
 
     if { $can_grant_p } {
-	lappend actions "Permissions" [export_vars -no_empty -base permission-manage { tree_id locale object_id }] "Manage permissions for tree"
+	lappend actions "Permissions" [export_vars -no_empty -base permission-manage { tree_id locale object_id ctx_id}] "Manage permissions for tree"
     }
 
 }
@@ -156,6 +157,6 @@
     -key category_id \
     -actions $actions \
     -bulk_actions $bulk_actions \
-    -bulk_action_export_vars { tree_id locale object_id }
+    -bulk_action_export_vars { tree_id locale object_id ctx_id}
 
 ad_return_template