当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPParser::ReturnPHPStr2方法代码示例

本文整理汇总了PHP中PHPParser::ReturnPHPStr2方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser::ReturnPHPStr2方法的具体用法?PHP PHPParser::ReturnPHPStr2怎么用?PHP PHPParser::ReturnPHPStr2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPParser的用法示例。


在下文中一共展示了PHPParser::ReturnPHPStr2方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _RenderAllComponents

 function _RenderAllComponents($arParams, $bLPA)
 {
     global $APPLICATION, $USER;
     $s = '';
     $arPHP = PHPParser::ParseFile($arParams['source']);
     $l = count($arPHP);
     if ($l > 0) {
         $new_source = '';
         $end = 0;
         $comp_count = 0;
         ob_start();
         for ($n = 0; $n < $l; $n++) {
             //Trim php tags
             $src = $arPHP[$n][2];
             if (SubStr($src, 0, 5) == "<?" . "php") {
                 $src = SubStr($src, 5);
             } else {
                 $src = SubStr($src, 2);
             }
             $src = SubStr($src, 0, -2);
             $comp2_begin = '$APPLICATION->INCLUDECOMPONENT(';
             if (strtoupper(substr($src, 0, strlen($comp2_begin))) != $comp2_begin) {
                 continue;
             }
             $arRes = PHPParser::CheckForComponent2($arPHP[$n][2]);
             if ($arRes) {
                 $comp_name = CMain::_ReplaceNonLatin($arRes['COMPONENT_NAME']);
                 $template_name = CMain::_ReplaceNonLatin($arRes['TEMPLATE_NAME']);
                 $arParams = $arRes['PARAMS'];
                 $arParams['BX_EDITOR_RENDER_MODE'] = 'Y';
                 if ($bLPA) {
                     $arPHPparams = array();
                     CMain::LPAComponentChecker($arParams, $arPHPparams);
                     $len = count($arPHPparams);
                 }
                 $br = "\r\n";
                 $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $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, $template);
                     $arParameters = array();
                     if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) {
                         $arParameters = $arParameters + $arCompParams["PARAMETERS"];
                     }
                     if (is_array($arTemplParams)) {
                         $arParameters = $arParameters + $arTemplParams;
                     }
                     if ($bLPA) {
                         // 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'] : '';
                         }
                     }
                     foreach ($arParams as $key => $val) {
                         if ($key != addslashes($key)) {
                             unset($arParams[$key]);
                         } else {
                             $arParams[$key] = addslashes($val);
                         }
                     }
                     //ReturnPHPStr
                     $params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
                     $code .= "\t" . 'Array(' . $br . "\t" . $params . $br . "\t" . ')';
                 } else {
                     $code .= "\t" . 'Array()';
                 }
                 $parent_comp = CMain::_ReplaceNonLatin($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' || intVal($parent_comp) == $parent_comp) {
                         $code .= ',' . $br . "\t" . $parent_comp;
                     } else {
                         $code .= ',' . $br . "\t\"" . $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 . ');';
                 echo '#BX_RENDERED_COMPONENT_' . $comp_count . '#';
                 eval($code);
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:editor_utils.php

示例2: foreach

            foreach ($aPostValues as $name => $value) {
                if (is_array($value) && count($value) == 1 && isset($value[0]) && $value[0] == "") {
                    $aPostValues[$name] = array();
                } elseif ($bLimitPhpAccess && substr($value, 0, 2) == '={' && substr($value, -1) == '}') {
                    $aPostValues[$name] = $arValues[$name];
                }
            }
            //check template name
            $sTemplateName = "";
            foreach ($arComponentTemplates as $templ) {
                if ($templ["NAME"] == $_POST["NEW_COMPONENT_TEMPLATE"]) {
                    $sTemplateName = $templ["NAME"];
                    break;
                }
            }
            $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $sTemplateName . "\", " . "array(\n\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n\t)" . ",\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . (!empty($arComponent["DATA"]["FUNCTION_PARAMS"]) ? ",\n\t" . "array(\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n\t)" : "") . "\n);";
            $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
            $f = $io->GetFile($abs_path);
            $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents()));
            if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
                $obJSPopup->Close();
            } else {
                $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
            }
        }
    }
}
$componentPath = CComponentEngine::MakeComponentPath($_GET["component_name"]);
$arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
$localPath = getLocalPath("components" . $componentPath);
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:component_props2.php

