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


PHP eZTemplateNodeTool::createStringElement方法代码示例

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


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

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

示例2: urlTransformation

    function urlTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
    {
        $ini = eZINI::instance();
        $shareTemplates = $ini->hasVariable('TemplateSettings', 'ShareCompiledTemplates') ? $ini->variable('TemplateSettings', 'ShareCompiledTemplates') == 'enabled' : false;
        $useTmp = false;
        $newElements = array();
        $values = array();
        $paramCount = 0;
        $tmpCount = 0;
        switch ($operatorName) {
            case $this->URLName:
                if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                    $url = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                    $serverURL = isset($parameters[2]) ? eZTemplateNodeTool::elementStaticValue($parameters[2]) : 'relative';
                    eZURI::transformURI($url, false, $serverURL);
                    $url = $this->applyQuotes($url, $parameters[1]);
                    return array(eZTemplateNodeTool::createStringElement($url));
                } else {
                    if ($shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                        $url = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                        $values[] = array(eZTemplateNodeTool::createStringElement($url));
                        $values[] = isset($parameters[2]) ? $parameters[2] : array(eZTemplateNodeTool::createStringElement('relative'));
                        $code = <<<CODEPIECE

%tmp1% = %1%;
eZURI::transformURI( %tmp1%, false, %2% );

CODEPIECE;
                        $useTmp = true;
                        ++$tmpCount;
                    } else {
                        $values[] = $parameters[0];
                        $values[] = isset($parameters[2]) ? $parameters[2] : array(eZTemplateNodeTool::createStringElement('relative'));
                        $code = <<<CODEPIECE

//include_once( 'lib/ezutils/classes/ezuri.php' );
eZURI::transformURI( %1%, false, %2% );

CODEPIECE;
                    }
                }
                ++$paramCount;
                break;
            case $this->URLRootName:
                if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                    $url = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                    if (preg_match("#^[a-zA-Z0-9]+:#", $url) or substr($url, 0, 2) == '//') {
                        $url = '/';
                    } else {
                        if (strlen($url) > 0 and $url[0] != '/') {
                            $url = '/' . $url;
                        }
                    }
                    $serverURL = isset($parameters[2]) ? eZTemplateNodeTool::elementStaticValue($parameters[2]) : 'relative';
                    // Same as "ezurl" without "index.php" and the siteaccess name in the returned address.
                    eZURI::transformURI($url, true, $serverURL);
                    $url = $this->applyQuotes($url, $parameters[1]);
                    return array(eZTemplateNodeTool::createStringElement($url));
                } else {
                    if ($shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                        $url = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                        $values[] = array(eZTemplateNodeTool::createStringElement($url));
                        $values[] = isset($parameters[2]) ? $parameters[2] : array(eZTemplateNodeTool::createStringElement('relative'));
                        $code = '%tmp1% = %1%;';
                        $code .= 'if ( preg_match( "#^[a-zA-Z0-9]+:#", %tmp1% ) or' . "\n" . 'substr( %tmp1%, 0, 2 ) == \'//\' )' . "\n" . '  %tmp1% = \'/\';' . "\n" . 'else if ( strlen( %tmp1% ) > 0 and' . "\n" . '  %tmp1%[0] != \'/\' )' . "\n" . '%tmp1% = \'/\' . %tmp1%;' . "\n";
                        $code .= '//include_once( \'lib/ezutils/classes/ezuri.php\' );' . "\n" . 'eZURI::transformURI( %tmp1%, true, %2% );' . "\n";
                        $useTmp = true;
                        ++$tmpCount;
                    } else {
                        $values[] = $parameters[0];
                        $values[] = isset($parameters[2]) ? $parameters[2] : array(eZTemplateNodeTool::createStringElement('relative'));
                        $code = 'if ( preg_match( "#^[a-zA-Z0-9]+:#", %1% ) or' . "\n" . 'substr( %1%, 0, 2 ) == \'//\' )' . "\n" . '  %1% = \'/\';' . "\n" . 'else if ( strlen( %1% ) > 0 and' . "\n" . '  %1%[0] != \'/\' )' . "\n" . '%1% = \'/\' . %1%;' . "\n";
                        $code .= '//include_once( \'lib/ezutils/classes/ezuri.php\' );' . "\n" . 'eZURI::transformURI( %1%, true, %2% );' . "\n";
                    }
                }
                ++$paramCount;
                break;
            case $this->SysName:
                if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[1])) {
                    $sysAttribute = eZTemplateNodeTool::elementStaticValue($parameters[1]);
                    return array(eZTemplateNodeTool::createStringElement($this->Sys->attribute($sysAttribute)));
                }
                return false;
                break;
            case $this->DesignName:
                if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                    $path = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                    $path = $this->eZDesign($tpl, $path, $operatorName);
                    $path = $this->applyQuotes($path, $parameters[1]);
                    return array(eZTemplateNodeTool::createStringElement($path));
                } else {
                    if ($shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
                        $path = eZTemplateNodeTool::elementStaticValue($parameters[0]);
                        $values[] = array(eZTemplateNodeTool::createStringElement($path));
                        $code = '%tmp1% = %1%;' . "\n" . '%tmp1% = eZURLOperator::eZDesign( $tpl, %tmp1%, "' . $operatorName . '" );' . "\n";
                        $useTmp = true;
                        ++$tmpCount;
                    } else {
                        $values[] = $parameters[0];
                        $code = '%1% = eZURLOperator::eZDesign( $tpl, %1%, "' . $operatorName . '" );' . "\n";
//.........这里部分代码省略.........
开发者ID:stevoland,项目名称:ez_patch,代码行数:101,代码来源:ezurloperator.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: 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::elementConstantValue($parameters[0]);
     $numParameters = count($parameters);
     $context = $numParameters > 1 ? eZTemplateNodeTool::elementConstantValue($parameters[1]) : null;
     $comment = $numParameters > 2 ? eZTemplateNodeTool::elementConstantValue($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:CG77,项目名称:ezpublish-legacy,代码行数:37,代码来源:ezi18noperator.php

示例5: createNamespaceChangeNode

 static function createNamespaceChangeNode($variableData, $parameters = array())
 {
     if (is_string($variableData)) {
         $variableData = array(eZTemplateNodeTool::createStringElement($variableData));
     } else {
         if (is_numeric($variableData)) {
             $variableData = array(eZTemplateNodeTool::createNumericElement($variableData));
         }
     }
     $node = array(eZTemplate::NODE_INTERNAL_NAMESPACE_CHANGE, $variableData, $parameters);
     return $node;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:12,代码来源:eztemplatenodetool.php

示例6: 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;
            }
        }

        $ini = eZINI::instance();
        $dynamic = $ini->variable( 'RegionalSettings', 'DynamicTemplateMode' ) === 'enabled';

        if ( $dynamic )
        {
            $numParameters = count ( $parameters );
            $values = array();
            $values[] = ( $numParameters > 1 ) ? $parameters[1] : null;;
            $values[] = $parameters[0];
            $values[] = ( $numParameters > 2 ) ? $parameters[2] : null;
            $values[] = ( $numParameters > 3 ) ? $parameters[3] : null;
            $code = '%output% = ezpI18n::tr( %1%, %2%, %3%, %4% );' . "\n";
            return array( eZTemplateNodeTool::createCodePieceElement( $code, $values ) );
        }

        $value = eZTemplateNodeTool::elementConstantValue( $parameters[0] );

        $numParameters = count ( $parameters );
        $context = ( $numParameters > 1 ) ? eZTemplateNodeTool::elementConstantValue( $parameters[1] ) : null;
        $comment = ( $numParameters > 2 ) ? eZTemplateNodeTool::elementConstantValue( $parameters[2] ) : null;

        if ( $numParameters < 4 )
        {
            return array ( eZTemplateNodeTool::createStringElement( ezpI18n::tr( $context, $value, $comment, null ) ) );
        }

        $values = array();

        if ( $ini->variable( 'RegionalSettings', 'TextTranslation' ) != 'disabled' )
        {
            $newValue = ezpI18n::tr( $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:sushilbshinde,项目名称:ezpublish-study,代码行数:66,代码来源:ezi18noperator.php


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