From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../classes/Twig/I18n/TokenParserTrans.php | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php (limited to 'srcs/phpmyadmin/libraries/classes/Twig/I18n/TokenParserTrans.php') 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 @@ +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']); + } +} -- cgit