示例3: substr

			$sTemplateName = "";
			foreach($arComponentTemplates as $templ)
			{
				if($templ["NAME"] == $_POST["NEW_COMPONENT_TEMPLATE"])
				{
					$sTemplateName = $templ["NAME"];
					break;
				}
			}

			$code =  ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]."=":"").
				"\$APPLICATION->IncludeComponent(\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", ".
				"\"".$sTemplateName."\", ".
				"array(\n\t".PHPParser::ReturnPHPStr2($aPostValues)."\n\t)".
				",\n\t".(strlen($arComponent["DATA"]["PARENT_COMP"]) > 0? $arComponent["DATA"]["PARENT_COMP"] : "false").
				(!empty($arComponent["DATA"]["FUNCTION_PARAMS"])? ",\n\t"."array(\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n\t)" : "").
				"\n);";
			$filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]);

			$f = $io->GetFile($abs_path);
			$arUndoParams = array(
				'module' => 'fileman',
				'undoType' => 'edit_component_props',
				'undoHandler' => 'CFileman::UndoEditFile',
				'arContent' => array(
					'absPath' => $abs_path,
					'content' => $f->GetContents()
				)
			);

			if($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
开发者ID:nProfessor,项目名称:Mytb,代码行数:31,代码来源:component_props2.php

示例4: array

                     $arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name, $template);
                     $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'] : '';
                     }
                     CComponentUtil::PrepareVariables($arParams);
                     //ReturnPHPStr
                     $params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
                     $code .= "\t" . 'Array(' . $br . "\t" . $params . $br . "\t" . ')' . $br . ');';
                 } else {
                     $code .= "\t" . 'Array()' . $br . ');';
                 }
                 $code = '<?' . $code . '?>';
                 $new_content .= $code;
             }
         }
     }
     $new_content .= CMain::EncodePHPTags(substr($content_, $end));
     $CONTENT = $new_content;
 } else {
     $CONTENT = CMain::EncodePHPTags($new_content);
 }
 // Get array of PHP scripts from original template src
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:template_create_preview.php

