Merge $tabindex and $idindex into $fieldIndex

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2023-04-21 20:19:14 +01:00
parent 269535a7a5
commit 0032b489f3
8 changed files with 39 additions and 69 deletions

View File

@ -78,7 +78,7 @@ class InsertEdit
];
private int $rowOffset = 0;
private int $tabindex = 0;
private int $fieldIndex = 0;
public function __construct(
private DatabaseInterface $dbi,
@ -426,7 +426,6 @@ class InsertEdit
* @param string $backupField hidden input field
* @param string $columnNameAppendix the name attribute
* @param string $onChangeClause onchange clause for fields
* @param int $idindex id index
* @param string $textDir text direction
* @param string $specialCharsEncoded replaced char if the string starts
* with a \r\n pair (0x0d0a) add an extra \n
@ -439,7 +438,6 @@ class InsertEdit
string $backupField,
string $columnNameAppendix,
string $onChangeClause,
int $idindex,
string $textDir,
string $specialCharsEncoded,
string $dataType,
@ -470,9 +468,9 @@ class InsertEdit
. ' rows="' . $textAreaRows . '"'
. ' cols="' . $textareaCols . '"'
. ' dir="' . $textDir . '"'
. ' id="field_' . $idindex . '_3"'
. ' id="field_' . $this->fieldIndex . '_3"'
. ($onChangeClause ? ' onchange="' . htmlspecialchars($onChangeClause, ENT_COMPAT) . '"' : '')
. ' tabindex="' . $this->tabindex . '"'
. ' tabindex="' . $this->fieldIndex . '"'
. ' data-type="' . $dataType . '">'
. $specialCharsEncoded
. '</textarea>';
@ -486,7 +484,6 @@ class InsertEdit
* @param string $specialChars special characters
* @param int $fieldsize html field size
* @param string $onChangeClause onchange clause for fields
* @param int $idindex id index
* @param string $dataType the html5 data-* attribute type
*
* @return string an html snippet
@ -497,7 +494,6 @@ class InsertEdit
string $specialChars,
int $fieldsize,
string $onChangeClause,
int $idindex,
string $dataType,
): string {
$theClass = 'textfield';
@ -532,9 +528,9 @@ class InsertEdit
. ($inputMinMax ? ' ' . $inputMinMax : '')
. ' data-type="' . $dataType . '"'
. ' class="' . $theClass . '" onchange="' . htmlspecialchars($onChangeClause, ENT_COMPAT) . '"'
. ' tabindex="' . $this->tabindex . '"'
. ' tabindex="' . $this->fieldIndex . '"'
. ($isInteger ? ' inputmode="numeric"' : '')
. ' id="field_' . $idindex . '_3">';
. ' id="field_' . $this->fieldIndex . '_3">';
}
/**
@ -603,7 +599,6 @@ class InsertEdit
* @param string $columnNameAppendix the name attribute
* @param string $onChangeClause onchange clause for fields
* @param string $specialChars special characters
* @param int $idindex id index
* @param string $textDir text direction
* @param string $specialCharsEncoded replaced char if the string starts
* with a \r\n pair (0x0d0a) add an extra \n
@ -621,7 +616,6 @@ class InsertEdit
string $columnNameAppendix,
string $onChangeClause,
string $specialChars,
int $idindex,
string $textDir,
string $specialCharsEncoded,
string $data,
@ -640,7 +634,6 @@ class InsertEdit
$backupField,
$columnNameAppendix,
$onChangeClause,
$idindex,
$textDir,
$specialCharsEncoded,
$dataType,
@ -652,7 +645,6 @@ class InsertEdit
$specialChars,
$fieldsize,
$onChangeClause,
$idindex,
$dataType,
);
}
@ -1783,8 +1775,7 @@ class InsertEdit
$backupField = '';
}
$idindex = ($this->rowOffset * $columnsCnt) + $columnNumber + 1;
$this->tabindex = $idindex;
$this->fieldIndex = ($this->rowOffset * $columnsCnt) + $columnNumber + 1;
// The function column
// -------------------
@ -1846,8 +1837,7 @@ class InsertEdit
$transformationOptions,
$currentValue,
$textDir,
$this->tabindex,
$idindex,
$this->fieldIndex,
);
$GLOBALS['plugin_scripts'] = array_merge(
@ -1943,7 +1933,6 @@ class InsertEdit
$specialChars,
min(max($column['len'], 4), $GLOBALS['cfg']['LimitChars']),
$onChangeClause,
$idindex,
'HEX',
);
}
@ -1955,7 +1944,6 @@ class InsertEdit
$columnNameAppendix,
$onChangeClause,
$specialChars,
$idindex,
$textDir,
$specialCharsEncoded,
$data,
@ -1975,7 +1963,7 @@ class InsertEdit
'function_options' => $functionOptions,
'nullify_code' => $nullifyCode,
'real_null_value' => $realNullValue,
'id_index' => $idindex,
'id_index' => $this->fieldIndex,
'type' => $type,
'decimals' => $noDecimals,
'special_chars' => $specialChars,

View File

@ -33,8 +33,7 @@ abstract class IOTransformationsPlugin extends TransformationsPlugin
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -45,8 +44,7 @@ abstract class IOTransformationsPlugin extends TransformationsPlugin
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
return '';
}

View File

@ -40,8 +40,7 @@ abstract class CodeMirrorEditorTransformationPlugin extends IOTransformationsPlu
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -52,8 +51,7 @@ abstract class CodeMirrorEditorTransformationPlugin extends IOTransformationsPlu
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
$html = '';
if (! empty($value)) {

View File

@ -54,8 +54,7 @@ abstract class ImageUploadTransformationsPlugin extends IOTransformationsPlugin
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -66,8 +65,7 @@ abstract class ImageUploadTransformationsPlugin extends IOTransformationsPlugin
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
$html = '';
$src = '';

View File

@ -49,8 +49,7 @@ abstract class TextFileUploadTransformationsPlugin extends IOTransformationsPlug
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -61,8 +60,7 @@ abstract class TextFileUploadTransformationsPlugin extends IOTransformationsPlug
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
$html = '';
if (! empty($value)) {

View File

@ -56,8 +56,7 @@ class Text_Plain_Iptobinary extends IOTransformationsPlugin
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -68,8 +67,7 @@ class Text_Plain_Iptobinary extends IOTransformationsPlugin
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
$html = '';
$val = '';
@ -93,8 +91,8 @@ class Text_Plain_Iptobinary extends IOTransformationsPlugin
. ' size="40"'
. ' dir="' . $textDir . '"'
. ' class="' . $class . '"'
. ' id="field_' . $idIndex . '_3"'
. ' tabindex="' . ($tabIndex) . '">';
. ' id="field_' . $fieldIndex . '_3"'
. ' tabindex="' . $fieldIndex . '">';
}
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */

View File

@ -53,8 +53,7 @@ class Text_Plain_Iptolong extends IOTransformationsPlugin
* @param mixed[] $options transformation options
* @param string $value Current field value
* @param string $textDir text direction
* @param int $tabIndex tab index
* @param int $idIndex id index
* @param int $fieldIndex field index
*
* @return string the html for input field
*/
@ -65,8 +64,7 @@ class Text_Plain_Iptolong extends IOTransformationsPlugin
array $options,
string $value,
string $textDir,
int $tabIndex,
int $idIndex,
int $fieldIndex,
): string {
$html = '';
$val = '';
@ -85,8 +83,8 @@ class Text_Plain_Iptolong extends IOTransformationsPlugin
. ' size="40"'
. ' dir="' . $textDir . '"'
. ' class="transform_IPToLong"'
. ' id="field_' . $idIndex . '_3"'
. ' tabindex="' . ($tabIndex) . '" />';
. ' id="field_' . $fieldIndex . '_3"'
. ' tabindex="' . $fieldIndex . '" />';
}
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */

View File

@ -602,12 +602,12 @@ class InsertEditTest extends AbstractTestCase
$column['is_char'] = true;
$column['Type'] = 'char(10)';
$column['True_Type'] = 'char';
(new ReflectionProperty(InsertEdit::class, 'tabindex'))->setValue($this->insertEdit, 2);
(new ReflectionProperty(InsertEdit::class, 'fieldIndex'))->setValue($this->insertEdit, 2);
$result = $this->callFunction(
$this->insertEdit,
InsertEdit::class,
'getTextarea',
[$column, 'a', 'b', '', 1, 'abc/', 'foobar', 'CHAR'],
[$column, 'a', 'b', '', 'abc/', 'foobar', 'CHAR'],
);
$result = $this->parseString($result);
@ -615,7 +615,7 @@ class InsertEditTest extends AbstractTestCase
$this->assertStringContainsString(
'<textarea name="fieldsb" class="char charField" '
. 'data-maxlength="10" rows="7" cols="1" dir="abc/" '
. 'id="field_1_3" tabindex="2" data-type="CHAR">',
. 'id="field_2_3" tabindex="2" data-type="CHAR">',
$result,
);
}
@ -629,17 +629,17 @@ class InsertEditTest extends AbstractTestCase
$column = [];
$column['pma_type'] = 'date';
$column['True_Type'] = 'date';
(new ReflectionProperty(InsertEdit::class, 'tabindex'))->setValue($this->insertEdit, 23);
(new ReflectionProperty(InsertEdit::class, 'fieldIndex'))->setValue($this->insertEdit, 23);
$result = $this->callFunction(
$this->insertEdit,
InsertEdit::class,
'getHtmlInput',
[$column, 'a', 'b', 30, 'c', 0, 'DATE'],
[$column, 'a', 'b', 30, 'c', 'DATE'],
);
$this->assertEquals(
'<input type="text" name="fieldsa" value="b" size="30" data-type="DATE"'
. ' class="textfield datefield" onchange="c" tabindex="23" id="field_0_3">',
. ' class="textfield datefield" onchange="c" tabindex="23" id="field_23_3">',
$result,
);
@ -650,11 +650,11 @@ class InsertEditTest extends AbstractTestCase
$this->insertEdit,
InsertEdit::class,
'getHtmlInput',
[$column, 'a', 'b', 30, 'c', 0, 'DATE'],
[$column, 'a', 'b', 30, 'c', 'DATE'],
);
$this->assertEquals(
'<input type="text" name="fieldsa" value="b" size="30" data-type="DATE"'
. ' class="textfield datetimefield" onchange="c" tabindex="23" id="field_0_3">',
. ' class="textfield datetimefield" onchange="c" tabindex="23" id="field_23_3">',
$result,
);
@ -665,11 +665,11 @@ class InsertEditTest extends AbstractTestCase
$this->insertEdit,
InsertEdit::class,
'getHtmlInput',
[$column, 'a', 'b', 30, 'c', 0, 'DATE'],
[$column, 'a', 'b', 30, 'c', 'DATE'],
);
$this->assertEquals(
'<input type="text" name="fieldsa" value="b" size="30" data-type="DATE"'
. ' class="textfield datetimefield" onchange="c" tabindex="23" id="field_0_3">',
. ' class="textfield datetimefield" onchange="c" tabindex="23" id="field_23_3">',
$result,
);
@ -681,11 +681,11 @@ class InsertEditTest extends AbstractTestCase
$this->insertEdit,
InsertEdit::class,
'getHtmlInput',
[$column, 'a', 'b', 11, 'c', 0, 'INT'],
[$column, 'a', 'b', 11, 'c', 'INT'],
);
$this->assertEquals(
'<input type="text" name="fieldsa" value="b" size="11" min="-2147483648" max="2147483647" data-type="INT"'
. ' class="textfield" onchange="c" tabindex="23" inputmode="numeric" id="field_0_3">',
. ' class="textfield" onchange="c" tabindex="23" inputmode="numeric" id="field_23_3">',
$result,
);
}
@ -741,7 +741,7 @@ class InsertEditTest extends AbstractTestCase
$extractedColumnSpec = [];
$extractedColumnSpec['spec_in_brackets'] = '25';
(new ReflectionProperty(InsertEdit::class, 'tabindex'))->setValue($this->insertEdit, 22);
(new ReflectionProperty(InsertEdit::class, 'fieldIndex'))->setValue($this->insertEdit, 22);
$result = $this->callFunction(
$this->insertEdit,
InsertEdit::class,
@ -753,7 +753,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",
@ -765,7 +764,7 @@ class InsertEditTest extends AbstractTestCase
"a\na\n"
. '<textarea name="fieldsb" class="char charField" '
. 'data-maxlength="25" rows="7" cols="1" dir="/" '
. 'id="field_1_3" onchange="c" tabindex="22" data-type="CHAR">'
. 'id="field_22_3" onchange="c" tabindex="22" data-type="CHAR">'
. '&lt;</textarea>',
$result,
);
@ -786,7 +785,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",
@ -797,7 +795,7 @@ class InsertEditTest extends AbstractTestCase
$this->assertEquals(
"a\n"
. '<input type="text" name="fieldsb" value="&lt;" size="20" data-type="'
. 'DATE" class="textfield datetimefield" onchange="c" tabindex="22" id="field_1_3"'
. 'DATE" class="textfield datetimefield" onchange="c" tabindex="22" id="field_22_3"'
. '><input type="hidden" name="auto_incrementb" value="1">'
. '<input type="hidden" name="fields_typeb" value="timestamp">',
$result,
@ -816,7 +814,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",
@ -841,7 +838,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",
@ -866,7 +862,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",
@ -891,7 +886,6 @@ class InsertEditTest extends AbstractTestCase
'b',
'c',
'&lt;',
1,
'/',
'&lt;',
"foo\nbar",