本文整理汇总了PHP中eZTemplateNodeTool::createNumericElement方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createNumericElement方法的具体用法?PHP eZTemplateNodeTool::createNumericElement怎么用?PHP eZTemplateNodeTool::createNumericElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createNumericElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: arrayTrans
//.........这里部分代码省略.........
for ($i = 2; $i < count($parameters); ++$i) {
$array_to_insert[] = eZTemplateNodeTool::elementStaticValue($parameters[$i]);
}
return array(eZTemplateNodeTool::createArrayElement(array_merge($array_one, $array_to_insert, $array_two)));
}
}
}
$tmpCount = 0;
if ($isString) {
$code = '%output% = substr( ' . $inputArrayCode . ', 0, ' . $offsetCode . ' ) . ' . $insertElemCode[0] . ' . substr( ' . $inputArrayCode . ', ' . $offsetCode . ' );';
} else {
if ($isArray) {
$code = '%tmp1% = ' . $inputArrayCode . ';' . "\n" . '%tmp2% = array_slice( %tmp1%, 0, ' . $offsetCode . ' );' . "\n" . '%tmp3% = array_slice( %tmp1%, ' . $offsetCode . ' );' . "\n" . '%tmp4% = array( ';
for ($i = 0; $i < count($insertElemCode); ++$i) {
if ($i != 0) {
$code .= ", ";
}
$code .= $insertElemCode[$i];
}
$code .= ' );' . "\n" . '%output% = array_merge( %tmp2%, %tmp4%, %tmp3% );' . "\n";
$tmpCount = 4;
} else {
$code = '%tmp1% = ' . $inputArrayCode . ';' . "\n" . 'if ( is_string( %tmp1% ) )' . "\n" . '{' . "\n" . ' %output% = substr( ' . $inputArrayCode . ', 0, ' . $offsetCode . ' ) . ' . $insertElemCode[0] . ' . substr( ' . $inputArrayCode . ', ' . $offsetCode . ' );' . "\n" . '}' . "\n" . 'else if ( is_array( %tmp1% ) )' . "\n" . '{' . "\n" . ' %tmp2% = array_slice( %tmp1%, 0, ' . $offsetCode . ' );' . "\n" . ' %tmp3% = array_slice( %tmp1%, ' . $offsetCode . ' );' . "\n" . ' %tmp4% = array( ';
for ($i = 0; $i < count($insertElemCode); ++$i) {
if ($i != 0) {
$code .= ", ";
}
$code .= $insertElemCode[$i];
}
$code .= ' );' . "\n" . ' %output% = array_merge( %tmp2%, %tmp4%, %tmp3% );' . "\n" . '}' . "\n";
$tmpCount = 4;
}
}
return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, $tmpCount));
break;
case $this->ReverseName:
if (eZTemplateNodeTool::isStaticElement($parameters[0])) {
if (is_string(eZTemplateNodeTool::elementStaticValue($parameters[0]))) {
return array(eZTemplateNodeTool::createStringElement(strrev(eZTemplateNodeTool::elementStaticValue($parameters[0]))));
} else {
if (is_array(eZTemplateNodeTool::elementStaticValue($parameters[0]))) {
return array(eZTemplateNodeTool::createArrayElement(array_reverse(eZTemplateNodeTool::elementStaticValue($parameters[0]))));
}
}
}
$values = array($parameters[0]);
$code = 'if ( is_string( %1% ) )' . "\n" . '{' . "\n" . ' %output% = strrev( %1% );' . "\n" . '}' . "\n" . 'else if( is_array( %1% ) )' . "\n" . '{' . "\n" . ' %output% = array_reverse( %1% );' . "\n" . '}' . "\n";
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
break;
case $this->ArraySumName:
if (eZTemplateNodeTool::isStaticElement($parameters[0])) {
return array(eZTemplateNodeTool::createNumericElement(array_sum(eZTemplateNodeTool::elementStaticValue($parameters[0]))));
}
$values = array($parameters[0]);
$code = '%output% = array_sum( %1% );';
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
break;
case $this->RepeatName:
$values = array();
$isString = false;
$isArray = false;
if (!eZTemplateNodeTool::isStaticElement($parameters[0])) {
$values[] = $parameters[0];
$arrayCode = '%' . count($values) . '%';
} else {
$arrayCode = eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[0]), 0, 0, false);
$isString = is_string(eZTemplateNodeTool::elementStaticValue($parameters[0]));
$isArray = is_array(eZTemplateNodeTool::elementStaticValue($parameters[0]));
}
if (!eZTemplateNodeTool::isStaticElement($parameters[1])) {
$values[] = $parameters[1];
$countCode = '%' . count($values) . '%';
} else {
$count = (int) eZTemplateNodeTool::elementStaticValue($parameters[1]);
if (count($values) == 0) {
if ($isString) {
$retText = '';
$origText = eZTemplateNodeTool::elementStaticValue($parameters[0]);
for ($i = 0; $i < $count; $i++) {
$retText .= $origText;
}
return array(eZTemplateNodeTool::createStringElement($retText));
} else {
if ($isArray) {
$retArray = array();
$origArray = eZTemplateNodeTool::elementStaticValue($parameters[0]);
for ($i = 0; $i < $count; $i++) {
$retArray = array_merge($retArray, $origArray);
}
return array(eZTemplateNodeTool::createArrayElement($retArray));
}
}
}
$countCode = (string) $count;
}
$code = '%tmp2% = ' . $arrayCode . ';' . "\n" . 'if ( is_string( %tmp2% ) )' . "\n" . ' %output% = \'\';' . "\n" . 'else if ( is_array( %tmp2% ) )' . "\n" . ' %output% = array();' . "\n" . 'for( %tmp1% = 0; %tmp1% < ' . $countCode . '; ++%tmp1% )' . "\n" . '{' . "\n" . ' if ( is_string( %tmp2% ) )' . "\n" . ' %output% .= %tmp2%;' . "\n" . ' else if ( is_array( %tmp2% ) )' . "\n" . ' %output% = array_merge( %output%, %tmp2% );' . "\n" . '}' . "\n";
return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 2));
break;
}
}
示例2: 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;
}
示例3: operatorTransform
//.........这里部分代码省略.........
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) {
if ($output >= 0 and $output < 10) {
$prefix_var = '';
}
foreach ($prefixes as $prefix) {
$val = pow(2, (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( 2, (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 ($unit_ini->hasVariable("BinaryPrefixes", $prefix)) {
$prefix_base = 2;
$prefix_var = $unit_ini->variableArray("BinaryPrefixes", $prefix);
} else {
if ($unit_ini->hasVariable("DecimalPrefixes", $prefix)) {
$prefix_base = 10;
$prefix_var = $unit_ini->variableArray("DecimalPrefixes", $prefix);
} else {
if ($prefix == "none") {
$prefix_var = '';
if ($hasInput) {
$output = number_format($output, $decimalCount, $decimalSymbol, $decimalThousandsSeparator);
} else {
$values = array();
$values[] = $parameters[0];
$values[] = array(eZTemplateNodeTool::createStringElement(''));
$values[] = array(eZTemplateNodeTool::createStringElement($base));
$code = '%output% = number_format( %1%, ' . $decimalCount . ', ' . $decimalSymbolText . ', ' . $decimalThousandsSeparatorText . ' ) . \' \' . %2% . %3%;';
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
}
}
}
}
if (is_array($prefix_var)) {
if ($hasInput) {
$val = pow($prefix_base, (int) $prefix_var[0]);
$output = number_format($output / $val, $decimalCount, $decimalSymbol, $decimalThousandsSeparator);
$prefix_var = $prefix_var[1];
} else {
$values = array();
$values[] = $parameters[0];
$values[] = array(eZTemplateNodeTool::createNumericElement(pow($prefix_base, (int) $prefix_var[0])));
$values[] = array(eZTemplateNodeTool::createStringElement($prefix_var[1]));
$values[] = array(eZTemplateNodeTool::createStringElement($base));
$code = '%output% = number_format( %1% / %2%, ' . $decimalCount . ', ' . $decimalSymbolText . ', ' . $decimalThousandsSeparatorText . ' ) . \' \' . %3% . %4%;';
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
}
}
}
}
if ($hasInput) {
return array(eZTemplateNodeTool::createStringElement($output . ' ' . $prefix_var . $base));
}
$values = array();
$values[] = $parameters[0];
$values[] = array(eZTemplateNodeTool::createStringElement($prefix_var));
$values[] = array(eZTemplateNodeTool::createStringElement($base));
$code = '%output% = %1% . \' \' . %2% . %3%;';
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
}
示例4: romanTransformation
function romanTransformation( $operatorName, &$node, $tpl, &$resourceData,
$element, $lastElement, $elementList, $elementTree, &$parameters )
{
$values = array();
if ( count( $parameters ) != 1 )
return false;
$newElements = array();
if ( eZTemplateNodeTool::isConstantElement( $parameters[0] ) )
{
$staticResult = $this->buildRoman( eZTemplateNodeTool::elementConstantValue( $parameters[0] ) );
return array( eZTemplateNodeTool::createNumericElement( $staticResult ) );
}
else
{
return false;
}
}