Index: openacs-4/packages/xowiki/tcl/weblog-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/weblog-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/xowiki/tcl/weblog-procs.tcl 15 May 2007 10:49:37 -0000 1.9 +++ openacs-4/packages/xowiki/tcl/weblog-procs.tcl 18 May 2007 09:07:44 -0000 1.10 @@ -5,13 +5,16 @@ Class create ::xowiki::Weblog -parameter { package_id - page_size - page_number + {page_size 20} + {page_number ""} date tag ptag category_id + instances_of filter_msg + {sort_composite ""} + {no_footer false} {name_filter ""} {entry_label "Postings"} {exclude_item_ids 0} @@ -22,7 +25,7 @@ ::xowiki::Weblog instproc init {} { my instvar filter_msg package_id nr_items next_page_link prev_page_link my instvar date category_id tag ptag page_number page_size summary items - my instvar name_filter entry_label + my instvar name_filter entry_label instances_of sort_composite my log "--W starting" set folder_id [::$package_id set folder_id] @@ -69,38 +72,55 @@ if {$name_filter ne ""} { append extra_where_clause "and ci.name ~ E'$name_filter' " } - - # create an item container, which delegates rendering to its chidlren + set base_type ::xowiki::Page + set base_table xowiki_pagei + set attributes [list cr.revision_id p.publish_date p.title p.creator p.creation_user \ + p.description s.body] + if {$instances_of ne ""} { + set form_items [list] + foreach t [split $instances_of |] { + set form_item_id [::xowiki::Form lookup -name $t -parent_id $folder_id] + if {$form_item_id == 0} {error "Cannot lookup page $t"} + lappend form_items $form_item_id + } + append extra_where_clause " and p.page_template in ('[join $form_items ',']') and p.page_instance_id = cr.revision_id " + set base_type ::xowiki::FormInstance + set base_table xowiki_form_instancei + lappend attributes instance_attributes + } + + # create an item container, which delegates rendering to its children set items [::xo::OrderedComposite new -proc render {} { set content "" - foreach c [my children] { - $c mixin add [my set entry_renderer] - append content [$c render] - } + foreach c [my children] { append content [$c render] } return $content }] + foreach i [split [my exclude_item_ids] ,] {lappend ::xowiki_page_item_id_rendered $i} $items set weblog_obj [self] set sql \ [list -folder_id $folder_id \ - -select_attributes [list p.publish_date p.title p.creator p.creation_user \ - p.description s.body] \ + -select_attributes $attributes \ -orderby "p.publish_date desc" \ - -page_number $page_number -page_size $page_size \ - -extra_from_clause $extra_from_clause \ - -extra_where_clause "and ci.item_id not in ([my exclude_item_ids]) \ + -from_clause "$extra_from_clause , $base_table p left outer join syndication s on s.object_id = p.revision_id" \ + -where_clause "ci.item_id not in ([my exclude_item_ids]) \ and ci.name != '::$folder_id' and ci.name not like '%weblog%' $date_clause \ [::xowiki::Page container_already_rendered ci.item_id] \ and ci.content_type not in ('::xowiki::PageTemplate','::xowiki::Object') \ and ci.publish_status <> 'production' \ $extra_where_clause" ] + + if {$page_number ne ""} { + lappend sql -page_number $page_number -page_size $page_size + } - set nr_items [db_string count [eval ::xowiki::Page select_query $sql -count true]] + set nr_items [db_string count [eval $base_type instance_select_query $sql -count true]] - set s [::xowiki::Page instantiate_objects -sql [eval ::xowiki::Page select_query $sql]] + set s [$base_type instantiate_objects -sql [eval $base_type instance_select_query $sql]] + foreach c [$s children] { - $c instvar page_id publish_date title name item_id creator creation_user description body + $c instvar revision_id publish_date title name item_id creator creation_user description body regexp {^([^.]+)[.][0-9]+(.*)$} $publish_date _ publish_date tz set pretty_date [util::age_pretty -timestamp_ansi $publish_date \ @@ -116,47 +136,56 @@ "[string range $body 0 150]..." : $description}] } else { # do full instantiation and rendering - # ns_log notice "--Render object=$p, $page_id $name $title" - set p [::Generic::CrItem instantiate -item_id 0 -revision_id $page_id] + # ns_log notice "--Render object=$p, $revision_id $name $title" + set p [::Generic::CrItem instantiate -item_id 0 -revision_id $revision_id] + if {[my no_footer]} {$p set __no_footer 1} if {[catch {$p set description [$p render]} errorMsg]} { - set description "Render Error ($errorMsg) $page_id $name $title" + set description "Render Error ($errorMsg) $revision_id $name $title" } } $p set pretty_date $pretty_date $p set publish_date $publish_date my log "--W setting $p set publish_date $publish_date" #$p proc destroy {} {my log "--Render temporal object destroyed"; next} - #ns_log notice "--W Render object $p DONE $page_id $name $title " - + #ns_log notice "--W Render object $p DONE $revision_id $name $title " + $p mixin add [my set entry_renderer] $items add $p } array set smsg {1 full 0 summary} set flink "$smsg($summary)" - set nr [llength [$items children]] - set from [expr {($page_number-1)*$page_size+1}] - set to [expr {($page_number-1)*$page_size+$nr}] - set range [expr {$nr > 1 ? "$from - $to" : $from}] - - if {$filter_msg ne ""} { - append filter_msg ", $range of $nr_items $entry_label (all, $flink)" - } else { - append filter_msg "Showing $range of $nr_items $entry_label ($flink)" - } - - set next_p [expr {$nr_items > $page_number*$page_size}] - set prev_p [expr {$page_number > 1}] + if {$page_number ne ""} { + set nr [llength [$items children]] + set from [expr {($page_number-1)*$page_size+1}] + set to [expr {($page_number-1)*$page_size+$nr}] + set range [expr {$nr > 1 ? "$from - $to" : $from}] + + if {$filter_msg ne ""} { + append filter_msg ", $range of $nr_items $entry_label (all, $flink)" + } else { + append filter_msg "Showing $range of $nr_items $entry_label ($flink)" + } + + set next_p [expr {$nr_items > $page_number*$page_size}] + set prev_p [expr {$page_number > 1}] - if {$next_p} { - set query [::xo::update_query_variable [ns_conn query] page_number [expr {$page_number+1}]] - set next_page_link [export_vars -base [::xo::cc url] $query] + if {$next_p} { + set query [::xo::update_query_variable [ns_conn query] page_number [expr {$page_number+1}]] + set next_page_link [export_vars -base [::xo::cc url] $query] + } + if {$prev_p} { + set query [::xo::update_query_variable [ns_conn query] page_number [expr {$page_number-1}]] + set prev_page_link [export_vars -base [::xo::cc url] $query] + } } - if {$prev_p} { - set query [::xo::update_query_variable [ns_conn query] page_number [expr {$page_number-1}]] - set prev_page_link [export_vars -base [::xo::cc url] $query] - } my proc destroy {} {my log "--W"; next} + + if {$sort_composite ne ""} { + foreach {kind att direction} [split $sort_composite ,] break + if {$kind eq "method"} {$items mixin add ::xo::OrderedComposite::MethodCompare} + $items orderby -order [expr {$direction eq "asc" ? "increasing" : "decreasing"}] $att + } my log "--W done" } Index: openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 9 May 2007 13:15:13 -0000 1.14 +++ openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 18 May 2007 09:07:44 -0000 1.15 @@ -330,4 +330,11 @@ return $result } + proc form_upgrade {} { + db_dml from_upgrade { + update xowiki_form f set form = xowiki_formi.data from xowiki_formi + where f.xowiki_form_id = xowiki_formi.revision_id + } + } + } \ No newline at end of file Index: openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/Attic/xowiki-portlet-procs.tcl,v diff -u -r1.54 -r1.55 --- openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 15 May 2007 10:49:37 -0000 1.54 +++ openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 18 May 2007 09:07:44 -0000 1.55 @@ -1875,7 +1875,7 @@ " } - + ############################################################################# Class create form-instance-menu \ -superclass ::xowiki::Portlet \ -parameter { @@ -1889,7 +1889,7 @@ my instvar __including_page set form [$__including_page page_template] set base [$package_id pretty_link [$form name]] - return "
\n" + return " \n" } ############################################################################# @@ -1898,7 +1898,8 @@ -parameter { {__decoration none} {parameter_declaration { - {-form_item_id:integer,required} + {-form_item_id:integer} + {-form} {-orderby "last_modified,desc"} }} } @@ -1907,6 +1908,11 @@ my get_parameters my instvar __including_page + if {![info exists form_item_id]} { + set form_item_id [::xowiki::Form lookup -name $form -parent_id $folder_id] + if {$form_item_id == 0} {error "Cannot lookup page $form"} + } + ::xowiki::Page requireCSS "/resources/acs-templating/lists.css" TableWidget t1 -volatile \ Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.99 -r1.100 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 15 May 2007 10:49:37 -0000 1.99 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 18 May 2007 09:07:44 -0000 1.100 @@ -76,18 +76,20 @@ -mime_type text/xotcl \ -form ::xowiki::ObjectForm - ::Generic::CrClass create Form -superclass Page \ + ::Generic::CrClass create Form -superclass PageTemplate \ -pretty_name "XoWiki Form" -pretty_plural "XoWiki Forms" \ -table_name "xowiki_form" -id_column "xowiki_form_id" \ -cr_attributes { + ::Generic::Attribute new -attribute_name form -datatype text \ + -pretty_name "Form" ::Generic::Attribute new -attribute_name form_constraints -datatype text \ -pretty_name "Form Constraints" } \ -form ::xowiki::FormForm ::Generic::CrClass create FormInstance -superclass PageInstance \ -pretty_name "XoWiki FormInstance" -pretty_plural "XoWiki FormInstances" \ -table_name "xowiki_form_instance" -id_column "xowiki_form_instance_id" \ - -form ::xowiki::WikiForm + -form ::xowiki::PageInstanceEditForm # # create various extra tables, indices and views @@ -650,7 +652,7 @@ Page instproc get_content {} { #my log "--" - set content [my substitute_markup [my set text]] + return [my substitute_markup [my set text]] } Page instproc set_content {text} { my text [list [string map [list >> "\nThis form in an instance of [$page_template name]
" - return "$intro[$root asHTML]" + set text [lindex [my get_from_template text] 0] + if {$text ne ""} { + # we have a template + return [next] + } else { + set form [lindex [my get_from_template form] 0] + dom parse -simple -html $form doc + $doc documentElement root + my provide_values + return [$root asHTML] + } } - #FormInstance instproc render {} { - # my instvar doc root package_id - # set form [lindex [my get_text_from_template] 0] - # dom parse -simple -html $form doc - # $doc documentElement root - # my provide_values - # return [$root asHTML] - #} FormInstance instproc edit {} { my instvar page_template doc root package_id - set form [lindex [my get_text_from_template] 0] - dom parse -simple -html $form doc - $doc documentElement root - - $root appendFromList [list input [list type submit] {}] - set form [lindex [$root selectNodes //form] 0] + set form [lindex [my get_from_template form] 0] if {$form eq ""} { - my msg "no form found in page [$page_template name]" + next } else { - $form setAttribute action [$package_id pretty_link [my name]]?m=save method POST + dom parse -simple -html $form doc + $doc documentElement root + + $root appendFromList [list input [list type submit] {}] + set form [lindex [$root selectNodes //form] 0] + if {$form eq ""} { + my msg "no form found in page [$page_template name]" + } else { + $form setAttribute action [$package_id pretty_link [my name]]?m=save method POST + } + my provide_values + set result [$root asHTML] + my view $result } - my provide_values - set result [$root asHTML] - my view $result } FormInstance instproc save {} { my instvar package_id Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.49 -r1.50 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 9 May 2007 13:19:23 -0000 1.49 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 18 May 2007 09:07:44 -0000 1.50 @@ -243,8 +243,8 @@ } # the following line is like [$package_id url], but works as well with renamed objects - set myurl [expr {$new ? [$package_id url] : - [$package_id pretty_link [my form_parameter name]]}] + #set myurl [expr {$new ? [$package_id url] : + # [$package_id pretty_link [my form_parameter name]]}] set myurl [$package_id pretty_link [my form_parameter name]] @@ -262,6 +262,7 @@ variable ::template::parse_level lappend parse_level [info level] set action_vars [expr {$new ? "{edit-new 1} object_type return_url" : "{m edit} return_url"}] + my log "--formclass=[$object_type getFormClass -data [self]] ot=$object_type" [$object_type getFormClass -data [self]] create ::xowiki::f1 -volatile \ -action [export_vars -base [$package_id url] $action_vars] \ -data [self] \ Index: openacs-4/packages/xowiki/www/prototypes/bib.page =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/prototypes/bib.page,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/xowiki/www/prototypes/bib.page 18 May 2007 09:07:44 -0000 1.1 @@ -0,0 +1,99 @@ +# -*- tcl -*- +# $Id: bib.page,v 1.1 2007/05/18 09:07:44 gustafn Exp $ +::xowiki::Object new -title "Bibliography Includelet" -text { + # + # A bibliography interface based on weblog. + # Bibliography entries are typically selected via + # instances_of (PageInstances, FormInstances). + # + # Gustaf Neumann fecit, May 2007 + # + my initialize -parameter { + {-summary:boolean 0} + {-date ""} + {-category_id ""} + {-tag ""} + {-ptag ""} + {-instances_of ""} + } + + # + # The following definition is the default rendering per + # weblog entry. This is executed in the context of every displayed page. + # + Class create EntryRenderer + EntryRenderer instproc render {} { + append content "