当前位置: 首页>>代码示例>>PHP>>正文


PHP eZPHPCreator::variableText方法代码示例

本文整理汇总了PHP中eZPHPCreator::variableText方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPHPCreator::variableText方法的具体用法?PHP eZPHPCreator::variableText怎么用?PHP eZPHPCreator::variableText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZPHPCreator的用法示例。


在下文中一共展示了eZPHPCreator::variableText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preferencesTransformation

 function preferencesTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (count($parameters[0]) == 0) {
         return false;
     }
     $values = array();
     if (eZTemplateNodeTool::isConstantElement($parameters[0])) {
         $name = eZTemplateNodeTool::elementConstantValue($parameters[0]);
         $nameText = eZPHPCreator::variableText($name, 0, 0, false);
     } else {
         $nameText = '%1%';
         $values[] = $parameters[0];
     }
     return array(eZTemplateNodeTool::createCodePieceElement("%output% = eZPreferences::value( {$nameText} );\n", $values));
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:15,代码来源:ezkerneloperator.php

示例2: templateNodeCaseTransformation

 function templateNodeCaseTransformation($tpl, &$newNodes, &$caseNodes, &$caseCounter, &$node, $privateData)
 {
     if ($node[2] == 'case') {
         if (is_array($node[3]) && count($node[3])) {
             if (isset($node[3]['match'])) {
                 $match = $node[3]['match'];
                 $match = eZTemplateCompiler::processElementTransformationList($tpl, $node, $match, $privateData);
                 $dynamicCase = false;
                 if (eZTemplateNodeTool::isConstantElement($match)) {
                     $matchValue = eZTemplateNodeTool::elementConstantValue($match);
                     $caseText = eZPHPCreator::variableText($matchValue, 0, 0, false);
                 } else {
                     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $match, false, array(), 'case' . $caseCounter);
                     $caseText = "\$case" . $caseCounter;
                     ++$caseCounter;
                     $dynamicCase = true;
                 }
                 $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    case {$caseText}:\n    {");
                 if ($dynamicCase) {
                     $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("        unset( {$caseText} );");
                 }
             } else {
                 if (isset($node[3]['in'])) {
                     return false;
                 }
             }
         } else {
             $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    default:\n    {");
         }
         $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
         if ($children === false) {
             $children = array();
         } else {
             $children = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $children, $privateData);
         }
         $caseNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(8);
         $caseNodes = array_merge($caseNodes, $children);
         $caseNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(8);
         $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    } break;");
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:41,代码来源:eztemplateswitchfunction.php

示例3: mergeTrans

 function mergeTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $code = '';
     $stringCode = '';
     $paramCount = 0;
     $values = array();
     $staticArray = array();
     for ($i = 1; $i < count($parameters); ++$i) {
         if ($i != 1) {
             $code .= ', ';
             $stringCode .= ', ';
         }
         if (!eZTemplateNodeTool::isStaticElement($parameters[$i])) {
             $values[] = $parameters[$i];
             ++$paramCount;
             if ($operatorName == $this->MergeName or $operatorName == $this->ArrayMergeName) {
                 $code .= '%' . $paramCount . '%';
             } else {
                 $code .= 'array( %' . $paramCount . '% )';
             }
             $stringCode .= '%' . $paramCount . '%';
         } else {
             if ($paramCount == 0) {
                 $staticArray[] = eZTemplateNodeTool::elementStaticValue($parameters[$i]);
             }
             if ($operatorName == $this->MergeName or $operatorName == $this->ArrayMergeName) {
                 $code .= '' . eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[$i]), 0, 0, false) . '';
             } else {
                 $tmp_check = eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[$i]), 0, 0, false);
                 // hiding "%1%", "%output%" etc. in static input string to avoid replacing it on "$var" inside compiler.
                 $tmp_check = str_replace("%", '"."%"."', $tmp_check);
                 $code .= 'array( ' . $tmp_check . ' )';
             }
             $stringCode .= eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[$i]), 0, 0, false);
         }
     }
     $isString = false;
     $isArray = false;
     $code2 = false;
     if ($parameters[0]) {
         if (!eZTemplateNodeTool::isStaticElement($parameters[0])) {
             $values[] = $parameters[0];
             ++$paramCount;
             $code2 = '%' . $paramCount . '%';
         } else {
             $isString = is_string(eZTemplateNodeTool::elementStaticValue($parameters[0]));
             $isArray = is_array(eZTemplateNodeTool::elementStaticValue($parameters[0]));
             if ($paramCount == 0) {
                 //                    $staticArray[] = eZTemplateNodeTool::elementStaticValue( $parameters[0] );
             } else {
                 $code2 = eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[0]), 0, 0, false);
             }
         }
     }
     if ($paramCount == 0) {
         if ($operatorName == $this->AppendName or $operatorName == $this->ArrayAppendName or $operatorName == $this->MergeName or $operatorName == $this->ArrayMergeName) {
             if ($isString) {
                 $str = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                 for ($i = 0; $i < count($staticArray); ++$i) {
                     $str .= $staticArray[$i];
                 }
                 return array(eZTemplateNodeTool::createStringElement($str));
             } else {
                 if ($isArray) {
                     $returnArray = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                     for ($i = 0; $i < count($staticArray); ++$i) {
                         $returnArray = array_merge($returnArray, $staticArray[$i]);
                     }
                     return array(eZTemplateNodeTool::createArrayElement($returnArray));
                 }
             }
         } else {
             if ($operatorName == $this->PrependName or $operatorName == $this->ArrayPrependName) {
                 if ($isString) {
                     return array(eZTemplateNodeTool::createStringElement(eZTemplateNodeTool::elementStaticValue($parameters[1]) . eZTemplateNodeTool::elementStaticValue($parameters[0])));
                 } else {
                     if ($isArray) {
                         return array(eZTemplateNodeTool::createArrayElement(array_merge($staticArray, eZTemplateNodeTool::elementStaticValue($parameters[0]))));
                     }
                 }
             }
         }
     }
     if ($code2) {
         if ($operatorName == $this->AppendName) {
             $code = 'if ( is_string( ' . $code2 . ' ) )' . "\n" . '    %output% = ' . $code2 . ' . implode( \'\', array( ' . $stringCode . ' ) );' . "\n" . 'else if( is_array( ' . $code2 . ' ) )' . "\n" . '    %output% = array_merge( ' . $code2 . ', ' . $code . ' );';
         } else {
             if ($operatorName == $this->ArrayAppendName) {
                 $code = '%output% = array_merge( ' . $code2 . ', ' . $code . ' );';
             } else {
                 if ($operatorName == $this->MergeName) {
                     $code = '%output% = array_merge( ' . $code2 . ', ' . $code . ' );';
                 } else {
                     if ($operatorName == $this->ArrayMergeName) {
                         $code = '%output% = array_merge( ' . $code2 . ', ' . $code . ' );';
                     } else {
                         if ($operatorName == $this->PrependName) {
                             $code = 'if ( is_string( ' . $code2 . ' ) )' . "\n" . '    %output% = implode( \'\', array( ' . $stringCode . ' ) ) . ' . $code2 . ';' . "\n" . 'else if( is_array( ' . $code2 . ' ) )' . "\n" . '    %output% = array_merge( ' . $code . ', ' . $code2 . ' );';
                         } else {
                             if ($operatorName == $this->ArrayPrependName) {
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatearrayoperator.php

示例4: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $ini = eZINI::instance();
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     if ($ini->variable('TemplateSettings', 'TemplateCache') != 'enabled') {
         return $children;
     }
     $functionPlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
     $placementKeyString = eZTemplateCacheBlock::placementString($functionPlacement);
     $newNodes = array();
     $ignoreContentExpiry = false;
     if (isset($parameters['expiry'])) {
         if (eZTemplateNodeTool::isConstantElement($parameters['expiry'])) {
             $expiryValue = eZTemplateNodeTool::elementConstantValue($parameters['expiry']);
             $ttlCode = $expiryValue > 0 ? eZPHPCreator::variableText($expiryValue, 0, 0, false) : 'null';
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['expiry'], false, array(), 'localExpiry');
             $ttlCode = "( \$localExpiry > 0 ? \$localExpiry : null )";
         }
     } else {
         $ttlCode = eZPHPCreator::variableText(self::DEFAULT_TTL, 0, 0, false);
     }
     if (isset($parameters['ignore_content_expiry'])) {
         $ignoreContentExpiry = eZTemplateNodeTool::elementConstantValue($parameters['ignore_content_expiry']);
     }
     $keysData = false;
     $hasKeys = false;
     $subtreeExpiryData = null;
     $subtreeValue = null;
     if (isset($parameters['keys'])) {
         $keysData = $parameters['keys'];
         $hasKeys = true;
     }
     if (isset($parameters['subtree_expiry'])) {
         $subtreeExpiryData = $parameters['subtree_expiry'];
         if (!eZTemplateNodeTool::isConstantElement($subtreeExpiryData)) {
             $hasKeys = true;
         } else {
             $subtreeValue = eZTemplateNodeTool::elementConstantValue($subtreeExpiryData);
         }
         $ignoreContentExpiry = true;
     }
     $accessName = false;
     if (isset($GLOBALS['eZCurrentAccess']['name'])) {
         $accessName = $GLOBALS['eZCurrentAccess']['name'];
     }
     if ($hasKeys) {
         $placementKeyStringText = eZPHPCreator::variableText($placementKeyString, 0, 0, false);
         $accessNameText = eZPHPCreator::variableText($accessName, 0, 0, false);
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $keysData, false, array(), 'cacheKeys');
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $subtreeExpiryData, false, array(), 'subtreeExpiry');
         $code = "\$cacheKeys = array( \$cacheKeys, {$placementKeyStringText}, {$accessNameText} );\n";
         $cachePathText = "\$cachePath";
     } else {
         $nodeID = $subtreeValue ? eZTemplateCacheBlock::decodeNodeID($subtreeValue) : false;
         $cachePath = eZTemplateCacheBlock::cachePath(eZTemplateCacheBlock::keyString(array($placementKeyString, $accessName)), $nodeID);
         $code = "";
         $cachePathText = eZPHPCreator::variableText($cachePath, 0, 0, false);
     }
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
     $code = '';
     $codePlacementHash = md5($placementKeyString);
     if ($hasKeys) {
         $code .= "list(\$cacheHandler_{$codePlacementHash}, \$contentData) =\n  eZTemplateCacheBlock::retrieve( \$cacheKeys, \$subtreeExpiry, {$ttlCode}, " . ($ignoreContentExpiry ? "false" : "true") . " );\n";
     } else {
         $nodeIDText = var_export($nodeID, true);
         $code .= "list(\$cacheHandler_{$codePlacementHash}, \$contentData) =\n  eZTemplateCacheBlock::handle( {$cachePathText}, {$nodeIDText}, {$ttlCode}, " . ($ignoreContentExpiry ? "false" : "true") . " );\n";
     }
     $code .= "if ( !( \$contentData instanceof eZClusterFileFailure ) )\n" . "{\n";
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code, array('spacing' => 0));
     $newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode('contentData', array('spacing' => 4));
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("    unset( \$contentData );\n" . "}\n" . "else\n" . "{\n" . "    unset( \$contentData );");
     $newNodes[] = eZTemplateNodeTool::createOutputVariableIncreaseNode(array('spacing' => 4));
     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(4);
     $newNodes = array_merge($newNodes, $children);
     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(4);
     $newNodes[] = eZTemplateNodeTool::createAssignFromOutputVariableNode('cachedText', array('spacing' => 4));
     $code = "\$cacheHandler_{$codePlacementHash}->storeCache( array( 'scope' => 'template-block', 'binarydata' => \$cachedText ) );\n";
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code, array('spacing' => 4));
     $newNodes[] = eZTemplateNodeTool::createOutputVariableDecreaseNode(array('spacing' => 4));
     $newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode('cachedText', array('spacing' => 4));
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("    unset( \$cachedText, \$cacheHandler_{$codePlacementHash} );\n}\n");
     return $newNodes;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:84,代码来源:eztemplatecachefunction.php

示例5: 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;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:95,代码来源:eztemplatedesignresource.php

示例6: generateVariableDataCode


//.........这里部分代码省略.........
                                                            if (is_array($knownType)) {
                                                                $knownTypes = array_merge($knownTypes, $knownType);
                                                            } else {
                                                                $knownTypes[] = $knownType;
                                                            }
                                                            $knownTypes = array_unique($knownTypes);
                                                        } else {
                                                            $knownTypes[] = 'static';
                                                        }
                                                    }
                                                    $php->addCodePiece("if (! isset( \${$variableAssignmentName} ) ) \${$variableAssignmentName} = NULL;\n", array('spacing' => $spacing));
                                                    $php->addCodePiece("while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$variableAssignmentName} ) and method_exists( \${$variableAssignmentName}, 'templateValue' ) )\n" . "    \${$variableAssignmentName} = \${$variableAssignmentName}" . "->templateValue();\n");
                                                    $php->addCodePiece("\$" . $variableAssignmentName . "Data = array( 'value' => \${$variableAssignmentName} );\n\$tpl->processOperator( {$operatorNameText},\n                       {$operatorParametersText},\n                       \$rootNamespace, \$currentNamespace, \$" . $variableAssignmentName . "Data, false, false );\n\${$variableAssignmentName} = \$" . $variableAssignmentName . "Data['value'];\nunset( \$" . $variableAssignmentName . "Data );\n", array('spacing' => $spacing));
                                                } else {
                                                    if ($variableDataType == eZTemplate::TYPE_VOID) {
                                                    } else {
                                                        if ($variableDataType == eZTemplate::TYPE_DYNAMIC_ARRAY) {
                                                            $knownTypes = array_unique(array_merge($knownTypes, array('array')));
                                                            $code = '%output% = array( ';
                                                            $matchMap = array('%input%', '%output%');
                                                            $replaceMap = array('$' . $variableAssignmentName, '$' . $variableAssignmentName);
                                                            $unsetList = array();
                                                            $counter = 1;
                                                            $paramCount = 0;
                                                            $values = $variableDataItem[2];
                                                            $newParameters = $parameters;
                                                            foreach ($values as $key => $value) {
                                                                if ($paramCount != 0) {
                                                                    $code .= ', ';
                                                                }
                                                                ++$paramCount;
                                                                $code .= '\'' . $key . '\' => ';
                                                                if (eZTemplateNodeTool::isStaticElement($value)) {
                                                                    $code .= eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($value), 0, 0, false);
                                                                    continue;
                                                                }
                                                                $code .= '%' . $counter . '%';
                                                                $newParameters['counter'] += 1;
                                                                $newVariableAssignmentName = $newParameters['variable'];
                                                                $newVariableAssignmentCounter = $newParameters['counter'];
                                                                if ($newVariableAssignmentCounter > 0) {
                                                                    $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                                }
                                                                $matchMap[] = '%' . $counter . '%';
                                                                $replaceMap[] = '$' . $newVariableAssignmentName;
                                                                $unsetList[] = $newVariableAssignmentName;
                                                                $tmpKnownTypes = array();
                                                                eZTemplateCompiler::generateVariableDataCode($php, $tpl, $value, $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                                ++$counter;
                                                            }
                                                            $code .= ' );';
                                                            $code = str_replace($matchMap, $replaceMap, $code);
                                                            $php->addCodePiece($code, array('spacing' => $spacing));
                                                            $php->addVariableUnsetList($unsetList, array('spacing' => $spacing));
                                                        } else {
                                                            if ($variableDataType == eZTemplate::TYPE_INTERNAL_CODE_PIECE) {
                                                                $code = $variableDataItem[1];
                                                                $values = false;
                                                                $matchMap = array('%input%', '%output%');
                                                                $replaceMap = array('$' . $variableAssignmentName, '$' . $variableAssignmentName);
                                                                $unsetList = array();
                                                                $counter = 1;
                                                                if (isset($variableDataItem[3]) && is_array($variableDataItem[3])) {
                                                                    $newParameters = $parameters;
                                                                    $values = $variableDataItem[3];
                                                                    foreach ($values as $value) {
开发者ID:runelangseid,项目名称:ezpublish,代码行数:67,代码来源:eztemplatecompiler.php

示例7: fetchTransform


//.........这里部分代码省略.........
        }
        else
        {
            $functionKeys = array();
        }

        $paramCount = 0;
        $values = array();
        if ( $isVariable )
        {
            $values[] = $fetchParameters;

            $parametersCode = 'array( ';
            foreach( $functionDefinition['parameters'] as $parameterDefinition )
            {
                if ( $paramCount != 0 )
                {
                    $parametersCode .= ',' . "\n";
                }
                ++$paramCount;

                $parameterName = $parameterDefinition['name'];

                if ( $parameterTranslation )
                {
                    if ( in_array( $parameterName, array_keys( $parameterTranslation ) ) )
                    {
                        $parameterName = $parameterTranslation[$parameterName];
                    }
                }

                $defaultValue = 'null';
                if ( !$parameterDefinition['required'] )
                    $defaultValue = eZPHPCreator::variableText( $parameterDefinition['default'], 0, 0, false );

                $parametersSelection = '%1%[\'' . $parameterName . '\']';
                $parametersCode .= '( isset( ' . $parametersSelection . ' ) ? ' . $parametersSelection . " : $defaultValue )";
            }

            $parametersCode .= ' )';

        }
        else
        {
            $parametersCode = 'array( ';
            if ( count( $functionDefinition['parameters'] ) )
            {
                foreach( $functionDefinition['parameters'] as $parameterDefinition )
                {
                    if ( $paramCount != 0 )
                    {
                        $parametersCode .= ',' . "\n";
                    }
                    ++$paramCount;

                    $parameterName = $parameterDefinition['name'];

                    if ( $parameterTranslation )
                    {
                        if ( in_array( $parameterName, array_keys( $parameterTranslation ) ) )
                        {
                            $parameterName = $parameterTranslation[$parameterName];
                        }
                    }

                    $parametersCode .= '    \'' . $parameterName . '\' => ';
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:67,代码来源:eztemplateexecuteoperator.php

示例8: 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;
//.........这里部分代码省略.........
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:101,代码来源:ezobjectforwarder.php

示例9: operatorTransform

 function operatorTransform($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (!eZTemplateNodeTool::isConstantElement($parameters[1]) || count($parameters) > 2 && !eZTemplateNodeTool::isConstantElement($parameters[2])) {
         return false;
     }
     // We do not support non-static values for decimal_count, decimal_symbol and thousands_separator
     if (count($parameters) > 3 and !eZTemplateNodeTool::isConstantElement($parameters[3])) {
         return false;
     }
     if (count($parameters) > 4 and !eZTemplateNodeTool::isConstantElement($parameters[4])) {
         return false;
     }
     if (count($parameters) > 5 and !eZTemplateNodeTool::isConstantElement($parameters[5])) {
         return false;
     }
     $locale = eZLocale::instance();
     $decimalCount = $locale->decimalCount();
     $decimalSymbol = $locale->decimalSymbol();
     $decimalThousandsSeparator = $locale->thousandsSeparator();
     if (count($parameters) > 2) {
         $prefix = eZTemplateNodeTool::elementConstantValue($parameters[2]);
     } else {
         $prefix = 'auto';
     }
     if (count($parameters) > 3) {
         $decimalCount = eZTemplateNodeTool::elementConstantValue($parameters[3]);
     } elseif ($prefix == 'none') {
         $decimalCount = 0;
     }
     if (count($parameters) > 4) {
         $decimalSymbol = eZTemplateNodeTool::elementConstantValue($parameters[4]);
     }
     if (count($parameters) > 5) {
         $decimalThousandsSeparator = eZTemplateNodeTool::elementConstantValue($parameters[5]);
     }
     $decimalSymbolText = eZPHPCreator::variableText($decimalSymbol, 0, 0, false);
     $decimalThousandsSeparatorText = eZPHPCreator::variableText($decimalThousandsSeparator, 0, 0, false);
     $unit = eZTemplateNodeTool::elementConstantValue($parameters[1]);
     $ini = eZINI::instance();
     if ($prefix == "auto") {
         $prefixes = $ini->variableArray("UnitSettings", "BinaryUnits");
         if (in_array($unit, $prefixes)) {
             $prefix = "binary";
         } else {
             $prefix = "decimal";
         }
     }
     $unit_ini = eZINI::instance("units.ini");
     $use_si = $ini->variable("UnitSettings", "UseSIUnits") == "true";
     $fake = $use_si ? "" : "Fake";
     if ($unit_ini->hasVariable("Base", $unit)) {
         $base = $unit_ini->variable("Base", $unit);
     }
     $hasInput = false;
     $output = false;
     if (eZTemplateNodeTool::isConstantElement($parameters[0])) {
         $output = eZTemplateNodeTool::elementConstantValue($parameters[0]);
         $hasInput = true;
     }
     $prefix_var = "";
     if ($prefix == "decimal") {
         $prefixes = $unit_ini->group("DecimalPrefixes");
         $prefix_group = $unit_ini->group("DecimalPrefixes");
         $prefixes = array();
         foreach ($prefix_group as $prefix_item) {
             $prefixes[] = explode(";", $prefix_item);
         }
         usort($prefixes, "eZTemplateUnitCompareFactor");
         $prefix_var = "";
         if ($hasInput) {
             if ($output >= 0 and $output < 10) {
                 $prefix_var = '';
             } else {
                 foreach ($prefixes as $prefix) {
                     $val = pow(10, (int) $prefix[0]);
                     if ($val <= $output) {
                         $prefix_var = $prefix[1];
                         $output = number_format($output / $val, $decimalCount, $decimalSymbol, $decimalThousandsSeparator);
                         break;
                     }
                 }
             }
         } else {
             $values = array();
             $values[] = $parameters[0];
             $values[] = array(eZTemplateNodeTool::createArrayElement($prefixes));
             $values[] = array(eZTemplateNodeTool::createStringElement($base));
             $code = 'if ( %1% >= 0 and %1% < 10 )' . "\n" . '{' . "\n" . '    %tmp3% = \'\';' . "\n" . '}' . "\n" . 'else' . "\n" . '{' . "\n" . '    %tmp3% = "";' . "\n" . '    foreach ( %2% as %tmp1% )' . "\n" . '    {' . "\n" . '        %tmp2% = pow( 10, (int)%tmp1%[0] );' . "\n" . '        if ( %tmp2% <= %1% )' . "\n" . '        {' . "\n" . '            %tmp3% = %tmp1%[1];' . "\n" . '            %1% = number_format( %1% / %tmp2%, ' . $decimalCount . ', ' . $decimalSymbolText . ', ' . $decimalThousandsSeparatorText . ' );' . "\n" . '            break;' . "\n" . '        }' . "\n" . '    }' . "\n" . '}' . "\n" . '%output% = %1% . \' \' . %tmp3% . %3%;';
             return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 3));
         }
     } else {
         if ($prefix == "binary") {
             $prefix_group = $unit_ini->group($fake . "BinaryPrefixes");
             $prefixes = array();
             foreach ($prefix_group as $prefix_item) {
                 $prefixes[] = explode(";", $prefix_item);
             }
             usort($prefixes, "eZTemplateUnitCompareFactor");
             $prefix_var = "";
             if ($hasInput) {
//.........这里部分代码省略.........
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:101,代码来源:eztemplateunitoperator.php

示例10: variableText

 static function variableText($value, $column = 0, $iteration = 0, $maxIterations = false)
 {
     // the last parameter will always be ignored
     $maxIterations = false;
     if ($value === true) {
         $text = 'true';
     } else {
         if ($value === false) {
             $text = 'false';
         } else {
             if ($value === null) {
                 $text = 'null';
             } else {
                 if (is_string($value)) {
                     $valueText = str_replace(array("\\", "\"", "\$", "\n"), array("\\\\", "\\\"", "\\\$", "\\n"), $value);
                     $text = "\"{$valueText}\"";
                 } else {
                     if (is_numeric($value)) {
                         $text = $value;
                     } else {
                         if (is_object($value)) {
                             $text = '';
                             if (method_exists($value, 'serializedata')) {
                                 $serializeData = $value->serializeData();
                                 $className = $serializeData['class_name'];
                                 $text = "new {$className}(";
                                 $column += strlen($text);
                                 $parameters = $serializeData['parameters'];
                                 $variables = $serializeData['variables'];
                                 $i = 0;
                                 foreach ($parameters as $parameter) {
                                     if ($i > 0) {
                                         $text .= ",\n" . str_repeat(' ', $column);
                                     }
                                     $variableName = $variables[$parameter];
                                     $variableValue = $value->{$variableName};
                                     $keyText = " ";
                                     $text .= $keyText . eZPHPCreator::variableText($variableValue, $column + strlen($keyText), $iteration + 1);
                                     ++$i;
                                 }
                                 if ($i > 0) {
                                     $text .= ' ';
                                 }
                                 $text .= ')';
                             }
                         } else {
                             if (is_array($value)) {
                                 $text = 'array(';
                                 $column += strlen($text);
                                 $valueKeys = array_keys($value);
                                 $isIndexed = true;
                                 for ($i = 0; $i < count($valueKeys); ++$i) {
                                     if ($i !== $valueKeys[$i]) {
                                         $isIndexed = false;
                                         break;
                                     }
                                 }
                                 $i = 0;
                                 foreach ($valueKeys as $key) {
                                     if ($i > 0) {
                                         $text .= ",\n" . str_repeat(' ', $column);
                                     }
                                     $element = $value[$key];
                                     $keyText = ' ';
                                     if (!$isIndexed) {
                                         if (is_int($key)) {
                                             $keyText = $key;
                                         } else {
                                             $keyText = "\"" . str_replace(array("\\", "\"", "\n"), array("\\\\", "\\\"", "\\n"), $key) . "\"";
                                         }
                                         $keyText = " {$keyText} => ";
                                     }
                                     $text .= $keyText . eZPHPCreator::variableText($element, $column + strlen($keyText), $iteration + 1);
                                     ++$i;
                                 }
                                 if ($i > 0) {
                                     $text .= ' ';
                                 }
                                 $text .= ')';
                             } else {
                                 $text = 'null';
                             }
                         }
                     }
                 }
             }
         }
     }
     return $text;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:90,代码来源:ezphpcreator.php

示例11: chooseTransformation

    function chooseTransformation( $operatorName, &$node, $tpl, &$resourceData,
                                   $element, $lastElement, $elementList, $elementTree, &$parameters )
    {
        $values = array();
        $function = $operatorName;

        if ( ( count( $parameters ) < 2) )
        {
            return false;
        }

        $tmpValues = false;
        $newElements = array();
        if ( eZTemplateNodeTool::isConstantElement( $parameters[0] ) )
        {
            $selected = eZTemplateNodeTool::elementConstantValue( $parameters[0] );

            if ( $selected < 0 or $selected > ( count( $parameters ) - 1 ) )
            {
                return false;
            }

            return $parameters[$selected + 1];
        }
        else
        {
            $values[] = $parameters[0];
            $array = $parameters;
            unset( $array[0] );

            $count = count( $parameters ) - 1;
            $operatorNameText = eZPHPCreator::variableText( $operatorName );

            if ( count( $parameters ) == ( 2 + 1 ) )
            {
                $code = "%output% = %1% ? %3% : %2%;\n";
                $values[] = $parameters[1];
                $values[] = $parameters[2];
            }
            else
            {
                $code = ( "if ( %1% < 0 and\n" .
                          "     %1% >= $count )\n" .
                          "{\n" .
                          "    \$tpl->error( $operatorNameText, \"Index \" . %1% . \" out of range\" );\n" .
                          "     %output% = false;\n" .
                          "}\n" );
                $code .= "else switch ( %1% )\n{\n";
                $valueNumber = 2;
                for ( $i = 0; $i < $count; ++$i )
                {
                    $parameterNumber = $i + 1;
                    $code .= "    case $i:";
                    if ( eZTemplateNodeTool::isConstantElement( $parameters[$parameterNumber] ) )
                    {
                        $value = eZTemplateNodeTool::elementConstantValue( $parameters[$parameterNumber] );
                        $valueText = eZPHPCreator::variableText( $value, 0, 0, false );
                        $code .= " %output% = $valueText; break;\n";
                    }
                    else
                    {
                        $code .= "\n    {\n";
                        $code .= "%code$valueNumber%\n";
                        $code .= "%output% = %$valueNumber%;\n";
                        $code .= "    } break;\n";
                        $values[] = $parameters[$parameterNumber];
                        ++$valueNumber;
                    }
                }
                $code .= "}\n";
            }
        }
        $newElements[] = eZTemplateNodeTool::createCodePieceElement( $code, $values, eZTemplateNodeTool::extractVariableNodePlacement( $node ), false );
        return $newElements;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:75,代码来源:eztemplatelogicoperator.php

示例12: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $useLastValue = false;
     if (isset($parameters['last-value']) and !eZTemplateNodeTool::isConstantElement($parameters['last-value'])) {
         return false;
     }
     if (isset($parameters['name']) and !eZTemplateNodeTool::isConstantElement($parameters['name'])) {
         return false;
     }
     if (isset($parameters['var']) and !eZTemplateNodeTool::isConstantElement($parameters['var'])) {
         return false;
     }
     if (isset($parameters['reverse']) and !eZTemplateNodeTool::isConstantElement($parameters['reverse'])) {
         return false;
     }
     $varName = false;
     if (isset($parameters['var'])) {
         $varName = eZTemplateNodeTool::elementConstantValue($parameters['var']);
     }
     if (isset($parameters['last-value'])) {
         $useLastValue = (bool) eZTemplateNodeTool::elementConstantValue($parameters['last-value']);
     }
     if (!$varName) {
         $useLastValue = false;
     }
     $reverseLoop = false;
     if (isset($parameters['reverse'])) {
         $reverseLoop = eZTemplateNodeTool::elementConstantValue($parameters['reverse']);
     }
     $useLoop = isset($parameters['loop']);
     $allowLoop = true;
     $newNodes = array();
     $maxText = "false";
     $useMax = false;
     $maxPopText = false;
     if (isset($parameters['max'])) {
         if (eZTemplateNodeTool::isConstantElement($parameters['max'])) {
             $maxValue = eZTemplateNodeTool::elementConstantValue($parameters['max']);
             if ($maxValue > 0) {
                 $maxText = eZPHPCreator::variableText($maxValue);
                 $useMax = true;
             } else {
                 return array(eZTemplateNodeTool::createTextNode(''));
             }
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['max'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'max');
             $maxText = "\$max";
             $maxPopText = ", \$max";
             $useMax = true;
         }
     }
     // Controls whether the 'if' statement with brackets is added
     $useShow = false;
     // Controls whether main nodes are handled, also controls delimiter and filters
     $useMain = true;
     // Controls wether else nodes are handled
     $useElse = false;
     $spacing = 0;
     if (isset($parameters['show'])) {
         if (eZTemplateNodeTool::isConstantElement($parameters['show'])) {
             $showValue = eZTemplateNodeTool::elementConstantValue($parameters['show']);
             if ($showValue) {
                 $useMain = true;
                 $useElse = false;
                 $useShow = false;
             } else {
                 $useMain = false;
                 $useElse = true;
                 $useShow = false;
             }
             $newNodes[] = eZTemplateNodeTool::createTextNode('');
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['show'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'show');
             $spacing = 4;
             $useElse = true;
             $useShow = true;
         }
     }
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     if ($useShow) {
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$show )\n{\n");
         $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode($spacing);
         $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('show');
     }
     if (isset($parameters['name']) and !$useLoop) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
     }
     $mainNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'before', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => 'section-else')), 'filter' => array(array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => array('delimiter', 'section-exclude', 'section-include')))))));
     $delimiterNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'equal', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => 'delimiter')))));
     $filterNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'equal', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => array('section-exclude', 'section-include'))))));
     $delimiterNode = false;
     if (count($delimiterNodes) > 0) {
         $delimiterNode = $delimiterNodes[0];
     }
     if ($useMain) {
         // Avoid transformation if the nodes will not be used, saves time
         $mainNodes = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $mainNodes, $privateData);
     }
     if ($useLoop and $useMain) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['loop'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'loopItem');
