Index: openacs-4/packages/news/news.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/news.info,v
diff -u -N -r1.28 -r1.29
--- openacs-4/packages/news/news.info 10 Oct 2009 22:38:10 -0000 1.28
+++ openacs-4/packages/news/news.info 22 Dec 2009 22:24:02 -0000 1.29
@@ -7,7 +7,7 @@
f
f
-
+
OpenACS
Used for announcements and news items.
2007-06-15
@@ -16,7 +16,7 @@
0
#news.News#
-
+
Index: openacs-4/packages/news/sql/oracle/news-views-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/oracle/news-views-create.sql,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/news/sql/oracle/news-views-create.sql 24 Feb 2005 18:03:04 -0000 1.1
+++ openacs-4/packages/news/sql/oracle/news-views-create.sql 22 Dec 2009 22:24:02 -0000 1.2
@@ -13,9 +13,8 @@
cn.package_id,
cr.title as publish_title,
cn.lead as publish_lead,
- content.blob_to_string(cr.content) as publish_body,
- cr.content as content,
- decode(cr.mime_type, 'text/html','t','f') as html_p,
+ cr.content as publish_body,
+ cr.mime_type as publish_format,
to_char(cr.publish_date, 'Mon dd, yyyy') as pretty_publish_date,
cr.publish_date,
ao.creation_user,
@@ -46,8 +45,8 @@
cn.archive_date,
cr.title as publish_title,
cn.lead as publish_lead,
- content.blob_to_string(cr.content) as publish_body,
- decode(cr.mime_type, 'text/html','t','f') as html_p,
+ cr.content as publish_body,
+ cr.mime_type as publish_format,
ao.creation_user,
ps.first_names || ' ' || ps.last_name as item_creator,
ao.creation_date,
@@ -111,11 +110,11 @@
ci.live_revision,
cr.title as publish_title,
cn.lead as publish_lead,
- content.blob_to_string(cr.content) as publish_body,
+ cr.content as publish_body,
cr.publish_date,
cn.archive_date,
cr.description as log_entry,
- decode(cr.mime_type,'text/html','t','f') as html_p,
+ cr.mime_type as publish_format,
cr.mime_type as mime_type,
cn.package_id,
ao.creation_date as creation_date,
@@ -175,8 +174,8 @@
revision_id,
cr.title as publish_title,
cn.lead as publish_lead,
- content.blob_to_string(cr.content) as publish_body,
- decode(cr.mime_type,'text/html','t','f') as html_p,
+ cr.content as publish_body,
+ cr.mime_type as publish_format,
cr.publish_date,
cn.archive_date,
news.status(cr.publish_date, cn.archive_date) as status,
Index: openacs-4/packages/news/sql/postgresql/news-views-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/postgresql/news-views-create.sql,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/news/sql/postgresql/news-views-create.sql 24 Feb 2005 18:03:04 -0000 1.1
+++ openacs-4/packages/news/sql/postgresql/news-views-create.sql 22 Dec 2009 22:24:02 -0000 1.2
@@ -22,7 +22,7 @@
cr.title as publish_title,
cn.lead as publish_lead,
cr.content as publish_body,
- (case when cr.mime_type = 'text/html' then 't' else 'f' end) as html_p,
+ cr.mime_type as publish_format,
to_char(cr.publish_date, 'Mon dd, yyyy') as pretty_publish_date,
cr.publish_date,
ao.creation_user,
@@ -59,7 +59,7 @@
cr.title as publish_title,
cn.lead as publish_lead,
cr.content as publish_body,
- (case when cr.mime_type = 'text/html' then 't' else 'f' end) as html_p,
+ cr.mime_type as publish_format,
ao.creation_user,
ps.first_names || ' ' || ps.last_name as item_creator,
ao.creation_date::date as creation_date,
@@ -130,7 +130,7 @@
cr.publish_date,
cn.archive_date,
cr.description as log_entry,
- (case when cr.mime_type = 'text/html' then 't' else 'f' end) as html_p,
+ cr.mime_type as publish_format,
cr.mime_type as mime_type,
cn.package_id,
ao.creation_date::date as creation_date,
@@ -194,7 +194,7 @@
cr.title as publish_title,
cn.lead as publish_lead,
cr.content as publish_body,
- (case when cr.mime_type = 'text/html' then 't' else 'f' end) as html_p,
+ cr.mime_type as publish_format,
cr.publish_date,
cn.archive_date,
news__status(cr.publish_date, cn.archive_date) as status,
Index: openacs-4/packages/news/tcl/news-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/tcl/news-procs.tcl,v
diff -u -N -r1.30 -r1.31
--- openacs-4/packages/news/tcl/news-procs.tcl 14 Jun 2009 07:47:40 -0000 1.30
+++ openacs-4/packages/news/tcl/news-procs.tcl 22 Dec 2009 22:24:02 -0000 1.31
@@ -153,7 +153,7 @@
live_revision,
publish_title,
publish_lead,
- html_p,
+ publish_format,
publish_date,
publish_body,
creation_user,
@@ -175,6 +175,7 @@
publish_title $publish_title \
publish_title $publish_lead \
publish_body $publish_body \
+ publish_format $publish_format \
publish_image {} \
creator_link $item_creator ]]
@@ -390,17 +391,10 @@
set instance_name [application_group::closest_ancestor_element -include_self -node_id $node_id -element "instance_name"]
# get the title and teaser for latest news item for the given package id
- if { [db_0or1row "get_news" "select item_id, publish_date, publish_title as title, publish_lead as lead, publish_body as body,html_p from news_items_live_or_submitted where news_id =
+ if { [db_0or1row "get_news" "select item_id, publish_date, publish_title as title, publish_lead as lead, publish_body, publish_format from news_items_live_or_submitted where news_id =
:news_id"] } {
- set new_content "$title\n\n$lead"
- set html_content [ad_html_text_convert -- $new_content]
- if {$html_p} {
- append new_content "\n\n[ad_html_text_convert -from text/html -to text/plain -- $body]"
- append html_content "
$body"
- } else {
- append new_content "\n\n$body"
- append html_content "
[ad_html_text_convert -- $body]"
- }
+ set new_content "$title\n\n$lead\n\n[ad_html_text_convert -from $publish_format -to text/plain -- $publish_body]"
+ set html_content [ad_html_text_convert -from $publish_format -to text/html -- $publish_body]
append new_content "\n\n[string repeat - 70]"
append new_content "\n\n[parameter::get_from_package_key -package_key acs-kernel -parameter SystemURL][news_util_get_url $news_package_id]]item?item_id=$item_id \n\n"
append html_content "
[ad_html_text_convert "\n [parameter::get_from_package_key -package_key acs-kernel -parameter SystemURL][news_util_get_url $news_package_id]item?item_id=$item_id"]
"
Index: openacs-4/packages/news/www/item-create-3.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/item-create-3.tcl,v
diff -u -N -r1.10 -r1.11
--- openacs-4/packages/news/www/item-create-3.tcl 8 Aug 2006 21:27:04 -0000 1.10
+++ openacs-4/packages/news/www/item-create-3.tcl 22 Dec 2009 22:24:02 -0000 1.11
@@ -10,11 +10,11 @@
@cvs-id $Id$
} {
publish_title:notnull
- publish_body:notnull,allhtml,trim
+ publish_body:notnull,html,trim
+ publish_body.format:notnull,trim
{publish_lead {}}
{publish_date_ansi:trim "[db_null]"}
{archive_date_ansi:trim "[db_null]"}
- html_p:notnull
permanent_p:notnull
imgfile:optional
} -validate {
@@ -69,29 +69,20 @@
set creation_ip [ad_conn "peeraddr"]
set user_id [ad_conn "user_id"]
+# avoid any db weirdness with the "." in the variable name.
+set mime_type ${publish_body.format}
-# set mime_type
-if {[string match $html_p t]} {
- set mime_type "text/html"
-} else {
- set mime_type "text/plain"
-}
# do insert: unfortunately the publish_body cannot be supplied through the PL/SQL function
# we therefore have to do this in a second step
set news_id [db_exec_plsql create_news_item {}]
-
#
# RAL: For postgres, we need NOT store the data in a blob. The
# news item body is stored in the prior news__new call.
#
set content_add [db_map content_add]
if {![string match $content_add ""]} {
- db_dml content_add "
- update cr_revisions
- set content = empty_blob()
- where revision_id = :news_id
- returning content into :1" -blobs [list $publish_body]
+ db_dml content_add {} -blobs [list $publish_body]
}
# if an image is specified, we add it here.
Index: openacs-4/packages/news/www/item-create.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/item-create.tcl,v
diff -u -N -r1.7 -r1.8
--- openacs-4/packages/news/www/item-create.tcl 24 Feb 2009 23:11:02 -0000 1.7
+++ openacs-4/packages/news/www/item-create.tcl 22 Dec 2009 22:24:02 -0000 1.8
@@ -12,17 +12,11 @@
} {
{publish_title {}}
{publish_lead {}}
- {publish_body:allhtml {}}
- {html_p {f}}
+ {publish_body:html {}}
+ {publish_body.format {}}
{publish_date_ansi {now}}
{archive_date_ansi {}}
{permanent_p {}}
-} -properties {
- title:onevalue
- context:onevalue
- publish_date_select:onevalue
- archive_date_select:onevalue
- immediate_approve_p:onevalue
}
# Authorization by news_create
@@ -63,16 +57,12 @@
{label "[_ news.Lead]"}
{html {cols 60 rows 3}}
{value $publish_lead}}
- {publish_body:text(textarea),optional
+ {publish_body:text(richtext),optional
{label "[_ news.Body]"}
{html {cols 60 rows 20}}
- {value $publish_body}}
+ {value "[list $publish_body ${publish_body.format}]"}}
{text_file:text(file),optional
{label "[_ news.or_upload_text_file]"}}
- {html_p:text(radio)
- {label "[_ news.The_text_is_formatted_as]"}
- {options {{"#news.Plain_text#" f} {"#news.HTML#" t}}}
- {value $html_p}}
}
if { $immediate_approve_p } {
Index: openacs-4/packages/news/www/item.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/item.adp,v
diff -u -N -r1.15 -r1.16
--- openacs-4/packages/news/www/item.adp 9 Nov 2008 23:29:28 -0000 1.15
+++ openacs-4/packages/news/www/item.adp 22 Dec 2009 22:24:02 -0000 1.16
@@ -5,10 +5,10 @@
@title;noquote@
+ publish_title = "@publish_title;noquote@"
+ publish_body = "@publish_body;noquote@"
+ publish_format = "@publish_format;noquote@"
+ creator_link = "@creator_link;noquote@">
#news.Comments#
@@ -21,4 +21,4 @@
@footer_links;noquote@
-
\ No newline at end of file
+
Index: openacs-4/packages/news/www/item.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/item.tcl,v
diff -u -N -r1.16 -r1.17
--- openacs-4/packages/news/www/item.tcl 9 Nov 2008 23:29:28 -0000 1.16
+++ openacs-4/packages/news/www/item.tcl 22 Dec 2009 22:24:02 -0000 1.17
@@ -18,8 +18,8 @@
publish_title:onevalue
publish_date:onevalue
publish_body:onevalue
+ publish_format:onevalue
publish_image:onevalue
- html_p:onevalue
creator_link:onevalue
comments:onevalue
comment_link:onevalue
@@ -39,21 +39,6 @@
if { $item_exist_p } {
- # workaround to get blobs with >4000 chars into a var, content.blob_to_string fails!
- # when this'll work, you get publish_body by selecting 'publish_body' directly from above view
- #
- # RAL: publish_body is already snagged in the 1st query above for postgres.
- #
- set get_content [db_map get_content]
- if { $get_content ne "" } {
- set publish_body [db_string get_content {}]
- }
-
- # text-only body
- if { !$html_p } {
- set publish_body "[ad_text_to_html -- $publish_body]
"
- }
-
# Footer actions
set footer_links [list]
Index: openacs-4/packages/news/www/item.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/item.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/www/item.xql 22 Dec 2009 22:24:02 -0000 1.3
@@ -0,0 +1,13 @@
+
+
+
+
+
+ select item_id, live_revision, publish_title, publish_body, publish_format, publish_date,
+ '' || item_creator || '' as creator_link
+ from news_items_live_or_submitted
+ where item_id = :item_id
+
+
+
+
Index: openacs-4/packages/news/www/news.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/news.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/www/news.tcl 22 Dec 2009 22:24:02 -0000 1.1
@@ -0,0 +1,4 @@
+# /packages/news/www/news.tcl
+# Display one news revision.
+
+set publish_body [ad_html_text_convert -from $publish_format -to text/html -- $publish_body]
Index: openacs-4/packages/news/www/preview.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/preview.adp,v
diff -u -N -r1.13 -r1.14
--- openacs-4/packages/news/www/preview.adp 10 Oct 2009 22:38:10 -0000 1.13
+++ openacs-4/packages/news/www/preview.adp 22 Dec 2009 22:24:02 -0000 1.14
@@ -25,11 +25,12 @@
-
+
-
\ No newline at end of file
+
Index: openacs-4/packages/news/www/preview.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/preview.tcl,v
diff -u -N -r1.20 -r1.21
--- openacs-4/packages/news/www/preview.tcl 28 Apr 2009 09:20:20 -0000 1.20
+++ openacs-4/packages/news/www/preview.tcl 22 Dec 2009 22:24:02 -0000 1.21
@@ -11,9 +11,9 @@
action:notnull,trim
publish_title:notnull,trim
{publish_lead {}}
- {publish_body:allhtml,trim ""}
+ {publish_body:html,trim ""}
+ publish_body.format:notnull
{revision_log: ""}
- html_p:notnull,trim
text_file:optional
text_file.tmpfile:optional,tmpfile
{publish_date:array ""}
@@ -31,16 +31,6 @@
} -validate {
- content_html -requires {publish_body html_p} {
- if { [string equal $html_p "t"] } {
- set complaint [ad_html_security_check $publish_body]
- if { ![empty_string_p $complaint] } {
- ad_complain $complaint
- return
- }
- }
- }
-
check_revision_log -requires {action revision_log} {
if { ![string match $action "News Item"] && [empty_string_p $revision_log]} {
ad_complain "[_ news.lt_You_must_supply_a_rev]"
@@ -77,6 +67,7 @@
publish_title:onevalue
publish_lead:onevalue
publish_body:onevalue
+ publish_format:onevalue
publish_location:onevalue
hidden_vars:onevalue
permanent_p:onevalue
@@ -95,38 +86,16 @@
set news_admin_p [ad_permission_p $package_id news_admin]
+# Template parser treats publish_body.format as an array reference
+set publish_format ${publish_body.format}
+
if { [string match $action "News Item"] } {
set title "[_ news.Preview_news_item]"
} else {
set title "[_ news.Preview] $action"
}
set context [list $title]
-if {[info exists imgfile]} {
- unset imgfile
-}
-
-# create a new revision of the image if we've come back from the image-choose
-# page and we are revising
-if {[exists_and_not_null item_id] && [info exists imgfile]} {
-
- # check user has admin privileges (we can only get here from
- # admin/revision-add, so all legit users will have admin on package)
- permission::require_permission \
- -object_id [ad_conn package_id] -privilege news_admin
-
- if {[db_0or1row img_item_id {}]} {
- # add a revision to the existing image item
- ImageMagick::util::revise_image -file $imgfile -item_id $img_item_id
- } else {
- # create a new image item
- ImageMagick::util::create_image_item -file $imgfile -parent_id $item_id
- }
- # delete the tmpfile
- ImageMagick::delete_tmp_file $imgfile
-}
-
-
# set up image path
if {[exists_and_not_null item_id]} {
set image_id [news_get_image_id $item_id]
@@ -192,24 +161,27 @@
set publish_body [read $fd]
close $fd
}
+}
+if { ${publish_body.format} eq "text/html" || ${publish_body.format} eq "text/enhanced" } {
+
# close any open HTML tags in any case
set publish_body [util_close_html_tags $publish_body]
set errors [ad_html_security_check $publish_body]
- ns_log Notice "errors: $errors"
if { ![empty_string_p $errors] } {
ad_return_complaint 1 $errors
+ ad_script_abort
}
}
if { [string match $action "News Item"] } {
# form variables for confirmation step
- set hidden_vars [export_form_vars publish_title publish_lead publish_body \
+ set hidden_vars [export_form_vars publish_title publish_lead publish_body publish_body.format \
publish_date_ansi archive_date_ansi html_p permanent_p imgfile]
- set image_vars [export_form_vars publish_title publish_lead publish_body \
+ set image_vars [export_form_vars publish_title publish_lead publish_body publish_body.format \
publish_date_ansi archive_date_ansi html_p \
permanent_p action]
set form_action "