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


PHP eZTemplateNodeTool::elementStaticValue方法代码示例

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


在下文中一共展示了eZTemplateNodeTool::elementStaticValue方法的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: 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

示例4: 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

示例5: 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

示例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


//.........这里部分代码省略.........
                                    // 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])) {
                                                    $attributeStaticValue = eZTemplateNodeTool::elementStaticValue($variableDataItem[1]);
                                                    $attributeText = $php->thisVariableText($attributeStaticValue, 0, 0, false);
                                                } else {
                                                    $newParameters['counter'] += 1;
                                                    $tmpKnownTypes = array();
                                                    eZTemplateCompiler::generateVariableDataCode($php, $tpl, $variableDataItem[1], $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                    $newVariableAssignmentName = $newParameters['variable'];
                                                    $newVariableAssignmentCounter = $newParameters['counter'];
                                                    if ($newVariableAssignmentCounter > 0) {
                                                        $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                    }
                                                    $attributeText = "\${$newVariableAssignmentName}";
                                                }
                                                $php->addCodePiece("\${$tmpVariableAssignmentName} = compiledFetchAttribute( \${$variableAssignmentName}, {$attributeText} );\n" . "unset( \${$variableAssignmentName} );\n" . "\${$variableAssignmentName} = \${$tmpVariableAssignmentName};\n", array('spacing' => $spacing));
                                                // End if optimized node object is null/false. See also eZTemplateOptimizer::optimizeVariable()
                                                if ($optimizeNode && $index == 3) {
                                                    $php->addCodePiece("}\n");
                                                }
                                            } else {
                                                if ($variableDataType == eZTemplate::TYPE_OPERATOR) {
                                                    $knownTypes = array();
                                                    $operatorParameters = $variableDataItem[1];
                                                    $operatorName = $operatorParameters[0];
                                                    $operatorParameters = array_splice($operatorParameters, 1);
                                                    $operatorNameText = $php->thisVariableText($operatorName, 0, 0, false);
                                                    $operatorParametersText = $php->thisVariableText($operatorParameters, 23, 0, false);
                                                    $operatorHint = eZTemplateCompiler::operatorHint($tpl, $operatorName);
                                                    if (isset($operatorHint['output']) and $operatorHint['output']) {
                                                        if (isset($operatorHint['output-type'])) {
                                                            $knownType = $operatorHint['output-type'];
                                                            if (is_array($knownType)) {
                                                                $knownTypes = array_merge($knownTypes, $knownType);
                                                            } else {
开发者ID:runelangseid,项目名称:ezpublish,代码行数:67,代码来源: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: i18nTrans

 function i18nTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     // i18n( $input, $context, $comment, $arguments )
     // Check if if the three first parameters are constants, if not we cannot compile it
     foreach (array_slice($parameters, 0, 3) as $parameter) {
         if ($parameter !== null && !eZTemplateNodeTool::isConstantElement($parameter)) {
             return false;
         }
     }
     $value = eZTemplateNodeTool::elementStaticValue($parameters[0]);
     $numParameters = count($parameters);
     $context = $numParameters > 1 ? eZTemplateNodeTool::elementStaticValue($parameters[1]) : null;
     $comment = $numParameters > 2 ? eZTemplateNodeTool::elementStaticValue($parameters[2]) : null;
     if ($numParameters < 4) {
         return array(eZTemplateNodeTool::createStringElement(ezpI18n::tr($context, $value, $comment, null)));
     }
     $values = array();
     $ini = eZINI::instance();
     if ($ini->variable('RegionalSettings', 'TextTranslation') != 'disabled') {
         $language = eZLocale::instance()->localeFullCode();
         if ($language != "eng-GB") {
             $file = 'translation.ts';
             $ini = eZINI::instance();
             $useCache = $ini->variable('RegionalSettings', 'TranslationCache') != 'disabled';
             eZTSTranslator::initialize($context, $language, $file, $useCache);
             $man = eZTranslatorManager::instance();
             $newValue = $man->translate($context, $value, $comment);
             if ($newValue) {
                 $value = $newValue;
             }
         }
     }
     $values[] = array(eZTemplateNodeTool::createStringElement($value));
     $values[] = $parameters[3];
     $code = '%tmp1% = array();' . "\n" . 'foreach ( %2% as %tmp2% => %tmp3% )' . "\n" . '{' . "\n" . '  if ( is_int( %tmp2% ) )' . "\n" . '    %tmp1%[\'%\' . ( (%tmp2%%9) + 1 )] = %tmp3%;' . "\n" . '  else' . "\n" . '    %tmp1%[%tmp2%] = %tmp3%;' . "\n" . '}' . "\n" . '%output% = strtr( %1%, %tmp1% );' . "\n";
     return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 3));
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:37,代码来源:ezi18noperator.php

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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