本文整理汇总了PHP中eZTemplateNodeTool::createResourceAcquisitionNode方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createResourceAcquisitionNode方法的具体用法?PHP eZTemplateNodeTool::createResourceAcquisitionNode怎么用?PHP eZTemplateNodeTool::createResourceAcquisitionNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createResourceAcquisitionNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateNodeTransformation
function templateNodeTransformation($functionName, &$node, $tpl, &$resourceData, $parameters, $namespaceValue)
{
if ($this->Name != 'file') {
return false;
}
$file = $resourceData['template-name'];
if (!file_exists($file)) {
return false;
}
$newNodes = array();
$newNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode($resourceData['resource'], $file, $file, eZTemplate::RESOURCE_FETCH, false, $node[4], array(), $namespaceValue);
return $newNodes;
}
示例2: templateNodeTransformation
function templateNodeTransformation($functionName, &$node, $tpl, &$resourceData, $parameters, $namespaceValue)
{
if ($this->Name != 'design' and $this->Name != 'standard') {
return false;
}
$file = $resourceData['template-name'];
$matchFileArray = eZTemplateDesignResource::overrideArray($this->OverrideSiteAccess);
$matchList = array();
foreach ($matchFileArray as $matchFile) {
if (!isset($matchFile['template'])) {
continue;
}
if ($matchFile['template'] == '/' . $file) {
$matchList[] = $matchFile;
}
}
$resourceName = $resourceData['resource'];
$resourceNameText = eZPHPCreator::variableText($resourceName);
$designKeysName = 'dKeys';
if ($resourceName == 'standard') {
$designKeysName = 'rKeys';
}
$newNodes = array();
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("if " . ($resourceData['use-comments'] ? "/*TDR:" . __LINE__ . "*/" : "") . "( !isset( \${$designKeysName} ) )\n" . "{\n" . " \$resH = \$tpl->resourceHandler( {$resourceNameText} );\n" . " \${$designKeysName} = \$resH->keys();" . "\n" . "}\n");
foreach ($matchList as $match) {
$basedir = $match['base_dir'];
$template = $match['template'];
$file = $basedir . $template;
$spacing = 0;
$addFileResource = true;
if (isset($match['custom_match'])) {
$spacing = 4;
$customMatchList = $match['custom_match'];
$matchCount = 0;
foreach ($customMatchList as $customMatch) {
$matchConditionCount = count($customMatch['conditions']);
$code = '';
if ($matchCount > 0) {
$code = "else " . ($resourceData['use-comments'] ? "/*TDR:" . __LINE__ . "*/" : "") . "";
}
if ($matchConditionCount > 0) {
if ($matchCount > 0) {
$code .= " ";
}
$code .= "if " . ($resourceData['use-comments'] ? "/*TDR:" . __LINE__ . "*/" : "") . "( ";
}
$ifLength = strlen($code);
$conditionCount = 0;
if (is_array($customMatch['conditions'])) {
foreach ($customMatch['conditions'] as $conditionName => $conditionValue) {
if ($conditionCount > 0) {
$code .= " and\n" . str_repeat(' ', $ifLength);
}
$conditionNameText = eZPHPCreator::variableText($conditionName, 0);
$conditionValueText = eZPHPCreator::variableText($conditionValue, 0);
$code .= "isset( \$" . $designKeysName . "[{$conditionNameText}] ) and ";
if ($conditionName == 'url_alias') {
$code .= "(strpos( \$" . $designKeysName . "[{$conditionNameText}], {$conditionValueText} ) === 0 )";
} else {
$code .= "( is_array( \$" . $designKeysName . "[{$conditionNameText}] ) ? " . "in_array( {$conditionValueText}, \$" . $designKeysName . "[{$conditionNameText}] ) : " . "\$" . $designKeysName . "[{$conditionNameText}] == {$conditionValueText} )";
}
++$conditionCount;
}
}
if ($matchConditionCount > 0) {
$code .= " )\n";
}
if ($matchConditionCount > 0 or $matchCount > 0) {
$code .= "{";
}
$matchFile = $customMatch['match_file'];
$newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
$newNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode('', $matchFile, $matchFile, eZTemplate::RESOURCE_FETCH, false, $node[4], array('spacing' => $spacing), $namespaceValue);
if ($matchConditionCount > 0 or $matchCount > 0) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
}
++$matchCount;
if ($matchConditionCount == 0) {
$addFileResource = false;
break;
}
}
if ($addFileResource) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("else" . ($resourceData['use-comments'] ? "/*TDR:" . __LINE__ . "*/" : "") . "\n{");
}
}
if ($addFileResource) {
$newNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode('', $file, $file, eZTemplate::RESOURCE_FETCH, false, $node[4], array('spacing' => $spacing), $namespaceValue);
}
if (isset($match['custom_match']) and $addFileResource) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
}
}
return $newNodes;
}
示例3: resourceAcquisitionTransformation
//.........这里部分代码省略.........
if ( $conditionCount > 0 )
$code .= " and\n" . str_repeat( ' ', $ifLength );
$conditionNameText = eZPHPCreator::variableText( $conditionName, 0 );
$conditionValueText = eZPHPCreator::variableText( $conditionValue, 0 );
$code .= "isset( \$" . $designKeysName . "[$conditionNameText] ) and ";
if ( $conditionNameText == '"url_alias"' )
{
$code .= "( strpos(\$" . $designKeysName . "[$conditionNameText], $conditionValueText ) === 0 )";
}
else
{
$code .= "( is_array( \$" . $designKeysName . "[$conditionNameText] ) ? " .
"in_array( $conditionValueText, \$" . $designKeysName . "[$conditionNameText] ) : " .
"\$" . $designKeysName . "[$conditionNameText] == $conditionValueText )";
}
++$conditionCount;
}
}
if ( $matchConditionCount > 0 )
{
$code .= " )\n";
}
if ( $matchConditionCount > 0 or $matchCount > 0 )
{
$code .= "{";
}
$matchFile = $customMatch['match_file'];
$tmpAcquisitionNodes[] = eZTemplateNodeTool::createCodePieceNode( $code, array( 'spacing' => $customSpacing ) );
$hasAcquisitionNodes = true;
// If $matchFile is an array we cannot create a transformation for this entry
if ( is_array( $matchFile ) )
return false;
$tmpAcquisitionNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode( '',
$matchFile, $matchFile,
eZTemplate::RESOURCE_FETCH, false,
$node[4], array( 'spacing' => $customSpacing + 4 ),
$rule['namespace'] );
if ( $matchConditionCount > 0 or $matchCount > 0 )
{
$tmpAcquisitionNodes[] = eZTemplateNodeTool::createCodePieceNode( "}", array( 'spacing' => $customSpacing ) );
}
++$matchCount;
if ( $matchConditionCount == 0 )
{
$addFileResource = false;
break;
}
}
if ( $addFileResource )
$tmpAcquisitionNodes[] = eZTemplateNodeTool::createCodePieceNode( "else " . ( $resourceData['use-comments'] ? ( "/*OF:" . __LINE__ . "*/" ) : "" ) . " \n{", array( 'spacing' => $customSpacing ) );
}
else
{
$matchFile = $matchItem['base_dir'] . $matchItem['template'];
$matchLookupArray[$matchPart] = $matchFile;
$useArrayLookup = true;
}
if ( !$useArrayLookup )
{
if ( $addFileResource )
{
$matchFile = $matchItem['base_dir'] . $matchItem['template'];
$tmpAcquisitionNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode( '',
$matchFile, $matchFile,