本文整理汇总了PHP中eZTemplateNodeTool::createBooleanElement方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createBooleanElement方法的具体用法?PHP eZTemplateNodeTool::createBooleanElement怎么用?PHP eZTemplateNodeTool::createBooleanElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createBooleanElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: compareTrans
function compareTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
{
$isArray = false;
$isString = false;
$inParam = null;
$inParamCode = '';
$compareParams = array();
$compareParamsCode = array();
$offset = 0;
$values = array();
$tmpCount = 0;
if (eZTemplateNodeTool::isStaticElement($parameters[0])) {
$inParam = eZTemplateNodeTool::elementStaticValue($parameters[0]);
$inParamCode = eZPHPCreator::variableText($inParam, 0, 0, false);
$isString = is_string($inParam);
$isArray = is_array($inParam);
} else {
$values[] = $parameters[0];
$inParamCode = '%' . count($values) . '%';
}
for ($i = 1; $i < count($parameters); $i++) {
if (eZTemplateNodeTool::isStaticElement($parameters[$i])) {
$compareParams[] = eZTemplateNodeTool::elementStaticValue($parameters[$i]);
$compareParamsCode[] = eZPHPCreator::variableText(eZTemplateNodeTool::elementStaticValue($parameters[$i]), 0, 0, false);
} else {
$values[] = $parameters[$i];
$compareParamsCode[] = '%' . count($values) . '%';
}
}
switch ($operatorName) {
case $this->EndsWithName:
if (count($values) == 0) {
if ($isString) {
$result = strrpos($inParam, $compareParams[0]) === strlen($inParam) - strlen($compareParams[0]);
} else {
if ($isArray) {
$length = count($inParam);
$params = count($compareParams);
$start = $length - $params;
$result = true;
for ($i = 0; $i < $params; ++$i) {
if ($inParam[$start + $i] != $compareParams[$i]) {
$result = false;
break;
}
}
}
}
return array(eZTemplateNodeTool::createBooleanElement($result));
}
if ($isString) {
$code = '%output% = ( strrpos( ' . $inParamCode . ', ' . $compareParamsCode[0] . ' ) === ( strlen( ' . $inParamCode . ' ) - strlen( ' . $compareParamsCode[0] . ' ) ) );';
} else {
if ($isArray) {
$code = '%tmp4% = ' . $inParamCode . ';' . "\n" . '%tmp1% = count( %tmp4% );' . "\n" . '%tmp2% = ' . count($compareParamsCode) . ';' . "\n" . '%tmp3% = %tmp1% - %tmp2%;' . "\n" . '%output% = true;' . "\n";
for ($i = 0; $i < count($compareParamsCode); ++$i) {
if ($i != 0) {
$code .= 'else ';
}
$code .= 'if ( %tmp4%[%tmp3% + ' . $i . '] != ' . $compareParamsCode[$i] . ')' . "\n" . ' %output% = false;' . "\n";
}
$tmpCount = 4;
} else {
$code = '%tmp4% = ' . $inParamCode . ';' . "\n" . 'if ( is_string( %tmp4% ) )' . "\n" . '{' . "\n" . ' %output% = ( strrpos( %tmp4%, ' . $compareParamsCode[0] . ' ) === ( strlen( %tmp4% ) - strlen( ' . $compareParamsCode[0] . ' ) ) );' . "\n" . '}' . "\n" . 'else if( is_array( %tmp4% ) )' . "\n" . '{' . "\n" . ' %tmp1% = count( %tmp4% );' . "\n" . ' %tmp2% = ' . count($compareParamsCode) . ';' . "\n" . ' %tmp3% = %tmp1% - %tmp2%;' . "\n" . ' %output% = true;' . "\n";
for ($i = 0; $i < count($compareParamsCode); ++$i) {
if ($i != 0) {
$code .= ' else ';
}
$code .= 'if ( %tmp4%[%tmp3% + ' . $i . '] != ' . $compareParamsCode[$i] . ')' . "\n" . ' %output% = false;' . "\n";
}
$code .= '}';
$tmpCount = 4;
}
}
return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, $tmpCount));
break;
case $this->BeginsWithName:
if (count($values) == 0) {
if ($isString) {
$result = strpos($inParam, $compareParams[0]) === 0;
} else {
if ($isArray) {
$result = true;
for ($i = 0; $i < count($compareParams); ++$i) {
if ($inParam[$i] != $compareParams[$i]) {
$result = false;
break;
}
}
}
}
return array(eZTemplateNodeTool::createBooleanElement($result));
}
if ($isString) {
$code = '%output% = ( ' . $compareParamsCode[0] . ' && strpos( ' . $inParamCode . ', ' . $compareParamsCode[0] . ' ) === 0 );';
} else {
if ($isArray) {
$code = '%tmp1% = ' . $inParamCode . ';' . "\n" . '%output% = true;' . "\n";
for ($i = 0; $i < count($compareParamsCode); ++$i) {
if ($i != 0) {
//.........这里部分代码省略.........
示例3: urlTransformation
//.........这里部分代码省略.........
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";
}
}
++$paramCount;
break;
case $this->ImageName:
$skipSlash = count($parameters) > 2 ? eZTemplateNodeTool::elementStaticValue($parameters[2]) == true : false;
if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
$path = eZTemplateNodeTool::elementStaticValue($parameters[0]);
$path = eZURLOperator::eZImage($tpl, $path, $operatorName, $skipSlash);
$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));
$values[] = array(eZTemplateNodeTool::createBooleanElement($skipSlash));
$code = '%tmp1% = %1%;' . "\n" . '%tmp1% = eZURLOperator::eZImage( $tpl, %tmp1%, "' . $operatorName . '", %2% );' . "\n";
$useTmp = true;
++$tmpCount;
} else {
$values[] = $parameters[0];
$values[] = array(eZTemplateNodeTool::createBooleanElement($skipSlash));
$code = '%1% = eZURLOperator::eZImage( $tpl, %1%, "' . $operatorName . '", %2% );' . "\n";
}
}
++$paramCount;
break;
case $this->ExtName:
if (!$shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
$origUrl = eZTemplateNodeTool::elementStaticValue($parameters[0]);
$url = eZURL::urlByMD5(md5($origUrl));
if ($url == false) {
eZURL::registerURL($origUrl);
} else {
$origUrl = $url;
}
$origUrl = $this->applyQuotes($origUrl, $parameters[1]);
return array(eZTemplateNodeTool::createStringElement($origUrl));
} else {
if ($shareTemplates && eZTemplateNodeTool::isStaticElement($parameters[0])) {
$origUrl = eZTemplateNodeTool::elementStaticValue($parameters[0]);
$values[] = array(eZTemplateNodeTool::createStringElement($origUrl));
$code .= '//include_once( \'kernel/classes/datatypes/ezurl/ezurl.php\' );' . "\n" . '%tmp1% = %1%; ' . "\n" . '%tmp2% = eZURL::urlByMD5( md5( %tmp1% ) );' . "\n" . 'if ( %tmp2% == false )' . "\n" . ' eZURL::registerURL( %tmp1% );' . "\n" . 'else' . "\n" . ' %tmp1% = %tmp2%;' . "\n";
++$tmpCount;
$useTmp = true;
} else {
$values[] = $parameters[0];
$code .= '//include_once( \'kernel/classes/datatypes/ezurl/ezurl.php\' );' . "\n" . '%tmp1% = eZURL::urlByMD5( md5( %1% ) );' . "\n" . 'if ( %tmp1% == false )' . "\n" . ' eZURL::registerURL( %1% );' . "\n" . 'else' . "\n" . ' %1% = %tmp1%;' . "\n";
示例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();
}
}
}
}
}
示例5: trueFalseTransformation
function trueFalseTransformation( $operatorName, &$node, $tpl, &$resourceData,
$element, $lastElement, $elementList, $elementTree, &$parameters )
{
$values = array();
if ( ( count( $parameters ) != 0 ) )
{
return false;
}
$newElements = array();
$value = false;
if ( $operatorName == $this->TrueName )
$value = true;
$newElements[] = eZTemplateNodeTool::createBooleanElement( $value );
return $newElements;
}