::xotcl::Class
::xowiki::MenuBar
Class Hierarchy of ::xowiki::MenuBar
- ::xotcl::Object
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- getExitHandler, setExitHandler, unsetExitHandler
- ::xowiki::MenuBar
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- id
- Methods for instances:
- add_menu, add_menu_item, additional_sub_menu, clear_menu, content, get_prop, init, render-yui, update_items
- Methods to be applied on the class:
- Methods provided by the meta-class
Class Relations
- superclass: ::xotcl::Object
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xowiki::MenuBar \
-superclass ::xotcl::Object \
-parameter id
Methods
instproc add_menu
::xowiki::policy5 instproc add_menu {-name {-label ""}} {
my instvar Menues
if {$name in $Menues} {
error "menu $name exists already"
}
if {[string match {[a-z]*} $name]} {
error "names must start with uppercase, provided name '$name'"
}
my lappend Menues $name
if {$label eq ""} {set label $name}
my set Menu($name) [list text $label]
#my log "menues: $Menues"
}
instproc add_menu_item
::xowiki::policy5 instproc add_menu_item {-name:required -item:required} {
#
# The provided items are of the form of attribute-value pairs
# containing at least attributes "text" and "url"
# (e.g. "text .... url ....").
#
my instvar Menues
set full_name $name
if {![regexp {^([^.]+)[.](.+)$} $name _ menu name]} {
error "menu item name '$name' not of the form Menu.Name"
}
if {$menu ni $Menues} {
error "menu $menu does not exist"
}
if {[string match {[a-z]*} $name]} {
error "names must start with uppercase, provided name '$name'"
}
#
# get group name (syntax: Menu.Group.Item)
#
set group_name ""
regexp {^[^.]+[.]([^.]+)[.].*} $full_name _ group_name
#
# provide a default label
#
regsub -all {[.]} $full_name - full_name
array set "" [list text "#xowiki.menu-$full_name#" group $group_name]
array set "" $item
set item [array get ""]
#
# If an entry with the given name exists, update it. Otherwise add
# such an entry.
#
set updated 0
set newitems [list]
foreach {n i} [my set Menu($menu)] {
if {$n eq $name} {
lappend newitems $name $item
set updated 1
} else {
lappend newitems $n $i
}
}
if {$updated} {
my set Menu($menu) $newitems
} else {
my lappend Menu($menu) $name $item
}
}
instproc additional_sub_menu
::xowiki::policy5 instproc additional_sub_menu {-kind:required -pages:required -owner:required} {
my set submenu_pages($kind) $pages
my set submenu_owner($kind) $owner
}
instproc clear_menu
::xowiki::policy5 instproc clear_menu -menu:required {
array set "" [my set Menu($menu)]
my set Menu($menu) [list text $(text)]
}
instproc content
::xowiki::policy5 instproc content {} {
set result [list id [my id]]
foreach m [my set Menues] {
lappend result $m [my set Menu($m)]
}
return $result
}
instproc get_prop
::xowiki::policy5 instproc get_prop {dict key {default {}}} {
if {![dict exists $dict $key]} {
return $default
}
return [dict get $dict $key]
}
instproc init
::xowiki::policy5 instproc init {} {
my set Menues [list]
my destroy_on_cleanup
}
instproc render-yui
::xowiki::policy5 instproc render-yui {} {
set M [my content]
set mb [::xowiki::YUIMenuBar -id [my get_prop $M id] -configuration {
{autosubmenudisplay: false, keepopen: true, lazyload: false}
} {
foreach {menu_att menu} $M {
if {$menu_att eq "id"} continue
::xowiki::YUIMenuBarItem -text [my get_prop $menu text] {
::xowiki::YUIMenu {
foreach {item_att item} $menu {
if {[string match {[a-z]*} $item_att]} continue
set text [my get_prop $item text]
set url [my get_prop $item url]
set group [my get_prop $item group]
#my msg "ia=$item_att group '$group' // t=$text item=$item"
::xowiki::YUIMenuItem -text $text -href $url -group $group {}
}
}
}
}
}]
return [$mb asHTML]
}
instproc update_items
::xowiki::policy5 instproc update_items {-package_id:required -nls_language:required -parent_id:required -return_url -autoname -template_file items} {
# A folder page can contain extra menu entries (sample
# below). Iterate of the extra_menu property and add according
# menu entries.
#{form_link -name New.Page -label New Page -form en:page.form}
foreach me $items {
array unset ""
set kind [lindex $me 0]
if {[string range $kind 0 0] eq "#"} continue
my log "ME <$me> kind=$kind"
switch $kind {
clear_menu {
# sample entry: clear_menu -menu New
array set "" [lrange $me 1 end]
my clear_menu -menu $(-menu)
}
form_link -
entry {
# sample entry: entry -name New.YouTubeLink -label YouTube -form en:YouTube.form
if {$kind eq "form_link"} {
my log "$me, name 'form_link' is deprecated, use 'entry' instead"
}
array set "" [lrange $me 1 end]
if {[info exists (-form)]} {
set link [$package_id make_form_link -form $(-form) -parent_id $parent_id -nls_language $nls_language -return_url $return_url]
} elseif {[info exists (-object_type)]} {
set link [$package_id make_link -with_entities 0 $package_id edit-new [list object_type $(-object_type)] parent_id return_url autoname template_file]
} else {
my log "Warning: no link specified"
set link ""
}
set item [list url $link]
if {[info exists (-label)]} {lappend item text $(-label)}
my add_menu_item -name $(-name) -item $item
}
default { error "unknown kind of menu entry: $kind" }
}
}
}