Class ::xowiki::includelet::random-form-page (public)
::xowiki::IncludeletClass ::xowiki::includelet::random-form-page
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl
Include random form page (instance of the specified form)
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::includelet {} ::nsf::object::alloc ::xowiki::IncludeletClass ::xowiki::includelet::random-form-page {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :aggregating false set :cacheable false set :localized true set :personalized true} ::xowiki::includelet::random-form-page proc page_names {package_id form publish_status} { # # This is a cacheable method returning a list of the names from # which the random page is selected. We use a class method and the # argument list with util_memoize inability to provide a key for # caching. # set form_item_ids [::$package_id instantiate_forms -forms $form] 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 -initialize false -publish_status $publish_status -package_id $package_id] set result [list] foreach item [$items children] { lappend result [$item name] } return $result } ::xowiki::includelet::random-form-page instproc render {} { :get_parameters set cmd [list ::xowiki::includelet::random-form-page page_names $package_id $form $publish_status] if {[ns_info name] eq "NaviServer"} { set names [::xowiki::cache -expires $expires -partition_key $package_id random-$package_id-$form $cmd] } else { set names [util_memoize $cmd] } set random_item [lindex $names [expr { int([llength $names] * rand()) }]] if {$random_item eq ""} { return "" } { return [${:__including_page} include [list $random_item -decoration none]] } } ::xowiki::includelet::random-form-page instparametercmd __decoration ::xowiki::includelet::random-form-page instparametercmd parameter_declaration ::nsf::relation::set ::xowiki::includelet::random-form-page superclass ::xowiki::Includelet ::nx::slotObj -container slot ::xowiki::includelet::random-form-page ::xowiki::includelet::random-form-page::slot eval {set :__parameter { {__decoration none} {parameter_declaration { {-form:required} {-publish_status "ready"} {-expires 600} }} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::random-form-page::slot::parameter_declaration {set :accessor public set :configurable true set :convert false set :default { {-form:required} {-publish_status "ready"} {-expires 600} } set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::random-form-page set :incremental 0 set :manager ::xowiki::includelet::random-form-page::slot::parameter_declaration set :methodname parameter_declaration set :multiplicity 1..1 set :name parameter_declaration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::random-form-page::slot::__decoration {set :accessor public set :configurable true set :convert false set :default none set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::random-form-page set :incremental 0 set :manager ::xowiki::includelet::random-form-page::slot::__decoration set :methodname __decoration set :multiplicity 1..1 set :name __decoration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init}XQL Not present: Generic, PostgreSQL, Oracle