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


PHP PHPParser::ParseScript方法代码示例

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


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

示例1: OnChangeFileComponent

 function OnChangeFileComponent($path, $site)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     // kind of optimization
     if (!HasScriptExtension($path)) {
         return;
     }
     $docRoot = CSite::GetSiteDocRoot($site);
     CUrlRewriter::Delete(array("SITE_ID" => $site, "PATH" => $path, "ID" => "NULL"));
     if (class_exists("\\Bitrix\\Main\\Application", false)) {
         \Bitrix\Main\Component\ParametersTable::deleteByFilter(array("SITE_ID" => $site, "REAL_PATH" => $path));
     }
     $fileSrc = $APPLICATION->GetFileContent($docRoot . $path);
     $arComponents = PHPParser::ParseScript($fileSrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         if (class_exists("\\Bitrix\\Main\\Application", false)) {
             \Bitrix\Main\Component\ParametersTable::add(array('SITE_ID' => $site, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y" ? \Bitrix\Main\Component\ParametersTable::SEF_MODE : \Bitrix\Main\Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y" ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"])));
         }
         if (isset($arComponents[$i]["DATA"]["PARAMS"]) && is_array($arComponents[$i]["DATA"]["PARAMS"])) {
             if (array_key_exists("SEF_MODE", $arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
                 CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
             }
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:26,代码来源:main.php

示例2: ReindexFile

 function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
 {
     global $APPLICATION;
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     if (!CUrlRewriter::CheckPath($path)) {
         return 0;
     }
     if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
         return 0;
     }
     $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
     if (!$filesrc || $filesrc == "") {
         return 0;
     }
     $arComponents = PHPParser::ParseScript($filesrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
             $arFields = array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path);
             CUrlRewriter::Add($arFields);
         }
     }
     return true;
 }
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:24,代码来源:urlrewriter.php

示例3: FindComponent

 public static function FindComponent($component_name, $filesrc, $src_line)
 {
     /* parse source file for PHP code */
     $arComponents = PHPParser::ParseScript($filesrc);
     /* identify the component by line number */
     $arComponent = false;
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         $nLineFrom = substr_count(substr($filesrc, 0, $arComponents[$i]["START"]), "\n") + 1;
         $nLineTo = substr_count(substr($filesrc, 0, $arComponents[$i]["END"]), "\n") + 1;
         if ($nLineFrom <= $src_line && $nLineTo >= $src_line) {
             if ($arComponents[$i]["DATA"]["COMPONENT_NAME"] == $component_name) {
                 $arComponent = $arComponents[$i];
                 break;
             }
         }
         if ($nLineTo > $src_line) {
             break;
         }
     }
     return $arComponent;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:21,代码来源:php_parser.php

示例4: OnChangeFileComponent

	function OnChangeFileComponent($path, $site)
	{
		require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/php_parser.php");

		global $APPLICATION;

		$docRoot = CSite::GetSiteDocRoot($site);

		CUrlRewriter::Delete(
			array("SITE_ID" => $site, "PATH" => $path, "ID" => "NULL")
		);

		$fileSrc = $APPLICATION->GetFileContent($docRoot.$path);
		$arComponents = PHPParser::ParseScript($fileSrc);
		for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++)
		{
			if (isset($arComponents[$i]["DATA"]["PARAMS"]) && is_array($arComponents[$i]["DATA"]["PARAMS"]))
			{
				if (array_key_exists("SEF_MODE", $arComponents[$i]["DATA"]["PARAMS"])
					&& $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y")
				{
					CUrlRewriter::Add(
						array(
							"SITE_ID" => $site,
							"CONDITION" => "#^".$arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"]."#",
							"ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"],
							"PATH" => $path
						)
					);
				}
			}
		}
	}
开发者ID:nProfessor,项目名称:Mytb,代码行数:33,代码来源:main.php

示例5: ReindexFile

 public static function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
 {
     global $APPLICATION;
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     if (!CUrlRewriter::CheckPath($path)) {
         return 0;
     }
     if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
         return 0;
     }
     $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
     if (!$filesrc || $filesrc == "") {
         return 0;
     }
     $arComponents = PHPParser::ParseScript($filesrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
             if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
                 $ruleMaker = new \Bitrix\Main\UrlRewriterRuleMaker();
                 $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
                 CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
             } else {
                 CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
             }
         }
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:29,代码来源:urlrewriter.php

示例6: GetMessage

// try to read parameters from script file
/* Try to open script containing the component call */
if (!$src_path || $src_line <= 0) {
    $strWarning .= GetMessage("comp_prop_err_param") . "<br>";
} else {
    $abs_path = $io->RelativeToAbsolutePath($src_path);
    $f = $io->GetFile($abs_path);
    $filesrc = $f->GetContents();
    if (!$filesrc || $filesrc == "") {
        $strWarning .= GetMessage("comp_prop_err_open") . "<br>";
    }
}
$arComponent = false;
if ($strWarning == "") {
    /* parse source file for PHP code */
    $arComponents = PHPParser::ParseScript($filesrc);
    /* identify the component by line number */
    for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
        $nLineFrom = substr_count(substr($filesrc, 0, $arComponents[$i]["START"]), "\n") + 1;
        $nLineTo = substr_count(substr($filesrc, 0, $arComponents[$i]["END"]), "\n") + 1;
        if ($nLineFrom <= $src_line && $nLineTo >= $src_line) {
            if ($arComponents[$i]["DATA"]["COMPONENT_NAME"] == $_GET["component_name"]) {
                $arComponent = $arComponents[$i];
                break;
            }
        }
        if ($nLineTo > $src_line) {
            break;
        }
    }
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:template_copy.php


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