Index: openacs-4/packages/news/lib/latest-news-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/lib/latest-news-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/lib/latest-news-oracle.xql 27 Jan 2005 15:13:35 -0000 1.1
@@ -0,0 +1,33 @@
+
+
+oracle
+
+
+
+SELECT r.*
+FROM
+(SELECT
+ item_id,
+ publish_title AS title,
+ '' AS lead,
+ publish_date
+ FROM
+ news_items_approved
+ WHERE
+ package_id = :package_id
+ $max_age_filter
+ AND (archive_date IS NULL OR archive_date > sysdate)
+ ORDER BY
+ publish_date DESC, item_id DESC
+) r
+WHERE rownum <= $n
+
+
+
+
+
+ AND sysdate - to_timestamp(publish_date,'YYYY-MM-DD') < interval '$max_age' day
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/news/lib/latest-news-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/lib/latest-news-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/lib/latest-news-postgresql.xql 27 Jan 2005 15:13:35 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+postgresql7.3
+
+
+SELECT
+ item_id,
+ publish_title AS title,
+ '' AS lead,
+ publish_date
+FROM
+ news_items_approved
+WHERE
+ package_id = :package_id $max_age_filter
+ AND (archive_date IS NULL OR archive_date > now())
+ORDER BY
+ publish_date DESC, item_id DESC
+LIMIT $n
+
+
+
+ AND age(publish_date) < interval :max_age_pg
+
+
+
Index: openacs-4/packages/news/lib/latest-news.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/lib/latest-news.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/lib/latest-news.adp 27 Jan 2005 15:13:35 -0000 1.1
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ No recent news
+
+
+
+
+
+
+
+
+
+ @news.lead@
@news.date@
+
+ More news...
+
+
Index: openacs-4/packages/news/lib/latest-news.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/lib/latest-news.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/news/lib/latest-news.tcl 27 Jan 2005 15:13:35 -0000 1.1
@@ -0,0 +1,68 @@
+# include fragment to show latest news stories
+#
+# parameters:
+# package_id - ID of the news instance to use as a source
+# base_url - base URL of the news instance to use as a source
+# n - The number of stories to show, default 2
+# max_age - The limit on the recency of news items, in days, default no limit
+# id - CSS id
+# class - CSS class
+# show_empty_p - show element even if empty, default 1
+# cache - cache period, default 0 for no caching
+#
+# @author Tom Ayles (tom@beatniq.net)
+# @creation-date 2003-12-17
+# @cvs-id $Id: latest-news.tcl,v 1.1 2005/01/27 15:13:35 jeffd Exp $
+#
+
+# parameter processing... n is interpolated into the query (as bind variables
+# are not supported in PGSQL LIMIT construct), so we have to check its validity
+if { [info exists n] } {
+ if { ![string is integer $n] } { error {n must be an integer} }
+} else {
+ set n 2
+}
+if { ![info exists cache] } { set cache 0 }
+if { [info exists max_age] } {
+ set max_age_filter [db_map max_age_filter]
+} else {
+ set max_age {}
+ set max_age_filter {}
+}
+foreach param {id class} { if { ![info exists $param] } { set $param {} } }
+if { ![info exists show_empty_p] } { set show_empty_p 1 }
+
+if { ![exists_and_not_null package_id]
+ && ![exists_and_not_null base_url] } {
+ error "must supply package_id and/or base_url"
+}
+
+if { ![exists_and_not_null package_id] } {
+ set package_id [site_node::get_element \
+ -url $base_url -element object_id]
+}
+if { ![exists_and_not_null base_url] } {
+ set base_url [lindex [site_node::get_url_from_object_id \
+ -object_id $package_id] 0]
+}
+
+
+set script "# /packages/news/lib/latest-news.tcl
+set max_age_filter {$max_age_filter}
+set n $n
+db_list_of_lists ls {} -bind { package_id $package_id max_age $max_age max_age_pg {$max_age days} }"
+
+multirow create news item_id title lead publish_date url date
+util_memoize_flush $script
+foreach row [util_memoize $script $cache] {
+ set item_id [lindex $row 0]
+ set title [lindex $row 1]
+ set lead [lindex $row 2]
+ set publish_date [lindex $row 3]
+ set url "${base_url}item?item_id=$item_id"
+ set date [lc_time_fmt $publish_date {%x}]
+
+ multirow append news $item_id $title $lead $publish_date $url $date
+}
+
+ad_return_template