diff options
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Twig')
15 files changed, 0 insertions, 1055 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Twig/CoreExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/CoreExtension.php deleted file mode 100644 index e6e2142..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/CoreExtension.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\CoreExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; - -/** - * Class CoreExtension - * - * @package PhpMyAdmin\Twig - */ -class CoreExtension extends AbstractExtension -{ - /** - * Returns a list of filters to add to the existing list. - * - * @return TwigFilter[] - */ - public function getFilters() - { - return [ - new TwigFilter( - 'mime_default_function', - 'PhpMyAdmin\Core::mimeDefaultFunction', - ['is_safe' => ['html']] - ), - new TwigFilter( - 'link', - 'PhpMyAdmin\Core::linkURL' - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/I18n/NodeTrans.php b/srcs/phpmyadmin/libraries/classes/Twig/I18n/NodeTrans.php deleted file mode 100644 index 6fae7aa..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/I18n/NodeTrans.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\I18n\NodeTrans class - * - * @package PhpMyAdmin\Twig\I18n - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig\I18n; - -use Twig\Compiler; -use Twig\Extensions\Node\TransNode; -use Twig\Node\Expression\AbstractExpression; -use Twig\Node\Node; - -/** - * Class NodeTrans - * - * @package PhpMyAdmin\Twig\I18n - */ -class NodeTrans extends TransNode -{ - /** - * Constructor. - * - * 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 $plural Node plural - * @param AbstractExpression $count Node count - * @param Node $context Node context - * @param Node $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 = null, - AbstractExpression $count = null, - Node $context = null, - Node $notes = null, - $lineno, - $tag = null - ) { - $nodes = ['body' => $body]; - if (null !== $count) { - $nodes['count'] = $count; - } - if (null !== $plural) { - $nodes['plural'] = $plural; - } - if (null !== $context) { - $nodes['context'] = $context; - } - if (null !== $notes) { - $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); - - list($msg, $vars) = $this->compileString($this->getNode('body')); - - if ($this->hasNode('plural')) { - list($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 ('count' === $var->getAttribute('name')) { - $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? - * - * @return string - */ - protected function getTransFunction($plural, $hasMsgContext = false) - { - if ($hasMsgContext) { - return $plural ? '_ngettext' : '_pgettext'; - } - - return $plural ? '_ngettext' : '_gettext'; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php b/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php deleted file mode 100644 index 25aade0..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\I18n\TokenParserTrans class - * - * @package PhpMyAdmin\Twig\I18n - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig\I18n; - -use Twig\Extensions\Node\TransNode; -use Twig\Extensions\TokenParser\TransTokenParser; -use Twig\Token; -use Twig_Error_Syntax; - -/** - * Class TokenParserTrans - * - * @package PhpMyAdmin\Twig\I18n - */ -class TokenParserTrans extends TransTokenParser -{ - /** - * Parses a token and returns a node. - * - * @param Token $token Twig token to parse - * - * @return TransNode - * - * @throws Twig_Error_Syntax - */ - 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 ('plural' === $next) { - $count = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Token::BLOCK_END_TYPE); - $plural = $this->parser->subparse([$this, 'decideForFork']); - - if ('notes' === $stream->next()->getValue()) { - $stream->expect(Token::BLOCK_END_TYPE); - $notes = $this->parser->subparse([$this, 'decideForEnd'], true); - } - } elseif ('context' === $next) { - $stream->expect(Token::BLOCK_END_TYPE); - $context = $this->parser->subparse([$this, 'decideForEnd'], true); - } elseif ('notes' === $next) { - $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']); - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/I18nExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/I18nExtension.php deleted file mode 100644 index 4d0c14f..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/I18nExtension.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\I18nExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use PhpMyAdmin\Twig\I18n\TokenParserTrans; -use Twig\Extensions\I18nExtension as TwigI18nExtension; -use Twig\TokenParser\TokenParserInterface; -use Twig\TwigFilter; - -/** - * Class I18nExtension - * - * @package PhpMyAdmin\Twig - */ -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'), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/MessageExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/MessageExtension.php deleted file mode 100644 index 27328de..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/MessageExtension.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\MessageExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use PhpMyAdmin\Message; -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; - -/** - * Class MessageExtension - * - * @package PhpMyAdmin\Twig - */ -class MessageExtension extends AbstractExtension -{ - /** - * Returns a list of filters to add to the existing list. - * - * @return TwigFilter[] - */ - public function getFilters() - { - return [ - new TwigFilter( - 'notice', - function (string $string) { - return Message::notice($string)->getDisplay(); - }, - ['is_safe' => ['html']] - ), - new TwigFilter( - 'error', - function (string $string) { - return Message::error($string)->getDisplay(); - }, - ['is_safe' => ['html']] - ), - new TwigFilter( - 'raw_success', - function (string $string) { - return Message::rawSuccess($string)->getDisplay(); - }, - ['is_safe' => ['html']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/PluginsExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/PluginsExtension.php deleted file mode 100644 index 1706a62..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/PluginsExtension.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\PluginsExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class PluginsExtension - * - * @package PhpMyAdmin\Twig - */ -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']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/RelationExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/RelationExtension.php deleted file mode 100644 index 6aca5d3..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/RelationExtension.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\RelationExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use PhpMyAdmin\Relation; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class RelationExtension - * - * @package PhpMyAdmin\Twig - */ -class RelationExtension extends AbstractExtension -{ - /** - * Returns a list of functions to add to the existing list. - * - * @return TwigFunction[] - */ - public function getFunctions() - { - $relation = new Relation($GLOBALS['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', - ] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/SanitizeExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/SanitizeExtension.php deleted file mode 100644 index 0256109..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/SanitizeExtension.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\SanitizeExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; -use Twig\TwigFunction; - -/** - * Class SanitizeExtension - * - * @package PhpMyAdmin\Twig - */ -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']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/ServerPrivilegesExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/ServerPrivilegesExtension.php deleted file mode 100644 index 0a1363c..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/ServerPrivilegesExtension.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\ServerPrivilegesExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use PhpMyAdmin\Relation; -use PhpMyAdmin\RelationCleanup; -use PhpMyAdmin\Server\Privileges; -use PhpMyAdmin\Template; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class ServerPrivilegesExtension - * - * @package PhpMyAdmin\Twig - */ -class ServerPrivilegesExtension extends AbstractExtension -{ - /** - * Returns a list of functions to add to the existing list. - * - * @return TwigFunction[] - */ - public function getFunctions() - { - $relation = new Relation($GLOBALS['dbi']); - $serverPrivileges = new Privileges( - new Template(), - $GLOBALS['dbi'], - $relation, - new RelationCleanup($GLOBALS['dbi'], $relation) - ); - return [ - new TwigFunction( - 'format_privilege', - [ - $serverPrivileges, - 'formatPrivilege', - ], - ['is_safe' => ['html']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/StorageEngineExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/StorageEngineExtension.php deleted file mode 100644 index 34b87c1..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/StorageEngineExtension.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\StorageEngineExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class StorageEngineExtension - * - * @package PhpMyAdmin\Twig - */ -class StorageEngineExtension extends AbstractExtension -{ - /** - * Returns a list of functions to add to the existing list. - * - * @return TwigFunction[] - */ - public function getFunctions() - { - return [ - new TwigFunction( - 'get_html_select', - 'PhpMyAdmin\StorageEngine::getHtmlSelect', - ['is_safe' => ['html']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/TableExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/TableExtension.php deleted file mode 100644 index 1dc4ef1..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/TableExtension.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\TableExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class TableExtension - * - * @package PhpMyAdmin\Twig - */ -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' - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/TrackerExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/TrackerExtension.php deleted file mode 100644 index ac883f5..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/TrackerExtension.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\TrackerExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class TrackerExtension - * - * @package PhpMyAdmin\Twig - */ -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' - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/TransformationsExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/TransformationsExtension.php deleted file mode 100644 index 5ab9ef5..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/TransformationsExtension.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\TransformationsExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use PhpMyAdmin\Transformations; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class TransformationsExtension - * - * @package PhpMyAdmin\Twig - */ -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', - ] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/UrlExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/UrlExtension.php deleted file mode 100644 index 2a50838..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/UrlExtension.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\UrlExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class UrlExtension - * - * @package PhpMyAdmin\Twig - */ -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']] - ), - ]; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Twig/UtilExtension.php b/srcs/phpmyadmin/libraries/classes/Twig/UtilExtension.php deleted file mode 100644 index 809b07e..0000000 --- a/srcs/phpmyadmin/libraries/classes/Twig/UtilExtension.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * hold PhpMyAdmin\Twig\UtilExtension class - * - * @package PhpMyAdmin\Twig - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFilter; -use Twig\TwigFunction; - -/** - * Class UtilExtension - * - * @package PhpMyAdmin\Twig - */ -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( - 'get_browse_upload_file_block', - 'PhpMyAdmin\Util::getBrowseUploadFileBlock', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'extract_column_spec', - 'PhpMyAdmin\Util::extractColumnSpec' - ), - new TwigFunction( - 'format_byte_down', - 'PhpMyAdmin\Util::formatByteDown' - ), - new TwigFunction( - 'format_number', - 'PhpMyAdmin\Util::formatNumber' - ), - new TwigFunction( - 'format_sql', - 'PhpMyAdmin\Util::formatSql', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_button_or_image', - 'PhpMyAdmin\Util::getButtonOrImage', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_docu_link', - 'PhpMyAdmin\Util::getDocuLink', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_list_navigator', - 'PhpMyAdmin\Util::getListNavigator', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'show_docu', - 'PhpMyAdmin\Util::showDocu', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_dropdown', - 'PhpMyAdmin\Util::getDropdown', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_fk_checkbox', - 'PhpMyAdmin\Util::getFKCheckbox', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_gis_datatypes', - 'PhpMyAdmin\Util::getGISDatatypes' - ), - new TwigFunction( - 'get_gis_functions', - 'PhpMyAdmin\Util::getGISFunctions' - ), - new TwigFunction( - 'get_html_tab', - 'PhpMyAdmin\Util::getHtmlTab', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_icon', - 'PhpMyAdmin\Util::getIcon', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_image', - 'PhpMyAdmin\Util::getImage', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_radio_fields', - 'PhpMyAdmin\Util::getRadioFields', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_select_upload_file_block', - 'PhpMyAdmin\Util::getSelectUploadFileBlock', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_script_name_for_option', - 'PhpMyAdmin\Util::getScriptNameForOption', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_start_and_number_of_rows_panel', - 'PhpMyAdmin\Util::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\Util::linkOrButton', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'link_to_var_documentation', - 'PhpMyAdmin\Util::linkToVarDocumentation', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'localised_date', - 'PhpMyAdmin\Util::localisedDate' - ), - new TwigFunction( - 'show_hint', - 'PhpMyAdmin\Util::showHint', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'show_icons', - 'PhpMyAdmin\Util::showIcons' - ), - new TwigFunction( - 'show_mysql_docu', - 'PhpMyAdmin\Util::showMySQLDocu', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_mysql_docu_url', - 'PhpMyAdmin\Util::getMySQLDocuURL', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'show_php_docu', - 'PhpMyAdmin\Util::showPHPDocu', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'sortable_table_header', - 'PhpMyAdmin\Util::sortableTableHeader', - ['is_safe' => ['html']] - ), - new TwigFunction( - 'timespan_format', - 'PhpMyAdmin\Util::timespanFormat' - ), - new TwigFunction( - 'generate_hidden_max_file_size', - 'PhpMyAdmin\Util::generateHiddenMaxFileSize', - ['is_safe' => ['html']] - ), - ]; - } - - /** - * 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::convertBitDefaultValue' - ), - ]; - } -} |
