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.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/object-display.adp	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/contrib/packages/simulation/lib/object-display.adp	17 Oct 2003 09:22:55 -0000	1.2
@@ -2,5 +2,7 @@
   <property name="title">@page_title;noquote@</property>
   <property name="context">@context;noquote@</property>
 
-<p><listtemplate name="attributes"></listtemplate></p>
 
+<if @content_html@ not nil>@content_html;noquote@</if>
+
+<if @edit_url@ not nil><a href="@edit_url@" class="button">Edit</a></if>
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.2 -r1.3
--- openacs-4/contrib/packages/simulation/lib/object-display.tcl	14 Oct 2003 14:59:50 -0000	1.2
+++ openacs-4/contrib/packages/simulation/lib/object-display.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -20,16 +20,23 @@
 
 # get the item by url if now revision id is given
 if { ![info exists revision_id] } {
-    array set current_item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live]
+    array set item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live]
 } else {
-    array set current_item [bcms::revision::get_revision -revision_id $revision_id]
+    array set item [bcms::revision::get_revision -revision_id $revision_id]
 }
+item::get_content \
+    -revision_id $item(revision_id) \
+    -array content
 
-item::get_revision_content $current_item(revision_id)
+set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] 
 
-# TODO: Render using template
-#set rendered [publish::merge_with_template $current_item(item_id)]
 
+######
+#
+# Temporary hack to dipslay attributes
+#
+#####
+
 template::list::create \
     -name attributes \
     -multirow attributes \
@@ -42,12 +49,44 @@
         }
     }
 
+
 multirow create attributes attribute value 
 
-set page_title $current_item(title)
+set page_title $item(title)
 set context [list [list ../object-list "Objects"] $page_title]
 
 foreach name [lsort [array names content]] {
     multirow append attributes $name $content($name)
 }
 
+
+if { [permission::write_permission_p -object_id $item(item_id)] } {
+    set edit_url [export_vars -base [ad_conn package_url]object-edit { { item_id $item(item_id) } }]
+}
+
+
+#####
+#
+# Render using template
+#
+#####
+
+# Dropped
+return
+
+item::get_content \
+    -revision_id [item::get_live_revision [item::get_template_id $item(item_id)]] \
+    -array template
+
+# Make content available to rendered page
+foreach __elm [array names content] { 
+    set $__elm $content($__elm)
+}
+
+
+publish::push_id $item_id $revision_id
+set code [template::adp_compile -string $template(text)]
+set rendered_page [template::adp_eval code]
+publish::pop_id
+
+
Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-content-types-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql	17 Oct 2003 09:22:55 -0000	1.2
@@ -80,38 +80,16 @@
 select content_type__create_attribute(
     'sim_home',                    -- content_type
     'stylesheet',                  -- attribute_name
-    'string',                      -- datatype
+    'text',                        -- datatype
     'Stylesheet',                  -- pretty_name
     'Stylesheets',                 -- pretty_plural
     5,                             -- sort_order
     null,                          -- default_value
-    'varchar(4000)'                -- column_spec
+    'text'                         -- column_spec
 );
 
 
 
 
 
 
--- sim_contact
-
-select content_type__create_type(
-    'sim_contact',                 -- content_type
-    'content_revision',            -- supertype
-    'Contact',                     -- pretty_name,
-    'Contacts',                    -- pretty_plural
-    'sim_contacts',                -- table_name
-    'contact_id',                  -- id_column
-    null                           -- name_method
-);
-
-select content_type__create_attribute(
-    'sim_contact',                 -- content_type
-    'internal_mail_adress',        -- attribute_name
-    'string',                      -- datatype
-    'Internal Mail Addresss',      -- pretty_name
-    'Internal Mail Addresses',     -- pretty_plural
-    1,                             -- sort_order
-    null,                          -- default_value
-    'varchar(1000)'                -- column_spec
-);
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.1 -r1.2
--- openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl	17 Oct 2003 09:22:55 -0000	1.2
@@ -21,6 +21,6 @@
                        -folder_label "${instance_name} Root" \
                        -parent_id 0 \
                        -package_id $package_id \
