本文整理汇总了PHP中eZTemplateCompiler::inspectVariableData方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateCompiler::inspectVariableData方法的具体用法?PHP eZTemplateCompiler::inspectVariableData怎么用?PHP eZTemplateCompiler::inspectVariableData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateCompiler
的用法示例。
在下文中一共展示了eZTemplateCompiler::inspectVariableData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: functionTemplateStatistics
function functionTemplateStatistics($functionName, &$node, $tpl, $resourceData, $namespace, &$stats)
{
$newNamespace = $namespace;
$parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
if ($functionName == $this->SetName or $functionName == $this->LetName or $functionName == $this->DefaultName) {
if (isset($parameters['-name'])) {
$nameData = $parameters['-name'];
$nameDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $nameData, false, $resourceData);
if ($nameDataInspection['is-constant'] and !$nameDataInspection['has-operators'] and !$nameDataInspection['has-attributes']) {
$parameterNamespace = $nameDataInspection['new-data'][0][1];
$newNamespace = $tpl->mergeNamespace($namespace, $parameterNamespace);
}
}
}
if ($functionName == $this->SetName) {
foreach (array_keys($parameters) as $name) {
if ($name == '-name') {
continue;
}
$parameter =& $parameters[$name];
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array('is_modified' => true));
eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
}
} else {
if ($functionName == $this->LetName) {
foreach (array_keys($parameters) as $name) {
if ($name == '-name') {
continue;
}
$parameter =& $parameters[$name];
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array('is_created' => true, 'is_removed' => true));
eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
}
} else {
if ($functionName == $this->DefaultName) {
foreach (array_keys($parameters) as $name) {
if ($name == '-name') {
continue;
}
$parameter =& $parameters[$name];
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array());
eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
}
}
}
}
if ($functionName == $this->LetName or $functionName == $this->DefaultName) {
$functionChildren = eZTemplateNodeTool::extractFunctionNodeChildren($node);
if (is_array($functionChildren)) {
eZTemplateCompiler::calculateVariableStatisticsChildren($tpl, $functionChildren, $resourceData, $newNamespace, $stats);
}
}
}
示例2: generatePHPCodeChildren
//.........这里部分代码省略.........
}
continue;
} else {
if ($nodeType == eZTemplate::NODE_TEXT) {
$text = $node[2];
if ($text != '') {
$variablePlacement = $node[3];
$originalText = eZTemplateCompiler::fetchTemplatePiece($variablePlacement);
if ($useComments) {
$php->addComment("Text start:", true, true, array('spacing' => $currentParameters['spacing']));
$php->addComment($originalText, true, true, array('spacing' => $currentParameters['spacing']));
$php->addComment("Text end:", true, true, array('spacing' => $currentParameters['spacing']));
}
$php->addVariable(eZTemplateCompiler::currentTextName($parameters), $text, eZPHPCreator::VARIABLE_APPEND_TEXT, array('spacing' => $currentParameters['spacing']));
}
continue;
} else {
if ($nodeType == eZTemplate::NODE_VARIABLE) {
$variableAssignmentName = $node[1];
$variableData = $node[2];
$variablePlacement = $node[3];
$variableParameters = array();
if (isset($node[4]) and $node[4]) {
$variableParameters = $node[4];
}
$variableOnlyExisting = isset($node[5]) ? $node[5] : false;
$variableOverWrite = isset($node[6]) ? $node[6] : false;
$rememberSet = isset($node[7]) ? $node[7] : false;
$spacing = $currentParameters['spacing'];
if (isset($variableParameters['spacing'])) {
$spacing += $variableParameters['spacing'];
}
$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);
示例3: functionTemplateStatistics
function functionTemplateStatistics($functionName, &$node, $tpl, $resourceData, $namespace, &$stats)
{
if ($functionName != $this->Name) {
return false;
}
$newNamespace = $namespace;
$parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
if (isset($parameters['name'])) {
$nameData = $parameters['name'];
$nameDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $nameData, false, $resourceData);
if ($nameDataInspection['is-constant'] and !$nameDataInspection['has-operators'] and !$nameDataInspection['has-attributes']) {
$parameterNamespace = $nameDataInspection['new-data'][0][1];
$newNamespace = $tpl->mergeNamespace($namespace, $parameterNamespace);
}
}
$parameterNames = array('loop', 'show', 'var', 'last-value', 'reverse', 'sequence', 'max', 'offset');
foreach ($parameterNames as $parameterName) {
if (isset($parameters[$parameterName])) {
eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameters[$parameterName], false, $resourceData, $namespace, $stats);
}
}
if (!isset($parameters['var'])) {
if (isset($parameters['loop'])) {
$newVariables = array('key', 'item', 'index', 'number');
foreach ($newVariables as $newVariableName) {
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $newVariableName, array('is_created' => true, 'is_removed' => true));
}
}
if (isset($parameters['sequence'])) {
$newVariables = array('sequence');
foreach ($newVariables as $newVariableName) {
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $newVariableName, array('is_created' => true, 'is_removed' => true));
}
}
} else {
if (isset($parameters['loop'])) {
$varDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $parameters['var'], false, $resourceData);
if ($varDataInspection['is-constant'] and !$varDataInspection['has-operators'] and !$varDataInspection['has-attributes']) {
$varName = $varDataInspection['new-data'][0][1];
eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $varName, array('is_created' => true, 'is_removed' => true));
}
}
}
$functionChildren = eZTemplateNodeTool::extractFunctionNodeChildren($node);
if (is_array($functionChildren)) {
eZTemplateCompiler::calculateVariableStatisticsChildren($tpl, $functionChildren, $resourceData, $newNamespace, $stats);
}
}