Index: openacs-4/packages/xowiki/tcl/xowiki-uploader-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-uploader-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/xowiki/tcl/xowiki-uploader-procs.tcl 7 Jul 2018 10:58:20 -0000 1.3 +++ openacs-4/packages/xowiki/tcl/xowiki-uploader-procs.tcl 3 Sep 2024 15:37:55 -0000 1.4 @@ -27,15 +27,15 @@ error "not implemented" } } - + nx::Class create ::xowiki::UploadFile -superclass ::xowiki::Upload { # # Class for storing files as xowiki::File instances. # :public method store_file {} { # # Store the file provided via instance variables by using the - # formfield::file implementation. + # formfield::file implementation (uses xowiki::File). # set f [::xowiki::formfield::file new -name upload -object ${:parent_object}] set file_object [$f store_file \ @@ -48,10 +48,28 @@ -publish_date_cmd {;} \ -save_flag ""] $f destroy - return {status_code 201 message created} + return [list status_code 201 message created file_object $file_object file_name ${:file_name}] } } + nx::Class create ::xowiki::UploadFileIconified -superclass ::xowiki::UploadFile { + # + # Refinement of ::xowiki::UploadFile but returning content rended + # by a special renderer. There is e.g. such a renderer defined in + # xowf for the online exam. + # + :public method store_file {} { + # + # Store files and return a thumbnail rendering when successful. + # + set d [next] + if {[dict get $d status_code] in {200 201}} { + return [list status_code 201 message [${:parent_object} render_thumbnails $d]] + } + return {status_code 500 message "something wrong"} + } + } + nx::Class create ::xowiki::UploadPhotoForm -superclass ::xowiki::Upload { # # Class for storing files as instances of photo.form. @@ -65,13 +83,13 @@ return {status_code 200 message ok} } # - # Mime type is ok, save the file under the file name either as a + # Mime type is ok, save the file under the filename either as a # new item or as a new revision. # set package_id [${:parent_object} package_id] set parent_id [${:parent_object} item_id] - - set photo_object [$package_id get_page_from_name -name en:${:file_name} -parent_id $parent_id] + + set photo_object [::$package_id get_page_from_name -name en:${:file_name} -parent_id $parent_id] if {$photo_object ne ""} { # # The photo page instance exists already, create a new revision. @@ -83,14 +101,14 @@ $f content-type ${:content_type} $f set tmpfile ${:tmpfile} $f convert_to_internal - $photo_object save + $photo_object save } else { # # Create a new page instance of photo.form. # ns_log notice "new Photo ${:file_name}" - set photoFormObj [::xowiki::Weblog instantiate_forms \ - -parent_id $parent_id -forms en:photo.form -package_id $package_id] + set photoFormObj [::$package_id instantiate_forms \ + -parent_id $parent_id -forms en:photo.form] set photo_object [$photoFormObj create_form_page_instance \ -name en:${:file_name} \ -nls_language en_US \ @@ -107,7 +125,7 @@ $f set tmpfile ${:tmpfile} $f convert_to_internal } - + return {status_code 201 message created} } }