Update website

This commit is contained in:
Guilhem Lavaux 2025-03-24 09:27:39 +01:00
parent a0b0d3dae7
commit ae7ef6ad45
3151 changed files with 566766 additions and 48 deletions

View file

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class CoreExtension extends AbstractExtension
{
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'link',
'PhpMyAdmin\Core::linkURL'
),
];
}
}

View file

@ -0,0 +1,156 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig\I18n;
use PhpMyAdmin\Twig\Extensions\Node\TransNode;
use Twig\Compiler;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Node;
use function array_merge;
use function str_replace;
use function trim;
class NodeTrans extends TransNode
{
/**
* The nodes are automatically made available as properties ($this->node).
* The attributes are automatically made available as array items ($this['name']).
*
* @param Node $body Body of node trans
* @param Node|null $plural Node plural
* @param AbstractExpression $count Node count
* @param Node|null $context Node context
* @param Node|null $notes Node notes
* @param int $lineno The line number
* @param string $tag The tag name associated with the Node
*/
public function __construct(
Node $body,
?Node $plural,
?AbstractExpression $count,
?Node $context,
?Node $notes,
int $lineno,
string $tag
) {
$nodes = ['body' => $body];
if ($count !== null) {
$nodes['count'] = $count;
}
if ($plural !== null) {
$nodes['plural'] = $plural;
}
if ($context !== null) {
$nodes['context'] = $context;
}
if ($notes !== null) {
$nodes['notes'] = $notes;
}
Node::__construct($nodes, [], $lineno, $tag);
}
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler Node compiler
*
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);
[$msg, $vars] = $this->compileString($this->getNode('body'));
$msg1 = null;
if ($this->hasNode('plural')) {
[$msg1, $vars1] = $this->compileString($this->getNode('plural'));
$vars = array_merge($vars, $vars1);
}
$function = $this->getTransFunction(
$this->hasNode('plural'),
$this->hasNode('context')
);
if ($this->hasNode('notes')) {
$message = trim($this->getNode('notes')->getAttribute('data'));
// line breaks are not allowed cause we want a single line comment
$message = str_replace(["\n", "\r"], ' ', $message);
$compiler->write('// l10n: ' . $message . "\n");
}
if ($vars) {
$compiler
->write('echo strtr(' . $function . '(')
->subcompile($msg);
if ($this->hasNode('plural')) {
$compiler
->raw(', ')
->subcompile($msg1)
->raw(', abs(')
->subcompile($this->hasNode('count') ? $this->getNode('count') : null)
->raw(')');
}
$compiler->raw('), array(');
foreach ($vars as $var) {
if ($var->getAttribute('name') === 'count') {
$compiler
->string('%count%')
->raw(' => abs(')
->subcompile($this->hasNode('count') ? $this->getNode('count') : null)
->raw('), ');
} else {
$compiler
->string('%' . $var->getAttribute('name') . '%')
->raw(' => ')
->subcompile($var)
->raw(', ');
}
}
$compiler->raw("));\n");
} else {
$compiler->write('echo ' . $function . '(');
if ($this->hasNode('context')) {
$context = trim($this->getNode('context')->getAttribute('data'));
$compiler->write('"' . $context . '", ');
}
$compiler->subcompile($msg);
if ($this->hasNode('plural')) {
$compiler
->raw(', ')
->subcompile($msg1)
->raw(', abs(')
->subcompile($this->hasNode('count') ? $this->getNode('count') : null)
->raw(')');
}
$compiler->raw(");\n");
}
}
/**
* @param bool $plural Return plural or singular function to use
* @param bool $hasMsgContext It has message context?
*/
protected function getTransFunction($plural, bool $hasMsgContext = false): string
{
if ($hasMsgContext) {
return $plural ? '_ngettext' : '_pgettext';
}
return $plural ? '_ngettext' : '_gettext';
}
}

View file

