Index: openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml,v diff -u -r1.19 -r1.20 --- openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml 22 Jul 2007 12:01:27 -0000 1.19 +++ openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml 24 Jul 2007 20:48:32 -0000 1.20 @@ -1,5 +1,5 @@ - + Verwalten Zur�ck @@ -8,7 +8,7 @@ L�schen Bearbeiten bearbeiten - Eintr�ge, die das Formular %form% verwenden: + Eintr�ge f�r as Formular %form%: Dieses Formular wird noch von %count% Eintr�gen verwendet. Bitte verwenden Sie diese, bevor Sie das Formular l�schen. Formular Einschr�nkungen Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 24 Jul 2007 13:21:39 -0000 1.27 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 24 Jul 2007 20:48:33 -0000 1.28 @@ -166,8 +166,10 @@ #my msg "[my name] searchDefaults" ::xotcl::Class::Parameter searchDefaults [self]; # TODO: will be different in xotcl 1.6.* } else { - #my msg "Ignoring unknown spec for entry [my name]: '$s'" - error [_ xowiki.error-form_constraint-unknown_spec_entry [list name [my name] entry $s x "Unknown spec entry for entry '$s'"]] + if {$s ne ""} { + error [_ xowiki.error-form_constraint-unknown_spec_entry \ + [list name [my name] entry $s x "Unknown spec entry for entry '$s'"]] + } } } } @@ -425,6 +427,18 @@ ########################################################### # + # ::xowiki::FormField::user_id + # + ########################################################### + + Class FormField::user_id -superclass FormField::numeric -parameter { + } + FormField::user_id instproc pretty_value {v} { + return [::xo::get_user_name $v] + } + + ########################################################### + # # ::xowiki::FormField::url # ########################################################### @@ -867,6 +881,8 @@ FormField::date instproc pretty_value {v} { # internally, we have ansi format. For displaying the date, use the display format + # drop of the value after the "." we assume to have a date in the local zone + regexp {^([^.]+)[.]} $v _ v return [clock format [clock scan $v] -format [string map [list _ " "] [my display_format]]] } Index: openacs-4/packages/xowiki/tcl/xowiki-form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-form-procs.tcl,v diff -u -r1.80 -r1.81 --- openacs-4/packages/xowiki/tcl/xowiki-form-procs.tcl 23 Jul 2007 19:48:37 -0000 1.80 +++ openacs-4/packages/xowiki/tcl/xowiki-form-procs.tcl 24 Jul 2007 20:48:33 -0000 1.81 @@ -616,7 +616,7 @@ set dont_edit [concat [[$data info class] edit_atts] [list title] \ [::Generic::CrClass set common_query_atts]] - set category_spec [$data get_short_spec _categories] + set category_spec [$data get_short_spec @categories] foreach f [split $category_spec ,] { if {$f eq "off"} {my set with_categories false} } @@ -673,19 +673,20 @@ Class create FormForm -superclass ::xowiki::PageTemplateForm \ -parameter { - {field_list {item_id name page_order title creator text form form_constraints - anon_instances description nls_language}} - {f.text "= richtext,height=200px"} - {f.form "= richtext,height=200px"} - {validate { - {name {\[::xowiki::validate_name\]} {Another item with this name exists \ - already in this folder}} - {text {\[::xowiki::validate_form_text\]} {Form must contain a valid template}} - {form {\[::xowiki::validate_form_form\]} {Form must contain an HTML form}} - {form_constraints {\[::xowiki::validate_form_constraints\]} {Invalid form constraints}} - }} + {field_list {item_id name page_order title creator text form form_constraints + anon_instances description nls_language}} + {f.text "= richtext,height=200px"} + {f.form "= richtext,height=200px"} + {f.form_constraints "="} + {validate { + {name {\[::xowiki::validate_name\]} {Another item with this name exists \ + already in this folder}} + {text {\[::xowiki::validate_form_text\]} {Form must contain a valid template}} + {form {\[::xowiki::validate_form_form\]} {Form must contain an HTML form}} + {form_constraints {\[::xowiki::validate_form_constraints\]} {Invalid form constraints}} + }} } - + FormForm instproc new_data {} { my instvar data set item_id [next] Index: openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/Attic/xowiki-portlet-procs.tcl,v diff -u -r1.75 -r1.76 --- openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 24 Jul 2007 13:21:39 -0000 1.75 +++ openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 24 Jul 2007 20:48:33 -0000 1.76 @@ -2130,61 +2130,143 @@ {parameter_declaration { {-form_item_id:integer} {-form} - {-orderby "last_modified,desc"} + {-orderby "_last_modified,desc"} + {-field_names} }} } form-usages instproc render {} { my get_parameters my instvar __including_page + ::xowiki::Page requireCSS "/resources/acs-templating/lists.css" + set return_url [::xo::cc url]?[::xo::cc actual_query] + if {![info exists form_item_id]} { set form_item_id [::xowiki::Form lookup -name $form -parent_id $folder_id] if {$form_item_id == 0} {error "Cannot lookup page $form"} } - #set form_item_id [::xowiki::Form instantiate -item_id $form_item_id] - #$form_item_id destroy_on_cleanup - #set form_fields [$form_item_id create_form_fields $field_names] - - ::xowiki::Page requireCSS "/resources/acs-templating/lists.css" - set return_url [::xo::cc url]?[::xo::cc actual_query] + set form_item [::xowiki::Form instantiate -item_id $form_item_id] + $form_item destroy_on_cleanup - TableWidget t1 -volatile \ - -columns { - ImageField_EditIcon edit -label "" -html {style "padding: 2px;"} - AnchorField name -label [_ xowiki.Page-name] -orderby name - Field last_modified -label "Modification Date" -orderby last_modified - Field creation_user -label "By User" -orderby creation_user - ImageField_DeleteIcon delete -label "" + if {![info exists field_names]} { + set fn [::xowiki::PageInstance get_short_spec_from_form_constraints \ + -name @table \ + -form_constraints [$form_item form_constraints]] + set field_names [split $fn ,] + } + if {$field_names eq ""} { + set field_names {_name _last_modified _creation_user} + } + + set sql_atts [list instance_attributes] + foreach att [::xowiki::FormPage edit_atts] {set __att($att) 1} + set common_atts [list last_modified creation_user] + foreach att $common_atts { + lappend sql_atts p.$att + set __att($att) 1 + } + + set form_constraints [$form_item form_constraints] + set cr_field_spec [::xowiki::PageInstance get_short_spec_from_form_constraints \ + -name @cr_fields \ + -form_constraints $form_constraints] + set field_spec [::xowiki::PageInstance get_short_spec_from_form_constraints \ + -name @fields \ + -form_constraints $form_constraints] + + foreach spec_name $field_names { + # TODO: the short_spec does not contain @cr_fields + set short_spec [::xowiki::PageInstance get_short_spec_from_form_constraints \ + -name $spec_name \ + -form_constraints $form_constraints] + + switch -glob -- $spec_name { + __* {error not_allowed} + _* { + set varname [string range $spec_name 1 end] + if {![info exists __att($varname)]} { + error "unknown attribute $spec_name" + } + set f [$form_item create_form_field \ + -name $spec_name \ + -slot [$form_item find_slot $varname] \ + -spec $cr_field_spec,$short_spec] + lappend sql_atts p.$varname } + default { + set f [$form_item create_form_field \ + -name $spec_name \ + -slot "" \ + -spec $field_spec,$short_spec] + } + } + lappend form_fields $f + set __ff($spec_name) $f + } + #my msg ff=[array names __ff] + #$form_item show_fields $form_fields + if {[info exists __ff(_creation_user)]} {$__ff(_creation_user) label "By User"} + + set cols "" + append cols {ImageField_EditIcon edit -label "" -html {style "padding: 2px;"}} \n + foreach fn $field_names { + append cols [list AnchorField $fn -label [$__ff($fn) label] -orderby $fn] \n + } + append cols [list ImageField_DeleteIcon delete -label "" ] \n + + TableWidget t1 -volatile -columns $cols + + # + # Sorting is done for the time being in tcl. This has the advantage + # that page_orders can be sorted with the special mixin and that + # instance attributes can be used for sorting as well. + # foreach {att order} [split $orderby ,] break - set sql [::xowiki::FormPage instance_select_query \ - -select_attributes "publish_date creation_user revision_id" \ - -from_clause ", xowiki_page_instance p" \ - -with_subtypes 0 \ - -orderby "$att $order" \ - -where_clause " p.page_template = $form_item_id \ - and p.page_instance_id = cr.revision_id \ - and ci.publish_status <> 'production' \ - " \ - -folder_id [$package_id folder_id]] + if {$att eq "_page_order"} { + t1 mixin add ::xo::OrderedComposite::IndexCompare + } + t1 orderby -order [expr {$order eq "asc" ? "increasing" : "decreasing"}] $att - db_foreach [my qn get_pages] $sql { + # + # build SQL query and iterate over the results + # maybe this could be slightly faster by using instantiate_objects + # + set items [::xowiki::FormPage instantiate_all \ + -select_attributes $sql_atts \ + -from_clause ", xowiki_form_pagex p" \ + -with_subtypes false \ + -where_clause " p.page_template = $form_item_id \ + and p.xowiki_form_page_id = cr.revision_id \ + and ci.publish_status <> 'production' " \ + -folder_id [$package_id folder_id]] + $items destroy_on_cleanup - set p [::Generic::CrItem instantiate -item_id 0 -revision_id $revision_id] - $p destroy_on_cleanup - set page_link [$package_id pretty_link $name] - regexp {^([^.]+)[.]} $publish_date _ publish_date - + foreach p [$items children] { + $p set package_id $package_id + + array set __ia [$p set instance_attributes] + set page_link [$package_id pretty_link [$p name]] + t1 add \ - -name $name \ - -name.href $page_link \ - -creation_user [::xo::get_user_name $creation_user] \ -delete.href [$package_id make_link -link $page_link $p delete return_url] \ - -edit.href [$package_id make_link -link $page_link $p edit return_url] \ - -last_modified $publish_date + -edit.href [$package_id make_link -link $page_link $p edit return_url] + + set __c [t1 last_child] + $__c set _name.href $page_link + foreach __fn $field_names { + switch -glob -- $__fn { + __* {error not_allowed} + _* {set __value [$p set [string range $__fn 1 end]]} + default {set __value $__ia($__fn)} + } + if {[$__ff($__fn) istype ::xowiki::FormField::richtext]} { + $__c set $__fn.richtext 1 + } + $__c set $__fn [$__ff($__fn) pretty_value $__value] + } } set base [$package_id pretty_link [$__including_page name]] Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.153 -r1.154 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 24 Jul 2007 13:21:39 -0000 1.153 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 24 Jul 2007 20:48:33 -0000 1.154 @@ -37,6 +37,8 @@ {lang en} {render_adp 1} {absolute_links 0} + last_modified + creation_user } \ -form ::xowiki::WikiForm @@ -46,7 +48,7 @@ if {![::xotcl::Object isobject ::xowiki::Page::slot]} { ::xotcl::Object create ::xowiki::Page::slot } - foreach parameter {name title description text nls_language} { + foreach parameter {name title description text nls_language publish_date creation_user} { if {![::xotcl::Object isobject ::xowiki::Page::slot::$parameter]} { ::xo::Attribute create ::xowiki::Page::slot::$parameter } @@ -75,6 +77,11 @@ ::xowiki::Page::slot::nls_language set datatype text ::xowiki::Page::slot::nls_language set spec {select,options=[xowiki::locales]} + ::xowiki::Page::slot::last_modified set pretty_name #xowiki.Page-last_modified# + ::xowiki::Page::slot::last_modified set spec date + + ::xowiki::Page::slot::creation_user set spec user_id + ::Generic::CrClass create PlainPage -superclass Page \ -pretty_name "XoWiki Plain Page" -pretty_plural "XoWiki Plain Pages" \ -table_name "xowiki_plain_page" -id_column "ppage_id" \ @@ -137,7 +144,7 @@ -datatype text -sqltype long_text -default "" ::Generic::Attribute new -attribute_name form_constraints \ -datatype text -sqltype long_text -default "" \ - -validator form_constraints + -validator form_constraints -spec "textarea,cols=100,rows=2" } \ -form ::xowiki::FormForm @@ -1071,29 +1078,29 @@ # PageInstance methods # + PageInstance proc get_short_spec_from_form_constraints {-name -form_constraints} { + foreach name_and_spec $form_constraints { + foreach {spec_name short_spec} [split $name_and_spec :] break + if {$spec_name eq $name} { + #my msg "get_short_spec $name returns 1 $short_spec" + return $short_spec + } + } + return "" + } + PageInstance instproc get_short_spec {name} { #my msg "get_short_spec $name" my instvar page_template # in the old-fashioned 2-form page-instance create, page_template # might be non-existant or empty. if {[info exists page_template] && $page_template ne "" && [$page_template exists form_constraints]} { - foreach name_and_spec [$page_template form_constraints] { - foreach {spec_name short_spec} [split $name_and_spec :] break - if {$spec_name eq $name} { - #my msg "get_short_spec $name returns 1 $short_spec" - return $short_spec - } + set short_spec [::xowiki::PageInstance get_short_spec_from_form_constraints \ + -name $name -form_constraints [$page_template form_constraints]] + if {$short_spec ne ""} { + return $short_spec } - # in case not found, look for name prefixed with _, in cases - # we refer to instance variables of the page - #foreach name_and_spec [$page_template form_constraints] { - # foreach {spec_name short_spec} [split $name_and_spec :] break - # if {"_$spec_name" eq $name} { - # my msg "get_short_spec $name returns 2 $short_spec" - # return $short_spec - # } - #} } return "" } @@ -1266,6 +1273,8 @@ # foreach name_and_spec $form_constraints { foreach {spec_name short_spec} [split $name_and_spec :] break + if {$spec_name eq "@table"} continue + #my msg "checking spec '$short_spec' for form field '$spec_name'" if {[catch { set f [my create_form_field \ 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 -r1.90 -r1.91 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 24 Jul 2007 13:21:39 -0000 1.90 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 24 Jul 2007 20:48:33 -0000 1.91 @@ -311,8 +311,10 @@ return $html } - Page instproc find_slot {name} { - set start_class [my info class] + Page instproc find_slot {-start_class name} { + if {![info exists start_class]} { + set start_class [my info class] + } foreach cl [concat $start_class [$start_class info heritage]] { set slotobj ${cl}::slot::$name if {[my isobject $slotobj]} { @@ -353,9 +355,9 @@ } else { set default "" } - if {![my exists name]} { - my name "" - } + #if {![my exists name]} { + # my name "" + #} set f [FormField new -name $name \ -id [::xowiki::Portlet html_id F.[my name].$name] \ -locale [my nls_language] \ @@ -395,7 +397,7 @@ namespace eval ::xowiki { FormPage instproc create_category_fields {} { - set category_spec [my get_short_spec _categories] + set category_spec [my get_short_spec @categories] foreach f [split $category_spec ,] { if {$f eq "off"} {return [list]} } @@ -580,8 +582,8 @@ FormPage instproc create_form_fields {field_names} { set form_fields [my create_category_fields] - set cr_field_spec [my get_short_spec _cr_fields] - set field_spec [my get_short_spec _fields] + set cr_field_spec [my get_short_spec @cr_fields] + set field_spec [my get_short_spec @fields] foreach att $field_names { switch -glob -- $att {