mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Small optimizations in env() and Helper::_parseAttributes().
This commit is contained in:
parent
d89581dcca
commit
47f6a29998
2 changed files with 6 additions and 7 deletions
|
@ -264,14 +264,14 @@ if (!function_exists('sortByKey')) {
|
|||
* @link http://book.cakephp.org/view/1130/env
|
||||
*/
|
||||
function env($key) {
|
||||
if ($key == 'HTTPS') {
|
||||
if ($key === 'HTTPS') {
|
||||
if (isset($_SERVER['HTTPS'])) {
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
|
||||
}
|
||||
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
|
||||
}
|
||||
|
||||
if ($key == 'SCRIPT_NAME') {
|
||||
if ($key === 'SCRIPT_NAME') {
|
||||
if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
|
||||
$key = 'SCRIPT_URL';
|
||||
}
|
||||
|
|
|
@ -355,14 +355,13 @@ class Helper extends Object {
|
|||
if (!is_array($exclude)) {
|
||||
$exclude = array();
|
||||
}
|
||||
$keys = array_diff(array_keys($options), array_merge($exclude, array('escape')));
|
||||
$values = array_intersect_key(array_values($options), $keys);
|
||||
$filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true)));
|
||||
$escape = $options['escape'];
|
||||
$attributes = array();
|
||||
|
||||
foreach ($keys as $index => $key) {
|
||||
if ($values[$index] !== false && $values[$index] !== null) {
|
||||
$attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
|
||||
foreach ($filtered as $key => $value) {
|
||||
if ($value !== false && $value !== null) {
|
||||
$attributes[] = $this->__formatAttribute($key, $value, $escape);
|
||||
}
|
||||
}
|
||||
$out = implode(' ', $attributes);
|
||||
|
|
Loading…
Reference in a new issue