本文整理汇总了PHP中PHPParser::getComponentFunctionStrings方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser::getComponentFunctionStrings方法的具体用法?PHP PHPParser::getComponentFunctionStrings怎么用?PHP PHPParser::getComponentFunctionStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPParser
的用法示例。
在下文中一共展示了PHPParser::getComponentFunctionStrings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Process
public static function Process($filesrc = false, $old_filesrc = false)
{
if ($filesrc === false) {
return '';
}
// Find all php fragments in $filesrc and:
// 1. Kill all non-component 2.0 fragments
// 2. Get and check params of components
$arPHP = PHPParser::ParseFile($filesrc);
$l = count($arPHP);
if ($l > 0) {
$new_filesrc = '';
$end = 0;
for ($n = 0; $n < $l; $n++) {
$start = $arPHP[$n][0];
$new_filesrc .= self::EncodePHPTags(substr($filesrc, $end, $start - $end));
$end = $arPHP[$n][1];
//Trim php tags
$src = $arPHP[$n][2];
if (substr($src, 0, 5) == "<?php") {
$src = '<?' . substr($src, 5);
}
//If it's Component 2 - we handle it's params, non components2 will be somehow erased
$success = false;
$isComponent2Begin = false;
$component2FunctionName = '';
$arIncludeComponentFunctionStrings = PHPParser::getComponentFunctionStrings();
foreach ($arIncludeComponentFunctionStrings as $functionName) {
$comp2_begin = '<?' . strtoupper($functionName) . '(';
if (strtoupper(substr($src, 0, strlen($comp2_begin))) == $comp2_begin) {
$isComponent2Begin = true;
$component2FunctionName = $functionName;
break;
}
}
if ($isComponent2Begin) {
$arRes = PHPParser::CheckForComponent2($src);
if ($arRes) {
$success = true;
$comp_name = $arRes['COMPONENT_NAME'];
$template_name = $arRes['TEMPLATE_NAME'];
$arParams = $arRes['PARAMS'];
$arPHPparams = array();
self::ComponentChecker($arParams, $arPHPparams);
$len = count($arPHPparams);
$br = "\r\n";
$code = $component2FunctionName . '(' . $br . "\t" . '"' . EscapePHPString($comp_name) . '",' . $br . "\t" . '"' . EscapePHPString($template_name) . '",' . $br;
// If exist at least one parameter with php code inside
if (count($arParams) > 0) {
// Get array with description of component params
$arCompParams = CComponentUtil::GetComponentProps($comp_name);
$arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name);
$arParameters = array();
if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) {
$arParameters = $arParameters + $arCompParams["PARAMETERS"];
}
if (is_array($arTemplParams)) {
$arParameters = $arParameters + $arTemplParams;
}
// Replace values from 'DEFAULT'
for ($e = 0; $e < $len; $e++) {
$par_name = $arPHPparams[$e];
$arParams[$par_name] = isset($arParameters[$par_name]['DEFAULT']) ? $arParameters[$par_name]['DEFAULT'] : '';
}
//ReturnPHPStr
$params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
$code .= "\t" . 'array(' . $br . "\t" . $params . $br . "\t" . ')';
} else {
$code .= "\t" . 'array()';
}
$parent_comp = $arRes['PARENT_COMP'];
$arExParams_ = $arRes['FUNCTION_PARAMS'];
$bEx = isset($arExParams_) && is_array($arExParams_) && count($arExParams_) > 0;
if (!$parent_comp || strtolower($parent_comp) == 'false') {
$parent_comp = false;
}
if ($parent_comp) {
if ($parent_comp == 'true' || is_numeric($parent_comp)) {
$code .= ',' . $br . "\t" . $parent_comp;
} else {
$code .= ',' . $br . "\t\"" . EscapePHPString($parent_comp) . '"';
}
}
if ($bEx) {
if (!$parent_comp) {
$code .= ',' . $br . "\tfalse";
}
$arExParams = array();
foreach ($arExParams_ as $k => $v) {
$k = CMain::_ReplaceNonLatin($k);
$v = CMain::_ReplaceNonLatin($v);
if (strlen($k) > 0 && strlen($v) > 0) {
$arExParams[$k] = $v;
}
}
$exParams = PHPParser::ReturnPHPStr2($arExParams);
$code .= ',' . $br . "\tarray(" . $exParams . ')';
}
$code .= $br . ');';
$code = '<?' . $code . '?>';
//.........这里部分代码省略.........