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


PHP HFile::getDir方法代码示例

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


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

示例1: getCopyFileName

 protected function getCopyFileName($filePath)
 {
     $path = HFile::getDir($filePath);
     $files = file_exists($path) ? HFile::findFiles($path) : array();
     $files = array_flip($files);
     $ext = HFile::getExtension($this->fileName);
     $file = HFile::getFileNameByPath($this->fileName, true);
     $i = 0;
     $copyFileName = '';
     do {
         $copyFileName = $file . '(' . ++$i . ').' . $ext;
     } while (array_key_exists($copyFileName, $files));
     return $copyFileName;
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:14,代码来源:FileUploadAction.php

示例2: combineAndCompress

 /**
  * Performs the actual combining and compressing
  *
  * @param <type> $type
  * @param <type> $urls
  * @param <type> $pos
  */
 private function combineAndCompress($type, $urls, $pos)
 {
     $this->fileUrl or $this->fileUrl = $this->getCoreScriptUrl();
     $this->basePath or $this->basePath = realpath($_SERVER['DOCUMENT_ROOT']);
     $this->filePath or $this->filePath = $this->basePath . $this->fileUrl;
     $optionsHash = $type == 'js' ? md5($this->basePath . $this->compressJs . $this->ttlDays . $this->prefix) : md5($this->basePath . $this->compressCss . $this->ttlDays . $this->prefix . serialize($this->cssMinFilters + $this->cssMinPlugins));
     if ($this->autoRefresh) {
         $mtimes = array();
         foreach ($urls as $file) {
             $fileName = $this->basePath . '/' . trim($file, '/');
             if (file_exists($fileName)) {
                 $mtimes[] = filemtime($fileName);
             }
         }
         $this->_changesHash = md5(serialize($mtimes));
     }
     $combineHash = md5(implode('', $urls));
     $fileName = $this->prefix . md5($combineHash . $optionsHash . $this->_changesHash) . ".{$type}";
     $this->_renewFile = file_exists($this->filePath . '/' . $fileName) ? false : true;
     if ($this->_renewFile) {
         $this->garbageCollect($type);
         $combinedFile = '';
         $notCompress = '';
         // mixa
         foreach ($urls as $key => $file) {
             $path = str_replace('//', '/', $this->basePath . '/' . $file);
             if (!file_exists($path) && mb_strpos($path, Yii::app()->assetManager->basePath) !== false) {
                 // TODO тестовая версия
                 $dir = HFile::getDir($path);
                 HFile::removeDirectoryRecursive($dir);
                 Yii::app()->getRequest()->redirect(Yii::app()->getRequest()->getUrl());
             }
             $fileContent = file_get_contents($path);
             // mixa, обработка зависимых файлов
             $fn = basename($file);
             if (isset($this->dependResource[$fn])) {
                 $webroot = Yii::getPathOfAlias('webroot');
                 foreach ($this->dependResource[$fn] as $dependFile => $addPath) {
                     $dependFile = str_replace('\\', '/', $dependFile);
                     $dependFileName = basename($dependFile);
                     $relativePath = str_replace($webroot, "", $dependFile);
                     if (!file_exists($this->filePath . $relativePath)) {
                         $dir = dirname($this->filePath . $relativePath);
                         if (!file_exists($dir)) {
                             mkdir($dir, Yii::app()->assetManager->newDirMode, true);
                         }
                         copy($dependFile, $this->filePath . $relativePath);
                         @chmod($this->filePath . '/' . $dependFileName, Yii::app()->assetManager->newFileMode);
                     }
                     //            $fileContent = str_replace($addPath.$dependFileName, $this->fileUrl.$relativePath, $fileContent);
                     $fileContent = preg_replace('~([^a-zA-Z\\-])' . $addPath . $dependFileName . '~u', "\${1}" . $this->fileUrl . $relativePath, $fileContent);
                 }
             }
             //---
             if ($type == 'css' && strpos($fn, ".min") !== false) {
                 // mixa, почему-то уже сжатые css-файлы жмутся с ошибками (bootstrap)
                 $notCompress .= $fileContent;
             } else {
                 $combinedFile .= $fileContent;
                 if ($type == 'js') {
                     $combinedFile .= ";\n\r";
                 }
             }
         }
         if ($type == 'js' && $this->compressJs) {
             $combinedFile = $this->minifyJs($combinedFile);
         }
         if ($type == 'css' && $this->compressCss) {
             $combinedFile = $this->minifyCss($combinedFile);
         }
         file_put_contents($this->filePath . '/' . $fileName, $notCompress . $combinedFile);
     }
     foreach ($urls as $url) {
         $this->scriptMap[basename($url)] = $this->fileUrl . '/' . $fileName;
     }
     $this->remapScripts();
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:84,代码来源:ExtendedClientScript.php

示例3: beforeDelete

 protected function beforeDelete()
 {
     //Рекурсивно удаляем дочерние файлы:
     $this->deleteChildFile();
     //Удаляем файл:
     HFile::removeFile($this->getFilePath());
     //Удаляем папку где был файл (если пустая)
     HFile::removeDir(HFile::getDir($this->getFilePath()));
     return parent::beforeDelete();
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:10,代码来源:File.php


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