xowiki::Package instproc get_parameter (public)

 <instance of xowiki::Package[i]> get_parameter \
    [ -check_query_parameter check_query_parameter ] [ -nocache ] \
    [ -type type ] attribute [ default ]

Defined in packages/xowiki/tcl/package-procs.tcl

Resolves configurable parameters according to the following precedence: (1) values specifically set per page {{set-parameter ...}} (2) query parameter (3) form fields from the parameter_page FormPage (4) standard OpenACS package parameter The specified attribute can be of the form "name:value_constraint"

Switches:
-check_query_parameter
(defaults to "true") (optional)
-nocache
(optional)
-type
(optional)
Parameters:
attribute
default (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) xowiki::Package instproc get_parameter xowiki::Package instproc get_parameter test_create_form_with_form_instance->xowiki::Package instproc get_parameter ad_return_complaint ad_return_complaint (public) xowiki::Package instproc get_parameter->ad_return_complaint xo::validate_parameter_constraints xo::validate_parameter_constraints (public) xowiki::Package instproc get_parameter->xo::validate_parameter_constraints

Testcases:
create_form_with_form_instance
Source code:
set attribute_name $attribute
set attribute_constraint ""
regexp {^([^:]+):(.*)$} $attribute . attribute_name attribute_constraint

if {$nocache} {
  set value ""
} else {
  #
  # Cached values, or values programmatically set
  #
  set value [::xo::cc get_parameter $attribute_name]
}

if {$check_query_parameter && $value eq ""} {
  #
  # Query parameter handle already the notation with
  # "name:valueconstraint"
  #
  set value [string trim [:query_parameter $attribute]]
}
if {$value eq "" && $attribute_name ne "parameter_page"} {
  #
  # Try to get the parameter from the parameter_page.  We have to
  # be very cautious here to avoid recursive calls (e.g. when
  # resolve_page_name needs as well parameters such as
  # use_connection_locale or subst_blank_in_name, etc.).
  #
  set value [:get_parameter_from_parameter_page  -parameter_page_name [:get_parameter parameter_page:graph ""]  $attribute_name]
}

if {$value eq ""} {
  set value [next $attribute_name $default]
}
if {$type ne ""} {
  #
  # To be extended and generalized.
  #
  switch -- $type {
    word {if {[regexp {\W} $value]} {
      ad_return_complaint 1 "value for parameter '$attribute' contains invalid character"}
    }
    noquote {if {[regexp {['\"]} $value]} {
      ad_return_complaint 1 "value for parameter '$attribute' contains invalid character"}
    }
    default {error "requested type unknown: $type"}
  }
}
if {$value ne "" && $attribute_constraint ne ""} {
  xo::validate_parameter_constraints $attribute_name $attribute_constraint $value
}
#:log "           $attribute returns '$value'"
return $value
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: