fowr
1 year ago
committed by
Zankaria
43 changed files with 490 additions and 622 deletions
@ -4,7 +4,7 @@ |
|||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
||||
"This file is @generated automatically" |
"This file is @generated automatically" |
||||
], |
], |
||||
"content-hash": "346d80deda89b0298a414b565213f312", |
"content-hash": "b3695c356f94b9226e689a31f8dc1463", |
||||
"packages": [ |
"packages": [ |
||||
{ |
{ |
||||
"name": "gettext/gettext", |
"name": "gettext/gettext", |
||||
@ -25,12 +25,12 @@ |
|||||
}, |
}, |
||||
"type": "library", |
"type": "library", |
||||
"autoload": { |
"autoload": { |
||||
"psr-0": { |
|
||||
"Gettext": "" |
|
||||
}, |
|
||||
"files": [ |
"files": [ |
||||
"Gettext/translator_functions.php" |
"Gettext/translator_functions.php" |
||||
] |
], |
||||
|
"psr-0": { |
||||
|
"Gettext": "" |
||||
|
} |
||||
}, |
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
"license": [ |
||||
@ -191,12 +191,12 @@ |
|||||
} |
} |
||||
}, |
}, |
||||
"autoload": { |
"autoload": { |
||||
"psr-4": { |
|
||||
"Symfony\\Polyfill\\Ctype\\": "" |
|
||||
}, |
|
||||
"files": [ |
"files": [ |
||||
"bootstrap.php" |
"bootstrap.php" |
||||
] |
], |
||||
|
"psr-4": { |
||||
|
"Symfony\\Polyfill\\Ctype\\": "" |
||||
|
} |
||||
}, |
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
"license": [ |
||||
@ -239,32 +239,114 @@ |
|||||
], |
], |
||||
"time": "2021-10-20T20:35:02+00:00" |
"time": "2021-10-20T20:35:02+00:00" |
||||
}, |
}, |
||||
|
{ |
||||
|
"name": "symfony/polyfill-mbstring", |
||||
|
"version": "v1.29.0", |
||||
|
"source": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git", |
||||
|
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" |
||||
|
}, |
||||
|
"dist": { |
||||
|
"type": "zip", |
||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", |
||||
|
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", |
||||
|
"shasum": "" |
||||
|
}, |
||||
|
"require": { |
||||
|
"php": ">=7.1" |
||||
|
}, |
||||
|
"provide": { |
||||
|
"ext-mbstring": "*" |
||||
|
}, |
||||
|
"suggest": { |
||||
|
"ext-mbstring": "For best performance" |
||||
|
}, |
||||
|
"type": "library", |
||||
|
"extra": { |
||||
|
"thanks": { |
||||
|
"name": "symfony/polyfill", |
||||
|
"url": "https://github.com/symfony/polyfill" |
||||
|
} |
||||
|
}, |
||||
|
"autoload": { |
||||
|
"files": [ |
||||
|
"bootstrap.php" |
||||
|
], |
||||
|
"psr-4": { |
||||
|
"Symfony\\Polyfill\\Mbstring\\": "" |
||||
|
} |
||||
|
}, |
||||
|
"notification-url": "https://packagist.org/downloads/", |
||||
|
"license": [ |
||||
|
"MIT" |
||||
|
], |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Nicolas Grekas", |
||||
|
"email": "[email protected]" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Symfony Community", |
||||
|
"homepage": "https://symfony.com/contributors" |
||||
|
} |
||||
|
], |
||||
|
"description": "Symfony polyfill for the Mbstring extension", |
||||
|
"homepage": "https://symfony.com", |
||||
|
"keywords": [ |
||||
|
"compatibility", |
||||
|
"mbstring", |
||||
|
"polyfill", |
||||
|
"portable", |
||||
|
"shim" |
||||
|
], |
||||
|
"support": { |
||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" |
||||
|
}, |
||||
|
"funding": [ |
||||
|
{ |
||||
|
"url": "https://symfony.com/sponsor", |
||||
|
"type": "custom" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://github.com/fabpot", |
||||
|
"type": "github" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony", |
||||
|
"type": "tidelift" |
||||
|
} |
||||
|
], |
||||
|
"time": "2024-01-29T20:11:03+00:00" |
||||
|
}, |
||||
{ |
{ |
||||
"name": "twig/twig", |
"name": "twig/twig", |
||||
"version": "v1.44.6", |
"version": "v2.9.0", |
||||
"source": { |
"source": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://github.com/twigphp/Twig.git", |
"url": "https://github.com/twigphp/Twig.git", |
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3" |
"reference": "82a1c055c8ed4c4705023bfd0405f3c74db6e3ae" |
||||
}, |
}, |
||||
"dist": { |
"dist": { |
||||
"type": "zip", |
"type": "zip", |
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ae39480f010ef88adc7938503c9b02d3baf2f3b3", |
"url": "https://api.github.com/repos/twigphp/Twig/zipball/82a1c055c8ed4c4705023bfd0405f3c74db6e3ae", |
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3", |
"reference": "82a1c055c8ed4c4705023bfd0405f3c74db6e3ae", |
||||
"shasum": "" |
"shasum": "" |
||||
}, |
}, |
||||
"require": { |
"require": { |
||||
"php": ">=7.2.5", |
"php": "^7.0", |
||||
"symfony/polyfill-ctype": "^1.8" |
"symfony/polyfill-ctype": "^1.8", |
||||
|
"symfony/polyfill-mbstring": "^1.3" |
||||
}, |
}, |
||||
"require-dev": { |
"require-dev": { |
||||
"psr/container": "^1.0", |
"psr/container": "^1.0", |
||||
"symfony/phpunit-bridge": "^4.4.9|^5.0.9" |
"symfony/debug": "^2.7", |
||||
|
"symfony/phpunit-bridge": "^3.4.19|^4.1.8" |
||||
}, |
}, |
||||
"type": "library", |
"type": "library", |
||||
"extra": { |
"extra": { |
||||
"branch-alias": { |
"branch-alias": { |
||||
"dev-master": "1.44-dev" |
"dev-master": "2.9-dev" |
||||
} |
} |
||||
}, |
}, |
||||
"autoload": { |
"autoload": { |
||||
@ -286,14 +368,15 @@ |
|||||
"homepage": "http://fabien.potencier.org", |
"homepage": "http://fabien.potencier.org", |
||||
"role": "Lead Developer" |
"role": "Lead Developer" |
||||
}, |
}, |
||||
{ |
|
||||
"name": "Twig Team", |
|
||||
"role": "Contributors" |
|
||||
}, |
|
||||
{ |
{ |
||||
"name": "Armin Ronacher", |
"name": "Armin Ronacher", |
||||
"email": "[email protected]", |
"email": "[email protected]", |
||||
"role": "Project Founder" |
"role": "Project Founder" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Twig Team", |
||||
|
"homepage": "https://twig.symfony.com/contributors", |
||||
|
"role": "Contributors" |
||||
} |
} |
||||
], |
], |
||||
"description": "Twig, the flexible, fast, and secure template language for PHP", |
"description": "Twig, the flexible, fast, and secure template language for PHP", |
||||
@ -303,19 +386,9 @@ |
|||||
], |
], |
||||
"support": { |
"support": { |
||||
"issues": "https://github.com/twigphp/Twig/issues", |
"issues": "https://github.com/twigphp/Twig/issues", |
||||
"source": "https://github.com/twigphp/Twig/tree/v1.44.6" |
"source": "https://github.com/twigphp/Twig/tree/v2.9.0" |
||||
}, |
}, |
||||
"funding": [ |
"time": "2019-04-28T06:57:38+00:00" |
||||
{ |
|
||||
"url": "https://github.com/fabpot", |
|
||||
"type": "github" |
|
||||
}, |
|
||||
{ |
|
||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig", |
|
||||
"type": "tidelift" |
|
||||
} |
|
||||
], |
|
||||
"time": "2021-11-25T13:31:46+00:00" |
|
||||
} |
} |
||||
], |
], |
||||
"packages-dev": [], |
"packages-dev": [], |
||||
|
@ -1,44 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
class Twig_Extensions_Extension_I18n extends Twig_Extension |
|
||||
{ |
|
||||
/** |
|
||||
* Returns the token parser instances to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances |
|
||||
*/ |
|
||||
public function getTokenParsers() |
|
||||
{ |
|
||||
return array(new Twig_Extensions_TokenParser_Trans()); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns a list of filters to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFilters() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFilter('trans', 'gettext'), |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns the name of the extension. |
|
||||
* |
|
||||
* @return string The extension name |
|
||||
*/ |
|
||||
public function getName() |
|
||||
{ |
|
||||
return 'i18n'; |
|
||||
} |
|
||||
} |
|
@ -1,137 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
class Twig_Extensions_Extension_Tinyboard extends Twig_Extension |
|
||||
{ |
|
||||
/** |
|
||||
* Returns a list of filters to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFilters() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFilter('filesize', 'format_bytes'), |
|
||||
new Twig_SimpleFilter('truncate', 'twig_truncate_filter'), |
|
||||
new Twig_SimpleFilter('truncate_body', 'truncate'), |
|
||||
new Twig_SimpleFilter('truncate_filename', 'twig_filename_truncate_filter'), |
|
||||
new Twig_SimpleFilter('extension', 'twig_extension_filter'), |
|
||||
new Twig_SimpleFilter('sprintf', 'sprintf'), |
|
||||
new Twig_SimpleFilter('capcode', 'capcode'), |
|
||||
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'), |
|
||||
new Twig_SimpleFilter('remove_markup', 'remove_markup'), |
|
||||
new Twig_SimpleFilter('newline_to_full_stop', 'newline_to_full_stop'), |
|
||||
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'), |
|
||||
new Twig_SimpleFilter('date', 'twig_date_filter'), |
|
||||
new Twig_SimpleFilter('poster_id', 'poster_id'), |
|
||||
new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'), |
|
||||
new Twig_SimpleFilter('count', 'count'), |
|
||||
new Twig_SimpleFilter('ago', 'ago'), |
|
||||
new Twig_SimpleFilter('until', 'until'), |
|
||||
new Twig_SimpleFilter('push', 'twig_push_filter'), |
|
||||
new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'), |
|
||||
new Twig_SimpleFilter('addslashes', 'addslashes'), |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns a list of functions to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFunctions() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFunction('time', 'time'), |
|
||||
new Twig_SimpleFunction('floor', 'floor'), |
|
||||
new Twig_SimpleFunction('timezone', 'twig_timezone_function'), |
|
||||
new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'), |
|
||||
new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'), |
|
||||
new Twig_SimpleFunction('ratio', 'twig_ratio_function'), |
|
||||
new Twig_SimpleFunction('secure_link_confirm', 'twig_secure_link_confirm'), |
|
||||
new Twig_SimpleFunction('secure_link', 'twig_secure_link'), |
|
||||
new Twig_SimpleFunction('link_for', 'link_for') |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns the name of the extension. |
|
||||
* |
|
||||
* @return string The extension name |
|
||||
*/ |
|
||||
public function getName() |
|
||||
{ |
|
||||
return 'tinyboard'; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
function twig_timezone_function() { |
|
||||
return 'Z'; |
|
||||
} |
|
||||
|
|
||||
function twig_push_filter($array, $value) { |
|
||||
array_push($array, $value); |
|
||||
return $array; |
|
||||
} |
|
||||
|
|
||||
function twig_remove_whitespace_filter($data) { |
|
||||
return preg_replace('/[\t\r\n]/', '', $data); |
|
||||
} |
|
||||
|
|
||||
function twig_date_filter($date, $format) { |
|
||||
return gmstrftime($format, $date); |
|
||||
} |
|
||||
|
|
||||
function twig_hasPermission_filter($mod, $permission, $board = null) { |
|
||||
return hasPermission($permission, $board, $mod); |
|
||||
} |
|
||||
|
|
||||
function twig_extension_filter($value, $case_insensitive = true) { |
|
||||
$ext = mb_substr($value, mb_strrpos($value, '.') + 1); |
|
||||
if($case_insensitive) |
|
||||
$ext = mb_strtolower($ext); |
|
||||
return $ext; |
|
||||
} |
|
||||
|
|
||||
function twig_sprintf_filter( $value, $var) { |
|
||||
return sprintf($value, $var); |
|
||||
} |
|
||||
|
|
||||
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') { |
|
||||
if (mb_strlen($value) > $length) { |
|
||||
if ($preserve) { |
|
||||
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) { |
|
||||
$length = $breakpoint; |
|
||||
} |
|
||||
} |
|
||||
return mb_substr($value, 0, $length) . $separator; |
|
||||
} |
|
||||
return $value; |
|
||||
} |
|
||||
|
|
||||
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') { |
|
||||
if (mb_strlen($value) > $length) { |
|
||||
$value = strrev($value); |
|
||||
$array = array_reverse(explode(".", $value, 2)); |
|
||||
$array = array_map("strrev", $array); |
|
||||
|
|
||||
$filename = &$array[0]; |
|
||||
$extension = isset($array[1]) ? $array[1] : false; |
|
||||
|
|
||||
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator; |
|
||||
|
|
||||
return implode(".", $array); |
|
||||
} |
|
||||
return $value; |
|
||||
} |
|
||||
|
|
||||
function twig_ratio_function($w, $h) { |
|
||||
return fraction($w, $h, ':'); |
|
||||
} |
|
||||
function twig_secure_link_confirm($text, $title, $confirm_message, $href) { |
|
||||
global $config; |
|
||||
|
|
||||
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>'; |
|
||||
} |
|
||||
function twig_secure_link($href) { |
|
||||
return $href . '/' . make_secure_link_token($href); |
|
||||
} |
|
@ -1,133 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
|
|
||||
/** |
|
||||
* Represents a trans node. |
|
||||
* |
|
||||
* @package twig |
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> |
|
||||
*/ |
|
||||
class Twig_Extensions_Node_Trans extends Twig_Node |
|
||||
{ |
|
||||
public function __construct(Twig_NodeInterface $body, Twig_NodeInterface $plural = null, Twig_Node_Expression $count = null, $lineno, $tag = null) |
|
||||
{ |
|
||||
parent::__construct(array('count' => $count, 'body' => $body, 'plural' => $plural), array(), $lineno, $tag); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Compiles the node to PHP. |
|
||||
* |
|
||||
* @param Twig_Compiler A Twig_Compiler instance |
|
||||
*/ |
|
||||
public function compile(Twig_Compiler $compiler) |
|
||||
{ |
|
||||
$compiler->addDebugInfo($this); |
|
||||
|
|
||||
list($msg, $vars) = $this->compileString($this->getNode('body')); |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
list($msg1, $vars1) = $this->compileString($this->getNode('plural')); |
|
||||
|
|
||||
$vars = array_merge($vars, $vars1); |
|
||||
} |
|
||||
|
|
||||
$function = null === $this->getNode('plural') ? 'gettext' : 'ngettext'; |
|
||||
|
|
||||
if ($vars) { |
|
||||
$compiler |
|
||||
->write('echo strtr('.$function.'(') |
|
||||
->subcompile($msg) |
|
||||
; |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
$compiler |
|
||||
->raw(', ') |
|
||||
->subcompile($msg1) |
|
||||
->raw(', abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw(')') |
|
||||
; |
|
||||
} |
|
||||
|
|
||||
$compiler->raw('), array('); |
|
||||
|
|
||||
foreach ($vars as $var) { |
|
||||
if ('count' === $var->getAttribute('name')) { |
|
||||
$compiler |
|
||||
->string('%count%') |
|
||||
->raw(' => abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw('), ') |
|
||||
; |
|
||||
} else { |
|
||||
$compiler |
|
||||
->string('%'.$var->getAttribute('name').'%') |
|
||||
->raw(' => ') |
|
||||
->subcompile($var) |
|
||||
->raw(', ') |
|
||||
; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$compiler->raw("));\n"); |
|
||||
} else { |
|
||||
$compiler |
|
||||
->write('echo '.$function.'(') |
|
||||
->subcompile($msg) |
|
||||
; |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
$compiler |
|
||||
->raw(', ') |
|
||||
->subcompile($msg1) |
|
||||
->raw(', abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw(')') |
|
||||
; |
|
||||
} |
|
||||
|
|
||||
$compiler->raw(");\n"); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
protected function compileString(Twig_NodeInterface $body) |
|
||||
{ |
|
||||
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) { |
|
||||
return array($body, array()); |
|
||||
} |
|
||||
|
|
||||
$vars = array(); |
|
||||
if (count($body)) { |
|
||||
$msg = ''; |
|
||||
|
|
||||
foreach ($body as $node) { |
|
||||
if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof Twig_Node_SetTemp) { |
|
||||
$node = $node->getNode(1); |
|
||||
} |
|
||||
|
|
||||
if ($node instanceof Twig_Node_Print) { |
|
||||
$n = $node->getNode('expr'); |
|
||||
while ($n instanceof Twig_Node_Expression_Filter) { |
|
||||
$n = $n->getNode('node'); |
|
||||
} |
|
||||
$msg .= sprintf('%%%s%%', $n->getAttribute('name')); |
|
||||
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine()); |
|
||||
} else { |
|
||||
$msg .= $node->getAttribute('data'); |
|
||||
} |
|
||||
} |
|
||||
} else { |
|
||||
$msg = $body->getAttribute('data'); |
|
||||
} |
|
||||
|
|
||||
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars); |
|
||||
} |
|
||||
} |
|
@ -1,80 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser |
|
||||
{ |
|
||||
/** |
|
||||
* Parses a token and returns a node. |
|
||||
* |
|
||||
* @param Twig_Token $token A Twig_Token instance |
|
||||
* |
|
||||
* @return Twig_NodeInterface A Twig_NodeInterface instance |
|
||||
*/ |
|
||||
public function parse(Twig_Token $token) |
|
||||
{ |
|
||||
$lineno = $token->getLine(); |
|
||||
$stream = $this->parser->getStream(); |
|
||||
$count = null; |
|
||||
$plural = null; |
|
||||
|
|
||||
if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) { |
|
||||
$body = $this->parser->getExpressionParser()->parseExpression(); |
|
||||
} else { |
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
$body = $this->parser->subparse(array($this, 'decideForFork')); |
|
||||
if ('plural' === $stream->next()->getValue()) { |
|
||||
$count = $this->parser->getExpressionParser()->parseExpression(); |
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
$plural = $this->parser->subparse(array($this, 'decideForEnd'), true); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
|
|
||||
$this->checkTransString($body, $lineno); |
|
||||
|
|
||||
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag()); |
|
||||
} |
|
||||
|
|
||||
public function decideForFork(Twig_Token $token) |
|
||||
{ |
|
||||
return $token->test(array('plural', 'endtrans')); |
|
||||
} |
|
||||
|
|
||||
public function decideForEnd(Twig_Token $token) |
|
||||
{ |
|
||||
return $token->test('endtrans'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Gets the tag name associated with this token parser. |
|
||||
* |
|
||||
* @param string The tag name |
|
||||
*/ |
|
||||
public function getTag() |
|
||||
{ |
|
||||
return 'trans'; |
|
||||
} |
|
||||
|
|
||||
protected function checkTransString(Twig_NodeInterface $body, $lineno) |
|
||||
{ |
|
||||
foreach ($body as $i => $node) { |
|
||||
if ( |
|
||||
$node instanceof Twig_Node_Text |
|
||||
|| |
|
||||
($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_Name) |
|
||||
) { |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
throw new Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,7 +1,7 @@ |
|||||
{% filter remove_whitespace %} |
{% apply spaceless %} |
||||
{# Automatically removes unnecessary whitespace #} |
{# Automatically removes unnecessary whitespace #} |
||||
<div class="ban"> |
<div class="ban"> |
||||
<h2>You are not banned!</h2> |
<h2>You are not banned!</h2> |
||||
<p class="reason">Well done on not being terrible!</p> |
<p class="reason">Well done on not being terrible!</p> |
||||
</div> |
</div> |
||||
{% endfilter %} |
{% endapply %} |
||||
|
Loading…
Reference in new issue