SourceForge.net LogoPHPGallue
[ class tree: libbase ] [ index: libbase ] [ all elements ]

Class: GALGlobalVars

Source Location: /libbase/globalvars.inc.php

Class Overview


Class to filter GET, POST and COOKIE vars.


Author(s):

Variables

Methods



Class Details

[line 273]
Class to filter GET, POST and COOKIE vars.

This class is intended for filtering a script's input variables. If you pass options to a script e.g. with GET parameters, these parameters often have a very limited set of valid values, for example size='large', size='medium', size='small'. In every case you use such a parameter you have to make sure it has a valid value. Additionally it is often the case that the value of such a parameter should be persistent. One solution are PHP sessions, but they would make it more difficult to create persistent links that can be bookmarked or included in external documents. This class provides the url() method that builds an URL with all GET parameters. Additionally this class allows multiple sources for a parameter and can set cookies.




Tags:

todo:  Implement some interfaces of the SDL package to allow iterating over the registered variables (low priority).


[ Top ]


Class Variables

$base_url =  ""

[line 289]

The base URL of the script (without GET parameters)



Tags:

access:  protected

Type:   string


[ Top ]

$cookie_lifetime =  1

[line 284]

The cookie lifetime when cookies are set.



Tags:

access:  protected

Type:   int


[ Top ]

$vars = array()

[line 279]

The variables.



Tags:

var:  Array of GALDescriptor objects
access:  protected

Type:   array


[ Top ]



Class Methods


constructor __construct [line 295]

GALGlobalVars __construct( int $cookie_lifetime, string $base_url)

initializes a GALGlobalVars object.



Parameters:

int   $cookie_lifetime   The lifetime of cookies set by this class.
string   $base_url   The URL of the traget script without GET parameters.

[ Top ]

method dump [line 442]

void dump( )

Dump information about all registered parameters to stdout.



[ Top ]

method dumpDOM [line 455]

void dumpDOM( $node)

Append information about all registered parameters as XHTML markup to the given node.



Parameters:

DOMNode   $node   The node the output is appended to.

[ Top ]

method evaluate [line 396]

void evaluate( array &$getvars, array &$postvars, array &$cookievars)

Evaluates the GET, POST and COOKIE data.

This method calls evaluate() for every GALDescriptor that corresponds to a registered parameter.




Tags:

see:  GALDescriptor::evaluate()
throws:  GAL_EGlobalVars


Parameters:

array   &$getvars   Typically global $_GET variable.
array   &$postvars   Typically global $_POST variable.
array   &$cookievars   Typically global $_COOKIE variable.

[ Top ]

method get [line 369]

void get( string $name)

Get the value of a certain parameter.

Alias for __get().




Tags:

throws:  GAL_EProperty


Parameters:

string   $name   The parameter's name.

[ Top ]

method register [line 311]

void register( string $name, mixed $sources, mixed $range, mixed $value, mixed $default)

Registers a GET, POST or COOKIE parameter.

This method creates and stores an internal GALDescriptor object that is used to evaluate a GET, POST or COOKIE parameter.




Tags:

throws:  GAL_EGlobalVars If a parameter with the same name is already registered.


Parameters:

string   $name   The parameter's (and the GALDescriptor's) name
mixed   $sources   The parameter's source (see GALDescriptor::__construct()).
mixed   $range   The parameter's range (see GALDescriptor::__construct()).
mixed   $value   The parameter's initial value (see GALDescriptor::__construct()).
mixed   $default   The parameter's default value (see GALDescriptor::__construct()).

[ Top ]

method registered [line 332]

bool registered( string $name)

Checks if a parameter with the given name is registered.



Tags:

return:  TRUE if a matching parameter was registered, FALSE otherwise.


Parameters:

string   $name   Maybe the name of a registered parameter ;).

[ Top ]

method set [line 343]

void set( string $name, mixed $value)

Set a certain parameter to a certain value.

Alias for __set().




Tags:

throws:  GAL_EProperty


Parameters:

string   $name   The parameter's name.
mixed   $value   The parameter's new value.

[ Top ]

method setcookies [line 407]

void setcookies( )

Sets cookies for all parameters that have GALDescriptor::COOKIE as source.



[ Top ]

method unregister [line 323]

void unregister( string $name)

Unregister a parameter.



Parameters:

string   $name   The name of the parameter that will be registered.

[ Top ]

method url [line 419]

void url( [array $changes = array()])

Generates an URL with all GET variables.



Parameters:

array   $changes   Override some values, array(var_name => new_value, ...).

[ Top ]

method __get [line 378]

void __get( string $name)

Get the value of a certain parameter.



Tags:

throws:  GAL_EProperty


Parameters:

string   $name   The parameter's name.

[ Top ]

method __set [line 353]

void __set( string $name, mixed $value)

Magic method to set parameters manually.



Tags:

throws:  GAL_EProperty


Parameters:

string   $name   The parameter's name.
mixed   $value   The parameter's new value.

[ Top ]


Documentation generated on Wed, 16 Aug 2006 15:36:06 +0200 by phpDocumentor 1.3.0RC6