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


PHP PHPParser类代码示例

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


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

示例1: Load

 public static final function Load($path, $name)
 {
     if (class_exists($name)) {
         return true;
     }
     PHPParser::LoadPHPFile($path);
     if (!class_exists($name)) {
         throw new ApplicationException(sprintf(_("%s must contain %s class."), $path, $name), E_ERROR);
     }
     return true;
 }
开发者ID:rchicoria,项目名称:epp-drs,代码行数:11,代码来源:class.ModuleFactory.php

示例2: main

 private function main()
 {
     while ($this->isRunning === TRUE) {
         // Setup our listen arrays
         $sockReads = $sockWrites = $socketExcept = array();
         if (!$this->isWindows) {
             $sockReads[] = STDIN;
         }
         // Add host sockets to the arrays as needed
         // While at it, check if we need to connect to any of the hosts.
         $this->hosts->getSelectableSockets($sockReads, $sockWrites);
         // Add http sockets to the arrays as needed
         $this->http->getSelectableSockets($sockReads, $sockWrites);
         // Add telnet sockets to the arrays as needed
         $this->telnet->getSelectableSockets($sockReads, $sockWrites);
         // Update timeout if there are timers waiting to be fired.
         $this->updateSelectTimeOut($this->sleep, $this->uSleep);
         # Error suppression used because this function returns a "Invalid CRT parameters detected" only on Windows.
         $numReady = @stream_select($sockReads, $sockWrites, $socketExcept, $this->sleep, $this->uSleep);
         // Keep looping until you've handled all activities on the sockets.
         while ($numReady > 0) {
             $numReady -= $this->hosts->checkTraffic($sockReads, $sockWrites);
             $numReady -= $this->http->checkTraffic($sockReads, $sockWrites);
             $numReady -= $this->telnet->checkTraffic($sockReads, $sockWrites);
             // KB input
             if (in_array(STDIN, $sockReads)) {
                 $numReady--;
                 $kbInput = trim(fread(STDIN, STREAM_READ_BYTES));
                 // Split up the input
                 $exp = explode(' ', $kbInput);
                 // Process the command (the first char or word of the line)
                 switch ($exp[0]) {
                     case 'c':
                         console(sprintf('%32s - %64s', 'COMMAND', 'DESCRIPTOIN'));
                         foreach ($this->plugins->getPlugins() as $plugin => $details) {
                             foreach ($details->sayCommands as $command => $detail) {
                                 console(sprintf('%32s - %64s', $command, $detail['info']));
                             }
                         }
                         break;
                     case 'h':
                         console(sprintf('%14s %28s:%-5s %8s %22s', 'Host ID', 'IP', 'PORT', 'UDPPORT', 'STATUS'));
                         foreach ($this->hosts->getHostsInfo() as $host) {
                             $status = ($host['connStatus'] == CONN_CONNECTED ? '' : ($host['connStatus'] == CONN_VERIFIED ? 'VERIFIED &' : ' NOT')) . ' CONNECTED';
                             $socketType = $host['socketType'] == SOCKTYPE_TCP ? 'tcp://' : 'udp://';
                             console(sprintf('%14s %28s:%-5s %8s %22s', $host['id'], $socketType . $host['ip'], $host['port'], $host['udpPort'], $status));
                         }
                         break;
                     case 'I':
                         console('RE-INITIALISING PRISM...');
                         $this->initialise(NULL, NULL);
                         break;
                     case 'p':
                         console(sprintf('%28s %8s %24s %64s', 'NAME', 'VERSION', 'AUTHOR', 'DESCRIPTION'));
                         foreach ($this->plugins->getPlugins() as $plugin => $details) {
                             console(sprintf("%28s %8s %24s %64s", $plugin::NAME, $plugin::VERSION, $plugin::AUTHOR, $plugin::DESCRIPTION));
                         }
                         break;
                     case 'x':
                         $this->isRunning = FALSE;
                         break;
                     case 'w':
                         console(sprintf('%15s:%5s %5s', 'IP', 'PORT', 'LAST ACTIVITY'));
                         foreach ($this->http->getHttpInfo() as $v) {
                             $lastAct = time() - $v['lastActivity'];
                             console(sprintf('%15s:%5s %13d', $v['ip'], $v['port'], $lastAct));
                         }
                         console('Counted ' . $this->http->getHttpNumClients() . ' http client' . ($this->http->getHttpNumClients() == 1 ? '' : 's'));
                         break;
                     default:
                         console('Available Commands:');
                         console('	h - show host info');
                         console('	I - re-initialise PRISM (reload ini files / reconnect to hosts / reset http socket');
                         console('	p - show plugin info');
                         console('	x - exit PHPInSimMod');
                         console('	w - show www connections');
                         console('	c - show command list');
                 }
             }
         }
         // End while(numReady)
         // No need to do the maintenance check every turn
         if ($this->nextMaintenance > time()) {
             continue;
         }
         $this->nextMaintenance = time() + MAINTENANCE_INTERVAL;
         if (!$this->hosts->maintenance()) {
             $this->isRunning = FALSE;
         }
         $this->http->maintenance();
         PHPParser::cleanSessions();
     }
     // End while(isRunning)
 }
