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


PHP Dwoo_Compiler::getCompiledParams方法代码示例

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


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

示例1: preProcessing

 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     $params = $compiler->getCompiledParams($params);
     $parsedParams = array();
     if (!isset($params['*'])) {
         $params['*'] = array();
     }
     foreach ($params['*'] as $param => $defValue) {
         if (is_numeric($param)) {
             $param = $defValue;
             $defValue = null;
         }
         $param = trim($param, '\'"');
         if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
             throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
         }
         $parsedParams[$param] = $defValue;
     }
     $params['name'] = substr($params['name'], 1, -1);
     $params['*'] = $parsedParams;
     $params['uuid'] = uniqid();
     $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
     $currentBlock =& $compiler->getCurrentBlock();
     $currentBlock['params'] = $params;
     return '';
 }
开发者ID:netfreak,项目名称:pyrocms,代码行数:26,代码来源:template.php

示例2: preProcessing

 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     $params = $compiler->getCompiledParams($params);
     switch (strtolower(trim((string) $params['enabled'], '"\''))) {
         case 'on':
         case 'true':
         case 'enabled':
         case 'enable':
         case '1':
             $enable = true;
             break;
         case 'off':
         case 'false':
         case 'disabled':
         case 'disable':
         case '0':
             $enable = false;
             break;
         default:
             throw new Dwoo_Compilation_Exception($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
     }
     self::$stack[] = $compiler->getAutoEscape();
     $compiler->setAutoEscape($enable);
     return '';
 }
开发者ID:netfreak,项目名称:pyrocms,代码行数:25,代码来源:auto_escape.php

示例3: preProcessing

 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     $params = $compiler->getCompiledParams($params);
     $func = $params['__funcname'];
     $pluginType = $params['__functype'];
     $params = $params['*'];
     if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
         $customPlugins = $compiler->getDwoo()->getCustomPlugins();
         $callback = $customPlugins[$func]['callback'];
         if (is_array($callback)) {
             if (is_object($callback[0])) {
                 $callback = '$this->customPlugins[\'' . $func . '\'][0]->' . $callback[1] . '(';
             } else {
                 $callback = '' . $callback[0] . '::' . $callback[1] . '(';
             }
         } else {
             $callback = $callback . '(';
         }
     } else {
         $callback = 'smarty_block_' . $func . '(';
     }
     $paramsOut = '';
     foreach ($params as $i => $p) {
         $paramsOut .= var_export($i, true) . ' => ' . $p . ',';
     }
     $curBlock =& $compiler->getCurrentBlock();
     $curBlock['params']['postOut'] = Dwoo_Compiler::PHP_OPEN . ' $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $callback . '$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);' . Dwoo_Compiler::PHP_CLOSE;
     return Dwoo_Compiler::PHP_OPEN . $prepend . ' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array(' . $paramsOut . '); $_block_repeat=true; ' . $callback . '$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();' . Dwoo_Compiler::PHP_CLOSE;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:29,代码来源:smartyinterface.php

示例4: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $rparams = $compiler->getRealParams($params);
     $cparams = $compiler->getCompiledParams($params);
     $compiler->setScope($rparams['var']);
     $pre = Dwoo_Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . self::$cnt . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Dwoo_Compiler::PHP_CLOSE;
     $post = Dwoo_Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . self::$cnt++ . ', true);' . "\n}\n" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
     }
     return $pre . $content . $post;
 }
开发者ID:netfreak,项目名称:pyrocms,代码行数:12,代码来源:with.php

示例5: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $params = isset($params['*']) ? $params['*'] : array();
     $params_php = array();
     foreach ($params as $key => $val) {
         $params_php[] = var_export($key, true) . ' => ' . $val;
     }
     $params_php = 'array(' . implode(', ', $params_php) . ')';
     $pre = Dwoo_Compiler::PHP_OPEN . 'ob_start();' . Dwoo_Compiler::PHP_CLOSE;
     $post = Dwoo_Compiler::PHP_OPEN . __CLASS__ . '::_process(ob_get_clean(), ' . $params_php . ');' . Dwoo_Compiler::PHP_CLOSE;
     return $pre . $content . $post;
 }
开发者ID:apeschar,项目名称:php-fw,代码行数:13,代码来源:FWTemplate.class.php

示例6: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $mode = trim($params['mode'], '"\'');
     switch ($mode) {
         case 'js':
         case 'javascript':
             $content = preg_replace('#(?<!:)//\\s[^\\r\\n]*|/\\*.*?\\*/#', '', $content);
         case 'default':
         default:
     }
     $content = preg_replace(array("/\n/", "/\r/", '/(<\\?(?:php)?|<%)\\s*/'), array('', '', '$1 '), preg_replace('#^\\s*(.+?)\\s*$#m', '$1', $content));
     return $content;
 }
开发者ID:nan0desu,项目名称:xyntach,代码行数:14,代码来源:strip.php

示例7: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $p = $compiler->getCompiledParams($params);
     // no content was provided so use the url as display text
     if ($content == "") {
         // merge </a> into the href if href is a string
         if (substr($p['href'], -1) === '"' || substr($p['href'], -1) === '\'') {
             return Dwoo_Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, -1) . '</a>' . substr($p['href'], -1) . ';' . Dwoo_Compiler::PHP_CLOSE;
         }
         // otherwise append
         return Dwoo_Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'</a>\';' . Dwoo_Compiler::PHP_CLOSE;
     }
     // return content
     return $content . '</a>';
 }
开发者ID:nan0desu,项目名称:xyntach,代码行数:15,代码来源:a.php

示例8: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $out = $content . Dwoo_Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();';
     if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
         $out .= "\n" . '$tmp = trim($tmp);';
     }
     if ($params['cat'] === 'true' || $params['cat'] === 1) {
         $out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;';
     }
     if ($params['assign'] !== 'null') {
         $out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;';
     }
     return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Dwoo_Compiler::PHP_CLOSE;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:15,代码来源:capture.php

示例9: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     if (!isset($params['initialized'])) {
         return '';
     }
     $params = $compiler->getCompiledParams($params);
     $pre = Dwoo_Compiler::PHP_OPEN . "elseif (" . implode(' ', self::replaceKeywords($params['*'], $compiler)) . ") {\n" . Dwoo_Compiler::PHP_CLOSE;
     $post = Dwoo_Compiler::PHP_OPEN . "\n}" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
     }
     $block =& $compiler->getCurrentBlock();
     $block['params']['hasElse'] = $pre . $content . $post;
     return '';
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:elseif.php

示例10: postProcessing

 /**
  * Called when Dwoo hits the closing {ifconfig} tag. Returns a PHP string that will make the
  * appropriate get_config(), get_config_plugin() or get_config_plugin_instance() call when the
  * compiled template is executed.
  *
  * @param Dwoo_Compiler $compiler
  * @param array $params
  * @param unknown_type $prepend
  * @param unknown_type $append
  * @param string $content The contents between the opening and closing tags
  */
 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $key = $params['key'];
     $plugintype = $params['plugintype'];
     $pluginname = $params['pluginname'];
     $pluginid = trim($params['pluginid'], '\'"');
     $compareTo = $params['compareTo'];
     if ($plugintype != 'null' && $pluginname != 'null') {
         $function = "get_config_plugin({$plugintype}, {$pluginname}, {$key})";
     } else {
         if ($plugintype != 'null' && $pluginid != 'null') {
             $function = "get_config_plugin_instance({$plugintype}, {$pluginid}, {$key})";
         } else {
             $function = "get_config({$key})";
         }
     }
     $pre = Dwoo_Compiler::PHP_OPEN . "if ({$function} == {$compareTo}) {\n" . Dwoo_Compiler::PHP_CLOSE;
     $post = Dwoo_Compiler::PHP_OPEN . "\n}" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
     }
     return $pre . $content . $post;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:35,代码来源:block.ifconfig.php

示例11: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $tpl = $compiler->getTemplateSource($params['tplPointer']);
     // assigns params
     $src = $params['from'];
     $name = $params['name'];
     // evaluates which global variables have to be computed
     $varName = '$dwoo.loop.' . trim($name, '"\'') . '.';
     $shortVarName = '$.loop.' . trim($name, '"\'') . '.';
     $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
     $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
     $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
     $usesIndex = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
     $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
     $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
     $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
     if (strpos($name, '$this->scope[') !== false) {
         $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
     }
     // gets foreach id
     $cnt = self::$cnt++;
     // builds pre processing output
     $pre = Dwoo_Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';';
     // adds foreach properties
     if ($usesAny) {
         $pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n(";
         if ($usesIndex) {
             $pre .= "\n\t" . '"index"		=> 0,';
         }
         if ($usesIteration) {
             $pre .= "\n\t" . '"iteration"		=> 1,';
         }
         if ($usesFirst) {
             $pre .= "\n\t" . '"first"		=> null,';
         }
         if ($usesLast) {
             $pre .= "\n\t" . '"last"		=> null,';
         }
         if ($usesShow) {
             $pre .= "\n\t" . '"show"		=> $this->isTraversable($_loop' . $cnt . '_data, true),';
         }
         if ($usesTotal) {
             $pre .= "\n\t" . '"total"		=> $this->count($_loop' . $cnt . '_data),';
         }
         $pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];';
     }
     // checks if the loop must be looped
     $pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
     // iterates over keys
     $pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{";
     // updates properties
     if ($usesFirst) {
         $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);';
     }
     if ($usesLast) {
         $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);';
     }
     $pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Dwoo_Compiler::PHP_CLOSE;
     // build post processing output and cache it
     $post = Dwoo_Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);';
     // update properties
     if ($usesIndex) {
         $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;';
     }
     if ($usesIteration) {
         $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;';
     }
     // end loop
     $post .= "\n\t}\n}\n" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
     }
     return $pre . $content . $post;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:75,代码来源:loop.php

