mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 03:46:39 +00:00
changed filter first argument to be a Twig_Environment instead of Twig_Template
git-svn-id: http://svn.twig-project.org/trunk@64 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
@@ -71,7 +71,7 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression implements Twig_N
|
||||
}
|
||||
else
|
||||
{
|
||||
$compiler->raw($filterMap[$name][0].($filterMap[$name][1] ? '($this, ' : '('));
|
||||
$compiler->raw($filterMap[$name][0].($filterMap[$name][1] ? '($this->getEnvironment(), ' : '('));
|
||||
}
|
||||
$postponed[] = $attrs;
|
||||
}
|
||||
|
||||
+17
-17
@@ -99,69 +99,69 @@ function twig_sort_filter($array)
|
||||
return $array;
|
||||
}
|
||||
|
||||
function twig_escape_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_escape_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
if (!is_string($string))
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
|
||||
return htmlspecialchars($string, ENT_QUOTES, $template->getEnvironment()->getCharset());
|
||||
return htmlspecialchars($string, ENT_QUOTES, $env->getCharset());
|
||||
}
|
||||
|
||||
// add multibyte extensions if possible
|
||||
if (function_exists('mb_get_info'))
|
||||
{
|
||||
function twig_upper_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_upper_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
if (!is_null($template->getEnvironment()->getCharset()))
|
||||
if (!is_null($env->getCharset()))
|
||||
{
|
||||
return mb_strtoupper($string, $template->getEnvironment()->getCharset());
|
||||
return mb_strtoupper($string, $env->getCharset());
|
||||
}
|
||||
|
||||
return strtoupper($string);
|
||||
}
|
||||
|
||||
function twig_lower_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_lower_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
if (!is_null($template->getEnvironment()->getCharset()))
|
||||
if (!is_null($env->getCharset()))
|
||||
{
|
||||
return mb_strtolower($string, $template->getEnvironment()->getCharset());
|
||||
return mb_strtolower($string, $env->getCharset());
|
||||
}
|
||||
|
||||
return strtolower($string);
|
||||
}
|
||||
|
||||
function twig_title_string_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_title_string_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
if (is_null($template->getEnvironment()->getCharset()))
|
||||
if (is_null($env->getCharset()))
|
||||
{
|
||||
return ucwords(strtolower($string));
|
||||
}
|
||||
|
||||
return mb_convert_case($string, MB_CASE_TITLE, $template->getEnvironment()->getCharset());
|
||||
return mb_convert_case($string, MB_CASE_TITLE, $env->getCharset());
|
||||
}
|
||||
|
||||
function twig_capitalize_string_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_capitalize_string_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
if (is_null($template->getEnvironment()->getCharset()))
|
||||
if (is_null($env->getCharset()))
|
||||
{
|
||||
return ucfirst(strtolower($string));
|
||||
}
|
||||
|
||||
return mb_strtoupper(mb_substr($string, 0, 1, $template->getEnvironment()->getCharset())).
|
||||
mb_strtolower(mb_substr($string, 1, mb_strlen($string), $template->getEnvironment()->getCharset()));
|
||||
return mb_strtoupper(mb_substr($string, 0, 1, $env->getCharset())).
|
||||
mb_strtolower(mb_substr($string, 1, mb_strlen($string), $env->getCharset()));
|
||||
}
|
||||
}
|
||||
// and byte fallback
|
||||
else
|
||||
{
|
||||
function twig_title_string_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_title_string_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
return ucwords(strtolower($string));
|
||||
}
|
||||
|
||||
function twig_capitalize_string_filter(Twig_TemplateInterface $template, $string)
|
||||
function twig_capitalize_string_filter(Twig_Environment $env, $string)
|
||||
{
|
||||
return ucfirst(strtolower($string));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user