开发者ID:NochEinKamel,项目名称:PRISM,代码行数:94,代码来源:PHPInSimMod.php

示例3: 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

示例4: reindexFile

 private function reindexFile($siteId, $rootPath, $path, $maxFileSize = 0)
 {
     $pathAbs = IO\Path::combine($rootPath, $path);
     if (!UrlRewriter::checkPath($pathAbs)) {
         return 0;
     }
     $file = new IO\File($pathAbs);
     if ($maxFileSize > 0 && $file->getFileSize() > $maxFileSize * 1024) {
         return 0;
     }
     $fileSrc = $file->getContents();
     if (!$fileSrc || $fileSrc == "") {
         return 0;
     }
     $arComponents = \PHPParser::parseScript($fileSrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         $sef = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y";
         Component\ParametersTable::add(array('SITE_ID' => $siteId, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $sef ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $sef ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"])));
         if ($sef) {
             if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
                 $ruleMaker = new UrlRewriterRuleMaker();
                 $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
                 $arFields = array("CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
             } else {
                 $arFields = array("CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
             }
             UrlRewriter::add($siteId, $arFields);
         }
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:urlrewriter.php

示例5: markFile

 /** 
  * Mark a source code file based on the coverage data gathered
  * 
  * @param $phpFile Name of the actual source file
  * @param $fileLink Link to the html mark-up file for the $phpFile
  * @param &$coverageLines Coverage recording for $phpFile
  * @return boolean FALSE on failure
  * @access protected
  */
 protected function markFile($phpFile, $fileLink, &$coverageLines)
 {
     global $util;
     $fileLink = $util->replaceBackslashes($fileLink);
     $parentDir = $util->replaceBackslashes(dirname($fileLink));
     if (!file_exists($parentDir)) {
         //echo "\nCreating dir: $parentDir\n";
         $util->makeDirRecursive($parentDir, 0755);
     }
     $writer = fopen($fileLink, "w");
     if (empty($writer)) {
         $this->logger->error("Could not open file for writing: {$fileLink}", __FILE__, __LINE__);
         return false;
     }
     // Get the header for file
     $filestr = $this->writePhpFileHeader(basename($phpFile), $fileLink);
     // Add header for table
     $filestr .= '<table width="100%" border="0" cellpadding="2" cellspacing="0">';
     $filestr .= $this->writeFileTableHead();
     $lineCnt = $coveredCnt = $uncoveredCnt = 0;
     $parser = new PHPParser();
     $parser->parse($phpFile);
     $lastLineType = "non-exec";
     $fileLines = array();
     while (($line = $parser->getLine()) !== false) {
         if (substr($line, -1) == "\n") {
             $line = substr($line, 0, -1);
         }
         $lineCnt++;
         $coverageLineNumbers = array_keys($coverageLines);
         if (in_array($lineCnt, $coverageLineNumbers)) {
             $lineType = $parser->getLineType();
             if ($lineType == LINE_TYPE_EXEC) {
                 $coveredCnt++;
                 $type = "covered";
             } else {
                 if ($lineType == LINE_TYPE_CONT) {
                     // XDebug might return this as covered - when it is
                     // actually merely a continuation of previous line
                     if ($lastLineType == "covered" || $lastLineType == "covered_cont") {
                         unset($coverageLines[$lineCnt]);
                         $type = "covered_cont";
                         $coveredCnt++;
                     } else {
                         $ft = "uncovered_cont";
                         for ($il = $lineCnt - 1; $il >= 0 && isset($fileLines[$lineCnt - 1]["type"]) && $ft == "uncovered_cont"; $il--) {
                             $ft = $fileLines[$il]["type"];
                             $uncoveredCnt--;
                             $coveredCnt++;
                             if ($ft == "uncovered") {
                                 $fileLines[$il]["type"] = "covered";
                             } else {
                                 $fileLines[$il]["type"] = "covered_cont";
                             }
                         }
                         $coveredCnt++;
                         $type = "covered_cont";
                     }
                 } else {
                     $type = "non-exec";
                     $coverageLines[$lineCnt] = 0;
                 }
             }
         } else {
             if ($parser->getLineType() == LINE_TYPE_EXEC) {
                 $uncoveredCnt++;
                 $type = "uncovered";
             } else {
                 if ($parser->getLineType() == LINE_TYPE_CONT) {
                     if ($lastLineType == "uncovered" || $lastLineType == "uncovered_cont") {
                         $uncoveredCnt++;
                         $type = "uncovered_cont";
                     } else {
                         if ($lastLineType == "covered" || $lastLineType == "covered_cont") {
                             $coveredCnt++;
                             $type = "covered_cont";
                         } else {
                             $type = $lastLineType;
                             $this->logger->debug("LINE_TYPE_CONT with lastLineType={$lastLineType}", __FILE__, __LINE__);
                         }
                     }
                 } else {
                     $type = "non-exec";
                 }
             }
         }
         // Save line type
         $lastLineType = $type;
         //echo $line . "\t[" . $type . "]\n";
         if (!isset($coverageLines[$lineCnt])) {
             $coverageLines[$lineCnt] = 0;
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:HtmlCoverageReporter.php

示例6: htmlspecialcharsbx

    $str_SITE_ID = htmlspecialcharsbx($site);
    $str_BODY_TYPE = "html";
    $str_TITLE = htmlspecialcharsbx($str_TITLE);
} else {
    $doc_files = CWorkflow::GetFileList($ID);
    while ($zr = $doc_files->GetNext()) {
        $arDocFiles[] = $zr;
    }
    $str_BODY = htmlspecialcharsback($str_BODY);
}
if ($message) {
    $DB->InitTableVarsForEdit("b_workflow_document", "", "str_");
}
if ($USER->CanDoFileOperation('fm_lpa', array($str_SITE_ID, $str_FILENAME)) && !$USER->CanDoOperation('edit_php')) {
    $content = $str_BODY;
    $arPHP = PHPParser::ParseFile($content);
    $l = count($arPHP);
    if ($l > 0) {
        $str_BODY = '';
        $end = 0;
        $php_count = 0;
        for ($n = 0; $n < $l; $n++) {
            $start = $arPHP[$n][0];
            $str_BODY .= substr($content, $end, $start - $end);
            $end = $arPHP[$n][1];
            //Trim php tags
            $src = $arPHP[$n][2];
            if (SubStr($src, 0, 5) == "<?" . "php") {
                $src = SubStr($src, 5);
            } else {
                $src = SubStr($src, 2);
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:workflow_edit.php

示例7: 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

示例8: 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

示例9: GetDirList

function GetDirList($path, &$arDirs, &$arFiles, $arFilter = array(), $sort = array(), $type = "DF", $bLogical = false, $task_mode = false)
{
    global $USER, $APPLICATION;
    CMain::InitPathVars($site, $path);
    $DOC_ROOT = CSite::GetSiteDocRoot($site);
    $arDirs = array();
    $arFiles = array();
    $exts = strtolower($arFilter["EXTENSIONS"]);
    $arexts = explode(",", $exts);
    if (isset($arFilter["TYPE"])) {
        $type = strtoupper($arFilter["TYPE"]);
    }
    $io = CBXVirtualIo::GetInstance();
    $path = $io->CombinePath("/", $path);
    $abs_path = $io->CombinePath($DOC_ROOT, $path);
    if (!$io->DirectoryExists($abs_path)) {
        return false;
    }
    $date_format = CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL"));
    $tzOffset = CTimeZone::GetOffset();
    $dir = $io->GetDirectory($abs_path);
    $arChildren = $dir->GetChildren();
    foreach ($arChildren as $child) {
        $arFile = array();
        if (($type == "F" || $type == "") && $child->IsDirectory()) {
            continue;
        }
        if (($type == "D" || $type == "") && !$child->IsDirectory()) {
            continue;
        }
        $file = $child->GetName();
        if ($bLogical) {
            if ($child->IsDirectory()) {
                $sSectionName = "";
                $fsn = $io->CombinePath($abs_path, $file, ".section.php");
                if (!$io->FileExists($fsn)) {
                    continue;
                }
                include $io->GetPhysicalName($fsn);
                $arFile["LOGIC_NAME"] = $sSectionName;
            } else {
                if (CFileMan::GetFileTypeEx($file) != "php") {
                    continue;
                }
                if ($file == '.section.php') {
                    continue;
                }
                if (!preg_match('/^\\.(.*)?\\.menu\\.(php|html|php3|php4|php5|php6|phtml)$/', $file, $regs)) {
                    $f = $io->GetFile($abs_path . "/" . $file);
                    $filesrc = $f->GetContents();
                    $title = PHPParser::getPageTitle($filesrc);
                    if ($title === false) {
                        continue;
                    }
                    $arFile["LOGIC_NAME"] = $title;
                }
            }
        }
        $arFile["PATH"] = $abs_path . "/" . $file;
        $arFile["ABS_PATH"] = $path . "/" . $file;
        $arFile["NAME"] = $file;
        $arPerm = $APPLICATION->GetFileAccessPermission(array($site, $path . "/" . $file), $USER->GetUserGroupArray(), $task_mode);
        if ($task_mode) {
            $arFile["PERMISSION"] = $arPerm[0];
            if (count($arPerm[1]) > 0) {
                $arFile["PERMISSION_EX"] = $arPerm[1];
            }
        } else {
            $arFile["PERMISSION"] = $arPerm;
        }
        $arFile["TIMESTAMP"] = $child->GetModificationTime() + $tzOffset;
        $arFile["DATE"] = date($date_format, $arFile["TIMESTAMP"]);
        if (isset($arFilter["TIMESTAMP_1"]) && strtotime($arFile["DATE"]) < strtotime($arFilter["TIMESTAMP_1"])) {
            continue;
        }
        if (isset($arFilter["TIMESTAMP_2"]) && strtotime($arFile["DATE"]) > strtotime($arFilter["TIMESTAMP_2"])) {
            continue;
        }
        if (is_set($arFilter, "MIN_PERMISSION") && $arFile["PERMISSION"] < $arFilter["MIN_PERMISSION"] && !$task_mode) {
            continue;
        }
        if (!$child->IsDirectory() && $arFile["PERMISSION"] <= "R" && !$task_mode) {
            continue;
        }
        if ($bLogical) {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["LOGIC_NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        } else {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        }
        //if(strlen($arFilter["NAME"])>0 && strpos($arFile["NAME"], $arFilter["NAME"])===false)
        //	continue;
        if (substr($arFile["ABS_PATH"], 0, strlen(BX_ROOT . "/modules")) == BX_ROOT . "/modules" && !$USER->CanDoOperation('edit_php') && !$task_mode) {
            continue;
        }
        if ($arFile["PERMISSION"] == "U" && !$task_mode) {
            $ftype = GetFileType($arFile["NAME"]);
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:admin_tools.php

示例10: markFile

 protected function markFile($phpFile, $fileLink, &$coverageLines)
 {
     global $util;
     $fileLink = $util->replaceBackslashes($fileLink);
     $parentDir = $util->replaceBackslashes(dirname($fileLink));
     $lineCnt = $coveredCnt = $uncoveredCnt = 0;
     $parser = new PHPParser();
     $parser->parse($phpFile);
     $lastLineType = "non-exec";
     $fileLines = array();
     while (($line = $parser->getLine()) !== false) {
         $line = substr($line, 0, strlen($line) - 1);
         $lineCnt++;
         $coverageLineNumbers = array_keys($coverageLines);
         if (in_array($lineCnt, $coverageLineNumbers)) {
             $lineType = $parser->getLineType();
             if ($lineType == LINE_TYPE_EXEC) {
                 $coveredCnt++;
                 $type = "covered";
             } else {
                 if ($lineType == LINE_TYPE_CONT) {
                     // XDebug might return this as covered - when it is
                     // actually merely a continuation of previous line
                     if ($lastLineType == "covered") {
                         unset($coverageLines[$lineCnt]);
                         $type = $lastLineType;
                     } else {
                         if ($lineCnt - 1 >= 0 && isset($fileLines[$lineCnt - 1]["type"])) {
                             if ($fileLines[$lineCnt - 1]["type"] == "uncovered") {
                                 $uncoveredCnt--;
                             }
                             $fileLines[$lineCnt - 1]["type"] = $lastLineType = "covered";
                         }
                         $coveredCnt++;
                         $type = "covered";
                     }
                 } else {
                     $type = "non-exec";
                     $coverageLines[$lineCnt] = 0;
                 }
             }
         } else {
             if ($parser->getLineType() == LINE_TYPE_EXEC) {
                 $uncoveredCnt++;
                 $type = "uncovered";
             } else {
                 if ($parser->getLineType() == LINE_TYPE_CONT) {
                     $type = $lastLineType;
                 } else {
                     $type = "non-exec";
                 }
             }
         }
         // Save line type
         $lastLineType = $type;
         if (!isset($coverageLines[$lineCnt])) {
             $coverageLines[$lineCnt] = 0;
         }
         $fileLines[$lineCnt] = array("type" => $type, "lineCnt" => $lineCnt, "line" => $line, "coverageLines" => $coverageLines[$lineCnt]);
     }
     return array('filename' => $phpFile, 'covered' => $coveredCnt, 'uncovered' => $uncoveredCnt, 'total' => $lineCnt);
 }
开发者ID:vasiatka,项目名称:sitemap,代码行数:62,代码来源:lmbSummaryCoverageReporter.class.php

示例11: 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

示例12: 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

示例13: 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

示例14: GetMessage

            }
        }
    }
    if ($aComponent === false) {
        $strWarning .= GetMessage("comp_prop_err_comp") . "<br>";
    }
}
//$_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh"
if ($strWarning == "") {
    $arTemplate = CTemplates::GetByID($_GET["path"], $arValues, $_GET["template_id"]);
    /* save parameters to file */
    if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $aComponent !== false && $arTemplate !== false) {
        if (!check_bitrix_sessid()) {
            $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
        } else {
            $params = PHPParser::ReturnPHPStr($_POST, $arTemplate["PARAMS"]);
            if ($params != "") {
                $code = "<" . "?" . ($arRes["VARIABLE"] ? $arRes["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeFile(\"" . $_GET["path"] . "\", Array(\r\n\t" . $params . "\r\n\t)\r\n);?" . ">";
            } else {
                $code = "<" . "?" . ($arRes["VARIABLE"] ? $arRes["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeFile(\"" . $_GET["path"] . "\");?" . ">";
            }
            $filesrc_for_save = substr($filesrc, 0, $aComponent[0]) . $code . substr($filesrc, $aComponent[1]);
            if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                $obJSPopup->Close();
            } else {
                $strWarning .= GetMessage("comp_prop_err_save") . "<br />";
            }
        }
    }
}
if ($arTemplate["ICON"] == "" || !is_file($_SERVER["DOCUMENT_ROOT"] . $arTemplate["ICON"])) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:component_props.php

示例15: FetchParams

 function FetchParams($content)
 {
     // 1. Parse file
     $arPHP = PHPParser::ParseFile($content);
     $arComponents = array('bitrix:intranet.event_calendar', 'bitrix:socialnetwork', 'bitrix:socialnetwork_user', 'bitrix:socialnetwork_group');
     if (count($arPHP) > 0) {
         self::$types = CCalendarConvert::GetOption('__convert_types');
         self::$iblockTypes = CCalendarConvert::GetOption('__convert_ibl_types');
         self::$settings = CCalendarConvert::GetOption('__convert_settings');
         foreach ($arPHP as $code) {
             $arRes = PHPParser::CheckForComponent2($code[2]);
             if ($arRes && in_array($arRes['COMPONENT_NAME'], $arComponents)) {
                 $PARAMS = $arRes['PARAMS'];
                 if ($arRes['COMPONENT_NAME'] == 'bitrix:intranet.event_calendar') {
                     if (!in_array($PARAMS['IBLOCK_TYPE'], self::$iblockTypes) && $PARAMS['IBLOCK_TYPE']) {
                         self::$iblockTypes[] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (self::$types['user']['iblockType'] == '') {
                         self::$types['user']['iblockType'] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (self::$types['group']['iblockType'] == '') {
                         self::$types['group']['iblockType'] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (isset($PARAMS['USERS_IBLOCK_ID']) && $PARAMS['USERS_IBLOCK_ID'] > 0 && self::$types['user']['iblockId'] <= 0) {
                         self::$types['user']['iblockId'] = intval($PARAMS['USERS_IBLOCK_ID']);
                     }
                     if (isset($PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID']) && $PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID'] > 0 && self::$types['group']['iblockId'] <= 0) {
                         self::$types['group']['iblockId'] = intval($PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID']);
                     }
                     // Settings
                     self::SetModuleOption('path_to_user', $PARAMS['PATH_TO_USER']);
                     self::SetModuleOption('week_holidays', $PARAMS['WEEK_HOLIDAYS']);
                     self::SetModuleOption('year_holidays', $PARAMS['YEAR_HOLIDAYS']);
                     self::SetModuleOption('work_time_start', $PARAMS['WORK_TIME_START']);
                     self::SetModuleOption('work_time_end', $PARAMS['WORK_TIME_END']);
                     self::SetModuleOption('rm_iblock_type', $PARAMS['CALENDAR_IBLOCK_TYPE']);
                     self::SetModuleOption('rm_iblock_id', $PARAMS['CALENDAR_RES_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_rm', $PARAMS['CALENDAR_PATH_TO_RES_MEETING']);
                     self::SetModuleOption('vr_iblock_id', $PARAMS['CALENDAR_VIDEO_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING_DETAIL']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING']);
                 } else {
                     if (!in_array($PARAMS['CALENDAR_IBLOCK_TYPE'], self::$iblockTypes) && $PARAMS['CALENDAR_IBLOCK_TYPE']) {
                         self::$iblockTypes[] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (self::$types['user']['iblockType'] == '') {
                         self::$types['user']['iblockType'] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (self::$types['group']['iblockType'] == '') {
                         self::$types['group']['iblockType'] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (isset($PARAMS['CALENDAR_USER_IBLOCK_ID']) && $PARAMS['CALENDAR_USER_IBLOCK_ID'] > 0 && self::$types['user']['iblockId'] <= 0) {
                         self::$types['user']['iblockId'] = intval($PARAMS['CALENDAR_USER_IBLOCK_ID']);
                     }
                     if (isset($PARAMS['CALENDAR_GROUP_IBLOCK_ID']) && $PARAMS['CALENDAR_GROUP_IBLOCK_ID'] > 0 && self::$types['group']['iblockId'] <= 0) {
                         self::$types['group']['iblockId'] = intval($PARAMS['CALENDAR_GROUP_IBLOCK_ID']);
                     }
                     self::SetModuleOption('path_to_user', $PARAMS['PATH_TO_USER']);
                     self::SetModuleOption('path_to_group', $PARAMS['PATH_TO_GROUP']);
                     if (isset($PARAMS['SEF_URL_TEMPLATES']['group_calendar']) && (strpos($PARAMS['SEF_URL_TEMPLATES']['group_calendar'], 'extranet') === false && strpos($PARAMS['SEF_FOLDER'], 'extranet') === false)) {
                         self::SetModuleOption('path_to_group_calendar', $PARAMS['SEF_FOLDER'] . $PARAMS['SEF_URL_TEMPLATES']['group_calendar']);
                     }
                     if (isset($PARAMS['SEF_URL_TEMPLATES']['user_calendar']) && (strpos($PARAMS['SEF_URL_TEMPLATES']['user_calendar'], 'extranet') === false && strpos($PARAMS['SEF_FOLDER'], 'extranet') === false)) {
                         self::SetModuleOption('path_to_user_calendar', $PARAMS['SEF_FOLDER'] . $PARAMS['SEF_URL_TEMPLATES']['user_calendar']);
                     }
                     self::SetModuleOption('week_holidays', $PARAMS['CALENDAR_WEEK_HOLIDAYS']);
                     self::SetModuleOption('year_holidays', $PARAMS['CALENDAR_YEAR_HOLIDAYS']);
                     self::SetModuleOption('work_time_start', $PARAMS['CALENDAR_WORK_TIME_START']);
                     self::SetModuleOption('work_time_end', $PARAMS['CALENDAR_WORK_TIME_END']);
                     self::SetModuleOption('rm_iblock_type', $PARAMS['CALENDAR_IBLOCK_TYPE']);
                     self::SetModuleOption('rm_iblock_id', $PARAMS['CALENDAR_RES_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_rm', $PARAMS['CALENDAR_PATH_TO_RES_MEETING']);
                     self::SetModuleOption('vr_iblock_id', $PARAMS['CALENDAR_VIDEO_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING_DETAIL']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING']);
                 }
             }
         }
         CCalendarConvert::SetOption('__convert_types', self::$types);
         CCalendarConvert::SetOption('__convert_ibl_types', self::$iblockTypes);
         CCalendarConvert::SetOption('__convert_settings', self::$settings);
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:84,代码来源:calendar_convert.php


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