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.1 -r1.2 --- openacs-4/contrib/packages/simulation/lib/object-display.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/lib/object-display.tcl 14 Oct 2003 14:59:50 -0000 1.2 @@ -25,6 +25,8 @@ array set current_item [bcms::revision::get_revision -revision_id $revision_id] } +item::get_revision_content $current_item(revision_id) + # TODO: Render using template #set rendered [publish::merge_with_template $current_item(item_id)] @@ -45,7 +47,7 @@ set page_title $current_item(title) set context [list [list ../object-list "Objects"] $page_title] -foreach name [array names current_item] { - multirow append attributes $name $current_item($name) +foreach name [lsort [array names content]] { + multirow append attributes $name $content($name) } Index: openacs-4/contrib/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.adp,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/index.adp 14 Oct 2003 13:58:03 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/index.adp 14 Oct 2003 14:59:51 -0000 1.3 @@ -8,8 +8,8 @@
-

Flash map of city:

-

TODO

+

Sieberdam:

+


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.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/object-edit.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/object-edit.tcl 14 Oct 2003 14:59:51 -0000 1.2 @@ -5,8 +5,19 @@ @cvs-id $Id$ } { object_id:integer,optional - parent_id:integer - content_type + parent_id:integer,optional + content_type:optional +} -validate { + not_object_id { + if { ![exists_and_not_null object_id] } { + if { ![exists_and_not_null parent_id] } { + ad_complain parent_id "parent_id is required" + } + if { ![exists_and_not_null content_type] } { + ad_complain content_type "parent_id is required" + } + } + } } set page_title "Create Object" @@ -15,22 +26,31 @@ ad_form -name object -form { {object_id:key} {content_type:text(hidden)} - {parent_id:integer(hidden)} + {parent_id:integer(hidden),optional} {title:text {label "Title"} {html {size 50}} } {name:text,optional {label "URL name"} {html {size 50}} - {help_text "This will become part of the URL for the object."} + {help_text {[ad_decode [ad_form_new_p -key object_id] 1 "This will become part of the URL for the object." ""]}} + {mode {[ad_decode [ad_form_new_p -key object_id] 1 "edit" "display"]}} } {description:text(textarea),optional {label "Description"} {html {cols 60 rows 8}} } } +if { ![ad_form_new_p -key object_id] } { + # Get data for existing object + array set item_info [bcms::item::get_item -item_id $object_id -revision live] + item::get_revision_content $item_info(revision_id) + set content_type $item_info(content_type) +} + + # LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, # we'll want to generalize and move into acs-content-repository @@ -90,6 +110,8 @@ keyword {} } +set attr_names [list] + db_foreach select_attributes { select attribute_name, pretty_name, datatype, default_value, min_n_values from acs_attributes @@ -98,6 +120,8 @@ and static_p = 'f' order by sort_order } { + lappend attr_names $attribute_name + set elm_decl "attr__${content_type}__${attribute_name}:$form_datatype($datatype)($form_widget($datatype))" set optional_p [expr ![empty_string_p $default_value] || $min_n_values == 0] @@ -112,9 +136,17 @@ ad_form -extend -name object -new_request { # Set element values from local vars +} -on_submit { + + set attributes [list] + foreach attribute_name $attr_names { + lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] + } + } -new_data { set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] + if { [empty_string_p $name] } { set name [util_text_to_url -existing_urls $existing_items -text $title] } else { @@ -124,19 +156,6 @@ } } - set attributes [list] - - db_foreach select_attributes { - select attribute_name, pretty_name, datatype, default_value, min_n_values - from acs_attributes - where object_type = :content_type - and storage = 'type_specific' - and static_p = 'f' - order by sort_order - } { - lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] - } - set item_id [bcms::item::create_item \ -item_name $name \ -parent_id $parent_id \ @@ -155,13 +174,31 @@ -status "live" } -edit_request { - - error TODO + foreach elm { title name description } { + set $elm $content($elm) + } + + foreach attribute_name $attr_names { + set attr__${content_type}__${attribute_name} $content($attribute_name) + } + } -edit_data { - error TODO + set revision_id [bcms::revision::add_revision \ + -item_id $object_id \ + -title $title \ + -content_type $content_type \ + -mime_type "text/plain" \ + -description $description \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + + } -after_submit { ad_returnredirect object-list ad_script_abort 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.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/object-list.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/object-list.tcl 14 Oct 2003 14:59:51 -0000 1.2 @@ -18,6 +18,12 @@ -name objects \ -multirow objects \ -elements { + edit { + sub_class narrow + display_template { + Edit + } + } object_type_pretty { label "Type" orderby upper(ot.pretty_name) @@ -36,7 +42,7 @@ set package_id [ad_conn package_id] -db_multirow -extend { view_url } objects select_objects " +db_multirow -extend { edit_url view_url } objects select_objects " select i.item_id, i.name, r.title, @@ -54,6 +60,7 @@ [template::list::orderby_clause -orderby -name "objects"] " { set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { { object_id $item_id } }] set view_url [export_vars -base "object/$name"] } 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.1 -r1.2 --- openacs-4/packages/simulation/lib/object-display.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/packages/simulation/lib/object-display.tcl 14 Oct 2003 14:59:50 -0000 1.2 @@ -25,6 +25,8 @@ array set current_item [bcms::revision::get_revision -revision_id $revision_id] } +item::get_revision_content $current_item(revision_id) + # TODO: Render using template #set rendered [publish::merge_with_template $current_item(item_id)] @@ -45,7 +47,7 @@ set page_title $current_item(title) set context [list [list ../object-list "Objects"] $page_title] -foreach name [array names current_item] { - multirow append attributes $name $current_item($name) +foreach name [lsort [array names content]] { + multirow append attributes $name $content($name) } Index: openacs-4/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/index.adp 14 Oct 2003 13:58:03 -0000 1.2 +++ openacs-4/packages/simulation/www/index.adp 14 Oct 2003 14:59:51 -0000 1.3 @@ -8,8 +8,8 @@
-

Flash map of city:

-

TODO

+

Sieberdam:

+


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.1 -r1.2 --- openacs-4/packages/simulation/www/object-edit.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/packages/simulation/www/object-edit.tcl 14 Oct 2003 14:59:51 -0000 1.2 @@ -5,8 +5,19 @@ @cvs-id $Id$ } { object_id:integer,optional - parent_id:integer - content_type + parent_id:integer,optional + content_type:optional +} -validate { + not_object_id { + if { ![exists_and_not_null object_id] } { + if { ![exists_and_not_null parent_id] } { + ad_complain parent_id "parent_id is required" + } + if { ![exists_and_not_null content_type] } { + ad_complain content_type "parent_id is required" + } + } + } } set page_title "Create Object" @@ -15,22 +26,31 @@ ad_form -name object -form { {object_id:key} {content_type:text(hidden)} - {parent_id:integer(hidden)} + {parent_id:integer(hidden),optional} {title:text {label "Title"} {html {size 50}} } {name:text,optional {label "URL name"} {html {size 50}} - {help_text "This will become part of the URL for the object."} + {help_text {[ad_decode [ad_form_new_p -key object_id] 1 "This will become part of the URL for the object." ""]}} + {mode {[ad_decode [ad_form_new_p -key object_id] 1 "edit" "display"]}} } {description:text(textarea),optional {label "Description"} {html {cols 60 rows 8}} } } +if { ![ad_form_new_p -key object_id] } { + # Get data for existing object + array set item_info [bcms::item::get_item -item_id $object_id -revision live] + item::get_revision_content $item_info(revision_id) + set content_type $item_info(content_type) +} + + # LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, # we'll want to generalize and move into acs-content-repository @@ -90,6 +110,8 @@ keyword {} } +set attr_names [list] + db_foreach select_attributes { select attribute_name, pretty_name, datatype, default_value, min_n_values from acs_attributes @@ -98,6 +120,8 @@ and static_p = 'f' order by sort_order } { + lappend attr_names $attribute_name + set elm_decl "attr__${content_type}__${attribute_name}:$form_datatype($datatype)($form_widget($datatype))" set optional_p [expr ![empty_string_p $default_value] || $min_n_values == 0] @@ -112,9 +136,17 @@ ad_form -extend -name object -new_request { # Set element values from local vars +} -on_submit { + + set attributes [list] + foreach attribute_name $attr_names { + lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] + } + } -new_data { set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] + if { [empty_string_p $name] } { set name [util_text_to_url -existing_urls $existing_items -text $title] } else { @@ -124,19 +156,6 @@ } } - set attributes [list] - - db_foreach select_attributes { - select attribute_name, pretty_name, datatype, default_value, min_n_values - from acs_attributes - where object_type = :content_type - and storage = 'type_specific' - and static_p = 'f' - order by sort_order - } { - lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] - } - set item_id [bcms::item::create_item \ -item_name $name \ -parent_id $parent_id \ @@ -155,13 +174,31 @@ -status "live" } -edit_request { - - error TODO + foreach elm { title name description } { + set $elm $content($elm) + } + + foreach attribute_name $attr_names { + set attr__${content_type}__${attribute_name} $content($attribute_name) + } + } -edit_data { - error TODO + set revision_id [bcms::revision::add_revision \ + -item_id $object_id \ + -title $title \ + -content_type $content_type \ + -mime_type "text/plain" \ + -description $description \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + + } -after_submit { ad_returnredirect object-list ad_script_abort 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.1 -r1.2 --- openacs-4/packages/simulation/www/object-list.tcl 14 Oct 2003 13:58:03 -0000 1.1 +++ openacs-4/packages/simulation/www/object-list.tcl 14 Oct 2003 14:59:51 -0000 1.2 @@ -18,6 +18,12 @@ -name objects \ -multirow objects \ -elements { + edit { + sub_class narrow + display_template { + Edit + } + } object_type_pretty { label "Type" orderby upper(ot.pretty_name) @@ -36,7 +42,7 @@ set package_id [ad_conn package_id] -db_multirow -extend { view_url } objects select_objects " +db_multirow -extend { edit_url view_url } objects select_objects " select i.item_id, i.name, r.title, @@ -54,6 +60,7 @@ [template::list::orderby_clause -orderby -name "objects"] " { set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { { object_id $item_id } }] set view_url [export_vars -base "object/$name"] }