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


PHP eZTemplateNodeTool::createArrayElement方法代码示例

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


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

示例1: createConstantElement

 static function createConstantElement( $constant, $variablePlacement = false )
 {
     if ( is_array( $constant ) )
         return eZTemplateNodeTool::createArrayElement( $constant, $variablePlacement );
     else if ( is_string( $constant ) )
         return eZTemplateNodeTool::createStringElement( $constant, $variablePlacement );
     else if ( is_bool( $constant ) )
         return eZTemplateNodeTool::createBooleanElement( $constant, $variablePlacement );
     else if ( is_numeric( $constant ) )
         return eZTemplateNodeTool::createNumericElement( $constant, $variablePlacement );
     else
         return eZTemplateNodeTool::createVoidElement();
 }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:13,代码来源:eztemplatenodetool.php

示例2: mergeTrans

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

示例3: operatorTransform

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

示例4: createStaticElement

 static function createStaticElement($static, $variablePlacement = false)
 {
     if (is_array($static)) {
         return eZTemplateNodeTool::createArrayElement($static, $variablePlacement);
     } else {
         if (is_string($static)) {
             return eZTemplateNodeTool::createStringElement($static, $variablePlacement);
         } else {
             if (is_bool($static)) {
                 return eZTemplateNodeTool::createBooleanElement($static, $variablePlacement);
             } else {
                 if (is_numeric($static)) {
                     return eZTemplateNodeTool::createNumericElement($static, $variablePlacement);
                 } else {
                     return eZTemplateNodeTool::createVoidElement();
                 }
             }
         }
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:20,代码来源:eztemplatenodetool.php


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