aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-09 10:55:03 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-09 13:09:38 +0100
commit04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa (patch)
tree5c691241355c943a3c68ddb06b8cf8c60aa11319 /srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php
parent7e0d85db834d6351ed85d01e5126ac31dc510b86 (diff)
downloadft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.gz
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.bz2
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.zip
phpmyadmin working
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php')
-rw-r--r--srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php b/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php
new file mode 100644
index 0000000..25aade0
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php
@@ -0,0 +1,85 @@
+<?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']);
+ }
+}