//.........这里部分代码省略.........
开发者ID:legende91,项目名称:ez,代码行数:101,代码来源:eztemplatesectionfunction.php

示例13: condTransform

    function condTransform( $operatorName, &$node, $tpl, &$resourceData,
                            $element, $lastElement, $elementList, $elementTree, &$parameters )
    {
        switch( $operatorName )
        {
            case $this->CondName:
            {
                $paramCount = count( $parameters );
                $clauseCount = floor( $paramCount / 2 );
                $hasDefaultClause = ( $paramCount % 2 ) != 0;

                if ( $paramCount == 1 )
                {
                    return $parameters[0];
                }

                $values = array();
                $code = '';
                $spacing = 0;
                $spacingCode = '';
                for ( $i = 0; $i < $clauseCount; ++$i )
                {
                    $prevSpacingCode = $spacingCode;
                    $spacingCode = str_repeat( " ", $spacing*4 );
                    if ( $i > 0 )
                    {
                        $code .= $prevSpacingCode . "else\n" . $prevSpacingCode . "{\n";
                    }

                    $values[] = $parameters[$i*2];
                    if ( $i > 0 )
                    {
                        $code .= $spacingCode . "%code" . count( $values ) . "%\n";
                    }
                    $code .= $spacingCode. 'if ( %' . count( $values ) . "% )\n" . $spacingCode . "{\n";

                    if ( !eZTemplateNodeTool::isConstantElement( $parameters[$i*2 + 1] ) )
                    {
                        $values[] = $parameters[$i*2 + 1];
                        $code .= ( $spacingCode . "    %code" . count( $values ) . "%\n" .
                                   $spacingCode . "    %output% = %" . count( $values ) . "%;\n" );
                    }
                    else
                    {
                        $code .= $spacingCode . '    %output% = ' . eZPHPCreator::variableText( eZTemplateNodeTool::elementConstantValue( $parameters[$i*2 + 1] ), 0, 0, false ) . ';' . "\n";
                    }
                    $code .= $spacingCode . "}\n";
                    ++$spacing;
                }
                $bracketCount = $clauseCount - 1;
                if ( $hasDefaultClause )
                {
                    ++$bracketCount;
                    $values[] = $parameters[$paramCount - 1];
                    if ( $clauseCount > 0 )
                    {
                        $code .= $spacingCode . "else\n" . $spacingCode . "{\n" . $spacingCode . "    %code" . count( $values ) . "%\n    ";
                    }

                    $code .= $spacingCode . '%output% = %' . count( $values ) . "%;\n";
                }
                for ( $clauseIndex = 0; $clauseIndex < $bracketCount; ++$clauseIndex )
                {
                    $spacingCode = str_repeat( " ", ( $bracketCount - $clauseIndex - 1 ) *4 );
                    $code .= $spacingCode . "}\n";
                }

                return array( eZTemplateNodeTool::createCodePieceElement( $code, $values ) );
            } break;

            case $this->FirstSetName:
            {
                $values = array();
                $code = '';
                $spacing = 0;
                $spacingCode = '';
                $nestCount = 0;
                for( $i = 0; $i < count( $parameters ); ++$i )
                {
                    if ( $i != 0 )
                    {
                        $code .= "$spacingCode}\n" . $spacingCode . "else\n$spacingCode{\n";
                    }
                    $spacingCode = str_repeat( ' ', $spacing*4 );
                    ++$spacing;

                    if ( eZTemplateNodeTool::isConstantElement( $parameters[$i] ) )
                    {
                        $code .= "$spacingCode%output% = " . eZPHPCreator::variableText( eZTemplateNodeTool::elementConstantValue( $parameters[$i] ), 0, 0, false ) . ";\n";
                        break;
                    }
                    ++$nestCount;

                    $values[] = $parameters[$i];
                    $code .= ( $spacingCode . "%code" . count( $values ) . "%\n" .
                               $spacingCode . 'if ( isset( %' . count( $values ) . "% ) )\n" .
                               $spacingCode . "{\n" .
                               $spacingCode . "    %output% = %" . count( $values ) . '%;' . "\n" );
                }
                for ( $i = 0; $i < $nestCount; ++$i )
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:eztemplatecontroloperator.php


注:本文中的eZPHPCreator::variableText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。