本文整理汇总了PHP中eZTemplateCompiler::generateVariableCode方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateCompiler::generateVariableCode方法的具体用法?PHP eZTemplateCompiler::generateVariableCode怎么用?PHP eZTemplateCompiler::generateVariableCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateCompiler
的用法示例。
在下文中一共展示了eZTemplateCompiler::generateVariableCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generatePHPCodeChildren
//.........这里部分代码省略.........
$variableParameters = array_merge(array('variable-name' => 'var', 'text-result' => true), $variableParameters);
$dataInspection = eZTemplateCompiler::inspectVariableData($tpl, $variableData, $variablePlacement, $resourceData);
$newNode = $node;
$newNode[1] = false;
$treatVariableDataAsNonObject = isset($variableParameters['treat-value-as-non-object']) && $variableParameters['treat-value-as-non-object'];
if ($useComments) {
$php->addComment("Variable data: " . "Is constant: " . ($dataInspection['is-constant'] ? 'Yes' : 'No') . " Is variable: " . ($dataInspection['is-variable'] ? 'Yes' : 'No') . " Has attributes: " . ($dataInspection['has-attributes'] ? 'Yes' : 'No') . " Has operators: " . ($dataInspection['has-operators'] ? 'Yes' : 'No'), true, true, array('spacing' => $spacing));
$originalText = eZTemplateCompiler::fetchTemplatePiece($variablePlacement);
$php->addComment('{' . $originalText . '}', true, true, array('spacing' => $spacing));
}
$generatedVariableName = $variableParameters['variable-name'];
$assignVariable = false;
if ($variableAssignmentName !== false) {
if (is_array($variableAssignmentName)) {
$variableParameters['text-result'] = false;
$assignVariable = true;
} else {
$generatedVariableName = $variableAssignmentName;
$variableParameters['text-result'] = false;
}
}
$isStaticElement = false;
$nodeElements = $node[2];
$knownTypes = array();
if (eZTemplateNodeTool::isStaticElement($nodeElements) and !$variableParameters['text-result']) {
$variableText = $php->thisVariableText(eZTemplateNodeTool::elementStaticValue($nodeElements), 0, 0, false);
$isStaticElement = true;
} else {
if (eZTemplateNodeTool::isPHPVariableElement($nodeElements) and !$variableParameters['text-result']) {
$variableText = '$' . eZTemplateNodeTool::elementStaticValue($nodeElements);
$isStaticElement = true;
} else {
$variableText = "\${$generatedVariableName}";
eZTemplateCompiler::generateVariableCode($php, $tpl, $node, $knownTypes, $dataInspection, array('spacing' => $spacing, 'variable' => $generatedVariableName, 'treat-value-as-non-object' => $treatVariableDataAsNonObject, 'counter' => 0), $resourceData);
}
}
if ($variableParameters['text-result']) {
$textName = eZTemplateCompiler::currentTextName($parameters);
if (count($knownTypes) == 0 or in_array('objectproxy', $knownTypes)) {
$php->addCodePiece("\${$textName} .= ( is_object( \${$generatedVariableName} ) ? compiledFetchText( \$tpl, \$rootNamespace, \$currentNamespace, false, \${$generatedVariableName} ) : \${$generatedVariableName} );" . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "\n" . "unset( \${$generatedVariableName} );\n", array('spacing' => $spacing));
} else {
$php->addCodePiece("\${$textName} .= \${$generatedVariableName};\n" . "unset( \${$generatedVariableName} );\n", array('spacing' => $spacing));
}
} else {
if ($assignVariable) {
$namespace = $variableAssignmentName[0];
$namespaceScope = $variableAssignmentName[1];
$variableName = $variableAssignmentName[2];
$namespaceText = eZTemplateCompiler::generateMergeNamespaceCode($php, $tpl, $namespace, $namespaceScope, array('spacing' => $spacing), true);
if (!is_string($namespaceText)) {
$namespaceText = "\$namespace";
}
$variableNameText = $php->thisVariableText($variableName, 0, 0, false);
$unsetVariableText = false;
if ($variableOnlyExisting) {
if (!$isStaticElement) {
$unsetVariableText = "\n unset( {$variableText} );";
}
$php->addCodePiece("if " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( array_key_exists( {$namespaceText}, \$vars ) && array_key_exists( {$variableNameText}, \$vars[{$namespaceText}] ) )\n" . "{\n" . " \$vars[{$namespaceText}][{$variableNameText}] = {$variableText};{$unsetVariableText}\n" . "}", array('spacing' => $spacing));
} else {
if ($variableOverWrite) {
if (!$isStaticElement) {
$unsetVariableText = "\nunset( {$variableText} );";
}
if (isset($variableParameters['local-variable'])) {
$php->addCodePiece("if ( \$tpl->hasVariable( {$variableNameText}, {$namespaceText} ) )\n{\n");