Ejemplo n.º 1
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     if (!$islast) {
         $var = $executor->getCodeWriter()->createTempVariable();
         $executor->doIf('!phptal_isempty(' . $var . ' = ' . $exp . ')');
         $this->doEchoAttribute($executor->getCodeWriter(), $var);
         $executor->getCodeWriter()->recycleTempVariable($var);
     } else {
         $executor->doElse();
         $this->doEchoAttribute($executor->getCodeWriter(), $exp);
     }
 }
Ejemplo n.º 2
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     // check if the expression is empty
     if ($exp !== 'false') {
         $this->expressions[] = '!phptal_isempty(' . $exp . ')';
     }
     if ($islast) {
         // for the last one in the chain build a ORed condition
         $executor->getCodeWriter()->doIf(implode(' || ', $this->expressions));
         // The executor will always end an if so we output a dummy if
         $executor->doIf('false');
     }
 }
Ejemplo n.º 3
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     $codewriter = $executor->getCodeWriter();
     $escape = !($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE);
     $exp = $codewriter->getTranslatorReference() . "->translate({$exp}, " . ($escape ? 'true' : 'false') . ')';
     if (!$islast) {
         $var = $codewriter->createTempVariable();
         $executor->doIf('!phptal_isempty(' . $var . ' = ' . $exp . ')');
         $codewriter->pushCode("echo {$var}");
         $codewriter->recycleTempVariable($var);
     } else {
         $executor->doElse();
         $codewriter->pushCode("echo {$exp}");
     }
 }
Ejemplo n.º 4
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     if ($this->_defineScope == 'global') {
         $executor->doIf('($glb->' . $this->_defineVar . ' = ' . $exp . ') !== null');
     } else {
         $executor->doIf('($ctx->' . $this->_defineVar . ' = ' . $exp . ') !== null');
     }
 }
Ejemplo n.º 5
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     if ($this->_defineScope == 'global') {
         $var = '$tpl->getGlobalContext()->' . $this->_defineVar;
     } else {
         $var = '$ctx->' . $this->_defineVar;
     }
     $cw = $executor->getCodeWriter();
     if (!$islast) {
         // must use temp variable, because expression could refer to itself
         $tmp = $cw->createTempVariable();
         $executor->doIf('(' . $tmp . ' = ' . $exp . ') !== null');
         $cw->doSetVar($var, $tmp);
         $cw->recycleTempVariable($tmp);
     } else {
         $executor->doIf('(' . $var . ' = ' . $exp . ') !== null');
     }
 }
Ejemplo n.º 6
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     $codewriter = $executor->getCodeWriter();
     if (!$islast) {
         $condition = "!phptal_isempty({$this->_attkey} = ({$exp}))";
     } else {
         $condition = "NULL !== ({$this->_attkey} = ({$exp}))";
     }
     $executor->doIf($condition);
     if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) {
         $value = $codewriter->stringifyCode($this->_attkey);
     } else {
         $value = $codewriter->escapeCode($this->_attkey);
     }
     $codewriter->doSetVar($this->_attkey, $codewriter->str(" {$this->_attribute}=\"") . ".{$value}.'\"'");
 }
Ejemplo n.º 7
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     if (!$islast) {
         $condition = "!phptal_isempty({$this->_attkey} = {$exp})";
     } else {
         $condition = "NULL !== ({$this->_attkey} = {$exp})";
     }
     $executor->doIf($condition);
     if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) {
         $value = $this->_attkey;
     } else {
         $value = $this->tag->generator->escapeCode($this->_attkey);
     }
     $this->tag->generator->doSetVar($this->_attkey, "' {$this->_attribute}=\"'.{$value}.'\"'");
 }
Ejemplo n.º 8
0
 public function talesChainDefaultKeyword(PHPTAL_Php_TalesChainExecutor $executor)
 {
     $executor->doElse();
     $this->generateDefault($executor->getCodeWriter());
     $executor->breakChain();
 }
Ejemplo n.º 9
0
 public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast)
 {
     $executor->doIf('!phptal_isempty(' . self::REPLACE_VAR . ' = ' . $exp . ')');
     $this->doEcho(self::REPLACE_VAR);
 }