Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -N -r1.239.2.34 -r1.239.2.35 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 24 Nov 2019 12:09:16 -0000 1.239.2.34 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 26 Nov 2019 12:54:00 -0000 1.239.2.35 @@ -4218,7 +4218,7 @@ {-form} {-parent_id} {-package_ids ""} - {-orderby "_last_modified,desc"} + {-orderby "_raw_last_modified,desc"} {-view_field _name} {-publish_status "all"} {-field_names} @@ -4240,6 +4240,7 @@ {-buttons "edit delete"} {-renderer ""} {-return_url} + {-date_format} }} } -ad_doc { Show usages of the specified form. @@ -4248,6 +4249,9 @@ When provided and NOT empty, use the value as return_url. When provided and empty, do NOT set an return URL. When NOT provided, set the calling page as return_url. + @param date_format + Date format used for modification date. + Might be "pretty-age" or a format string like "%Y-%m-%d %T". } # {-renderer "YUIDataTableRenderer"} @@ -4334,6 +4338,7 @@ set table_properties [::xowiki::PageInstance get_list_from_form_constraints \ -name @table_properties \ -form_constraints $form_constraints] + foreach {attr value} $table_properties { # All labels of the following switch statement are used # as variable names. Take care when adding new labels not to @@ -4388,35 +4393,51 @@ set form_fields [::xowiki::FormPage get_table_form_fields \ -base_item $form_item \ -field_names $field_names \ - -form_constraints $form_constraints] + -form_constraints $form_constraints \ + -nls_language [${:__including_page} nls_language] \ + ] #$form_item show_fields $form_fields - foreach f $form_fields {set __ff([$f name]) $f} + foreach f $form_fields { + set __ff([$f name]) $f + } #foreach f $form_fields {ns_log notice "form <[$form_item name]: field [$f name] label [$f label]"} } # if {[info exists __ff(_creation_user)]} {$__ff(_creation_user) label "By User"} # TODO: wiki-substitution is just forced in here. Maybe it makes # more sense to use it as a default for _text, but we have to # check all the nested cases to avoid double-substitutions. - if {[info exists __ff(_text)]} {$__ff(_text) set wiki 1} + if {[info exists __ff(_text)]} { + $__ff(_text) set wiki 1 + } - foreach b $buttons {set use_button($b) 1} + if {[info exists __ff(_last_modified)] && [info exists date_format]} { + $__ff(_last_modified) display_format $date_format + } + foreach b $buttons { + set use_button($b) 1 + } + set cols "" # we currently support only 'export' as bulk action set bulk_action_cols "" foreach bulk_action $bulk_actions { if {$bulk_action eq "export"} { - append actions [subst {Action bulk-delete -label [_ xowiki.export] -tooltip [_ xowiki.export] \ - -url [::$package_id package_url]admin/export}]\n + append actions [list Action bulk-delete \ + -label [_ xowiki.export] \ + -tooltip [_ xowiki.export] \ + -url [::$package_id package_url]admin/export \ + ] \n } } if {[llength $bulk_actions] > 0} { append cols [subst {BulkAction create objects -id ID -actions {$actions}}] \n append cols {HiddenField create ID} \n } if {[info exists use_button(publish_status)]} { - append cols {ImageAnchorField create _publish_status -orderby _publish_status.src -src "" \ + append cols {ImageAnchorField create _publish_status \ + -orderby _publish_status.src -src "" \ -width 8 -height 8 -title "Toggle Publish Status" \ -alt "publish status" -label [_ xowiki.publish_status] \ -CSSclass publish-status-item-button \ @@ -4434,24 +4455,35 @@ append cols {AnchorField create _view -CSSclass view-item-button -label "" \ -html {style "padding: 2px;"} -no_csv 1 -richtext 1} \n } + set sort_fields {} foreach fn $field_names { if {[info exists __hidden($fn)]} continue + set field_orderby [expr {$fn eq "_last_modified" ? "_raw_last_modified" : $fn}] append cols [list AnchorField create $fn \ -label [$__ff($fn) label] \ -richtext 1 \ - -orderby $fn \ + -orderby $field_orderby \ ] \n + lappend sort_fields $field_orderby } if {[info exists use_button(delete)]} { #append cols [list ImageField_DeleteIcon _delete -label "" -no_csv 1] \n - append cols [list AnchorField create _delete -CSSclass delete-item-button -label "" -no_csv 1 -richtext 1] \n + append cols [list AnchorField create _delete \ + -CSSclass delete-item-button \ + -label "" \ + -no_csv 1 \ + -richtext 1] \n } + #ns_log notice "COLS\n$cols" set cmd [list TableWidget create t1 -volatile -columns $cols] if {$renderer ne ""} { lappend cmd -renderer $renderer } else { - switch [parameter::get_global_value -package_key xowiki -parameter PreferredCSSToolkit -default bootstrap] { + switch [parameter::get_global_value \ + -package_key xowiki \ + -parameter PreferredCSSToolkit \ + -default bootstrap] { bootstrap {set renderer BootstrapTableRenderer} default {set renderer YUIDataTableRenderer} } @@ -4466,7 +4498,7 @@ # lassign [split $orderby ,] att order set sortable 1 - if {$att ni $field_names} { + if {$att ni $sort_fields} { # if {[ns_conn isconnected]} { # set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]] # if {[string match "*bingbot*" $user_agent] || [string match "*turnitin*" $user_agent]} { @@ -4615,6 +4647,7 @@ # set always last_modified for default sorting $__c set _last_modified [$p set last_modified] + $__c set _raw_last_modified [$p set last_modified] foreach __fn $field_names { $__ff($__fn) object $p Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -N -r1.368.2.51 -r1.368.2.52 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 25 Nov 2019 09:51:13 -0000 1.368.2.51 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 26 Nov 2019 12:54:00 -0000 1.368.2.52 @@ -2098,11 +2098,11 @@ -base_item -field_names -form_constraints + {-nls_language ""} } { array set __att [list publish_status 1] - foreach att [::xowiki::FormPage array names db_slot] {set __att($att) 1} - foreach att [list last_modified creation_user] { + foreach att [list last_modified creation_user {*}[::xowiki::FormPage array names db_slot]] { set __att($att) 1 } @@ -2134,15 +2134,19 @@ set f [$base_item create_raw_form_field \ -name $field_name \ -slot [$base_item find_slot $varname] \ - -spec $cr_field_spec,$short_spec] + -spec $cr_field_spec,$short_spec \ + -nls_language $nls_language \ + ] #:log "---> $f <[$f label]>" $f set __base_field $varname } default { set f [$base_item create_raw_form_field \ -name $field_name \ -slot "" \ - -spec $field_spec,$short_spec] + -spec $field_spec,$short_spec \ + -nls_language $nls_language \ + ] } } lappend form_fields $f @@ -2174,13 +2178,17 @@ {-spec ""} {-configuration ""} {-omit_field_name_spec:boolean false} + {-nls_language ""} } { set save_slot $slot if {$slot eq ""} { # We have no slot, so create a minimal slot. This should only happen for instance attributes set slot [::xo::Attribute new -pretty_name $name -datatype text -noinit] $slot destroy_on_cleanup } + if {$nls_language eq ""} { + set nls_language [:nls_language] + } set spec_list [list] if {[$slot exists spec]} {lappend spec_list [$slot set spec]} @@ -2203,7 +2211,7 @@ } set f [::xowiki::formfield::FormField new -name $name \ -id [::xowiki::Includelet html_id F.${:name}.$name] \ - -locale [:nls_language] \ + -locale $nls_language \ -label $label \ -type [expr {[$slot exists datatype] ? [$slot set datatype] : "text"}] \ -help_text [expr {[$slot exists help_text] ? [$slot set help_text] : ""}] \ @@ -2226,6 +2234,7 @@ {-spec ""} {-configuration ""} {-omit_field_name_spec:boolean false} + {-nls_language ""} } { # For workflows, we do not want to get the form constraints of the # page itself (i.e. the property of the generic workflow form) but @@ -2247,7 +2256,13 @@ if {$spec ne ""} {lappend spec_list $spec} if {$short_spec ne ""} {lappend spec_list $short_spec} #:log "$name: short_spec '$short_spec', spec_list 1 = '[join $spec_list ,]'" - set f [next -name $name -slot $slot -spec [join $spec_list ,] -configuration $configuration] + set f [next \ + -name $name \ + -slot $slot \ + -spec [join $spec_list ,] \ + -configuration $configuration \ + -nls_language $nls_language \ + ] #:log "created form-field '$name' $f [$f info class] validator=[$f validator] p=[$f info precedence]" return $f }