"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/helpers/BaseHtml.php" between
yii2-2.0.36.tar.gz and yii2-2.0.37.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

BaseHtml.php  (yii2-2.0.36):BaseHtml.php  (yii2-2.0.37)
skipping to change at line 422 skipping to change at line 422
} }
return static::tag('a', $text, $options); return static::tag('a', $text, $options);
} }
/** /**
* Generates a mailto hyperlink. * Generates a mailto hyperlink.
* @param string $text link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code * @param string $text link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code
* such as an image tag. If this is coming from end users, you should consid er [[encode()]] * such as an image tag. If this is coming from end users, you should consid er [[encode()]]
* it to prevent XSS attacks. * it to prevent XSS attacks.
* @param string $email email address. If this is null, the first parameter (link body) will be treated * @param string|null $email email address. If this is null, the first param eter (link body) will be treated
* as the email address and used. * as the email address and used.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated mailto link * @return string the generated mailto link
*/ */
public static function mailto($text, $email = null, $options = []) public static function mailto($text, $email = null, $options = [])
{ {
$options['href'] = 'mailto:' . ($email === null ? $text : $email); $options['href'] = 'mailto:' . ($email === null ? $text : $email);
skipping to change at line 472 skipping to change at line 472
} }
return static::tag('img', '', $options); return static::tag('img', '', $options);
} }
/** /**
* Generates a label tag. * Generates a label tag.
* @param string $content label text. It will NOT be HTML-encoded. Therefore you can pass in HTML code * @param string $content label text. It will NOT be HTML-encoded. Therefore you can pass in HTML code
* such as an image tag. If this is is coming from end users, you should [[e ncode()]] * such as an image tag. If this is is coming from end users, you should [[e ncode()]]
* it to prevent XSS attacks. * it to prevent XSS attacks.
* @param string $for the ID of the HTML element that this label is associat ed with. * @param string|null $for the ID of the HTML element that this label is ass ociated with.
* If this is null, the "for" attribute will not be generated. * If this is null, the "for" attribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated label tag * @return string the generated label tag
*/ */
public static function label($content, $for = null, $options = []) public static function label($content, $for = null, $options = [])
{ {
$options['for'] = $for; $options['for'] = $for;
skipping to change at line 547 skipping to change at line 547
*/ */
public static function resetButton($content = 'Reset', $options = []) public static function resetButton($content = 'Reset', $options = [])
{ {
$options['type'] = 'reset'; $options['type'] = 'reset';
return static::button($content, $options); return static::button($content, $options);
} }
/** /**
* Generates an input type of the given type. * Generates an input type of the given type.
* @param string $type the type attribute. * @param string $type the type attribute.
* @param string $name the name attribute. If it is null, the name attribute * @param string|null $name the name attribute. If it is null, the name attr
will not be generated. ibute will not be generated.
* @param string $value the value attribute. If it is null, the value attrib * @param string|null $value the value attribute. If it is null, the value a
ute will not be generated. ttribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated input tag * @return string the generated input tag
*/ */
public static function input($type, $name = null, $value = null, $options = []) public static function input($type, $name = null, $value = null, $options = [])
{ {
if (!isset($options['type'])) { if (!isset($options['type'])) {
$options['type'] = $type; $options['type'] = $type;
skipping to change at line 619 skipping to change at line 619
public static function resetInput($label = 'Reset', $options = []) public static function resetInput($label = 'Reset', $options = [])
{ {
$options['type'] = 'reset'; $options['type'] = 'reset';
$options['value'] = $label; $options['value'] = $label;
return static::tag('input', '', $options); return static::tag('input', '', $options);
} }
/** /**
* Generates a text input field. * Generates a text input field.
* @param string $name the name attribute. * @param string $name the name attribute.
* @param string $value the value attribute. If it is null, the value attrib ute will not be generated. * @param string|null $value the value attribute. If it is null, the value a ttribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated text input tag * @return string the generated text input tag
*/ */
public static function textInput($name, $value = null, $options = []) public static function textInput($name, $value = null, $options = [])
{ {
return static::input('text', $name, $value, $options); return static::input('text', $name, $value, $options);
} }
/** /**
* Generates a hidden input field. * Generates a hidden input field.
* @param string $name the name attribute. * @param string $name the name attribute.
* @param string $value the value attribute. If it is null, the value attrib ute will not be generated. * @param string|null $value the value attribute. If it is null, the value a ttribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated hidden input tag * @return string the generated hidden input tag
*/ */
public static function hiddenInput($name, $value = null, $options = []) public static function hiddenInput($name, $value = null, $options = [])
{ {
return static::input('hidden', $name, $value, $options); return static::input('hidden', $name, $value, $options);
} }
/** /**
* Generates a password input field. * Generates a password input field.
* @param string $name the name attribute. * @param string $name the name attribute.
* @param string $value the value attribute. If it is null, the value attrib ute will not be generated. * @param string|null $value the value attribute. If it is null, the value a ttribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated password input tag * @return string the generated password input tag
*/ */
public static function passwordInput($name, $value = null, $options = []) public static function passwordInput($name, $value = null, $options = [])
{ {
return static::input('password', $name, $value, $options); return static::input('password', $name, $value, $options);
} }
/** /**
* Generates a file input field. * Generates a file input field.
* To use a file input field, you should set the enclosing form's "enctype" attribute to * To use a file input field, you should set the enclosing form's "enctype" attribute to
* be "multipart/form-data". After the form is submitted, the uploaded file information * be "multipart/form-data". After the form is submitted, the uploaded file information
* can be obtained via $_FILES[$name] (see PHP documentation). * can be obtained via $_FILES[$name] (see PHP documentation).
* @param string $name the name attribute. * @param string $name the name attribute.
* @param string $value the value attribute. If it is null, the value attrib ute will not be generated. * @param string|null $value the value attribute. If it is null, the value a ttribute will not be generated.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded usin g [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* @return string the generated file input tag * @return string the generated file input tag
*/ */
public static function fileInput($name, $value = null, $options = []) public static function fileInput($name, $value = null, $options = [])
{ {
return static::input('file', $name, $value, $options); return static::input('file', $name, $value, $options);
} }
skipping to change at line 821 skipping to change at line 821
* 'value2' => ['label' => 'value 2'], * 'value2' => ['label' => 'value 2'],
* ]; * ];
* ``` * ```
* *
* - groups: array, the attributes for the optgroup tags. The structure of t his is similar to that of 'options', * - groups: array, the attributes for the optgroup tags. The structure of t his is similar to that of 'options',
* except that the array keys represent the optgroup labels specified in $ items. * except that the array keys represent the optgroup labels specified in $ items.
* - encodeSpaces: bool, whether to encode spaces in option prompt and optio n value with ` ` character. * - encodeSpaces: bool, whether to encode spaces in option prompt and optio n value with ` ` character.
* Defaults to false. * Defaults to false.
* - encode: bool, whether to encode option prompt and option value characte rs. * - encode: bool, whether to encode option prompt and option value characte rs.
* Defaults to `true`. This option is available since 2.0.3. * Defaults to `true`. This option is available since 2.0.3.
* - strict: boolean, if `$selection` is an array and this value is true a s
trict comparison will be performed on `$items` keys. Defaults to false.
* This option is available since 2.0.37.
* *
* The rest of the options will be rendered as the attributes of the resulti ng tag. The values will * The rest of the options will be rendered as the attributes of the resulti ng tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* *
* @return string the generated drop-down list tag * @return string the generated drop-down list tag
*/ */
public static function dropDownList($name, $selection = null, $items = [], $ options = []) public static function dropDownList($name, $selection = null, $items = [], $ options = [])
{ {
if (!empty($options['multiple'])) { if (!empty($options['multiple'])) {
skipping to change at line 879 skipping to change at line 881
* *
* - groups: array, the attributes for the optgroup tags. The structure of t his is similar to that of 'options', * - groups: array, the attributes for the optgroup tags. The structure of t his is similar to that of 'options',
* except that the array keys represent the optgroup labels specified in $ items. * except that the array keys represent the optgroup labels specified in $ items.
* - unselect: string, the value that will be submitted when no option is se lected. * - unselect: string, the value that will be submitted when no option is se lected.
* When this attribute is set, a hidden field will be generated so that if no option is selected in multiple * When this attribute is set, a hidden field will be generated so that if no option is selected in multiple
* mode, we can still obtain the posted unselect value. * mode, we can still obtain the posted unselect value.
* - encodeSpaces: bool, whether to encode spaces in option prompt and optio n value with ` ` character. * - encodeSpaces: bool, whether to encode spaces in option prompt and optio n value with ` ` character.
* Defaults to false. * Defaults to false.
* - encode: bool, whether to encode option prompt and option value characte rs. * - encode: bool, whether to encode option prompt and option value characte rs.
* Defaults to `true`. This option is available since 2.0.3. * Defaults to `true`. This option is available since 2.0.3.
* - strict: boolean, if `$selection` is an array and this value is true a s
trict comparison will be performed on `$items` keys. Defaults to false.
* This option is available since 2.0.37.
* *
* The rest of the options will be rendered as the attributes of the resulti ng tag. The values will * The rest of the options will be rendered as the attributes of the resulti ng tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
* See [[renderTagAttributes()]] for details on how attributes are being ren dered. * See [[renderTagAttributes()]] for details on how attributes are being ren dered.
* *
* @return string the generated list box tag * @return string the generated list box tag
*/ */
public static function listBox($name, $selection = null, $items = [], $optio ns = []) public static function listBox($name, $selection = null, $items = [], $optio ns = [])
{ {
if (!array_key_exists('size', $options)) { if (!array_key_exists('size', $options)) {
skipping to change at line 933 skipping to change at line 937
* The following options are specially handled: * The following options are specially handled:
* *
* - tag: string|false, the tag name of the container element. False to rend er checkbox without container. * - tag: string|false, the tag name of the container element. False to rend er checkbox without container.
* See also [[tag()]]. * See also [[tag()]].
* - unselect: string, the value that should be submitted when none of the c heckboxes is selected. * - unselect: string, the value that should be submitted when none of the c heckboxes is selected.
* By setting this option, a hidden input will be generated. * By setting this option, a hidden input will be generated.
* - disabled: boolean, whether the generated by unselect option hidden inpu t should be disabled. Defaults to false. * - disabled: boolean, whether the generated by unselect option hidden inpu t should be disabled. Defaults to false.
* This option is available since version 2.0.16. * This option is available since version 2.0.16.
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults t o true. * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults t o true.
* This option is ignored if `item` option is set. * This option is ignored if `item` option is set.
* - strict: boolean, if `$selection` is an array and this value is true a s
trict comparison will be performed on `$items` keys. Defaults to false.
* This option is available since 2.0.37.
* - separator: string, the HTML code that separates items. * - separator: string, the HTML code that separates items.
* - itemOptions: array, the options for generating the checkbox tag using [ [checkbox()]]. * - itemOptions: array, the options for generating the checkbox tag using [ [checkbox()]].
* - item: callable, a callback that can be used to customize the generation of the HTML code * - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callbac k must be: * corresponding to a single item in $items. The signature of this callbac k must be:
* *
* ```php * ```php
* function ($index, $label, $name, $checked, $value) * function ($index, $label, $name, $checked, $value)
* ``` * ```
* *
* where $index is the zero-based index of the checkbox in the whole list; $label * where $index is the zero-based index of the checkbox in the whole list; $label
skipping to change at line 964 skipping to change at line 970
} }
if (ArrayHelper::isTraversable($selection)) { if (ArrayHelper::isTraversable($selection)) {
$selection = array_map('strval', ArrayHelper::toArray($selection)); $selection = array_map('strval', ArrayHelper::toArray($selection));
} }
$formatter = ArrayHelper::remove($options, 'item'); $formatter = ArrayHelper::remove($options, 'item');
$itemOptions = ArrayHelper::remove($options, 'itemOptions', []); $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
$encode = ArrayHelper::remove($options, 'encode', true); $encode = ArrayHelper::remove($options, 'encode', true);
$separator = ArrayHelper::remove($options, 'separator', "\n"); $separator = ArrayHelper::remove($options, 'separator', "\n");
$tag = ArrayHelper::remove($options, 'tag', 'div'); $tag = ArrayHelper::remove($options, 'tag', 'div');
$strict = ArrayHelper::remove($options, 'strict', false);
$lines = []; $lines = [];
$index = 0; $index = 0;
foreach ($items as $value => $label) { foreach ($items as $value => $label) {
$checked = $selection !== null && $checked = $selection !== null &&
(!ArrayHelper::isTraversable($selection) && !strcmp($value, $sel ection) (!ArrayHelper::isTraversable($selection) && !strcmp($value, $sel ection)
|| ArrayHelper::isTraversable($selection) && ArrayHelper::is In((string)$value, $selection)); || ArrayHelper::isTraversable($selection) && ArrayHelper::is In((string)$value, $selection, $strict));
if ($formatter !== null) { if ($formatter !== null) {
$lines[] = call_user_func($formatter, $index, $label, $name, $ch ecked, $value); $lines[] = call_user_func($formatter, $index, $label, $name, $ch ecked, $value);
} else { } else {
$lines[] = static::checkbox($name, $checked, array_merge([ $lines[] = static::checkbox($name, $checked, array_merge([
'value' => $value, 'value' => $value,
'label' => $encode ? static::encode($label) : $label, 'label' => $encode ? static::encode($label) : $label,
], $itemOptions)); ], $itemOptions));
} }
$index++; $index++;
} }
skipping to change at line 1023 skipping to change at line 1030
* The following options are specially handled: * The following options are specially handled:
* *
* - tag: string|false, the tag name of the container element. False to rend er radio buttons without container. * - tag: string|false, the tag name of the container element. False to rend er radio buttons without container.
* See also [[tag()]]. * See also [[tag()]].
* - unselect: string, the value that should be submitted when none of the r adio buttons is selected. * - unselect: string, the value that should be submitted when none of the r adio buttons is selected.
* By setting this option, a hidden input will be generated. * By setting this option, a hidden input will be generated.
* - disabled: boolean, whether the generated by unselect option hidden inpu t should be disabled. Defaults to false. * - disabled: boolean, whether the generated by unselect option hidden inpu t should be disabled. Defaults to false.
* This option is available since version 2.0.16. * This option is available since version 2.0.16.
* - encode: boolean, whether to HTML-encode the checkbox labels. Defaults t o true. * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults t o true.
* This option is ignored if `item` option is set. * This option is ignored if `item` option is set.
* - strict: boolean, if `$selection` is an array and this value is true a s
trict comparison will be performed on `$items` keys. Defaults to false.
* This option is available since 2.0.37.
* - separator: string, the HTML code that separates items. * - separator: string, the HTML code that separates items.
* - itemOptions: array, the options for generating the radio button tag usi ng [[radio()]]. * - itemOptions: array, the options for generating the radio button tag usi ng [[radio()]].
* - item: callable, a callback that can be used to customize the generation of the HTML code * - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callbac k must be: * corresponding to a single item in $items. The signature of this callbac k must be:
* *
* ```php * ```php
* function ($index, $label, $name, $checked, $value) * function ($index, $label, $name, $checked, $value)
* ``` * ```
* *
* where $index is the zero-based index of the radio button in the whole l ist; $label * where $index is the zero-based index of the radio button in the whole l ist; $label
skipping to change at line 1051 skipping to change at line 1060
{ {
if (ArrayHelper::isTraversable($selection)) { if (ArrayHelper::isTraversable($selection)) {
$selection = array_map('strval', ArrayHelper::toArray($selection)); $selection = array_map('strval', ArrayHelper::toArray($selection));
} }
$formatter = ArrayHelper::remove($options, 'item'); $formatter = ArrayHelper::remove($options, 'item');
$itemOptions = ArrayHelper::remove($options, 'itemOptions', []); $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
$encode = ArrayHelper::remove($options, 'encode', true); $encode = ArrayHelper::remove($options, 'encode', true);
$separator = ArrayHelper::remove($options, 'separator', "\n"); $separator = ArrayHelper::remove($options, 'separator', "\n");
$tag = ArrayHelper::remove($options, 'tag', 'div'); $tag = ArrayHelper::remove($options, 'tag', 'div');
$strict = ArrayHelper::remove($options, 'strict', false);
$hidden = ''; $hidden = '';
if (isset($options['unselect'])) { if (isset($options['unselect'])) {
// add a hidden field so that if the list box has no option being se lected, it still submits a value // add a hidden field so that if the list box has no option being se lected, it still submits a value
$hiddenOptions = []; $hiddenOptions = [];
// make sure disabled input is not sending any value // make sure disabled input is not sending any value
if (!empty($options['disabled'])) { if (!empty($options['disabled'])) {
$hiddenOptions['disabled'] = $options['disabled']; $hiddenOptions['disabled'] = $options['disabled'];
} }
$hidden = static::hiddenInput($name, $options['unselect'], $hiddenO ptions); $hidden = static::hiddenInput($name, $options['unselect'], $hiddenO ptions);
unset($options['unselect'], $options['disabled']); unset($options['unselect'], $options['disabled']);
} }
$lines = []; $lines = [];
$index = 0; $index = 0;
foreach ($items as $value => $label) { foreach ($items as $value => $label) {
$checked = $selection !== null && $checked = $selection !== null &&
(!ArrayHelper::isTraversable($selection) && !strcmp($value, $sel ection) (!ArrayHelper::isTraversable($selection) && !strcmp($value, $sel ection)
|| ArrayHelper::isTraversable($selection) && ArrayHelper::is In((string)$value, $selection)); || ArrayHelper::isTraversable($selection) && ArrayHelper::is In((string)$value, $selection, $strict));
if ($formatter !== null) { if ($formatter !== null) {
$lines[] = call_user_func($formatter, $index, $label, $name, $ch ecked, $value); $lines[] = call_user_func($formatter, $index, $label, $name, $ch ecked, $value);
} else { } else {
$lines[] = static::radio($name, $checked, array_merge([ $lines[] = static::radio($name, $checked, array_merge([
'value' => $value, 'value' => $value,
'label' => $encode ? static::encode($label) : $label, 'label' => $encode ? static::encode($label) : $label,
], $itemOptions)); ], $itemOptions));
} }
$index++; $index++;
} }
skipping to change at line 1862 skipping to change at line 1872
*/ */
public static function renderSelectOptions($selection, $items, &$tagOptions = []) public static function renderSelectOptions($selection, $items, &$tagOptions = [])
{ {
if (ArrayHelper::isTraversable($selection)) { if (ArrayHelper::isTraversable($selection)) {
$selection = array_map('strval', ArrayHelper::toArray($selection)); $selection = array_map('strval', ArrayHelper::toArray($selection));
} }
$lines = []; $lines = [];
$encodeSpaces = ArrayHelper::remove($tagOptions, 'encodeSpaces', false); $encodeSpaces = ArrayHelper::remove($tagOptions, 'encodeSpaces', false);
$encode = ArrayHelper::remove($tagOptions, 'encode', true); $encode = ArrayHelper::remove($tagOptions, 'encode', true);
$strict = ArrayHelper::remove($tagOptions, 'strict', false);
if (isset($tagOptions['prompt'])) { if (isset($tagOptions['prompt'])) {
$promptOptions = ['value' => '']; $promptOptions = ['value' => ''];
if (is_string($tagOptions['prompt'])) { if (is_string($tagOptions['prompt'])) {
$promptText = $tagOptions['prompt']; $promptText = $tagOptions['prompt'];
} else { } else {
$promptText = $tagOptions['prompt']['text']; $promptText = $tagOptions['prompt']['text'];
$promptOptions = array_merge($promptOptions, $tagOptions['prompt ']['options']); $promptOptions = array_merge($promptOptions, $tagOptions['prompt ']['options']);
} }
$promptText = $encode ? static::encode($promptText) : $promptText; $promptText = $encode ? static::encode($promptText) : $promptText;
if ($encodeSpaces) { if ($encodeSpaces) {
skipping to change at line 1889 skipping to change at line 1900
unset($tagOptions['prompt'], $tagOptions['options'], $tagOptions['groups ']); unset($tagOptions['prompt'], $tagOptions['options'], $tagOptions['groups ']);
$options['encodeSpaces'] = ArrayHelper::getValue($options, 'encodeSpaces ', $encodeSpaces); $options['encodeSpaces'] = ArrayHelper::getValue($options, 'encodeSpaces ', $encodeSpaces);
$options['encode'] = ArrayHelper::getValue($options, 'encode', $encode); $options['encode'] = ArrayHelper::getValue($options, 'encode', $encode);
foreach ($items as $key => $value) { foreach ($items as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
$groupAttrs = isset($groups[$key]) ? $groups[$key] : []; $groupAttrs = isset($groups[$key]) ? $groups[$key] : [];
if (!isset($groupAttrs['label'])) { if (!isset($groupAttrs['label'])) {
$groupAttrs['label'] = $key; $groupAttrs['label'] = $key;
} }
$attrs = ['options' => $options, 'groups' => $groups, 'encodeSpa ces' => $encodeSpaces, 'encode' => $encode]; $attrs = ['options' => $options, 'groups' => $groups, 'encodeSpa ces' => $encodeSpaces, 'encode' => $encode, 'strict' => $strict];
$content = static::renderSelectOptions($selection, $value, $attr s); $content = static::renderSelectOptions($selection, $value, $attr s);
$lines[] = static::tag('optgroup', "\n" . $content . "\n", $grou pAttrs); $lines[] = static::tag('optgroup', "\n" . $content . "\n", $grou pAttrs);
} else { } else {
$attrs = isset($options[$key]) ? $options[$key] : []; $attrs = isset($options[$key]) ? $options[$key] : [];
$attrs['value'] = (string) $key; $attrs['value'] = (string) $key;
if (!array_key_exists('selected', $attrs)) { if (!array_key_exists('selected', $attrs)) {
$attrs['selected'] = $selection !== null && $attrs['selected'] = $selection !== null &&
(!ArrayHelper::isTraversable($selection) && !strcmp($key , $selection) (!ArrayHelper::isTraversable($selection) && !strcmp($key , $selection)
|| ArrayHelper::isTraversable($selection) && ArrayHelper ::isIn((string)$key, $selection)); || ArrayHelper::isTraversable($selection) && ArrayHelper ::isIn((string)$key, $selection, $strict));
} }
$text = $encode ? static::encode($value) : $value; $text = $encode ? static::encode($value) : $value;
if ($encodeSpaces) { if ($encodeSpaces) {
$text = str_replace(' ', ' ', $text); $text = str_replace(' ', ' ', $text);
} }
$lines[] = static::tag('option', $text, $attrs); $lines[] = static::tag('option', $text, $attrs);
} }
} }
return implode("\n", $lines); return implode("\n", $lines);
 End of changes. 18 change blocks. 
14 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)