Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -N -r1.123 -r1.124 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 10 Jul 2009 16:48:32 -0000 1.123 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 7 Sep 2009 23:50:03 -0000 1.124 @@ -3220,7 +3220,7 @@ switch $attr { orderby {set $attr _[::xowiki::formfield::FormField fc_decode $value]} publish_status - category_id - unless - - where - with_categories - csv - voting_form - + where - with_categories - with_form_link - csv - voting_form - voting_form_form - voting_form_anon_instances { set $attr $value #my msg " set $attr $value" @@ -3263,7 +3263,7 @@ # if {[info exists __ff(_creation_user)]} {$__ff(_creation_user) label "By User"} - # TODO: wiki-substituion is just hacked in here. maybe it makes + # TODO: wiki-substitution is just foced in here. Maybe it makes # more sense to use it as a default for _text, but we have to # check all the nested cases to avoid double-substitutions. if {[info exists __ff(_text)]} {$__ff(_text) set wiki 1} @@ -3700,4 +3700,38 @@ my get_parameters return "$email" } +} + +namespace eval ::xowiki::includelet { + ############################################################################# + # random-form-page + # + ::xowiki::IncludeletClass create random-form-page \ + -superclass ::xowiki::Includelet \ + -parameter { + {__decoration none} + {parameter_declaration { + {-form:required} + {-publish_status "ready"} + }} + } + + random-form-page instproc render {} { + my get_parameters + set form_item_ids [::xowiki::Weblog instantiate_forms -forms $form -package_id $package_id] + set form_fields [::xowiki::FormPage get_table_form_fields \ + -base_item [lindex $form_item_ids 0] -field_names _name \ + -form_constraints ""] + set items [::xowiki::FormPage get_form_entries \ + -base_item_ids $form_item_ids -form_fields $form_fields \ + -publish_status $publish_status \ + -package_id $package_id] + set random_element [expr { int([llength [$items children]] * rand()) }] + set random_item [lindex [$items children] $random_element] + if {$random_item eq ""} { + return "" + } { + return [[my set __including_page] include [list [$random_item name] -decoration none]] + } + } } \ No newline at end of file