当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPTAL_Php_CodeWriter::str方法代码示例

本文整理汇总了PHP中PHPTAL_Php_CodeWriter::str方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL_Php_CodeWriter::str方法的具体用法?PHP PHPTAL_Php_CodeWriter::str怎么用?PHP PHPTAL_Php_CodeWriter::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPTAL_Php_CodeWriter的用法示例。


在下文中一共展示了PHPTAL_Php_CodeWriter::str方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     $codewriter->doEval('file_put_contents(' . $codewriter->str($codewriter->getCacheFilesBaseName()) . '.md5(' . $this->cache_tag . '), ob_get_flush())');
     $codewriter->doElse();
     $codewriter->doEval('readfile(' . $codewriter->str($codewriter->getCacheFilesBaseName()) . '.md5(' . $this->cache_tag . '))');
     $codewriter->doEnd('if');
 }
开发者ID:palmic,项目名称:lbox,代码行数:7,代码来源:Cache.php

示例2: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     if ($this->function_name !== null) {
         $codewriter->doEnd();
         $codewriter->pushCode('$ctx->fillSlotCallback(' . $codewriter->str($this->expression) . ', ' . $codewriter->str($this->function_name) . ', $_thistpl, clone $tpl)');
     } else {
         $codewriter->pushCode('$ctx->fillSlot(' . $codewriter->str($this->expression) . ', ob_get_clean())');
     }
 }
开发者ID:gbisra,项目名称:Computer-r-us,代码行数:9,代码来源:FillSlot.php

示例3: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     // ensure that a sources stack exists or create it
     $codewriter->doIf('!isset($_i18n_sources)');
     $codewriter->pushCode('$_i18n_sources = array()');
     $codewriter->end();
     // push current source and use new one
     $codewriter->pushCode('$_i18n_sources[] = ' . $codewriter->getTranslatorReference() . '->setSource(' . $codewriter->str($this->expression) . ')');
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:9,代码来源:Source.php

示例4: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     // end of if PROCEED
     $codewriter->doEnd();
     // if trigger found, notify the end of the node
     $codewriter->doIf($this->var);
     $codewriter->pushCode($this->var . '->end(' . $codewriter->str($this->expression) . ', $tpl)');
     $codewriter->doEnd();
     $codewriter->recycleTempVariable($this->var);
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:10,代码来源:Id.php

示例5: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     // number or variable name followed by time unit
     // optional per expression
     if (!preg_match('/^\\s*([0-9]+\\s*|[a-zA-Z][\\/a-zA-Z0-9_]*\\s+)([dhms])\\s*(?:\\;?\\s*per\\s+([^;]+)|)\\s*$/', $this->expression, $matches)) {
         throw new PHPTAL_ParserException("Cache attribute syntax error: " . $this->expression, $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
     }
     $cache_len = $matches[1];
     if (!is_numeric($cache_len)) {
         $cache_len = $codewriter->evaluateExpression($cache_len);
         if (is_array($cache_len)) {
             throw new PHPTAL_ParserException("Chained expressions in cache length are not supported", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
         }
     }
     switch ($matches[2]) {
         case 'd':
             $cache_len .= '*24';
             /* no break */
         /* no break */
         case 'h':
             $cache_len .= '*60';
             /* no break */
         /* no break */
         case 'm':
             $cache_len .= '*60';
             /* no break */
     }
     $cache_tag = '"' . addslashes($this->phpelement->getQualifiedName() . ':' . $this->phpelement->getSourceLine()) . '"';
     $cache_per_expression = isset($matches[3]) ? trim($matches[3]) : null;
     if ($cache_per_expression == 'url') {
         $cache_tag .= '.$_SERVER["REQUEST_URI"]';
     } elseif ($cache_per_expression == 'nothing') {
         /* do nothing */
     } elseif ($cache_per_expression) {
         $code = $codewriter->evaluateExpression($cache_per_expression);
         if (is_array($code)) {
             throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
         }
         $cache_tag = '(' . $code . ')."@".' . $cache_tag;
     }
     $this->cache_filename_var = $codewriter->createTempVariable();
     $codewriter->doSetVar($this->cache_filename_var, $codewriter->str($codewriter->getCacheFilesBaseName()) . '.md5(' . $cache_tag . ')');
     $cond = '!file_exists(' . $this->cache_filename_var . ') || time() - ' . $cache_len . ' >= filemtime(' . $this->cache_filename_var . ')';
     $codewriter->doIf($cond);
     $codewriter->doEval('ob_start()');
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:46,代码来源:Cache.php

示例6: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $escape = true;
     if (preg_match('/^(text|structure)(?:\\s+(.*)|\\s*$)/', $this->expression, $m)) {
         if ($m[1] == 'structure') {
             $escape = false;
         }
         $this->expression = isset($m[2]) ? $m[2] : '';
     }
     // if no expression is given, the content of the node is used as
     // a translation key
     if (strlen(trim($this->expression)) == 0) {
         $key = $this->_getTranslationKey($this->phpelement, !$escape, $codewriter->getEncoding());
         $key = trim(preg_replace('/\\s+/sm' . ($codewriter->getEncoding() == 'UTF-8' ? 'u' : ''), ' ', $key));
         $code = $codewriter->str($key);
     } else {
         $code = $codewriter->evaluateExpression($this->expression);
     }
     $this->_prepareNames($codewriter, $this->phpelement);
     $codewriter->pushCode('echo $_translator->translate(' . $code . ',' . ($escape ? 'true' : 'false') . ');');
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:21,代码来源:Translate.php

示例7: _getTranslationCode

 /**
  * @param key - unescaped string (not PHP code) for the key
  */
 private function _getTranslationCode(PHPTAL_Php_CodeWriter $codewriter, $key)
 {
     $code = '';
     if (preg_match_all('/\\$\\{(.*?)\\}/', $key, $m)) {
         array_shift($m);
         $m = array_shift($m);
         foreach ($m as $name) {
             $code .= "\n" . '$_translator->setVar(' . $codewriter->str($name) . ',' . PHPTAL_Php_TalesInternal::compileToPHPExpression($name) . ');';
             // allow more complex TAL expressions
         }
         $code .= "\n";
     }
     // notice the false boolean which indicate that the html is escaped
     // elsewhere looks like an hack doesn't it ? :)
     $code .= 'echo ' . $codewriter->escapeCode('$_translator->translate(' . $codewriter->str($key) . ', false)');
     return $code;
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:20,代码来源:Attributes.php

示例8: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     $codewriter->pushCode($codewriter->getTranslatorReference() . '->setVar(' . $codewriter->str($this->expression) . ', ob_get_clean())');
 }
开发者ID:gbisra,项目名称:Computer-r-us,代码行数:4,代码来源:Name.php

示例9: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $codewriter->doIf('$ctx->hasSlot(' . $codewriter->str($this->expression) . ')');
     $codewriter->pushCode('echo $ctx->getSlot(' . $codewriter->str($this->expression) . ')');
     $codewriter->doElse();
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:6,代码来源:DefineSlot.php

示例10: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     $codewriter->pushCode('$_translator->setVar(' . $codewriter->str($this->expression) . ', ob_get_contents())');
     $codewriter->pushCode('ob_end_clean()');
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:5,代码来源:Name.php


注:本文中的PHPTAL_Php_CodeWriter::str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。