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.46 -r1.47 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 12 Dec 2007 18:00:01 -0000 1.46 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 14 Dec 2007 10:24:51 -0000 1.47 @@ -862,8 +862,86 @@ {maxlength 4} } + ########################################################### # + # ::xowiki::FormField::image_url + # + ########################################################### + + Class FormField::image_url -superclass FormField::text -parameter { + {validator image_check} + href cssclass + {float left} width height + padding {padding-right 10px} padding-left padding-top padding-bottom + margin margin-left margin-right margin-top margin-bottom + border border-width position top botton left right + } + FormField::image_url instproc entry_name {value} { + if {![regexp -nocase {/([^/]+)[.](gif|jpg|jpeg|png)} $value _ name ext]} { + return "" + } + return image:$name.$ext + } + FormField::image_url instproc check=image_check {value} { + if {$value eq ""} {return 1} + set entry_name [my entry_name $value] + if {$entry_name eq ""} { + my log "--img '$value' does not appear to be an image" + # no image? + return 0 + } + set folder_id [[my object] set parent_id] + if {[::xo::db::CrClass lookup -name $entry_name -parent_id $folder_id]} { + my log "--img entry named $entry_name exists already" + # file exists already + return 1 + } + if {[catch { + set r [::xo::HttpRequest new -url $value -volatile] + set img [$r set data] + } errorMsg]} { + # cannot transfer image + my log "--img cannot tranfer image '$value' ($errorMsg)" + return 0 + } + set import_file [ns_tmpnam] + ::xowiki::write_file $import_file $img + set file_object [::xowiki::File new -destroy_on_cleanup \ + -title $entry_name \ + -name $entry_name \ + -parent_id $folder_id \ + -package_id [[my object] package_id] \ + -creation_user [::xo::cc user_id] \ + ] + $file_object set import_file $import_file + $file_object save_new + return 1 + } + FormField::image_url instproc pretty_value {v} { + set entry_name [my entry_name $v] + if {$entry_name eq ""} { + return "" + } + my instvar object + set l [::xowiki::Link new -destroy_on_cleanup \ + -name $entry_name -page $object -type image -label [my label] \ + -folder_id [$object parent_id] -package_id [$object package_id]] + foreach option { + href cssclass + float width height + padding padding-right padding-left padding-top padding-bottom + margin margin-left margin-right margin-top margin-bottom + border border-width position top botton left right + } { + if {[my exists $option]} {$l set $option [my set $option]} + } + set html [$l render] + return $html + } + + ########################################################### + # # ::xowiki::CompoundField # ########################################################### Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.103 -r1.104 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 12 Dec 2007 16:44:08 -0000 1.103 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 14 Dec 2007 10:24:51 -0000 1.104 @@ -217,6 +217,7 @@ set party_id [::xo::cc user_id] if {[info exists privilege]} { + #my log "-- checking priv $privilege for [self args]" set granted [expr {$privilege eq "public" ? 1 : [permission::permission_p \ -object_id $id -privilege $privilege -party_id $party_id] }] Index: openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl,v diff -u -r1.37 -r1.38 --- openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 26 Nov 2007 09:14:43 -0000 1.37 +++ openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 14 Dec 2007 10:24:51 -0000 1.38 @@ -477,4 +477,18 @@ } } + proc read_file {fn} { + set F [open $fn] + fconfigure $F -translation binary + set content [read $F] + close $F + return $content + } + proc write_file {fn content} { + set F [open $fn w] + fconfigure $F -translation binary + puts -nonewline $F $content + close $F + } + } \ No newline at end of file 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.197 -r1.198 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 Dec 2007 16:59:23 -0000 1.197 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 14 Dec 2007 10:24:51 -0000 1.198 @@ -246,11 +246,7 @@ File instproc marshall {} { set fn [my full_file_name] - set F [open $fn] - fconfigure $F -translation binary - set C [read $F] - close $F - my set __file_content [::base64::encode $C] + my set __file_content [::base64::encode [::xowiki::read_file $fn]] next } @@ -273,10 +269,7 @@ # we have to care about recoding the file content my instvar import_file __file_content set import_file [ns_tmpnam] - set F [open $import_file w] - fconfigure $F -translation binary - puts -nonewline $F [::base64::decode $__file_content] - close $F + ::xowiki::write_file $import_file [::base64::decode $__file_content] } # set default values. 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.120 -r1.121 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 4 Dec 2007 22:57:36 -0000 1.120 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 14 Dec 2007 10:24:51 -0000 1.121 @@ -517,7 +517,7 @@ _* { # instance attribute fields set f [my lookup_form_field -name $att $form_fields] - set value [$f value [::xo::cc form_parameter $att]] + set value [$f value [string trim [::xo::cc form_parameter $att]]] set varname [string range $att 1 end] # get rid of strange utf-8 characters hex C2AD (firefox bug?) # ns_log notice "FORM_DATA var=$varname, value='$value' s=$s" @@ -528,7 +528,7 @@ default { # user form content fields set f [my lookup_form_field -name $att $form_fields] - set value [$f value [::xo::cc form_parameter $att]] + set value [$f value [string trim [::xo::cc form_parameter $att]]] if {![string match *.* $att]} {set __ia($att) $value} } }