Index: openacs-4/packages/xowiki/www/portlets/most-popular.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/portlets/Attic/most-popular.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/xowiki/www/portlets/most-popular.tcl 30 Apr 2006 23:53:35 -0000 1.2 +++ openacs-4/packages/xowiki/www/portlets/most-popular.tcl 3 May 2006 12:03:23 -0000 1.3 @@ -7,33 +7,38 @@ ::xowiki::Page requireCSS "/resources/acs-templating/lists.css" -# get the folder id from the including page -set folder_id [$__including_page set parent_id] +::xowiki::Page proc __render_html { + -folder_id + -max_entries +} { + set package_id [$folder_id set package_id] -if {![info exists max_entries]} {set max_entries 20} -if {![info exists package_id]} {set package_id [$folder_id set package_id]} + TableWidget t1 -volatile \ + -columns { + AnchorField title -label [_ xowiki.page_title] + Field count -label Count -html { align right } + } -TableWidget t1 -volatile \ - -columns { - AnchorField title -label [_ xowiki.page_title] - Field count -label Count -html { align right } - } - -set content "" -db_foreach get_pages \ - "select sum(x.count), x.page_id, p.page_title,r.title \ + db_foreach get_pages \ + "select sum(x.count), x.page_id, r.title,i.name \ from xowiki_last_visited x, xowiki_page p, cr_items i, cr_revisions r \ where x.page_id = i.item_id and i.live_revision = p.page_id and r.revision_id = p.page_id \ - and x.package_id = $package_id group by x.page_id, p.page_title, r.title \ - order by sum desc limit $max_entries \ - " { - if {$page_title eq ""} {set page_title $title} + and x.package_id = $package_id group by x.page_id, r.title, i.name \ + order by sum desc limit $max_entries " \ + { + if {$title eq ""} {set title $name} + + t1 add \ + -title $title \ + -title.href [::xowiki::Page pretty_link $name] \ + -count $sum + } + return [t1 asHTML] +} - t1 add \ - -title $page_title \ - -title.href [::xowiki::Page pretty_link $title] \ - -count $sum - } - -set content [t1 asHTML] +set content [::xowiki::Page __render_html \ + -folder_id [$__including_page set parent_id] \ + -max_entries [expr {[info exists max_entries] ? $max_entries : 10}] \ + ] +if {![info exists name]} {set name "Most Popular Pages"} set link ""