Skip to content

Commit

Permalink
CS: removing some temporary variables making debugging harder
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickallaert committed May 19, 2011
1 parent e858487 commit 3c35e5f
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions kernel/common/ezobjectforwarder.php
Expand Up @@ -81,7 +81,6 @@ function templateNodeTransformation( $functionName, &$node,
$viewName = false; $viewName = false;
if ( $rule['use_views'] ) if ( $rule['use_views'] )
{ {
$optionalViews = isset( $rule['optional_views'] ) ? $rule['optional_views'] : false;
$viewName = $rule['use_views']; $viewName = $rule['use_views'];
if ( isset( $parameters[$viewName] ) ) if ( isset( $parameters[$viewName] ) )
{ {
Expand All @@ -95,7 +94,7 @@ function templateNodeTransformation( $functionName, &$node,
} }
else else
{ {
if ( !$optionalViews ) if ( !( isset( $rule['optional_views'] ) && $rule['optional_views'] ) )
{ {
return false; return false;
} }
Expand All @@ -120,8 +119,8 @@ function templateNodeTransformation( $functionName, &$node,
$parameterName == $outputName or $parameterName == $outputName or
$parameterName == $viewName ) $parameterName == $viewName )
continue; continue;
$parameterData = $parameters[$parameterName];
$newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameterData, false, array(), $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters[$parameterName], false, array(),
array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName ) ); array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName ) );
$variableList[] = $parameterName; $variableList[] = $parameterName;
} }
Expand All @@ -147,20 +146,17 @@ function templateNodeTransformation( $functionName, &$node,
isset( $templateRoot['attributes'] ) and isset( $templateRoot['attributes'] ) and
isset( $templateRoot['matches'] ) ) isset( $templateRoot['matches'] ) )
{ {
$rootAttributes = $templateRoot['attributes'];
$attributeAccessData = array(); $attributeAccessData = array();
$attributeAccessData[] = eZTemplateNodeTool::createVariableElement( $outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE ); $attributeAccessData[] = eZTemplateNodeTool::createVariableElement( $outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE );
foreach ( $rootAttributes as $rootAttributeName ) foreach ( $templateRoot['attributes'] as $rootAttributeName )
{ {
$attributeAccessData[] = eZTemplateNodeTool::createAttributeLookupElement( $rootAttributeName ); $attributeAccessData[] = eZTemplateNodeTool::createAttributeLookupElement( $rootAttributeName );
} }
$newNodes[] = eZTemplateNodeTool::createVariableNode( false, $attributeAccessData, false, $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $attributeAccessData, false,
array( 'spacing' => 0 ), 'templateRootMatch' ); array( 'spacing' => 0 ), 'templateRootMatch' );
$rootMatches = $templateRoot['matches'];
$rootMatchCounter = 0; $rootMatchCounter = 0;
foreach ( $rootMatches as $rootMatch ) foreach ( $templateRoot['matches'] as $rootMatch )
{ {
$rootMatchValue = $rootMatch[0];
$templateRoot = $rootMatch[1]; $templateRoot = $rootMatch[1];


$resourceNodes = $this->resourceAcquisitionTransformation( $functionName, $node, $rule, $inputData, $resourceNodes = $this->resourceAcquisitionTransformation( $functionName, $node, $rule, $inputData,
Expand All @@ -172,7 +168,7 @@ function templateNodeTransformation( $functionName, &$node,
if ( $resourceNodes === false ) if ( $resourceNodes === false )
continue; continue;


$rootMatchValueText = eZPHPCreator::variableText( $rootMatchValue, 0, 0, false ); $rootMatchValueText = eZPHPCreator::variableText( $rootMatch[0], 0, 0, false );
$code = ''; $code = '';
if ( $rootMatchCounter > 0 ) if ( $rootMatchCounter > 0 )
{ {
Expand Down Expand Up @@ -220,8 +216,7 @@ function resourceAcquisitionTransformation( $functionName, &$node, $rule, $input
continue; continue;


$path = $matchFile['template']; $path = $matchFile['template'];
$subPath = substr( $path, 0, $startRootLength ); if ( substr( $path, 0, $startRootLength ) == $startRoot and
if ( $subPath == $startRoot and
$path[$startRootLength] == '/' ) $path[$startRootLength] == '/' )
{ {
$matchFile['match_part'] = substr( $path, $startRootLength + 1 ); $matchFile['match_part'] = substr( $path, $startRootLength + 1 );
Expand All @@ -238,14 +233,13 @@ function resourceAcquisitionTransformation( $functionName, &$node, $rule, $input
"}", array( 'spacing' => $acquisitionSpacing ) ); "}", array( 'spacing' => $acquisitionSpacing ) );
if ( isset( $rule["attribute_keys"] ) ) if ( isset( $rule["attribute_keys"] ) )
{ {
$attributeKeys = $rule["attribute_keys"];
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( !isset( \$" . $designKeysName . "Stack ) )\n" . $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( !isset( \$" . $designKeysName . "Stack ) )\n" .
"{\n" . "{\n" .
" \$" . $designKeysName . "Stack = array();\n" . " \$" . $designKeysName . "Stack = array();\n" .
"}\n" . "}\n" .
"\$" . $designKeysName . "Stack[] = \$$designKeysName;", "\$" . $designKeysName . "Stack[] = \$$designKeysName;",
array( 'spacing' => $acquisitionSpacing ) ); array( 'spacing' => $acquisitionSpacing ) );
foreach ( $attributeKeys as $designKey => $attributeKeyArray ) foreach ( $rule["attribute_keys"] as $designKey => $attributeKeyArray )
{ {
$attributeAccessData = array(); $attributeAccessData = array();
$attributeAccessData[] = eZTemplateNodeTool::createVariableElement( $outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE ); $attributeAccessData[] = eZTemplateNodeTool::createVariableElement( $outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE );
Expand Down Expand Up @@ -314,9 +308,8 @@ function resourceAcquisitionTransformation( $functionName, &$node, $rule, $input
{ {
$customSpacing = $spacing + 4; $customSpacing = $spacing + 4;
$defaultMatchSpacing = $spacing + 4; $defaultMatchSpacing = $spacing + 4;
$customMatchList = $matchItem['custom_match'];
$matchCount = 0; $matchCount = 0;
foreach ( $customMatchList as $customMatch ) foreach ( $matchItem['custom_match'] as $customMatch )
{ {
$matchConditionCount = count( $customMatch['conditions'] ); $matchConditionCount = count( $customMatch['conditions'] );
$code = ''; $code = '';
Expand Down Expand Up @@ -478,9 +471,8 @@ function resourceAcquisitionTransformation( $functionName, &$node, $rule, $input
if ( isset( $viewFileMatch['custom_match'] ) ) if ( isset( $viewFileMatch['custom_match'] ) )
{ {
$spacing = $mainSpacing + 4; $spacing = $mainSpacing + 4;
$customMatchList = $viewFileMatch['custom_match'];
$matchCount = 0; $matchCount = 0;
foreach ( $customMatchList as $customMatch ) foreach ( $viewFileMatch['custom_match'] as $customMatch )
{ {
$matchConditionCount = count( $customMatch['conditions'] ); $matchConditionCount = count( $customMatch['conditions'] );
$code = ''; $code = '';
Expand Down Expand Up @@ -651,11 +643,9 @@ function process( $tpl, &$textElements, $functionName, $functionChildren, $funct
if ( isset( $rule['attribute_keys'] ) ) if ( isset( $rule['attribute_keys'] ) )
{ {
$resourceKeys = array(); $resourceKeys = array();
$attributeKeys = $rule['attribute_keys']; foreach( $rule['attribute_keys'] as $attributeKey => $attributeSelection )
foreach( $attributeKeys as $attributeKey => $attributeSelection )
{ {
$keyValue = $tpl->variableAttribute( $input_var, $attributeSelection ); $resourceKeys[] = array( $attributeKey, $tpl->variableAttribute( $input_var, $attributeSelection ) );
$resourceKeys[] = array( $attributeKey, $keyValue );
} }
} }


Expand All @@ -681,18 +671,16 @@ function process( $tpl, &$textElements, $functionName, $functionChildren, $funct
else else
{ {
$templateRootValue = $tpl->variableAttribute( $input_var, $templateRoot['attributes'] ); $templateRootValue = $tpl->variableAttribute( $input_var, $templateRoot['attributes'] );
$templateRootMatches = $templateRoot['matches']; foreach ( $templateRoot['matches'] as $templateRootMatch )
foreach ( $templateRootMatches as $templateRootMatch )
{ {
if ( $templateRootMatch[0] == $templateRootValue ) if ( $templateRootMatch[0] == $templateRootValue )
{ {
$template_dir = $templateRootMatch[1]; $template_dir = $templateRootMatch[1];
if ( is_array( $template_dir ) ) if ( is_array( $template_dir ) )
{ {
$templateDirAttributesList = $template_dir[1];
$template_dir = $template_dir[0]; $template_dir = $template_dir[0];
$attributeValues = array(); $attributeValues = array();
foreach ( $templateDirAttributesList as $templateDirAttributes ) foreach ( $template_dir[1] as $templateDirAttributes )
{ {
$attributeValues[] = $tpl->variableAttribute( $input_var, $templateDirAttributes ); $attributeValues[] = $tpl->variableAttribute( $input_var, $templateDirAttributes );
} }
Expand All @@ -709,7 +697,6 @@ function process( $tpl, &$textElements, $functionName, $functionChildren, $funct
} }


$resourceData = null; $resourceData = null;
$root = null;
if ( is_array( $attributeAccess ) ) if ( is_array( $attributeAccess ) )
{ {
foreach( $attributeAccess as $attributeAccessArray ) foreach( $attributeAccess as $attributeAccessArray )
Expand Down Expand Up @@ -759,8 +746,13 @@ function process( $tpl, &$textElements, $functionName, $functionChildren, $funct
{ {
continue; continue;
} }
$paramValue = $tpl->elementValue( $params[$paramName], $old_nspace, $currentNamespace, $functionPlacement );
$tpl->setVariable( $paramName, $paramValue, $outCurrentNamespace, true ); $tpl->setVariable(
$paramName,
$tpl->elementValue( $params[$paramName], $old_nspace, $currentNamespace, $functionPlacement ),
$outCurrentNamespace,
true
);
$setVariableArray[] = $paramName; $setVariableArray[] = $paramName;
} }
// Set constant variables // Set constant variables
Expand All @@ -786,8 +778,7 @@ function process( $tpl, &$textElements, $functionName, $functionChildren, $funct
if ( !$templateCompilationUsed and if ( !$templateCompilationUsed and
$resourceData['root-node'] ) $resourceData['root-node'] )
{ {
$root = $resourceData['root-node']; $tpl->process( $resourceData['root-node'], $sub_text, $outCurrentNamespace, $outCurrentNamespace );
$tpl->process( $root, $sub_text, $outCurrentNamespace, $outCurrentNamespace );
$tpl->setIncludeOutput( $uri, $sub_text ); $tpl->setIncludeOutput( $uri, $sub_text );


$textElements[] = $sub_text; $textElements[] = $sub_text;
Expand Down

0 comments on commit 3c35e5f

Please sign in to comment.