mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 09:44:28 +01:00
Continue upgrading Twig
This commit is contained in:
parent
538e88b7bd
commit
48c5fb4615
@ -28,7 +28,7 @@ class Twig_Extensions_Extension_I18n extends Twig_Extension
|
|||||||
public function getFilters()
|
public function getFilters()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'trans' => new Twig_Filter_Function('gettext'),
|
new Twig_SimpleFilter('trans', 'gettext'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,23 +9,23 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
|
|||||||
*/
|
*/
|
||||||
public function getFilters()
|
public function getFilters()
|
||||||
{
|
{
|
||||||
return Array(
|
return array(
|
||||||
'filesize' => new Twig_Filter_Function('format_bytes'),
|
new Twig_SimpleFilter('filesize', 'format_bytes'),
|
||||||
'truncate' => new Twig_Filter_Function('twig_truncate_filter'),
|
new Twig_SimpleFilter('truncate', 'twig_truncate_filter'),
|
||||||
'truncate_body' => new Twig_Filter_Function('truncate'),
|
new Twig_SimpleFilter('truncate_body', 'truncate'),
|
||||||
'extension' => new Twig_Filter_Function('twig_extension_filter'),
|
new Twig_SimpleFilter('extension', 'twig_extension_filter'),
|
||||||
'sprintf' => new Twig_Filter_Function('sprintf'),
|
new Twig_SimpleFilter('sprintf', 'sprintf'),
|
||||||
'capcode' => new Twig_Filter_Function('capcode'),
|
new Twig_SimpleFilter('capcode', 'capcode'),
|
||||||
'hasPermission' => new Twig_Filter_Function('twig_hasPermission_filter'),
|
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'),
|
||||||
'date' => new Twig_Filter_Function('twig_date_filter'),
|
new Twig_SimpleFilter('date', 'twig_date_filter'),
|
||||||
'poster_id' => new Twig_Filter_Function('poster_id'),
|
new Twig_SimpleFilter('poster_id', 'poster_id'),
|
||||||
'remove_whitespace' => new Twig_Filter_Function('twig_remove_whitespace_filter'),
|
new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'),
|
||||||
'count' => new Twig_Filter_Function('count'),
|
new Twig_SimpleFilter('count', 'count'),
|
||||||
'ago' => new Twig_Filter_Function('ago'),
|
new Twig_SimpleFilter('ago', 'ago'),
|
||||||
'until' => new Twig_Filter_Function('until'),
|
new Twig_SimpleFilter('until', 'until'),
|
||||||
'push' => new Twig_Filter_Function('twig_push_filter'),
|
new Twig_SimpleFilter('push', 'twig_push_filter'),
|
||||||
'bidi_cleanup' => new Twig_Filter_Function('bidi_cleanup'),
|
new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'),
|
||||||
'addslashes' => new Twig_Filter_Function('addslashes')
|
new Twig_SimpleFilter('addslashes', 'addslashes')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
|
|||||||
*/
|
*/
|
||||||
public function getFunctions()
|
public function getFunctions()
|
||||||
{
|
{
|
||||||
return Array(
|
return array(
|
||||||
'time' => new Twig_Filter_Function('time'),
|
new Twig_SimpleFunction('time', 'time'),
|
||||||
'floor' => new Twig_Filter_Function('floor'),
|
new Twig_SimpleFunction('floor', 'floor'),
|
||||||
'timezone' => new Twig_Filter_Function('twig_timezone_function'),
|
new Twig_SimpleFunction('timezone', 'twig_timezone_function'),
|
||||||
'hiddenInputs' => new Twig_Filter_Function('hiddenInputs'),
|
new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'),
|
||||||
'hiddenInputsHash' => new Twig_Filter_Function('hiddenInputsHash'),
|
new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,22 +94,25 @@ class Twig_Extensions_Node_Trans extends Twig_Node
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
$compiler->raw(');');
|
$compiler->raw(");\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function compileString(Twig_NodeInterface $body)
|
protected function compileString(Twig_NodeInterface $body)
|
||||||
{
|
{
|
||||||
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant) {
|
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) {
|
||||||
return array($body, array());
|
return array($body, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = array();
|
$vars = array();
|
||||||
|
|
||||||
if (count($body)) {
|
if (count($body)) {
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|
||||||
foreach ($body as $node) {
|
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) {
|
if ($node instanceof Twig_Node_Print) {
|
||||||
$n = $node->getNode('expr');
|
$n = $node->getNode('expr');
|
||||||
while ($n instanceof Twig_Node_Expression_Filter) {
|
while ($n instanceof Twig_Node_Expression_Filter) {
|
||||||
|
@ -43,12 +43,12 @@ class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser
|
|||||||
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag());
|
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decideForFork($token)
|
public function decideForFork(Twig_Token $token)
|
||||||
{
|
{
|
||||||
return $token->test(array('plural', 'endtrans'));
|
return $token->test(array('plural', 'endtrans'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decideForEnd($token)
|
public function decideForEnd(Twig_Token $token)
|
||||||
{
|
{
|
||||||
return $token->test('endtrans');
|
return $token->test('endtrans');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user