Index: openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl,v diff -u -r1.48 -r1.49 --- openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl 6 Oct 2018 09:26:52 -0000 1.48 +++ openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl 3 Sep 2024 15:37:34 -0000 1.49 @@ -14,20 +14,20 @@ -separator context } { - Generate the an html fragment for a context bar. + Generate the an HTML fragment for a context bar. This is the function that takes a list in the format
     [list [list url1 text1] [list url2 text2] ... "terminal text"]
     
-    and generates the html fragment.  In general the higher level
+    and generates the HTML fragment.  In general, the higher level
     proc ad_context_bar should be
     used, and then only in the sitewide master rather than on
     individual pages.
 
     @param separator The text placed between each link
     @param context list as with ad_context_bar
 
-    @return html fragment
+    @return HTML fragment
 
     @see ad_context_bar
 } {
@@ -102,7 +102,7 @@
     @param node_id If provided work up from this node, otherwise the current node
     @param from_node If provided do not generate links to the given node and above.
 
-    @return an html fragment generated by ad_context_bar_html
+    @return an HTML fragment generated by ad_context_bar_html
 
     @see ad_context_bar_html
 } {
@@ -129,14 +129,20 @@
 
     foreach elm [ad_context_node_list -from_node $from_node $node_id] {
         lassign $elm elm_0 elm_1
-        if { $node_id_url_end > 0 && [string match -nocase $node_id_url [string range $elm_0 0 ${node_id_url_end}-1] ] } {
+        if { $node_id_url_end > 0
+             && [string match -nocase $node_id_url [string range $elm_0 0 $node_id_url_end-1] ]
+         } {
             set elm_0 [string range $elm_0 $node_id_url_end end]
         }
         template::multirow append $multirow $elm_0 $elm_1
     }
 
     if { [string match "admin/*" [ad_conn extra_url]] } {
-        template::multirow append $multirow "[ad_conn package_url]admin/" "[_ acs-tcl.Administration]"
+        template::multirow append $multirow \
+            "[ad_conn package_url]admin/" \
+            [expr {[ad_conn package_key] ne "acs-subsite"
+                   ? [_ acs-tcl.Administration]
+                   : [_ acs-subsite.Administration]}]
     }
 
     if { [llength $context] == 0 } {
@@ -156,14 +162,15 @@
     -separator
     args
 } {
-    Returns a Yahoo-style hierarchical navbar. Includes "Administration"
-    if applicable, and the subsite if not global. 'args' can be either
-    one or more lists, or a simple string.
+    Returns a Yahoo-style hierarchical navbar. Includes
+    "Administration" or "Subsite Administration" if applicable, and
+    the subsite if not global. 'args' can be either one or more lists,
+    or a simple string.
 
     @param node_id If provided work up from this node, otherwise the current node
     @param from_node If provided do not generate links to the given node and above.
     @param separator The text placed between each link (passed to ad_context_bar_html if provided)
-    @return an html fragment generated by ad_context_bar_html
+    @return an HTML fragment generated by ad_context_bar_html
 
     @see ad_context_bar_html
 } {
@@ -175,16 +182,26 @@
         set node_id [ad_conn node_id]
     }
 
+    #
+    # Get context info for this node. In case of "early" errors
+    # (e.g. invalid characters in the URL), the result might be empty.
+    #
     set context [ad_context_node_list -from_node $from_node $node_id]
 
     if { [string match "admin/*" [ad_conn extra_url]] } {
         lappend context [list "[ad_conn package_url]admin/" \
-                             [_ acs-tcl.Administration]]
+                             [expr {[ad_conn package_key] ne "acs-subsite"
+                                    ? [_ acs-tcl.Administration]
+                                    : [_ acs-subsite.Administration]}]]
     }
 
     if {[llength $args] == 0} {
-        # fix last element to just be literal string
-        lset context end [lindex $context end 1]
+        #
+        # Fix last element to just be literal string
+        #
+        if {$context ne ""} {
+            lset context end [lindex $context end 1]
+        }
     } else {
         if {![string match "\{*" $args]} {
             # args is not a list, transform it into one.
@@ -210,17 +227,17 @@
 
     @param args list of url desc ([list [list url desc] [list url desc]])
 
-    @return html fragment
+    @return HTML fragment
 
     @see ad_context_bar_html
 } {
     set counter 0
     foreach arg $args {
-        lappend link_list [subst {[ns_quotehtml [lindex $element 1]]}]
+        lappend link_list [subst {[ns_quotehtml [lindex $arg 1]]}]
         incr counter
     }
     if { $counter } {
-        return "\[[join $link_list " | "]\]"
+        return "\[[join $link_list { | }]\]"
     } else {
         return ""
     }
@@ -290,7 +307,7 @@
     set netscape_p 0
 
     # get the version
-    set user_agent [ns_set get [ad_conn headers] User-Agent]
+    set user_agent [ns_set iget [ad_conn headers] User-Agent]
     regexp -nocase "mozilla/(\[^\.\ \]*)" $user_agent match version
 
     # IE browsers have MSIE and Mozilla in their user-agent header
@@ -319,7 +336,7 @@
     set netscape_p 0
 
     # get the version
-    set user_agent [ns_set get [ad_conn headers] User-Agent]
+    set user_agent [ns_set iget [ad_conn headers] User-Agent]
     regexp -nocase "mozilla/(\[^\.\ \]*)" $user_agent match version
 
     # IE browsers have MSIE and Mozilla in their user-agent header
@@ -395,9 +412,9 @@
 
 
 #     foreach naked_pattern [ad_naked_html_patterns] {
-# 	if { [string match $naked_pattern $url_stub] } {
-# 	    # want the global admins with no menu, but not the domain admin
-# 	    return ""
+#       if { [string match $naked_pattern $url_stub] } {
+#           # want the global admins with no menu, but not the domain admin
+#           return ""
 #         }
 #     }
 
@@ -413,89 +430,89 @@
 #     set return_string ""
 
 #     if { $java_script_p } {
-#     	append return_string "
-# 	"
+#       function go_to_url(url) \{
+#               if (url \!= \"\") \{
+#                       self.location=url;
+#               \}
+#               return;
+#       \}
+#       // -->
+#       "
 #     } else {
 
-# 	append return_string "
+#       append return_string "
 
-# 	"
+#       function go_to_url(url) \{
+#       \}
+#       // -->
+#       "
 #     }
 
 #     # We divide up the screen into 4 areas top to bottom:
@@ -510,10 +527,10 @@
 
 
 #     if {$netscape3_p} {
-# 	append return_string "\"Cognet\"
+#       append return_string "\"Cognet\"
 # "
 #     }  else {
-# 	append return_string "
+#       append return_string "
 # 
# # +# append return_string "\"go\" +# #
\"Cognet\"" @@ -529,12 +546,12 @@ #   " # if {$netscape3_p} { -# append return_string "   +# append return_string "   # #
" # } else { -# append return_string "\"go\" -#
# # " @@ -547,37 +564,37 @@ # set uplevel_string "\"Up\"" # foreach url_pattern [ad_no_uplevel_patterns] { -# if { [regexp $url_pattern $url_stub match] } { -# set uplevel_string "" -# } +# if { [regexp $url_pattern $url_stub match] } { +# set uplevel_string "" +# } # } # append return_string $uplevel_string # append return_string "" # if {$netscape3_p} { -# append return_string "" +# append return_string "
" # } else { -# append return_string "
+# append return_string "
#
# " # } # # Navigation Table # foreach item $menu_items { -# if { $item == [menu_highlight $section] } { -# append return_string "" -# } else { -# append return_string "" -# } +# if { $item == [menu_highlight $section] } { +# append return_string "" +# } else { +# append return_string "" +# } # } # append return_string " # #
\"$item\"
\"$item\"
\"$item\"
\"$item\"
# # -# [menu_subsection $section] +# [menu_subsection $section] # #
" @@ -603,22 +620,22 @@ # set full_filename "$::acs::pageroot$url_stub" # foreach naked_pattern [ad_naked_html_patterns] { -# if { [string match $naked_pattern $url_stub] } { -# return "" -# } +# if { [string match $naked_pattern $url_stub] } { +# return "" +# } # } # set netscape3_p 0 # if {[netscape3_browser]} { -# set netscape3_p 1 +# set netscape3_p 1 # } # append return_string "
" # # close up the table # if {$netscape3_p != 1} { -# append return_string " +# append return_string " # " # }