Class ::xowiki::includelet::random-form-page

::xowiki::includelet::random-form-page[i] create ... \
           [ -__decoration (default "none") ] \
           [ -parameter_declaration (default " {-form:required} {-publish_status "ready"} {-expires 600} ") ]

Include random form page (instance of the specified form)
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl

Class Relations

  • class: ::xowiki::IncludeletClass[i]
  • superclass: ::xowiki::Includelet[i]
::xowiki::IncludeletClass create ::xowiki::includelet::random-form-page \
     -superclass ::xowiki::Includelet

Methods (to be applied on the object)

  • page_names (scripted)

    #
    # 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

Methods (to be applied on instances)

  • __decoration (setter)

  • parameter_declaration (setter)

  • render (scripted)

    :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]]
    }