本文整理汇总了PHP中eZTemplateNodeTool::createConstantElement方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createConstantElement方法的具体用法?PHP eZTemplateNodeTool::createConstantElement怎么用?PHP eZTemplateNodeTool::createConstantElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createConstantElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: concatTransformation
function concatTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
{
$values = array();
$function = $operatorName;
if (count($parameters) < 1) {
return false;
}
if (count($parameters) == 1 and eZTemplateNodeTool::isConstantElement($parameters[0])) {
return array(eZTemplateNodeTool::createConstantElement(eZTemplateNodeTool::elementConstantValue($parameters[0])));
}
$newElements = array();
$counter = 1;
$code = "%output% = ( ";
foreach ($parameters as $parameter) {
$values[] = $parameter;
if ($counter > 1) {
$code .= ' . ';
}
$code .= "%{$counter}%";
$counter++;
}
$code .= " );\n";
$newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
return $newElements;
}
示例2: logicalComparisonTransformation
function logicalComparisonTransformation( $operatorName, &$node, $tpl, &$resourceData,
$element, $lastElement, $elementList, $elementTree, &$parameters )
{
$values = array();
$function = $operatorName;
$minParameterCount = $maxParameterCount = 2;
switch ( $operatorName )
{
case 'lt':
$operator = '<';
break;
case 'le':
$operator = '<=';
break;
case 'gt':
$operator = '>';
break;
case 'ge':
$operator = '>=';
break;
case 'eq':
$operator = '==';
break;
case 'ne':
$operator = '!=';
break;
case 'and':
$operator = 'and';
$maxParameterCount = false;
break;
case 'or':
$operator = 'or';
$maxParameterCount = false;
break;
}
if ( ( count( $parameters ) < 2 ) ||
( $maxParameterCount && ( count( $parameters ) > $maxParameterCount ) ) )
{
return false;
}
$newElements = array();
if ( $operatorName == 'or' )
{
$staticResult = false;
$staticValue = null;
$dynamicParameters = array();
$addDynamic = false;
$lastValue = null;
foreach ( $parameters as $parameter )
{
if ( $addDynamic )
{
$dynamicParameters[] = $parameter;
continue;
}
if ( eZTemplateNodeTool::isConstantElement( $parameter ) )
{
$parameterValue = eZTemplateNodeTool::elementConstantValue( $parameter );
if ( $staticValue === null )
{
$staticValue = $parameterValue;
}
else
{
$staticValue = ( $staticValue or $parameterValue );
}
$lastValue = $parameterValue;
if ( $parameterValue )
{
$staticResult = true;
break;
}
continue;
}
$addDynamic = true;
$dynamicParameters[] = $parameter;
$staticValue = null;
}
if ( count( $dynamicParameters ) == 0 )
{
if ( !$staticResult )
$lastValue = false;
$newElements[] = eZTemplateNodeTool::createConstantElement( $lastValue );
return $newElements;
}
$code = '';
$counter = 0;
foreach ( $dynamicParameters as $parameter )
{
if ( $counter++ )
{
$code .= "else ";
}
$code .= ( "if ( %$counter% )\n" .
" %output% = %$counter%;\n" );
$values[] = $parameter;
}
//.........这里部分代码省略.........
示例3: customMapTransformation
function customMapTransformation($operatorName, $node, $tpl, $resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
{
$values = array();
$newElements = array();
$mapEntry = $this->customMap[$operatorName];
$paramCount = count($parameters);
$strlenFunc = 'strlen';
$substrFunc = 'substr';
$code = "\$strlenFunc = 'strlen'; \$substrFunc = 'substr';\n";
if (function_exists('mb_strlen')) {
$strlenFunc = 'mb_strlen';
$substrFunc = 'mb_substr';
$code = "\$strlenFunc = 'mb_strlen'; \$substrFunc = 'mb_substr';\n";
}
if ($paramCount < 1) {
return false;
}
$allStatic = true;
$staticValues = array();
$replaceMap = array('$result');
$replacementMap = array('%output%');
for ($i = 0; $i < $paramCount; $i++) {
if (eZTemplateNodeTool::isConstantElement($parameters[$i])) {
$staticValues[$i] = eZTemplateNodeTool::elementConstantValue($parameters[$i]);
} else {
$allStatic = false;
}
}
if ($allStatic) {
$result = false;
if (isset($mapEntry['code' . $paramCount])) {
eval($mapEntry['code' . $paramCount]);
} else {
eval($mapEntry['code']);
}
return array(eZTemplateNodeTool::createConstantElement($result));
} else {
$replaceMap = array('$result', '$paramCount');
$replacementMap = array('%output%', $paramCount);
for ($i = 0; $i < $paramCount; $i++) {
$values[] = $parameters[$i];
$replaceMap[] = "\$staticValues[{$i}]";
$replacementMap[] = '%' . ($i + 1) . '%';
}
if (isset($mapEntry['code' . $paramCount])) {
$code .= str_replace($replaceMap, $replacementMap, $mapEntry['code' . $paramCount]) . "\n";
} else {
$code .= str_replace($replaceMap, $replacementMap, $mapEntry['code']) . "\n";
}
}
$newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
return $newElements;
}
示例4: extractTrans
function extractTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
{
$offset = 0;
$length = false;
$values = array();
$code = '';
if ($operatorName == $this->ExtractName) {
if (eZTemplateNodeTool::isConstantElement($parameters[1])) {
$offset = eZTemplateNodeTool::elementConstantValue($parameters[1]);
$code .= (string) $offset;
} else {
$values[] = $parameters[1];
$code .= '%' . count($values) . '%';
}
} else {
if ($operatorName == $this->ExtractRightName) {
if (eZTemplateNodeTool::isConstantElement($parameters[1])) {
$offset = -1 * eZTemplateNodeTool::elementConstantValue($parameters[1]);
$code .= (string) $offset;
} else {
$values[] = $parameters[1];
$code .= '-1 * %' . count($values) . '%';
}
} else {
$code .= '0';
}
}
if ($operatorName == $this->ExtractName) {
if (isset($parameters[2]) and eZTemplateNodeTool::isConstantElement($parameters[2])) {
$length = eZTemplateNodeTool::elementConstantValue($parameters[2]);
$code .= ', ' . (string) $length;
} else {
if (isset($parameters[2])) {
$values[] = $parameters[2];
$code .= ', ' . '%' . count($values) . '%';
}
}
} else {
if ($operatorName == $this->ExtractLeftName) {
if (eZTemplateNodeTool::isConstantElement($parameters[1])) {
$length = eZTemplateNodeTool::elementConstantValue($parameters[1]);
$code .= ', ' . (string) $length;
} else {
$values[] = $parameters[1];
$code .= ', ' . '%' . count($values) . '%';
}
}
}
if (eZTemplateNodeTool::isConstantElement($parameters[0])) {
if (count($values) == 0) {
$input = eZTemplateNodeTool::elementConstantValue($parameters[0]);
if ($operatorName == $this->ExtractRightName or !$length) {
if (is_string($input)) {
$output = substr($input, $offset);
} else {
$output = array_slice($input, $offset);
}
} else {
if (is_string($input)) {
$output = substr($input, $offset, $length);
} else {
$output = array_slice($input, $offset, $length);
}
}
return array(eZTemplateNodeTool::createConstantElement($output));
} else {
$code = '%output% = array_slice( ' . eZPHPCreator::variableText(eZTemplateNodeTool::elementConstantValue($parameters[0]), 0, 0, false) . ', ' . $code . ' );';
}
} else {
$values[] = $parameters[0];
$code = "if ( is_string( %" . count($values) . "% ) )\n" . " %output% = substr( %" . count($values) . "%, " . $code . " );\n" . "else\n" . " %output% = array_slice( %" . count($values) . "%, " . $code . " );";
}
return array(eZTemplateNodeTool::createCodePieceElement($code, $values));
}