mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Adding fix for #2219
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4654 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a06dce5a69
commit
38577ca149
1 changed files with 27 additions and 19 deletions
|
@ -255,29 +255,37 @@ class Helper extends Overloadable {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
|
function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
|
||||||
$minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
|
|
||||||
if (!is_array($exclude)) {
|
|
||||||
$exclude = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$out = array();
|
if (!is_array($exclude)) {
|
||||||
|
$exclude = array();
|
||||||
foreach($options as $key => $value) {
|
|
||||||
if (!in_array($key, $exclude)) {
|
|
||||||
if (in_array($key, $minimizedAttributes) && ($value === 1 || $value === true || $value === 'true' || in_array($value, $minimizedAttributes))) {
|
|
||||||
$value = $key;
|
|
||||||
} elseif(in_array($key, $minimizedAttributes)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$out[] = "{$key}=\"{$value}\"";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$out = join(' ', $out);
|
$keys = array_diff(array_keys($options), $exclude);
|
||||||
return $out ? $insertBefore . $out . $insertAfter : null;
|
$values = array_intersect_key(array_values($options), $keys);
|
||||||
|
$out = implode(' ', array_map(array(&$this, '__formatAttribute'), $keys, $values));
|
||||||
} else {
|
} else {
|
||||||
return $options ? $insertBefore . $options . $insertAfter : null;
|
$out = $options;
|
||||||
}
|
}
|
||||||
|
return $out ? $insertBefore . $out . $insertAfter : '';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __formatAttribute($key, $value) {
|
||||||
|
$attribute = '';
|
||||||
|
$attributeFormat = '%s="%s"';
|
||||||
|
$minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
|
||||||
|
|
||||||
|
if (in_array($key, $minimizedAttributes)) {
|
||||||
|
if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
|
||||||
|
$attribute = sprintf($attributeFormat, $key, $key);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$attribute = sprintf($attributeFormat, $key, htmlspecialchars($value));
|
||||||
|
}
|
||||||
|
return $attribute;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @deprecated Name changed to '_parseAttributes'. Version 0.9.2.
|
* @deprecated Name changed to '_parseAttributes'. Version 0.9.2.
|
||||||
|
|
Loading…
Add table
Reference in a new issue