Index: openacs-4/packages/static-portlet/static-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/static-portlet.info,v diff -u -r1.13.2.3.4.6 -r1.13.2.3.4.7 --- openacs-4/packages/static-portlet/static-portlet.info 5 Jul 2005 18:14:15 -0000 1.13.2.3.4.6 +++ openacs-4/packages/static-portlet/static-portlet.info 19 Jul 2005 17:45:19 -0000 1.13.2.3.4.7 @@ -7,12 +7,12 @@ f f - + OpenACS 2004-03-10 OpenACS - + Index: openacs-4/packages/static-portlet/sql/postgresql/static-core.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/sql/postgresql/static-core.sql,v diff -u -r1.4.6.1 -r1.4.6.2 --- openacs-4/packages/static-portlet/sql/postgresql/static-core.sql 22 Jun 2004 19:28:49 -0000 1.4.6.1 +++ openacs-4/packages/static-portlet/sql/postgresql/static-core.sql 19 Jul 2005 17:45:19 -0000 1.4.6.2 @@ -70,7 +70,10 @@ pretty_name varchar(100) constraint static_p_c_pretty_name_nn not null, - body text + body text, + format varchar(30) default 'text/html' + constraint static_p_c_format_in + check (format in ('text/enhanced', 'text/plain', 'text/fixed-width', 'text/html')) ); @@ -79,17 +82,19 @@ -- API -- -create function static_portal_content_item__new (integer, varchar, varchar) +create function static_portal_content_item__new (integer, varchar, varchar, varchar) returns integer as ' declare p_package_id alias for $1; p_pretty_name alias for $2; p_content alias for $3; + p_format alias for $4; begin return static_portal_content_item__new( p_package_id, p_pretty_name, p_content, + p_format, null, null, null, @@ -103,6 +108,7 @@ integer, -- package_id in static_portal_content.package_id%TYPE default null, varchar, -- pretty_name in static_portal_content.pretty_name%TYPE default null, varchar, -- content in static_portal_content.content%TYPE default null, + varchar, -- format in static_portal_content.format%TYPE default text/html, varchar, -- object_type in acs_objects.object_type%TYPE default [static_portal_content], timestamptz, -- creation_date in acs_objects.creation_date%TYPE default sysdate, integer, -- creation_user in acs_objects.creation_user%TYPE default null, @@ -114,11 +120,12 @@ p_package_id alias for $1; p_pretty_name alias for $2; p_content alias for $3; - p_object_type alias for $4; - p_creation_date alias for $5; - p_creation_user alias for $6; - p_creation_ip alias for $7; - p_context_id alias for $8; + p_format alias for $4; + p_object_type alias for $5; + p_creation_date alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; v_content_id static_portal_content.content_id%TYPE; v_object_type varchar; begin @@ -139,9 +146,9 @@ insert into static_portal_content - (content_id, package_id, pretty_name, body) + (content_id, package_id, pretty_name, body, format) values - (v_content_id, p_package_id, p_pretty_name, p_content); + (v_content_id, p_package_id, p_pretty_name, p_content, p_format); return v_content_id; end;' language 'plpgsql'; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/static-portlet/sql/postgresql/upgrade/upgrade-2.1.2d1-2.1.2d2.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/static-portlet/tcl/static-portal-content-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-portal-content-procs-postgresql.xql,v diff -u -r1.3 -r1.3.10.1 --- openacs-4/packages/static-portlet/tcl/static-portal-content-procs-postgresql.xql 4 Aug 2002 21:49:55 -0000 1.3 +++ openacs-4/packages/static-portlet/tcl/static-portal-content-procs-postgresql.xql 19 Jul 2005 17:45:20 -0000 1.3.10.1 @@ -8,7 +8,8 @@ select static_portal_content_item__new( :package_id, :pretty_name, - :content + :content, + :format ); Index: openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl,v diff -u -r1.16.6.3 -r1.16.6.4 --- openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 10 Aug 2004 16:42:53 -0000 1.16.6.3 +++ openacs-4/packages/static-portlet/tcl/static-portal-content-procs.tcl 19 Jul 2005 17:45:20 -0000 1.16.6.4 @@ -30,10 +30,11 @@ {-package_id:required} {-content:required} {-pretty_name:required} + {-format "text/html"} } { Calls the pl/sql to create the new content item } { - # Create the content item + # Create the content item set content_id [db_exec_plsql new_content_item {}] # Ben's style only cause he was editing here and then changed things back @@ -72,8 +73,8 @@ lappend new_content_ids [static_portal_content::new \ -package_id $package_id \ -content [get_content -content_id $old_content_id] \ - -pretty_name [get_pretty_name -content_id $old_content_id] - ] + -format [get_content_format -content_id $old_content_id] \ + -pretty_name [get_pretty_name -content_id $old_content_id]] } @@ -167,10 +168,12 @@ {-content_id:required} {-content:required} {-pretty_name:required} + {-format "text/html"} } { updates the content item } { - db_transaction { + + db_transaction { # update the content item db_dml update_content_item {} @@ -225,5 +228,12 @@ } { return [db_string get_package_id.select {}] } - + + ad_proc -public get_content_format { + {-content_id:required} + } { + Get the format of the content's item + } { + return [db_string get_content_format.select {} ] + } } Index: openacs-4/packages/static-portlet/tcl/static-portal-content-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/tcl/static-portal-content-procs.xql,v diff -u -r1.2.10.1 -r1.2.10.2 --- openacs-4/packages/static-portlet/tcl/static-portal-content-procs.xql 22 Jun 2004 19:28:49 -0000 1.2.10.1 +++ openacs-4/packages/static-portlet/tcl/static-portal-content-procs.xql 19 Jul 2005 17:45:20 -0000 1.2.10.2 @@ -24,7 +24,7 @@ update static_portal_content set - body = :content, pretty_name = :pretty_name + body = :content, pretty_name = :pretty_name, format = :format where content_id = :content_id @@ -53,4 +53,12 @@ + + + select format + from static_portal_content + where content_id = :content_id + + + Index: openacs-4/packages/static-portlet/www/element.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/www/element.tcl,v diff -u -r1.10.2.1.4.6 -r1.10.2.1.4.7 --- openacs-4/packages/static-portlet/www/element.tcl 5 Nov 2004 12:02:49 -0000 1.10.2.1.4.6 +++ openacs-4/packages/static-portlet/www/element.tcl 19 Jul 2005 17:45:20 -0000 1.10.2.1.4.7 @@ -70,16 +70,18 @@ {package_id:text(hidden) {value $package_id}} {referer:text(hidden) {value $referer}} } -edit_request { - db_1row get_content_element "" - ad_set_form_values pretty_name + db_1row get_content_element "" + set content [template::util::richtext::create $body $format] + ad_set_form_values pretty_name } -new_data { + db_transaction { set item_id [static_portal_content::new \ -package_id $package_id \ - -content $content \ - -pretty_name $pretty_name - ] - + -content [template::util::richtext::get_property contents $content] \ + -format [template::util::richtext::get_property format $content] \ + -pretty_name $pretty_name] + set old_element_id [static_portal_content::add_to_portal \ -portal_id $portal_id \ -package_id $package_id \ @@ -114,8 +116,9 @@ # clone the template's content set new_content_id [static_portal_content::new \ -package_id $community_id \ - -content $content \ - -pretty_name $pretty_name ] + -content [template::util::richtext::get_property contents $content] \ + -format [template::util::richtext::get_property format $content] \ + -pretty_name $pretty_name ] } @@ -133,7 +136,6 @@ } - # redirect and abort ad_returnredirect $referer ad_script_abort @@ -144,9 +146,9 @@ static_portal_content::update \ -portal_id $portal_id \ -content_id $element_content_id \ - -pretty_name $pretty_name \ - -content $content - + -pretty_name $pretty_name \ + -content [template::util::richtext::get_property contents $content] \ + -format [template::util::richtext::get_property format $content] } @@ -189,8 +191,9 @@ # clone the template's content set element_content_id [static_portal_content::new \ -package_id $community_id \ - -content $content \ - -pretty_name $pretty_name ] + -content [template::util::richtext::get_property contents $content] \ + -format [template::util::richtext::get_property format $content] \ + -pretty_name $pretty_name ] } set new_element_id [ static_portal_content::add_to_portal \ @@ -209,7 +212,8 @@ -portal_id $target_portal_id \ -content_id $element_content_id \ -pretty_name $pretty_name \ - -content $content + -content [template::util::richtext::get_property contents $content] \ + -format [template::util::richtext::get_property format $content] } if {$enforce_portlet == 0} { @@ -232,6 +236,9 @@ file_content_id:key {pretty_name:text(text) {label "[_ static-portlet.Name]"} {html {size 60}}} {upload_file:file {label "[_ static-portlet.File]"}} + {content_format:text(select) {label "Format"} + {options { {"Enhanced Text" "text/enhanced"} {"Plain Text" "text/plain"} {"Fixed-width Text" "text/fixed-width"} { "HTML" "text/html"} }} + {value "text/plain"}} } if {[lsearch $templates $type] >= 0} { @@ -268,7 +275,8 @@ set item_id [static_portal_content::new \ -package_id $package_id \ -content $content \ - -pretty_name $pretty_name + -format $content_format \ + -pretty_name $pretty_name ] static_portal_content::add_to_portal \ @@ -304,6 +312,7 @@ set new_content_id [static_portal_content::new \ -package_id $community_id \ -content $content \ + -format $content_format \ -pretty_name $pretty_name ] } @@ -344,7 +353,8 @@ -portal_id $portal_id \ -content_id $file_content_id \ -pretty_name $pretty_name \ - -content $content + -content $content \ + -format $content_format } switch $type { @@ -388,7 +398,8 @@ set file_content_id [static_portal_content::new \ -package_id $community_id \ -content $content \ - -pretty_name $pretty_name ] + -format $content_format \ + -pretty_name $pretty_name ] } set new_element_id [ static_portal_content::add_to_portal \ @@ -407,7 +418,8 @@ -portal_id $target_portal_id \ -content_id $file_content_id \ -pretty_name $pretty_name \ - -content $content + -content $content \ + -format $content_format } if {$enforce_portlet == 0} { Index: openacs-4/packages/static-portlet/www/element.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/www/element.xql,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/static-portlet/www/element.xql 22 Jun 2004 19:30:05 -0000 1.1.2.1 +++ openacs-4/packages/static-portlet/www/element.xql 19 Jul 2005 17:45:20 -0000 1.1.2.2 @@ -4,7 +4,7 @@ - select body as content, pretty_name + select body, pretty_name, format from static_portal_content where content_id = :content_id Index: openacs-4/packages/static-portlet/www/static-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-portlet/www/static-portlet.tcl,v diff -u -r1.6.6.1.4.2 -r1.6.6.1.4.3 --- openacs-4/packages/static-portlet/www/static-portlet.tcl 10 Nov 2004 14:01:48 -0000 1.6.6.1.4.2 +++ openacs-4/packages/static-portlet/www/static-portlet.tcl 19 Jul 2005 17:45:20 -0000 1.6.6.1.4.3 @@ -30,7 +30,7 @@ set success_p 0 set success_p [db_0or1row select_content { - select body as content, pretty_name + select body, pretty_name, format from static_portal_content where content_id = :content_id }] @@ -39,8 +39,7 @@ set class_instances_pretty_name [_ dotlrn.class_instances_pretty_name] set pretty_name [lang::util::localize $pretty_name] +set content_w [template::util::richtext::create $body $format] +set content [template::util::richtext::get_property html_value $content_w] -if { [regexp {^\{(.*)\} text/html$} $content match elhtml] } { - set content $elhtml - }