• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP twig_convert_encoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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, 'éÄ');
 }
开发者ID:Aryellix,项目名称:scrumator,代码行数:11,代码来源:CoreTest.php


示例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 "    ";
     }
 }
开发者ID:nsteenv,项目名称:bewelcome-symfony,代码行数:54,代码来源:df9ad58db2ef01bd996578be15fd.php


示例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 '&#xFFFD;';
    }
    /**
     * 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);
}
开发者ID:stler,项目名称:NMFrame,代码行数:44,代码来源:Core.php


示例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));
    }
}
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:51,代码来源:Core.php


示例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);
}
开发者ID:SerdarSanri,项目名称:twig-bundle,代码行数:11,代码来源:Core.php


示例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':
//.........这里部分代码省略.........
开发者ID:JohnnyEstilles,项目名称:Twig,代码行数:101,代码来源:Core.php


示例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'] = (ar 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP twig_cycle函数代码示例发布时间:2022-05-23
下一篇:
PHP twig_constant函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap