b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.8) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: Request

Source Location: /blogs/inc/_misc/_request.class.php

Class Request

Property Summary
Array   $err_messages  
boolean   $link_log_messages_to_field_IDs   If true, the internal function _add_message_to_Log() will create links to IDs of the fields where the error occurred.
Log   $Messages  
Array   $params  

[ Top ]
Method Summary
Request   Request()   Constructor.
void   compile_cat_array()   Compiles the cat array from $cat (recursive + optional modifiers) and $catsel[] (non recursive)
NULL|mixed   get()   Get the value of a param.
void   memorize_param()   Memorize a parameter for automatic future use in regenerate_url()
mixed   param()   Sets a parameter with values from the request or to provided default, except if param is already set!
void   params()   Sets several similar parameters at once.
boolean   params_check_at_least_one()  
string   param_action()   Get the action from params.
string   param_arrayindex()   Get the param from an array param's first index.
boolean|string   param_check_date()   Check if param is an ISO date
boolean|array   param_check_date_format()   Check if param is a valid date (format wise).
boolean   param_check_email()  
boolean   param_check_not_empty()  
boolean   param_check_number()   Checks if the param is a decimal number (no float, e.g. 3.14).
boolean   param_check_passwords()  
boolean   param_check_phone()  
boolean   param_check_range()   Checks if the param is a decimal number (no float, e.g. 3.14) in a given range.
boolean   param_check_regexp()   Check if the value of a param is a regular expression (syntax).
boolean   param_check_url()  
void   param_child_select_value()   set a parameter with the second part(X2) of the value from request ( X1-X2 )
string   param_combo()   Sets a combo parameter with values from the request, => the value of the select option and the input text value if new is selected Display an error if the new value is selected that the input text has a value
string   param_compact_date()   Sets a date parameter with values from the request or to provided default, And check if param is a valid date (format wise).
void   param_date()   Sets a date parameter by converting locale date (if valid) to ISO date.
void   param_error()   Add an error for a variable, either to the Form's field and/or the global $Messages object.
void   param_error_multiple()   Add an error for multiple variables, either to the Form's field and/or the global $Messages object.
void   param_extend()   Extend a parameter with an array of params.
boolean   param_integer_range()   Gets a param and makes sure it's a decimal number (no float, e.g. 3.14) in a given range.
boolean   param_isFilename()   Check if the value is a file name
boolean   param_string_not_empty()  
mixed   param_time()   Sets a time parameter with the value from the request of the var argument or of the concat of the var argument_h: var argument_mn: var argument_s , except if param is already set!
void   set_param()   Set the value of a param (by force! :P)
integer   validation_errors()   Check if there have been validation errors
void   _add_message_to_Log()   This function is used by param_error() and param_error_multiple().

[ Top ]
Properties
Array   $err_messages = array() [line 58]

[ Top ]
boolean   $link_log_messages_to_field_IDs = true [line 70]

If true, the internal function _add_message_to_Log() will create links to IDs of the fields where the error occurred.


[ Top ]
Log   $Messages [line 63]

[ Top ]
Array   $params = array() [line 53]

[ Top ]
Methods
Constructor Request  [line 76]

  Request Request( &$Messages  )

Constructor.

Parameters:
   &$Messages: 


[ Top ]
compile_cat_array  [line 987]

  void compile_cat_array( [ $restrict_to_blog = 0], [ $cat_default = NULL], [ $catsel_default = array()]  )

Compiles the cat array from $cat (recursive + optional modifiers) and $catsel[] (non recursive)

and keeps those values available for future reference

Parameters:
   $restrict_to_blog: 
   $cat_default: 
   $catsel_default: 


[ Top ]
get  [line 390]

  NULL|mixed get( $var  )

Get the value of a param.

Parameters:
   $var: 

API Tags:
Return:  The value of the param, if set. NULL otherwise.


[ Top ]
memorize_param  [line 142]

  void memorize_param( $var, $type, $default, [ $value = NULL]  )

Memorize a parameter for automatic future use in regenerate_url()

Parameters:
   $var: 
   $type: 
   $default: 
   $value: 


[ Top ]
param  [line 108]

  mixed param( string $var, [string $type = ''], [mixed $default = ''], [boolean $memorize = false], [boolean $override = false], [boolean $use_default = true], [mixed $strict_typing = 'allow_empty']  )