示例5: ProcessLPA

 function ProcessLPA($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 .= CMain::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 erased
             $comp2_begin = '<?$APPLICATION->INCLUDECOMPONENT(';
             if (strtoupper(substr($src, 0, strlen($comp2_begin))) == $comp2_begin) {
                 $arRes = PHPParser::CheckForComponent2($src);
                 if ($arRes) {
                     $comp_name = CMain::_ReplaceNonLatin($arRes['COMPONENT_NAME']);
                     $template_name = CMain::_ReplaceNonLatin($arRes['TEMPLATE_NAME']);
                     $arParams = $arRes['PARAMS'];
                     $arPHPparams = array();
                     CMain::LPAComponentChecker($arParams, $arPHPparams);
                     $len = count($arPHPparams);
                     $br = "\r\n";
                     $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $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 = CMain::_ReplaceNonLatin($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' || intVal($parent_comp) == $parent_comp) {
                             $code .= ',' . $br . "\t" . $parent_comp;
                         } else {
                             $code .= ',' . $br . "\t\"" . $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;
                             }
                         }
                         //CComponentUtil::PrepareVariables($arExParams);
                         $exParams = PHPParser::ReturnPHPStr2($arExParams);
                         $code .= ',' . $br . "\tarray(" . $exParams . ')';
                     }
                     $code .= $br . ');';
                     $code = '<?' . $code . '?>';
                     $new_filesrc .= $code;
                 }
             }
         }
         $new_filesrc .= CMain::EncodePHPTags(substr($filesrc, $end));
         $filesrc = $new_filesrc;
     } else {
         $filesrc = CMain::EncodePHPTags($filesrc);
     }
     if (strpos($filesrc, '#PHP') !== false && $old_filesrc !== false) {
         // Get array of PHP scripts from old saved file
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:main.php

示例6: GetMessage

    }
}
if ($strWarning == "") {
    $arComponent = PHPParser::FindComponent($_GET["component_name"], $filesrc, $src_line);
    if ($arComponent === false) {
        $strWarning = GetMessage("comp_prop_err_comp");
    }
}
if ($strWarning == "") {
    if (!check_bitrix_sessid()) {
        $strWarning = GetMessage("comp_prop_err_save");
    } else {
        if (!is_array($arComponent["DATA"]["FUNCTION_PARAMS"])) {
            $arComponent["DATA"]["FUNCTION_PARAMS"] = array();
        }
        $arComponent["DATA"]["FUNCTION_PARAMS"]["ACTIVE_COMPONENT"] = $_GET['active'] == 'N' ? 'N' : 'Y';
        $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $arComponent["DATA"]["TEMPLATE_NAME"] . "\", " . "array(\r\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"]) . "\r\n\t)" . ",\r\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . ",\r\n\t" . "array(\r\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\r\n\t)" . "\r\n);";
        $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
        $f = $io->GetFile($abs_path);
        $arUndoParams = array('module' => 'fileman', 'undoType' => $_GET['active'] == 'N' ? 'disable_component' : 'enable_component', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents()));
        if (!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
            $strWarning = GetMessage("comp_prop_err_save");
        } else {
            CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
        }
    }
}
if ($strWarning != "") {
    echo "<script>alert('" . CUtil::JSEscape($strWarning) . "')</script>";
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_js.php";
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:enable_component.php

示例7: substr

			$functionParams = "";
			if(!empty($arComponent["DATA"]["FUNCTION_PARAMS"]))
			{
				$functionParams = ",\n".
					"\tarray(\n".
					"\t\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n".
					"\t)";
			}

			$code = ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]." = ":"").
				"\$APPLICATION->IncludeComponent(\n".
				"\t\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", \n".
				"\t\"".$sTemplateName."\", \n".
				"\tarray(\n".
				"\t\t".PHPParser::ReturnPHPStr2($aPostValues)."\n".
				"\t),\n".
				"\t".($arComponent["DATA"]["PARENT_COMP"] <> ''? $arComponent["DATA"]["PARENT_COMP"] : "false").
				$functionParams.
				"\n);";

			$filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]);

			$f = $io->GetFile($abs_path);
			$arUndoParams = array(
				'module' => 'fileman',
				'undoType' => 'edit_component_props',
				'undoHandler' => 'CFileman::UndoEditFile',
				'arContent' => array(
					'absPath' => $abs_path,
					'content' => $f->GetContents()
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:30,代码来源:component_props2.php

示例8: foreach

                }
            }
            //check template name
            $sTemplateName = "";
            $arComponentTemplates = CComponentUtil::GetTemplatesList($componentName, $templateId);
            foreach ($arComponentTemplates as $templ) {
                if ($templ["NAME"] == $_POST["COMPONENT_TEMPLATE"]) {
                    $sTemplateName = $templ["NAME"];
                    break;
                }
            }
            $functionParams = "";
            if (!empty($arComponent["DATA"]["FUNCTION_PARAMS"])) {
                $functionParams = ",\n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n" . "\t)";
            }
            $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . " = " : "") . "\$APPLICATION->IncludeComponent(\n" . "\t\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", \n" . "\t\"" . $sTemplateName . "\", \n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n" . "\t),\n" . "\t" . ($arComponent["DATA"]["PARENT_COMP"] != '' ? $arComponent["DATA"]["PARENT_COMP"] : "false") . $functionParams . "\n);";
            $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
            $f = $io->GetFile($abs_path);
            $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents()));
            if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
                $obJSPopup->Close();
            } else {
                $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
            }
        }
    }
}
$componentPath = CComponentEngine::MakeComponentPath($componentName);
if ($strWarning !== "") {
    $obJSPopup->ShowValidationError($strWarning);
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:component_props2.php

示例9: GetMessage

	{
		$strWarning = GetMessage("comp_prop_err_save");
	}
	else
	{
		if(!is_array($arComponent["DATA"]["FUNCTION_PARAMS"]))
			$arComponent["DATA"]["FUNCTION_PARAMS"] = array();
		
		$arComponent["DATA"]["FUNCTION_PARAMS"]["ACTIVE_COMPONENT"] = ($_GET['active'] == 'N'? 'N':'Y');

		$code =  ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]."=":"").
			"\$APPLICATION->IncludeComponent(\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", ".
			"\"".$arComponent["DATA"]["TEMPLATE_NAME"]."\", ".
			"array(\r\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"])."\r\n\t)".
			",\r\n\t".(strlen($arComponent["DATA"]["PARENT_COMP"]) > 0? $arComponent["DATA"]["PARENT_COMP"] : "false").
			",\r\n\t"."array(\r\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\r\n\t)".
			"\r\n);";

		$filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]);

		$f = $io->GetFile($abs_path);
		$arUndoParams = array(
			'module' => 'fileman',
			'undoType' => $_GET['active'] == 'N'? 'disable_component' : 'enable_component' ,
			'undoHandler' => 'CFileman::UndoEditFile',
			'arContent' => array(
				'absPath' => $abs_path,
				'content' => $f->GetContents()
			)
		);
		
开发者ID:ASDAFF,项目名称:open_bx,代码行数:30,代码来源:enable_component.php


注:本文中的PHPParser::ReturnPHPStr2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。