class Url (View source)

Static methods for URL/hidden inputs generating

Methods

static string
getHiddenInputs(string|array $db = '', string $table = '', string|array $skip = [])

Generates text with hidden inputs.

static string
getHiddenFields(array $values, string $pre = '', bool $isToken = false)

create hidden form fields from array with name => value

static string
getCommon(array $params = [], string $divider = '?', bool $encrypt = true)

Generates text with URL parameters.

static string
getCommonRaw(array $params = [], string $divider = '?', bool $encrypt = true)

Generates text with URL parameters.

static string
buildHttpQuery(array $params, bool $encrypt = true)

No description

static string
encryptQuery(string $query)

No description

static string|null
decryptQuery(string $query)

No description

static string
getArgSeparator()

Returns url separator character used for separating url parts.

static string
getFromRoute(string $route, array $additionalParameters = [], bool $encrypt = true)

No description

Details

static string getHiddenInputs(string|array $db = '', string $table = '', string|array $skip = [])

Generates text with hidden inputs.

Parameters

string|array $db

optional database name (can also be an array of parameters)

string $table

optional table name

string|array $skip

do not generate a hidden field for this parameter (can be an array of strings)

Return Value

string

string with input fields

See also

Url::getCommon

static string getHiddenFields(array $values, string $pre = '', bool $isToken = false)

create hidden form fields from array with name => value

$values = array(
    'aaa' => aaa,
    'bbb' => array(
         'bbb_0',
         'bbb_1',
    ),
    'ccc' => array(
         'a' => 'ccc_a',
         'b' => 'ccc_b',
    ),
);
echo Url::getHiddenFields($values);

// produces:
<input type="hidden" name="aaa" Value="aaa">
<input type="hidden" name="bbb[0]" Value="bbb_0">
<input type="hidden" name="bbb[1]" Value="bbb_1">
<input type="hidden" name="ccc[a]" Value="ccc_a">
<input type="hidden" name="ccc[b]" Value="ccc_b">

Parameters

array $values

hidden values

string $pre prefix
bool $isToken

if token already added in hidden input field

Return Value

string

form fields of type hidden

static string getCommon(array $params = [], string $divider = '?', bool $encrypt = true)

Generates text with URL parameters.

$params['myparam'] = 'myvalue';
$params['db']      = 'mysql';
$params['table']   = 'rights';
// note the missing ?
echo 'script.php' . Url::getCommon($params);
// produces with cookies enabled:
// script.php?myparam=myvalue&db=mysql&table=rights
// with cookies disabled:
// script.php?server=1&lang=en&myparam=myvalue&db=mysql
// &table=rights

// note the missing ?
echo 'script.php' . Url::getCommon();
// produces with cookies enabled:
// script.php
// with cookies disabled:
// script.php?server=1&lang=en

Parameters

array $params

optional, Contains an associative array with url params

string $divider

optional character to use instead of '?'

bool $encrypt

whether to encrypt URL params

Return Value

string

string with URL parameters

static string getCommonRaw(array $params = [], string $divider = '?', bool $encrypt = true)

Generates text with URL parameters.

$params['myparam'] = 'myvalue';
$params['db']      = 'mysql';
$params['table']   = 'rights';
// note the missing ?
echo 'script.php' . Url::getCommon($params);
// produces with cookies enabled:
// script.php?myparam=myvalue&db=mysql&table=rights
// with cookies disabled:
// script.php?server=1&lang=en&myparam=myvalue&db=mysql
// &table=rights

// note the missing ?
echo 'script.php' . Url::getCommon();
// produces with cookies enabled:
// script.php
// with cookies disabled:
// script.php?server=1&lang=en

Parameters

array $params

optional, Contains an associative array with url params

string $divider

optional character to use instead of '?'

bool $encrypt

whether to encrypt URL params

Return Value

string

string with URL parameters

static string buildHttpQuery(array $params, bool $encrypt = true)

No description

Parameters

array $params
bool $encrypt

whether to encrypt URL params

Return Value

string

static string encryptQuery(string $query)

No description

Parameters

string $query

Return Value

string

static string|null decryptQuery(string $query)

No description

Parameters

string $query

Return Value

string|null

static string getArgSeparator()

Returns url separator character used for separating url parts.

Extracted from 'arg_separator.input' as set in php.ini, but prefers '&' and ';'.

static string getFromRoute(string $route, array $additionalParameters = [], bool $encrypt = true)

No description

Parameters

string $route

Route to use

array $additionalParameters

Additional URL parameters

bool $encrypt

Return Value

string