Index: openacs-4/packages/xowiki/tcl/folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/folder-procs.tcl,v diff -u -r1.55 -r1.56 --- openacs-4/packages/xowiki/tcl/folder-procs.tcl 30 Jan 2019 20:25:16 -0000 1.55 +++ openacs-4/packages/xowiki/tcl/folder-procs.tcl 3 Sep 2024 15:37:55 -0000 1.56 @@ -5,7 +5,7 @@ * An xowiki includelet to display the "folders" * An xowiki includelet to display the "child-resources" - of a page (e.g. the contents of a folder) + of a page (e.g. the contents of a folder) @author Michael Aram @author Gustaf Neumann @@ -32,10 +32,17 @@ {-context_tree_view false} }} {id "[xowiki::Includelet js_name [self]]"} + } -ad_doc { + + List the folder tree of the current instance + + @param show_full_tree (default false) + @param context_tree_view (default false) + } folders instproc include_head_entries {} { - switch [${:package_id} get_parameter PreferredCSSToolkit bootstrap] { + switch [::xowiki::CSS toolkit] { yui {::xowiki::Tree include_head_entries -renderer yuitree -style folders} bootstrap - default { ::xowiki::Tree include_head_entries -renderer bootstrap3 } @@ -46,7 +53,7 @@ :get_parameters set tree [:build_tree] - switch [${:package_id} get_parameter PreferredCSSToolkit bootstrap] { + switch [::xowiki::CSS toolkit] { yui { set js " var [:js_name]; @@ -63,17 +70,19 @@ } bootstrap - default { + #:msg "render tree $tree // [$tree procsearch render ]" set HTML [$tree render -style bootstrap3-folders] + #set HTML [$tree render -style list -properties {CSSclass_top_ul xowiki-tree}] } } #:log HTML=$HTML return $HTML } folders instproc folder_query { - -form_id:required - -package_id:required - {-parent_id ""} + -form_id:integer,required + -package_id:integer,required + {-parent_id:integer,0..1 ""} } { if {$parent_id eq ""} { return [subst { @@ -82,13 +91,6 @@ and publish_status = 'ready' }] } - #return [subst { - # select * from xowiki_form_instance_children ch - # left join xowiki_form_instance_attributes xa on (ch.item_id = xa.item_id) - # where page_template = '$form_id' and ch.package_id = '$package_id' - # and root_item_id = '$parent_id' - # and publish_status = 'ready' - #}] # # Oracle query missing @@ -100,7 +102,6 @@ o.object_id, o.object_type, o.title AS object_title, o.context_id, o.security_inherit_p, o.creation_user, o.creation_date, o.creation_ip, o.last_modified, o.modifying_user, o.modifying_ip, - --o.tree_sortkey, o.max_child_sortkey, cr.revision_id, cr.title, content_revision__get_content(cr.revision_id) AS text, cr.description, cr.publish_date, cr.mime_type, cr.nls_language, xowiki_form_page.xowiki_form_page_id, @@ -113,9 +114,9 @@ WITH RECURSIVE child_items AS ( select * from xowiki_form_instance_item_index where item_id = '$parent_id' - UNION ALL - select xi.* from xowiki_form_instance_item_index xi, child_items - where xi.parent_id = child_items.item_id + UNION ALL + select xi.* from xowiki_form_instance_item_index xi, child_items + where xi.parent_id = child_items.item_id ) select * from child_items where page_template = '$form_id' and package_id = '$package_id' and publish_status = 'ready') xi @@ -130,40 +131,58 @@ folders instproc collect_folders { -package_id:required - -folder_form_id:required - -link_form_id:required + -folder_form_id + -link_form_id {-parent_id ""} {-subtree_query ""} {-depth 3} } { set folders [list] + # + # In case no "folder_form_id" or "link_form_id" were provided, + # fetch it here. + # + foreach {var form} { + folder_form en:folder.form + link_form en:link.form + } { + if {![info exists ${var}_id]} { + set $var [::$package_id instantiate_forms -forms $form] + set ${var}_id [[set $var] item_id] + } + } + # safety belt, for recursive structures - if {$depth < 1} {return $folders} + if {$depth < 1} { + return $folders + } # - # get folders + # Get Folders # set sql [:folder_query -form_id $folder_form_id \ -parent_id $parent_id \ -package_id $package_id] + #ns_log notice "folder_pages:\n$sql" set folder_pages [::xowiki::FormPage instantiate_objects -sql $sql \ -named_objects true -object_named_after "item_id" \ + -keep_existing_objects true \ -object_class ::xowiki::FormPage -initialize true] # - # get links + # Get links. # set sql [:folder_query -form_id $link_form_id \ -parent_id $parent_id \ -package_id $package_id] #ns_log notice "links (parent-id ='$parent_id'):\n$sql" set links [::xowiki::FormPage instantiate_objects -sql $sql \ - -named_objects true -object_named_after "item_id" \ - -object_class ::xowiki::FormPage -initialize true] + -named_objects true -object_named_after "item_id" \ + -object_class ::xowiki::FormPage -initialize true] - #my msg "[llength [$links children]] links" + #:msg "[llength [$links children]] links under $parent_id " set folders [$folder_pages children] @@ -174,12 +193,14 @@ foreach l [$links children] { set link_type [$l get_property_from_link_page link_type] set cross_package [$l get_property_from_link_page cross_package] + #:log "==================== [$l name]: link_type $link_type cross package $cross_package" if {$link_type ne "folder_link"} continue if {$cross_package} { # - # we found a cross-package link. These kind of links require further queries + # We found a cross-package link. These kind of links require + # further queries. # set target [$l get_target_from_link_page] set sub_folders [:collect_folders -package_id [$target physical_package_id] \ @@ -189,9 +210,9 @@ foreach f $sub_folders { - #my msg "$f [$f name] is a folder-link pointing to $target [$target name] current ${:current_folder_id}" + #:msg "$f [$f name] is a folder-link pointing to $target [$target name] current ${:current_folder_id}" if {[$f parent_id] eq [$target item_id]} { - #my msg "1 found child [$f name] and reset parent_id from [$f parent_id] to [$l item_id], package_id [$l package_id]" + #:msg "1 found child [$f name] and reset parent_id from [$f parent_id] to [$l item_id], package_id [$l package_id]" # # reset the current_folder if necessary # @@ -204,22 +225,22 @@ $f set_resolve_context -package_id [$l package_id] -parent_id [$l item_id] # # TODO we could save the double-fetch by collecting in - # get_form_entries via item-ids, not via new-objects + # get_form_entries via item_ids, not via new objects. # #::xo::db::CrClass get_instance_from_db -item_id [$f item_id] [$f item_id] set_resolve_context -package_id [$l package_id] -parent_id [$l item_id] } else { - #my msg "2 found child [$f name] and reset parent_id from [$f parent_id] to [$f parent_id], package id [$l package_id]" + #:msg "2 found child [$f name] and reset parent_id from [$f parent_id] to [$f parent_id], package id [$l package_id]" $f set_resolve_context -package_id [$l package_id] -parent_id [$f parent_id] #::xo::db::CrClass get_instance_from_db -item_id [$f item_id] [$f item_id] set_resolve_context -package_id [$l package_id] -parent_id [$f parent_id] } - #my msg "including $f [$f name] [$f item_id]" + #:msg "including $f [$f name] [$f item_id]" lappend folders $f } } - #my msg link=$link + #:msg link=$link lappend folders $l } return $folders @@ -233,160 +254,138 @@ set page [$page set __link_source] } set package_id [::xo::cc package_id] - set with_links [$package_id get_parameter "MenuBarSymLinks" 0] - #my ds [::xo::cc serialize] set lang [::xo::cc lang] - #set lang en set return_url [::xo::cc url] set nls_language [$page get_nls_language_from_lang $lang] - set :folder_form_id [::xowiki::Weblog instantiate_forms -forms en:folder.form \ - -package_id $package_id] - set :link_form_id [::xowiki::Weblog instantiate_forms -forms en:link.form \ - -package_id $package_id] - #my msg folder_form=${:folder_form_id} + set :folder_form_id [::$package_id instantiate_forms -forms en:folder.form] + set :link_form_id [::$package_id instantiate_forms -forms en:link.form] + #:msg folder_form=${:folder_form_id} + set :current_folder [$page get_folder -folder_form_ids ${:folder_form_id}] set :current_folder_id [${:current_folder} item_id] - #my msg "FOLDERS [$page name] package_id $package_id current_folder ${:current_folder} [${:current_folder} name]" + #:msg "FOLDERS [$page name] package_id $package_id current_folder ${:current_folder} [${:current_folder} name]" - # Start with the "package's folder" as root folder - set root_folder_id [::$package_id folder_id] - set root_folder [::xo::db::CrClass get_instance_from_db -item_id $root_folder_id] - set root_folder_is_current [expr {${:current_folder_id} == [$root_folder item_id]}] + if {[::$package_id get_parameter MenuBar:boolean 0]} { - set mb [info commands ::__xowiki__MenuBar] - if {$mb ne ""} { # - # We have a menubar. Add folder-specific content to the - # menubar. + # We want a menubar. Create a menubar object, which might be + # configured via the menu_entries property in the current + # folder. # - if {$root_folder_is_current} { + set menu_entries [list \ + {*}[::$package_id get_parameter ExtraMenuEntries {}] \ + {*}[${:current_folder} property extra_menu_entries]] + set have_config [lsearch -all -index 0 $menu_entries config] + + if {$have_config != -1} { # - # We do not want to see unneeded parent_ids in the links. When - # we insert to the root folder, set opt_parent_id to empty to - # make argument passing easy. "make_link" just checks for the - # existence of the variable, so we unset parent_id in this case. + # In case, we have multiple entries, use the last one. # - set opt_parent_id "" - set folder_link [$package_id package_url] - if {[info exists parent_id]} {unset parent_id} + set have_config [lrange $have_config end end] + + # + # We have a special configuration for the menubar, probably + # consisting of a default setup and/or a menubar class. The + # entry should be of the form: + # + # {config -use xxxx -class MenuBar} + # + set properties [lrange [lindex $menu_entries $have_config] 1 end] + if {[dict exists $properties -class]} { + set p_class [dict get $properties -class] + } + foreach p {-class -use} { + if {[dict exists $properties $p]} { + set p$p [dict get $properties $p] + } + } + } + set class ::xowiki::MenuBar + if {[info exists p-class] + && [info commands ::xowiki::${p-class}] + && [::xowiki::${p-class} istype ::xowiki::MenuBar] + } { + set class ::xowiki::${p-class} } else { - set parent_id ${:current_folder_id} - set opt_parent_id $parent_id - ::xo::db::CrClass get_instance_from_db -item_id $parent_id - set folder_link [${:current_folder} pretty_link] + set class ::xowiki::MenuBar } - set return_url [::xo::cc url] - set new_folder_link [$package_id make_form_link -form en:folder.form \ - -parent_id $opt_parent_id \ - -return_url $return_url] - if {$with_links} { - set new_sym_link [$package_id make_form_link -form en:link.form \ - -parent_id $opt_parent_id \ - -nls_language $nls_language -return_url $return_url] - } - # set new_page_link [$package_id make_link \ - # $package_id edit-new \ - # {object_type ::xowiki::Page} \ - # parent_id return_url autoname template_file] + set mb [$class create ::__xowiki__MenuBar -id menubar] - set new_page_link [$package_id make_form_link -form en:page.form \ - -parent_id $opt_parent_id \ - -return_url $return_url] - set new_file_link [$package_id make_link \ - $package_id edit-new \ - {object_type ::xowiki::File} \ - parent_id return_url autoname template_file] - set new_form_link [$package_id make_link \ - $package_id edit-new \ - {object_type ::xowiki::Form} \ - parent_id return_url autoname template_file] - set import_link [$package_id make_link -privilege admin \ - -link "admin/import" $package_id {} parent_id return_url] - set import_archive_link [$package_id make_form_link -form en:import-archive.form \ - -parent_id $opt_parent_id] - - - set index_link [$package_id make_link -link $folder_link ${:current_folder} list] - - $mb add_menu_item -name Package.Startpage -item [list url $folder_link] - $mb add_menu_item -name Package.Toc -item [list url $index_link] - - $mb add_menu_item -name New.Page -item [list url $new_page_link] - $mb add_menu_item -name New.File -item [list url $new_file_link] - $mb add_menu_item -name New.Folder -item [list url $new_folder_link] - if {$with_links} { - $mb add_menu_item -name New.SymLink -item [list url $new_sym_link] + if {[info exists p-use] + && [$mb procsearch config=${p-use}] ne "" + } { + set config ${p-use} + } else { + set config default } - $mb add_menu_item -name New.Form -item [list url $new_form_link] - $mb add_menu_item -name Package.ImportDump -item [list url $import_link] - $mb add_menu_item -name Package.ImportArchive -item [list url $import_archive_link] + # + # Now we have a menubar $mb. Add folder-specific content to it. + # + # "bind_vars" will contain the variables used by "make_link" to + # set the query parameters. We do not want to see parent_ids in + # the links of the root folder. When we insert to the root + # folder, set opt_parent_id to empty to make argument passing + # easy. "make_link" just checks for the existence of the + # variable, so no add "parent_id" to the "bind_vars". + # - if {[::xowiki::clipboard is_empty]} { - set clipboard_copy_link "" - set clipboard_export_link "" - set clipboard_content_link "" - set clipboard_clear_link "" + if {[${:current_folder_id} is_package_root_folder]} { + set opt_parent_id "" + set folder_link [::$package_id package_url] + set bind_vars {} + #:msg "use instance name as title to [::$package_id instance_name]" + ${:current_folder} title [::$package_id instance_name] } else { - # todo: check, whether the use is allowed to insert into the current folder - set clipboard_copy_link $folder_link?m=clipboard-copy - set clipboard_export_link $folder_link?m=clipboard-export - set clipboard_content_link $folder_link?m=clipboard-content - set clipboard_clear_link $folder_link?m=clipboard-clear + set parent_id ${:current_folder_id} + set opt_parent_id $parent_id + ::xo::db::CrClass get_instance_from_db -item_id $parent_id + set folder_link [${:current_folder} pretty_link] + set bind_vars [list parent_id $parent_id opt_parent_id $parent_id] } - # todo: we should check either, whether to user is allowed to - # copy-to-clipboard from the current folder, and/or the user is - # allowed to do this with certain items.... (the latter in - # clipboard-add) - $mb add_menu_item -name Clipboard.Add \ - -item [list url \# listener [list click acs_ListBulkActionClick("objects","$folder_link?m=clipboard-add")]] - $mb add_menu_item -name Clipboard.Content -item [list url $clipboard_content_link] - $mb add_menu_item -name Clipboard.Clear -item [list url $clipboard_clear_link] - $mb add_menu_item -name Clipboard.Use.Copy -item [list url $clipboard_copy_link] - $mb add_menu_item -name Clipboard.Use.Export -item [list url $clipboard_export_link] + lappend bind_vars nls_language $nls_language - set uploader_link [$package_id make_link ${:current_folder} file-upload] - $mb add_extra_item -name dropzone1 -type DropZone \ - -item [list url $uploader_link label DropZone uploader File] + $mb current_folder ${:current_folder} + $mb parent_id $opt_parent_id + #:log "folders: call update_items with config '$config' bind_vars=$bind_vars" - #set modestate [::xowiki::mode::admin get] - #set modebutton_link [$package_id make_link ${:current_folder} toggle-modebutton] - #$mb add_extra_item -name admin -type ModeButton \ - # -item [list url $modebutton_link on $modestate label admin] - $mb update_items \ + -bind_vars $bind_vars \ + -config $config \ + -current_page $page \ + -folder_link $folder_link \ -package_id $package_id \ - -parent_id $opt_parent_id \ - -return_url $return_url \ - -nls_language $nls_language \ - [list \ - {*}[$package_id get_parameter ExtraMenuEntries {}] \ - {*}[${:current_folder} property extra_menu_entries]] + -return_url [ad_urlencode_folder_path [::xo::cc url]] } - set top_folder_of_tree $root_folder + # Start with the "package's folder" as root folder + set root_folder [::xo::db::CrClass get_instance_from_db \ + -item_id [::$package_id folder_id]] + # # Check, if the optional context tree view is activated # - if {$context_tree_view || [$package_id get_parameter FolderContextTreeView false]} { + set top_folder_of_tree $root_folder + if {$context_tree_view || [::$package_id get_parameter FolderContextTreeView:boolean false]} { set parent_id [${:current_folder} parent_id] if {$parent_id ne -100} { set top_folder_of_tree $parent_id - #my msg top_folder_of_tree=$top_folder_of_tree + #:msg top_folder_of_tree=$top_folder_of_tree } } - set parent_folder [$top_folder_of_tree parent_id] - if {$top_folder_of_tree eq $root_folder || $parent_folder eq "-100"} { - set href [::$package_id package_url] - set label [::$package_id instance_name] - #my msg "use instance name" + if {$top_folder_of_tree eq $root_folder + || [$top_folder_of_tree parent_id] eq "-100" + } { + set href [::$package_id package_url] + set label [::$package_id instance_name] + #:msg "use instance name in tree display" } else { - set href [$top_folder_of_tree pretty_link] + set href [$top_folder_of_tree pretty_link] set label "[$top_folder_of_tree title] ..." } @@ -406,8 +405,8 @@ -folder_form_id ${:folder_form_id} \ -link_form_id ${:link_form_id}] - #my msg "folder ${:folder_form_id} has [llength $folders] entries" - #foreach f $folders {lappend _ [$f item_id]}; :msg $_ + #:msg "folder ${:folder_form_id} has [llength $folders] entries" + #:msg [lmap f $folders {$f item_id}] :build_sub_tree -node $node -folders $folders return $t @@ -433,9 +432,13 @@ } } + #:msg "[$node label] has [llength $sub_folders] subfolders" foreach c $sub_folders { set label [$c title] + if {[regexp [lang::util::message_key_regexp] $label . innerValue]} { + set label [_ $innerValue] + } set folder_href [$c pretty_link] set is_current [expr {${:current_folder_id} eq [$c item_id]}] @@ -456,7 +459,7 @@ if {$is_current} { $node open_tree - if {[info commands ::__xowiki__MenuBar] ne "" + if {[nsf::is object ::__xowiki__MenuBar] && [::__xowiki__MenuBar exists submenu_pages(folder)]} { set owner [::__xowiki__MenuBar set submenu_owner(folder)] $subnode add_pages -full true \ @@ -487,84 +490,101 @@ {-skin:optional "yui-skin-sam"} {-show_types "::xowiki::Page,::xowiki::File,::xowiki::Form,::xowiki::FormPage"} {-regexp:optional} + {-language_specific:boolean false} {-with_subtypes:boolean,optional false} {-orderby:token,optional "last_modified,desc"} {-publish_status:wordchar "ready"} {-view_target ""} {-html-content} {-parent .} - {-hide} + {-columns { + objects + edit + publish_status + object_type + name + last_modified + mod_user + duplicate + delete + }} + {-hide {}} {-menubar ""} } } + } -ad_doc { + + Include the content of the current folder somewhat similar to explorer. + + @param show_types types of the pages to be included + @param with_subtypes (default false) + @param orderby order entries by the specified attribite (default last_modified,desc) + @param publish_status show content with the provided publishstatuses (can be ored) + @param parent folder (defaults to . (=current page as parent)) + @param columns columns to be displayed + @param hide hide certain columns + @param menubar include menubar optionally + @param regepx SQL reqexp for filtering on content item names + } child-resources instproc types_to_show {} { :get_parameters - foreach type [split $show_types ,] {set ($type) 1} - return [lsort [array names ""]] + return [lsort -unique [split $show_types ,]] } child-resources instproc render {} { :get_parameters - set current_folder ${:__including_page} + set current_folder [:get_current_folder $parent] + set :current_folder_id [$current_folder item_id] - if {$parent eq ".."} { - set current_folder [$current_folder parent_id] - ::xo::db::CrClass get_instance_from_db -item_id $current_folder - } else { - set page [$package_id get_page_from_item_ref \ - -use_package_path true \ - -use_site_wide_pages true \ - -use_prototype_pages true \ - -parent_id [$current_folder item_id] \ - $parent] - set current_folder $page + set logical_folder_id ${:current_folder_id} + if {[$current_folder exists physical_item_id]} { + set :current_folder_id [$current_folder set physical_item_id] } - if {![$current_folder istype ::xowiki::FormPage]} { - # current folder has to be a FormPage - set current_folder [$current_folder parent_id] - if {![$current_folder istype ::xowiki::FormPage]} { - error "child-resources not included from a FormPage" - } - } - set :current_folder_id [$current_folder item_id] - - if {[::xo::cc query_parameter m] ne "list" && $parent ne ".."} { + if {[::xo::cc query_parameter m:token] ne "list"} { set index [$current_folder property index] + #:log "child-resources: current folder $current_folder has index <$index>" if {$index ne ""} { set download [string match "file:*" $index] - set index_link [$package_id pretty_link \ - -parent_id [$current_folder item_id] \ + #:log "child-resources: lookup index under [$current_folder item_id] ${:current_folder_id}" + set index_link [::$package_id pretty_link \ + -parent_id ${:current_folder_id} \ -download $download \ $index] - return [$package_id returnredirect $index_link] + return [::$package_id returnredirect $index_link] } } - set logical_folder_id ${:current_folder_id} - if {[$current_folder exists physical_item_id]} { - set :current_folder_id [$current_folder set physical_item_id] - } - $package_id instvar package_key - set return_url [ad_return_url -default_url [$current_folder pretty_link]] - set category_url [export_vars -base [$package_id package_url] { {manage-categories 1} {object_id $package_id}}] + #::$package_id instvar package_key + set current_folder_pretty_link [$current_folder pretty_link] + set return_url [ad_return_url -default_url $current_folder_pretty_link] + set category_url [export_vars -base [::$package_id package_url] { + {manage-categories 1} {object_id $package_id} + }] - set columns {objects edit object_type name last_modified mod_user delete} - foreach column $columns {set ::hidden($column) 0 } - if {[info exists hide]} { - foreach column $hide {if {[info exists ::hidden($column)]} {set ::hidden($column) 1}} + set all_columns {objects edit object_type name title last_modified mod_user duplicate delete} + foreach column $all_columns { + set ::hidden($column) [expr {$column ni $columns || $column in $hide}] } + # # We have to use the global variable for the time being due to # scoping in "-columns" - set ::__xowiki_with_publish_status [expr {$publish_status ne "ready"}] - set ::__xowiki_folder_link [$package_id make_link $current_folder bulk-delete {__csrf_token $::__csrf_token}] + set ::__xowiki_with_publish_status [expr { + $publish_status ne "ready" + || "publish_status" in $columns}] - switch [$package_id get_parameter PreferredCSSToolkit bootstrap] { + # unexisting csrf token usually means we are outside a connection thread + set csrf [expr {[info exists ::__csrf_token] ? [list __csrf_token $::__csrf_token] : ""}] + set ::__xowiki_folder_link [::$package_id make_link \ + -link $current_folder_pretty_link \ + $current_folder bulk-delete $csrf return_url] + switch [::xowiki::CSS toolkit] { + bootstrap5 - bootstrap {set tableWidgetClass ::xowiki::BootstrapTable} default {set tableWidgetClass ::xowiki::YUIDataTable} } @@ -573,25 +593,34 @@ -columns { BulkAction create objects -id ID -hide $::hidden(objects) -actions { if {$::__xowiki_folder_link ne ""} { - Action bulk-delete -label Delete -tooltip "Delete selected" \ - -url $::__xowiki_folder_link + Action bulk-delete \ + -label [_ xowiki.delete] \ + -tooltip [_ xowiki.Delete_selected] \ + -url $::__xowiki_folder_link \ + -confirm_message [_ xowiki.delete_confirm] } } + # The "-html" options are currently ignored in the YUI # DataTable. Not sure, it can be integrated in the traditional way. # HiddenField create ID AnchorField create edit -CSSclass edit-item-button -label "" \ -hide $::hidden(edit) + AnchorField create duplicate -CSSclass copy-item-button \ + -hide $::hidden(duplicate) \ + -label "" if {$::__xowiki_with_publish_status} { - ImageAnchorField create publish_status -orderby publish_status.src -src "" \ - -width 8 -height 8 -border 0 -title "Toggle Publish Status" \ - -alt "publish status" -label [_ xowiki.publish_status] + AnchorField create publish_status -CSSclass publish-status-item-button \ + -orderby publish_status.CSSclass \ + -label "" -richtext 1 } Field create object_type -label [_ xowiki.page_kind] -orderby object_type -richtext false \ -hide $::hidden(object_type) - AnchorField create name -label [_ xowiki.Page-name] -orderby name \ + AnchorField create name -label [_ xowiki.name] -orderby name \ -hide $::hidden(name) + AnchorField create title -label [_ xowiki.title] -orderby title \ + -hide $::hidden(title) Field create last_modified -label [_ xowiki.Page-last_modified] -orderby last_modified \ -hide $::hidden(last_modified) Field create mod_user -label [_ xowiki.By_user] -orderby mod_user -hide $::hidden(mod_user) @@ -600,10 +629,28 @@ -label "" }] - set extra_where_clause "true" + set extra_where_clause "1=1" # TODO: why filter on title and name? - if {[info exists regexp]} {set extra_where_clause "(bt.title ~ '$regexp' OR ci.name ~ '$regexp' )"} + if {[info exists regexp]} { + set extra_where_clause "(bt.title ~ '$regexp' OR ci.name ~ '$regexp' )" + } + if {$language_specific} { + # + # Setting the property language_specific does two things: + # a) filter the entries by this language + # b) change the title of the folder when a property ml_title is supplied. + # + set lang [string range [:locale] 0 1] + set extra_where_clause "ci.name like '${lang}:%'" + + # + # Update the title to a language-specific value + # + $current_folder update_langstring_property _title $lang + #:msg "$current_folder update_langstring_property _title $lang -> [$current_folder title]" + } + #:log "child-resources of folder_id ${:current_folder_id} with publish_status '$publish_status'" set items [::xowiki::FormPage get_all_children \ -folder_id ${:current_folder_id} \ -publish_status $publish_status \ @@ -619,86 +666,113 @@ foreach c [$items children] { set name [$c name] + #:log "===###=== child-resources: get link for $name under ::$package_id logical_folder_id $logical_folder_id" + #set ::DDD 1 set page_link [::$package_id pretty_link \ -parent_id $logical_folder_id \ -context_url $url \ -folder_ids $folder_ids \ -path_encode false \ + -page $c \ $name] - array set icon [$c render_icon] + #:log "===###=== child-resources: get link for $name under ::$package_id -> $page_link" + #unset ::DDD + set icon [$c render_icon] ad_try { set prettyName [$c pretty_name] } on error {errorMsg} { - :msg "can't obtain pretty name of [$c item_id] [$c name]: $errorMsg" + :msg "can't obtain pretty name of [$c name] (item_id [$c item_id]): $errorMsg" set prettyName $name } + # -ID $page_link $t add \ - -ID [$c name] \ + -ID [$c item_id] \ -name $prettyName \ -name.href [export_vars -base $page_link {template_file html-content}] \ -name.title [$c set title] \ - -object_type $icon(text) \ - -object_type.richtext $icon(is_richtext) \ + -title [$c set title] \ + -title.href [export_vars -base $page_link {template_file html-content}] \ + -object_type [dict get $icon text] \ + -object_type.richtext [dict get $icon is_richtext] \ -last_modified [$c set last_modified] \ -edit "" \ - -edit.href [export_vars -base $page_link {{m edit} return_url}] \ + -edit.href [export_vars -base $page_link {{m:token edit} return_url}] \ -edit.title #xowiki.edit# \ -mod_user [::xo::get_user_name [$c set creation_user]] \ + -duplicate "" \ + -duplicate.href [export_vars -base $page_link {{m:token duplicate} return_url}] \ + -duplicate.title #xowiki.duplicate# \ -delete "" \ - -delete.href [export_vars -base $page_link {{m delete} return_url}] \ + -delete.href [export_vars -base $page_link {{m:token delete} return_url}] \ -delete.title #xowiki.delete# if {$::__xowiki_with_publish_status} { # TODO: this should get some architectural support - if {[$c set publish_status] eq "ready"} { - set image active.png + + set publish_status [$c set publish_status] + if {$publish_status eq "ready"} { + set CSSclass green set state "production" + } elseif {$publish_status eq "expired"} { + set CSSclass black + set state "production" } else { - set image inactive.png + set CSSclass red set state "ready" } - set revision_id [$c set revision_id] - [$t last_child] set publish_status.src /resources/xowiki/$image - [$t last_child] set publish_status.href \ - [export_vars -base $page_link {{m toggle-publish-status} return_url}] + set line [$t last_child] + $line set publish_status "■" + $line set publish_status.CSSclass $CSSclass + $line set publish_status.title #xowiki.publish_status_make_$state# + $line set publish_status.href [export_vars -base $page_link {{m toggle-publish-status} return_url}] } } + set sort_names [$t column_names] + lappend sort_names {*}[lmap n $sort_names {set _ $n.CSSclass}] lassign [split $orderby ,] att order - $t orderby -order [expr {$order eq "asc" ? "increasing" : "decreasing"}] $att - set resources_list "[$t asHTML]" - - if {$menubar ne ""} { - set mb [::xowiki::MenuBar new -id submenubar] - # for now, just the first group - lassign $menubar Menu entries - $mb add_menu -name $Menu - set menuEntries {} - foreach e $entries { - switch -- $e { - ::xowiki::File { - lappend menuEntries {entry -name New.File -label File -object_type ::xowiki::File} - } - default {ns_log notice "can't handle $e in submenubar so far"} - } - } - $mb update_items \ - -package_id $package_id \ - -parent_id ${:current_folder_id} \ - -return_url $return_url \ - -nls_language [$current_folder get_nls_language_from_lang [::xo::cc lang]] \ - $menuEntries - - set menubar [$mb render-preferred] + if {$att in $sort_names} { + $t orderby -order [expr {$order eq "asc" ? "increasing" : "decreasing"}] $att + } else { + ad_log warning "Ignore invalid sorting criterion '$att' (valid: $sort_names)" + util_user_message -message "Ignore invalid sorting criterion '$att'" } - set viewers [util_coalesce [$current_folder property viewers] [$current_folder get_parameter viewers]] + + # if {$menubar ne ""} { + # set mb [::xowiki::MenuBar new -id submenubar] + # # for now, just the first group + # lassign $menubar Menu entries + # $mb add_menu -name $Menu + # set menuEntries {} + # foreach e $entries { + # switch -- $e { + # ::xowiki::File { + # lappend menuEntries {entry -name New.File -label File -object_type ::xowiki::File} + # } + # default {ns_log notice "can't handle $e in submenubar so far"} + # } + # } + # ns_log notice "================= 2nd call update_items" + # $mb update_items \ + # -package_id $package_id \ + # -parent_id ${:current_folder_id} \ + # -return_url $return_url \ + # -nls_language [$current_folder get_nls_language_from_lang [::xo::cc lang]] + # set menubar [$mb render-preferred] + # } + #ns_log notice "sub-menubar: 2nd update_items needed? menubar <$menubar>" + set viewers [util_coalesce \ + [$current_folder property viewers] \ + [$current_folder get_parameter viewers]] set viewer_links "" foreach v $viewers { set wf_link "${v}?p.folder=[$current_folder name]" append wf_link "&m=create-or-use" - append viewer_links [subst -nocommands -nobackslashes {
  • view with $v
  • }] + append viewer_links [subst -nocommands -nobackslashes { +
  • view with $v
  • + }] } return "$menubar [$t asHTML]"