Sets a parameter with values from the request or to provided default, except if param is already set!

Also removes magic quotes if they are set automatically by PHP. Also forces type. Priority order: POST, GET, COOKIE, DEFAULT.

Parameters:
string   $var:  Variable to set
string   $type:  Force value type to one of:
  • integer
  • float, double
  • string (strips (HTML-)Tags, trims whitespace)
  • array (TODO: array/integer , array/array/string )
  • html (does nothing)
  • '' (does nothing)
  • '/^...$/' check regexp pattern match (string)
  • boolean (will force type to boolean, but you can't use 'true' as a default since it has special meaning. There is no real reason to pass booleans on a URL though. Passing 0 and 1 as integers seems to be best practice).
Value type will be forced only if resulting value (probably from default then) is !== NULL
mixed   $default:  Default value or TRUE if user input required
boolean   $memorize:  Do we need to memorize this to regenerate the URL for this page?
boolean   $override:  Override if variable already set
boolean   $use_default:  Force setting of variable to default if no param is sent and var wasn't set before
mixed   $strict_typing:  true will refuse illegal values, false will try to convert illegal to legal values, 'allow_empty' will refuse illegale values but will always accept empty values (This helps blocking dirty spambots or borked index bots. Saves a lot of processor time by killing invalid requests)

API Tags:
Return:  Final value of Variable, or false if we don't force setting and did not set


[ Top ]
params  [line 120]

  void params( array $vars, [ $type = ''], [ $default = ''], [ $memorize = false], [ $override = false], [ $forceset = true]  )

Sets several similar parameters at once.

Parameters:
array   $vars: 
   $type: 
   $default: 
   $memorize: 
   $override: 
   $forceset: 


[ Top ]
params_check_at_least_one  [line 823]

  boolean params_check_at_least_one( array $vars, string $err_msg, [string|NULL $field_err_msg = NULL]  )

Parameters:
array   $vars:  of param names
string   $err_msg:  error message
string|NULL   $field_err_msg:  error message for form field ($err_msg gets used if === NULL).

API Tags:
Return:  true if OK


[ Top ]
param_action  [line 337]

  string param_action( [mixed $default = ''], [ $memorize = false]  )

Get the action from params.

If we got no "action" param, we'll check for an "actionArray" param ( <input type="submit" name="actionArray[real_action]" ...> ). And the real $action will be found in the first key... When there are multiple submit buttons, this is smarter than checking the value which is a translated string. When there is an image button, this allows to work around IE not sending the value (it only sends X & Y coords of the click).

Parameters:
mixed   $default:  Default to use.
   $memorize: 


[ Top ]
param_arrayindex  [line 364]

  string param_arrayindex( string $param_name, [mixed $default = '']  )

Get the param from an array param's first index.

E.g., for "param[value]" as a submit button you can get the value with

.

Parameters:
string   $param_name:  Param name
mixed   $default:  Default to use

API Tags:
See:  Request::param_action()


[ Top ]
param_check_date  [line 562]

  boolean|string param_check_date( string $var, string $err_msg, [boolean $required = false], [string $date_format = NULL]  )

Check if param is an ISO date

Parameters:
string   $var:  param name
string   $err_msg:  error message
boolean   $required:  Is a non-empty date required?
string   $date_format:  date format (php format)

API Tags:
Return:  false if not OK, ISO date if OK


[ Top ]
param_check_date_format  [line 662]

  boolean|array param_check_date_format( string $var, string $err_msg, [array|boolean $func_params = array()]  )

Check if param is a valid date (format wise).

Parameters:
string   $var:  param name
string   $err_msg:  error message
array|boolean   $func_params:  Additional params:
  • 'required': Is non-empty date required? Default: true.
  • 'date_pattern': Pattern for the date, using named capturing groups ('day', 'month', 'year'). Default: '#^(\d\d\d\d)-?(\d\d)-?(\d\d)$#' (accepts both ISO and "compact") You can also use "Named Capturing Groups" and write it like this: '#^(?P<year>\d\d\d\d)-(?P<month>\d\d)-(?P<day>\d\d)$#' (ISO). This allows to use for example '#^(?P<day>\d\d)-(?P<month>\d\d)-(?P<year>\d\d\d\d)$#' NOTE: "Named Capturing Groups" require PHP 4.3.3! If no named groups are given we'll use (1 == year, 2 == month, 3 == day).
  • 'field_err_msg': Error for the form field

API Tags:
Return:  true if empty, but OK. False if not valid. Matching array if ok.
Deprecated:  won't handle locale date formats on PHP < 4.3.3


[ Top ]
param_check_email  [line 494]

  boolean param_check_email( string $var, [ $required = false]  )

Parameters:
string   $var:  param name
   $required: 

API Tags:
Return:  true if OK


[ Top ]
param_check_not_empty  [line 415]

  boolean param_check_not_empty( string $var, string $err_msg, [string|NULL $field_err_msg = NULL]  )

Parameters:
string   $var:  param name
string   $err_msg:  error message
string|NULL   $field_err_msg:  error message for form field ($err_msg gets used if === NULL).

API Tags:
Return:  true if OK


[ Top ]
param_check_number  [line 433]

  boolean param_check_number( string $var, string $err_msg, [ $required = false]  )

Checks if the param is a decimal number (no float, e.g. 3.14).

Parameters:
string   $var:  param name
string   $err_msg:  error message
   $required: 

API Tags:
Return:  true if OK


[ Top ]
param_check_passwords  [line 777]

  boolean param_check_passwords( string $var1, string $var2, [boolean $required = false]  )

Parameters:
string   $var1:  param name
string   $var2:  param name
boolean   $required:  Is a password required? (non-empty)

API Tags:
Return:  true if OK


[ Top ]
param_check_phone  [line 514]

  boolean param_check_phone( string $var, [ $required = false]  )

Parameters:
string   $var:  param name
   $required: 

API Tags:
Return:  true if OK


[ Top ]
param_check_range  [line 474]

  boolean param_check_range( string $var, integer $min, integer $max, string $err_msg, [ $required = true]  )

Checks if the param is a decimal number (no float, e.g. 3.14) in a given range.

Parameters:
string   $var:  param name
integer   $min:  min value
integer   $max:  max value
string   $err_msg:  error message
   $required: 

API Tags:
Return:  true if OK


[ Top ]
param_check_regexp  [line 760]

  boolean param_check_regexp( string $var, string $err_msg, [string|NULL $field_err_msg = NULL]  )

Check if the value of a param is a regular expression (syntax).

Parameters:
string   $var:  param name
string   $err_msg:  error message
string|NULL   $field_err_msg:  error message for form field ($err_msg gets used if === NULL).

API Tags:
Return:  true if OK


[ Top ]
param_check_url  [line 542]

  boolean param_check_url( string $var, string &$uri_scheme  )

Parameters:
string   $var:  param name
string   &$uri_scheme:  error message

API Tags:
Return:  true if OK


[ Top ]
param_child_select_value  [line 288]

  void param_child_select_value( string $var  )

set a parameter with the second part(X2) of the value from request ( X1-X2 )

Parameters:
string   $var:  Variable to set


[ Top ]
param_combo  [line 852]

  string param_combo( string $var, mixed $default, boolean $allow_none, [string $err_msg = '']  )

Sets a combo parameter with values from the request, => the value of the select option and the input text value if new is selected Display an error if the new value is selected that the input text has a value

Parameters:
string   $var:  Variable to set
mixed   $default:  Default value or TRUE if user input required
boolean   $allow_none:  true: allows to select new without entring a value in the input combo text
string   $err_msg:  error message

API Tags:
Return:  position status ID or 'new' or '' if new is seleted but not input text value


[ Top ]
param_compact_date  [line 719]

  string param_compact_date( string $var, [mixed $default = ''], [boolean $memorize = false], string $err_msg, [boolean $required = false]  )

Sets a date parameter with values from the request or to provided default, And check if param is a valid date (format wise).

Parameters:
string   $var:  Variable to set
mixed   $default:  Default value or TRUE if user input required
boolean   $memorize:  memorize ( see param() )
string   $err_msg:  error message
boolean   $required:  'required': Is non-empty date required? Default: true.

API Tags:
Return:  the compact date value ( yyyymmdd )


[ Top ]
param_date  [line 212]

  void param_date( $var, $err_msg, $required  )

Sets a date parameter by converting locale date (if valid) to ISO date.

If the date is not valid, it is set to the param unchanged (unconverted).

Parameters:
   $var: 
   $err_msg: 
   $required: 


[ Top ]
param_error  [line 897]

  void param_error( string $var, string|NULL $err_msg, [string|NULL $field_err_msg = NULL]  )

Add an error for a variable, either to the Form's field and/or the global $Messages object.

Parameters:
string   $var:  param name
string|NULL   $err_msg:  error message (by using NULL you can only add an error to the field, but not the $Message object)
string|NULL   $field_err_msg:  error message for form field ($err_msg gets used if === NULL).


[ Top ]
param_error_multiple  [line 922]

  void param_error_multiple( array $vars, string|NULL $err_msg, [string|NULL $field_err_msg = NULL]  )

Add an error for multiple variables, either to the Form's field and/or the global $Messages object.

Parameters:
array   $vars:  of param names
string|NULL   $err_msg:  error message (by using NULL you can only add an error to the field, but not the $Message object)
string|NULL   $field_err_msg:  error message for form fields ($err_msg gets used if === NULL).


[ Top ]
param_extend  [line 162]

  void param_extend( string $var, string $var_ext_array, [boolean $save_prefix = true]  )

Extend a parameter with an array of params.

Will be used for author/authorsel[], etc. Note: cannot be used for catsel[], because catsel is NON-recursive

Parameters:
string   $var:  Variable to extend
string   $var_ext_array:  Name of array Variable to use as an extension
boolean   $save_prefix:  Save non numeric prefix?


[ Top ]
param_integer_range  [line 458]

  boolean param_integer_range( string $var, integer $min, integer $max, string $err_msg, [ $required = true]  )

Gets a param and makes sure it's a decimal number (no float, e.g. 3.14) in a given range.

Parameters:
string   $var:  param name
integer   $min:  min value
integer   $max:  max value
string   $err_msg:  error message
   $required: 

API Tags:
Return:  true if OK


[ Top ]
param_isFilename  [line 314]

  boolean param_isFilename( string $var, string $err_msg  )

Check if the value is a file name

Parameters:
string   $var:  param name
string   $err_msg:  error message

API Tags:
Return:  true if OK


[ Top ]
param_string_not_empty  [line 402]

  boolean param_string_not_empty( string $var, string $err_msg, [string|NULL $field_err_msg = NULL]  )

Parameters:
string   $var:  param name
string   $err_msg:  error message
string|NULL   $field_err_msg:  error message for form field ($err_msg gets used if === NULL).

API Tags:
Return:  true if OK


[ Top ]
param_time  [line 238]

  mixed param_time( string $var, [mixed $default = ''], [boolean $memorize = false], [boolean $override = false], [boolean $forceset = true]  )

Sets a time parameter with the value from the request of the var argument or of the concat of the var argument_h: var argument_mn: var argument_s , except if param is already set!

Parameters:
string   $var:  Variable to set
mixed   $default:  Default value or TRUE if user input required
boolean   $memorize:  Do we need to memorize this to regenerate the URL for this page?
boolean   $override:  Override if variable already set
boolean   $forceset:  Force setting of variable to default?

API Tags:
Return:  Final value of Variable, or false if we don't force setting and did not set


[ Top ]
set_param  [line 132]

  void set_param( $var, $value  )

Set the value of a param (by force! :P)

Parameters:
   $var: 
   $value: 


[ Top ]
validation_errors  [line 884]

  integer validation_errors( )

Check if there have been validation errors

We play it safe here and check for all kind of errors, not just those from this particlar class.



[ Top ]
_add_message_to_Log  [line 955]

  void _add_message_to_Log( string $var, string $err_msg, [ $log_category = 'error']  )

This function is used by param_error() and param_error_multiple().

If $link_log_messages_to_field_IDs is true, it will link those parts of the error message that are not already links, to the html IDs of the fields with errors.

Parameters:
string   $var:  param name
string   $err_msg:  error message
   $log_category: 

API Tags:
Access:  protected


[ Top ]

Documentation generated on Tue, 18 Dec 2007 23:21:47 +0100 by phpDocumentor 1.4.0