@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig\I18n;
use PhpMyAdmin\Twig\Extensions\TokenParser\TransTokenParser;
use Twig\Error\SyntaxError;
use Twig\Token;
class TokenParserTrans extends TransTokenParser
{
/**
* Parses a token and returns a node.
*
* @param Token $token Twig token to parse
*
* @return NodeTrans
*
* @throws SyntaxError
*/
public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$count = null;
$plural = null;
$notes = null;
$context = null;
if (! $stream->test(Token::BLOCK_END_TYPE)) {
$body = $this->parser->getExpressionParser()->parseExpression();
} else {
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse([$this, 'decideForFork']);
$next = $stream->next()->getValue();
if ($next === 'plural') {
$count = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Token::BLOCK_END_TYPE);
$plural = $this->parser->subparse([$this, 'decideForFork']);
if ($stream->next()->getValue() === 'notes') {
$stream->expect(Token::BLOCK_END_TYPE);
$notes = $this->parser->subparse([$this, 'decideForEnd'], true);
}
} elseif ($next === 'context') {
$stream->expect(Token::BLOCK_END_TYPE);
$context = $this->parser->subparse([$this, 'decideForEnd'], true);
} elseif ($next === 'notes') {
$stream->expect(Token::BLOCK_END_TYPE);
$notes = $this->parser->subparse([$this, 'decideForEnd'], true);
}
}
$stream->expect(Token::BLOCK_END_TYPE);
$this->checkTransString($body, $lineno);
return new NodeTrans($body, $plural, $count, $context, $notes, $lineno, $this->getTag());
}
/**
* Tests the current token for a type.
*
* @param Token $token Twig token to test
*
* @return bool
*/
public function decideForFork(Token $token)
{
return $token->test(['plural', 'context', 'notes', 'endtrans']);
}
}

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use PhpMyAdmin\Twig\Extensions\I18nExtension as TwigI18nExtension;
use PhpMyAdmin\Twig\I18n\TokenParserTrans;
use Twig\TokenParser\TokenParserInterface;
use Twig\TwigFilter;
class I18nExtension extends TwigI18nExtension
{
/**
* Returns the token parser instances to add to the existing list.
*
* @return TokenParserInterface[]
*/
public function getTokenParsers()
{
return [new TokenParserTrans()];
}
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter('trans', '_gettext'),
];
}
}

View file

@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use PhpMyAdmin\Message;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class MessageExtension extends AbstractExtension
{
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'notice',
static function (string $string) {
return Message::notice($string)->getDisplay();
},
['is_safe' => ['html']]
),
new TwigFilter(
'error',
static function (string $string) {
return Message::error($string)->getDisplay();
},
['is_safe' => ['html']]
),
new TwigFilter(
'raw_success',
static function (string $string) {
return Message::rawSuccess($string)->getDisplay();
},
['is_safe' => ['html']]
),
];
}
}

View file

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class PluginsExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'checkbox_check',
'PhpMyAdmin\Plugins::checkboxCheck',
['is_safe' => ['html']]
),
new TwigFunction(
'get_choice',
'PhpMyAdmin\Plugins::getChoice',
['is_safe' => ['html']]
),
new TwigFunction(
'get_default_plugin',
'PhpMyAdmin\Plugins::getDefault',
['is_safe' => ['html']]
),
new TwigFunction(
'get_options',
'PhpMyAdmin\Plugins::getOptions',
['is_safe' => ['html']]
),
];
}
}

View file

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use PhpMyAdmin\Relation;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class RelationExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
global $dbi;
$relation = new Relation($dbi);
return [
new TwigFunction(
'foreign_dropdown',
[
$relation,
'foreignDropdown',
],
['is_safe' => ['html']]
),
new TwigFunction(
'get_display_field',
[
$relation,
'getDisplayField',
],
['is_safe' => ['html']]
),
new TwigFunction(
'get_foreign_data',
[
$relation,
'getForeignData',
]
),
new TwigFunction(
'get_tables',
[
$relation,
'getTables',
]
),
new TwigFunction(
'search_column_in_foreigners',
[
$relation,
'searchColumnInForeigners',
]
),
];
}
}

View file

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
class SanitizeExtension extends AbstractExtension
{
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'escape_js_string',
'PhpMyAdmin\Sanitize::escapeJsString',
['is_safe' => ['html']]
),
new TwigFilter(
'js_format',
'PhpMyAdmin\Sanitize::jsFormat',
['is_safe' => ['html']]
),
new TwigFilter(
'sanitize',
'PhpMyAdmin\Sanitize::sanitizeMessage',
['is_safe' => ['html']]
),
];
}
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'get_js_value',
'PhpMyAdmin\Sanitize::getJsValue',
['is_safe' => ['html']]
),
];
}
}

View file

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class TableExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'table_get',
'PhpMyAdmin\Table::get'
),
];
}
}

View file

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class TrackerExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'get_tracker_version',
'PhpMyAdmin\Tracker::getVersion'
),
];
}
}

View file

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use PhpMyAdmin\Transformations;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class TransformationsExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
$transformations = new Transformations();
return [
new TwigFunction(
'get_description',
[
$transformations,
'getDescription',
]
),
new TwigFunction(
'get_name',
[
$transformations,
'getName',
]
),
];
}
}

