Exemplo n.º 1
0
 public function testGetUnorderedParametersUnknownBasedirScriptOrderedUnordered()
 {
     $urlCfg = new ezcUrlConfiguration();
     $urlCfg->basedir = '/mydir/shop';
     $urlCfg->script = 'index.php';
     $urlCfg->addOrderedParameter('module');
     $urlCfg->addUnorderedParameter('Software');
     $url = new ezcUrl('http://www.example.com/mydir/shop/index.php/order/(Software)/PHP/Version/5.2/Extension/XDebug/Extension/openssl', $urlCfg);
     $this->assertEquals('order', $url->getParam('module'));
     $this->assertEquals('PHP', $url->getParam('Software'));
     $this->assertEquals(array('(Software)', 'PHP', 'Version', '5.2', 'Extension', 'XDebug', 'Extension', 'openssl'), $url->getParams());
     $this->assertEquals('PHP', $url->getParam('Software'));
     $this->assertEquals('order', $url->getParam('module'));
 }
<?php

require_once 'tutorial_autoload.php';
// create an ezcUrlConfiguration object
$urlCfg = new ezcUrlConfiguration();
$urlCfg->basedir = '/mydir/shop';
$urlCfg->script = 'index.php';
$urlCfg->addOrderedParameter('module');
$url = new ezcUrl('http://www.example.com/mydir/shop/index.php/order/Software/PHP/Version/5.2/Extension/XDebug/Extension/openssl', $urlCfg);
// get the unordered parameters as a flat array
var_dump($url->getParams());
// will output array( 'Software', 'PHP', 'Version', '5.2', 'Extension', 'XDebug', 'Extension', 'openssl' )
Exemplo n.º 3
0
 /**
  * parseUrl sets up the parameters list by breaking up the URL and providing some 
  * default variables.
  */
 private function parseUrl(&$parameters)
 {
     $urlConfigRoot = new ezcUrlConfiguration();
     $urlConfigRoot->script = 'index.php';
     $urlConfigRoot->addOrderedParameter('module');
     $url = new ezcUrl($_SERVER['REQUEST_URI'], $urlConfigRoot);
     $moduleIdentifier = $url->getParam('module');
     $urlConfig = $this->urlConfigs[$moduleIdentifier];
     if (!$urlConfig) {
         $urlConfig = $this->urlConfigs['notfound'];
         $url = new ezcURL('/notfound/notfound/notfound', $urlConfigRoot);
     }
     $url->applyConfiguration($urlConfig);
     // var_dump($url->params);
     $parameters = array_merge($url->getQuery(), $_POST);
     $parameters['url'] = $url;
     $parameters['method'] = strtolower($_SERVER['REQUEST_METHOD']);
     $parameters['client_ip'] = $_SERVER['REMOTE_ADDR'];
     $parameters['client_port'] = $_SERVER['REMOTE_PORT'];
     //            var_dump($url->path);
 }
Exemplo n.º 4
0
<?php

require_once 'tutorial_autoload.php';
// create a default url configuration
$urlCfgDefault = new ezcUrlConfiguration();
$urlCfgDefault->addOrderedParameter('section');
// create a configuration for artists
$urlCfgArtist = new ezcUrlConfiguration();
$urlCfgArtist->addOrderedParameter('section');
$urlCfgArtist->addOrderedParameter('artist_name');
// create a configuration for albums
$urlCfgAlbum = new ezcUrlConfiguration();
$urlCfgAlbum->addOrderedParameter('section');
$urlCfgAlbum->addOrderedParameter('artist_name');
$urlCfgAlbum->addOrderedParameter('album_name');
// create a configuration for music genres
$urlCfgGenre = new ezcUrlConfiguration();
$urlCfgGenre->addOrderedParameter('section');
$urlCfgGenre->addOrderedParameter('genre_name');
$url = new ezcUrl('http://mymusicsite.com/showartist/Beatles', $urlCfgDefault);
switch ($url->getParam('section')) {
    case 'showartist':
        $url->applyConfiguration($urlCfgArtist);
        $artist = $url->getParam('artist_name');
        // do stuff with $artist
        var_dump($artist);
        break;
    case 'showalbum':
        $url->applyConfiguration($urlCfgAlbum);
        $artist = $url->getParam('artist_name');
        $album = $url->getParam('album_name');
Exemplo n.º 5
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.º 6
0
 public function testAddOrderedParameter()
 {
     $urlCfg = new ezcUrlConfiguration();
     $urlCfg->addOrderedParameter('folder');
 }