- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::Timeline
::xowiki::Timeline create ... \
[ -limit (default "1000") ] \
[ -user_id user_id ]
Class Relations
::xotcl::Class create ::xowiki::Timeline \ -superclass ::xowiki::XMLSyndicationMethods (to be applied on instances)
limit (setter)
render (scripted)
set folder_ids [::${:package_id} folder_id] set where_clause "" set limit "" set last_user "" set last_item "" set last_clock "" if {[info exists :user_id]} { append where_clause " and o.creation_user = [ns_dbquotevalue ${:user_id}] " } if {[info exists :limit]} { set limit [:limit] } ::xo::OrderedComposite items -destroy_on_cleanup set sql [::xo::dc select -vars "ci.name, ci.parent_id, o.creation_user, cr.publish_date, o2.creation_date, cr.item_id, cr.title" -from "cr_items ci, cr_revisions cr, acs_objects o, acs_objects o2" -where "cr.item_id = ci.item_id and o.object_id = cr.revision_id and o2.object_id = cr.item_id and ci.parent_id in ([ns_dbquotelist $folder_ids]) and o.creation_user is not null $where_clause" -orderby "revision_id desc" -limit $limit] ::xo::dc foreach timeline-get_pages $sql { set publish_date [::xo::db::tcl_date $publish_date tz] set creation_date [::xo::db::tcl_date $creation_date tz] set clock [clock scan $publish_date] if {$last_user == $creation_user && $last_item == $item_id && $last_clock ne ""} { #:log "--clockdiff = [expr {$last_clock - $clock }] $name [clock format $clock -format {%b %d %Y %X %Z} -gmt true]" if {($last_clock - $clock) < 7500 } { #:log "--clock ignore change due to cockdiff" continue } } set o [Object new] foreach att {item_id creation_user clock name publish_date parent_id title} { $o set $att [set $att] } $o set operation [expr {$creation_date eq $publish_date ? "created" : "modified"}] items add $o lassign [list $creation_user $item_id $clock] last_user last_item last_clock } # The following loop tries to distinguis between create and modify by age. # This does not work in cases, where we get just a limited amount # or restricted entries # if {$limit eq ""} { # foreach i [lreverse [items children]] { # set key seen([$i set item_id]) # if {[info exists $key]} { # $i set operation modified # } else { # $i set operation created # set $key 1 # } # } # } foreach i [items children] { set key contrib([clock format [$i set clock] -format "%Y-%m-%d" -gmt true],[$i set creation_user],[$i set item_id]) lappend $key $i } set result <data>\n foreach c [lsort -decreasing [array names contrib]] { if {[llength $contrib($c)] == 1} { set i $contrib($c) set title [$i set title] set user [::xo::get_user_name [$i set creation_user]] set event "$user [$i set operation] [$i set title] [$i set name]" } else { set i [lindex $contrib($c) 0] set event "Contributions by [::xo::get_user_name [$i set creation_user]] on [clock format [$i set clock] -format {%b %d %Y} -gmt true]\n<ul>" set title "[$i set title] ([llength $contrib($c)])" foreach j $contrib($c) { set stamp [clock format [$j set clock] -format "%X %Z" -gmt true] append event "<li>$stamp: [$j set operation]</li>" \n } append event "</ul>" \n } set stamp [clock format [$i set clock] -format "%b %d %Y %X %Z" -gmt true] set user [::xo::get_user_name [$i set creation_user]] append result [:tag -atts [list start $stamp title $title link [::${:package_id} pretty_link -parent_id [$i set parent_id] [$i set name]]] event $event] \n } append result </data>\n return $resultuser_id (setter)
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables