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


PHP eZTemplateNodeTool::isStaticElement方法代码示例

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


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

示例1: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName != $this->BlockName) {
         return false;
     }
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if (!isset($parameters['name'])) {
         return false;
     }
     $namespaceValue = false;
     $newNodes = array();
     if (isset($parameters["name"])) {
         $menuIni = eZINI::instance("menu.ini");
         $nameData = $parameters["name"];
         if (!eZTemplateNodeTool::isStaticElement($nameData)) {
             return false;
         }
         $menuName = eZTemplateNodeTool::elementStaticValue($nameData);
         if ($menuIni->hasVariable('SelectedMenu', $menuName)) {
             $menuTemplate = $menuIni->variable("SelectedMenu", $menuName);
             if ($menuTemplate != null) {
                 $uriString = "design:menu/{$menuTemplate}.tpl";
                 $resourceName = "";
                 $templateName = "";
                 $resource = $tpl->resourceFor($uriString, $resourceName, $templateName);
                 $resourceData = $tpl->resourceData($resource, $uriString, $resourceName, $templateName);
                 $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
                 $includeNodes = $resource->templateNodeTransformation($functionName, $node, $tpl, $resourceData, $parameters, $namespaceValue);
                 if ($includeNodes === false) {
                     return false;
                 }
                 $variableList = array();
                 foreach (array_keys($parameters) as $parameterName) {
                     if ($parameterName == 'name') {
                         continue;
                     }
                     $parameterData =& $parameters[$parameterName];
                     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
                     $variableList[] = $parameterName;
                 }
                 $newNodes = array_merge($newNodes, $includeNodes);
                 foreach ($variableList as $variableName) {
                     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode(array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $variableName));
                 }
             } else {
                 // to do: not use this function to generate empty code.
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("");
             }
         } else {
             // to do: not use this function to generate empty code.
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("");
         }
     }
     return $newNodes;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:55,代码来源:eztemplatemenufunction.php

示例2: preferencesTransformation

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

示例3: dateTimeTransformation

 function dateTimeTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $values = array();
     $newElements = array();
     $paramCount = count($parameters);
     if ($paramCount < 2) {
         return false;
     }
     if (!eZTemplateNodeTool::isStaticElement($parameters[1])) {
         return false;
     } else {
         $class = eZTemplateNodeTool::elementStaticValue($parameters[1]);
     }
     if ($class == 'custom' && $paramCount != 3) {
         return false;
     }
     $newElements[] = eZTemplateNodeTool::createCodePieceElement('//include_once("lib/ezlocale/classes/ezlocale.php");' . "\n");
     $newElements[] = eZTemplateNodeTool::createCodePieceElement('$locale = eZLocale::instance();' . "\n");
     if ($class == 'custom') {
         $values[] = $parameters[0];
         $values[] = $parameters[2];
         $newElements[] = eZTemplateNodeTool::createCodePieceElement("%output% = \$locale->formatDateTimeType( %2%, %1% );\n", $values);
         return $newElements;
     } else {
         $dtINI = eZINI::instance('datetime.ini');
         $formats = $dtINI->variable('ClassSettings', 'Formats');
         if (array_key_exists($class, $formats)) {
             $classFormat = addcslashes($formats[$class], "'");
             $values[] = $parameters[0];
             $newElements[] = eZTemplateNodeTool::createCodePieceElement("%output% = \$locale->formatDateTimeType( '{$classFormat}', %1% );\n", $values);
             return $newElements;
         }
     }
     return false;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:35,代码来源:eztemplatelocaleoperator.php

示例4: 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::isStaticElement($parameters[0])) {
         $selected = eZTemplateNodeTool::elementStaticValue($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::isStaticElement($parameters[$parameterNumber])) {
                     $value = eZTemplateNodeTool::elementStaticValue($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:runelangseid,项目名称:ezpublish,代码行数:51,代码来源:eztemplatelogicoperator.php

示例5: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $useLastValue = false;
     if (isset($parameters['last-value']) and !eZTemplateNodeTool::isStaticElement($parameters['last-value'])) {
         return false;
     }
     if (isset($parameters['name']) and !eZTemplateNodeTool::isStaticElement($parameters['name'])) {
         return false;
     }
     if (isset($parameters['var']) and !eZTemplateNodeTool::isStaticElement($parameters['var'])) {
         return false;
     }
     if (isset($parameters['reverse']) and !eZTemplateNodeTool::isStaticElement($parameters['reverse'])) {
         return false;
     }
     $varName = false;
     if (isset($parameters['var'])) {
         $varName = eZTemplateNodeTool::elementStaticValue($parameters['var']);
     }
     if (isset($parameters['last-value'])) {
         $useLastValue = (bool) eZTemplateNodeTool::elementStaticValue($parameters['last-value']);
     }
     if (!$varName) {
         $useLastValue = false;
     }
     $reverseLoop = false;
     if (isset($parameters['reverse'])) {
         $reverseLoop = eZTemplateNodeTool::elementStaticValue($parameters['reverse']);
     }
     $useLoop = isset($parameters['loop']);
     $allowLoop = true;
     $newNodes = array();
     $maxText = "false";
     $useMax = false;
     $maxPopText = false;
     if (isset($parameters['max'])) {
         if (eZTemplateNodeTool::isStaticElement($parameters['max'])) {
             $maxValue = eZTemplateNodeTool::elementStaticValue($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::isStaticElement($parameters['show'])) {
             $showValue = eZTemplateNodeTool::elementStaticValue($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:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatesectionfunction.php

示例6: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName != $this->IncludeName) {
         return false;
     }
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if (!isset($parameters['uri'])) {
         return false;
     }
     $uriData = $parameters['uri'];
     if (!eZTemplateNodeTool::isStaticElement($uriData)) {
         return false;
     }
     $namespaceValue = false;
     $namespaceName = '$currentNamespace';
     if (isset($parameters['name'])) {
         $nameData = $parameters['name'];
         if (!eZTemplateNodeTool::isStaticElement($nameData)) {
             return false;
         }
         $namespaceValue = eZTemplateNodeTool::elementStaticValue($nameData);
         $namespaceName = '$namespace';
     }
     $uriString = eZTemplateNodeTool::elementStaticValue($uriData);
     $resourceName = "";
     $templateName = "";
     $resource = $tpl->resourceFor($uriString, $resourceName, $templateName);
     $resourceData = $tpl->resourceData($resource, $uriString, $resourceName, $templateName);
     $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
     $includeNodes = $resource->templateNodeTransformation($functionName, $node, $tpl, $resourceData, $parameters, $namespaceValue);
     if ($includeNodes === false) {
         return false;
     }
     $newNodes = array();
     $variableList = array();
     $uniqID = md5(uniqid('inc'));
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$oldRestoreIncludeArray" . "_{$uniqID} = isset( \$restoreIncludeArray ) ? \$restoreIncludeArray : array();\n" . "\$restoreIncludeArray = array();\n");
     foreach (array_keys($parameters) as $parameterName) {
         if ($parameterName == 'uri' or $parameterName == 'name') {
             continue;
         }
         $parameterData =& $parameters[$parameterName];
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( isset( {$namespaceName} ) and isset( \$vars[{$namespaceName}]['{$parameterName}'] ) )\n" . "    \$restoreIncludeArray[] = array( {$namespaceName}, '{$parameterName}', \$vars[{$namespaceName}]['{$parameterName}'] );\n" . "elseif ( !isset( \$vars[( isset( {$namespaceName} ) ? {$namespaceName} : '' )]['{$parameterName}'] ) ) \n" . "    \$restoreIncludeArray[] = array( ( isset( {$namespaceName} ) ? {$namespaceName} : '' ), '{$parameterName}', 'unset' );\n");
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
         $variableList[] = $parameterName;
     }
     $newNodes = array_merge($newNodes, $includeNodes);
     // Restore previous variables, before including
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("foreach ( \$restoreIncludeArray as \$element )\n" . "{\n" . "    if ( \$element[2] === 'unset' )\n" . "    {\n" . "        unset( \$vars[\$element[0]][\$element[1]] );\n" . "        continue;\n" . "    }\n" . "    \$vars[\$element[0]][\$element[1]] = \$element[2];\n" . "}\n" . "\$restoreIncludeArray = \$oldRestoreIncludeArray" . "_{$uniqID};\n");
     return $newNodes;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:51,代码来源:eztemplateincludefunction.php

示例7: generateVariableDataCode

    static function generateVariableDataCode($php, $tpl, $variableData, &$knownTypes, $dataInspection, &$persistence, $parameters, &$resourceData)
    {
        $staticTypeMap = array(eZTemplate::TYPE_STRING => 'string', eZTemplate::TYPE_NUMERIC => 'numeric', eZTemplate::TYPE_IDENTIFIER => 'string', eZTemplate::TYPE_ARRAY => 'array', eZTemplate::TYPE_BOOLEAN => 'boolean');
        $variableAssignmentName = $parameters['variable'];
        $variableAssignmentCounter = $parameters['counter'];
        $spacing = 0;
        $optimizeNode = false;
        if (isset($parameters['spacing'])) {
            $spacing = $parameters['spacing'];
        }
        if ($variableAssignmentCounter > 0) {
            $variableAssignmentName .= $variableAssignmentCounter;
        }
        // We need to unset the assignment variable before any elements are processed
        // This ensures that we don't work on existing variables
        $php->addCodePiece("unset( \${$variableAssignmentName} );\n", array('spacing' => $spacing));
        if (is_array($variableData)) {
            foreach ($variableData as $index => $variableDataItem) {
                $variableDataType = $variableDataItem[0];
                if ($variableDataType == eZTemplate::TYPE_STRING or $variableDataType == eZTemplate::TYPE_NUMERIC or $variableDataType == eZTemplate::TYPE_IDENTIFIER or $variableDataType == eZTemplate::TYPE_ARRAY or $variableDataType == eZTemplate::TYPE_BOOLEAN) {
                    $knownTypes = array_unique(array_merge($knownTypes, array($staticTypeMap[$variableDataType])));
                    $dataValue = $variableDataItem[1];
                    $dataText = $php->thisVariableText($dataValue, 0, 0, false);
                    $php->addCodePiece("\${$variableAssignmentName} = {$dataText};\n", array('spacing' => $spacing));
                } else {
                    if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_NODE) {
                        $optimizeNode = true;
                        if (!isset($resourceData['node-object-cached'])) {
                            $tpl->error("eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : ""), "Attribute node-object-cached of variable \$resourceData was not found but variable node eZTemplate::TYPE_OPTIMIZED_NODE is still present. This should not happen");
                        }
                        $php->addCodePiece("\${$variableAssignmentName} = \$nod_{$resourceData['uniqid']};\n");
                        // If optimized node is not set, use unoptimized code.
                        $php->addCodePiece("if ( !\${$variableAssignmentName} )\n{\n");
                    } else {
                        if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_ARRAY_LOOKUP) {
                            $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                            // This code is used a lot so we create a variable for it
                            $phpVar = "\${$variableAssignmentName}";
                            $indexName = "'{$variableDataItem[1][0][1]}'";
                            // Add sanity checking
                            $code .= "if ( !isset( {$phpVar}[{$indexName}] ) )\n" . "{\n" . "    \$tpl->error( 'eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : "") . "', \"PHP variable \\{$phpVar}" . "[{$indexName}] does not exist, cannot fetch the value.\" );\n" . "    {$phpVar} = null;\n" . "}\n" . "else\n    ";
                            // Add the actual code
                            $code .= "{$phpVar} = {$phpVar}[{$indexName}];\n";
                            $php->addCodePiece($code);
                        } else {
                            if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_ATTRIBUTE_LOOKUP) {
                                $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                                $code .= <<<END
if ( !is_object( \${$variableAssignmentName} ) )
{
    \${$variableAssignmentName} = null;
}
else if ( \${$variableAssignmentName}->hasAttribute( "{$variableDataItem[1][0][1]}" ) )
{
    \${$variableAssignmentName} = \${$variableAssignmentName}->attribute( "{$variableDataItem[1][0][1]}" );
}

END;
                                $php->addCodePiece($code);
                            } else {
                                if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_CONTENT_CALL) {
                                    // Line number comment
                                    $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                                    // This code is used a lot so we create a variable for it
                                    $phpVar = "\${$variableAssignmentName}";
                                    // Add sanity checking
                                    $code .= "if ( !is_object( {$phpVar} ) )\n" . "{\n" . "    \$tpl->error( 'eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : "") . "', \"PHP variable \\{$phpVar} is not an object, cannot fetch content()\" );\n" . "    {$phpVar} = null;\n" . "}\n" . "else\n" . "{\n";
                                    // Add the actual code
                                    $code .= "     {$phpVar}Tmp = {$phpVar}->content();\n" . "     unset( {$phpVar} );\n" . "     {$phpVar} = {$phpVar}Tmp;\n" . "     unset( {$phpVar}Tmp );\n}\n";
                                    $php->addCodePiece($code);
                                } else {
                                    if ($variableDataType == eZTemplate::TYPE_PHP_VARIABLE) {
                                        $knownTypes = array();
                                        $phpVariableName = $variableDataItem[1];
                                        $php->addCodePiece("\${$variableAssignmentName} = \${$phpVariableName};\n", array('spacing' => $spacing));
                                    } else {
                                        if ($variableDataType == eZTemplate::TYPE_VARIABLE) {
                                            $knownTypes = array();
                                            $namespace = $variableDataItem[1][0];
                                            $namespaceScope = $variableDataItem[1][1];
                                            $variableName = $variableDataItem[1][2];
                                            $namespaceText = eZTemplateCompiler::generateMergeNamespaceCode($php, $tpl, $namespace, $namespaceScope, array('spacing' => $spacing), true);
                                            if (!is_string($namespaceText)) {
                                                $namespaceText = "\$namespace";
                                            }
                                            $variableNameText = $php->thisVariableText($variableName, 0, 0, false);
                                            $code = "unset( \${$variableAssignmentName} );\n";
                                            $code .= "\${$variableAssignmentName} = ( array_key_exists( {$namespaceText}, \$vars ) and array_key_exists( {$variableNameText}, \$vars[{$namespaceText}] ) ) ? \$vars[{$namespaceText}][{$variableNameText}] : null;\n";
                                            $php->addCodePiece($code, array('spacing' => $spacing));
                                        } else {
                                            if ($variableDataType == eZTemplate::TYPE_ATTRIBUTE) {
                                                $knownTypes = array();
                                                $newParameters = $parameters;
                                                $newParameters['counter'] += 1;
                                                $tmpVariableAssignmentName = $newParameters['variable'];
                                                $tmpVariableAssignmentCounter = $newParameters['counter'];
                                                if ($tmpVariableAssignmentCounter > 0) {
                                                    $tmpVariableAssignmentName .= $tmpVariableAssignmentCounter;
                                                }
                                                if (eZTemplateNodeTool::isStaticElement($variableDataItem[1])) {
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatecompiler.php

示例8: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $newNodes = array();
     $namespaceValue = false;
     $varName = 'match';
     if (!isset($parameters['name'])) {
         return false;
     }
     if (!eZTemplateNodeTool::isStaticElement($parameters['name'])) {
         return false;
     }
     $nameData = $parameters['name'];
     $nameValue = eZTemplateNodeTool::elementStaticValue($nameData);
     $nameSpaceNode = eZTemplateNodeTool::createCodePieceNode("\$namespace = \$rootNamespace;\nif ( \$namespace == '' )\n    \$namespace = \"{$nameValue}\";\nelse\n    \$namespace .= ':{$nameValue}';\n");
     if (isset($parameters['loop'])) {
         $loopData = $parameters['loop'];
         if (!eZTemplateNodeTool::isStaticElement($loopData)) {
             return false;
         }
         $loopValue = eZTemplateNodeTool::elementStaticValue($loopData);
         $newNodes = $this->templateNodeSequenceCreate($node, $tpl, $parameters, $nameValue, $loopValue);
     } else {
         $newNodes = $this->templateNodeSequenceIterate($node, $tpl, $parameters, $nameValue);
     }
     $retNodes = array_merge(array($nameSpaceNode), $newNodes);
     return $retNodes;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:27,代码来源:eztemplatesequencefunction.php

示例9: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if (!isset($this->Rules[$functionName])) {
         return false;
     }
     $rule = $this->Rules[$functionName];
     $resourceData = $privateData['resource-data'];
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     $inputName = $rule['input_name'];
     if (!isset($parameters[$inputName])) {
         return false;
     }
     $inputData = $parameters[$inputName];
     $outputName = $rule['output_name'];
     $newNodes = array();
     $viewDir = '';
     $renderMode = false;
     if (isset($rule["render_mode"])) {
         $renderMode = $rule["render_mode"];
     }
     if (isset($parameters['render-mode'])) {
         $renderData = $parameters['render-mode'];
         if (!eZTemplateNodeTool::isStaticElement($renderData)) {
             return false;
         }
         $renderMode = eZTemplateNodeTool::elementStaticValue($renderData);
     }
     if ($renderMode) {
         $view_dir .= "/render-{$renderMode}";
     }
     $viewValue = false;
     $viewName = false;
     if ($rule['use_views']) {
         $optionalViews = isset($rule['optional_views']) ? $rule['optional_views'] : false;
         $viewName = $rule['use_views'];
         if (isset($parameters[$viewName])) {
             $viewData = $parameters[$viewName];
             if (!eZTemplateNodeTool::isStaticElement($viewData)) {
                 return false;
             }
             $viewValue = eZTemplateNodeTool::elementStaticValue($viewData);
             $viewDir .= '/' . $viewValue;
         } else {
             if (!$optionalViews) {
                 return false;
             }
         }
     }
     $namespaceValue = false;
     if (isset($rule['namespace'])) {
         $namespaceValue = $rule['namespace'];
     }
     $variableList = array();
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $inputData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $outputName));
     $variableList[] = $outputName;
     foreach (array_keys($parameters) as $parameterName) {
         if ($parameterName == $inputName or $parameterName == $outputName or $parameterName == $viewName) {
             continue;
         }
         $parameterData = $parameters[$parameterName];
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
         $variableList[] = $parameterName;
     }
     $templateRoot = $rule["template_root"];
     $matchFileArray = eZTemplateDesignResource::overrideArray();
     if (is_string($templateRoot)) {
         $resourceNodes = $this->resourceAcquisitionTransformation($functionName, $node, $rule, $inputData, $outputName, $namespaceValue, $templateRoot, $viewDir, $viewValue, $matchFileArray, 0, $resourceData);
         // If the transformation failed we return false to invoke interpreted mode
         if ($resourceNodes === false) {
             return false;
         }
         $newNodes = array_merge($newNodes, $resourceNodes);
     } else {
         if (isset($templateRoot['type']) and $templateRoot['type'] == 'multi_match' and isset($templateRoot['attributes']) and isset($templateRoot['matches'])) {
             $rootAttributes = $templateRoot['attributes'];
             $attributeAccessData = array();
             $attributeAccessData[] = eZTemplateNodeTool::createVariableElement($outputName, $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE);
             foreach ($rootAttributes as $rootAttributeName) {
                 $attributeAccessData[] = eZTemplateNodeTool::createAttributeLookupElement($rootAttributeName);
             }
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $attributeAccessData, false, array('spacing' => 0), 'templateRootMatch');
             $rootMatches = $templateRoot['matches'];
             $rootMatchCounter = 0;
             foreach ($rootMatches as $rootMatch) {
                 $rootMatchValue = $rootMatch[0];
                 $templateRoot = $rootMatch[1];
                 $resourceNodes = $this->resourceAcquisitionTransformation($functionName, $node, $rule, $inputData, $outputName, $namespaceValue, $templateRoot, $viewDir, $viewValue, $matchFileArray, 4, $resourceData);
                 // If this transformation failed we continue to the next root match
                 if ($resourceNodes === false) {
                     continue;
                 }
                 $rootMatchValueText = eZPHPCreator::variableText($rootMatchValue, 0, 0, false);
                 $code = '';
                 if ($rootMatchCounter > 0) {
                     $code .= "else " . ($resourceData['use-comments'] ? "/*OF:" . __LINE__ . "*/" : "") . "";
                 }
                 $code .= "if " . ($resourceData['use-comments'] ? "/*OF:" . __LINE__ . "*/" : "") . "( \$templateRootMatch == {$rootMatchValueText} )\n{";
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
                 $newNodes = array_merge($newNodes, $resourceNodes);
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:ezobjectforwarder.php

示例10: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName == $this->BlockName or $functionName == $this->AppendBlockName) {
         if (!isset($parameters['variable'])) {
             return false;
         }
         $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
         if (isset($parameters['scope'])) {
             if (!eZTemplateNodeTool::isStaticElement($parameters['scope'])) {
                 return false;
             }
             $scopeText = eZTemplateNodeTool::elementStaticValue($parameters['scope']);
             if ($scopeText == 'relative') {
                 $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
             } else {
                 if ($scopeText == 'root') {
                     $scope = eZTemplate::NAMESPACE_SCOPE_LOCAL;
                 } else {
                     if ($scopeText == 'global') {
                         $scope = eZTemplate::NAMESPACE_SCOPE_GLOBAL;
                     }
                 }
             }
         }
         $name = '';
         if (isset($parameters['name'])) {
             if (!eZTemplateNodeTool::isStaticElement($parameters['name'])) {
                 return false;
             }
             $name = eZTemplateNodeTool::elementStaticValue($parameters['name']);
         }
         $variableName = eZTemplateNodeTool::elementStaticValue($parameters['variable']);
         $newNodes = array();
         $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
         $newNodes[] = eZTemplateNodeTool::createOutputVariableIncreaseNode();
         $newNodes = array_merge($newNodes, $children);
         $newNodes[] = eZTemplateNodeTool::createAssignFromOutputVariableNode('blockText');
         if ($functionName == $this->AppendBlockName) {
             $data = array(eZTemplateNodeTool::createVariableElement($variableName, $name, $scope));
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $data, false, array(), 'blockData');
             // This block checks whether the append-block variable is an array or not.
             // TODO: This is a temporary solution and should also check whether the template variable exists.
             // This new solution requires probably writing the createVariableElement and createVariableNode your self.
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( is_null ( \$blockData ) ) \$blockData = array();");
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( is_array ( \$blockData ) ) \$blockData[] = \$blockText;");
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("else eZDebug::writeError( \"Variable '{$variableName}' is already in use.\" );");
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'blockData', false, array(), array($name, $scope, $variableName), false, true, true);
             $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('blockData');
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'blockText', false, array(), array($name, $scope, $variableName), false, true, true);
         }
         $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('blockText');
         $newNodes[] = eZTemplateNodeTool::createOutputVariableDecreaseNode();
         return $newNodes;
     } else {
         if ($functionName == $this->OnceName) {
             $functionPlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
             $key = $this->placementKey($functionPlacement);
             $newNodes = array();
             if ($key !== false) {
                 $keyText = eZPHPCreator::variableText($key, 0, 0, false);
                 $placementText = eZPHPCreator::variableText($functionPlacement, 0, 0, false);
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( !isset( \$GLOBALS['eZTemplateRunOnceKeys'][{$keyText}] ) )\n" . "{\n" . "    \$GLOBALS['eZTemplateRunOnceKeys'][{$keyText}] = {$placementText};");
                 $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
                 $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(4);
                 $newNodes = array_merge($newNodes, $children);
                 $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(4);
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
             }
             return $newNodes;
         }
     }
     return false;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:74,代码来源:eztemplateblockfunction.php

示例11: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $newNodes = array();
     $namespaceValue = false;
     $varName = 'match';
     if (!isset($parameters['match'])) {
         return false;
     }
     if (isset($parameters['name'])) {
         $nameData = $parameters['name'];
         if (!eZTemplateNodeTool::isStaticElement($nameData)) {
             return false;
         }
         $namespaceValue = eZTemplateNodeTool::elementStaticValue($nameData);
     }
     if (isset($parameters['var'])) {
         $varData = $parameters['var'];
         if (!eZTemplateNodeTool::isStaticElement($varData)) {
             return false;
         }
         $varName = eZTemplateNodeTool::elementStaticValue($varData);
     }
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['match'], false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $varName));
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['match'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array('variable-name' => 'match', 'text-result' => true), 'match');
     //                                                                       'text-result' => false ) );
     if (isset($parameters['name'])) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
     }
     $tmpNodes = array();
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     $caseNodes = array();
     $caseCounter = 1;
     if (is_array($children)) {
         foreach ($children as $child) {
             $childType = $child[0];
             if ($childType == eZTemplate::NODE_FUNCTION) {
                 if ($this->templateNodeCaseTransformation($tpl, $tmpNodes, $caseNodes, $caseCounter, $child, $privateData) === false) {
                     return false;
                 }
             }
         }
     }
     $newNodes = array_merge($newNodes, $tmpNodes);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("switch ( \$match )\n{");
     $newNodes = array_merge($newNodes, $caseNodes);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('match');
     if (isset($parameters['name'])) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
     }
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode(array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'match'));
     return $newNodes;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:53,代码来源:eztemplateswitchfunction.php

示例12: 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::isStaticElement($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::elementStaticValue($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::isStaticElement($parameters[$i])) {
                     $code .= "{$spacingCode}%output% = " . eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($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) {
                 $spacing = $nestCount - $i - 1;
                 $spacingCode = str_repeat(' ', $spacing * 4);
                 $code .= $spacingCode . "}\n";
             }
             return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
             break;
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:78,代码来源:eztemplatecontroloperator.php

示例13: operatorTransform

 function operatorTransform($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (!eZTemplateNodeTool::isStaticElement($parameters[1]) || count($parameters) > 2 && !eZTemplateNodeTool::isStaticElement($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::isStaticElement($parameters[3])) {
         return false;
     }
     if (count($parameters) > 4 and !eZTemplateNodeTool::isStaticElement($parameters[4])) {
         return false;
     }
     if (count($parameters) > 5 and !eZTemplateNodeTool::isStaticElement($parameters[5])) {
         return false;
     }
     $locale = eZLocale::instance();
     $decimalCount = $locale->decimalCount();
     $decimalSymbol = $locale->decimalSymbol();
     $decimalThousandsSeparator = $locale->thousandsSeparator();
     if (count($parameters) > 2) {
         $prefix = eZTemplateNodeTool::elementStaticValue($parameters[2]);
     } else {
         $prefix = 'auto';
     }
     if (count($parameters) > 3) {
         $decimalCount = eZTemplateNodeTool::elementStaticValue($parameters[3]);
     } elseif ($prefix == 'none') {
         $decimalCount = 0;
     }
     if (count($parameters) > 4) {
         $decimalSymbol = eZTemplateNodeTool::elementStaticValue($parameters[4]);
     }
     if (count($parameters) > 5) {
         $decimalThousandsSeparator = eZTemplateNodeTool::elementStaticValue($parameters[5]);
     }
     $decimalSymbolText = eZPHPCreator::variableText($decimalSymbol, 0, 0, false);
     $decimalThousandsSeparatorText = eZPHPCreator::variableText($decimalThousandsSeparator, 0, 0, false);
     $unit = eZTemplateNodeTool::elementStaticValue($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::isStaticElement($parameters[0])) {
         $output = eZTemplateNodeTool::elementStaticValue($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:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplateunitoperator.php

示例14: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     switch ($functionName) {
         case $this->SetName:
         case $this->DefaultName:
         case $this->LetName:
             $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
             if (isset($parameters['-scope'])) {
                 if (!eZTemplateNodeTool::isStaticElement($parameters['-scope'])) {
                     return false;
                 }
                 $scopeText = eZTemplateNodeTool::elementStaticValue($parameters['-scope']);
                 if ($scopeText == 'relative') {
                     $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
                 } else {
                     if ($scopeText == 'root') {
                         $scope = eZTemplate::NAMESPACE_SCOPE_LOCAL;
                     } else {
                         if ($scopeText == 'global') {
                             $scope = eZTemplate::NAMESPACE_SCOPE_GLOBAL;
                         }
                     }
                 }
             }
             $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
             $namespaceValue = false;
             if (isset($parameters['-name'])) {
                 if (!eZTemplateNodeTool::isStaticElement($parameters['-name'])) {
                     return false;
                 }
                 $namespaceValue = eZTemplateNodeTool::elementStaticValue($parameters['-name']);
             }
             $variableList = array();
             $setVarNodes = array();
             foreach (array_keys($parameters) as $parameterName) {
                 if ($parameterName == '-name' or $parameterName == '-scope') {
                     continue;
                 }
                 $parameterData =& $parameters[$parameterName];
                 $setVarNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), array($namespaceValue, $scope, $parameterName), $functionName == $this->SetName, $functionName != $this->DefaultName, false, $functionName == $this->DefaultName);
                 if ($functionName == $this->LetName or $functionName == $this->DefaultName) {
                     $variableList[] = $parameterName;
                 }
             }
             if (($functionName == $this->LetName or $functionName == $this->DefaultName) and $namespaceValue) {
                 $setVarNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($namespaceValue);
             }
             if ($functionName == $this->LetName or $functionName == $this->DefaultName) {
                 $childNodes = eZTemplateNodeTool::extractFunctionNodeChildren($node);
                 if (!is_array($childNodes)) {
                     $childNodes = array();
                 }
             } else {
                 $childNodes = array();
             }
             $unsetVarNodes = array();
             if (($functionName == $this->LetName or $functionName == $this->DefaultName) and $namespaceValue) {
                 $unsetVarNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
             }
             if ($functionName == $this->LetName or $functionName == $this->DefaultName) {
                 foreach ($variableList as $parameterName) {
                     $unsetVarNodes[] = eZTemplateNodeTool::createVariableUnsetNode(array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName), array('remember_set' => $functionName == $this->DefaultName));
                 }
             }
             return array_merge($setVarNodes, $childNodes, $unsetVarNodes);
             break;
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:68,代码来源:eztemplatesetfunction.php

示例15: washTransformation

 function washTransformation($operatorName, $node, $tpl, $resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $values = array();
     $tmpVarCount = 0;
     $newElements = array();
     $paramCount = count($parameters);
     if ($paramCount > 2) {
         return false;
     }
     $allStatic = true;
     $staticValues = array();
     for ($i = 0; $i < $paramCount; $i++) {
         if (eZTemplateNodeTool::isStaticElement($parameters[$i])) {
             $staticValues[$i] = eZTemplateNodeTool::elementStaticValue($parameters[$i]);
         } else {
             $allStatic = false;
         }
     }
     /* Do optimalizations for 'xhtml' case */
     if ($allStatic) {
         if ($paramCount == 1) {
             $type = 'xhtml';
         } else {
             $type = $staticValues[1];
         }
         $code = "%output% = '" . addcslashes($this->wash($staticValues[0], $tpl, $type), "'\\") . "' ;\n";
     } else {
         if ($paramCount == 1 || $paramCount == 2 && isset($staticValues[1]) && $staticValues[1] == 'xhtml') {
             $values[] = $parameters[0];
             $code = "%output% = htmlspecialchars( %1% );\n";
         } else {
             if ($paramCount == 2 && isset($staticValues[1]) && $staticValues[1] == 'pdf') {
                 $values[] = $parameters[0];
                 $tmpVarCount = 1;
                 $code = '%tmp1% = str_replace( array( " ", "\\r\\n", "\\t" ), array( "<C:callSpace>", "<C:callNewLine>", "<C:callTab>" ), %1% );' . "\n";
                 $code .= '%output% = str_replace( "\\n", "<C:callNewLine>", %tmp1% );' . "\n";
             } else {
                 if ($paramCount == 2 && isset($staticValues[1]) && $staticValues[1] == 'email') {
                     $ini = $tpl->ini();
                     $dotText = addcslashes($ini->variable('WashSettings', 'EmailDotText'), "'");
                     $atText = addcslashes($ini->variable('WashSettings', 'EmailAtText'), "'");
                     $values[] = $parameters[0];
                     $code = "%output% = str_replace( array( '.', '@' ), array( '{$dotText}', '{$atText}' ), %1% );\n";
                 } else {
                     if ($paramCount == 2 && isset($staticValues[1]) && $staticValues[1] == 'javascript') {
                         $values[] = $parameters[0];
                         $code = '%output% = str_replace( array( "\\\\", "\\"", "\'" ),
                                          array( "\\\\\\\\", "\\\\042", "\\\\047" ) , %1% ); ';
                     } else {
                         return false;
                     }
                 }
             }
         }
     }
     $newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values, false, $tmpVarCount);
     return $newElements;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:58,代码来源:eztemplatestringoperator.php


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