Index: openacs-4/contrib/packages/cop-ui/lib/contributions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/lib/contributions.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/cop-ui/lib/contributions.tcl 7 May 2004 17:25:39 -0000 1.3 +++ openacs-4/contrib/packages/cop-ui/lib/contributions.tcl 14 May 2004 11:30:15 -0000 1.4 @@ -3,43 +3,68 @@ # If user_id set it will be limited by that user otherwise all users. # if limit set then only limit items will be displayed. # if root_node_id exists then only return things under root node. +set root_node_id [ad_conn node_id] if {![info exists user_id]} { set user_id {} } if {![info exists category]} { set category {} } +if {[info exists supress]} { + foreach key $supress { + set hide($key) 1 + } +} +if {[info exists limit] + && [regexp {^[0-9]+$} $limit]} { + set limit " limit $limit" +} else { + set limit {} +} + +if {![info exists format]} { + set format table +} + if {[info exists root_node_id]} { set packages [cop::util::packages -node_id $root_node_id] } else { set packages {} } +if {![info exists hide(stars)]} { + lappend elements stars { + label "Rating" + display_template "@content.stars;noquote@" + } +} -lappend elements rating_img { - label "Rating" - display_template "@content.rating_img;noquote@" +if {![info exists hide(ratings)]} { + lappend elements ratings { + label \# + display_template "@content.ratings;noquote@" + html {align right} + } } -lappend elements ratings { - label \# - display_template "@content.ratings;noquote@" - html {align right} -} -lappend elements views { - label "Views" - html {align right} +if {![info exists hide(views)]} { + lappend elements views { + label "Views" + html {align right} + } } lappend elements object_title { label {Title} display_template {@content.title@} } -lappend elements object_type { - label {Type} +if {![info exists hide(object_type)]} { + lappend elements object_type { + label {Type} + } } lappend elements last_modified { @@ -48,6 +73,12 @@ html {align right} } +lappend elements new { + label {New} + display_template "@content.new;noquote@" + html {align right} +} + if {[empty_string_p $user_id]} { lappend elements name { label {Created by} @@ -60,11 +91,26 @@ -multirow content \ -key object_id \ -elements $elements \ + -selected_format $format \ -filters { user_id {} } \ + -formats { + table { + label Table + layout table + } + list { + label List + layout list + template { +
\[\] - / - views
+ by ,
+ } + } + } \ -orderby { - rating_img { + stars { orderby_desc {coalesce(rating_ave,99) asc, o.last_modified desc} orderby_asc {coalesce(rating_ave,0) desc, o.last_modified desc} } @@ -109,7 +155,7 @@ } # TODO: need to get the dimension to display, need to find the right CoP -db_multirow -extend {rating_img url_one ratings_url user_url} content content " +db_multirow -extend {stars url_one ratings_url user_url new} content content " SELECT o.title, o.object_id, o.title, t.pretty_name as object_type, r.rating_ave, r.ratings, v.views, to_char(o.last_modified,'YYYY-MM-DD HH24:MI:SS') as last_modified, u.user_id, u.first_names || ' ' || u.last_name as name FROM acs_object_types t, acs_objects o left outer join cr_items i on (o.object_id = i.item_id) @@ -121,16 +167,26 @@ 'cal_item','bt_bug','bt_patch', 'faq', 'faq_q_and_a', 'bookshelf_book') and (o.object_type != 'content_item' or i.content_type in ('content_extlink','file_storage_object','pa_album','pa_photo','static_page')) $restrict - [template::list::orderby_clause -orderby -name "content"] limit 20" { + [template::list::orderby_clause -orderby -name "content"]$limit" { if {![empty_string_p $rating_ave]} { set ratings_url "/cop1/cop/ratings/ratings?object_id=$object_id" set rating [format %.1f [expr {(round(2.0*$rating_ave))/2.0}]] - set rating_img "\"$rating\"" + set stars "\"$rating\"" set ratings "$ratings" } else { - set rating_img {} + set stars {none} + set ratings "0" } + # XXXJCD - make this work in general. + if {($object_id % 3) == 0} { + set new {NEW} + } else { + set new {} + } + + # XXXJCD - make this work in general. regsub {/www/cop1/static} $title {} title + set last_modified [regsub -all { } [util::age_pretty -hours_limit 0 -mode_2_fmt "%X %a" -mode_3_fmt "%x" -timestamp_ansi $last_modified -sysdate_ansi $now] {\ }] set user_url [acs_community_member_url -user_id $user_id] if {[catch {set url_one [acs_sc_call -error FtsContentProvider url [list $object_id] $object_type]} errMsg]} {