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


PHP PHPTAL_Php_CodeWriter::pushCode方法代码示例

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


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

示例1: 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

示例2: before

 public function before(PHPTAL_Php_CodeWriter $codewriter)
 {
     $this->tmp_var = $codewriter->createTempVariable();
     $codewriter->doSetVar($this->tmp_var, $codewriter->interpolateTalesVarsInString($this->expression));
     $codewriter->doIf('$ctx->hasSlot(' . $this->tmp_var . ')');
     $codewriter->pushCode('$ctx->echoSlot(' . $this->tmp_var . ')');
     $codewriter->doElse();
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:8,代码来源:DefineSlot.php

示例3: 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

示例4: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     $var = $codewriter->createTempVariable();
     $codewriter->pushCode('ob_end_flush()');
     $codewriter->doCatch('Exception ' . $var);
     $codewriter->pushCode('$tpl->addError(' . $var . ')');
     $codewriter->pushCode('ob_end_clean()');
     $expression = $this->extractEchoType($this->expression);
     $code = $codewriter->evaluateExpression($expression);
     switch ($code) {
         case PHPTAL_Php_TalesInternal::NOTHING_KEYWORD:
             break;
         case PHPTAL_Php_TalesInternal::DEFAULT_KEYWORD:
             $codewriter->pushHTML('<pre class="phptalError"');
             $codewriter->doEchoRaw($var);
             $codewriter->pushHTML('</pre>');
             break;
         default:
             $this->doEchoAttribute($codewriter, $code);
             break;
     }
     $codewriter->doEnd();
     $codewriter->recycleTempVariable($var);
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:24,代码来源:OnError.php

示例5: before

    /**
     * Attach html5 data attributes to element.
     *
     * Called before generating the compiled php for an attribute.
     *
     * Example (where 'element' is a Zend_Form_Element):
     *
     * <input ztal:data-attributes="element" />
     *
     * Within a Zend_Form implementation:
     *
     * $this->addElement('text', 'example', array(
     * 		'data' => array(
     * 			'hike' => 'foo',
     * 			'bar' => '1337',
     * 		)
     * ));
     *
     * @param PHPTAL_Php_CodeWriter $codewriter The code writer.
     *
     * @return void
     */
    public function before(\PHPTAL_Php_CodeWriter $codewriter)
    {
        $args = explode(',', $this->expression);
        $zendFormElement = $codewriter->evaluateExpression(trim($args[0]));
        $dataAttributes = $codewriter->createTempVariable();
        $tmp = $codewriter->createTempVariable();
        $assignment = $tmp . ' = ' . $zendFormElement . ';' . PHP_EOL;
        $attributes = '$attributes = ' . $tmp . '->getAttribs();';
        if (count($args) > 1) {
            $option = $codewriter->evaluateExpression(trim($args[1]));
            $optionVar = $codewriter->createTempVariable();
            $assignment .= $optionVar . ' = ' . $option . ';' . PHP_EOL;
            $attributes = '$attributes = ' . $tmp . '->getAttribsForOption(' . $optionVar . ');';
        }
        // PHPTAL changed the method signature for phptal_escape in v1.2.3.
        if (defined('PHPTAL_VERSION') && version_compare(PHPTAL_VERSION, '1.2.3', '>=')) {
            $escapeFunctionCall = 'phptal_escape($value, \'UTF-8\')';
        } else {
            $escapeFunctionCall = 'phptal_escape($value)';
        }
        /**
         * Compiled code will loop through a Zend_Form_Element attributes
         * looking for the 'data' key, and assign it to a known temporary
         * variable.
         */
        $source = '
		' . $assignment . '
		if ((is_object(' . $tmp . ')
			&& ' . $tmp . ' instanceof Zend_Form_Element)
		) {
			' . $attributes . PHP_EOL . '
			' . $dataAttributes . ' = " ";

			if (isset($attributes["data"]) && is_array($attributes["data"])) {
				foreach ($attributes["data"] as $key => $value) {
					' . $dataAttributes . ' .= "data-{$key}=\\"" . ' . $escapeFunctionCall . ' . "\\" ";
				}
				' . $dataAttributes . ' = rtrim(' . $dataAttributes . ');
			}
		}';
        // persist the code for compilation
        $codewriter->pushCode($source);
        // get the current DOM element to pull in the attributes
        $this->phpelement->getOrCreateAttributeNode('ztal:data-attributes')->overwriteFullWithVariable($dataAttributes);
    }
开发者ID:namesco,项目名称:ztal,代码行数:67,代码来源:DataAttributes.php

示例6: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     // restore source
     $code = $codewriter->getTranslatorReference() . '->setSource(array_pop($_i18n_sources))';
     $codewriter->pushCode($code);
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:6,代码来源:Source.php

示例7: 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

示例8: bufferizeContent

 private function bufferizeContent(PHPTAL_Php_CodeWriter $codewriter)
 {
     if (!$this->_buffered) {
         $this->tmp_content_var = $codewriter->createTempVariable();
         $codewriter->pushCode('ob_start()');
         $this->phpelement->generateContent($codewriter);
         $codewriter->doSetVar($this->tmp_content_var, 'ob_get_clean()');
         $this->_buffered = true;
     }
     $this->doDefineVarWith($codewriter, $this->tmp_content_var);
 }
开发者ID:palmic,项目名称:lbox,代码行数:11,代码来源:Define.php

示例9: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     $code = '$ctx->fillSlot("' . $this->expression . '", ob_get_clean())';
     $codewriter->pushCode($code);
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:5,代码来源:FillSlot.php

示例10: popSlots

 /**
  * generate code that pops macro slots
  * (restore slots if not inherited macro)
  */
 private function popSlots(PHPTAL_Php_CodeWriter $codewriter)
 {
     if (!$this->phpelement->hasAttributeNS('http://xml.zope.org/namespaces/metal', 'define-macro')) {
         $codewriter->pushCode('$ctx->popSlots()');
     }
 }
开发者ID:palmic,项目名称:lbox,代码行数:10,代码来源:UseMacro.php

示例11: 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

示例12: after

 public function after(PHPTAL_Php_CodeWriter $codewriter)
 {
     // restore domain
     $code = '$_translator->useDomain(array_pop($_i18n_domains))';
     $codewriter->pushCode($code);
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:6,代码来源:Domain.php

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