Instances of Form $label
\n" [t1 asHTML] 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 -N -r1.117 -r1.118 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 22 Jun 2007 13:32:02 -0000 1.117 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 25 Jun 2007 12:18:56 -0000 1.118 @@ -16,11 +16,9 @@ -mime_type text/html \ -cr_attributes { if {[::xo::db::has_ltree]} { - ::Generic::Attribute new -attribute_name page_order -datatype text \ - -pretty_name "Order" -sqltype ltree + ::Generic::Attribute new -attribute_name page_order -datatype text -sqltype ltree } - ::Generic::Attribute new -attribute_name creator -datatype text \ - -pretty_name "Creator" + ::Generic::Attribute new -attribute_name creator -datatype text } \ -parameter { page_id @@ -32,18 +30,33 @@ name title text + description + nls_language {folder_id -100} {lang en} {render_adp 1} {absolute_links 0} } \ -form ::xowiki::WikiForm - # TODO: the following line is just a start. type, required+label should be just attributes - # of the slot object - ::xowiki::Page::slot::name set spec "text,required,label=#xowiki.name#" + # TODO: the following slot definitions are not meant to stay this way. + # when we change to the xotcl 1.5.0+ slots, this will go away + ::xowiki::Page::slot::name set pretty_name #xowiki.Page-name# + ::xowiki::Page::slot::name set required true + ::xowiki::Page::slot::name set help_text #xowiki.Page-name-help_text# + ::xowiki::Page::slot::name set datatype text + ::xowiki::Page::slot::title set pretty_name #xowiki.Page-title# + ::xowiki::Page::slot::title set required true + ::xowiki::Page::slot::title set datatype text + ::xowiki::Page::slot::description set pretty_name #xowiki.Page-description# + ::xowiki::Page::slot::description set spec "textarea(cols=80;rows=2)" + ::xowiki::Page::slot::description set datatype text + ::xowiki::Page::slot::text set pretty_name #xowiki.Page-text# + ::xowiki::Page::slot::text set datatype text + ::xowiki::Page::slot::nls_language set pretty_name #xowiki.Page-nls_language# + ::xowiki::Page::slot::nls_language set datatype text + ::xowiki::Page::slot::nls_language set spec {select(options=[xowiki::locales])} - ::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" \ @@ -60,14 +73,13 @@ -pretty_name "Podcast Item" -pretty_plural "Podcast Items" \ -table_name "xowiki_podcast_item" -id_column "podcast_item_id" \ -cr_attributes { - ::Generic::Attribute new -attribute_name pub_date -datatype date -sqltype timestamp \ - -pretty_name "Publication Date" + ::Generic::Attribute new -attribute_name pub_date -datatype date \ + -sqltype timestamp -spec "date(format=YYYY_MM_DD_HH24_MI)" ::Generic::Attribute new -attribute_name duration -datatype text \ - -pretty_name "Duration" - ::Generic::Attribute new -attribute_name subtitle -datatype text \ - -pretty_name "Subtitle" + -help_text "#xowiki.PodcastItem-duration-help_text#" + ::Generic::Attribute new -attribute_name subtitle -datatype text ::Generic::Attribute new -attribute_name keywords -datatype text \ - -pretty_name "Keywords" + -help_text "#xowiki.PodcastItem-keywords-help_text#" } \ -storage_type file \ -form ::xowiki::PodcastForm @@ -77,19 +89,17 @@ -table_name "xowiki_page_template" -id_column "page_template_id" \ -cr_attributes { ::Generic::Attribute new -attribute_name anon_instances -datatype boolean \ - -sqltype boolean -default "f" \ - -pretty_name "#xowiki.PageTemplate-anon_instances#" + -sqltype boolean -default "f" } \ -form ::xowiki::PageTemplateForm ::Generic::CrClass create PageInstance -superclass Page \ -pretty_name "XoWiki Page Instance" -pretty_plural "XoWiki Page Instances" \ -table_name "xowiki_page_instance" -id_column "page_instance_id" \ -cr_attributes { - ::Generic::Attribute new -attribute_name page_template -datatype integer \ - -pretty_name "Page Template" + ::Generic::Attribute new -attribute_name page_template -datatype integer ::Generic::Attribute new -attribute_name instance_attributes -datatype text \ - -pretty_name "Instance Attributes" -default "" + -default "" } \ -form ::xowiki::PageInstanceForm \ -edit_form ::xowiki::PageInstanceEditForm @@ -104,10 +114,8 @@ -pretty_name "XoWiki Form" -pretty_plural "XoWiki Forms" \ -table_name "xowiki_form" -id_column "xowiki_form_id" \ -cr_attributes { - ::Generic::Attribute new -attribute_name form -datatype text \ - -pretty_name "#xowiki.Form-form#" - ::Generic::Attribute new -attribute_name form_constraints -datatype text \ - -pretty_name "#xowiki.Form-form_constraints#" + ::Generic::Attribute new -attribute_name form -datatype text + ::Generic::Attribute new -attribute_name form_constraints -datatype text } \ -form ::xowiki::FormForm ::Generic::CrClass create FormInstance -superclass PageInstance \ @@ -300,6 +308,12 @@ my set parent_id $parent_id my set package_id $package_id my set creation_user $creation_user + # + # if we import from an instance without page_orders into an instance + # with page_orders, we need default values + if {[::xo::db::has_ltree] && ![my exists page_order]} { + my set page_order "" + } # in the general case, no more actions required } @@ -314,6 +328,24 @@ close $F } + # set default values. + # todo: with slots, it should be easier to set default values + # for non existing variables + PageInstance instproc demarshall {args} { + # some older versions do not have anon_instances + if {![my exists anon_instances]} { + my set anon_instances "f" + } + next + } + Form instproc demarshall {args} { + # some older versions do not have anon_instances + if {![my exists anon_instances]} { + my set anon_instances "t" + } + next + } + Page instproc copy_content_vars {-from_object:required} { array set excluded_var { folder_id 1 package_id 1 absolute_links 1 lang_links 1 @@ -423,7 +455,7 @@ next } - Page instproc regsub-eval {re string cmd} { + Page instproc regsub_eval {re string cmd} { subst [regsub -all $re [string map { \" \\\" \[ \\[ \] \\] \ \$ \\$ \\ \\\\} $string] \ "\[$cmd\]"] @@ -612,9 +644,9 @@ foreach l0 [split [lindex $source 0] \n] { append l $l0 if {[string first \{\{ $l] > -1 && [string first \}\} $l] == -1} continue - set l [my regsub-eval $RE(anchor) $l {my anchor "\1" "\2"}] - set l [my regsub-eval $RE(div) $l {my div "\2" "\3"}] - set l [my regsub-eval $RE(include) $l {my include "\1" "\2" "\3"}] + set l [my regsub_eval $RE(anchor) $l {my anchor "\1" "\2"}] + set l [my regsub_eval $RE(div) $l {my div "\2" "\3"}] + set l [my regsub_eval $RE(include) $l {my include "\1" "\2" "\3"}] regsub -all $RE(clean) $l {\1} l regsub -all $RE(clean2) $l { \1} l append content [string range $l 1 end] \n @@ -798,9 +830,9 @@ set content "" foreach l [split $source \n] { set l " $l" - set l [my regsub-eval $RE(anchor) $l {my anchor "\1" "\2"}] - set l [my regsub-eval $RE(div) $l {my div "\2" "\3"}] - set l [my regsub-eval $RE(include) $l {my include "\1" "\2" ""}] + set l [my regsub_eval $RE(anchor) $l {my anchor "\1" "\2"}] + set l [my regsub_eval $RE(div) $l {my div "\2" "\3"}] + set l [my regsub_eval $RE(include) $l {my include "\1" "\2" ""}] regsub -all $RE(clean) $l {\1} l append content [string range $l 1 end] \n } @@ -848,7 +880,7 @@ #my log "--F page_link=$page_link ---- " set t [TableWidget new -volatile \ -columns { - AnchorField name -label [_ xowiki.name] + AnchorField name -label [_ xowiki.Page-name] Field mime_type -label "Content Type" Field last_modified -label "Last Modified" Field mod_user -label "By User" @@ -921,29 +953,36 @@ } return $value } - PageInstance instproc get_field_type {name default_spec} { - my instvar page_template + PageInstance instproc widget_spec_from_folder_object {name given_template_name} { # get the widget field specifications from the payload of the folder object # for a field with a specified name in a specified page template - set spec $default_spec - set short_spec [my get_short_spec $name] - if {$short_spec ne ""} { - set f [FormField new -volatile -name $name -spec $short_spec] - return [$f asWidgetSpec] - } - set given_template_name [$page_template set name] + my instvar page_template foreach {s widget} [[my set parent_id] get_payload widget_specs] { foreach {template_name var_name} [split $s ,] break #ns_log notice "--w T.title = '$given_template_name' var=$name" if {([string match $template_name $given_template_name] || $given_template_name eq "") && [string match $var_name $name]} { - set spec $widget + return $widget_spec #ns_log notice "--w using $widget for $name" } } - #ns_log notice "--w returning spec $spec" - return $spec + return "" } + PageInstance instproc get_field_type {name default_spec} { + my instvar page_template + # get widget spec from folder (highest priority) + set spec [my widget_spec_from_folder_object $name [$page_template set name]] + if {$spec ne ""} { + return $spec + } + # get widget spec from attribute definition + set f [my create_form_field -name $name -slot [my find_slot $name]] + if {$f ne ""} { + return [$f asWidgetSpec] + } + # use default widget spec + return $default_spec + } PageInstance instproc get_from_template {var} { my instvar page_template @@ -972,6 +1011,8 @@ array set __ia [my set instance_attributes] foreach var [array names __ia] { #my log "-- set $var [list $__ia($var)]" + # TODO: just for the lookup, whether a field is a richt text field, + # there should be a more efficient and easier way... if {[string match "richtext*" [my get_field_type $var text]]} { # ignore the text/html info from htmlarea set value [lindex $__ia($var) 0] 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.53 -r1.54 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 22 Jun 2007 13:32:02 -0000 1.53 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 25 Jun 2007 12:18:56 -0000 1.54 @@ -296,49 +296,61 @@ return $html } - FormInstance instproc createFormField {{-spec ""} {-configuration ""} -name} { - if {$spec ne ""} { - set f [FormField new -name $name -spec $spec] - } else { - # - # try first to get the information from the form constraints - # - set short_spec [my get_short_spec $name] - if {$short_spec ne ""} { - set f [FormField new -name $name -spec $short_spec] - } else { - - # TODO: this could be made cleaner by using slots, which require xotcl 1.5.*. - # currently, i do not want to force an upgrade to the newer xotcl versions. - set class [my info class] - set __container [::xo::OrderedComposite new -destroy_on_cleanup] - foreach cl [concat $class [$class info heritage]] { - if {[$cl exists cr_attributes]} {$__container contains [$cl cr_attributes]} - } - - # - # try to get the information from the attribute definitions - # - foreach __att [$__container children] { - #ns_log notice "--field compare '$__field' '[$__att attribute_name]'" - if {[$__att attribute_name] eq $name} { - #ns_log notice "--field $name [$__att serialize]" - set f [FormField new \ - -label [$__att pretty_name] -type [$__att datatype] \ - -spec [lindex $__wspec 1]] - break - } - } + Page instproc find_slot {name} { + set start_class [my info class] + foreach cl [concat $start_class [$start_class info heritage]] { + set slotobj ${cl}::slot::$name + if {[my isobject $slotobj]} { + #my msg $slotobj + return $slotobj } } - if {![info exists f]} { - error "could not find definitions for field $name" + return "" + } + + Page instproc create_form_field {-name -slot {-spec ""} {-configuration ""}} { + + 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 -volatile -noinit] } + + set spec_list [list] + if {[$slot exists spec]} {lappend spec_list [$slot set spec]} + if {$spec ne ""} {lappend spec_list $spec} + #my msg "[self args] spec_list $spec_list" + #my msg "$name, spec_list = '[join $spec_list ,]'" + + if {[$slot exists pretty_name]} { + set label [$slot set pretty_name] + } else { + set label $name + ns_log notice "no pretty_name for variable $name in slot $slot" + } + + set f [FormField new -name $name \ + -label $label \ + -type [expr {[$slot exists datatype] ? [$slot set datatype] : "text"}] \ + -help_text [expr {[$slot exists help_text] ? [$slot set help_text] : ""}] \ + -required [expr {[$slot exists required] ? [$slot set required] : "false"}] \ + -spec [join $spec_list ,] \ + ] $f destroy_on_cleanup $f configure $configuration return $f } + PageInstance instproc create_form_field {-name -slot {-spec ""} {-configuration ""}} { + # TODO combine with form_constraints, Remove unneeded cases + set short_spec [my get_short_spec $name] + set spec_list [list] + if {$short_spec ne ""} {lappend spec_list $short_spec} + if {$spec ne ""} {lappend spec_list $spec} + #my msg "$name, short_spec '$short_spec', spec_list 1 = '[join $spec_list ,]'" + set f [next -name $name -slot $slot -spec [join $spec_list ,] -configuration $configuration] + return $f + } + FormInstance instproc edit {} { my instvar page_template doc root package_id @@ -362,11 +374,11 @@ } $fcn if {$anon_instances eq "f"} { - set f [my createFormField -name __name -spec "text,required,label=#xowiki.name#" \ + set f [my create_form_field -name __name -slot [my find_slot name] \ -configuration [list -value [my set name]]] $root insertBeforeFromScript {$f render_item} $fcn - set f [my createFormField -name __title -spec "text,required,label=#xowiki.title#" \ + set f [my create_form_field -name __title -slot [my find_slot title] \ -configuration [list -value [my set title]]] $root insertBeforeFromScript {$f render_item} $fcn } Index: openacs-4/packages/xowiki/www/oacs-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/oacs-view.adp,v diff -u -N -r1.37 -r1.38 --- openacs-4/packages/xowiki/www/oacs-view.adp 15 Jun 2007 07:29:40 -0000 1.37 +++ openacs-4/packages/xowiki/www/oacs-view.adp 25 Jun 2007 12:18:57 -0000 1.38 @@ -1,4 +1,4 @@ - +" \ - "[join $entries {, }]\n" - } - return $content -} - -set link "" -if {![info exists name]} {set name "Tags"} -if {![info exists limit]} {set limit 20} -set summary [ns_queryget summary 0] -set content [::xowiki::Page __render_html \ - -folder_id [$__including_page set parent_id] \ - -user_id [::xo::cc user_id] \ - -summary $summary \ - -limit $limit \ - -popular [info exists popular] \ - ] - -if {![info exists skin]} {set skin portlet-skin} -if {![string match /* $skin]} {set skin [file dir $__adp_stub]/$skin} -template::set_file $skin - - Index: openacs-4/packages/xowiki/www/portlets/weblog.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/portlets/Attic/weblog.adp,v diff -u -N --- openacs-4/packages/xowiki/www/portlets/weblog.adp 19 Jun 2006 00:40:04 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ -