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


PHP eZTemplateCompiler::TemplatePrefix方法代码示例

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


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

示例1: generateVariableDataCode


//.........这里部分代码省略.........
                                                            $php->addCodePiece($code, array('spacing' => $spacing));
                                                            $php->addVariableUnsetList($unsetList, array('spacing' => $spacing));
                                                        } else {
                                                            if ($variableDataType == eZTemplate::TYPE_INTERNAL_CODE_PIECE) {
                                                                $code = $variableDataItem[1];
                                                                $values = false;
                                                                $matchMap = array('%input%', '%output%');
                                                                $replaceMap = array('$' . $variableAssignmentName, '$' . $variableAssignmentName);
                                                                $unsetList = array();
                                                                $counter = 1;
                                                                if (isset($variableDataItem[3]) && is_array($variableDataItem[3])) {
                                                                    $newParameters = $parameters;
                                                                    $values = $variableDataItem[3];
                                                                    foreach ($values as $value) {
                                                                        $newParameters['counter'] += 1;
                                                                        $newVariableAssignmentName = $newParameters['variable'];
                                                                        $newVariableAssignmentCounter = $newParameters['counter'];
                                                                        if ($newVariableAssignmentCounter > 0) {
                                                                            $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                                        }
                                                                        if (eZTemplateNodeTool::isStaticElement($value)) {
                                                                            $staticValue = eZTemplateNodeTool::elementStaticValue($value);
                                                                            $staticValueText = $php->thisVariableText($staticValue, 0, 0, false);
                                                                            if (preg_match("/%code{$counter}%/", $code)) {
                                                                                $matchMap[] = '%code' . $counter . '%';
                                                                                $replaceMap[] = '';
                                                                            }
                                                                            $matchMap[] = '%' . $counter . '%';
                                                                            $replaceMap[] = $staticValueText;
                                                                        } else {
                                                                            $matchMap[] = '%' . $counter . '%';
                                                                            $replaceMap[] = '$' . $newVariableAssignmentName;
                                                                            $unsetList[] = $newVariableAssignmentName;
                                                                            if (preg_match("/%code{$counter}%/", $code)) {
                                                                                $tmpPHP = new eZPHPCreator('', '', eZTemplateCompiler::TemplatePrefix());
                                                                                $tmpKnownTypes = array();
                                                                                eZTemplateCompiler::generateVariableDataCode($tmpPHP, $tpl, $value, $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                                                $newCode = $tmpPHP->fetch(false);
                                                                                if (count($tmpKnownTypes) == 0 or in_array('objectproxy', $tmpKnownTypes)) {
                                                                                    $newCode .= "while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$newVariableAssignmentName} ) and method_exists( \${$newVariableAssignmentName}, 'templateValue' ) )\n" . "    \${$newVariableAssignmentName} = \${$newVariableAssignmentName}" . "->templateValue();\n";
                                                                                }
                                                                                $matchMap[] = '%code' . $counter . '%';
                                                                                $replaceMap[] = $newCode;
                                                                            } else {
                                                                                $tmpKnownTypes = array();
                                                                                eZTemplateCompiler::generateVariableDataCode($php, $tpl, $value, $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                                                if (!$parameters['treat-value-as-non-object'] and (count($tmpKnownTypes) == 0 or in_array('objectproxy', $tmpKnownTypes))) {
                                                                                    $php->addCodePiece("while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$newVariableAssignmentName} ) and method_exists( \${$newVariableAssignmentName}, 'templateValue' ) )\n" . "    \${$newVariableAssignmentName} = \${$newVariableAssignmentName}" . "->templateValue();\n", array('spacing' => $spacing));
                                                                                }
                                                                            }
                                                                        }
                                                                        ++$counter;
                                                                    }
                                                                }
                                                                if (isset($variableDataItem[4]) && $variableDataItem[4] !== false) {
                                                                    $values = $variableDataItem[4];
                                                                    for ($i = 0; $i < $values; $i++) {
                                                                        $newParameters['counter'] += 1;
                                                                        $newVariableAssignmentName = $newParameters['variable'];
                                                                        $newVariableAssignmentCounter = $newParameters['counter'];
                                                                        if ($newVariableAssignmentCounter > 0) {
                                                                            $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                                        }
                                                                        $matchMap[] = '%tmp' . ($i + 1) . '%';
                                                                        $replaceMap[] = '$' . $newVariableAssignmentName;
                                                                        $unsetList[] = $newVariableAssignmentName;
                                                                    }
                                                                }
                                                                if (isset($variableDataItem[5]) and $variableDataItem[5]) {
                                                                    if (is_array($variableDataItem[5])) {
                                                                        $knownTypes = array_unique(array_merge($knownTypes, $variableDataItem[5]));
                                                                    } else {
                                                                        if (is_string($variableDataItem[5])) {
                                                                            $knownTypes = array_unique(array_merge($knownTypes, array($variableDataItem[5])));
                                                                        } else {
                                                                            $knownTypes = array_unique(array_merge($knownTypes, array('static')));
                                                                        }
                                                                    }
                                                                }
                                                                $code = str_replace($matchMap, $replaceMap, $code);
                                                                $php->addCodePiece($code, array('spacing' => $spacing));
                                                                $php->addVariableUnsetList($unsetList, array('spacing' => $spacing));
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // After the entire expression line is done we try to extract the actual value if proxies are used
        $php->addCodePiece("if (! isset( \${$variableAssignmentName} ) ) \${$variableAssignmentName} = NULL;\n");
        $php->addCodePiece("while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$variableAssignmentName} ) and method_exists( \${$variableAssignmentName}, 'templateValue' ) )\n" . "    \${$variableAssignmentName} = \${$variableAssignmentName}" . "->templateValue();\n");
    }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatecompiler.php


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