本文整理汇总了PHP中Bitrix\Main\IO\Path::getDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::getDirectory方法的具体用法?PHP Path::getDirectory怎么用?PHP Path::getDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\IO\Path
的用法示例。
在下文中一共展示了Path::getDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestedPageDirectory
public function getRequestedPageDirectory()
{
if ($this->requestedFileDirectory != null) {
return $this->requestedFileDirectory;
}
$requestedFile = $this->getRequestedPage();
return $this->requestedFileDirectory = IO\Path::getDirectory($requestedFile);
}
示例2: getRequestedPageDirectory
public function getRequestedPageDirectory()
{
if ($this->requestedPageDirectory === null) {
$requestedPage = $this->getRequestedPage();
$this->requestedPageDirectory = IO\Path::getDirectory($requestedPage);
}
return $this->requestedPageDirectory;
}
示例3: loadLanguageFile
/**
* Loads language messages for specified file
*
* @param string $file
* @param string $language
* @return array
*/
public static function loadLanguageFile($file, $language = null)
{
if ($language === null) {
$language = self::getCurrentLang();
}
if (!isset(self::$messages[$language])) {
self::$messages[$language] = array();
}
//first time call only for lang
if (self::$customMessages === null) {
self::$customMessages = self::loadCustomMessages($language);
}
$path = Path::getDirectory($file);
static $langDirCache = array();
if (isset($langDirCache[$path])) {
$langDir = $langDirCache[$path];
$fileName = substr($file, strlen($langDir) - 5);
} else {
//let's find language folder
$langDir = $fileName = "";
$filePath = $file;
while (($slashPos = strrpos($filePath, "/")) !== false) {
$filePath = substr($filePath, 0, $slashPos);
$langPath = $filePath . "/lang";
if (is_dir($langPath)) {
$langDir = $langPath;
$fileName = substr($file, $slashPos);
$langDirCache[$path] = $langDir;
break;
}
}
}
$mess = array();
if ($langDir != "") {
//load messages for default lang first
$defaultLang = self::getDefaultLang($language);
if ($defaultLang != $language) {
$langFile = $langDir . "/" . $defaultLang . $fileName;
if (file_exists($langFile)) {
$mess = self::includeFile($langFile);
}
}
//then load messages for specified lang
$langFile = $langDir . "/" . $language . $fileName;
if (file_exists($langFile)) {
$mess = array_merge($mess, self::includeFile($langFile));
}
foreach ($mess as $key => $val) {
self::$messages[$language][$key] = $val;
}
}
return $mess;
}
示例4: includeLangFiles
private static function includeLangFiles($file, $language)
{
static $langDirCache = array();
$path = Path::getDirectory($file);
if (isset($langDirCache[$path])) {
$langDir = $langDirCache[$path];
$fileName = substr($file, strlen($langDir) - 5);
} else {
//let's find language folder
$langDir = $fileName = "";
$filePath = $file;
while (($slashPos = strrpos($filePath, "/")) !== false) {
$filePath = substr($filePath, 0, $slashPos);
$langPath = $filePath . "/lang";
if (is_dir($langPath)) {
$langDir = $langPath;
$fileName = substr($file, $slashPos);
$langDirCache[$path] = $langDir;
break;
}
}
}
$mess = array();
if ($langDir != "") {
//load messages for default lang first
$defaultLang = self::getDefaultLang($language);
if ($defaultLang != $language) {
$langFile = $langDir . "/" . $defaultLang . $fileName;
if (file_exists($langFile)) {
$mess = self::includeFile($langFile);
}
}
//then load messages for specified lang
$langFile = $langDir . "/" . $language . $fileName;
if (file_exists($langFile)) {
$mess = array_merge($mess, self::includeFile($langFile));
}
}
return $mess;
}
示例5: download
/**
* Downloads and saves a file.
*
* @param string $url URI to download
* @param string $filePath Absolute file path
* @return bool
*/
public function download($url, $filePath)
{
$dir = IO\Path::getDirectory($filePath);
IO\Directory::createDirectory($dir);
$file = new IO\File($filePath);
$handler = $file->open("w+");
if ($handler !== false) {
$this->setOutputStream($handler);
$res = $this->query(self::HTTP_GET, $url);
fclose($handler);
return $res;
}
return false;
}
示例6: fixCssIncludes
/**
* Replace path to includes in css
* @param $content
* @param $path
* @return mixed
*/
public static function fixCssIncludes($content, $path)
{
$path = IO\Path::getDirectory($path);
$content = preg_replace_callback('#([;\\s:]*(?:url|@import)\\s*\\(\\s*)(\'|"|)(.+?)(\\2)\\s*\\)#si', create_function('$matches', 'return $matches[1].Bitrix\\Main\\Page\\Asset::replaceUrlCSS($matches[3], $matches[2], "' . addslashes($path) . '").")";'), $content);
$content = preg_replace_callback('#(\\s*@import\\s*)([\'"])([^\'"]+)(\\2)#si', create_function('$matches', 'return $matches[1].Bitrix\\Main\\Page\\Asset::replaceUrlCSS($matches[3], $matches[2],"' . addslashes($path) . '");'), $content);
return $content;
}
示例7: generateSourceMap
/**
* 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 . ']}';
}
示例8: getDirectoryName
public function getDirectoryName()
{
return Path::getDirectory($this->path);
}