Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- /**
- * ILLI
- *
- * @category ILLI_Core_Uri
- * @package ILLI
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- */
- NAMESPACE ILLI\Core\Uri;
- USE ILLI\Core\Virtual\Member\iField AS iField;
- USE ILLI\Core\Virtual\Member\tField AS tField;
- /**
- * ILLI Web Data URI
- *
- * @category ILLI_Core_Uri
- * @package ILLI
- * @subpackage Core\Uri
- * @namespace ILLI\Core\Uri
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- * @since 2.0.1
- * @version 3.0.1
- */
- CLASS Query
- {
- USE tField
- {
- tField_template__get as PUBLIC __get;
- tField_template__set as PUBLIC __set;
- }
- public function __construct($__query)
- {
- $toArray = function($queryData)
- {
- $new = [];
- if(is_string($queryData))
- {
- parse_str($queryData, $new);
- }
- else
- if(is_array($queryData))
- {
- $new = $queryData;
- }
- kSort($new);
- return $new;
- };
- $toString = function($string) use ($toArray)
- {
- return http_build_query($toArray($string), '@IDX:', ini_get('arg_separator.output'), PHP_QUERY_RFC1738);
- };
- $toEscape = function($string) use ($toArray)
- {
- return http_build_query($toArray($string), '@IDX:', ini_get('arg_separator.output'), PHP_QUERY_RFC3986);
- };
- $this->tField_define
- (
- 'query', 'array',
- [
- iField::PROP_INIT => $toArray($__query),
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_ON_SET => function(array $data) use ($toArray)
- {
- $data[iField::CALLBACK_PROP_NEW] = $toArray($data[iField::CALLBACK_PROP_NEW]);
- return $data;
- },
- iField::PROP_SYNCH =>
- [
- 'string' => $toString,
- 'escaped' => $toEscape,
- ]
- ],
- iField::DEBUG_CONTAINS
- | iField::DEBUG_ACCEPTED_TYPES
- | iField::DEBUG_INITIALIZED_AS
- )->tField_define
- (
- 'string', 'string',
- [
- iField::PROP_INIT => $toString($__query),
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_ON_SET => function(array $data) use ($toString, $toArray)
- {
- $data[iField::CALLBACK_PROP_NEW] = $toString($data[iField::CALLBACK_PROP_NEW]);
- return $data;
- },
- iField::PROP_SYNCH =>
- [
- 'escaped' => $toEscape,
- 'query' => $toArray,
- ]
- ],
- iField::DEBUG_CONTAINS
- | iField::DEBUG_ACCEPTED_TYPES
- | iField::DEBUG_INITIALIZED_AS
- )->tField_define
- (
- 'escaped', 'string',
- [
- iField::PROP_INIT => $toEscape($__query),
- iField::PROP_PRIVATE_SET => FALSE,
- iField::PROP_PRIVATE_GET => FALSE,
- iField::PROP_ON_SET => function(array $data) use ($toEscape, $toArray)
- {
- $data[iField::CALLBACK_PROP_NEW] = $toEscape($data[iField::CALLBACK_PROP_NEW]);
- return $data;
- },
- iField::PROP_SYNCH =>
- [
- 'string' => $toString,
- 'query' => $toArray,
- ]
- ],
- iField::DEBUG_CONTAINS
- | iField::DEBUG_ACCEPTED_TYPES
- | iField::DEBUG_INITIALIZED_AS
- );
- }
- }
- $u = new \ILLI\Core\Uri\Uri('ftp://bl@a:lksjjdls:k@jd@localhost:8888/gator/2/3/4/gatoZZZ?parameter1=testval&par2=val2#tab1');
- var_dump($u->Query->string);
- $u->Query->query = ['foo' => 'bar baz'];
- $u->Query->string = 'foo=bar&bar=baz bar';
- var_dump($u->Query->string);
- var_dump($u);
- ?>
- string(28) "par2=val2¶meter1=testval"
- string(19) "bar=baz+bar&foo=bar"
- object(ILLI\Core\Uri\Uri)#248 (4) {
- ["__tField":protected]=>
- array(1) {
- ["Query"]=>
- array(3) {
- ["contains"]=>
- &object(ILLI\Core\Uri\Query)#250 (4) {
- ["__tField":protected]=>
- array(3) {
- ["query"]=>
- array(3) {
- ["contains"]=>
- &array(2) {
- ["bar"]=>
- string(7) "baz bar"
- ["foo"]=>
- string(3) "bar"
- }
- ["init"]=>
- &array(2) {
- ["par2"]=>
- string(4) "val2"
- ["parameter1"]=>
- string(7) "testval"
- }
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(5) "array"
- }
- }
- ["string"]=>
- array(3) {
- ["contains"]=>
- &string(19) "bar=baz+bar&foo=bar"
- ["init"]=>
- &string(28) "par2=val2¶meter1=testval"
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(6) "string"
- }
- }
- ["escaped"]=>
- array(3) {
- ["contains"]=>
- &string(21) "bar=baz%20bar&foo=bar"
- ["init"]=>
- &string(28) "par2=val2¶meter1=testval"
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(6) "string"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Query":private]=>
- string(32) "000000000b1dab7b000000003636f1d0"
- }
- ["init"]=>
- &object(ILLI\Core\Uri\Query)#250 (4) {
- ["__tField":protected]=>
- array(3) {
- ["query"]=>
- array(3) {
- ["contains"]=>
- &array(2) {
- ["bar"]=>
- string(7) "baz bar"
- ["foo"]=>
- string(3) "bar"
- }
- ["init"]=>
- &array(2) {
- ["par2"]=>
- string(4) "val2"
- ["parameter1"]=>
- string(7) "testval"
- }
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(5) "array"
- }
- }
- ["string"]=>
- array(3) {
- ["contains"]=>
- &string(19) "bar=baz+bar&foo=bar"
- ["init"]=>
- &string(28) "par2=val2¶meter1=testval"
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(6) "string"
- }
- }
- ["escaped"]=>
- array(3) {
- ["contains"]=>
- &string(21) "bar=baz%20bar&foo=bar"
- ["init"]=>
- &string(28) "par2=val2¶meter1=testval"
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(6) "string"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Query":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Query":private]=>
- string(32) "000000000b1dab7b000000003636f1d0"
- }
- ["typeOf"]=>
- &array(1) {
- [0]=>
- string(20) "\ILLI\Core\Uri\Query"
- }
- }
- }
- ["__tField_LockRegistration":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_LockAllFields":"ILLI\Core\Uri\Uri":private]=>
- bool(false)
- ["__tField_Hash":"ILLI\Core\Uri\Uri":private]=>
- string(32) "000000000b1dab79000000003636f1d0"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement