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.6 -r1.7 --- openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl 18 Sep 2002 14:54:55 -0000 1.6 +++ openacs-4/packages/acs-tcl/tcl/navigation-procs.tcl 23 Sep 2002 11:30:29 -0000 1.7 @@ -1,169 +1,176 @@ ad_library { - Provides procedures to spit out the navigational parts of the site. @cvs-id $Id$ @author philg@mit.edu @creation-date 11/5/98 (adapted originally from the Cognet server) - edited February 28, 1999 by philg to include support for a - Yahoo-style navigation system (showing users where they are in a - hierarchy) - } +# edited February 28, 1999 by philg to include support for a +# Yahoo-style navigation system (showing users where they are in a +# hierarchy) -ad_proc ad_context_bar { +ad_proc -public ad_context_bar_html { + {-separator " : "} + context +} { + Generate the an html fragement 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 
+    calls like ad_context_bar and ad_admin_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
+
+    @see ad_context_bar
+    @see ad_admin_context_bar
+} { 
+    set out {}
+    foreach element [lrange $context 0 [expr [llength $context] - 2]] { 
+        append out "[lindex $element 1]$separator"
+    }
+    append out [lindex $context end]
+
+    return $out
+}
+
+ad_proc -public ad_context_bar { 
     -node_id
     args
 } {
-
     Returns a Yahoo-style hierarchical navbar. Includes "Your Workspace" or "Administration"
     if applicable, and the subsite if not global.
 
     @param node_id If provided work up from this node, otherwise the current node
 
+    @return an html fragment generated by ad_context_bar_html
+    
+    @see ad_context_bar_html
+    @see ad_admin_context_bar
 } {
+    if { ![info exists node_id] } {
+        set node_id [ad_conn node_id]
+    }
+    if {![parameter::get -package_id [site_node_closest_ancestor_package "acs-subsite"] -parameter ShowContextBarP -default 1]} {
+	return ""
+    }
 
-  set context [list]
+    set context [list]
 
-  if {[ad_conn user_id] != 0 && ![string match /pvt/home* [ad_conn url]]} {
-      lappend context [list "[ad_pvt_home]" "[ad_pvt_home_name]"]
-  }
+    if {[ad_conn user_id] != 0 && ![string match /pvt/home* [ad_conn url]]} {
+        lappend context [list "[ad_pvt_home]" "[ad_pvt_home_name]"]
+    }
 
-  if { ![info exists node_id] } {
-      set node_id [ad_conn node_id]
-  }
 
-  db_foreach context {
-    select site_node.url(node_id) as url, object_id,
-           acs_object.name(object_id) as object_name,
-           level
-    from site_nodes
-    start with node_id = :node_id
-    connect by prior parent_id = node_id
-    order by level asc
-  } {
-      lappend context [list $url $object_name]
-  }
+    db_foreach context {} { 
+        lappend context [list $url $object_name]
+    }
+    if { [string match admin/* [ad_conn extra_url]] } {
+        lappend context [list "[ad_conn package_url]admin/" \
+                             "Administration"]
+    }
 
-  if { [string match admin/* [ad_conn extra_url]] } {
-    lappend context [list "[ad_conn package_url]admin/" \
-	"Administration"]
-  }
-
-  set context [concat $context $args]
-
-  set out [list]
-
-  for { set i 0 } { $i < [llength $context] } { incr i } {
-    set element [lindex $context $i]
-    if { $i == [llength $context] - 1 } {
-      if {[llength $args] == 0} {
-	lappend out [lindex $element 1]
-      } else {
-	lappend out $element
-      }
-    } else {
-      lappend out "[lindex $element 1]"
+    if {[llength $args] == 0} { 
+        # fix last element to just be literal string
+        set context [lreplace $context end end [lindex [lindex $context end] 1]]
     }
-  }
 
-  return [join $out " : "]
+    return [ad_context_bar_html [concat $context $args]]
 }
 
+
+
 # a context bar, rooted at the workspace
 
-proc_doc ad_context_bar_ws args {
+ad_proc -deprecated -public ad_context_bar_ws args {
     Returns a Yahoo-style hierarchical navbar, starting with a link to workspace.
-} {
-    set choices [list "[ad_pvt_home_link]"]
 
+    @param list of url desc ([list [list url desc] [list url desc] ... "terminal"])
+    @return an html fragment generated by ad_context_bar_html
 
-    set index 0
-    foreach arg $args {
-	incr index
-	if { $index == [llength $args] } {
-	    lappend choices $arg
-	} else {
-	    lappend choices "[lindex $arg 1]"
-	}
-    }
-    return [join $choices " : "]
+    @see ad_context_bar
+} {
+    return [ad_context_bar_html [concat [list [list "[ad_pvt_home]" "[ad_pvt_home_name]"]] $args]]
 }
 
 # a context bar, rooted at the workspace or index, depending on whether
 # user is logged in
 
-proc_doc ad_context_bar_ws_or_index args {
+ad_proc -deprecated -public ad_context_bar_ws_or_index args {
     Returns a Yahoo-style hierarchical navbar, starting with a link to
     either the workspace or /, depending on whether or not the user is
-    logged in.  
+    logged in.  You should probably be using ad_context_bar and 
+    then only in the sitewide master.
+
+    @param args list of url desc ([list [list url desc] [list url desc] ... "terminal"])
+    @return an html fragment generated by ad_context_bar_html
+
+    @see ad_context_bar
 } {
-    if { [ad_get_user_id] == 0 } {
-	set choices [list "[ad_system_name]"] 
+    if { [ad_conn user_id] == 0 && ![string match /pvt/home* [ad_conn url]] } { 
+	set choices [list [list "/" [ad_system_name]]]
     } else {
-	set choices [list "[ad_pvt_home_link]"]
+	set choices [list [list [ad_pvt_home] [ad_pvt_home_name]]]
     }
 
-# lars, Apr25-00: Took out this old scoping thing
-#
-#    if { [ad_conn scope on_which_table] != "." } {
-#	if { [llength $args] == 0 } {
-#	    lappend choices [ad_conn scope name]
-#	} else {
-#	    lappend choices "[ad_conn scope name]"
-#	}
-#    }
-
-    set index 0
-    foreach arg $args {
-	incr index
-	if { $index == [llength $args] } {
-	    lappend choices $arg
-	} else {
-	    lappend choices "[lindex $arg 1]"
-	}
-    }
-    return [join $choices " : "]
+    return [ad_context_bar_html [concat $choices $args]]
 }
 
-proc_doc ad_admin_context_bar args { 
+ad_proc -public ad_admin_context_bar args { 
     Returns a Yahoo-style hierarchical navbar, starting with links
     workspace and admin home.
     Suitable for use in pages underneath /admin.
+
+    @param args list of url desc ([list [list url desc] [list url desc] ... "terminal"])
+    @return an html fragment generated by ad_context_bar_html
+
+    @see ad_context_bar
 } {
-    set choices [list "[ad_pvt_home_link]" "ACS System Wide Administration"]
-    set index 0
-    foreach arg $args {
-	incr index
-	if { $index == [llength $args] } {
-	    lappend choices $arg
-	} else {
-	    lappend choices "[lindex $arg 1]"
-	}
+    if {![llength $args]} { 
+        set choices [list [list [ad_pvt_home] [ad_pvt_home_name]] \
+                         [list /acs-admin/ "ACS System Wide Administration"]]
+    } else { 
+        set choices [list [list [ad_pvt_home] [ad_pvt_home_name]] \
+                         "ACS System Wide Administration"]
     }
-    return [join $choices " : "]
+
+    return [ad_context_bar_html [concat $choices $args]]
 }
 
-proc_doc ad_navbar args {
+ad_proc -public ad_navbar args {
     produces navigation bar. notice that navigation bar is different
     than context bar, which exploits a tree structure. navbar will just
     display a list of nicely formatted links.
+
+    @param args list of url desc ([list [list url desc] [list url desc]])
+
+    @return html fragment
+
+    @see ad_choice_bar
 } {
     set counter 0
     foreach arg $args {
 	lappend link_list "[lindex $arg 1]"
 	incr counter
     }
-    if { $counter > 0 } {
+    if { $counter } {
 	return "\[[join $link_list " | "]\]"
     } else {
 	return ""
     }
 }
 
-proc_doc ad_choice_bar { items links values {default ""} } {
+ad_proc -public ad_choice_bar { items links values {default ""} } {
     Displays a list of choices (Yahoo style), with the currently selected one highlighted.
+
+    @see ad_navbar 
 } {
 
     set count 0