Index: openacs-4/contrib/packages/simulation/lib/object-display.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/object-display.adp,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/lib/object-display.adp 27 Oct 2003 07:31:55 -0000 1.4 +++ openacs-4/contrib/packages/simulation/lib/object-display.adp 29 Oct 2003 18:48:09 -0000 1.5 @@ -7,4 +7,8 @@ @content_html;noquote@ -Edit + +

+ Edit +

+
Index: openacs-4/contrib/packages/simulation/lib/object-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/object-display.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/lib/object-display.tcl 27 Oct 2003 07:31:55 -0000 1.6 +++ openacs-4/contrib/packages/simulation/lib/object-display.tcl 29 Oct 2003 18:48:09 -0000 1.7 @@ -29,7 +29,14 @@ -array content if { [info exists content(text)] } { -set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] + switch $content(mime_type) { + text/enhanced - text/plain - text/fixed-width - text/html { + set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] + } + default { + set content_html [ad_quotehtml $content(text)] + } + } } else { set content(text) "" set content(html) "" @@ -76,9 +83,9 @@ # ##### -if { [info exists content(stylesheet)] } { +if { [exists_and_not_null content(stylesheet)] } { array set item [bcms::item::get_item -item_id $content(stylesheet)] - + set stylesheet_url [file join [ad_conn package_url] object-content $item(name)] } else { set stylesheet_url {} Index: openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/apm-callback-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl 24 Oct 2003 10:28:27 -0000 1.4 +++ openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl 29 Oct 2003 18:48:09 -0000 1.5 @@ -22,6 +22,6 @@ -parent_id 0 \ -package_id $package_id \ -context_id $package_id \ - -content_types { sim_character sim_prop sim_home sim_stylesheet }] + -content_types { sim_character sim_prop sim_home sim_stylesheet image }] } Index: openacs-4/contrib/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-edit.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/contrib/packages/simulation/www/object-edit.tcl 29 Oct 2003 15:29:08 -0000 1.12 +++ openacs-4/contrib/packages/simulation/www/object-edit.tcl 29 Oct 2003 18:48:09 -0000 1.13 @@ -48,7 +48,7 @@ ###################################################################### #TODO: content_type should be changable in new mode -ad_form -name object -cancel_url object-list -form { +ad_form -name object -cancel_url object-list -html {enctype multipart/form-data} -form { {item_id:key} {parent_id:integer(hidden),optional} } @@ -99,8 +99,13 @@ sim_home richtext sim_prop richtext sim_stylesheet textarea + image upload } +array set content_mime_type { + sim_stylesheet text/css +} + if { ![info exists content_method($content_type)] } { set content_method($content_type) "richtext" } @@ -121,6 +126,13 @@ } } } + upload { + ad_form -extend -name object -form { + {content_file:file(file) + {label "Content file"} + } + } + } default { error "The '$content_method($content_type)' content input method has not yet been implemented" } @@ -272,13 +284,46 @@ # Set element values from local vars } -on_submit { + switch $content_method($content_type) { + richtext { + set content_text [template::util::richtext::get_property contents $content_elm] + set mime_type [template::util::richtext::get_property format $content_elm] + set storage_type text + } + textarea { + set content_text $content_elm + if { [exists_and_not_null content_mime_type($content_type)] } { + set mime_type $content_mime_type($content_type) + } else { + set mime_type "text/plain" + } + set storage_type text + } + upload { + # Insertion is handled below + set storage_type file + + if { [string equal $content_type "image"] } { + # Figure out height and width + image::get_info \ + -filename [template::util::file::get_property tmp_filename $content_file] \ + -array image_info + + set attr__image__height $image_info(height) + set attr__image__width $image_info(width) + } + } + default { + error "The '$content_method($content_type)' content input method has not yet been implemented" + } + } + set attributes [list] foreach attribute_name $attr_names { set value [set attr__${content_type}__${attribute_name}] - lappend attributes [list $attribute_name ] + lappend attributes [list $attribute_name $value] } - } -new_data { permission::require_permission -privilege create -object_id [ad_conn package_id] @@ -299,32 +344,32 @@ set item_id [bcms::item::create_item \ -item_name $name \ -parent_id $parent_id \ - -content_type $content_type] + -content_type $content_type \ + -storage_type $storage_type] + switch $content_method($content_type) { - richtext { - set content_text [template::util::richtext::get_property contents $content_elm] - set mime_type [template::util::richtext::get_property format $content_elm] + upload { + set revision_id [bcms::revision::upload_file_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -upload_file $content_file \ + -description $description \ + -additional_properties $attributes] } - textarea { - set content_text $content_elm - set mime_type "text/plain" + default { + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type $mime_type \ + -content $content_text \ + -description $description \ + -additional_properties $attributes] } } - if { $content_type == "sim_stylesheet" } { - set mime_type "text/css" - } - - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -mime_type $mime_type \ - -content $content_text \ - -description $description \ - -additional_properties $attributes] - bcms::revision::set_revision_status \ -revision_id $revision_id \ -status "live" @@ -352,27 +397,29 @@ } } -edit_data { - switch $content_method($content_type) { - richtext { - set content_text [template::util::richtext::get_property contents $content_elm] - set mime_type [template::util::richtext::get_property format $content_elm] - } - textarea { - set content_text $content_elm - set mime_type "text/plain" - } - } - db_transaction { - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -mime_type $mime_type \ - -content $content_text \ - -description $description \ - -additional_properties $attributes] + switch $content_method($content_type) { + upload { + set revision_id [bcms::revision::upload_file_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -upload_file $content_file \ + -description $description \ + -additional_properties $attributes] + } + default { + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type $mime_type \ + -content $content_text \ + -description $description \ + -additional_properties $attributes] + } + } bcms::revision::set_revision_status \ -revision_id $revision_id \ Index: openacs-4/contrib/packages/simulation/www/object-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-list.adp,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/object-list.adp 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/object-list.adp 29 Oct 2003 18:48:09 -0000 1.2 @@ -4,8 +4,6 @@

- -

- » @object_types.label@ -

-
+

+ » Create new object +

Index: openacs-4/contrib/packages/simulation/www/object-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-list.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/simulation/www/object-list.tcl 27 Oct 2003 07:31:55 -0000 1.7 +++ openacs-4/contrib/packages/simulation/www/object-list.tcl 29 Oct 2003 18:48:09 -0000 1.8 @@ -56,6 +56,7 @@ i.name, r.title, r.description, + r.mime_type, i.content_type, ot.pretty_name as object_type_pretty from cr_folders f, @@ -70,15 +71,16 @@ " { set description [string_truncate -len 200 $description] set edit_url [export_vars -base "object-edit" { item_id }] - set view_url [export_vars -base "object/$name"] set delete_url [export_vars -base "object-delete" { item_id }] -} -multirow create object_types create_url label - -foreach elm [simulation::object_type::get_options] { - foreach { pretty_name content_type } $elm {} - multirow append object_types \ - [export_vars -base object-edit { content_type parent_id }] \ - "Create new $pretty_name" + switch -glob $mime_type { + text/* { + set view_url [export_vars -base "object/$name"] + } + default { + set view_url [export_vars -base "object-content/$name"] + } + } } + +set create_object_url [export_vars -base object-edit { parent_id }] Index: openacs-4/packages/simulation/lib/object-display.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/object-display.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/lib/object-display.adp 27 Oct 2003 07:31:55 -0000 1.4 +++ openacs-4/packages/simulation/lib/object-display.adp 29 Oct 2003 18:48:09 -0000 1.5 @@ -7,4 +7,8 @@ @content_html;noquote@ -Edit + +

+ Edit +

+
Index: openacs-4/packages/simulation/lib/object-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/object-display.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/lib/object-display.tcl 27 Oct 2003 07:31:55 -0000 1.6 +++ openacs-4/packages/simulation/lib/object-display.tcl 29 Oct 2003 18:48:09 -0000 1.7 @@ -29,7 +29,14 @@ -array content if { [info exists content(text)] } { -set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] + switch $content(mime_type) { + text/enhanced - text/plain - text/fixed-width - text/html { + set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] + } + default { + set content_html [ad_quotehtml $content(text)] + } + } } else { set content(text) "" set content(html) "" @@ -76,9 +83,9 @@ # ##### -if { [info exists content(stylesheet)] } { +if { [exists_and_not_null content(stylesheet)] } { array set item [bcms::item::get_item -item_id $content(stylesheet)] - + set stylesheet_url [file join [ad_conn package_url] object-content $item(name)] } else { set stylesheet_url {} Index: openacs-4/packages/simulation/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/apm-callback-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/tcl/apm-callback-procs.tcl 24 Oct 2003 10:28:27 -0000 1.4 +++ openacs-4/packages/simulation/tcl/apm-callback-procs.tcl 29 Oct 2003 18:48:09 -0000 1.5 @@ -22,6 +22,6 @@ -parent_id 0 \ -package_id $package_id \ -context_id $package_id \ - -content_types { sim_character sim_prop sim_home sim_stylesheet }] + -content_types { sim_character sim_prop sim_home sim_stylesheet image }] } Index: openacs-4/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-edit.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/simulation/www/object-edit.tcl 29 Oct 2003 15:29:08 -0000 1.12 +++ openacs-4/packages/simulation/www/object-edit.tcl 29 Oct 2003 18:48:09 -0000 1.13 @@ -48,7 +48,7 @@ ###################################################################### #TODO: content_type should be changable in new mode -ad_form -name object -cancel_url object-list -form { +ad_form -name object -cancel_url object-list -html {enctype multipart/form-data} -form { {item_id:key} {parent_id:integer(hidden),optional} } @@ -99,8 +99,13 @@ sim_home richtext sim_prop richtext sim_stylesheet textarea + image upload } +array set content_mime_type { + sim_stylesheet text/css +} + if { ![info exists content_method($content_type)] } { set content_method($content_type) "richtext" } @@ -121,6 +126,13 @@ } } } + upload { + ad_form -extend -name object -form { + {content_file:file(file) + {label "Content file"} + } + } + } default { error "The '$content_method($content_type)' content input method has not yet been implemented" } @@ -272,13 +284,46 @@ # Set element values from local vars } -on_submit { + switch $content_method($content_type) { + richtext { + set content_text [template::util::richtext::get_property contents $content_elm] + set mime_type [template::util::richtext::get_property format $content_elm] + set storage_type text + } + textarea { + set content_text $content_elm + if { [exists_and_not_null content_mime_type($content_type)] } { + set mime_type $content_mime_type($content_type) + } else { + set mime_type "text/plain" + } + set storage_type text + } + upload { + # Insertion is handled below + set storage_type file + + if { [string equal $content_type "image"] } { + # Figure out height and width + image::get_info \ + -filename [template::util::file::get_property tmp_filename $content_file] \ + -array image_info + + set attr__image__height $image_info(height) + set attr__image__width $image_info(width) + } + } + default { + error "The '$content_method($content_type)' content input method has not yet been implemented" + } + } + set attributes [list] foreach attribute_name $attr_names { set value [set attr__${content_type}__${attribute_name}] - lappend attributes [list $attribute_name ] + lappend attributes [list $attribute_name $value] } - } -new_data { permission::require_permission -privilege create -object_id [ad_conn package_id] @@ -299,32 +344,32 @@ set item_id [bcms::item::create_item \ -item_name $name \ -parent_id $parent_id \ - -content_type $content_type] + -content_type $content_type \ + -storage_type $storage_type] + switch $content_method($content_type) { - richtext { - set content_text [template::util::richtext::get_property contents $content_elm] - set mime_type [template::util::richtext::get_property format $content_elm] + upload { + set revision_id [bcms::revision::upload_file_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -upload_file $content_file \ + -description $description \ + -additional_properties $attributes] } - textarea { - set content_text $content_elm - set mime_type "text/plain" + default { + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type $mime_type \ + -content $content_text \ + -description $description \ + -additional_properties $attributes] } } - if { $content_type == "sim_stylesheet" } { - set mime_type "text/css" - } - - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -mime_type $mime_type \ - -content $content_text \ - -description $description \ - -additional_properties $attributes] - bcms::revision::set_revision_status \ -revision_id $revision_id \ -status "live" @@ -352,27 +397,29 @@ } } -edit_data { - switch $content_method($content_type) { - richtext { - set content_text [template::util::richtext::get_property contents $content_elm] - set mime_type [template::util::richtext::get_property format $content_elm] - } - textarea { - set content_text $content_elm - set mime_type "text/plain" - } - } - db_transaction { - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $title \ - -content_type $content_type \ - -mime_type $mime_type \ - -content $content_text \ - -description $description \ - -additional_properties $attributes] + switch $content_method($content_type) { + upload { + set revision_id [bcms::revision::upload_file_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -upload_file $content_file \ + -description $description \ + -additional_properties $attributes] + } + default { + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type $mime_type \ + -content $content_text \ + -description $description \ + -additional_properties $attributes] + } + } bcms::revision::set_revision_status \ -revision_id $revision_id \ Index: openacs-4/packages/simulation/www/object-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-list.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/object-list.adp 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/packages/simulation/www/object-list.adp 29 Oct 2003 18:48:09 -0000 1.2 @@ -4,8 +4,6 @@

- -

- » @object_types.label@ -

-
+

+ » Create new object +

Index: openacs-4/packages/simulation/www/object-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-list.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/simulation/www/object-list.tcl 27 Oct 2003 07:31:55 -0000 1.7 +++ openacs-4/packages/simulation/www/object-list.tcl 29 Oct 2003 18:48:09 -0000 1.8 @@ -56,6 +56,7 @@ i.name, r.title, r.description, + r.mime_type, i.content_type, ot.pretty_name as object_type_pretty from cr_folders f, @@ -70,15 +71,16 @@ " { set description [string_truncate -len 200 $description] set edit_url [export_vars -base "object-edit" { item_id }] - set view_url [export_vars -base "object/$name"] set delete_url [export_vars -base "object-delete" { item_id }] -} -multirow create object_types create_url label - -foreach elm [simulation::object_type::get_options] { - foreach { pretty_name content_type } $elm {} - multirow append object_types \ - [export_vars -base object-edit { content_type parent_id }] \ - "Create new $pretty_name" + switch -glob $mime_type { + text/* { + set view_url [export_vars -base "object/$name"] + } + default { + set view_url [export_vars -base "object-content/$name"] + } + } } + +set create_object_url [export_vars -base object-edit { parent_id }]