xowiki::Package instproc get_parameter (public)
<instance of xowiki::Package> get_parameter \ [ -check_query_parameter check_query_parameter ] [ -nocache ] \ [ -type type ] attribute [ default ]
Defined in /var/www/openacs.org/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 (optional, defaults to
"true"
)- -nocache (optional)
- -type (optional)
- Parameters:
- attribute (required)
- default (optional)
- 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 $valueXQL Not present: Generic, PostgreSQL, Oracle