Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-02-27 11:15:28 +01:00
commit 7fa42d634e
7 changed files with 87 additions and 68 deletions

View File

@ -2604,40 +2604,31 @@ class Util
foreach ($choices as $choice_value => $choice_label) {
if (! empty($class)) {
$radio_html .= '<div class="' . $class . '">';
}
if (! $id_prefix) {
$id_prefix = $html_field_name;
}
$html_field_id = $id_prefix . '_' . $choice_value;
$radio_html .= '<input type="radio" name="' . $html_field_name . '" id="'
. $html_field_id . '" value="'
. htmlspecialchars($choice_value) . '"';
if ($choice_value == $checked_choice) {
$radio_html .= ' checked="checked"';
if ($choice_value == $checked_choice){
$checked = 1;
}
$radio_html .= ' />' . "\n"
. '<label for="' . $html_field_id . '">'
. ($escape_label
? htmlspecialchars($choice_label)
: $choice_label)
. '</label>';
if ($line_break) {
$radio_html .= '<br />';
else{
$checked = 0;
}
if (! empty($class)) {
$radio_html .= '</div>';
}
$radio_html .= "\n";
$radio_html .= Template::get('radio_fields')->render([
'class' => $class,
'html_field_name' => $html_field_name,
'html_field_id' => $html_field_id,
'choice_value' => $choice_value,
'is_line_break' => $line_break,
'choice_label' => $choice_label,
'escape_label' => $escape_label,
'checked' => $checked
]);
}
return $radio_html;
}
/**
@ -2660,38 +2651,27 @@ class Util
public static function getDropdown(
$select_name, $choices, $active_choice, $id, $class = '', $placeholder = null
) {
$result = '<select'
. ' name="' . htmlspecialchars($select_name) . '"'
. ' id="' . htmlspecialchars($id) . '"'
. (! empty($class) ? ' class="' . htmlspecialchars($class) . '"' : '')
. '>';
$resultOptions = '';
$resultOptions = [];
$selected = false;
foreach ($choices as $one_choice_value => $one_choice_label) {
$resultOptions .= '<option value="'
. htmlspecialchars($one_choice_value) . '"';
$resultOptions[$one_choice_value]['value'] = $one_choice_value;
$resultOptions[$one_choice_value]['selected'] = false;
if ($one_choice_value == $active_choice) {
$resultOptions .= ' selected="selected"';
$resultOptions[$one_choice_value]['selected'] = true;
$selected = true;
}
$resultOptions .= '>' . htmlspecialchars($one_choice_label)
. '</option>';
$resultOptions[$one_choice_value]['label'] = $one_choice_label;
}
if (!empty($placeholder)) {
$resultOptions = '<option value="" disabled="disabled"'
. ( !$selected ? ' selected="selected"' : '' )
. '>' . $placeholder . '</option>'
. $resultOptions;
}
$result .= $resultOptions
. '</select>';
return $result;
return Template::get('dropdown')->render([
'select_name' => $select_name,
'id' => $id,
'class' => $class,
'placeholder' => $placeholder,
'selected' => $selected,
'resultOptions' => $resultOptions,
]);
}
/**

8
templates/dropdown.phtml Normal file
View File

@ -0,0 +1,8 @@
<select name="<?= htmlspecialchars($select_name) ?>" id="<?= htmlspecialchars($id) ?>" <?= !empty($class) ? 'class="' . htmlspecialchars($class) . '"' : '' ?>>
<?php if (!empty($placeholder)): ?>
<option value="" disabled="disabled" <?= !$selected ? ' selected="selected"' : '' ?> > <?= $placeholder?> </option>
<?php endif ?>
<?php foreach( $resultOptions as $option): ?>
<option value="<?=htmlspecialchars($option['value'])?>"<?= $option['selected']? ' selected="selected"' : '' ?>><?=htmlspecialchars($option['label']) ?></option>
<?php endforeach ?>
</select>

View File

@ -0,0 +1,11 @@
<?php if( !empty($class) ): ?>
<div class="<?= $class ?>">
<?php endif ?>
<input type="radio" name="<?=$html_field_name?>" id="<?=$html_field_id?>" value="<?=htmlspecialchars($choice_value)?>"<?= $checked? ' checked="checked"' : ''?> />
<label for="<?= $html_field_id ?>"><?= $escape_label? htmlspecialchars($choice_label) : $choice_label ?></label>
<?php if( $is_line_break ): ?>
<br />
<?php endif ?>
<?php if( !empty($class) ): ?>
</div>
<?php endif ?>

View File

@ -204,23 +204,23 @@ class DbSearchTest extends PMATestCase
. '<label for="criteriaSearchType_1">at least one of the words<span '
. 'class="pma_hint"><img src="themes/dot.gif" title="" alt="" class="icon ic_b_help" '
. '/><span class="hide">Words are separated by a space character (" ").'
. '</span></span></label><br />' . "\n"
. '</span></span></label>' . "\n" . '<br />' . "\n"
. '<input type="radio" name="criteriaSearchType" id="criteriaSearchType'
. '_2" value="2" />' . "\n"
. '<label for="criteriaSearchType_2">all words<span class="pma_hint">'
. '<img src="themes/dot.gif" title="" alt="" class="icon ic_b_help" /><span class'
. '="hide">Words are separated by a space character (" ").</span></span>'
. '</label><br />' . "\n"
. '</label>' . "\n" . '<br />' . "\n"
. '<input type="radio" name="criteriaSearchType" id="criteriaSearchType'
. '_3" value="3" />' . "\n"
. '<label for="criteriaSearchType_3">the exact phrase</label><br />'
. '<label for="criteriaSearchType_3">the exact phrase</label>' . "\n" . '<br />'
. "\n" . '<input type="radio" name="criteriaSearchType" id="criteria'
. 'SearchType_4" value="4" />' . "\n"
. '<label for="criteriaSearchType_4">as regular expression <a href='
. '"./url.php?url=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen'
. '%2Fregexp.html" target='
. '"mysql_doc"><img src="themes/dot.gif" title="Documentation"'
. ' alt="Documentation" class="icon ic_b_help" /></a></label><br />' . "\n"
. ' alt="Documentation" class="icon ic_b_help" /></a></label>' . "\n" . '<br />' . "\n"
. '</td></tr><tr><td class="right vtop">Inside tables:</td>'
. '<td rowspan="2"><select name="criteriaTables[]" size="6" '
. 'multiple="multiple"><option value="table1">table1</option>'

View File

@ -2529,10 +2529,13 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
'new'
);
$this->assertEquals(
'<select name="authentication_plugin" id="select_authentication_plugin">'
'<select name="authentication_plugin" id="select_authentication_plugin" >'
. "\n"
. '<option value="mysql_native_password" selected="selected">'
. 'Native MySQL authentication</option><option value="sha256_password">'
. 'SHA256 password authentication</option></select>',
. 'Native MySQL authentication</option>'
. "\n"
. '<option value="sha256_password">'
. 'SHA256 password authentication</option>' . "\n" . '</select>',
$actualHtml
);
@ -2544,10 +2547,12 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
);
$this->assertEquals(
'<select name="authentication_plugin" '
. 'id="select_authentication_plugin_cp"><option '
. 'id="select_authentication_plugin_cp" >'
. "\n" . '<option '
. 'value="mysql_native_password" selected="selected">'
. 'Native MySQL authentication</option><option value="sha256_password">'
. 'SHA256 password authentication</option></select>',
. 'Native MySQL authentication</option>'
. "\n" . '<option value="sha256_password">'
. 'SHA256 password authentication</option>' . "\n" . '</select>',
$actualHtml
);
@ -2559,9 +2564,10 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
);
$this->assertEquals(
'<select name="authentication_plugin" '
. 'id="select_authentication_plugin"><option '
. 'id="select_authentication_plugin" >'
. "\n" . '<option '
. 'value="mysql_native_password" selected="selected">'
. 'Native MySQL authentication</option></select>',
. 'Native MySQL authentication</option>'. "\n" .'</select>',
$actualHtml
);
@ -2574,9 +2580,11 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
);
$this->assertEquals(
'<select name="authentication_plugin" '
. 'id="select_authentication_plugin_cp"><option '
. 'value="mysql_native_password" selected="selected">'
. 'Native MySQL authentication</option></select>',
. 'id="select_authentication_plugin_cp" >'
. "\n"
. '<option value="mysql_native_password" selected="selected">'
. 'Native MySQL authentication</option>'
. "\n" . '</select>',
$actualHtml
);

View File

@ -33,7 +33,7 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
$id = "test_&lt;dropdown&gt;_name";
$result = '<select name="' . htmlspecialchars($name) . '" id="'
. htmlspecialchars($id) . '"></select>';
. htmlspecialchars($id) . '" >' . "\n" . '</select>';
$this->assertEquals(
$result,
@ -56,15 +56,15 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
$id = "test_&lt;dropdown&gt;_name";
$result = '<select name="' . htmlspecialchars($name) . '" id="'
. htmlspecialchars($id) . '">';
. htmlspecialchars($id) . '" >';
foreach ($choices as $one_choice_value => $one_choice_label) {
$result .= '<option value="' . htmlspecialchars($one_choice_value) . '"';
$result .= "\n" . '<option value="' . htmlspecialchars($one_choice_value) . '"';
if ($one_choice_value == $active_choice) {
$result .= ' selected="selected"';
}
$result .= '>' . htmlspecialchars($one_choice_label) . '</option>';
}
$result .= '</select>';
$result .= "\n" . '</select>';
$this->assertEquals(
$result,
@ -87,14 +87,16 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
$id = "test_&lt;dropdown&gt;_name";
$result = '<select name="' . htmlspecialchars($name) . '" id="'
. htmlspecialchars($id) . '">';
. htmlspecialchars($id) . '" >';
foreach ($choices as $one_choice_value => $one_choice_label) {
$result .= "\n";
$result .= '<option value="' . htmlspecialchars($one_choice_value) . '"';
if ($one_choice_value == $active_choice) {
$result .= ' selected="selected"';
}
$result .= '>' . htmlspecialchars($one_choice_label) . '</option>';
}
$result .= "\n";
$result .= '</select>';
$this->assertEquals(

View File

@ -54,6 +54,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">' . $choice_label
. '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
}
@ -86,6 +87,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">' . $choice_label
. '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
}
@ -114,6 +116,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
foreach ($choices as $choice_value => $choice_label) {
$html_field_id = $name . '_' . $choice_value;
$out .= '<div class="' . $class . '">';
$out .= "\n";
$out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id
. '" value="' . htmlspecialchars($choice_value) . '"';
if ($choice_value == $checked_choice) {
@ -122,7 +125,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">' . $choice_label
. '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
$out .= '</div>';
$out .= "\n";
}
@ -190,6 +195,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">'
. htmlspecialchars($choice_label) . '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
}
@ -224,6 +230,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">' . $choice_label
. '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
}
@ -252,6 +259,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
foreach ($choices as $choice_value => $choice_label) {
$html_field_id = $name . '_' . $choice_value;
$out .= '<div class="' . $class . '">';
$out .= "\n";
$out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id
. '" value="' . htmlspecialchars($choice_value) . '"';
if ($choice_value == $checked_choice) {
@ -260,7 +268,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$out .= ' />' . "\n";
$out .= '<label for="' . $html_field_id . '">'
. htmlspecialchars($choice_label) . '</label>';
$out .= "\n";
$out .= '<br />';
$out .= "\n";
$out .= '</div>';
$out .= "\n";
}