ezcUrlConfiguration makes it possible to use a custom URL form in your application.
A URL is assumed to be of this form: scheme://host/basedir/script/ordered_parameters/unordered_parameters
Example: http://example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7
Where: scheme = "http" host = "example.com" basedir = "mydir" script = "index.php" ordered parameters = "groups", "Games", "Adventure", "Adult" unordered parameters = array( "Larry", "7" )
When creating a configuration with ordered parameters, those parameters are required to be present in the parsed URL, in the same number as the configuration states. Having a different number of ordered parameters in the parsed URL will lead to wrong values assigned to the unordered parameters (if any follow the ordered parameters).
See the tutorial for a way to change configurations dynamically based on the ordered parameters.
Example of use:
Example of aggregating values for unordered parameters:
Source for this file: /Url/src/url_configuration.php
Version: | //autogen// |
AGGREGATE_ARGUMENTS
= 4
|
Flag for specifying aggregation for unordered parameter values if the parameter name appears more than once in the URL. For example, if the URL is 'http://www.example.com/(param1)/x/(param1)/y/z', then all values will be considered for the parameter param1. So $url->getParam( 'param1' ) will return array( array( "x" ), array( "y", "z" ) ), if $url is an ezcUrl object created from the above URL. |
MULTIPLE_ARGUMENTS
= 2
|
Flag for specifying multiple arguments for unordered parameters. |
SINGLE_ARGUMENT
= 1
|
Flag for specifying single arguments for unordered parameters. |
string | read/write |
$basedir
The part of the URL after the first slash. It can be null. Example: $basedir = shop in http://www.example.com/shop |
array(string=>int) | read/write |
$orderedParameters
The ordered parameters of the URL. Example: $orderedParameters = array( 'section' => 0, 'module' => 1, 'view' => 2, 'content' => 3 ); url = http://www.example.com/doc/components/view/trunk The numbers in the array represent the indices for each parameter. |
string | read/write |
$script
The default php script, which comes after the basedir. Can be null if the web server configuration is set to hide it. Example: $script = index.php in http://www.example.com/shop/index.php |
array(string) | read/write |
$unorderedDelimiters
The delimiters for the unordered parameters names. Example: $unorderedDelimiters = array( '(', ')' ) for url = http://www.example.com/doc/(file)/classtrees_Base.html |
array(string=>int) | read/write |
$unorderedParameters
The unordered parameters of the URL. Example: $unorderedParameters = array( 'file' => SINGLE_ARGUMENT ); url = http://www.example.com/doc/(file)/classtrees_Base.html The keys of the array represent the parameter names, and the values in the array represent the types of the parameters. |
public static ezcUrlConfiguration |
getInstance(
)
Returns the instance of the class. |
public ezcUrlConfiguration |
__construct(
)
Constructs a new ezcUrlConfiguration object. |
public void |
addOrderedParameter(
$name
)
Adds an ordered parameter to the URL configuration. |
public void |
addUnorderedParameter(
$name
, [ $type
= null] )
Adds an unordered parameter to the URL configuration. |
public void |
removeOrderedParameter(
$name
)
Removes an ordered parameter from the URL configuration. |
public void |
removeUnorderedParameter(
$name
)
Removes an unordered parameter from the URL configuration. |
Returns the instance of the class.
Constructs a new ezcUrlConfiguration object.
The properties of the object get default values, which can be changed by setting the properties directly, like:
Adds an ordered parameter to the URL configuration.
Ordered parameters must be added before unordered parameters, and they must appear in the parsed URL in the same number and order as they are defined in the configuration.
Name | Type | Description |
---|---|---|
$name |
string | The name of the ordered parameter to add to the configuration |
Adds an unordered parameter to the URL configuration.
The possible values for the $type parameter are:
Ordered parameters must be added before unordered parameters, and they must appear in the parsed URL in the same number and order as they are defined in the configuration.
Name | Type | Description |
---|---|---|
$name |
string | The name of the unordered parameter to add to the configuration |
$type |
int | The type of the unordered parameter |
Removes an ordered parameter from the URL configuration.
Name | Type | Description |
---|---|---|
$name |
string | The name of the ordered parameter to remove from the configuration |
Removes an unordered parameter from the URL configuration.
Name | Type | Description |
---|---|---|
$name |
string | The name of the unordered parameter to remove from the configuration |