PluginType enum
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
786c683d2d
commit
2702f2814e
@ -10596,24 +10596,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/BoolPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:checkboxCheck\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/BoolPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:getDefault\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/HiddenPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:getDefault\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/NumberPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
@ -10626,12 +10608,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/RadioPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:getDefault\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/RadioPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
@ -10644,18 +10620,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/SelectPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:getDefault\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/SelectPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$section of static method PhpMyAdmin\\Plugins\:\:getDefault\(\) expects ''Export''\|''Import''\|''Schema'', string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Properties/Options/Items/TextPropertyItem.php
|
||||
|
||||
-
|
||||
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
|
||||
identifier: equal.notAllowed
|
||||
|
||||
@ -5607,14 +5607,14 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<PossiblyInvalidCast>
|
||||
<code><![CDATA[$config->settings[$section][$opt]]]></code>
|
||||
<code><![CDATA[$config->settings[$pluginType->value][$opt]]]></code>
|
||||
</PossiblyInvalidCast>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$propertyGroup->getName()]]></code>
|
||||
<code><![CDATA[$subgroupHeader->getName()]]></code>
|
||||
</PossiblyNullOperand>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[empty(Config::getInstance()->settings[$section][$opt])]]></code>
|
||||
<code><![CDATA[empty(Config::getInstance()->settings[$pluginType->value][$opt])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Auth/AuthenticationConfig.php">
|
||||
@ -7205,9 +7205,6 @@
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/BoolPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$this->getForce()]]></code>
|
||||
<code><![CDATA[$this->getForce()]]></code>
|
||||
@ -7218,9 +7215,6 @@
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/HiddenPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
@ -7229,13 +7223,10 @@
|
||||
<file src="src/Properties/Options/Items/MessageOnlyPropertyItem.php">
|
||||
<PossiblyUnusedParam>
|
||||
<code><![CDATA[$pluginName]]></code>
|
||||
<code><![CDATA[$section]]></code>
|
||||
<code><![CDATA[$pluginType]]></code>
|
||||
</PossiblyUnusedParam>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/NumberPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
@ -7244,9 +7235,6 @@
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/RadioPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$val]]></code>
|
||||
</MixedAssignment>
|
||||
@ -7258,9 +7246,6 @@
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/SelectPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$val]]></code>
|
||||
</MixedAssignment>
|
||||
@ -7272,9 +7257,6 @@
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Properties/Options/Items/TextPropertyItem.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$section]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
<code><![CDATA[$this->getName()]]></code>
|
||||
|
||||
@ -20,6 +20,7 @@ use PhpMyAdmin\Import\Import;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Util;
|
||||
@ -93,9 +94,9 @@ final readonly class ImportController implements InvocableController
|
||||
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'database', 'db' => Current::$database];
|
||||
|
||||
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
|
||||
$options = Plugins::getOptions('Import', $importList);
|
||||
$options = Plugins::getOptions(PluginType::Import, $importList);
|
||||
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
|
||||
$maxUploadSize = Util::getUploadSizeInBytes();
|
||||
|
||||
$this->response->render('database/import/index', [
|
||||
|
||||
@ -18,6 +18,7 @@ use PhpMyAdmin\Import\Import;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Util;
|
||||
@ -78,9 +79,9 @@ final readonly class ImportController implements InvocableController
|
||||
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'server'];
|
||||
|
||||
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
|
||||
$options = Plugins::getOptions('Import', $importList);
|
||||
$options = Plugins::getOptions(PluginType::Import, $importList);
|
||||
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
|
||||
$maxUploadSize = Util::getUploadSizeInBytes();
|
||||
|
||||
$this->response->render('server/import/index', [
|
||||
|
||||
@ -21,6 +21,7 @@ use PhpMyAdmin\Import\Import;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Url;
|
||||
@ -122,9 +123,9 @@ final readonly class ImportController implements InvocableController
|
||||
];
|
||||
|
||||
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
|
||||
$options = Plugins::getOptions('Import', $importList);
|
||||
$options = Plugins::getOptions(PluginType::Import, $importList);
|
||||
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
|
||||
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
|
||||
$maxUploadSize = Util::getUploadSizeInBytes();
|
||||
|
||||
$this->response->render('table/import/index', [
|
||||
|
||||
@ -12,6 +12,7 @@ use PhpMyAdmin\Database\Designer\DesignerTable;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
use stdClass;
|
||||
@ -118,7 +119,7 @@ class Designer
|
||||
}
|
||||
|
||||
$choice = Plugins::getChoice($exportList, $this->getFormat($formatParam, $exportTypeParam));
|
||||
$options = Plugins::getOptions('Schema', $exportList);
|
||||
$options = Plugins::getOptions(PluginType::Schema, $exportList);
|
||||
|
||||
return $this->template->render('database/designer/schema_export', [
|
||||
'db' => $db,
|
||||
|
||||
@ -13,6 +13,7 @@ use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Query\Utilities;
|
||||
use PhpMyAdmin\Table\Table;
|
||||
use PhpMyAdmin\Util;
|
||||
@ -178,7 +179,7 @@ final readonly class Options
|
||||
'hidden_inputs' => $hiddenInputs,
|
||||
'export_method' => $_POST['quick_or_custom'] ?? $config->config->Export->method,
|
||||
'plugins_choice' => $dropdown,
|
||||
'options' => Plugins::getOptions('Export', $exportList),
|
||||
'options' => Plugins::getOptions(PluginType::Export, $exportList),
|
||||
'can_convert_kanji' => Encoding::canConvertKanji(),
|
||||
'exec_time_limit' => $config->settings['ExecTimeLimit'],
|
||||
'rows' => $rows,
|
||||
|
||||
@ -16,6 +16,7 @@ use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Plugins\ImportPlugin;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
|
||||
@ -197,21 +198,18 @@ class Plugins
|
||||
* Returns html input tag option 'checked' if plugin $opt
|
||||
* should be set by config or request
|
||||
*
|
||||
* @param string $section name of config section in
|
||||
* \PhpMyAdmin\Config::getInstance()->settings[$section] for plugin
|
||||
* @param string $opt name of option
|
||||
* @psalm-param 'Export'|'Import'|'Schema' $section
|
||||
* @param string $opt name of option
|
||||
*
|
||||
* @return string html input tag option 'checked'
|
||||
*/
|
||||
public static function checkboxCheck(string $section, string $opt): string
|
||||
public static function checkboxCheck(PluginType $pluginType, string $opt): string
|
||||
{
|
||||
// If the form is being repopulated using $_GET data, that is priority
|
||||
if (
|
||||
isset($_GET[$opt])
|
||||
|| ! isset($_GET['repopulate'])
|
||||
&& ((ImportSettings::$timeoutPassed && isset($_REQUEST[$opt]))
|
||||
|| ! empty(Config::getInstance()->settings[$section][$opt]))
|
||||
|| ! empty(Config::getInstance()->settings[$pluginType->value][$opt]))
|
||||
) {
|
||||
return ' checked';
|
||||
}
|
||||
@ -222,14 +220,12 @@ class Plugins
|
||||
/**
|
||||
* Returns default value for option $opt
|
||||
*
|
||||
* @param string $section name of config section in
|
||||
* \PhpMyAdmin\Config::getInstance()->settings[$section] for plugin
|
||||
* @param string $opt name of option
|
||||
* @psalm-param 'Export'|'Import'|'Schema' $section
|
||||
* @param PluginType $pluginType type of the plugin
|
||||
* @param string $opt name of option
|
||||
*
|
||||
* @return string default value for option $opt
|
||||
*/
|
||||
public static function getDefault(string $section, string $opt): string
|
||||
public static function getDefault(PluginType $pluginType, string $opt): string
|
||||
{
|
||||
if (isset($_GET[$opt]) && is_string($_GET[$opt])) {
|
||||
// If the form is being repopulated using $_GET data, that is priority
|
||||
@ -241,8 +237,8 @@ class Plugins
|
||||
}
|
||||
|
||||
$config = Config::getInstance();
|
||||
if (isset($config->settings[$section][$opt])) {
|
||||
return (string) $config->settings[$section][$opt];
|
||||
if (isset($config->settings[$pluginType->value][$opt])) {
|
||||
return (string) $config->settings[$pluginType->value][$opt];
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -274,17 +270,15 @@ class Plugins
|
||||
/**
|
||||
* Returns single option in a list element
|
||||
*
|
||||
* @param string $section name of config section in $cfg[$section] for plugin
|
||||
* @param string $pluginName unique plugin name
|
||||
* @param OptionsPropertyItem $propertyGroup options property main group instance
|
||||
* @param bool $isSubgroup if this group is a subgroup
|
||||
* @psalm-param 'Export'|'Import'|'Schema' $section
|
||||
*
|
||||
* @return string table row with option
|
||||
*/
|
||||
private static function getOneOption(
|
||||
Plugin $plugin,
|
||||
string $section,
|
||||
PluginType $pluginType,
|
||||
string $pluginName,
|
||||
OptionsPropertyItem $propertyGroup,
|
||||
bool $isSubgroup = false,
|
||||
@ -329,7 +323,7 @@ class Plugins
|
||||
// each subgroup can have a header, which may also be a form element
|
||||
$subgroupHeader = $propertyItem->getSubgroupHeader();
|
||||
if ($subgroupHeader !== null) {
|
||||
$ret .= self::getOneOption($plugin, $section, $pluginName, $subgroupHeader);
|
||||
$ret .= self::getOneOption($plugin, $pluginType, $pluginName, $subgroupHeader);
|
||||
}
|
||||
|
||||
$ret .= '<li class="list-group-item"><ul class="list-group"';
|
||||
@ -339,12 +333,12 @@ class Plugins
|
||||
$ret .= '>';
|
||||
}
|
||||
|
||||
$ret .= self::getOneOption($plugin, $section, $pluginName, $propertyItem, true);
|
||||
$ret .= self::getOneOption($plugin, $pluginType, $pluginName, $propertyItem, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
// single property item
|
||||
$ret .= self::getHtmlForProperty($plugin, $section, $pluginName, $propertyItem);
|
||||
$ret .= self::getHtmlForProperty($plugin, $pluginType, $pluginName, $propertyItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,28 +353,20 @@ class Plugins
|
||||
return $ret . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for properties items
|
||||
*
|
||||
* @param string $section name of config section in $cfg[$section] for plugin
|
||||
* @param string $pluginName unique plugin name
|
||||
* @param OptionsPropertyItem $propertyItem Property item
|
||||
* @psalm-param 'Export'|'Import'|'Schema' $section
|
||||
*/
|
||||
public static function getHtmlForProperty(
|
||||
private static function getHtmlForProperty(
|
||||
Plugin $plugin,
|
||||
string $section,
|
||||
PluginType $pluginType,
|
||||
string $pluginName,
|
||||
OptionsPropertyItem $propertyItem,
|
||||
): string {
|
||||
return match (true) {
|
||||
$propertyItem instanceof BoolPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof HiddenPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof MessageOnlyPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof RadioPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof SelectPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof TextPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof NumberPropertyItem => $propertyItem->getHtml($plugin, $section, $pluginName),
|
||||
$propertyItem instanceof BoolPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof HiddenPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof MessageOnlyPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof RadioPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof SelectPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof TextPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
$propertyItem instanceof NumberPropertyItem => $propertyItem->getHtml($plugin, $pluginType, $pluginName),
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
@ -388,13 +374,11 @@ class Plugins
|
||||
/**
|
||||
* Returns html div with editable options for plugin
|
||||
*
|
||||
* @param string $section name of config section in $cfg[$section]
|
||||
* @param ExportPlugin[]|ImportPlugin[]|SchemaPlugin[] $list array with plugin instances
|
||||
* @psalm-param 'Export'|'Import'|'Schema' $section
|
||||
* @param ExportPlugin[]|ImportPlugin[]|SchemaPlugin[] $list array with plugin instances
|
||||
*
|
||||
* @return string html fieldset with plugin options
|
||||
*/
|
||||
public static function getOptions(string $section, array $list): string
|
||||
public static function getOptions(PluginType $pluginType, array $list): string
|
||||
{
|
||||
$ret = '';
|
||||
// Options for plugins that support them
|
||||
@ -422,7 +406,7 @@ class Plugins
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= self::getOneOption($plugin, $section, $pluginName, $propertyMainGroup);
|
||||
$ret .= self::getOneOption($plugin, $pluginType, $pluginName, $propertyMainGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
src/Plugins/PluginType.php
Normal file
12
src/Plugins/PluginType.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins;
|
||||
|
||||
enum PluginType: string
|
||||
{
|
||||
case Export = 'Export';
|
||||
case Import = 'Import';
|
||||
case Schema = 'Schema';
|
||||
}
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
/**
|
||||
@ -13,7 +14,7 @@ use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
*/
|
||||
class BoolPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$ret = '<li class="list-group-item">' . "\n";
|
||||
$ret .= '<div class="form-check form-switch">' . "\n";
|
||||
@ -23,7 +24,7 @@ class BoolPropertyItem extends OptionsPropertyOneItem
|
||||
. $this->getName() . '"'
|
||||
. ' '
|
||||
. Plugins::checkboxCheck(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
);
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
use function htmlspecialchars;
|
||||
@ -15,13 +16,13 @@ use function htmlspecialchars;
|
||||
*/
|
||||
class HiddenPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
return '<li class="list-group-item"><input type="hidden" name="' . $pluginName . '_'
|
||||
. $this->getName() . '"'
|
||||
. ' value="'
|
||||
. htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
)))
|
||||
. '"></li>';
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
/**
|
||||
@ -13,7 +14,7 @@ use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
*/
|
||||
class MessageOnlyPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$ret = '<li class="list-group-item">' . "\n";
|
||||
$ret .= $plugin->getTranslatedText($this->getText() ?? '');
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
use function htmlspecialchars;
|
||||
@ -15,7 +16,7 @@ use function htmlspecialchars;
|
||||
*/
|
||||
class NumberPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$ret = '<li class="list-group-item">' . "\n";
|
||||
$ret .= '<label for="number_' . $pluginName . '_'
|
||||
@ -25,7 +26,7 @@ class NumberPropertyItem extends OptionsPropertyOneItem
|
||||
. $this->getName() . '"'
|
||||
. ' value="'
|
||||
. htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
))) . '"'
|
||||
. ' id="number_' . $pluginName . '_'
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
use function htmlspecialchars;
|
||||
@ -15,10 +16,10 @@ use function htmlspecialchars;
|
||||
*/
|
||||
class RadioPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$default = htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
)));
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
use function htmlspecialchars;
|
||||
@ -15,7 +16,7 @@ use function htmlspecialchars;
|
||||
*/
|
||||
class SelectPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$ret = '<li class="list-group-item">' . "\n";
|
||||
$ret .= '<label for="select_' . $pluginName . '_'
|
||||
@ -26,7 +27,7 @@ class SelectPropertyItem extends OptionsPropertyOneItem
|
||||
. ' id="select_' . $pluginName . '_'
|
||||
. $this->getName() . '">';
|
||||
$default = htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
)));
|
||||
foreach ($this->getValues() as $key => $val) {
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Properties\Options\Items;
|
||||
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Plugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
|
||||
|
||||
use function htmlspecialchars;
|
||||
@ -15,7 +16,7 @@ use function htmlspecialchars;
|
||||
*/
|
||||
class TextPropertyItem extends OptionsPropertyOneItem
|
||||
{
|
||||
public function getHtml(Plugin $plugin, string $section, string $pluginName): string
|
||||
public function getHtml(Plugin $plugin, PluginType $pluginType, string $pluginName): string
|
||||
{
|
||||
$ret = '<li class="list-group-item">' . "\n";
|
||||
$ret .= '<label for="text_' . $pluginName . '_'
|
||||
@ -25,7 +26,7 @@ class TextPropertyItem extends OptionsPropertyOneItem
|
||||
. $this->getName() . '"'
|
||||
. ' value="'
|
||||
. htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(
|
||||
$section,
|
||||
$pluginType,
|
||||
$pluginName . '_' . $this->getName(),
|
||||
))) . '"'
|
||||
. ' id="text_' . $pluginName . '_'
|
||||
|
||||
@ -21,6 +21,7 @@ use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
@ -82,7 +83,7 @@ class ExportControllerTest extends AbstractTestCase
|
||||
],
|
||||
'export_method' => 'quick',
|
||||
'plugins_choice' => Plugins::getChoice($exportList, 'sql'),
|
||||
'options' => Plugins::getOptions('Export', $exportList),
|
||||
'options' => Plugins::getOptions(PluginType::Export, $exportList),
|
||||
'can_convert_kanji' => false,
|
||||
'exec_time_limit' => 300,
|
||||
'rows' => [
|
||||
|
||||
@ -19,6 +19,7 @@ use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
@ -48,7 +49,7 @@ class ImportControllerTest extends AbstractTestCase
|
||||
ImportSettings::$importType = 'table';
|
||||
$importList = Plugins::getImport();
|
||||
$choice = Plugins::getChoice($importList, 'xml');
|
||||
$options = Plugins::getOptions('Import', $importList);
|
||||
$options = Plugins::getOptions(PluginType::Import, $importList);
|
||||
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), $template, $config, new Clock());
|
||||
|
||||
@ -18,6 +18,7 @@ use PhpMyAdmin\Export\TemplateModel;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
@ -110,7 +111,7 @@ class OptionsTest extends AbstractTestCase
|
||||
],
|
||||
'export_method' => $config->config->Export->method,
|
||||
'plugins_choice' => $dropdown,
|
||||
'options' => Plugins::getOptions('Export', $exportList),
|
||||
'options' => Plugins::getOptions(PluginType::Export, $exportList),
|
||||
'can_convert_kanji' => Encoding::canConvertKanji(),
|
||||
'exec_time_limit' => $config->settings['ExecTimeLimit'],
|
||||
'rows' => [],
|
||||
|
||||
@ -20,6 +20,7 @@ use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Plugins\Import\ImportSql;
|
||||
use PhpMyAdmin\Plugins\ImportPlugin;
|
||||
use PhpMyAdmin\Plugins\PluginType;
|
||||
use PhpMyAdmin\Plugins\Schema\SchemaPdf;
|
||||
use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
@ -66,13 +67,12 @@ class PluginsTest extends AbstractTestCase
|
||||
self::assertContainsOnlyInstancesOf(SchemaPlugin::class, $plugins);
|
||||
}
|
||||
|
||||
/** @psalm-param 'Export'|'Import'|'Schema' $section */
|
||||
#[DataProvider('providerForTestGetDefault')]
|
||||
public function testGetDefault(
|
||||
string $expected,
|
||||
string|int|null $actualConfig,
|
||||
string|null $actualGet,
|
||||
string $section,
|
||||
PluginType $pluginType,
|
||||
string $option,
|
||||
bool|null $timeoutPassed,
|
||||
): void {
|
||||
@ -85,30 +85,30 @@ class PluginsTest extends AbstractTestCase
|
||||
$_GET[$option] = $actualGet;
|
||||
}
|
||||
|
||||
Config::getInstance()->settings[$section][$option] = $actualConfig;
|
||||
$default = Plugins::getDefault($section, $option);
|
||||
Config::getInstance()->settings[$pluginType->value][$option] = $actualConfig;
|
||||
$default = Plugins::getDefault($pluginType, $option);
|
||||
self::assertSame($expected, $default);
|
||||
}
|
||||
|
||||
/** @return array<array{string, string|int|null, string|null, 'Export'|'Import'|'Schema', string, bool|null}> */
|
||||
/** @return array<array{string, string|int|null, string|null, PluginType, string, bool|null}> */
|
||||
public static function providerForTestGetDefault(): array
|
||||
{
|
||||
return [
|
||||
['xml', 'xml', null, 'Export', 'format', null],
|
||||
['xml', 'sql', 'xml', 'Export', 'format', null],
|
||||
['xml', null, 'xml', 'Export', 'format', null],
|
||||
['', null, null, 'Export', 'format', null],
|
||||
['xml', 'xml', null, PluginType::Export, 'format', null],
|
||||
['xml', 'sql', 'xml', PluginType::Export, 'format', null],
|
||||
['xml', null, 'xml', PluginType::Export, 'format', null],
|
||||
['', null, null, PluginType::Export, 'format', null],
|
||||
[
|
||||
'strLatexStructure strTest strLatexContinued',
|
||||
'strLatexStructure strTest strLatexContinued',
|
||||
null,
|
||||
'Export',
|
||||
PluginType::Export,
|
||||
'latex_structure_continued_caption',
|
||||
null,
|
||||
],
|
||||
['xml', 'sql', 'xml', 'Export', 'format', true],
|
||||
['sql', 'sql', 'xml', 'Export', 'format', false],
|
||||
['30', 30, null, 'Import', 'skip_queries', null],
|
||||
['xml', 'sql', 'xml', PluginType::Export, 'format', true],
|
||||
['sql', 'sql', 'xml', PluginType::Export, 'format', false],
|
||||
['30', 30, null, PluginType::Import, 'skip_queries', null],
|
||||
];
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ class PluginsTest extends AbstractTestCase
|
||||
ContainerBuilder::$container = $this->getContainerForGetOptions($this->createDatabaseInterface($dbiDummy));
|
||||
ImportSettings::$importType = 'table';
|
||||
|
||||
$options = Plugins::getOptions('Import', Plugins::getImport());
|
||||
$options = Plugins::getOptions(PluginType::Import, Plugins::getImport());
|
||||
$dbiDummy->assertAllQueriesConsumed();
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
@ -221,7 +221,7 @@ class PluginsTest extends AbstractTestCase
|
||||
{
|
||||
ContainerBuilder::$container = $this->getContainerForGetOptions($this->createDatabaseInterface());
|
||||
|
||||
$options = Plugins::getOptions('Export', Plugins::getExport(ExportType::Table, true));
|
||||
$options = Plugins::getOptions(PluginType::Export, Plugins::getExport(ExportType::Table, true));
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$expected = <<<'HTML'
|
||||
@ -452,7 +452,7 @@ class PluginsTest extends AbstractTestCase
|
||||
public function testGetOptionsForSchema(): void
|
||||
{
|
||||
ContainerBuilder::$container = $this->getContainerForGetOptions($this->createDatabaseInterface());
|
||||
$options = Plugins::getOptions('Schema', Plugins::getSchema());
|
||||
$options = Plugins::getOptions(PluginType::Schema, Plugins::getSchema());
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$expected = <<<'HTML'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user