예제 #1
0
 protected function walkInclude(IncludeNode $include)
 {
     $ret = "";
     $syms = array();
     if ($include->hasAssign()) {
         $ret .= "ob_start();";
     }
     foreach ($include->getLocals() as $name => $node) {
         $sym = $this->gensym();
         $syms[$sym] = $name;
         $ret .= "{$sym} = \${$name}; \${$name} = " . $this->walk($node) . ";";
     }
     if ($include->getScope() !== IncludeNode::SCOPE_PARENT) {
         foreach ($include->getTemplate()->getContext()->getVariableNames() as $name) {
             $sym = $this->gensym();
             $syms[$sym] = $name;
             $ret .= "{$sym} = \${$name};";
         }
     }
     $smartySym = $this->gensym();
     $ret .= "{$smartySym} = \$smarty;";
     $syms[$smartySym] = "smarty";
     $ret .= "\$smarty = (object) array('get' => \$_GET, 'post' => \$_POST, 'cookie' => \$_COOKIE, 'now' => {$smartySym}->now, 'capture' => (object) array(), 'foreach' => (object) array(), 'section' => (object) array());";
     $ret .= $this->walk($include->getTemplate());
     foreach (array_reverse($syms, true) as $sym => $name) {
         $ret .= "\${$name} = {$sym};";
     }
     if ($include->hasAssign()) {
         $ret .= "\${$include->getAssign()} = ob_get_clean();";
     }
     return $ret;
 }
 protected function walkInclude(IncludeNode $include)
 {
     $this->walk($include->getTemplate());
 }