本文整理汇总了PHP中eZTemplateNodeTool::createAttributeLookupElement方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createAttributeLookupElement方法的具体用法?PHP eZTemplateNodeTool::createAttributeLookupElement怎么用?PHP eZTemplateNodeTool::createAttributeLookupElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createAttributeLookupElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resourceAcquisitionTransformation
function resourceAcquisitionTransformation( $functionName, &$node, $rule, $inputData,
$outputName, $namespaceValue,
$templateRoot, $viewDir, $viewValue,
$matchFileArray, $acquisitionSpacing,
&$resourceData )
{
$startRoot = '/' . $templateRoot . $viewDir;
$viewFileMatchName = '/' . $templateRoot . '/' . $viewValue . '.tpl';
$startRootLength = strlen( $startRoot );
$matchList = array();
$viewFileMatch = null;
foreach ( $matchFileArray as $matchFile )
{
if ( !isset( $matchFile['template'] ) )
continue;
$path = $matchFile['template'];
if ( substr( $path, 0, $startRootLength ) == $startRoot and
$path[$startRootLength] == '/' )
{
$matchFile['match_part'] = substr( $path, $startRootLength + 1 );
$matchList[] = $matchFile;
}
if ( $path == $viewFileMatchName )
$viewFileMatch = $matchFile;
}
$designKeysName = 'dKeys';
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( !isset( \$$designKeysName ) )\n" .
"{\n" .
" \$resH = \$tpl->resourceHandler( 'design' );\n" .
" \$$designKeysName = \$resH->keys();\n" .
"}", array( 'spacing' => $acquisitionSpacing ) );
if ( isset( $rule["attribute_keys"] ) )
{
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( !isset( \$" . $designKeysName . "Stack ) )\n" .
"{\n" .
" \$" . $designKeysName . "Stack = array();\n" .
"}\n" .
"\$" . $designKeysName . "Stack[] = \$$designKeysName;",
array( 'spacing' => $acquisitionSpacing ) );
foreach ( $rule["attribute_keys"] as $designKey => $attributeKeyArray )
{
$attributeAccessData = array();
$attributeAccessData[] = eZTemplateNodeTool::createVariableElement( $outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE );
foreach ( $attributeKeyArray as $attributeKey )
{
$attributeAccessData[] = eZTemplateNodeTool::createAttributeLookupElement( $attributeKey );
}
$newNodes[] = eZTemplateNodeTool::createVariableNode( false, $attributeAccessData, false,
array( 'spacing' => 0 ), 'dKey' );
$designKeyText = eZPHPCreator::variableText( $designKey, 0, 0, false );
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "\$" . $designKeysName . "[$designKeyText] = \$dKey;",
array( 'spacing' => $acquisitionSpacing ) );
$newNodes[] = eZTemplateNodeTool::createVariableUnsetNode( 'dKey' );
}
}
$attributeAccess = $rule["attribute_access"];
$hasAttributeAccess = false;
if ( is_array( $attributeAccess ) )
{
$hasAttributeAccess = count( $attributeAccess ) > 0;
$attributeAccessCount = 0;
foreach ( $attributeAccess as $attributeAccessEntries )
{
$attributeAccessData = $inputData;
$spacing = $acquisitionSpacing;
if ( $attributeAccessCount > 1 )
{
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "else " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . " if ( !\$resourceFound )\n{\n", array( 'spacing' => $acquisitionSpacing ) );
$spacing += 4;
}
else if ( $attributeAccessCount > 0 )
{
$newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( !\$resourceFound )\n{\n", array( 'spacing' => $acquisitionSpacing ) );
$spacing += 4;
}
foreach ( $attributeAccessEntries as $attributeAccessName )
{
// $attributeAccessData[] = eZTemplateNodeTool::createCodePieceNode( "" . ( $resourceData['use-comments'] ? ( "/*TC:" . __LINE__ . "*/" ) : "" ) . "" );
$attributeAccessData[] = eZTemplateNodeTool::createAttributeLookupElement( $attributeAccessName );
}
$accessNodes = array();
$accessNodes[] = eZTemplateNodeTool::createVariableNode( false, $attributeAccessData, false,
array( 'spacing' => $spacing ), 'attributeAccess' );
$acquisitionNodes = array();
$templateCounter = 0;
$hasAcquisitionNodes = false;
$matchLookupArray = array();
foreach ( $matchList as $matchItem )
{
$tmpAcquisitionNodes = array();
$matchPart = $matchItem['match_part'];
if ( preg_match( "/^(.+)\.tpl$/", $matchPart, $matches ) )
$matchPart = $matches[1];
$code = "if " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "( \$attributeAccess == '$matchPart' )\n{\n";
if ( $templateCounter > 0 )
$code = "else " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . "" . $code;
//.........这里部分代码省略.........