From 49117dd86389df02edd13cc179fbbd544cd6d781 Mon Sep 17 00:00:00 2001 From: fabien Date: Fri, 16 Oct 2009 06:55:35 +0000 Subject: [PATCH] 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 --- lib/Twig/Node/Expression/Filter.php | 2 +- lib/Twig/runtime.php | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/Twig/Node/Expression/Filter.php b/lib/Twig/Node/Expression/Filter.php index e835296..7109d80 100644 --- a/lib/Twig/Node/Expression/Filter.php +++ b/lib/Twig/Node/Expression/Filter.php @@ -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; } diff --git a/lib/Twig/runtime.php b/lib/Twig/runtime.php index d4b02c1..02b492d 100644 --- a/lib/Twig/runtime.php +++ b/lib/Twig/runtime.php @@ -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)); } -- 1.7.2.5