Exemplo n.º 1
0
 /**
  * Test for bug #12825 (URL parser doesn't like empty elements.)
  */
 public function testGetUnorderedParameterMissing()
 {
     $urlCfg = new ezcUrlConfiguration();
     $urlCfg->basedir = 'mydir/';
     $urlCfg->script = 'index.php';
     $urlCfg->addUnorderedParameter('language');
     // should have been http://www.example.com/mydir/index.php/(language)/en
     $url = new ezcUrl('http://www.example.com/mydir/index.php//en', $urlCfg);
     $this->assertEquals(null, $url->getParam('language'));
 }
Exemplo n.º 2
0
<?php

require_once 'tutorial_autoload.php';
// create an ezcUrlConfiguration object
$urlCfg = new ezcUrlConfiguration();
// set the basedir and script values
$urlCfg->basedir = 'mydir';
$urlCfg->script = 'index.php';
// define delimiters for unordered parameter names
$urlCfg->unorderedDelimiters = array('(', ')');
// define ordered parameters
$urlCfg->addOrderedParameter('section');
$urlCfg->addOrderedParameter('group');
$urlCfg->addOrderedParameter('category');
$urlCfg->addOrderedParameter('subcategory');
// define unordered parameters
$urlCfg->addUnorderedParameter('game', ezcUrlConfiguration::MULTIPLE_ARGUMENTS);
// create a new ezcUrl object from a string url and use the above $urlCfg
$url = new ezcUrl('http://www.example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7', $urlCfg);
// get the parameter values from the url
var_dump($url->getParam('section'));
var_dump($url->getParam('group'));
var_dump($url->getParam('category'));
var_dump($url->getParam('subcategory'));
var_dump($url->getParam('game'));
// output the url (index.php will not be there)
var_dump($url->buildUrl());
// output the url (with index.php included)
var_dump($url->buildUrl(true));
Exemplo n.º 3
0
<?php

require_once 'tutorial_autoload.php';
// create an ezcUrlConfiguration object
$urlCfg = new ezcUrlConfiguration();
// set the basedir and script values
$urlCfg->basedir = 'mydir';
$urlCfg->script = 'index.php';
// define delimiters for unordered parameter names
$urlCfg->unorderedDelimiters = array('(', ')');
// define ordered parameters
$urlCfg->addOrderedParameter('section');
$urlCfg->addOrderedParameter('group');
$urlCfg->addOrderedParameter('category');
$urlCfg->addOrderedParameter('subcategory');
// define unordered parameters
$urlCfg->addUnorderedParameter('game');
// visualize the $urlCfg object
var_dump($urlCfg);
// create a new ezcUrl object from a string url and use the above $urlCfg
$url = new ezcUrl('http://www.example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7', $urlCfg);
Exemplo n.º 4
0
 public function testAddUnorderedParameter()
 {
     $urlCfg = new ezcUrlConfiguration();
     $urlCfg->addUnorderedParameter('folder');
 }
Exemplo n.º 5
0
<?php

require_once 'tutorial_autoload.php';
// create an ezcUrlConfiguration object
$urlCfg = new ezcUrlConfiguration();
// single parameter value
$urlCfg->addUnorderedParameter('param1');
$url = new ezcUrl('http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg);
var_dump($url->getParam('param1'));
// will output "y"
// multiple parameter values
$urlCfg->addUnorderedParameter('param1', ezcUrlConfiguration::MULTIPLE_ARGUMENTS);
$url = new ezcUrl('http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg);
var_dump($url->getParam('param1'));
// will output array( "y", "z" )
// multiple parameter values with aggregation
$urlCfg->addUnorderedParameter('param1', ezcUrlConfiguration::AGGREGATE_ARGUMENTS);
$url = new ezcUrl('http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg);
var_dump($url->getParam('param1'));
// will output array( array( "x" ), array( "y", "z" ) )
// output the url (it will be similar to the input url)
var_dump($url->buildUrl());