/** * Generates source map content * @param $fileName * @param $content * @return string */ private static function generateSourceMap($fileName, $content) { $files = self::getFilesInfo($content); $sections = ""; foreach ($files as $file) { if (!isset($file["map"]) || strlen($file["map"]) < 1) { continue; } $filePath = Main\Loader::getDocumentRoot() . $file["map"]; if (file_exists($filePath) && ($content = file_get_contents($filePath)) !== false) { if ($sections !== "") { $sections .= ","; } $dirPath = IO\Path::getDirectory($file["source"]); $sourceName = IO\Path::getName($file["source"]); $minName = IO\Path::getName($file["min"]); $sourceMap = str_replace(array($sourceName, $minName), array($dirPath . "/" . $sourceName, $dirPath . "/" . $minName), $content); $sections .= '{"offset": { "line": ' . $file["line"] . ', "column": 0 }, "map": ' . $sourceMap . '}'; } } return '{"version":3, "file":"' . $fileName . '", "sections": [' . $sections . ']}'; }
private static function checkPath($path) { static $searchMasksCache = false; if (is_array($searchMasksCache)) { $arExc = $searchMasksCache["exc"]; $arInc = $searchMasksCache["inc"]; } else { $arExc = array(); $arInc = array(); $inc = Config\Option::get("main", "urlrewrite_include_mask", "*.php"); $inc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $inc))))); $arIncTmp = explode(";", $inc); foreach ($arIncTmp as $preg_mask) { if (strlen(trim($preg_mask)) > 0) { $arInc[] = "'^" . trim($preg_mask) . "\$'"; } } $exc = Config\Option::get("main", "urlrewrite_exclude_mask", "/bitrix/*;"); $exc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $exc))))); $arExcTmp = explode(";", $exc); foreach ($arExcTmp as $preg_mask) { if (strlen(trim($preg_mask)) > 0) { $arExc[] = "'^" . trim($preg_mask) . "\$'"; } } $searchMasksCache = array("exc" => $arExc, "inc" => $arInc); } $file = IO\Path::getName($path); if (substr($file, 0, 1) === ".") { return 0; } foreach ($arExc as $preg_mask) { if (preg_match($preg_mask, $path)) { return false; } } foreach ($arInc as $preg_mask) { if (preg_match($preg_mask, $path)) { return true; } } return false; }
public function getName() { return Path::getName($this->path); }