Index: openacs-4/packages/news/catalog/news.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/catalog/news.en_US.ISO-8859-1.xml,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/news/catalog/news.en_US.ISO-8859-1.xml 17 Sep 2003 12:21:47 -0000 1.9
+++ openacs-4/packages/news/catalog/news.en_US.ISO-8859-1.xml 3 Oct 2003 15:45:38 -0000 1.10
@@ -15,6 +15,7 @@
Archive Date
Archive Now
Archived
+ archived in
Author
Back to news list
Body
@@ -29,8 +30,11 @@
Creation IP
Database Error
Delete
+ days
Error
Go
+ Going live in %n_days_until_publish% days, not scheduled for archive
+ Going live in %n_days_until_publish% days, scheduled for archive in %n_days_until_archive% days
HTML
It will go live on
It will move into the archive on
@@ -92,6 +96,8 @@
Preview news item
Publication Date
Published
+ Published, not scheduled for archive
+ Published, archived in %n_days_until_archive% days
Release
Release Date
rev.
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 -r1.10 -r1.11
--- openacs-4/packages/news/tcl/news-procs.tcl 30 Sep 2003 12:10:08 -0000 1.10
+++ openacs-4/packages/news/tcl/news-procs.tcl 3 Oct 2003 15:45:38 -0000 1.11
@@ -122,8 +122,69 @@
return $url
}
+ad_proc news_pretty_status_key {
+ {-publish_date:required}
+ {-archive_date:required}
+} {
+ Given the the publish and archive date of a news item, return
+ a human readable and localized string explaining the publish and archive status
+ of the item. For example, "Published, scheduled to be archived in 5 days"
+ @param publish_date The publish date on ANSI format
+ @param archive_date The archive date on ANSI format
+ @return The message key (package_key.message_key) for the text.
+ @author Peter Marklund
+} {
+ set now_seconds [clock scan now]
+ if { ![empty_string_p $archive_date] } {
+ set archive_date_seconds [clock scan $archive_date]
+ if { $archive_date_seconds > $now_seconds } {
+ # Scheduled for archive
+ set n_days_until_archive [expr ($archive_date_seconds - $now_seconds) / 86400]
+ }
+ }
+ if { ![empty_string_p $publish_date] } {
+ # The item has been published or is scheduled to be published
+
+ set publish_date_seconds [clock scan $publish_date]
+ if { $publish_date_seconds > $now_seconds } {
+ # Will be published in the future
+
+ set n_days_until_publish [expr ($publish_date_seconds - $now_seconds) / 86400]
+
+ if { [empty_string_p $archive_date] } {
+ # Not scheduled for archive
+ # Message with vars n_days_until_publish
+ set status_key news.going_live_no_archive
+ } else {
+ # Scheduled for archive
+ # Message with vars n_days_until_publish, n_days_until_archive
+ set status_key news.going_live_with_archive
+ }
+ } else {
+ # Has already been published
+
+ if { [empty_string_p $archive_date] } {
+ # Not scheduled for archive
+ set status_key news.published_no_archive
+ } elseif { $archive_date_seconds > $now_seconds } {
+ # Scheduled for archive
+ # Message with vars n_days_until_archive
+ set status_key news.published_scheduled_for_archive
+ } else {
+ # Already archived
+ set status_key news.Archived
+ }
+ }
+
+ } else {
+ # Item has no publish date - it's unapproved
+ set status_key news.Unapproved
+ }
+
+ return $status_key
+}
Index: openacs-4/packages/news/tcl/test/news-test-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/tcl/test/news-test-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/tcl/test/news-test-procs.tcl 3 Oct 2003 15:45:39 -0000 1.1
@@ -0,0 +1,70 @@
+ad_library {
+ Test cases for the Tcl API of the news package. The test cases are based
+ on the acs-automated-testing package
+
+ @author Peter Marklund
+ @creation-date 2nd October 2003
+ @cvs-id $Id: news-test-procs.tcl,v 1.1 2003/10/03 15:45:39 peterm Exp $
+}
+
+namespace eval news {}
+namespace eval news::test {}
+
+aa_register_case news_pretty_status_key {
+ Test the news_pretty_status_key proc.
+
+ @author Peter Marklund
+} {
+ set now_seconds [clock scan now]
+ set offset [expr 60*60*24*10]
+ set date_format "%Y-%m-%d"
+ set future_seconds [expr $now_seconds + $offset]
+ set future_date [clock format $future_seconds -format $date_format]
+ set past_seconds [expr $now_seconds - $offset]
+ set past_date [clock format $past_seconds -format $date_format]
+
+ # Scheduled for publish, no archive
+ news::test::assert_status_pretty \
+ -publish_date $future_date \
+ -archive_date "" \
+ -expect_key news.going_live_no_archive
+
+ # Scheduled for publish and archive
+ news::test::assert_status_pretty \
+ -publish_date $future_date \
+ -archive_date $future_date \
+ -expect_key news.going_live_with_archive
+
+ # Published, no archive
+ news::test::assert_status_pretty \
+ -publish_date $past_date \
+ -archive_date "" \
+ -expect_key news.published_no_archive
+
+ # Published scheduled archived
+ news::test::assert_status_pretty \
+ -publish_date $past_date \
+ -archive_date $future_date \
+ -expect_key news.published_scheduled_for_archive
+
+ # Published and archived
+ news::test::assert_status_pretty \
+ -publish_date $past_date \
+ -archive_date $past_date \
+ -expect_key news.Archived
+
+ # Not scheduled for publish
+ news::test::assert_status_pretty \
+ -publish_date "" \
+ -archive_date "" \
+ -expect_key news.Unapproved
+}
+
+ad_proc -private news::test::assert_status_pretty {
+ {-publish_date:required}
+ {-archive_date:required}
+ {-expect_key:required}
+} {
+ aa_equals "publish_date \"$publish_date\" archive_date \"$archive_date\"" \
+ [news_pretty_status_key -publish_date $publish_date -archive_date $archive_date] $expect_key
+}