本文整理汇总了PHP中twig_convert_encoding函数的典型用法代码示例。如果您正苦于以下问题:PHP twig_convert_encoding函数的具体用法?PHP twig_convert_encoding怎么用?PHP twig_convert_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了twig_convert_encoding函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_d5df272f6546f4a41daabb9a4980540cc0a5ad45d38339ad747f462cf3817597 = $this->env->getExtension("native_profiler");
$__internal_d5df272f6546f4a41daabb9a4980540cc0a5ad45d38339ad747f462cf3817597->enter($__internal_d5df272f6546f4a41daabb9a4980540cc0a5ad45d38339ad747f462cf3817597_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "links2.html"));
// line 1
echo "<a class=\"list-group-item\" href=\"#\">\n <h4 class=\"list-group-item-heading\">INFOS SUR LES LIENS : </h4>\n<p class=\"list-group-item-text\">";
// line 3
echo twig_escape_filter($this->env, isset($context["nblinks2"]) ? $context["nblinks2"] : $this->getContext($context, "nblinks2"), "html", null, true);
echo " ";
echo twig_escape_filter($this->env, twig_convert_encoding(" lien(s) trouvé(s)", "UTF-8", " iso-8859-1"), "html", null, true);
echo "</p>\n\t<ul style=\"list-style-type: none;\">";
// line 4
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(range(0, (isset($context["nblinks2"]) ? $context["nblinks2"] : $this->getContext($context, "nblinks2")) - 1));
foreach ($context['_seq'] as $context["_key"] => $context["i"]) {
// line 5
echo "\t\t\t<li>Texte de l'ancre du lien : ";
echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute(isset($context["links2"]) ? $context["links2"] : $this->getContext($context, "links2"), $context["i"], array(), "array"), 0, array(), "array"), "html", null, true);
echo "</li>\n\t\t\t<li>Lien de la page de destination : ";
// line 6
echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute(isset($context["links2"]) ? $context["links2"] : $this->getContext($context, "links2"), $context["i"], array(), "array"), 1, array(), "array"), "html", null, true);
echo "</li>\n\t\t\t<li>Attribut title du lien : ";
// line 7
echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute(isset($context["links2"]) ? $context["links2"] : $this->getContext($context, "links2"), $context["i"], array(), "array"), 2, array(), "array"), "html", null, true);
echo "</li>\n\t\t\t<br>\n\t\t";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['i'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 10
echo "\t</ul>\n \n</a> \n";
$__internal_d5df272f6546f4a41daabb9a4980540cc0a5ad45d38339ad747f462cf3817597->leave($__internal_d5df272f6546f4a41daabb9a4980540cc0a5ad45d38339ad747f462cf3817597_prof);
}
开发者ID:kibimimi,项目名称:monprojettest,代码行数:33,代码来源:874390c45eaf159634a2e708c2ce001938ec6f84fbcfa234528effa816c1c971.php
示例2: testReverseFilterOnNonUTF8String
public function testReverseFilterOnNonUTF8String()
{
if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) {
$this->markTestSkipped('needs iconv or mbstring');
}
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig->setCharset('ISO-8859-1');
$input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
$output = twig_convert_encoding(twig_reverse_filter($twig, $input), 'UTF-8', 'ISO-8859-1');
$this->assertEquals($output, 'éÄ');
}
示例3: block_panel
public function block_panel($context, array $blocks = array())
{
// line 34
echo " <h2>Messages ";
echo $this->getAttribute($this->getContext($context, "collector"), "isSpool") ? "spooled" : "sent";
echo "</h2>\n\n ";
// line 36
if (!$this->getAttribute($this->getContext($context, "collector"), "messages")) {
// line 37
echo " <p>\n <em>No message sent.</em>\n </p>\n ";
} else {
// line 41
echo " ";
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getContext($context, "collector"), "messages"));
foreach ($context['_seq'] as $context["i"] => $context["message"]) {
// line 42
echo " <h3>Message ";
echo twig_escape_filter($this->env, $this->getContext($context, "i") + 1, "html", null, true);
echo " / ";
echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "collector"), "messagecount"), "html", null, true);
echo "</h3>\n\n ";
// line 44
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($this->getContext($context, "message"), "headers"), "all"));
foreach ($context['_seq'] as $context["_key"] => $context["header"]) {
// line 45
echo " <pre>";
echo twig_escape_filter($this->env, $this->getContext($context, "header"), "html", null, true);
echo "</pre>\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['header'], $context['_parent'], $context['loop']);
$context = array_merge($_parent, array_intersect_key($context, $_parent));
// line 47
echo "\n <p>\n <pre>";
// line 50
if ($this->getAttribute($this->getContext($context, "message"), "charset")) {
// line 51
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "message"), "body"), "html", $this->getAttribute($this->getContext($context, "message"), "charset")), "UTF-8", $this->getAttribute($this->getContext($context, "message"), "charset")), "html", null, true);
} else {
// line 53
echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "message"), "body"), "html");
}
// line 55
echo "</pre>\n </p>\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['i'], $context['message'], $context['_parent'], $context['loop']);
$context = array_merge($_parent, array_intersect_key($context, $_parent));
// line 58
echo " ";
}
}
示例4: block_panel
//.........这里部分代码省略.........
echo " <div class=\"empty\">\n <p>No e-mail messages were sent.</p>\n </div>\n ";
} else {
// line 140
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messages", array(0 => $context["name"]), "method"));
$context['loop'] = array('parent' => $context['_parent'], 'index0' => 0, 'index' => 1, 'first' => true);
if (is_array($context['_seq']) || is_object($context['_seq']) && $context['_seq'] instanceof Countable) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["message"]) {
// line 141
echo " ";
if ($this->getAttribute($context["loop"], "length", array()) > 1) {
// line 142
echo " <h4>E-mail #";
echo twig_escape_filter($this->env, $this->getAttribute($context["loop"], "index", array()), "html", null, true);
echo " details</h4>\n ";
} else {
// line 144
echo " <h4>E-mail details</h4>\n ";
}
// line 146
echo "\n <div class=\"card\">\n <div class=\"card-block\">\n <span class=\"label\">Message headers</span>\n <pre>";
// line 150
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($context["message"], "headers", array()), "all", array()));
foreach ($context['_seq'] as $context["_key"] => $context["header"]) {
// line 151
echo twig_escape_filter($this->env, $context["header"], "html", null, true);
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['header'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 152
echo "</pre>\n </div>\n\n <div class=\"card-block\">\n <span class=\"label\">Message body</span>\n <pre>";
// line 158
if ($this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : null, "charset", array(), "any", true, true) && $this->getAttribute($context["message"], "charset", array())) {
// line 159
echo twig_escape_filter($this->env, twig_convert_encoding($this->getAttribute($context["message"], "body", array()), "UTF-8", $this->getAttribute($context["message"], "charset", array())), "html", null, true);
} else {
// line 161
echo twig_escape_filter($this->env, $this->getAttribute($context["message"], "body", array()), "html", null, true);
}
// line 163
echo "</pre>\n </div>\n\n ";
// line 166
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($context["message"], "children", array()));
foreach ($context['_seq'] as $context["_key"] => $context["messagePart"]) {
if (twig_in_filter($this->getAttribute($context["messagePart"], "contentType", array()), array(0 => "text/plain", 1 => "text/html"))) {
// line 167
echo " <div class=\"card-block\">\n <span class=\"label\">Alternative part (";
// line 168
echo twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "contentType", array()), "html", null, true);
echo ")</span>\n <pre>";
// line 170
if ($this->getAttribute($context["messagePart"], "charset", array())) {
// line 171
echo twig_escape_filter($this->env, twig_convert_encoding($this->getAttribute($context["messagePart"], "body", array()), "UTF-8", $this->getAttribute($context["messagePart"], "charset", array())), "html", null, true);
} else {
// line 173
echo twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "body", array()), "html", null, true);
}
// line 175
echo "</pre>\n </div>\n ";
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['messagePart'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 178
echo " </div>\n ";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['message'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 180
echo " ";
}
// line 181
echo " ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['name'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
$__internal_bc2dfa2f75a4283535b6eb0c6ed2d7f2100d58cb7fe3fb1c1eab67164914aa0a->leave($__internal_bc2dfa2f75a4283535b6eb0c6ed2d7f2100d58cb7fe3fb1c1eab67164914aa0a_prof);
}
开发者ID:MathieuThauvin,项目名称:NDL,代码行数:101,代码来源:0dc366914a910d6a5d8cda0352e8292a119437d408550893d046ca898f1eed3f.php
示例5: _twig_escape_html_attr_callback
/**
* This function is adapted from code coming from Zend Framework.
*
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
function _twig_escape_html_attr_callback($matches)
{
/*
* While HTML supports far more named entities, the lowest common denominator
* has become HTML5's XML Serialisation which is restricted to the those named
* entities that XML supports. Using HTML entities would result in this error:
* XML Parsing Error: undefined entity
*/
static $entityMap = array(34 => 'quot', 38 => 'amp', 60 => 'lt', 62 => 'gt');
$chr = $matches[0];
$ord = ord($chr);
/**
* The following replaces characters undefined in HTML with the
* hex entity for the Unicode replacement character.
*/
if ($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r" || $ord >= 0x7f && $ord <= 0x9f) {
return '�';
}
/**
* Check if the current character to escape has a name entity we should
* replace it with while grabbing the hex value of the character.
*/
if (strlen($chr) == 1) {
$hex = strtoupper(substr('00' . bin2hex($chr), -2));
} else {
$chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
$hex = strtoupper(substr('0000' . bin2hex($chr), -4));
}
$int = hexdec($hex);
if (array_key_exists($int, $entityMap)) {
return sprintf('&%s;', $entityMap[$int]);
}
/**
* Per OWASP recommendations, we'll use hex entities for any other
* characters where a named entity does not exist.
*/
return sprintf('&#x%s;', $hex);
}
示例6: block_panel
public function block_panel($context, array $blocks = array())
{
$__internal_729d2ff73542dbc0735d8864c619747ddf664be50a50dfe070f7284bb2db36fa = $this->env->getExtension("native_profiler");
$__internal_729d2ff73542dbc0735d8864c619747ddf664be50a50dfe070f7284bb2db36fa->enter($__internal_729d2ff73542dbc0735d8864c619747ddf664be50a50dfe070f7284bb2db36fa_prof = new Twig_Profiler_Profile($this->getTemplateName(), "block", "panel"));
// line 42
echo " <h2>Messages</h2>\n\n <table>\n <thead>\n <tr>\n <th scope=\"col\">Mailer</th>\n <th scope=\"col\">Messages</th>\n </tr>\n </thead>\n <tbody>\n ";
// line 52
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "mailers", array()));
foreach ($context['_seq'] as $context["_key"] => $context["name"]) {
// line 53
echo " <tr>\n <th>";
// line 54
echo twig_escape_filter($this->env, $context["name"], "html", null, true);
echo $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "isDefaultMailer", array(0 => $context["name"]), "method") ? " (default mailer)" : "";
echo "</th>\n <td>";
// line 55
echo twig_escape_filter($this->env, $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messageCount", array(0 => $context["name"]), "method"), "html", null, true);
echo " ";
echo $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "isSpool", array(0 => $context["name"]), "method") ? "spooled" : "sent";
echo "</td>\n </tr>\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['name'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 58
echo " </tbody>\n </table>\n\n ";
// line 61
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "mailers", array()));
foreach ($context['_seq'] as $context["_key"] => $context["name"]) {
// line 62
echo " <h3>Mailer <em>";
echo twig_escape_filter($this->env, $context["name"], "html", null, true);
echo "</em>";
echo $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "isDefaultMailer", array(0 => $context["name"]), "method") ? " (default mailer)" : "";
echo "</h3>\n\n ";
// line 64
if (!$this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messages", array(0 => $context["name"]), "method")) {
// line 65
echo " <p>\n <em>No message sent.</em>\n </p>\n ";
} else {
// line 69
echo " <ul class=\"alt\">\n ";
// line 70
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messages", array(0 => $context["name"]), "method"));
$context['loop'] = array('parent' => $context['_parent'], 'index0' => 0, 'index' => 1, 'first' => true);
if (is_array($context['_seq']) || is_object($context['_seq']) && $context['_seq'] instanceof Countable) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["message"]) {
// line 71
echo " <li class=\"";
echo twig_escape_filter($this->env, twig_cycle(array(0 => "odd", 1 => "even"), $this->getAttribute($context["loop"], "index", array())), "html", null, true);
echo "\">\n ";
// line 72
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($context["message"], "headers", array()), "all", array()));
foreach ($context['_seq'] as $context["_key"] => $context["header"]) {
// line 73
echo " <pre>";
echo twig_escape_filter($this->env, $context["header"], "html", null, true);
echo "</pre>\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['header'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 75
echo " <pre>";
// line 76
if ($this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : null, "charset", array(), "any", true, true) && $this->getAttribute($context["message"], "charset", array())) {
// line 77
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute($context["message"], "body", array()), "html", $this->getAttribute($context["message"], "charset", array())), "UTF-8", $this->getAttribute($context["message"], "charset", array())), "html", null, true);
} else {
// line 79
echo twig_escape_filter($this->env, $this->getAttribute($context["message"], "body", array()), "html");
}
// line 81
echo "</pre>\n ";
// line 82
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($context["message"], "children", array()));
foreach ($context['_seq'] as $context["_key"] => $context["messagePart"]) {
if ($this->getAttribute($context["messagePart"], "contentType", array()) == "text/plain" || $this->getAttribute($context["messagePart"], "contentType", array()) == "text/html") {
// line 83
echo " <h4>Alternative part</h4>\n <pre>";
// line 85
if ($this->getAttribute($context["messagePart"], "charset", array())) {
// line 86
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "body", array()), "html", $this->getAttribute($context["messagePart"], "charset", array())), "UTF-8", $this->getAttribute($context["messagePart"], "charset", array())), "html", null, true);
} else {
// line 88
echo twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "body", array()), "html");
}
// line 90
//.........这里部分代码省略.........
开发者ID:Benjichoun,项目名称:Blog_Voyage,代码行数:101,代码来源:25611b5bbcd10dbc5066368e39673a39d20af8dca8aa2bc9a3c9e90b3a75a3c4.php
示例7: twig_escape_filter
/**
* Escapes a string.
*
* @param Twig_Environment $env A Twig_Environment instance
* @param string $string The value to be escaped
* @param string $type The escaping strategy
* @param string $charset The charset
* @param Boolean $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
*/
function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $charset = null, $autoescape = false)
{
if ($autoescape && is_object($string) && $string instanceof Twig_Markup) {
return $string;
}
if (!is_string($string) && !(is_object($string) && method_exists($string, '__toString'))) {
return $string;
}
if (null === $charset) {
$charset = $env->getCharset();
}
$string = (string) $string;
switch ($type) {
case 'js':
// escape all non-alphanumeric characters
// into their \xHH or \uHHHH representations
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (null === ($string = preg_replace_callback('#[^\\p{L}\\p{N} ]#u', '_twig_escape_js_callback', $string))) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
case 'html':
// see http://php.net/htmlspecialchars
// Using a static variable to avoid initializing the array
// each time the function is called. Moving the declaration on the
// top of the function slow downs other escaping types.
static $htmlspecialcharsCharsets = array('iso-8859-1' => true, 'iso8859-1' => true, 'iso-8859-15' => true, 'iso8859-15' => true, 'utf-8' => true, 'cp866' => true, 'ibm866' => true, '866' => true, 'cp1251' => true, 'windows-1251' => true, 'win-1251' => true, '1251' => true, 'cp1252' => true, 'windows-1252' => true, '1252' => true, 'koi8-r' => true, 'koi8-ru' => true, 'koi8r' => true, 'big5' => true, '950' => true, 'gb2312' => true, '936' => true, 'big5-hkscs' => true, 'shift_jis' => true, 'sjis' => true, '932' => true, 'euc-jp' => true, 'eucjp' => true, 'iso8859-5' => true, 'iso-8859-5' => true, 'macroman' => true);
if (isset($htmlspecialcharsCharsets[strtolower($charset)])) {
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
}
$string = twig_convert_encoding($string, 'UTF-8', $charset);
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
return twig_convert_encoding($string, $charset, 'UTF-8');
default:
throw new Twig_Error_Runtime(sprintf('Invalid escape type "%s".', $type));
}
}
示例8: _twig_escape_js_callback
function _twig_escape_js_callback($matches)
{
$char = $matches[0];
// \xHH
if (!isset($char[1])) {
return '\\x' . substr('00' . bin2hex($char), -2);
}
// \uHHHH
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
return '\\u' . substr('0000' . bin2hex($char), -4);
}
示例9: twig_escape_filter
/**
* Escapes a string.
*
* @param Twig_Environment $env A Twig_Environment instance
* @param string $string The value to be escaped
* @param string $strategy The escaping strategy
* @param string $charset The charset
* @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
*
* @return string
*/
function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
{
if ($autoescape && $string instanceof Twig_Markup) {
return $string;
}
if (!is_string($string)) {
if (is_object($string) && method_exists($string, '__toString')) {
$string = (string) $string;
} else {
return $string;
}
}
if (null === $charset) {
$charset = $env->getCharset();
}
switch ($strategy) {
case 'html':
// see http://php.net/htmlspecialchars
// Using a static variable to avoid initializing the array
// each time the function is called. Moving the declaration on the
// top of the function slow downs other escaping strategies.
static $htmlspecialcharsCharsets;
if (null === $htmlspecialcharsCharsets) {
if (defined('HHVM_VERSION')) {
$htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
} else {
$htmlspecialcharsCharsets = array('ISO-8859-1' => true, 'ISO8859-1' => true, 'ISO-8859-15' => true, 'ISO8859-15' => true, 'utf-8' => true, 'UTF-8' => true, 'CP866' => true, 'IBM866' => true, '866' => true, 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true, '1251' => true, 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true, 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true, 'BIG5' => true, '950' => true, 'GB2312' => true, '936' => true, 'BIG5-HKSCS' => true, 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true, 'EUC-JP' => true, 'EUCJP' => true, 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true);
}
}
if (isset($htmlspecialcharsCharsets[$charset])) {
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
}
if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) {
// cache the lowercase variant for future iterations
$htmlspecialcharsCharsets[$charset] = true;
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
}
$string = twig_convert_encoding($string, 'UTF-8', $charset);
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
return twig_convert_encoding($string, $charset, 'UTF-8');
case 'js':
// escape all non-alphanumeric characters
// into their \xHH or \uHHHH representations
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
$string = preg_replace_callback('#[^a-zA-Z0-9,\\._]#Su', function ($matches) {
$char = $matches[0];
// \xHH
if (!isset($char[1])) {
return '\\x' . strtoupper(substr('00' . bin2hex($char), -2));
}
// \uHHHH
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
return '\\u' . strtoupper(substr('0000' . bin2hex($char), -4));
}, $string);
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
case 'css':
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', function ($matches) {
$char = $matches[0];
// \xHH
if (!isset($char[1])) {
$hex = ltrim(strtoupper(bin2hex($char)), '0');
if (0 === strlen($hex)) {
$hex = '0';
}
return '\\' . $hex . ' ';
}
// \uHHHH
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
return '\\' . ltrim(strtoupper(bin2hex($char)), '0') . ' ';
}, $string);
if ('UTF-8' != $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
case 'html_attr':
//.........这里部分代码省略.........
示例10: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_e1a57cc511c240b55441319e18f4f9b5d905ff560379057c158387d1d1e07bc7 = $this->env->getExtension("native_profiler");
$__internal_e1a57cc511c240b55441319e18f4f9b5d905ff560379057c158387d1d1e07bc7->enter($__internal_e1a57cc511c240b55441319e18f4f9b5d905ff560379057c158387d1d1e07bc7_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "headers1Infos.html"));
// line 1
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "Server", array(), "array", true, true)) {
// line 2
echo " ";
$context["headers1_Server"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "Server", array(), "array");
echo " \n";
} else {
// line 4
echo " ";
$context["headers1_Server"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 6
echo "\n";
// line 7
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "X-Powered-By", array(), "array", true, true)) {
// line 8
echo " ";
$context["headers1_X_Powered_By"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "X-Powered-By", array(), "array");
echo " \n";
} else {
// line 10
echo " ";
$context["headers1_X_Powered_By"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 12
echo "\n\n";
// line 14
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "Content-Type", array(), "array", true, true)) {
// line 15
echo " ";
$context["headers1_Content_Type"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "Content-Type", array(), "array");
echo " \n";
} else {
// line 17
echo " ";
$context["headers1_Content_Type"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 19
echo "\n\n";
// line 21
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "Last-Modified", array(), "array", true, true)) {
// line 22
echo "\t";
$context["headers1_Last_Modified"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "Last-Modified", array(), "array");
echo "\t\n";
} else {
// line 24
echo "\t";
$context["headers1_Last_Modified"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 25
echo " \n\n \t\t\n";
// line 28
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "Etag", array(), "array", true, true)) {
// line 29
echo " ";
$context["headers1_Etag"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "Etag", array(), "array");
echo " \n";
} else {
// line 31
echo " ";
$context["headers1_Etag"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 33
echo "\n\n";
// line 35
if ($this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : null, "Content-Length", array(), "array", true, true)) {
// line 36
echo " ";
$context["headers_Content_Length"] = $this->getAttribute(isset($context["headers1"]) ? $context["headers1"] : $this->getContext($context, "headers1"), "Content-Length", array(), "array");
echo " \n";
} else {
// line 38
echo " ";
$context["headers_Content_Length"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 40
echo "\n<a class=\"list-group-item\" href=\"#\">\n <h4 class=\"list-group-item-heading\">HEADERS INFOS : </h4>\n <p class=\"list-group-item-text\">";
// line 43
echo "Serveur";
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers1_Server"]) ? $context["headers1_Server"] : $this->getContext($context, "headers1_Server"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 44
echo twig_escape_filter($this->env, twig_convert_encoding("Langage de développement", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers1_X_Powered_By"]) ? $context["headers1_X_Powered_By"] : $this->getContext($context, "headers1_X_Powered_By"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 45
echo twig_escape_filter($this->env, twig_convert_encoding("Type de contenu", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers1_Content_Type"]) ? $context["headers1_Content_Type"] : $this->getContext($context, "headers1_Content_Type"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 46
echo twig_escape_filter($this->env, twig_convert_encoding("Date de dernière modification", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
//.........这里部分代码省略.........
开发者ID:kibimimi,项目名称:monprojettest,代码行数:101,代码来源:aa9754b1b2870c24018228bd5e83a9f37fe349f6addea1794b2fbaa43807807e.php
示例11: block_panel
public function block_panel($context, array $blocks = array())
{
// line 34
echo " <h2>Messages ";
echo $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "isSpool") ? "spooled" : "sent";
echo "</h2>\n\n ";
// line 36
if (!$this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messages")) {
// line 37
echo " <p>\n <em>No message sent.</em>\n </p>\n ";
} else {
// line 41
echo " ";
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messages"));
foreach ($context['_seq'] as $context["i"] => $context["message"]) {
// line 42
echo " <h3>Message ";
echo twig_escape_filter($this->env, (isset($context["i"]) ? $context["i"] : $this->getContext($context, "i")) + 1, "html", null, true);
echo " / ";
echo twig_escape_filter($this->env, $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "messagecount"), "html", null, true);
echo "</h3>\n\n ";
// line 44
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "headers"), "all"));
foreach ($context['_seq'] as $context["_key"] => $context["header"]) {
// line 45
echo " <pre>";
echo twig_escape_filter($this->env, isset($context["header"]) ? $context["header"] : $this->getContext($context, "header"), "html", null, true);
echo "</pre>\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['header'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 47
echo "\n <p>\n <pre>";
// line 50
if ($this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : null, "charset", array(), "any", true, true) && $this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "charset")) {
// line 51
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "body"), "html", $this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "charset")), "UTF-8", $this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "charset")), "html", null, true);
} else {
// line 53
echo twig_escape_filter($this->env, $this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "body"), "html");
}
// line 55
echo "</pre>\n </p>\n ";
// line 57
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["message"]) ? $context["message"] : $this->getContext($context, "message"), "children"));
foreach ($context['_seq'] as $context["_key"] => $context["messagePart"]) {
if ($this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "contentType") == "text/plain" || $this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "contentType") == "text/html") {
// line 58
echo " <h4>Alternative part</h4>\n <p>\n <pre>";
// line 61
if ($this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "charset")) {
// line 62
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "body"), "html", $this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "charset")), "UTF-8", $this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "charset")), "html", null, true);
} else {
// line 64
echo twig_escape_filter($this->env, $this->getAttribute(isset($context["messagePart"]) ? $context["messagePart"] : $this->getContext($context, "messagePart"), "body"), "html");
}
// line 66
echo "</pre>\n </p>\n ";
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['messagePart'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 69
echo " ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['i'], $context['message'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 70
echo " ";
}
}
示例12: block_panel
//.........这里部分代码省略.........
echo " <ul class=\"alt\">
";
// line 70
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute((isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector")), "messages", array(0 => $context["name"]), "method"));
$context['loop'] = array(
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
);
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["message"]) {
// line 71
echo " <li class=\"";
echo twig_escape_filter($this->env, twig_cycle(array(0 => "odd", 1 => "even"), $this->getAttribute($context["loop"], "index", array())), "html", null, true);
echo "\">
";
// line 72
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($context["message"], "headers", array()), "all", array()));
foreach ($context['_seq'] as $context["_key"] => $context["header"]) {
// line 73
echo " <pre>";
echo twig_escape_filter($this->env, $context["header"], "html", null, true);
echo "</pre>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['header'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 75
echo " <pre>";
// line 76
if (($this->getAttribute((isset($context["messagePart"]) ? $context["messagePart"] : null), "charset", array(), "any", true, true) && $this->getAttribute($context["message"], "charset", array()))) {
// line 77
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute($context["message"], "body", array()), "html", $this->getAttribute($context["message"], "charset", array())), "UTF-8", $this->getAttribute($context["message"], "charset", array())), "html", null, true);
} else {
// line 79
echo twig_escape_filter($this->env, $this->getAttribute($context["message"], "body", array()), "html");
}
// line 81
echo "</pre>
";
// line 82
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($context["message"], "children", array()));
foreach ($context['_seq'] as $context["_key"] => $context["messagePart"]) {
if ((($this->getAttribute($context["messagePart"], "contentType", array()) == "text/plain") || ($this->getAttribute($context["messagePart"], "contentType", array()) == "text/html"))) {
// line 83
echo " <h4>Alternative part</h4>
<pre>";
// line 85
if ($this->getAttribute($context["messagePart"], "charset", array())) {
// line 86
echo twig_escape_filter($this->env, twig_convert_encoding(twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "body", array()), "html", $this->getAttribute($context["messagePart"], "charset", array())), "UTF-8", $this->getAttribute($context["messagePart"], "charset", array())), "html", null, true);
} else {
// line 88
echo twig_escape_filter($this->env, $this->getAttribute($context["messagePart"], "body", array()), "html");
}
// line 90
echo "</pre>
";
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['messagePart'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 92
echo " </li>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['message'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 94
echo " </ul>
";
}
// line 96
echo " ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['name'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
}
示例13: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_1e69ed20d8f7f2817bc009ca58fc86bb9dcf4b5ba632756d8f8b356abd23d9da = $this->env->getExtension("native_profiler");
$__internal_1e69ed20d8f7f2817bc009ca58fc86bb9dcf4b5ba632756d8f8b356abd23d9da->enter($__internal_1e69ed20d8f7f2817bc009ca58fc86bb9dcf4b5ba632756d8f8b356abd23d9da_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "headers2Infos.html"));
// line 1
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "Server", array(), "array", true, true)) {
// line 2
echo " ";
$context["headers2_Server"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "Server", array(), "array");
echo " \n";
} else {
// line 4
echo " ";
$context["headers2_Server"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 6
echo "\n";
// line 7
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "X-Powered-By", array(), "array", true, true)) {
// line 8
echo " ";
$context["headers2_X_Powered_By"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "X-Powered-By", array(), "array");
echo " \n";
} else {
// line 10
echo " ";
$context["headers2_X_Powered_By"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 12
echo "\n\n";
// line 14
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "Content-Type", array(), "array", true, true)) {
// line 15
echo " ";
$context["headers2_Content_Type"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "Content-Type", array(), "array");
echo " \n";
} else {
// line 17
echo " ";
$context["headers2_Content_Type"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 19
echo "\n\n";
// line 21
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "Last-Modified", array(), "array", true, true)) {
// line 22
echo " ";
$context["headers2_Last_Modified"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "Last-Modified", array(), "array");
echo " \n";
} else {
// line 24
echo " ";
$context["headers2_Last_Modified"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 25
echo " \n\n \n";
// line 28
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "Etag", array(), "array", true, true)) {
// line 29
echo " ";
$context["headers2_Etag"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "Etag", array(), "array");
echo " \n";
} else {
// line 31
echo " ";
$context["headers2_Etag"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 33
echo "\n\n";
// line 35
if ($this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : null, "Content-Length", array(), "array", true, true)) {
// line 36
echo " ";
$context["headers_Content_Length"] = $this->getAttribute(isset($context["headers2"]) ? $context["headers2"] : $this->getContext($context, "headers2"), "Content-Length", array(), "array");
echo " \n";
} else {
// line 38
echo " ";
$context["headers_Content_Length"] = twig_convert_encoding("Non défini", "UTF-8", " iso-8859-1");
}
// line 40
echo "\nCache-Control\nConnection\nExpires\nVary\nX-Varnish\n\n<a class=\"list-group-item\" href=\"#\">\n <h4 class=\"list-group-item-heading\">HEADERS INFOS : </h4>\n <p class=\"list-group-item-text\">";
// line 49
echo "Serveur";
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers2_Server"]) ? $context["headers2_Server"] : $this->getContext($context, "headers2_Server"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 50
echo twig_escape_filter($this->env, twig_convert_encoding("Langage de développement", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers2_X_Powered_By"]) ? $context["headers2_X_Powered_By"] : $this->getContext($context, "headers2_X_Powered_By"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 51
echo twig_escape_filter($this->env, twig_convert_encoding("Type de contenu", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
echo twig_escape_filter($this->env, isset($context["headers2_Content_Type"]) ? $context["headers2_Content_Type"] : $this->getContext($context, "headers2_Content_Type"), "html", null, true);
echo "</p>\n <p class=\"list-group-item-text\">";
// line 52
echo twig_escape_filter($this->env, twig_convert_encoding("Date de dernière modification", "UTF-8", " iso-8859-1"), "html", null, true);
echo " : ";
//.........这里部分代码省略.........
开发者ID:kibimimi,项目名称:monprojettest,代码行数:101,代码来源:950ab913fc8bca5a76840389abd10a5c8ce336af579c3ab6b77ebec13bff63e7.php
示例14: _twig_escape_html_attr_callback
/**
* This function is adapted from code coming from Zend Framework.
*
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
function _twig_escape_html_attr_callback($matches)
{
static $entityMap = array(34 => 'quot', 38 => 'amp', 60 => 'lt', 62 => 'gt', 160 => 'nbsp', 161 => 'iexcl', 162 => 'cent', 163 => 'pound', 164 => 'curren', 165 => 'yen', 166 => 'brvbar', 167 => 'sect', 168 => 'uml', 169 => 'copy', 170 => 'ordf', 171 => 'laquo', 172 => 'not', 173 => 'shy', 174 => 'reg', 175 => 'macr', 176 => 'deg', 177 => 'plusmn', 178 => 'sup2', 179 => 'sup3', 180 => 'acute', 181 => 'micro', 182 => 'para', 183 => 'middot', 184 => 'cedil', 185 => 'sup1', 186 => 'ordm', 187 => 'raquo', 188 => 'frac14', 189 => 'frac12', 190 => 'frac34', 191 => 'iquest', 192 => 'Agrave', 193 => 'Aacute', 194 => 'Acirc', 195 => 'Atilde', 196 => 'Auml', 197 => 'Aring', 198 => 'AElig', 199 => 'Ccedil', 200 => 'Egrave', 201 => 'Eacute', 202 => 'Ecirc', 203 => 'Euml', 204 => 'Igrave', 205 => 'Iacute', 206 => 'Icirc', 207 => 'Iuml', 208 => 'ETH', 209 => 'Ntilde', 210 => 'Ograve', 211 => 'Oacute', 212 => 'Ocirc', 213 => 'Otilde', 214 => 'Ouml', 215 => 'times', 216 => 'Oslash', 217 => 'Ugrave', 218 => 'Uacute', 219 => 'Ucirc', 220 => 'Uuml', 221 => 'Yacute', 222 => 'THORN', 223 => 'szlig', 224 => 'agrave', 225 => 'aacute', 226 => 'acirc', 227 => 'atilde', 228 => 'auml', 229 => 'aring', 230 => 'aelig', 231 => 'ccedil', 232 => 'egrave', 233 => 'eacute', 234 => 'ecirc', 235 => 'euml', 236 => 'igrave', 237 => 'iacute', 238 => 'icirc', 239 => 'iuml', 240 => 'eth', 241 => 'ntilde', 242 => 'ograve', 243 => 'oacute', 244 => 'ocirc', 245 => 'otilde', 246 => 'ouml', 247 => 'divide', 248 => 'oslash', 249 => 'ugrave', 250 => 'uacute', 251 => 'ucirc', 252 => 'uuml', 253 => 'yacute', 254 => 'thorn', 255 => 'yuml', 338 => 'OElig', 339 => 'oelig', 352 => 'Scaron', 353 => 'scaron', 376 => 'Yuml', 402 => 'fnof', 710 => 'circ', 732 => 'tilde', 913 => 'Alpha', 914 => 'Beta', 915 => 'Gamma', 916 => 'Delta', 917 => 'Epsilon', 918 => 'Zeta', 919 => 'Eta', 920 => 'Theta', 921 => 'Iota', 922 => 'Kappa', 923 => 'Lambda', 924 => 'Mu', 925 => 'Nu', 926 => 'Xi', 927 => 'Omicron', 928 => 'Pi', 929 => 'Rho', 931 => 'Sigma', 932 => 'Tau', 933 => 'Upsilon', 934 => 'Phi', 935 => 'Chi', 936 => 'Psi', 937 => 'Omega', 945 => 'alpha', 946 => 'beta', 947 => 'gamma', 948 => 'delta', 949 => 'epsilon', 950 => 'zeta', 951 => 'eta', 952 => 'theta', 953 => 'iota', 954 => 'kappa', 955 => 'lambda', 956 => 'mu', 957 => 'nu', 958 => 'xi', 959 => 'omicron', 960 => 'pi', 961 => 'rho', 962 => 'sigmaf', 963 => 'sigma', 964 => 'tau', 965 => 'upsilon', 966 => 'phi', 967 => 'chi', 968 => 'psi', 969 => 'omega', 977 => 'thetasym', 978 => 'upsih', 982 => 'piv', 8194 => 'ensp', 8195 => 'emsp', 8201 => 'thinsp', 8204 => 'zwnj', 8205 => 'zwj', 8206 => 'lrm', 8207 => 'rlm', 8211 => 'ndash', 8212 => 'mdash', 8216 => 'lsquo', 8217 => 'rsquo', 8218 => 'sbquo', 8220 => 'ldquo', 8221 => 'rdquo', 8222 => 'bdquo', 8224 => 'dagger', 8225 => 'Dagger', 8226 => 'bull', 8230 => 'hellip', 8240 => 'permil', 8242 => 'prime', 8243 => 'Prime', 8249 => 'lsaquo', 8250 => 'rsaquo', 8254 => 'oline', 8260 => 'frasl', 8364 => 'euro', 8465 => 'image', 8472 => 'weierp', 8476 => 'real', 8482 => 'trade', 8501 => 'alefsym', 8592 => 'larr', 8593 => 'uarr', 8594 => 'rarr', 8595 => 'darr', 8596 => 'harr', 8629 => 'crarr', 8656 => 'lArr', 8657 => 'uArr', 8658 => 'rArr', 8659 => 'dArr', 8660 => 'hArr', 8704 => 'forall', 8706 => 'part', 8707 => 'exist', 8709 => 'empty', 8711 => 'nabla', 8712 => 'isin', 8713 => 'notin', 8715 => 'ni', 8719 => 'prod', 8721 => 'sum', 8722 => 'minus', 8727 => 'lowast', 8730 => 'radic', 8733 => 'prop', 8734 => 'infin', 8736 => 'ang', 8743 => 'and', 8744 => 'or', 8745 => 'cap', 8746 => 'cup', 8747 => 'int', 8756 => 'there4', 8764 => 'sim', 8773 => 'cong', 8776 => 'asymp', 8800 => 'ne', 8801 => 'equiv', 8804 => 'le', 8805 => 'ge', 8834 => 'sub', 8835 => 'sup', 8836 => 'nsub', 8838 => 'sube', 8839 => 'supe', 8853 => 'oplus', 8855 => 'otimes', 8869 => 'perp', 8901 => 'sdot', 8968 => 'lceil', 8969 => 'rceil', 8970 => 'lfloor', 8971 => 'rfloor', 9001 => 'lang', 9002 => 'rang', 9674 => 'loz', 9824 => 'spades', 9827 => 'clubs', 9829 => 'hearts', 9830 => 'diams');
$chr = $matches[0];
$ord = ord($chr);
/**
* The following replaces characters undefined in HTML with the
* hex entity for the Unicode replacement character.
*/
if ($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r" || $ord >= 0x7f && $ord <= 0x9f) {
return '�';
}
/**
* Check if the current character to escape has a name entity we should
* replace it with while grabbing the hex value of the character.
*/
if (strlen($chr) == 1) {
$hex = strtoupper(substr('00' . bin2hex($chr), -2));
} else {
$chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
$hex = strtoupper(substr('0000' . bin2hex($chr), -4));
}
$int = hexdec($hex);
if (array_key_exists($int, $entityMap)) {
return sprintf('&%s;', $entityMap[$int]);
}
/**
* Per OWASP recommendations, we'll use hex entities for any other
* characters where a named entity does not exist.
*/
return sprintf('&#x%s;', $hex);
}