當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZTemplateCompiler::TemplatePrefix方法代碼示例

本文整理匯總了PHP中eZTemplateCompiler::TemplatePrefix方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZTemplateCompiler::TemplatePrefix方法的具體用法?PHP eZTemplateCompiler::TemplatePrefix怎麽用?PHP eZTemplateCompiler::TemplatePrefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZTemplateCompiler的用法示例。


在下文中一共展示了eZTemplateCompiler::TemplatePrefix方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateVariableDataCode


//.........這裏部分代碼省略.........
                                                            $php->addCodePiece($code, array('spacing' => $spacing));
                                                            $php->addVariableUnsetList($unsetList, array('spacing' => $spacing));
                                                        } else {
                                                            if ($variableDataType == eZTemplate::TYPE_INTERNAL_CODE_PIECE) {
                                                                $code = $variableDataItem[1];
                                                                $values = false;
                                                                $matchMap = array('%input%', '%output%');
                                                                $replaceMap = array('$' . $variableAssignmentName, '$' . $variableAssignmentName);
                                                                $unsetList = array();
                                                                $counter = 1;
                                                                if (isset($variableDataItem[3]) && is_array($variableDataItem[3])) {
                                                                    $newParameters = $parameters;
                                                                    $values = $variableDataItem[3];
                                                                    foreach ($values as $value) {
                                                                        $newParameters['counter'] += 1;
                                                                        $newVariableAssignmentName = $newParameters['variable'];
                                                                        $newVariableAssignmentCounter = $newParameters['counter'];
                                                                        if ($newVariableAssignmentCounter > 0) {
                                                                            $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                                        }
                                                                        if (eZTemplateNodeTool::isStaticElement($value)) {
                                                                            $staticValue = eZTemplateNodeTool::elementStaticValue($value);
                                                                            $staticValueText = $php->thisVariableText($staticValue, 0, 0, false);
                                                                            if (preg_match("/%code{$counter}%/", $code)) {
                                                                                $matchMap[] = '%code' . $counter . '%';
                                                                                $replaceMap[] = '';
                                                                            }
                                                                            $matchMap[] = '%' . $counter . '%';
                                                                            $replaceMap[] = $staticValueText;
                                                                        } else {
                                                                            $matchMap[] = '%' . $counter . '%';
                                                                            $replaceMap[] = '$' . $newVariableAssignmentName;
                                                                            $unsetList[] = $newVariableAssignmentName;
                                                                            if (preg_match("/%code{$counter}%/", $code)) {
                                                                                $tmpPHP = new eZPHPCreator('', '', eZTemplateCompiler::TemplatePrefix());
                                                                                $tmpKnownTypes = array();
                                                                                eZTemplateCompiler::generateVariableDataCode($tmpPHP, $tpl, $value, $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                                                $newCode = $tmpPHP->fetch(false);
                                                                                if (count($tmpKnownTypes) == 0 or in_array('objectproxy', $tmpKnownTypes)) {
                                                                                    $newCode .= "while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$newVariableAssignmentName} ) and method_exists( \${$newVariableAssignmentName}, 'templateValue' ) )\n" . "    \${$newVariableAssignmentName} = \${$newVariableAssignmentName}" . "->templateValue();\n";
                                                                                }
                                                                                $matchMap[] = '%code' . $counter . '%';
                                                                                $replaceMap[] = $newCode;
                                                                            } else {
                                                                                $tmpKnownTypes = array();
                                                                                eZTemplateCompiler::generateVariableDataCode($php, $tpl, $value, $tmpKnownTypes, $dataInspection, $persistence, $newParameters, $resourceData);
                                                                                if (!$parameters['treat-value-as-non-object'] and (count($tmpKnownTypes) == 0 or in_array('objectproxy', $tmpKnownTypes))) {
                                                                                    $php->addCodePiece("while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$newVariableAssignmentName} ) and method_exists( \${$newVariableAssignmentName}, 'templateValue' ) )\n" . "    \${$newVariableAssignmentName} = \${$newVariableAssignmentName}" . "->templateValue();\n", array('spacing' => $spacing));
                                                                                }
                                                                            }
                                                                        }
                                                                        ++$counter;
                                                                    }
                                                                }
                                                                if (isset($variableDataItem[4]) && $variableDataItem[4] !== false) {
                                                                    $values = $variableDataItem[4];
                                                                    for ($i = 0; $i < $values; $i++) {
                                                                        $newParameters['counter'] += 1;
                                                                        $newVariableAssignmentName = $newParameters['variable'];
                                                                        $newVariableAssignmentCounter = $newParameters['counter'];
                                                                        if ($newVariableAssignmentCounter > 0) {
                                                                            $newVariableAssignmentName .= $newVariableAssignmentCounter;
                                                                        }
                                                                        $matchMap[] = '%tmp' . ($i + 1) . '%';
                                                                        $replaceMap[] = '$' . $newVariableAssignmentName;
                                                                        $unsetList[] = $newVariableAssignmentName;
                                                                    }
                                                                }
                                                                if (isset($variableDataItem[5]) and $variableDataItem[5]) {
                                                                    if (is_array($variableDataItem[5])) {
                                                                        $knownTypes = array_unique(array_merge($knownTypes, $variableDataItem[5]));
                                                                    } else {
                                                                        if (is_string($variableDataItem[5])) {
                                                                            $knownTypes = array_unique(array_merge($knownTypes, array($variableDataItem[5])));
                                                                        } else {
                                                                            $knownTypes = array_unique(array_merge($knownTypes, array('static')));
                                                                        }
                                                                    }
                                                                }
                                                                $code = str_replace($matchMap, $replaceMap, $code);
                                                                $php->addCodePiece($code, array('spacing' => $spacing));
                                                                $php->addVariableUnsetList($unsetList, array('spacing' => $spacing));
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // After the entire expression line is done we try to extract the actual value if proxies are used
        $php->addCodePiece("if (! isset( \${$variableAssignmentName} ) ) \${$variableAssignmentName} = NULL;\n");
        $php->addCodePiece("while " . ($resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/" : "") . "( is_object( \${$variableAssignmentName} ) and method_exists( \${$variableAssignmentName}, 'templateValue' ) )\n" . "    \${$variableAssignmentName} = \${$variableAssignmentName}" . "->templateValue();\n");
    }
開發者ID:runelangseid,項目名稱:ezpublish,代碼行數:101,代碼來源:eztemplatecompiler.php


注:本文中的eZTemplateCompiler::TemplatePrefix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。