-                       -content_types { sim_character sim_prop sim_home sim_contact file_storage_object }]
+                       -content_types { sim_character sim_prop sim_home file_storage_object content_template }]
 }
 
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.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/object-edit.tcl	14 Oct 2003 14:59:51 -0000	1.2
+++ openacs-4/contrib/packages/simulation/www/object-edit.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -4,27 +4,24 @@
     @creation-date 2003-10-13
     @cvs-id $Id$
 } {
-    object_id:integer,optional
+    item_id:integer,optional
     parent_id:integer,optional
     content_type:optional
 } -validate {
-    not_object_id {
-        if { ![exists_and_not_null object_id] } {
+    not_item_id {
+        if { ![exists_and_not_null item_id] } {
             if { ![exists_and_not_null parent_id] } {
-                ad_complain parent_id "parent_id is required"
+                ad_complain "parent_id is required"
             }
             if { ![exists_and_not_null content_type] } {
-                ad_complain content_type "parent_id is required"
+                ad_complain "content_type is required"
             }
         }
     }
 }
 
-set page_title "Create Object"
-set context [list [list "object-list" "Objects"] $page_title]
-
-ad_form -name object -form {
-    {object_id:key}
+ad_form -name object -cancel_url object-list -form {
+    {item_id:key}
     {content_type:text(hidden)}
     {parent_id:integer(hidden),optional}
     {title:text
@@ -34,23 +31,65 @@
     {name:text,optional
         {label "URL name"}
         {html {size 50}}
-        {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"]}}
+        {help_text {[ad_decode [ad_form_new_p -key item_id] 1 "This will become part of the URL for the object." ""]}}
+        {mode {[ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"]}}
     }
     {description:text(textarea),optional
         {label "Description"}
         {html {cols 60 rows 8}}
     }
 }
 
-if { ![ad_form_new_p -key object_id] } {
+if { ![ad_form_new_p -key item_id] } {
     # Get data for existing object
-    array set item_info [bcms::item::get_item -item_id $object_id -revision live]
+    array set item_info [bcms::item::get_item -item_id $item_id -revision live]
     item::get_revision_content $item_info(revision_id)
     set content_type $item_info(content_type)
+    set page_title "Edit Object"
+} else {
+    set object_type_pretty [db_string pretty { select pretty_name from acs_object_types where object_type = :content_type }]
+    set page_title "Create $object_type_pretty"
 }
+set context [list [list "object-list" "Objects"] $page_title]
 
 
+#####
+#
+# Content edit/upload method
+#
+#####
+
+array set content_method {
+    sim_character richtext
+    sim_home richtext
+    sim_prop richtext
+}
+
+if { [info exists content_method($content_type)] } {
+
+    switch $content_method($content_type) {
+        richtext {
+            ad_form -extend -name object -form {
+                {content_elm:richtext(richtext),optional
+                    {label "Content"}
+                    {html {cols 60 rows 8}}
+                }
+            }
+        }
+        upload {
+            
+        }
+    }
+
+}
+
+
+#####
+#
+# Dynamic attributes for the 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
 
@@ -161,11 +200,15 @@
                      -parent_id $parent_id \
                      -content_type $content_type]
     
+    set content_text [template::util::richtext::get_property contents $content_elm]
+    set mime_type [template::util::richtext::get_property format $content_elm]
+
     set revision_id [bcms::revision::add_revision \
                          -item_id $item_id \
                          -title $title \
                          -content_type $content_type \
-                         -mime_type "text/plain" \
+                         -mime_type $mime_type \
+                         -content $content_text \
                          -description $description \
                          -additional_properties $attributes]
 
@@ -183,13 +226,18 @@
         set attr__${content_type}__${attribute_name} $content($attribute_name)
     }
     
+    set content_elm [template::util::richtext::create $content(text) $content(mime_type)]
 } -edit_data {
 
+    set content_text [template::util::richtext::get_property contents $content_elm]
+    set mime_type [template::util::richtext::get_property format $content_elm]
+
     set revision_id [bcms::revision::add_revision \
-                         -item_id $object_id \
+                         -item_id $item_id \
                          -title $title \
                          -content_type $content_type \
-                         -mime_type "text/plain" \
+                         -mime_type $mime_type \
+                         -content $content_text \
                          -description $description \
                          -additional_properties $attributes]
 
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.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/object-list.tcl	14 Oct 2003 14:59:51 -0000	1.2
+++ openacs-4/contrib/packages/simulation/www/object-list.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -60,11 +60,11 @@
     [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 edit_url [export_vars -base "object-edit" { item_id }]
     set view_url [export_vars -base "object/$name"]
 }
 
-set sim_types { sim_character sim_prop sim_home sim_contact file_storage_object }
+set sim_types { sim_character sim_prop sim_home }
 
 db_multirow -extend { create_url label } object_types select_object_types "
     select ot.object_type as content_type,
@@ -74,4 +74,7 @@
 " {
     set create_url [export_vars -base object-edit { content_type parent_id }]
     set label "Create new $pretty_name"
+
 }
+
+#multirow append object_types content_template  "Template" [export_vars -base template-edit] "Upload new Template"
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.1 -r1.2
--- openacs-4/packages/simulation/lib/object-display.adp	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/packages/simulation/lib/object-display.adp	17 Oct 2003 09:22:55 -0000	1.2
@@ -2,5 +2,7 @@
   <property name="title">@page_title;noquote@</property>
   <property name="context">@context;noquote@</property>
 
-<p><listtemplate name="attributes"></listtemplate></p>
 
+<if @content_html@ not nil>@content_html;noquote@</if>
+
+<if @edit_url@ not nil><a href="@edit_url@" class="button">Edit</a></if>
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.2 -r1.3
--- openacs-4/packages/simulation/lib/object-display.tcl	14 Oct 2003 14:59:50 -0000	1.2
+++ openacs-4/packages/simulation/lib/object-display.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -20,16 +20,23 @@
 
 # get the item by url if now revision id is given
 if { ![info exists revision_id] } {
-    array set current_item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live]
+    array set item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live]
 } else {
-    array set current_item [bcms::revision::get_revision -revision_id $revision_id]
+    array set item [bcms::revision::get_revision -revision_id $revision_id]
 }
+item::get_content \
+    -revision_id $item(revision_id) \
+    -array content
 
-item::get_revision_content $current_item(revision_id)
+set content_html [ad_html_text_convert -from $content(mime_type) -to "text/html" -- $content(text)] 
 
-# TODO: Render using template
-#set rendered [publish::merge_with_template $current_item(item_id)]
 
+######
+#
+# Temporary hack to dipslay attributes
+#
+#####
+
 template::list::create \
     -name attributes \
     -multirow attributes \
@@ -42,12 +49,44 @@
         }
     }
 
+
 multirow create attributes attribute value 
 
-set page_title $current_item(title)
+set page_title $item(title)
 set context [list [list ../object-list "Objects"] $page_title]
 
 foreach name [lsort [array names content]] {
     multirow append attributes $name $content($name)
 }
 
+
+if { [permission::write_permission_p -object_id $item(item_id)] } {
+    set edit_url [export_vars -base [ad_conn package_url]object-edit { { item_id $item(item_id) } }]
+}
+
+
+#####
+#
+# Render using template
+#
+#####
+
+# Dropped
+return
+
+item::get_content \
+    -revision_id [item::get_live_revision [item::get_template_id $item(item_id)]] \
+    -array template
+
+# Make content available to rendered page
+foreach __elm [array names content] { 
+    set $__elm $content($__elm)
+}
+
+
+publish::push_id $item_id $revision_id
+set code [template::adp_compile -string $template(text)]
+set rendered_page [template::adp_eval code]
+publish::pop_id
+
+
Index: openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql	17 Oct 2003 09:22:55 -0000	1.2
@@ -80,38 +80,16 @@
 select content_type__create_attribute(
     'sim_home',                    -- content_type
     'stylesheet',                  -- attribute_name
-    'string',                      -- datatype
+    'text',                        -- datatype
     'Stylesheet',                  -- pretty_name
     'Stylesheets',                 -- pretty_plural
     5,                             -- sort_order
     null,                          -- default_value
-    'varchar(4000)'                -- column_spec
+    'text'                         -- column_spec
 );
 
 
 
 
 
 
--- sim_contact
-
-select content_type__create_type(
-    'sim_contact',                 -- content_type
-    'content_revision',            -- supertype
-    'Contact',                     -- pretty_name,
-    'Contacts',                    -- pretty_plural
-    'sim_contacts',                -- table_name
-    'contact_id',                  -- id_column
-    null                           -- name_method
-);
-
-select content_type__create_attribute(
-    'sim_contact',                 -- content_type
-    'internal_mail_adress',        -- attribute_name
-    'string',                      -- datatype
-    'Internal Mail Addresss',      -- pretty_name
-    'Internal Mail Addresses',     -- pretty_plural
-    1,                             -- sort_order
-    null,                          -- default_value
-    'varchar(1000)'                -- column_spec
-);
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.1 -r1.2
--- openacs-4/packages/simulation/tcl/apm-callback-procs.tcl	14 Oct 2003 13:58:03 -0000	1.1
+++ openacs-4/packages/simulation/tcl/apm-callback-procs.tcl	17 Oct 2003 09:22:55 -0000	1.2
@@ -21,6 +21,6 @@
                        -folder_label "${instance_name} Root" \
                        -parent_id 0 \
                        -package_id $package_id \
-                       -content_types { sim_character sim_prop sim_home sim_contact file_storage_object }]
+                       -content_types { sim_character sim_prop sim_home file_storage_object content_template }]
 }
 
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.2 -r1.3
--- openacs-4/packages/simulation/www/object-edit.tcl	14 Oct 2003 14:59:51 -0000	1.2
+++ openacs-4/packages/simulation/www/object-edit.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -4,27 +4,24 @@
     @creation-date 2003-10-13
     @cvs-id $Id$
 } {
-    object_id:integer,optional
+    item_id:integer,optional
     parent_id:integer,optional
     content_type:optional
 } -validate {
-    not_object_id {
-        if { ![exists_and_not_null object_id] } {
+    not_item_id {
+        if { ![exists_and_not_null item_id] } {
             if { ![exists_and_not_null parent_id] } {
-                ad_complain parent_id "parent_id is required"
+                ad_complain "parent_id is required"
             }
             if { ![exists_and_not_null content_type] } {
-                ad_complain content_type "parent_id is required"
+                ad_complain "content_type is required"
             }
         }
     }
 }
 
-set page_title "Create Object"
-set context [list [list "object-list" "Objects"] $page_title]
-
-ad_form -name object -form {
-    {object_id:key}
+ad_form -name object -cancel_url object-list -form {
+    {item_id:key}
     {content_type:text(hidden)}
     {parent_id:integer(hidden),optional}
     {title:text
@@ -34,23 +31,65 @@
     {name:text,optional
         {label "URL name"}
         {html {size 50}}
-        {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"]}}
+        {help_text {[ad_decode [ad_form_new_p -key item_id] 1 "This will become part of the URL for the object." ""]}}
+        {mode {[ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"]}}
     }
     {description:text(textarea),optional
         {label "Description"}
         {html {cols 60 rows 8}}
     }
 }
 
-if { ![ad_form_new_p -key object_id] } {
+if { ![ad_form_new_p -key item_id] } {
     # Get data for existing object
-    array set item_info [bcms::item::get_item -item_id $object_id -revision live]
+    array set item_info [bcms::item::get_item -item_id $item_id -revision live]
     item::get_revision_content $item_info(revision_id)
     set content_type $item_info(content_type)
+    set page_title "Edit Object"
+} else {
+    set object_type_pretty [db_string pretty { select pretty_name from acs_object_types where object_type = :content_type }]
+    set page_title "Create $object_type_pretty"
 }
+set context [list [list "object-list" "Objects"] $page_title]
 
 
+#####
+#
+# Content edit/upload method
+#
+#####
+
+array set content_method {
+    sim_character richtext
+    sim_home richtext
+    sim_prop richtext
+}
+
+if { [info exists content_method($content_type)] } {
+
+    switch $content_method($content_type) {
+        richtext {
+            ad_form -extend -name object -form {
+                {content_elm:richtext(richtext),optional
+                    {label "Content"}
+                    {html {cols 60 rows 8}}
+                }
+            }
+        }
+        upload {
+            
+        }
+    }
+
+}
+
+
+#####
+#
+# Dynamic attributes for the 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
 
@@ -161,11 +200,15 @@
                      -parent_id $parent_id \
                      -content_type $content_type]
     
+    set content_text [template::util::richtext::get_property contents $content_elm]
+    set mime_type [template::util::richtext::get_property format $content_elm]
+
     set revision_id [bcms::revision::add_revision \
                          -item_id $item_id \
                          -title $title \
                          -content_type $content_type \
-                         -mime_type "text/plain" \
+                         -mime_type $mime_type \
+                         -content $content_text \
                          -description $description \
                          -additional_properties $attributes]
 
@@ -183,13 +226,18 @@
         set attr__${content_type}__${attribute_name} $content($attribute_name)
     }
     
+    set content_elm [template::util::richtext::create $content(text) $content(mime_type)]
 } -edit_data {
 
+    set content_text [template::util::richtext::get_property contents $content_elm]
+    set mime_type [template::util::richtext::get_property format $content_elm]
+
     set revision_id [bcms::revision::add_revision \
-                         -item_id $object_id \
+                         -item_id $item_id \
                          -title $title \
                          -content_type $content_type \
-                         -mime_type "text/plain" \
+                         -mime_type $mime_type \
+                         -content $content_text \
                          -description $description \
                          -additional_properties $attributes]
 
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.2 -r1.3
--- openacs-4/packages/simulation/www/object-list.tcl	14 Oct 2003 14:59:51 -0000	1.2
+++ openacs-4/packages/simulation/www/object-list.tcl	17 Oct 2003 09:22:55 -0000	1.3
@@ -60,11 +60,11 @@
     [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 edit_url [export_vars -base "object-edit" { item_id }]
     set view_url [export_vars -base "object/$name"]
 }
 
-set sim_types { sim_character sim_prop sim_home sim_contact file_storage_object }
+set sim_types { sim_character sim_prop sim_home }
 
 db_multirow -extend { create_url label } object_types select_object_types "
     select ot.object_type as content_type,
@@ -74,4 +74,7 @@
 " {
     set create_url [export_vars -base object-edit { content_type parent_id }]
     set label "Create new $pretty_name"
+
 }
+
+#multirow append object_types content_template  "Template" [export_vars -base template-edit] "Upload new Template"