public function preRenderDocument(Document $document, array &$documents = array()) { $this->setTwigGlobals($document); // Force autoloading of Twig_Extension_StringLoader $this->twig->getExtension('string_loader'); try { $template = twig_template_from_string($this->twig, $document->getBody() ?: ''); } catch (\Twig_Error $e) { throw $this->enhanceTwigException($e, $document); } $nbsItems = $template->getNbsItems(array()); $maxesPerPage = $template->getMaxesPerPage(); if (!$this->haveToPaginate($nbsItems, $maxesPerPage)) { $parameters = array(); foreach ($nbsItems as $key => $nbItems) { $parameters[sprintf('__offset_%d__', $key)] = 0; $parameters[sprintf('__pages_%d__', $key)] = array($document); $parameters[sprintf('__current_page_%d__', $key)] = 1; } try { $document->setBody($template->render($parameters)); } catch (\Twig_Error $e) { throw $this->enhanceTwigException($e, $document, $template); } } $parameters = array(); $paginations = array(); foreach ($nbsItems as $key => $nbItems) { $nbPages = ceil($nbItems / $maxesPerPage[$key]); $paginations[$key] = $this->generatePages($document, $nbPages, 0 == $key, $key); $parameters[sprintf('__offset_%d__', $key)] = 0; $parameters[sprintf('__pages_%d__', $key)] = $paginations[$key]; $parameters[sprintf('__current_page_%d__', $key)] = 1; } try { $body = $template->render($parameters); } catch (\Twig_Error $e) { throw $this->enhanceTwigException($e, $document, $template); } $document->setBody($body); foreach ($paginations as $key => $pages) { $parametersTmp = $parameters; foreach ($pages as $nbPage => $page) { if (1 == $nbPage) { continue; } $parametersTmp[sprintf('__offset_%d__', $key)] = ($nbPage - 1) * $maxesPerPage[$key]; $parametersTmp[sprintf('__current_page_%d__', $key)] = $nbPage; try { $body = $template->render($parametersTmp); } catch (\Twig_Error $e) { throw $this->enhanceTwigException($e, $document, $template); } $page->setBody($body); $documents[] = $page; } } }
public function block_main($context, array $blocks = array()) { // line 80 echo " "; // line 93 echo "\n <!-- ▼item_detail▼ -->\n <div id=\"item_detail\">\n <div class=\"row\">\n <!--★画像★-->\n <div id=\"item_photo_area\" class=\"col-sm-6\">\n <div class=\"slides\">\n "; // line 100 if (twig_length_filter($this->env, $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "ProductImage", array())) > 0) { // line 101 echo " "; $context['_parent'] = $context; $context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "ProductImage", array())); foreach ($context['_seq'] as $context["_key"] => $context["ProductImage"]) { // line 102 echo " <div><img src=\""; echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute(isset($context["app"]) ? $context["app"] : null, "config", array()), "image_save_urlpath", array()), "html", null, true); echo "/"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getNoImageProduct($context["ProductImage"]), "html", null, true); echo "\"/></div>\n "; } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['_key'], $context['ProductImage'], $context['_parent'], $context['loop']); $context = array_intersect_key($context, $_parent) + $_parent; // line 104 echo " "; } else { // line 105 echo " <div><img src=\""; echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute(isset($context["app"]) ? $context["app"] : null, "config", array()), "image_save_urlpath", array()), "html", null, true); echo "/"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getNoImageProduct(""), "html", null, true); echo "\"/></div>\n "; } // line 107 echo " </div>\n </div>\n\n <section id=\"item_detail_area\" class=\"col-sm-6\">\n\n <!--★商品名★-->\n <h3 class=\"item_name\">"; // line 113 echo twig_escape_filter($this->env, $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "name", array()), "html", null, true); echo "</h3>\n <div class=\"item_detail\">\n <!--★通常価格★-->\n "; // line 116 if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "hasProductClass", array())) { // line 117 if (!(null === $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Min", array())) && $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Min", array()) == $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Max", array())) { // line 118 echo " <p class=\"normal_price\"> 通常価格:<span class=\"price01_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01IncTaxMin", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } elseif (!(null === $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Min", array())) && !(null === $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Max", array()))) { // line 120 echo " <p class=\"normal_price\"> 通常価格:<span class=\"price01_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01IncTaxMin", array())), "html", null, true); echo "</span> ~ <span class=\"price01_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01IncTaxMax", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } // line 122 echo " "; } else { // line 123 if (!(null === $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01Max", array()))) { // line 124 echo " <p class=\"normal_price\"> 通常価格:<span class=\"price01_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice01IncTaxMin", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } // line 126 echo " "; } // line 128 echo "<!--★販売価格★-->\n "; // line 129 if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "hasProductClass", array())) { // line 130 if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02Min", array()) == $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02Max", array())) { // line 131 echo " <p class=\"sale_price text-primary\"> <span class=\"price02_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02IncTaxMin", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } else { // line 133 echo " <p class=\"sale_price text-primary\"> <span class=\"price02_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02IncTaxMin", array())), "html", null, true); echo "</span> ~ <span class=\"price02_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02IncTaxMax", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } // line 135 echo " "; } else { // line 136 echo "<p class=\"sale_price text-primary\"> <span class=\"price02_default\">"; echo twig_escape_filter($this->env, $this->env->getExtension('eccube')->getPriceFilter($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "getPrice02IncTaxMin", array())), "html", null, true); echo "</span> <span class=\"small\">税込</span></p>\n "; } // line 139 echo "<!--▼商品コード-->\n <p class=\"item_code\">商品コード: <span id=\"item_code_default\">\n "; // line 141 echo twig_escape_filter($this->env, $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "code_min", array()), "html", null, true); echo "\n "; // line 142 if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "code_min", array()) != $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "code_max", array())) { echo " ~ "; echo twig_escape_filter($this->env, $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "code_max", array()), "html", null, true); } // line 143 echo " </span> </p>\n <!--▲商品コード-->\n\n <!-- ▼関連カテゴリ▼ -->\n <div class=\"relative_cat\">\n <p>関連カテゴリ</p>\n "; // line 149 $context['_parent'] = $context; $context['_seq'] = twig_ensure_traversable($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "ProductCategories", array())); foreach ($context['_seq'] as $context["_key"] => $context["ProductCategory"]) { // line 150 echo " <ol>\n "; // line 151 $context['_parent'] = $context; $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($context["ProductCategory"], "Category", array()), "path", array())); foreach ($context['_seq'] as $context["_key"] => $context["Category"]) { // line 152 echo " <li><a href=\""; echo $this->env->getExtension('routing')->getUrl("product_list"); echo "?category_id="; echo twig_escape_filter($this->env, $this->getAttribute($context["Category"], "id", array()), "html", null, true); echo "\">"; echo twig_escape_filter($this->env, $this->getAttribute($context["Category"], "name", array()), "html", null, true); echo "</a></li>\n "; } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['_key'], $context['Category'], $context['_parent'], $context['loop']); $context = array_intersect_key($context, $_parent) + $_parent; // line 154 echo " </ol>\n "; } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['_key'], $context['ProductCategory'], $context['_parent'], $context['loop']); $context = array_intersect_key($context, $_parent) + $_parent; // line 156 echo " </div>\n <!-- ▲関連カテゴリ▲ -->\n\n <form action=\"?\" method=\"post\" id=\"form1\" name=\"form1\">\n <!--▼買い物かご-->\n <div class=\"cart_area\">\n "; // line 162 if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "stock_find", array())) { // line 163 echo "\n "; // line 165 echo " "; if ($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id1", array(), "any", true, true)) { // line 166 echo " <ul class=\"classcategory_list\">\n "; // line 168 echo " <li>\n "; // line 169 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id1", array()), 'widget'); echo "\n "; // line 170 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id1", array()), 'errors'); echo "\n </li>\n "; // line 173 echo " "; if ($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id2", array(), "any", true, true)) { // line 174 echo " <li>\n "; // line 175 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id2", array()), 'widget'); echo "\n "; // line 176 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "classcategory_id2", array()), 'errors'); echo "\n </li>\n "; } // line 179 echo " </ul>\n "; } // line 181 echo "\n "; // line 183 echo " <dl class=\"quantity\">\n <dt>数量</dt>\n <dd>\n "; // line 186 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "quantity", array()), 'widget'); echo "\n "; // line 187 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute(isset($context["form"]) ? $context["form"] : null, "quantity", array()), 'errors'); echo "\n </dd>\n </dl>\n\n "; // line 192 echo " <div class=\"btn_area\">\n <ul class=\"row\">\n <li class=\"col-xs-12 col-sm-8\"><button type=\"submit\" class=\"btn btn-primary btn-block\">カートに入れる</button></li>\n </ul>\n </div>\n "; } else { // line 198 echo " "; // line 199 echo " <div class=\"btn_area\">\n <ul class=\"row\">\n <li class=\"col-xs-12 col-sm-8\"><button type=\"button\" class=\"btn btn-default btn-block\" disabled=\"disabled\">ただいま品切れ中です</button></li>\n </ul>\n </div>\n "; } // line 205 echo " </div>\n <!--▲買い物かご-->\n "; // line 207 echo $this->env->getExtension('form')->renderer->searchAndRenderBlock(isset($context["form"]) ? $context["form"] : null, 'rest'); echo "\n </form>\n\n <!--★商品説明★-->\n <p class=\"item_comment\">"; // line 211 echo nl2br($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "description_detail", array())); echo "</p>\n\n </div>\n <!-- /.item_detail -->\n\n </section>\n <!--詳細ここまで-->\n </div>\n\n "; // line 221 echo " "; if ($this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "freearea", array())) { // line 222 echo " <div id=\"sub_area\" class=\"row\">\n <div class=\"col-sm-10 col-sm-offset-1\">\n <div class=\"freearea\">"; // line 224 echo twig_include($this->env, $context, twig_template_from_string($this->env, $this->getAttribute(isset($context["Product"]) ? $context["Product"] : null, "freearea", array()))); echo "</div>\n </div>\n </div>\n "; } // line 228 echo " </div>\n <!-- ▲item_detail▲ -->\n"; }
public function filter($content, array $context, $options) { $template = twig_template_from_string($this->twig, $content); return $template->render($context); }