Update website
This commit is contained in:
parent
bb4b0f9be8
commit
011b183e28
4263 changed files with 3014 additions and 720369 deletions
|
@ -1,205 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
use function in_array;
|
||||
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Console
|
||||
{
|
||||
/** @var bool */
|
||||
public $StartHistory;
|
||||
|
||||
/** @var bool */
|
||||
public $AlwaysExpand;
|
||||
|
||||
/** @var bool */
|
||||
public $CurrentQuery;
|
||||
|
||||
/** @var bool */
|
||||
public $EnterExecutes;
|
||||
|
||||
/** @var bool */
|
||||
public $DarkTheme;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'info'|'show'|'collapse'
|
||||
*/
|
||||
public $Mode;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @psalm-var positive-int
|
||||
*/
|
||||
public $Height;
|
||||
|
||||
/** @var bool */
|
||||
public $GroupQueries;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'exec'|'time'|'count'
|
||||
*/
|
||||
public $OrderBy;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'asc'|'desc'
|
||||
*/
|
||||
public $Order;
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
public function __construct(array $console = [])
|
||||
{
|
||||
$this->StartHistory = $this->setStartHistory($console);
|
||||
$this->AlwaysExpand = $this->setAlwaysExpand($console);
|
||||
$this->CurrentQuery = $this->setCurrentQuery($console);
|
||||
$this->EnterExecutes = $this->setEnterExecutes($console);
|
||||
$this->DarkTheme = $this->setDarkTheme($console);
|
||||
$this->Mode = $this->setMode($console);
|
||||
$this->Height = $this->setHeight($console);
|
||||
$this->GroupQueries = $this->setGroupQueries($console);
|
||||
$this->OrderBy = $this->setOrderBy($console);
|
||||
$this->Order = $this->setOrder($console);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setStartHistory(array $console): bool
|
||||
{
|
||||
if (isset($console['StartHistory'])) {
|
||||
return (bool) $console['StartHistory'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setAlwaysExpand(array $console): bool
|
||||
{
|
||||
if (isset($console['AlwaysExpand'])) {
|
||||
return (bool) $console['AlwaysExpand'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setCurrentQuery(array $console): bool
|
||||
{
|
||||
if (isset($console['CurrentQuery'])) {
|
||||
return (bool) $console['CurrentQuery'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setEnterExecutes(array $console): bool
|
||||
{
|
||||
if (isset($console['EnterExecutes'])) {
|
||||
return (bool) $console['EnterExecutes'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setDarkTheme(array $console): bool
|
||||
{
|
||||
if (isset($console['DarkTheme'])) {
|
||||
return (bool) $console['DarkTheme'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*
|
||||
* @psalm-return 'info'|'show'|'collapse'
|
||||
*/
|
||||
private function setMode(array $console): string
|
||||
{
|
||||
if (isset($console['Mode']) && in_array($console['Mode'], ['show', 'collapse'], true)) {
|
||||
return $console['Mode'];
|
||||
}
|
||||
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*
|
||||
* @psalm-return positive-int
|
||||
*/
|
||||
private function setHeight(array $console): int
|
||||
{
|
||||
if (isset($console['Height'])) {
|
||||
$height = (int) $console['Height'];
|
||||
if ($height >= 1) {
|
||||
return $height;
|
||||
}
|
||||
}
|
||||
|
||||
return 92;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*/
|
||||
private function setGroupQueries(array $console): bool
|
||||
{
|
||||
if (isset($console['GroupQueries'])) {
|
||||
return (bool) $console['GroupQueries'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*
|
||||
* @psalm-return 'exec'|'time'|'count'
|
||||
*/
|
||||
private function setOrderBy(array $console): string
|
||||
{
|
||||
if (isset($console['OrderBy']) && in_array($console['OrderBy'], ['time', 'count'], true)) {
|
||||
return $console['OrderBy'];
|
||||
}
|
||||
|
||||
return 'exec';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $console
|
||||
*
|
||||
* @psalm-return 'asc'|'desc'
|
||||
*/
|
||||
private function setOrder(array $console): string
|
||||
{
|
||||
if (isset($console['Order']) && $console['Order'] === 'desc') {
|
||||
return 'desc';
|
||||
}
|
||||
|
||||
return 'asc';
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Debug
|
||||
{
|
||||
/**
|
||||
* Output executed queries and their execution times.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $sql;
|
||||
|
||||
/**
|
||||
* Log executed queries and their execution times to syslog.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $sqllog;
|
||||
|
||||
/**
|
||||
* Enable to let server present itself as demo server.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $demo;
|
||||
|
||||
/**
|
||||
* Enable Simple two-factor authentication.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $simple2fa;
|
||||
|
||||
/**
|
||||
* @param mixed[] $debug
|
||||
*/
|
||||
public function __construct(array $debug = [])
|
||||
{
|
||||
$this->sql = $this->setSql($debug);
|
||||
$this->sqllog = $this->setSqlLog($debug);
|
||||
$this->demo = $this->setDemo($debug);
|
||||
$this->simple2fa = $this->setSimple2fa($debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $debug
|
||||
*/
|
||||
private function setSql(array $debug): bool
|
||||
{
|
||||
return isset($debug['sql']) && $debug['sql'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $debug
|
||||
*/
|
||||
private function setSqlLog(array $debug): bool
|
||||
{
|
||||
return isset($debug['sqllog']) && $debug['sqllog'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $debug
|
||||
*/
|
||||
private function setDemo(array $debug): bool
|
||||
{
|
||||
return isset($debug['demo']) && $debug['demo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $debug
|
||||
*/
|
||||
private function setSimple2fa(array $debug): bool
|
||||
{
|
||||
return isset($debug['simple2fa']) && $debug['simple2fa'];
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,489 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Import
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'csv'|'docsql'|'ldi'|'sql'
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/**
|
||||
* Default charset for import.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $charset;
|
||||
|
||||
/** @var bool */
|
||||
public $allow_interrupt;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @psalm-var 0|positive-int
|
||||
*/
|
||||
public $skip_queries;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'NONE'|'ANSI'|'DB2'|'MAXDB'|'MYSQL323'|'MYSQL40'|'MSSQL'|'ORACLE'|'TRADITIONAL'
|
||||
*/
|
||||
public $sql_compatibility;
|
||||
|
||||
/** @var bool */
|
||||
public $sql_no_auto_value_on_zero;
|
||||
|
||||
/** @var bool */
|
||||
public $sql_read_as_multibytes;
|
||||
|
||||
/** @var bool */
|
||||
public $csv_replace;
|
||||
|
||||
/** @var bool */
|
||||
public $csv_ignore;
|
||||
|
||||
/** @var string */
|
||||
public $csv_terminated;
|
||||
|
||||
/** @var string */
|
||||
public $csv_enclosed;
|
||||
|
||||
/** @var string */
|
||||
public $csv_escaped;
|
||||
|
||||
/** @var string */
|
||||
public $csv_new_line;
|
||||
|
||||
/** @var string */
|
||||
public $csv_columns;
|
||||
|
||||
/** @var bool */
|
||||
public $csv_col_names;
|
||||
|
||||
/** @var bool */
|
||||
public $ldi_replace;
|
||||
|
||||
/** @var bool */
|
||||
public $ldi_ignore;
|
||||
|
||||
/** @var string */
|
||||
public $ldi_terminated;
|
||||
|
||||
/** @var string */
|
||||
public $ldi_enclosed;
|
||||
|
||||
/** @var string */
|
||||
public $ldi_escaped;
|
||||
|
||||
/** @var string */
|
||||
public $ldi_new_line;
|
||||
|
||||
/** @var string */
|
||||
public $ldi_columns;
|
||||
|
||||
/**
|
||||
* 'auto' for auto-detection, true or false for forcing
|
||||
*
|
||||
* @var string|bool
|
||||
* @psalm-var 'auto'|bool
|
||||
*/
|
||||
public $ldi_local_option;
|
||||
|
||||
/** @var bool */
|
||||
public $ods_col_names;
|
||||
|
||||
/** @var bool */
|
||||
public $ods_empty_rows;
|
||||
|
||||
/** @var bool */
|
||||
public $ods_recognize_percentages;
|
||||
|
||||
/** @var bool */
|
||||
public $ods_recognize_currency;
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
public function __construct(array $import = [])
|
||||
{
|
||||
$this->format = $this->setFormat($import);
|
||||
$this->charset = $this->setCharset($import);
|
||||
$this->allow_interrupt = $this->setAllowInterrupt($import);
|
||||
$this->skip_queries = $this->setSkipQueries($import);
|
||||
$this->sql_compatibility = $this->setSqlCompatibility($import);
|
||||
$this->sql_no_auto_value_on_zero = $this->setSqlNoAutoValueOnZero($import);
|
||||
$this->sql_read_as_multibytes = $this->setSqlReadAsMultibytes($import);
|
||||
$this->csv_replace = $this->setCsvReplace($import);
|
||||
$this->csv_ignore = $this->setCsvIgnore($import);
|
||||
$this->csv_terminated = $this->setCsvTerminated($import);
|
||||
$this->csv_enclosed = $this->setCsvEnclosed($import);
|
||||
$this->csv_escaped = $this->setCsvEscaped($import);
|
||||
$this->csv_new_line = $this->setCsvNewLine($import);
|
||||
$this->csv_columns = $this->setCsvColumns($import);
|
||||
$this->csv_col_names = $this->setCsvColNames($import);
|
||||
$this->ldi_replace = $this->setLdiReplace($import);
|
||||
$this->ldi_ignore = $this->setLdiIgnore($import);
|
||||
$this->ldi_terminated = $this->setLdiTerminated($import);
|
||||
$this->ldi_enclosed = $this->setLdiEnclosed($import);
|
||||
$this->ldi_escaped = $this->setLdiEscaped($import);
|
||||
$this->ldi_new_line = $this->setLdiNewLine($import);
|
||||
$this->ldi_columns = $this->setLdiColumns($import);
|
||||
$this->ldi_local_option = $this->setLdiLocalOption($import);
|
||||
$this->ods_col_names = $this->setOdsColNames($import);
|
||||
$this->ods_empty_rows = $this->setOdsEmptyRows($import);
|
||||
$this->ods_recognize_percentages = $this->setOdsRecognizePercentages($import);
|
||||
$this->ods_recognize_currency = $this->setOdsRecognizeCurrency($import);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*
|
||||
* @psalm-return 'csv'|'docsql'|'ldi'|'sql'
|
||||
*/
|
||||
private function setFormat(array $import): string
|
||||
{
|
||||
if (! isset($import['format']) || ! in_array($import['format'], ['csv', 'docsql', 'ldi'], true)) {
|
||||
return 'sql';
|
||||
}
|
||||
|
||||
return $import['format'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCharset(array $import): string
|
||||
{
|
||||
if (! isset($import['charset'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string) $import['charset'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setAllowInterrupt(array $import): bool
|
||||
{
|
||||
if (! isset($import['allow_interrupt'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (bool) $import['allow_interrupt'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*
|
||||
* @psalm-return 0|positive-int
|
||||
*/
|
||||
private function setSkipQueries(array $import): int
|
||||
{
|
||||
if (! isset($import['skip_queries'])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$skipQueries = (int) $import['skip_queries'];
|
||||
|
||||
return $skipQueries >= 1 ? $skipQueries : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*
|
||||
* @psalm-return 'NONE'|'ANSI'|'DB2'|'MAXDB'|'MYSQL323'|'MYSQL40'|'MSSQL'|'ORACLE'|'TRADITIONAL'
|
||||
*/
|
||||
private function setSqlCompatibility(array $import): string
|
||||
{
|
||||
if (
|
||||
! isset($import['sql_compatibility']) || ! in_array(
|
||||
$import['sql_compatibility'],
|
||||
['ANSI', 'DB2', 'MAXDB', 'MYSQL323', 'MYSQL40', 'MSSQL', 'ORACLE', 'TRADITIONAL'],
|
||||
true
|
||||
)
|
||||
) {
|
||||
return 'NONE';
|
||||
}
|
||||
|
||||
return $import['sql_compatibility'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setSqlNoAutoValueOnZero(array $import): bool
|
||||
{
|
||||
if (! isset($import['sql_no_auto_value_on_zero'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (bool) $import['sql_no_auto_value_on_zero'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setSqlReadAsMultibytes(array $import): bool
|
||||
{
|
||||
if (! isset($import['sql_read_as_multibytes'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['sql_read_as_multibytes'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvReplace(array $import): bool
|
||||
{
|
||||
if (! isset($import['csv_replace'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['csv_replace'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvIgnore(array $import): bool
|
||||
{
|
||||
if (! isset($import['csv_ignore'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['csv_ignore'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvTerminated(array $import): string
|
||||
{
|
||||
if (! isset($import['csv_terminated'])) {
|
||||
return ',';
|
||||
}
|
||||
|
||||
return (string) $import['csv_terminated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvEnclosed(array $import): string
|
||||
{
|
||||
if (! isset($import['csv_enclosed'])) {
|
||||
return '"';
|
||||
}
|
||||
|
||||
return (string) $import['csv_enclosed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvEscaped(array $import): string
|
||||
{
|
||||
if (! isset($import['csv_escaped'])) {
|
||||
return '"';
|
||||
}
|
||||
|
||||
return (string) $import['csv_escaped'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvNewLine(array $import): string
|
||||
{
|
||||
if (! isset($import['csv_new_line'])) {
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
return (string) $import['csv_new_line'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvColumns(array $import): string
|
||||
{
|
||||
if (! isset($import['csv_columns'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string) $import['csv_columns'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setCsvColNames(array $import): bool
|
||||
{
|
||||
if (! isset($import['csv_col_names'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['csv_col_names'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiReplace(array $import): bool
|
||||
{
|
||||
if (! isset($import['ldi_replace'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['ldi_replace'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiIgnore(array $import): bool
|
||||
{
|
||||
if (! isset($import['ldi_ignore'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['ldi_ignore'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiTerminated(array $import): string
|
||||
{
|
||||
if (! isset($import['ldi_terminated'])) {
|
||||
return ';';
|
||||
}
|
||||
|
||||
return (string) $import['ldi_terminated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiEnclosed(array $import): string
|
||||
{
|
||||
if (! isset($import['ldi_enclosed'])) {
|
||||
return '"';
|
||||
}
|
||||
|
||||
return (string) $import['ldi_enclosed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiEscaped(array $import): string
|
||||
{
|
||||
if (! isset($import['ldi_escaped'])) {
|
||||
return '\\';
|
||||
}
|
||||
|
||||
return (string) $import['ldi_escaped'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiNewLine(array $import): string
|
||||
{
|
||||
if (! isset($import['ldi_new_line'])) {
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
return (string) $import['ldi_new_line'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setLdiColumns(array $import): string
|
||||
{
|
||||
if (! isset($import['ldi_columns'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string) $import['ldi_columns'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*
|
||||
* @return bool|string
|
||||
* @psalm-return 'auto'|bool
|
||||
*/
|
||||
private function setLdiLocalOption(array $import)
|
||||
{
|
||||
if (! isset($import['ldi_local_option']) || $import['ldi_local_option'] === 'auto') {
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
return (bool) $import['ldi_local_option'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setOdsColNames(array $import): bool
|
||||
{
|
||||
if (! isset($import['ods_col_names'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $import['ods_col_names'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setOdsEmptyRows(array $import): bool
|
||||
{
|
||||
if (! isset($import['ods_empty_rows'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (bool) $import['ods_empty_rows'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setOdsRecognizePercentages(array $import): bool
|
||||
{
|
||||
if (! isset($import['ods_recognize_percentages'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (bool) $import['ods_recognize_percentages'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*/
|
||||
private function setOdsRecognizeCurrency(array $import): bool
|
||||
{
|
||||
if (! isset($import['ods_recognize_currency'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (bool) $import['ods_recognize_currency'];
|
||||
}
|
||||
}
|
|
@ -1,369 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Schema
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'pdf'|'eps'|'dia'|'svg'
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/** @var bool */
|
||||
public $pdf_show_color;
|
||||
|
||||
/** @var bool */
|
||||
public $pdf_show_keys;
|
||||
|
||||
/** @var bool */
|
||||
public $pdf_all_tables_same_width;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'L'|'P'
|
||||
*/
|
||||
public $pdf_orientation;
|
||||
|
||||
/** @var string */
|
||||
public $pdf_paper;
|
||||
|
||||
/** @var bool */
|
||||
public $pdf_show_grid;
|
||||
|
||||
/** @var bool */
|
||||
public $pdf_with_doc;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var ''|'name_asc'|'name_desc'
|
||||
*/
|
||||
public $pdf_table_order;
|
||||
|
||||
/** @var bool */
|
||||
public $dia_show_color;
|
||||
|
||||
/** @var bool */
|
||||
public $dia_show_keys;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'L'|'P'
|
||||
*/
|
||||
public $dia_orientation;
|
||||
|
||||
/** @var string */
|
||||
public $dia_paper;
|
||||
|
||||
/** @var bool */
|
||||
public $eps_show_color;
|
||||
|
||||
/** @var bool */
|
||||
public $eps_show_keys;
|
||||
|
||||
/** @var bool */
|
||||
public $eps_all_tables_same_width;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var 'L'|'P'
|
||||
*/
|
||||
public $eps_orientation;
|
||||
|
||||
/** @var bool */
|
||||
public $svg_show_color;
|
||||
|
||||
/** @var bool */
|
||||
public $svg_show_keys;
|
||||
|
||||
/** @var bool */
|
||||
public $svg_all_tables_same_width;
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
public function __construct(array $schema = [])
|
||||
{
|
||||
$this->format = $this->setFormat($schema);
|
||||
$this->pdf_show_color = $this->setPdfShowColor($schema);
|
||||
$this->pdf_show_keys = $this->setPdfShowKeys($schema);
|
||||
$this->pdf_all_tables_same_width = $this->setPdfAllTablesSameWidth($schema);
|
||||
$this->pdf_orientation = $this->setPdfOrientation($schema);
|
||||
$this->pdf_paper = $this->setPdfPaper($schema);
|
||||
$this->pdf_show_grid = $this->setPdfShowGrid($schema);
|
||||
$this->pdf_with_doc = $this->setPdfWithDoc($schema);
|
||||
$this->pdf_table_order = $this->setPdfTableOrder($schema);
|
||||
$this->dia_show_color = $this->setDiaShowColor($schema);
|
||||
$this->dia_show_keys = $this->setDiaShowKeys($schema);
|
||||
$this->dia_orientation = $this->setDiaOrientation($schema);
|
||||
$this->dia_paper = $this->setDiaPaper($schema);
|
||||
$this->eps_show_color = $this->setEpsShowColor($schema);
|
||||
$this->eps_show_keys = $this->setEpsShowKeys($schema);
|
||||
$this->eps_all_tables_same_width = $this->setEpsAllTablesSameWidth($schema);
|
||||
$this->eps_orientation = $this->setEpsOrientation($schema);
|
||||
$this->svg_show_color = $this->setSvgShowColor($schema);
|
||||
$this->svg_show_keys = $this->setSvgShowKeys($schema);
|
||||
$this->svg_all_tables_same_width = $this->setSvgAllTablesSameWidth($schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*
|
||||
* @psalm-return 'pdf'|'eps'|'dia'|'svg'
|
||||
*/
|
||||
private function setFormat(array $schema): string
|
||||
{
|
||||
if (isset($schema['format']) && in_array($schema['format'], ['eps', 'dia', 'svg'], true)) {
|
||||
return $schema['format'];
|
||||
}
|
||||
|
||||
return 'pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfShowColor(array $schema): bool
|
||||
{
|
||||
if (isset($schema['pdf_show_color'])) {
|
||||
return (bool) $schema['pdf_show_color'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfShowKeys(array $schema): bool
|
||||
{
|
||||
if (isset($schema['pdf_show_keys'])) {
|
||||
return (bool) $schema['pdf_show_keys'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfAllTablesSameWidth(array $schema): bool
|
||||
{
|
||||
if (isset($schema['pdf_all_tables_same_width'])) {
|
||||
return (bool) $schema['pdf_all_tables_same_width'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*
|
||||
* @psalm-return 'L'|'P'
|
||||
*/
|
||||
private function setPdfOrientation(array $schema): string
|
||||
{
|
||||
if (isset($schema['pdf_orientation']) && $schema['pdf_orientation'] === 'P') {
|
||||
return 'P';
|
||||
}
|
||||
|
||||
return 'L';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfPaper(array $schema): string
|
||||
{
|
||||
if (isset($schema['pdf_paper'])) {
|
||||
return (string) $schema['pdf_paper'];
|
||||
}
|
||||
|
||||
return 'A4';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfShowGrid(array $schema): bool
|
||||
{
|
||||
if (isset($schema['pdf_show_grid'])) {
|
||||
return (bool) $schema['pdf_show_grid'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setPdfWithDoc(array $schema): bool
|
||||
{
|
||||
if (isset($schema['pdf_with_doc'])) {
|
||||
return (bool) $schema['pdf_with_doc'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*
|
||||
* @psalm-return ''|'name_asc'|'name_desc'
|
||||
*/
|
||||
private function setPdfTableOrder(array $schema): string
|
||||
{
|
||||
if (
|
||||
isset($schema['pdf_table_order']) && in_array($schema['pdf_table_order'], ['name_asc', 'name_desc'], true)
|
||||
) {
|
||||
return $schema['pdf_table_order'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setDiaShowColor(array $schema): bool
|
||||
{
|
||||
if (isset($schema['dia_show_color'])) {
|
||||
return (bool) $schema['dia_show_color'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setDiaShowKeys(array $schema): bool
|
||||
{
|
||||
if (isset($schema['dia_show_keys'])) {
|
||||
return (bool) $schema['dia_show_keys'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*
|
||||
* @psalm-return 'L'|'P'
|
||||
*/
|
||||
private function setDiaOrientation(array $schema): string
|
||||
{
|
||||
if (isset($schema['dia_orientation']) && $schema['dia_orientation'] === 'P') {
|
||||
return 'P';
|
||||
}
|
||||
|
||||
return 'L';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setDiaPaper(array $schema): string
|
||||
{
|
||||
if (isset($schema['dia_paper'])) {
|
||||
return (string) $schema['dia_paper'];
|
||||
}
|
||||
|
||||
return 'A4';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setEpsShowColor(array $schema): bool
|
||||
{
|
||||
if (isset($schema['eps_show_color'])) {
|
||||
return (bool) $schema['eps_show_color'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setEpsShowKeys(array $schema): bool
|
||||
{
|
||||
if (isset($schema['eps_show_keys'])) {
|
||||
return (bool) $schema['eps_show_keys'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setEpsAllTablesSameWidth(array $schema): bool
|
||||
{
|
||||
if (isset($schema['eps_all_tables_same_width'])) {
|
||||
return (bool) $schema['eps_all_tables_same_width'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*
|
||||
* @psalm-return 'L'|'P'
|
||||
*/
|
||||
private function setEpsOrientation(array $schema): string
|
||||
{
|
||||
if (isset($schema['eps_orientation']) && $schema['eps_orientation'] === 'P') {
|
||||
return 'P';
|
||||
}
|
||||
|
||||
return 'L';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setSvgShowColor(array $schema): bool
|
||||
{
|
||||
if (isset($schema['svg_show_color'])) {
|
||||
return (bool) $schema['svg_show_color'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setSvgShowKeys(array $schema): bool
|
||||
{
|
||||
if (isset($schema['svg_show_keys'])) {
|
||||
return (bool) $schema['svg_show_keys'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $schema
|
||||
*/
|
||||
private function setSvgAllTablesSameWidth(array $schema): bool
|
||||
{
|
||||
if (isset($schema['svg_all_tables_same_width'])) {
|
||||
return (bool) $schema['svg_all_tables_same_width'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class SqlQueryBox
|
||||
{
|
||||
/**
|
||||
* Display an "Edit" link on the results page to change a query.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $Edit;
|
||||
|
||||
/**
|
||||
* Display an "Explain SQL" link on the results page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $Explain;
|
||||
|
||||
/**
|
||||
* Display a "Create PHP code" link on the results page to wrap a query in PHP.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $ShowAsPHP;
|
||||
|
||||
/**
|
||||
* Display a "Refresh" link on the results page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $Refresh;
|
||||
|
||||
/**
|
||||
* @param mixed[] $sqlQueryBox
|
||||
*/
|
||||
public function __construct(array $sqlQueryBox = [])
|
||||
{
|
||||
$this->Edit = $this->setEdit($sqlQueryBox);
|
||||
$this->Explain = $this->setExplain($sqlQueryBox);
|
||||
$this->ShowAsPHP = $this->setShowAsPHP($sqlQueryBox);
|
||||
$this->Refresh = $this->setRefresh($sqlQueryBox);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $sqlQueryBox
|
||||
*/
|
||||
private function setEdit(array $sqlQueryBox): bool
|
||||
{
|
||||
return ! isset($sqlQueryBox['Edit']) || $sqlQueryBox['Edit'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $sqlQueryBox
|
||||
*/
|
||||
private function setExplain(array $sqlQueryBox): bool
|
||||
{
|
||||
return ! isset($sqlQueryBox['Explain']) || $sqlQueryBox['Explain'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $sqlQueryBox
|
||||
*/
|
||||
private function setShowAsPHP(array $sqlQueryBox): bool
|
||||
{
|
||||
return ! isset($sqlQueryBox['ShowAsPHP']) || $sqlQueryBox['ShowAsPHP'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $sqlQueryBox
|
||||
*/
|
||||
private function setRefresh(array $sqlQueryBox): bool
|
||||
{
|
||||
return ! isset($sqlQueryBox['Refresh']) || $sqlQueryBox['Refresh'];
|
||||
}
|
||||
}
|
|
@ -1,391 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config\Settings;
|
||||
|
||||
use function is_array;
|
||||
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Transformations
|
||||
{
|
||||
/**
|
||||
* Displays a part of a string.
|
||||
* - The first option is the number of characters to skip from the beginning of the string (Default 0).
|
||||
* - The second option is the number of characters to return (Default: until end of string).
|
||||
* - The third option is the string to append and/or prepend when truncation occurs (Default: "…").
|
||||
*
|
||||
* @var array<int, int|string>
|
||||
* @psalm-var array{0: int, 1: 'all'|int, 2: string}
|
||||
*/
|
||||
public $Substring;
|
||||
|
||||
/**
|
||||
* Converts Boolean values to text (default 'T' and 'F').
|
||||
* - First option is for TRUE, second for FALSE. Nonzero=true.
|
||||
*
|
||||
* @var string[]
|
||||
* @psalm-var array{0: string, 1: string}
|
||||
*/
|
||||
public $Bool2Text;
|
||||
|
||||
/**
|
||||
* LINUX ONLY: Launches an external application and feeds it the column data via standard input.
|
||||
* Returns the standard output of the application. The default is Tidy, to pretty-print HTML code.
|
||||
* For security reasons, you have to manually edit the file
|
||||
* libraries/classes/Plugins/Transformations/Abs/ExternalTransformationsPlugin.php and list the tools
|
||||
* you want to make available.
|
||||
* - The first option is then the number of the program you want to use.
|
||||
* - The second option should be blank for historical reasons.
|
||||
* - The third option, if set to 1, will convert the output using htmlspecialchars() (Default 1).
|
||||
* - The fourth option, if set to 1, will prevent wrapping and ensure that the output appears
|
||||
* all on one line (Default 1).
|
||||
*
|
||||
* @var array<int, int|string>
|
||||
* @psalm-var array{0: int, 1: string, 2: int, 3: int}
|
||||
*/
|
||||
public $External;
|
||||
|
||||
/**
|
||||
* Prepends and/or Appends text to a string.
|
||||
* - First option is text to be prepended. second is appended (enclosed in single quotes, default empty string).
|
||||
*
|
||||
* @var string[]
|
||||
* @psalm-var array{0: string, 1: string}
|
||||
*/
|
||||
public $PreApPend;
|
||||
|
||||
/**
|
||||
* Displays hexadecimal representation of data.
|
||||
* Optional first parameter specifies how often space will be added (defaults to 2 nibbles).
|
||||
*
|
||||
* @var string[]
|
||||
* @psalm-var array{0: 0|positive-int}
|
||||
*/
|
||||
public $Hex;
|
||||
|
||||
/**
|
||||
* Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp column as formatted date.
|
||||
* - The first option is the offset (in hours) which will be added to the timestamp (Default: 0).
|
||||
* - Use second option to specify a different date/time format string.
|
||||
* - Third option determines whether you want to see local date or UTC one (use "local" or "utc" strings) for that.
|
||||
* According to that, date format has different value - for "local" see the documentation
|
||||
* for PHP's strftime() function and for "utc" it is done using gmdate() function.
|
||||
*
|
||||
* @var array<int, int|string>
|
||||
* @psalm-var array{0: 0|positive-int, 1: string, 2: 'local'|'utc'}
|
||||
*/
|
||||
public $DateFormat;
|
||||
|
||||
/**
|
||||
* Displays a clickable thumbnail.
|
||||
* The options are the maximum width and height in pixels.
|
||||
* The original aspect ratio is preserved.
|
||||
*
|
||||
* @var array<(int|string), (int|string|array<string, string>|null)>
|
||||
* @psalm-var array{
|
||||
* 0: 0|positive-int,
|
||||
* 1: 0|positive-int,
|
||||
* wrapper_link: string|null,
|
||||
* wrapper_params: array<array-key, string>
|
||||
* }
|
||||
*/
|
||||
public $Inline;
|
||||
|
||||
/**
|
||||
* Displays an image and a link; the column contains the filename.
|
||||
* - The first option is a URL prefix like "https://www.example.com/".
|
||||
* - The second and third options are the width and the height in pixels.
|
||||
*
|
||||
* @var array<int, int|string|null>
|
||||
* @psalm-var array{0: string|null, 1: 0|positive-int, 2: 0|positive-int}
|
||||
*/
|
||||
public $TextImageLink;
|
||||
|
||||
/**
|
||||
* Displays a link; the column contains the filename.
|
||||
* - The first option is a URL prefix like "https://www.example.com/".
|
||||
* - The second option is a title for the link.
|
||||
*
|
||||
* @var array<int, string|null>
|
||||
* @psalm-var array{0: string|null, 1: string|null, 2: bool|null}
|
||||
*/
|
||||
public $TextLink;
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*/
|
||||
public function __construct(array $transformations = [])
|
||||
{
|
||||
$this->Substring = $this->setSubstring($transformations);
|
||||
$this->Bool2Text = $this->setBool2Text($transformations);
|
||||
$this->External = $this->setExternal($transformations);
|
||||
$this->PreApPend = $this->setPreApPend($transformations);
|
||||
$this->Hex = $this->setHex($transformations);
|
||||
$this->DateFormat = $this->setDateFormat($transformations);
|
||||
$this->Inline = $this->setInline($transformations);
|
||||
$this->TextImageLink = $this->setTextImageLink($transformations);
|
||||
$this->TextLink = $this->setTextLink($transformations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<int, int|string>
|
||||
* @psalm-return array{0: int, 1: 'all'|int, 2: string}
|
||||
*/
|
||||
private function setSubstring(array $transformations): array
|
||||
{
|
||||
$substring = [0, 'all', '…'];
|
||||
if (isset($transformations['Substring']) && is_array($transformations['Substring'])) {
|
||||
if (isset($transformations['Substring'][0])) {
|
||||
$substring[0] = (int) $transformations['Substring'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['Substring'][1]) && $transformations['Substring'][1] !== 'all') {
|
||||
$substring[1] = (int) $transformations['Substring'][1];
|
||||
}
|
||||
|
||||
if (isset($transformations['Substring'][2])) {
|
||||
$substring[2] = (string) $transformations['Substring'][2];
|
||||
}
|
||||
}
|
||||
|
||||
return $substring;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return array{0: string, 1: string}
|
||||
*/
|
||||
private function setBool2Text(array $transformations): array
|
||||
{
|
||||
$bool2Text = ['T', 'F'];
|
||||
if (isset($transformations['Bool2Text']) && is_array($transformations['Bool2Text'])) {
|
||||
if (isset($transformations['Bool2Text'][0])) {
|
||||
$bool2Text[0] = (string) $transformations['Bool2Text'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['Bool2Text'][1])) {
|
||||
$bool2Text[1] = (string) $transformations['Bool2Text'][1];
|
||||
}
|
||||
}
|
||||
|
||||
return $bool2Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<int, int|string>
|
||||
* @psalm-return array{0: int, 1: string, 2: int, 3: int}
|
||||
*/
|
||||
private function setExternal(array $transformations): array
|
||||
{
|
||||
$external = [0, '-f /dev/null -i -wrap -q', 1, 1];
|
||||
if (isset($transformations['External']) && is_array($transformations['External'])) {
|
||||
if (isset($transformations['External'][0])) {
|
||||
$external[0] = (int) $transformations['External'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['External'][1])) {
|
||||
$external[1] = (string) $transformations['External'][1];
|
||||
}
|
||||
|
||||
if (isset($transformations['External'][2])) {
|
||||
$external[2] = (int) $transformations['External'][2];
|
||||
}
|
||||
|
||||
if (isset($transformations['External'][3])) {
|
||||
$external[3] = (int) $transformations['External'][3];
|
||||
}
|
||||
}
|
||||
|
||||
return $external;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return array{0: string, 1: string}
|
||||
*/
|
||||
private function setPreApPend(array $transformations): array
|
||||
{
|
||||
$preApPend = ['', ''];
|
||||
if (isset($transformations['PreApPend']) && is_array($transformations['PreApPend'])) {
|
||||
if (isset($transformations['PreApPend'][0])) {
|
||||
$preApPend[0] = (string) $transformations['PreApPend'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['PreApPend'][1])) {
|
||||
$preApPend[1] = (string) $transformations['PreApPend'][1];
|
||||
}
|
||||
}
|
||||
|
||||
return $preApPend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return array{0: 0|positive-int}
|
||||
*/
|
||||
private function setHex(array $transformations): array
|
||||
{
|
||||
if (isset($transformations['Hex']) && is_array($transformations['Hex'])) {
|
||||
if (isset($transformations['Hex'][0])) {
|
||||
$length = (int) $transformations['Hex'][0];
|
||||
if ($length >= 0) {
|
||||
return [$length];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [2];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<int, int|string>
|
||||
* @psalm-return array{0: 0|positive-int, 1: string, 2: 'local'|'utc'}
|
||||
*/
|
||||
private function setDateFormat(array $transformations): array
|
||||
{
|
||||
$dateFormat = [0, '', 'local'];
|
||||
if (isset($transformations['DateFormat']) && is_array($transformations['DateFormat'])) {
|
||||
if (isset($transformations['DateFormat'][0])) {
|
||||
$offset = (int) $transformations['DateFormat'][0];
|
||||
if ($offset >= 1) {
|
||||
$dateFormat[0] = $offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($transformations['DateFormat'][1])) {
|
||||
$dateFormat[1] = (string) $transformations['DateFormat'][1];
|
||||
}
|
||||
|
||||
if (isset($transformations['DateFormat'][2]) && $transformations['DateFormat'][2] === 'utc') {
|
||||
$dateFormat[2] = 'utc';
|
||||
}
|
||||
}
|
||||
|
||||
return $dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<(int|string), (int|string|array<string, string>|null)>
|
||||
* @psalm-return array{
|
||||
* 0: 0|positive-int,
|
||||
* 1: 0|positive-int,
|
||||
* wrapper_link: string|null,
|
||||
* wrapper_params: array<array-key, string>
|
||||
* }
|
||||
*/
|
||||
private function setInline(array $transformations): array
|
||||
{
|
||||
$inline = [100, 100, 'wrapper_link' => null, 'wrapper_params' => []];
|
||||
if (isset($transformations['Inline']) && is_array($transformations['Inline'])) {
|
||||
if (isset($transformations['Inline'][0])) {
|
||||
$width = (int) $transformations['Inline'][0];
|
||||
if ($width >= 0) {
|
||||
$inline[0] = $width;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($transformations['Inline'][1])) {
|
||||
$height = (int) $transformations['Inline'][1];
|
||||
if ($height >= 0) {
|
||||
$inline[1] = $height;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($transformations['Inline']['wrapper_link'])) {
|
||||
$inline['wrapper_link'] = (string) $transformations['Inline']['wrapper_link'];
|
||||
}
|
||||
|
||||
if (
|
||||
isset($transformations['Inline']['wrapper_params'])
|
||||
&& is_array($transformations['Inline']['wrapper_params'])
|
||||
) {
|
||||
/**
|
||||
* @var int|string $key
|
||||
* @var mixed $value
|
||||
*/
|
||||
foreach ($transformations['Inline']['wrapper_params'] as $key => $value) {
|
||||
$inline['wrapper_params'][$key] = (string) $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $inline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<int, int|string|null>
|
||||
* @psalm-return array{0: string|null, 1: 0|positive-int, 2: 0|positive-int}
|
||||
*/
|
||||
private function setTextImageLink(array $transformations): array
|
||||
{
|
||||
$textImageLink = [null, 100, 50];
|
||||
if (isset($transformations['TextImageLink']) && is_array($transformations['TextImageLink'])) {
|
||||
if (isset($transformations['TextImageLink'][0])) {
|
||||
$textImageLink[0] = (string) $transformations['TextImageLink'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['TextImageLink'][1])) {
|
||||
$width = (int) $transformations['TextImageLink'][1];
|
||||
if ($width >= 0) {
|
||||
$textImageLink[1] = $width;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($transformations['TextImageLink'][2])) {
|
||||
$height = (int) $transformations['TextImageLink'][2];
|
||||
if ($height >= 0) {
|
||||
$textImageLink[2] = $height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $textImageLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $transformations
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
* @psalm-return array{0: string|null, 1: string|null, 2: bool|null}
|
||||
*/
|
||||
private function setTextLink(array $transformations): array
|
||||
{
|
||||
$textLink = [null, null, null];
|
||||
if (isset($transformations['TextLink']) && is_array($transformations['TextLink'])) {
|
||||
if (isset($transformations['TextLink'][0])) {
|
||||
$textLink[0] = (string) $transformations['TextLink'][0];
|
||||
}
|
||||
|
||||
if (isset($transformations['TextLink'][1])) {
|
||||
$textLink[1] = (string) $transformations['TextLink'][1];
|
||||
}
|
||||
|
||||
if (isset($transformations['TextLink'][2])) {
|
||||
$textLink[2] = (bool) $transformations['TextLink'][2];
|
||||
}
|
||||
}
|
||||
|
||||
return $textLink;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue