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


PHP IOHelper::copyFile方法代码示例

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


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

示例1: onAfterInstall

 /**
  * When installed, this plugin converts RichText fields into BetterRedactor
  * fields. It also creates a folder, craft/config/redactor_plugins, and
  * populates it with some starting plugins.
  */
 public function onAfterInstall()
 {
     craft()->db->createCommand()->update('fields', array('type' => 'BetterRedactor'), array('type' => 'RichText'));
     $config_folder = craft()->path->getConfigPath() . '/redactor_plugins';
     if (!IOHelper::folderExists($config_folder)) {
         $initial_folder = craft()->path->getPluginsPath() . '/betterredactor/redactor_plugins';
         $files = array_filter(scandir($initial_folder), function ($file) use($initial_folder) {
             return is_file("{$initial_folder}/{$file}");
         });
         foreach ($files as $file) {
             if (preg_match('((.js|.css)$)i', $file)) {
                 IOHelper::copyFile("{$initial_folder}/{$file}", "{$config_folder}/{$file}");
             }
         }
     }
 }
开发者ID:imarc,项目名称:craft-betterredactor,代码行数:21,代码来源:BetterRedactorPlugin.php

示例2: _validateNewRequirements

 /**
  * @param string $unzipFolder
  *
  * @throws Exception
  * @return array
  */
 private function _validateNewRequirements($unzipFolder)
 {
     $requirementsFolderPath = $unzipFolder . '/app/etc/requirements/';
     $requirementsFile = $requirementsFolderPath . 'Requirements.php';
     $errors = array();
     if (!IOHelper::fileExists($requirementsFile)) {
         throw new Exception(Craft::t('The Requirements file is required and it does not exist at {path}.', array('path' => $requirementsFile)));
     }
     // Make sure we can write to craft/app/requirements
     if (!IOHelper::isWritable(craft()->path->getAppPath() . 'etc/requirements/')) {
         throw new Exception(StringHelper::parseMarkdown(Craft::t('Craft CMS needs to be able to write to your craft/app/etc/requirements folder and cannot. Please check your [permissions]({url}).', array('url' => 'http://craftcms.com/docs/updating#one-click-updating'))));
     }
     $tempFileName = StringHelper::UUID() . '.php';
     // Make a dupe of the requirements file and give it a random file name.
     IOHelper::copyFile($requirementsFile, $requirementsFolderPath . $tempFileName);
     $newTempFilePath = craft()->path->getAppPath() . 'etc/requirements/' . $tempFileName;
     // Copy the random file name requirements to the requirements folder.
     // We don't want to execute any PHP from the storage folder.
     IOHelper::copyFile($requirementsFolderPath . $tempFileName, $newTempFilePath);
     require_once $newTempFilePath;
     $checker = new RequirementsChecker();
     $checker->run();
     if ($checker->getResult() == RequirementResult::Failed) {
         foreach ($checker->getRequirements() as $requirement) {
             if ($requirement->getResult() == InstallStatus::Failed) {
                 Craft::log('Requirement "' . $requirement->getName() . '" failed with the message: ' . $requirement->getNotes(), LogLevel::Error, true);
                 $errors[] = $requirement->getNotes();
             }
         }
     }
     // Cleanup
     IOHelper::deleteFile($newTempFilePath);
     return $errors;
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:40,代码来源:Updater.php

示例3: copy

 /**
  * @param $destination
  *
  * @return bool
  */
 public function copy($destination)
 {
     if (!IOHelper::copyFile($this->getRealPath(), $destination)) {
         return false;
     }
     return true;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:12,代码来源:File.php

示例4: replaceFile

 /**
  * Replace physical file.
  *
  * @param AssetFileModel $oldFile     The assetFileModel representing the original file.
  * @param AssetFileModel $replaceWith The assetFileModel representing the new file.
  *
  * @return null
  */
 public function replaceFile(AssetFileModel $oldFile, AssetFileModel $replaceWith)
 {
     if ($oldFile->kind == 'image') {
         craft()->assetTransforms->deleteThumbnailsForFile($oldFile);
         $this->deleteSourceFile($oldFile->getFolder()->path . $oldFile->filename);
         $this->purgeCachedSourceFile($oldFile->getFolder(), $oldFile->filename);
         // For remote sources, fetch the source image and move it in the old ones place
         if (!$this->isSourceLocal()) {
             $localCopy = $this->getLocalCopy($replaceWith);
             if ($oldFile->kind == "image") {
                 IOHelper::copyFile($localCopy, craft()->path->getAssetsImageSourcePath() . $oldFile->id . '.' . IOHelper::getExtension($oldFile->filename));
             }
             IOHelper::deleteFile($localCopy);
         }
     }
     $this->moveSourceFile($replaceWith, craft()->assets->getFolderById($oldFile->folderId), $oldFile->filename, true);
     // Update file info
     $oldFile->width = $replaceWith->width;
     $oldFile->height = $replaceWith->height;
     $oldFile->size = $replaceWith->size;
     $oldFile->dateModified = $replaceWith->dateModified;
     craft()->assets->storeFile($oldFile);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:31,代码来源:BaseAssetSourceType.php

示例5: doFileUpdate

 /**
  * @param $manifestData
  * @param $sourceTempFolder
  * @param $handle
  *
  * @return bool
  */
 public static function doFileUpdate($manifestData, $sourceTempFolder, $handle)
 {
     if ($handle == 'craft') {
         $destDirectory = craft()->path->getAppPath();
         $sourceFileDirectory = 'app/';
     } else {
         $destDirectory = craft()->path->getPluginsPath() . $handle . '/';
         $sourceFileDirectory = '';
     }
     try {
         foreach ($manifestData as $row) {
             if (static::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $folder = false;
             $rowData = explode(';', $row);
             if (static::isManifestLineAFolder($rowData[0])) {
                 $folder = true;
                 $tempPath = static::cleanManifestFolderLine($rowData[0]);
             } else {
                 $tempPath = $rowData[0];
             }
             $destFile = IOHelper::normalizePathSeparators($destDirectory . $tempPath);
             $sourceFile = IOHelper::getRealPath(IOHelper::normalizePathSeparators($sourceTempFolder . '/' . $sourceFileDirectory . $tempPath));
             switch (trim($rowData[1])) {
                 // update the file
                 case PatchManifestFileAction::Add:
                     if ($folder) {
                         Craft::log('Updating folder: ' . $destFile, LogLevel::Info, true);
                         $tempFolder = rtrim($destFile, '/') . StringHelper::UUID() . '/';
                         $tempTempFolder = rtrim($destFile, '/') . '-tmp/';
                         IOHelper::createFolder($tempFolder);
                         IOHelper::copyFolder($sourceFile, $tempFolder);
                         IOHelper::rename($destFile, $tempTempFolder);
                         IOHelper::rename($tempFolder, $destFile);
                         IOHelper::clearFolder($tempTempFolder);
                         IOHelper::deleteFolder($tempTempFolder);
                     } else {
                         Craft::log('Updating file: ' . $destFile, LogLevel::Info, true);
                         IOHelper::copyFile($sourceFile, $destFile);
                     }
                     break;
             }
         }
     } catch (\Exception $e) {
         Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
         UpdateHelper::rollBackFileChanges($manifestData, $handle);
         return false;
     }
     return true;
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:58,代码来源:UpdateHelper.php

示例6: storeLocalSource

 /**
  * Store a local image copy to a destination path.
  *
  * @param $localCopy
  * @param $destination
  *
  * @return null
  */
 public function storeLocalSource($localCopy, $destination)
 {
     $maxCachedImageSize = $this->getCachedCloudImageSize();
     // Resize if constrained by maxCachedImageSizes setting
     if ($maxCachedImageSize > 0 && ImageHelper::isImageManipulatable($localCopy)) {
         craft()->images->loadImage($localCopy, $maxCachedImageSize, $maxCachedImageSize)->scaleToFit($maxCachedImageSize, $maxCachedImageSize)->setQuality(100)->saveAs($destination);
     } else {
         IOHelper::copyFile($localCopy, $destination);
     }
 }
开发者ID:JulesVan,项目名称:solutions-con,代码行数:18,代码来源:AssetTransformsService.php

示例7: replaceFile

 /**
  * Replace physical file.
  *
  * @param AssetFileModel $oldFile        The assetFileModel representing the original file.
  * @param AssetFileModel $replaceWith    The assetFileModel representing the new file.
  * @param string         $filenameToUse  The filename to use for the replaced file. If left
  *                                       empty, will use the name of the new file.
  *
  * @return null
  */
 public function replaceFile(AssetFileModel $oldFile, AssetFileModel $replaceWith, $filenameToUse = "")
 {
     if ($oldFile->kind == 'image') {
         craft()->assetTransforms->deleteAllTransformData($oldFile);
         $this->deleteSourceFile($oldFile->getFolder()->path . $oldFile->filename);
         $this->purgeCachedSourceFile($oldFile->getFolder(), $oldFile->filename);
         // For remote sources, fetch the source image and move it in the old ones place
         if (!$this->isSourceLocal()) {
             if ($replaceWith->kind == 'image') {
                 $localCopy = $replaceWith->getTransformSource();
                 IOHelper::copyFile($localCopy, craft()->path->getAssetsImageSourcePath() . $oldFile->id . '.' . IOHelper::getExtension($oldFile->filename));
             }
         }
     }
     $newFileName = !empty($filenameToUse) ? $filenameToUse : $oldFile->filename;
     $folder = craft()->assets->getFolderById($oldFile->folderId);
     $filenameChanges = StringHelper::toLowerCase($newFileName) != StringHelper::toLowerCase($replaceWith->filename);
     // If the filename does not change, this can trigger errors in some source types.
     if ($filenameChanges) {
         $this->moveSourceFile($replaceWith, $folder, $newFileName, true);
     }
     // Update file info
     $oldFile->width = $replaceWith->width;
     $oldFile->height = $replaceWith->height;
     $oldFile->size = $replaceWith->size;
     $oldFile->kind = $replaceWith->kind;
     $oldFile->dateModified = $replaceWith->dateModified;
     $oldFile->filename = $newFileName;
     if (empty($filenameToUse)) {
         $replaceWith->filename = $this->getNameReplacement($folder, $replaceWith->filename);
         craft()->assets->storeFile($replaceWith);
     } else {
         // If the file name has not changed, we're reusing the source file,
         // so we have to prevent deletion of source file here.
         craft()->assets->deleteFiles($replaceWith->id, $filenameChanges);
     }
     craft()->assets->storeFile($oldFile);
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:48,代码来源:BaseAssetSourceType.php

示例8: copySourceFile

 /**
  * @inheritDoc BaseAssetSourceType::copySourceFile()
  *
  * @param string $sourceUri
  * @param string $targetUri
  *
  * @return bool
  */
 protected function copySourceFile($sourceUri, $targetUri)
 {
     if ($sourceUri == $targetUri) {
         return true;
     }
     return IOHelper::copyFile($this->getSourceFileSystemPath() . $sourceUri, $this->getSourceFileSystemPath() . $targetUri, true);
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:15,代码来源:LocalAssetSourceType.php

示例9: _backupFiles

 /**
  * Attempt to backup each of the update manifest files by copying them to a file with the same name with a .bak extension.
  * If there is an exception thrown, we attempt to roll back all of the changes.
  *
  * @access private
  * @param $unzipFolder
  * @return bool
  */
 private function _backupFiles($unzipFolder)
 {
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     try {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             // No need to back up migration files.
             if (UpdateHelper::isManifestMigrationLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             $filePath = IOHelper::normalizePathSeparators(craft()->path->getAppPath() . $rowData[0]);
             // It's a folder
             if (UpdateHelper::isManifestLineAFolder($filePath)) {
                 $folderPath = UpdateHelper::cleanManifestFolderLine($filePath);
                 if (IOHelper::folderExists($folderPath)) {
                     Craft::log('Backing up folder ' . $folderPath, LogLevel::Info, true);
                     IOHelper::createFolder($folderPath . '.bak');
                     IOHelper::copyFolder($folderPath . '/', $folderPath . '.bak/');
                 }
             } else {
                 // If the file doesn't exist, it's probably a new file.
                 if (IOHelper::fileExists($filePath)) {
                     Craft::log('Backing up file ' . $filePath, LogLevel::Info, true);
                     IOHelper::copyFile($filePath, $filePath . '.bak');
                 }
             }
         }
     } catch (\Exception $e) {
         Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
         UpdateHelper::rollBackFileChanges($manifestData);
         return false;
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:45,代码来源:Updater.php

示例10: copyTransform

 /**
  * Copy a transform for a file from source location to target location.
  *
  * @param AssetFileModel $file
  * @param $source
  * @param $target
  * @return mixed
  */
 public function copyTransform(AssetFileModel $file, $source, $target)
 {
     $fileFolder = $file->getFolder();
     $basePath = $this->_getSourceFileSystemPath() . $fileFolder->fullPath;
     IOHelper::copyFile($basePath . $source . '/' . $file->filename, $basePath . $target . '/' . $file->filename);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:14,代码来源:LocalAssetSourceType.php


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