View file

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class UrlExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'get_hidden_inputs',
'PhpMyAdmin\Url::getHiddenInputs',
['is_safe' => ['html']]
),
new TwigFunction(
'get_hidden_fields',
'PhpMyAdmin\Url::getHiddenFields',
['is_safe' => ['html']]
),
new TwigFunction(
'get_common',
'PhpMyAdmin\Url::getCommon',
['is_safe' => ['html']]
),
new TwigFunction(
'get_common_raw',
'PhpMyAdmin\Url::getCommonRaw',
['is_safe' => ['html']]
),
new TwigFunction(
'url',
'PhpMyAdmin\Url::getFromRoute',
['is_safe' => ['html']]
),
];
}
}

View file

@ -0,0 +1,170 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
class UtilExtension extends AbstractExtension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[]
*/
public function getFunctions()
{
return [
new TwigFunction(
'backquote',
'PhpMyAdmin\Util::backquote'
),
new TwigFunction(
'extract_column_spec',
'PhpMyAdmin\Util::extractColumnSpec'
),
new TwigFunction(
'format_byte_down',
'PhpMyAdmin\Util::formatByteDown'
),
new TwigFunction(
'get_formatted_maximum_upload_size',
'PhpMyAdmin\Util::getFormattedMaximumUploadSize'
),
new TwigFunction(
'format_number',
'PhpMyAdmin\Util::formatNumber'
),
new TwigFunction(
'format_sql',
'\PhpMyAdmin\Html\Generator::formatSql',
['is_safe' => ['html']]
),
new TwigFunction(
'get_docu_link',
'\PhpMyAdmin\Html\MySQLDocumentation::getDocumentationLink',
['is_safe' => ['html']]
),
new TwigFunction(
'get_list_navigator',
'\PhpMyAdmin\Html\Generator::getListNavigator',
['is_safe' => ['html']]
),
new TwigFunction(
'show_docu',
'\PhpMyAdmin\Html\MySQLDocumentation::showDocumentation',
['is_safe' => ['html']]
),
new TwigFunction(
'get_gis_datatypes',
'PhpMyAdmin\Util::getGISDatatypes'
),
new TwigFunction(
'get_gis_functions',
'PhpMyAdmin\Util::getGISFunctions'
),
new TwigFunction(
'get_icon',
'\PhpMyAdmin\Html\Generator::getIcon',
['is_safe' => ['html']]
),
new TwigFunction(
'get_image',
'\PhpMyAdmin\Html\Generator::getImage',
['is_safe' => ['html']]
),
new TwigFunction(
'get_start_and_number_of_rows_panel',
'PhpMyAdmin\Html\Generator::getStartAndNumberOfRowsPanel',
['is_safe' => ['html']]
),
new TwigFunction(
'get_supported_datatypes',
'PhpMyAdmin\Util::getSupportedDatatypes',
['is_safe' => ['html']]
),
new TwigFunction(
'is_foreign_key_supported',
'PhpMyAdmin\Util::isForeignKeySupported'
),
new TwigFunction(
'link_or_button',
'PhpMyAdmin\Html\Generator::linkOrButton',
['is_safe' => ['html']]
),
new TwigFunction(
'link_to_var_documentation',
'PhpMyAdmin\Html\Generator::linkToVarDocumentation',
['is_safe' => ['html']]
),
new TwigFunction(
'localised_date',
'PhpMyAdmin\Util::localisedDate'
),
new TwigFunction(
'show_hint',
'\PhpMyAdmin\Html\Generator::showHint',
['is_safe' => ['html']]
),
new TwigFunction(
'show_icons',
'PhpMyAdmin\Util::showIcons'
),
new TwigFunction(
'show_text',
'PhpMyAdmin\Util::showText'
),
new TwigFunction(
'show_mysql_docu',
'\PhpMyAdmin\Html\MySQLDocumentation::show',
['is_safe' => ['html']]
),
new TwigFunction(
'get_mysql_docu_url',
'PhpMyAdmin\Util::getMySQLDocuURL',
['is_safe' => ['html']]
),
new TwigFunction(
'get_docu_url',
'PhpMyAdmin\Util::getdocuURL',
['is_safe' => ['html']]
),
new TwigFunction(
'show_php_docu',
'\PhpMyAdmin\Html\Generator::showPHPDocumentation',
['is_safe' => ['html']]
),
new TwigFunction(
'sortable_table_header',
'PhpMyAdmin\Util::sortableTableHeader',
['is_safe' => ['html']]
),
new TwigFunction(
'timespan_format',
'PhpMyAdmin\Util::timespanFormat'
),
];
}
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'convert_bit_default_value',
'PhpMyAdmin\Util::convertBitDefaultValue'
),
new TwigFilter(
'escape_mysql_wildcards',
'PhpMyAdmin\Util::escapeMysqlWildcards'
),
];
}
}