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


PHP IOHelper::clearFolder方法代码示例

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


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

示例1: clear

 /**
  * @param bool $suppressErrors
  * @return bool
  */
 public function clear($suppressErrors = false)
 {
     if (!IOHelper::clearFolder($this->getRealPath(), $suppressErrors)) {
         return false;
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:11,代码来源:Folder.php

示例2: safeUp

 /**
  * Any migration code in here is wrapped inside of a transaction.
  *
  * @return bool
  */
 public function safeUp()
 {
     Craft::log('Clearing asset caches', LogLevel::Info, true);
     $path = craft()->path->getRuntimePath() . 'assets';
     IOHelper::clearFolder($path);
     Craft::log('Done clearing asset caches', LogLevel::Info, true);
     return true;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:13,代码来源:m151007_000000_clear_asset_caches.php

示例3: performAction

 /**
  * Performs the tool's action.
  *
  * @param array $params
  * @return array
  */
 public function performAction($params = array())
 {
     if (!isset($params['folders'])) {
         return;
     }
     $allFolders = array_keys($this->_getFolders());
     if ($params['folders'] == '*') {
         $folders = $allFolders;
     } else {
         $folders = $params['folders'];
     }
     foreach ($folders as $folder) {
         if (in_array($folder, $allFolders)) {
             $path = craft()->path->getRuntimePath() . $folder;
             IOHelper::clearFolder($path, true);
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:24,代码来源:ClearCachesTool.php

示例4: unzip

 /**
  * @param $srcZip
  * @param $destFolder
  *
  * @return bool
  */
 public static function unzip($srcZip, $destFolder)
 {
     craft()->config->maxPowerCaptain();
     if (IOHelper::fileExists($srcZip)) {
         if (IOHelper::getExtension($srcZip) == 'zip') {
             if (!IOHelper::folderExists($destFolder)) {
                 if (!IOHelper::createFolder($destFolder)) {
                     Craft::log('Tried to create the unzip destination folder, but could not: ' . $destFolder, LogLevel::Error);
                     return false;
                 }
             } else {
                 // If the destination folder exists and it has contents, clear them.
                 if (($conents = IOHelper::getFolderContents($destFolder)) !== false) {
                     // Begin the great purge.
                     if (!IOHelper::clearFolder($destFolder)) {
                         Craft::log('Tried to clear the contents of the unzip destination folder, but could not: ' . $destFolder, LogLevel::Error);
                         return false;
                     }
                 }
             }
             $zip = static::_getZipInstance($srcZip);
             $result = $zip->unzip($srcZip, $destFolder);
             if ($result === true) {
                 return $result;
             } else {
                 Craft::log('There was an error unzipping the file: ' . $srcZip, LogLevel::Error);
                 return false;
             }
         } else {
             Craft::log($srcZip . ' is not a zip file and cannot be unzipped.', LogLevel::Error);
             return false;
         }
     } else {
         Craft::log('Unzipping is only available for files.', LogLevel::Error);
         return false;
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:43,代码来源:Zip.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: actionDeleteSiteImage

 /**
  * Delete logo.
  *
  * @return null
  */
 public function actionDeleteSiteImage()
 {
     $this->requireAdmin();
     $type = craft()->request->getRequiredPost('type');
     if (!in_array($type, $this->_allowedTypes)) {
         $this->returnErrorJson(Craft::t('That is not a legal site image type.'));
     }
     IOHelper::clearFolder(craft()->path->getRebrandPath() . $type . '/');
     $html = craft()->templates->render('settings/general/_images/' . $type);
     $this->returnJson(array('html' => $html));
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:16,代码来源:RebrandController.php

示例7: flushUpdateInfoFromCache

 /**
  * @return bool
  */
 public function flushUpdateInfoFromCache()
 {
     Craft::log('Flushing update info from cache.', LogLevel::Info, true);
     if (IOHelper::clearFolder(craft()->path->getCompiledTemplatesPath(), true) && IOHelper::clearFolder(craft()->path->getCachePath(), true)) {
         return true;
     }
     return false;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:11,代码来源:UpdatesService.php

示例8: actionCropUserPhoto

 /**
  * Crop user photo.
  *
  * @return null
  */
 public function actionCropUserPhoto()
 {
     $this->requireAjaxRequest();
     craft()->userSession->requireLogin();
     $userId = craft()->request->getRequiredPost('userId');
     if ($userId != craft()->userSession->getUser()->id) {
         craft()->userSession->requirePermission('editUsers');
     }
     try {
         $x1 = craft()->request->getRequiredPost('x1');
         $x2 = craft()->request->getRequiredPost('x2');
         $y1 = craft()->request->getRequiredPost('y1');
         $y2 = craft()->request->getRequiredPost('y2');
         $source = craft()->request->getRequiredPost('source');
         // Strip off any querystring info, if any.
         $source = UrlHelper::stripQueryString($source);
         $user = craft()->users->getUserById($userId);
         $userName = AssetsHelper::cleanAssetName($user->username, false);
         // make sure that this is this user's file
         $imagePath = craft()->path->getTempUploadsPath() . 'userphotos/' . $userName . '/' . $source;
         if (IOHelper::fileExists($imagePath) && craft()->images->checkMemoryForImage($imagePath)) {
             craft()->users->deleteUserPhoto($user);
             $image = craft()->images->loadImage($imagePath);
             $image->crop($x1, $x2, $y1, $y2);
             if (craft()->users->saveUserPhoto(IOHelper::getFileName($imagePath), $image, $user)) {
                 IOHelper::clearFolder(craft()->path->getTempUploadsPath() . 'userphotos/' . $userName);
                 $html = craft()->templates->render('users/_userphoto', array('account' => $user));
                 $this->returnJson(array('html' => $html));
             }
         }
         IOHelper::clearFolder(craft()->path->getTempUploadsPath() . 'userphotos/' . $userName);
     } catch (Exception $exception) {
         $this->returnErrorJson($exception->getMessage());
     }
     $this->returnErrorJson(Craft::t('Something went wrong when processing the photo.'));
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:41,代码来源:UsersController.php

示例9: _processUpdateLogic

 /**
  * @throws HttpException
  * @return null
  */
 private function _processUpdateLogic()
 {
     // Let all non-action CP requests through.
     if ($this->request->isCpRequest() && (!$this->request->isActionRequest() || $this->request->getActionSegments() == array('users', 'login'))) {
         // If this is a request to actually manually update Craft, do it
         if ($this->request->getSegment(1) == 'manualupdate') {
             $this->runController('templates/manualUpdate');
             $this->end();
         } else {
             if ($this->updates->isBreakpointUpdateNeeded()) {
                 throw new HttpException(200, Craft::t('You need to be on at least Craft CMS {url} before you can manually update to Craft CMS {targetVersion} build {targetBuild}.', array('url' => '[build ' . CRAFT_MIN_BUILD_REQUIRED . '](' . CRAFT_MIN_BUILD_URL . ')', 'targetVersion' => CRAFT_VERSION, 'targetBuild' => CRAFT_BUILD)));
             } else {
                 if (!$this->request->isAjaxRequest()) {
                     if ($this->request->getPathInfo() !== '') {
                         $this->userSession->setReturnUrl($this->request->getPath());
                     }
                 }
                 // Clear the template caches in case they've been compiled since this release was cut.
                 IOHelper::clearFolder($this->path->getCompiledTemplatesPath());
                 // Show the manual update notification template
                 $this->runController('templates/manualUpdateNotification');
             }
         }
     } else {
         if ($this->request->isActionRequest() && ($actionSegs = $this->request->getActionSegments()) !== null && isset($actionSegs[0]) && $actionSegs[0] == 'update') {
             $controller = $actionSegs[0];
             $action = isset($actionSegs[1]) ? $actionSegs[1] : 'index';
             $this->runController($controller . '/' . $action);
         } else {
             // If an exception gets throw during the rendering of the 503 template, let
             // TemplatesController->actionRenderError() take care of it.
             throw new HttpException(503);
         }
     }
     // <Gandalf> YOU SHALL NOT PASS!
     $this->end();
 }
开发者ID:vescoyez,项目名称:portfolio_v2,代码行数:41,代码来源:WebApp.php

示例10: performAction

 /**
  * Performs the tool's action.
  *
  * @param array $params
  *
  * @return null
  */
 public function performAction($params = array())
 {
     if (!isset($params['caches'])) {
         return;
     }
     $allFolderKeys = array_keys($this->_getFolders());
     if ($params['caches'] == '*') {
         $folders = $allFolderKeys;
     } else {
         $folders = array();
         foreach ($params['caches'] as $cacheKey) {
             if (in_array($cacheKey, $allFolderKeys)) {
                 $folders[] = $cacheKey;
             }
         }
     }
     $allFolders = array_keys($this->_getFolders(false));
     foreach ($folders as $folder) {
         foreach ($allFolders as $allFolder) {
             if (md5($allFolder) == $folder) {
                 if ($allFolder == 'dataCache') {
                     craft()->cache->flush();
                 } else {
                     IOHelper::clearFolder($allFolder, true);
                     break;
                 }
             }
         }
     }
     if ($params['caches'] == '*' || in_array('templateCaches', $params['caches'])) {
         craft()->templateCache->deleteAllCaches();
     }
     if ($params['caches'] == '*' || in_array('assetTransformIndex', $params['caches'])) {
         craft()->db->createCommand()->truncateTable('assettransformindex');
     }
     if ($params['caches'] == '*' || in_array('assetIndexingData', $params['caches'])) {
         craft()->db->createCommand()->truncateTable('assetindexdata');
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:46,代码来源:ClearCachesTool.php

示例11: actionDeleteLogo

 /**
  * Delete logo.
  */
 public function actionDeleteLogo()
 {
     $this->requireAdmin();
     IOHelper::clearFolder(craft()->path->getStoragePath() . 'logo/');
     $html = craft()->templates->render('settings/general/_logo');
     $this->returnJson(array('html' => $html));
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:10,代码来源:RebrandController.php

示例12: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  */
 private function _cleanTempFiles($unzipFolder)
 {
     // Get rid of all the .bak files/folders.
     $baks = IOHelper::getFolderContents(craft()->path->getAppPath(), true, ".*\\.bak\$");
     foreach ($baks as $bak) {
         if (IOHelper::fileExists($bak)) {
             if (IOHelper::isWritable($bak)) {
                 Craft::log('Deleting .bak file: ' . $bak, LogLevel::Info, true);
                 IOHelper::deleteFile($bak, true);
             }
         } else {
             if (IOHelper::folderExists($bak)) {
                 if (IOHelper::isWritable($bak)) {
                     Craft::log('Deleting .bak folder:' . $bak, LogLevel::Info, true);
                     IOHelper::clearFolder($bak, true);
                     IOHelper::deleteFolder($bak, true);
                 }
             }
         }
     }
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             $folder = false;
             if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                 $folder = true;
                 $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
             } else {
                 $tempFilePath = $rowData[0];
             }
             $fullPath = '';
             switch (trim($rowData[1])) {
                 // If the file/folder was set to be deleted, there is no backup and we go ahead and remove it now.
                 case PatchManifestFileAction::Remove:
                     if ($tempFilePath == '') {
                         $fullPath = IOHelper::normalizePathSeparators(craft()->path->getAppPath());
                     } else {
                         $fullPath = IOHelper::normalizePathSeparators(craft()->path->getAppPath() . $tempFilePath);
                     }
                     break;
             }
             // Delete any files/folders we backed up.
             if ($folder) {
                 if (($folder = IOHelper::getFolder($fullPath)) !== false) {
                     Craft::log('Deleting folder: ' . $folder->getRealPath(), LogLevel::Info, true);
                     $folder->delete();
                 }
             } else {
                 if (($file = IOHelper::getFile($fullPath)) !== false) {
                     Craft::log('Deleting file: ' . $file->getRealPath(), LogLevel::Info, true);
                     $file->delete();
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:66,代码来源:Updater.php

示例13: actionSendSupportRequest


//.........这里部分代码省略.........
             if (!IOHelper::folderExists($tempFolder)) {
                 IOHelper::createFolder($tempFolder);
             }
             //
             // Attached just the Feed Me log
             //
             if ($getHelpModel->attachLogs) {
                 if (IOHelper::folderExists(craft()->path->getLogPath())) {
                     $logFolderContents = IOHelper::getFolderContents(craft()->path->getLogPath());
                     foreach ($logFolderContents as $file) {
                         // Just grab the Feed Me log
                         if (IOHelper::fileExists($file) && basename($file) == 'feedme.log') {
                             Zip::add($zipFile, $file, craft()->path->getStoragePath());
                         }
                     }
                 }
             }
             //
             // Backup our feed settings
             //
             if ($getHelpModel->attachSettings) {
                 if (IOHelper::folderExists(craft()->path->getDbBackupPath())) {
                     $backup = craft()->path->getDbBackupPath() . StringHelper::toLowerCase('feedme_' . gmdate('ymd_His') . '.sql');
                     $feedInfo = $this->_prepareSqlFeedSettings($getHelpModel->feedIssue);
                     IOHelper::writeToFile($backup, $feedInfo . PHP_EOL, true, true);
                     Zip::add($zipFile, $backup, craft()->path->getStoragePath());
                 }
             }
             //
             // Save the contents of the feed
             //
             if ($getHelpModel->attachFeed) {
                 $feedData = craft()->feedMe_feed->getRawData($feed->feedUrl);
                 $tempFile = $tempFolder . 'feed.' . StringHelper::toLowerCase($feed->feedType);
                 IOHelper::writeToFile($tempFile, $feedData . PHP_EOL, true, true);
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
             //
             // Get some information about the fields we're mapping to - handy to know
             //
             if ($getHelpModel->attachFields) {
                 $fieldInfo = array();
                 foreach ($feed->fieldMapping as $feedHandle => $fieldHandle) {
                     $field = craft()->fields->getFieldByHandle($fieldHandle);
                     if ($field) {
                         $fieldInfo[] = $this->_prepareExportField($field);
                     }
                 }
                 // Support PHP <5.4, JSON_PRETTY_PRINT = 128, JSON_NUMERIC_CHECK = 32
                 $json = json_encode($fieldInfo, 128 | 32);
                 $tempFile = $tempFolder . 'fields.json';
                 IOHelper::writeToFile($tempFile, $json . PHP_EOL, true, true);
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
             //
             // Add in any additional attachments
             //
             if ($getHelpModel->attachment) {
                 $tempFile = $tempFolder . $getHelpModel->attachment->getName();
                 $getHelpModel->attachment->saveAs($tempFile);
                 // Make sure it actually saved.
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
         } catch (\Exception $e) {
             FeedMePlugin::log('Tried to attach debug logs to a support request and something went horribly wrong: ' . $e->getMessage(), LogLevel::Warning, true);
         }
         $email = new EmailModel();
         $email->fromEmail = $getHelpModel->fromEmail;
         $email->toEmail = "web@sgroup.com.au";
         $email->subject = "Feed Me Support";
         $email->body = $message;
         if ($zipFile) {
             $email->addAttachment($zipFile, 'FeedMeSupportAttachment.zip', 'base64', 'application/zip');
         }
         $result = craft()->email->sendEmail($email);
         if ($result) {
             if ($zipFile) {
                 if (IOHelper::fileExists($zipFile)) {
                     IOHelper::deleteFile($zipFile);
                 }
             }
             if ($tempFolder) {
                 IOHelper::clearFolder($tempFolder);
                 IOHelper::deleteFolder($tempFolder);
             }
             $success = true;
         } else {
             $errors = array('Support' => array('Unable to contact support. Please try again soon.'));
         }
     } else {
         $errors = $getHelpModel->getErrors();
     }
     $this->returnJson(array('success' => $success, 'errors' => $errors));
 }
开发者ID:EP-NY,项目名称:FeedMe,代码行数:101,代码来源:FeedMe_SupportController.php

示例14: safeUp

 /**
  * Any migration code in here is wrapped inside of a transaction.
  *
  * @return bool
  */
 public function safeUp()
 {
     IOHelper::clearFolder(craft()->path->getCompiledTemplatesPath(), true);
     return true;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:10,代码来源:m140401_100002_delete_compiled_templates.php

示例15: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  *
  * @param string $unzipFolder
  *
  * @return null
  */
 private function _cleanTempFiles($unzipFolder)
 {
     $appPath = craft()->path->getAppPath();
     // Get rid of all the .bak files/folders.
     $filesToDelete = IOHelper::getFolderContents($appPath, true, ".*\\.bak\$");
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             if ($rowData[1] == PatchManifestFileAction::Remove) {
                 if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                     $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
                 } else {
                     $tempFilePath = $rowData[0];
                 }
                 $filesToDelete[] = $appPath . $tempFilePath;
             }
         }
         foreach ($filesToDelete as $fileToDelete) {
             if (IOHelper::fileExists($fileToDelete)) {
                 if (IOHelper::isWritable($fileToDelete)) {
                     Craft::log('Deleting file: ' . $fileToDelete, LogLevel::Info, true);
                     IOHelper::deleteFile($fileToDelete, true);
                 }
             } else {
                 if (IOHelper::folderExists($fileToDelete)) {
                     if (IOHelper::isWritable($fileToDelete)) {
                         Craft::log('Deleting .bak folder:' . $fileToDelete, LogLevel::Info, true);
                         IOHelper::clearFolder($fileToDelete, true);
                         IOHelper::deleteFolder($fileToDelete, true);
                     }
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:49,代码来源:Updater.php


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