static function inspectVariableData($tpl, $variableData, $variablePlacement, &$resourceData) { $dataInspection = array('is-constant' => false, 'is-variable' => false, 'has-operators' => false, 'has-attributes' => false); if (!is_array($variableData)) { return $dataInspection; } $newVariableData = array(); // Static optimizations, the following items are done: // - Recognize static data // - Extract static data, if possible, from operators // - Remove parameters and input which not be used. foreach ($variableData as $variableItem) { $variableItemType = $variableItem[0]; $variableItemData = $variableItem[1]; $variableItemPlacement = $variableItem[2]; if ($variableItemType == eZTemplate::TYPE_STRING or $variableItemType == eZTemplate::TYPE_IDENTIFIER) { $dataInspection['is-constant'] = true; $dataInspection['is-variable'] = false; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_NUMERIC) { $dataInspection['is-constant'] = true; $dataInspection['is-variable'] = false; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_BOOLEAN) { $dataInspection['is-constant'] = true; $dataInspection['is-variable'] = false; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_DYNAMIC_ARRAY) { $dataInspection['is-constant'] = false; $dataInspection['is-variable'] = true; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_ARRAY) { $dataInspection['is-constant'] = true; $dataInspection['is-variable'] = false; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_VARIABLE) { $dataInspection['is-constant'] = false; $dataInspection['is-variable'] = true; $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_ATTRIBUTE) { $dataInspection['has-attributes'] = true; $newDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $variableItemData, $variableItemPlacement, $resourceData); if (isset($newDataInspection['new-data'])) { $variableItemData = $newDataInspection['new-data']; } $variableItem[1] = $variableItemData; unset($newDataInspection); $newVariableData[] = $variableItem; } else { if ($variableItemType == eZTemplate::TYPE_OPERATOR) { $dataInspection['has-operators'] = true; $operatorName = $variableItemData[0]; $operatorHint = eZTemplateCompiler::operatorHint($tpl, $operatorName); $newVariableItem = $variableItem; if ($operatorHint and isset($operatorHint['input']) and isset($operatorHint['output']) and isset($operatorHint['parameters'])) { if (!$operatorHint['input'] and $operatorHint['output']) { $newVariableData = array(); } if (!isset($operatorHint) or !$operatorHint['parameters']) { $newVariableItem[1] = array($operatorName); } if (isset($operatorHint['static']) and $operatorHint['static']) { $operatorStaticData = eZTemplateCompiler::operatorStaticData($tpl, $operatorName); $newVariableItem = eZTemplateCompiler::createStaticVariableData($tpl, $operatorStaticData, $variableItemPlacement); $dataInspection['is-constant'] = true; $dataInspection['is-variable'] = false; $dataInspection['has-operators'] = false; } } if ($newVariableItem[0] == eZTemplate::TYPE_OPERATOR) { $tmpVariableItem = $newVariableItem[1]; $newVariableItem[1] = array($operatorName); for ($i = 1; $i < count($tmpVariableItem); ++$i) { $operatorParameter = $tmpVariableItem[$i]; $newDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $operatorParameter, false, $resourceData); if (isset($newDataInspection['new-data'])) { $operatorParameter = $newDataInspection['new-data']; } $newVariableItem[1][] = $operatorParameter; } } $newVariableData[] = $newVariableItem; } else { if ($variableItemType == eZTemplate::TYPE_VOID) { $tpl->warning('TemplateCompiler', "Void datatype should not be used, ignoring it"); } else { if ($variableItemType > eZTemplate::TYPE_INTERNAL and $variableItemType < eZTemplate::TYPE_INTERNAL_STOP) { $newVariableData[] = $variableItem; } else { $tpl->warning('TemplateCompiler', "Unknown data type {$variableItemType}, ignoring it"); } } } } } } } } } } } $dataInspection['new-data'] = $newVariableData; return $dataInspection; }