示例12: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $params = $compiler->getCompiledParams($params);
     $tpl = $compiler->getTemplateSource($params['tplPointer']);
     // assigns params
     $src = $params['from'];
     if ($params['item'] !== 'null') {
         if ($params['key'] !== 'null') {
             $key = $params['key'];
         }
         $val = $params['item'];
     } elseif ($params['key'] !== 'null') {
         $val = $params['key'];
     } else {
         throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>item</em> parameter missing');
     }
     $name = $params['name'];
     if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
         throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>item</em> parameter must be of type string');
     }
     if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
         throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>key</em> parameter must be of type string');
     }
     // evaluates which global variables have to be computed
     $varName = '$dwoo.foreach.' . trim($name, '"\'') . '.';
     $shortVarName = '$.foreach.' . trim($name, '"\'') . '.';
     $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
     $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
     $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
     $usesIndex = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
     $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
     $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
     $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
     if (strpos($name, '$this->scope[') !== false) {
         $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
     }
     // override globals vars if implode is used
     if ($params['implode'] !== 'null') {
         $implode = $params['implode'];
         $usesAny = true;
         $usesLast = true;
         $usesIteration = true;
         $usesTotal = true;
     }
     // gets foreach id
     $cnt = self::$cnt++;
     // build pre content output
     $pre = Dwoo_Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';';
     // adds foreach properties
     if ($usesAny) {
         $pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n(";
         if ($usesIndex) {
             $pre .= "\n\t" . '"index"		=> 0,';
         }
         if ($usesIteration) {
             $pre .= "\n\t" . '"iteration"		=> 1,';
         }
         if ($usesFirst) {
             $pre .= "\n\t" . '"first"		=> null,';
         }
         if ($usesLast) {
             $pre .= "\n\t" . '"last"		=> null,';
         }
         if ($usesShow) {
             $pre .= "\n\t" . '"show"		=> $this->isArray($_fh' . $cnt . '_data, true),';
         }
         if ($usesTotal) {
             $pre .= "\n\t" . '"total"		=> $this->isArray($_fh' . $cnt . '_data) ? count($_fh' . $cnt . '_data) : 0,';
         }
         $pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];';
     }
     // checks if foreach must be looped
     $pre .= "\n" . 'if ($this->isArray($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') === true)' . "\n{";
     // iterates over keys
     $pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{";
     // updates properties
     if ($usesFirst) {
         $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);';
     }
     if ($usesLast) {
         $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);';
     }
     $pre .= "\n/* -- foreach start output */\n" . Dwoo_Compiler::PHP_CLOSE;
     // build post content output
     $post = Dwoo_Compiler::PHP_OPEN . "\n";
     if (isset($implode)) {
         $post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n";
     }
     $post .= '/* -- foreach end output */';
     // update properties
     if ($usesIndex) {
         $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;';
     }
     if ($usesIteration) {
         $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;';
     }
     // end loop
     $post .= "\n\t}\n}" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:foreach.php

示例13: postProcessing

    public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
    {
        $params = $compiler->getCompiledParams($params);
        $tpl = $compiler->getTemplateSource($params['tplPointer']);
        // assigns params
        $from = $params['from'];
        $name = $params['name'];
        $step = $params['step'];
        $to = $params['to'];
        // evaluates which global variables have to be computed
        $varName = '$dwoo.for.' . trim($name, '"\'') . '.';
        $shortVarName = '$.for.' . trim($name, '"\'') . '.';
        $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
        $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
        $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
        $usesIndex = strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
        $usesIteration = $usesFirst || $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
        $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
        $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
        // gets foreach id
        $cnt = self::$cnt++;
        // builds pre processing output for
        $out = Dwoo_Compiler::PHP_OPEN . "\n" . '$_for' . $cnt . '_from = ' . $from . ';' . "\n" . '$_for' . $cnt . '_to = ' . $to . ';' . "\n" . '$_for' . $cnt . '_step = abs(' . $step . ');' . "\n" . 'if (is_numeric($_for' . $cnt . '_from) && !is_numeric($_for' . $cnt . '_to)) { $this->triggerError(\'For requires the <em>to</em> parameter when using a numerical <em>from</em>\'); }' . "\n" . '$tmp_shows = $this->isArray($_for' . $cnt . '_from, true) || (is_numeric($_for' . $cnt . '_from) && (abs(($_for' . $cnt . '_from - $_for' . $cnt . '_to)/$_for' . $cnt . '_step) !== 0 || $_for' . $cnt . '_from == $_for' . $cnt . '_to));';
        // adds foreach properties
        if ($usesAny) {
            $out .= "\n" . '$this->globals["for"][' . $name . '] = array' . "\n(";
            if ($usesIndex) {
                $out .= "\n\t" . '"index"		=> 0,';
            }
            if ($usesIteration) {
                $out .= "\n\t" . '"iteration"		=> 1,';
            }
            if ($usesFirst) {
                $out .= "\n\t" . '"first"		=> null,';
            }
            if ($usesLast) {
                $out .= "\n\t" . '"last"		=> null,';
            }
            if ($usesShow) {
                $out .= "\n\t" . '"show"		=> $tmp_shows,';
            }
            if ($usesTotal) {
                $out .= "\n\t" . '"total"		=> $this->isArray($_for' . $cnt . '_from) ? floor(count($_for' . $cnt . '_from) / $_for' . $cnt . '_step) : (is_numeric($_for' . $cnt . '_from) ? abs(($_for' . $cnt . '_to + 1 - $_for' . $cnt . '_from)/$_for' . $cnt . '_step) : 0),';
            }
            $out .= "\n);\n" . '$_for' . $cnt . '_glob =& $this->globals["for"][' . $name . '];';
        }
        // checks if for must be looped
        $out .= "\n" . 'if ($tmp_shows)' . "\n{";
        // set from/to to correct values if an array was given
        $out .= "\n\t" . 'if ($this->isArray($_for' . $cnt . '_from, true)) {
		$_for' . $cnt . '_to = is_numeric($_for' . $cnt . '_to) ? $_for' . $cnt . '_to - $_for' . $cnt . '_step : count($_for' . $cnt . '_from) - 1;
		$_for' . $cnt . '_from = 0;
	}';
        // reverse from and to if needed
        $out .= "\n\t" . 'if ($_for' . $cnt . '_from > $_for' . $cnt . '_to) {
		$tmp = $_for' . $cnt . '_from;
		$_for' . $cnt . '_from = $_for' . $cnt . '_to;
		$_for' . $cnt . '_to = $tmp;
	}
	for ($this->scope[' . $name . '] = $_for' . $cnt . '_from; $this->scope[' . $name . '] <= $_for' . $cnt . '_to; $this->scope[' . $name . '] += $_for' . $cnt . '_step)' . "\n\t{";
        // updates properties
        if ($usesIndex) {
            $out .= "\n\t\t" . '$_for' . $cnt . '_glob["index"] = $this->scope[' . $name . '];';
        }
        if ($usesFirst) {
            $out .= "\n\t\t" . '$_for' . $cnt . '_glob["first"] = (string) ($_for' . $cnt . '_glob["iteration"] === 1);';
        }
        if ($usesLast) {
            $out .= "\n\t\t" . '$_for' . $cnt . '_glob["last"] = (string) ($_for' . $cnt . '_glob["iteration"] === $_for' . $cnt . '_glob["total"]);';
        }
        $out .= "\n/* -- for start output */\n" . Dwoo_Compiler::PHP_CLOSE;
        // build post processing output and cache it
        $postOut = Dwoo_Compiler::PHP_OPEN . '/* -- for end output */';
        // update properties
        if ($usesIteration) {
            $postOut .= "\n\t\t" . '$_for' . $cnt . '_glob["iteration"]+=1;';
        }
        // end loop
        $postOut .= "\n\t}\n}\n" . Dwoo_Compiler::PHP_CLOSE;
        if (isset($params['hasElse'])) {
            $postOut .= $params['hasElse'];
        }
        return $out . $content . $postOut;
    }
开发者ID:nan0desu,项目名称:xyntach,代码行数:84,代码来源:for.php

示例14: postProcessing

 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $tokens = $compiler->getParamTokens($params);
     $params = $compiler->getCompiledParams($params);
     $pre = Dwoo_Compiler::PHP_OPEN . 'if (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Dwoo_Compiler::PHP_CLOSE;
     $post = Dwoo_Compiler::PHP_OPEN . "\n}" . Dwoo_Compiler::PHP_CLOSE;
     if (isset($params['hasElse'])) {
         $post .= $params['hasElse'];
     }
     return $pre . $content . $post;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:11,代码来源:if.php

示例15: preProcessing

 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     return Dwoo_Compiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . Dwoo_Compiler::PHP_CLOSE;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:4,代码来源:Dwoo.compiled.php


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