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


PHP Filesystem::deleteDirectory方法代码示例

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


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

示例1: clear

 /**
  * Clear all Cache
  *
  * @museDescription  Clears all cached items in document root cache directory
  *
  * @return  void
  */
 public function clear()
 {
     // Path to cache folder
     $cacheDir = PATH_APP . DS . 'cache' . DS . '*';
     // Remove recursively
     foreach (glob($cacheDir) as $cacheFileOrDir) {
         $readable = str_replace(PATH_APP . DS, '', $cacheFileOrDir);
         if (is_dir($cacheFileOrDir)) {
             if (!Filesystem::deleteDirectory($cacheFileOrDir)) {
                 $this->output->addLine('Unable to delete cache directory: ' . $readable, 'error');
             } else {
                 $this->output->addLine($readable . ' deleted', 'success');
             }
         } else {
             // Don't delete index.html
             if ($cacheFileOrDir != PATH_APP . DS . 'cache' . DS . 'index.html') {
                 if (!Filesystem::delete($cacheFileOrDir)) {
                     $this->output->addLine('Unable to delete cache file: ' . $readable, 'error');
                 } else {
                     $this->output->addLine($readable . ' deleted', 'success');
                 }
             }
         }
     }
     $this->output->addLine('Clear cache complete', 'success');
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:33,代码来源:Cache.php

示例2: postInstall

 /**
  * Run composer post-install script
  * 
  * @param  Event  $event
  * @return void
  */
 public static function postInstall(Event $event)
 {
     static::init();
     $event->getIO()->write('<info>Writing resources.lock file</info>');
     $installed = json_decode(file_get_contents(static::$vendorPath . '/composer/installed.json'));
     $data = [];
     $finder = (new Finder())->directories()->ignoreVCS(true)->in(static::$resourcesPath . '/packages');
     foreach ($installed as $package) {
         if (!property_exists($package, 'extra')) {
             continue;
         }
         $extra = $package->extra;
         if (!property_exists($extra, 'resources')) {
             continue;
         }
         $resources = $extra->resources;
         foreach ($resources as $resource => $namespaces) {
             foreach ($namespaces as $namespace => $path) {
                 $finder->exclude($namespace);
                 $data[$resource][$namespace] = $path;
             }
         }
     }
     // We turn the iterator to an array to
     // prevent an exception when we delete the directorys
     foreach (iterator_to_array($finder) as $file) {
         \Filesystem::deleteDirectory($file->getPathname());
     }
     file_put_contents(static::$resourcesPath . '/resources.lock', json_encode($data, JSON_PRETTY_PRINT));
 }
开发者ID:encorephp,项目名称:kernel,代码行数:36,代码来源:Script.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire()
 {
     $cachePath = config('jms.cache');
     if (count($filesystem->allFiles($cachePath))) {
         \Filesystem::deleteDirectory($cachePath);
         $this->info('JMS cache cleared!');
     }
 }
开发者ID:izziaraffaele,项目名称:laravel-jms,代码行数:13,代码来源:CacheClearCommand.php

示例4: cleanup

 /**
  * Method to delete tmp folder
  *
  * @return	boolean   true if delete successful, false otherwise
  * @since	2.5
  */
 public function cleanup()
 {
     // Clear installation messages
     User::setState('com_installer.message', '');
     User::setState('com_installer.extension_message', '');
     // Delete temporary directory
     return Filesystem::deleteDirectory($this->getState('to_path'));
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:14,代码来源:template.php

示例5: removeTask

 /**
  * Removes a resource
  * Redirects to main listing
  *
  * @return     void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array(0));
     // Ensure we have some IDs to work with
     if (count($ids) < 1) {
         $this->setMessage(Lang::txt('COM_RESOURCES_NO_ITEM_SELECTED'));
         return $this->cancelTask();
     }
     foreach ($ids as $id) {
         // Load resource info
         $row = new Resource($this->database);
         $row->load($id);
         // Get path and delete directories
         if ($row->path != '') {
             $listdir = $row->path;
         } else {
             // No stored path, derive from created date
             $listdir = Html::build_path($row->created, $id, '');
         }
         // Build the path
         $path = Utilities::buildUploadPath($listdir, '');
         $base = PATH_APP . '/' . trim($this->config->get('webpath', '/site/resources'), '/');
         $baseY = $base . '/' . Date::of($row->created)->format("Y");
         $baseM = $baseY . '/' . Date::of($row->created)->format("m");
         // Check if the folder even exists
         if (!is_dir($path) or !$path) {
             $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND'));
         } else {
             if ($path == $base || $path == $baseY || $path == $baseM) {
                 $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND'));
             } else {
                 // Attempt to delete the folder
                 if (!\Filesystem::deleteDirectory($path)) {
                     $this->setError(Lang::txt('COM_RESOURCES_ERROR_UNABLE_TO_DELETE_DIRECTORY'));
                 }
             }
         }
         // Delete associations to the resource
         $row->deleteExistence();
         // Delete the resource
         $row->delete();
     }
     $pid = Request::getInt('pid', 0);
     // Redirect
     App::redirect($this->buildRedirectURL($pid));
 }
开发者ID:zooley,项目名称:hubzero-cms,代码行数:55,代码来源:items.php

示例6: _prepDir

 /**
  * Prep file directory (provisioned project)
  *
  * @param      boolean		$force
  *
  * @return     boolean
  */
 protected function _prepDir($force = true)
 {
     if (!$this->model->exists()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Get member files path
     $memberPath = $this->_getMemberPath();
     // Create and initialize local repo
     if (!$this->model->repo()->iniLocal()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Copy files from member directory
     if (!Filesystem::copyDirectory($memberPath, $this->model->repo()->get('path'))) {
         $this->setError(Lang::txt('COM_PROJECTS_FAILED_TO_COPY_FILES'));
         return false;
     }
     // Read copied files
     $get = Filesystem::files($this->model->repo()->get('path'));
     $num = count($get);
     $checkedin = 0;
     // Check-in copied files
     if ($get) {
         foreach ($get as $file) {
             $file = str_replace($this->model->repo()->get('path') . DS, '', $file);
             if (is_file($this->model->repo()->get('path') . DS . $file)) {
                 // Checkin into repo
                 $this->model->repo()->call('checkin', array('file' => $this->model->repo()->getMetadata($file, 'file', array())));
                 $checkedin++;
             }
         }
     }
     if ($num == $checkedin) {
         // Clean up member files
         Filesystem::deleteDirectory($memberPath);
         return true;
     }
     return false;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:47,代码来源:publications.php

示例7: deleteAllForTicket

 /**
  * Delete all records based on ticket number
  *
  * @param   integer  $ticket  Ticket ID
  * @return  boolean  True on success
  */
 public function deleteAllForTicket($ticket)
 {
     $this->_db->setQuery("DELETE FROM {$this->_tbl} WHERE ticket=" . $this->_db->quote($ticket));
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $config = Component::params('com_support');
     $path = PATH_APP . DS . trim($config->get('webpath', '/site/tickets'), DS) . DS . $ticket;
     if (is_dir($path)) {
         if (!\Filesystem::deleteDirectory($path)) {
             $this->setError(Lang::txt('Unable to delete path'));
             return false;
         }
     }
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:23,代码来源:attachment.php

示例8: activateTask


//.........这里部分代码省略.........
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
         return;
     }
     // Must be project creator
     if (!$this->model->access('owner')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Must be a provisioned project to be activated
     if (!$this->model->isProvisioned()) {
         // Redirect to project page
         App::redirect(Route::url($this->model->link()));
         return;
     }
     // Redirect to setup if activation not complete
     if ($this->model->inSetup()) {
         App::redirect(Route::url($this->model->link('setup')));
         return;
     }
     // Get publication of a provisioned project
     $pub = $this->model->getPublication();
     if (empty($pub)) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
         return;
     }
     // Incoming
     $name = trim(Request::getVar('new-alias', '', 'post'));
     $title = trim(Request::getVar('title', '', 'post'));
     $confirm = trim(Request::getInt('confirm', 0, 'post'));
     $name = preg_replace('/ /', '', $name);
     $name = strtolower($name);
     // Check incoming data
     $verified = $this->model->check($name, $this->model->get('id'));
     if ($confirm && !$verified) {
         $error = $this->model->getError() ? $this->model->getError() : Lang::txt('COM_PROJECTS_ERROR_NAME_INVALID_OR_EMPTY');
         $this->setError($error);
     } elseif ($confirm && ($title == '' || strlen($title) < 3)) {
         $this->setError(Lang::txt('COM_PROJECTS_ERROR_TITLE_SHORT_OR_EMPTY'));
     }
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     // Display page
     if (!$confirm || $this->getError()) {
         $this->view->setLayout('provisioned');
         $this->view->model = $this->model;
         $this->view->team = $this->model->_tblOwner->getOwnerNames($this->model->get('alias'));
         // Output HTML
         $this->view->pub = isset($pub) ? $pub : '';
         $this->view->suggested = $name;
         $this->view->verified = $verified;
         $this->view->suggested = $verified ? $this->view->suggested : '';
         $this->view->title = $this->title;
         $this->view->active = $this->active;
         $this->view->task = $this->_task;
         $this->view->authorized = 1;
         $this->view->option = $this->_option;
         $this->view->msg = $this->_getNotifications('success');
         if ($this->getError()) {
             $this->view->setError($this->getError());
         }
         $this->view->display();
         return;
     }
     // Save new alias & title
     if (!$this->getError()) {
         $this->model->set('title', \Hubzero\Utility\String::truncate($title, 250));
         $this->model->set('alias', $name);
         $state = $this->_setupComplete == 3 ? 0 : 1;
         $this->model->set('state', $state);
         $this->model->set('setup_stage', 2);
         $this->model->set('provisioned', 0);
         $this->model->set('modified', Date::toSql());
         $this->model->set('modified_by', User::get('id'));
         // Save changes
         if (!$this->model->store()) {
             $this->setError($this->model->getError());
         }
     }
     // Get project parent directory
     $path = Helpers\Html::getProjectRepoPath($this->model->get('alias'));
     $newpath = Helpers\Html::getProjectRepoPath($name, 'files', true);
     // Rename project parent directory
     if ($path && is_dir($path)) {
         if (!Filesystem::copyDirectory($path, $newpath)) {
             $this->setError(Lang::txt('COM_PROJECTS_FAILED_TO_COPY_FILES'));
         } else {
             // Correct permissions to 0755
             Filesystem::setPermissions($newpath);
             // Delete original repo
             Filesystem::deleteDirectory($path);
         }
     }
     // Log activity
     $this->_logActivity($this->model->get('id'), 'provisioned', 'activate', 'save', 1);
     // Send to continue setup
     App::redirect(Route::url($this->model->link('setup')));
     return;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:projects.php

示例9: deleteDirectory

 /**
  * Delete dir
  *
  * @param      array	$params
  *
  * @return     array
  */
 public function deleteDirectory($params = array())
 {
     $file = isset($params['file']) ? $params['file'] : NULL;
     $author = isset($params['author']) ? $params['author'] : NULL;
     $date = isset($params['date']) ? $params['date'] : NULL;
     if (!$file instanceof Models\File || $file->get('type') != 'folder') {
         return false;
     }
     // Delete from Git
     $this->_git->gitDelete($file->get('localPath'), 'folder', $commitMsg);
     $this->_git->gitCommit($commitMsg, $author, $date);
     if (!$this->get('remote') && file_exists($file->get('fullPath'))) {
         // Remove directory that is not in Git
         if (!Filesystem::deleteDirectory($file->get('fullPath'))) {
             return false;
         }
     }
     return true;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:26,代码来源:git.php

示例10: _saveChildData

 /**
  * Save Child Resources
  *
  * @return void
  */
 private function _saveChildData()
 {
     // if we updating we want to completely replace
     if ($this->_mode == 'UPDATE' && isset($this->record->resource->id)) {
         // remove any existing files
         $children = $this->record->resource->getItemChildren(array('parent_id' => $this->record->resource->id));
         foreach ($children as $child) {
             $rconfig = \Component::params('com_resources');
             $base = PATH_APP . DS . trim($rconfig->get('uploadpath', '/site/resources'), DS);
             $file = $base . DS . $child->path;
             //get file info
             $info = pathinfo($file);
             $directory = $info['dirname'];
             if ($child->type == 13 && file_exists($file)) {
                 \Filesystem::delete($file);
             }
             if (is_dir($directory)) {
                 // get iterator on direcotry
                 $iterator = new \FilesystemIterator($directory);
                 $isDirEmpty = !$iterator->valid();
                 // remove directory if empty
                 if ($isDirEmpty) {
                     \Filesystem::deleteDirectory($directory);
                 }
             }
         }
         // delete all child resources
         $sql = "DELETE FROM `#__resources` WHERE `id` IN (\n\t\t\t\t\t\tSELECT child_id FROM `#__resource_assoc` WHERE `parent_id`=" . $this->_database->quote($this->record->resource->id) . ")";
         $this->_database->setQuery($sql);
         $this->_database->query();
         // delete all child resource associations
         $sql = "DELETE FROM `#__resource_assoc` WHERE `parent_id`=" . $this->_database->quote($this->record->resource->id);
         $this->_database->setQuery($sql);
         $this->_database->query();
     }
     // loop through each child
     foreach ($this->record->children as $child) {
         // save child
         if (!$child->store()) {
             throw new Exception(Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_UNABLE_SAVECHILD'));
         }
         // create parent - child association
         $assoc = new Tables\Assoc($this->_database);
         $assoc->ordering = $assoc->getLastOrder($this->record->resource->id);
         $assoc->ordering = $assoc->ordering ? $assoc->ordering : 0;
         $assoc->ordering++;
         $assoc->parent_id = $this->record->resource->id;
         $assoc->child_id = $child->id;
         $assoc->grouping = 0;
         if (!$assoc->store(true)) {
             throw new Exception(Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_UNABLE_SAVECHILDASSOC'));
         }
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:59,代码来源:record.php

示例11: deletefolderTask

 /**
  * Delete a folder and contents
  *
  * @return  void
  */
 public function deletefolderTask()
 {
     // Check for request forgeries
     Request::checkToken('get');
     // Incoming directory (this should be a path built from a resource ID and its creation year/month)
     $listdir = Request::getVar('listdir', '');
     if (!$listdir) {
         $this->setError(Lang::txt('COM_RESOURCES_ERROR_NO_LISTDIR'));
         $this->displayTask();
         return;
     }
     // Make sure the listdir follows YYYY/MM/#
     $parts = explode('/', $listdir);
     if (count($parts) < 3) {
         $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND'));
         $this->displayTask();
         return;
     }
     // Incoming sub-directory
     $subdir = Request::getVar('subdir', '');
     // Build the path
     $path = Utilities::buildUploadPath($listdir, $subdir);
     // Incoming directory to delete
     $folder = Request::getVar('delFolder', '');
     if (!$folder) {
         $this->setError(Lang::txt('COM_RESOURCES_ERROR_NO_DIRECTORY'));
         $this->displayTask();
         return;
     }
     $folder = Utilities::normalizePath($folder);
     // Check if the folder even exists
     if (!is_dir($path . $folder) or !$folder) {
         $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND'));
     } else {
         // Attempt to delete the file
         if (!\Filesystem::deleteDirectory($path . $folder)) {
             $this->setError(Lang::txt('COM_RESOURCES_ERROR_UNABLE_TO_DELETE_DIRECTORY'));
         }
     }
     // Push through to the media view
     $this->displayTask();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:47,代码来源:media.php

示例12: _addFromExtracted

 /**
  * Add files to repo from extracted archive
  *
  * @return  boolean
  */
 protected function _addFromExtracted($extractPath, $zipName, $target, $params, &$available)
 {
     $reserved = isset($params['reserved']) ? $params['reserved'] : array();
     $dirPath = isset($params['subdir']) ? $params['subdir'] : NULL;
     $extracted = Filesystem::files($extractPath, '.', true, true, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'));
     // check for viruses - scans the directory for efficency
     $command = "clamscan -i --no-summary --block-encrypted -r " . $extractPath;
     exec($command, $output, $virus_status);
     $virusChecked = FALSE;
     if ($virus_status == 0) {
         $virusChecked = TRUE;
     } else {
         Filesystem::deleteDirectory($extractPath);
         $this->setError('The antivirus software has rejected your files.');
         return false;
     }
     $z = 0;
     foreach ($extracted as $e) {
         $fileinfo = pathinfo($e);
         $a_dir = $fileinfo['dirname'];
         $a_dir = str_replace($extractPath . DS, '', $a_dir);
         // Skip certain system files
         if (preg_match("/__MACOSX/", $e) or preg_match("/.DS_Store/", $e)) {
             continue;
         }
         $file = $fileinfo['basename'];
         $size = filesize($e);
         // Run some checks, stop in case of a problem
         if (!$this->_check($file, $e, $size, $available, $virusChecked)) {
             return false;
         }
         // Clean up filename
         $safe_dir = $a_dir && $a_dir != '.' ? Filesystem::cleanPath($a_dir) : '';
         $safe_dir = trim($safe_dir, DS);
         $safe_file = Filesystem::clean($file);
         // Strips out temporary path
         if (strpos($safe_dir, 'tmp/') !== FALSE) {
             $parts = explode('/', $safe_dir);
             $safe_dir = str_replace($parts[0] . '/', '', $safe_dir);
             $safe_dir = str_replace($parts[1] . '/', '', $safe_dir);
         }
         $skipDir = false;
         if (is_array($reserved) && $safe_dir && in_array(strtolower($safe_dir), $reserved)) {
             $skipDir = true;
         }
         $safeName = $safe_dir && !$skipDir ? $safe_dir . DS . $safe_file : $safe_file;
         $localPath = $dirPath ? $dirPath . DS . $safeName : $safeName;
         $where = $target . DS . $safeName;
         $exists = is_file($where) ? true : false;
         // Provision directory
         if ($safe_dir && !$skipDir && !is_dir($target . DS . $safe_dir)) {
             if (Filesystem::makeDirectory($target . DS . $safe_dir, 0755, true, true)) {
                 // File object
                 $localDirPath = $dirPath ? $dirPath . DS . $safe_dir : $safe_dir;
                 $fileObject = new Models\File(trim($localDirPath), $this->get('path'));
                 $fileObject->set('type', 'folder');
                 $params['file'] = $fileObject;
                 $params['replace'] = false;
                 // Success - check in change
                 $this->call('checkin', $params);
                 $z++;
             }
         }
         // Strips out temporary path
         if (strpos($safeName, 'tmp/') !== FALSE) {
             $parts = explode('/', $safeName);
             $safeName = str_replace($parts[0] . '/', '', $safeName);
             $safeName = str_replace($parts[1] . '/', '', $safeName);
         }
         // Copy file into project
         if (Filesystem::copy($e, $target . DS . $safeName)) {
             // File object
             $fileObject = new Models\File(trim($localPath), $this->get('path'));
             $params['file'] = $fileObject;
             $params['replace'] = $exists;
             // Success - check in change
             $this->call('checkin', $params);
             $z++;
         }
     }
     return $z;
 }
开发者ID:digideskio,项目名称:hubzero-cms,代码行数:87,代码来源:repo.php

示例13: delete

 /**
  * Delete a record
  *
  * @return  boolean True on success, false on error
  */
 public function delete()
 {
     // Remove authors
     foreach ($this->authors() as $author) {
         if (!$author->delete()) {
             $this->setError($author->getError());
             return false;
         }
     }
     // Remove comments
     foreach ($this->comments() as $comment) {
         if (!$comment->delete()) {
             $this->setError($comment->getError());
             return false;
         }
     }
     // Remove revisions
     foreach ($this->revisions() as $revision) {
         if (!$revision->delete()) {
             $this->setError($revision->getError());
             return false;
         }
     }
     // Remove tags
     $this->tag('');
     // Remove files
     $path = PATH_APP . DS . trim($this->config('filepath', '/site/wiki'), DS);
     if (is_dir($path . DS . $this->get('id'))) {
         if (!\Filesystem::deleteDirectory($path . DS . $this->get('id'))) {
             $this->setError(Lang::txt('COM_WIKI_UNABLE_TO_DELETE_FOLDER'));
         }
     }
     // Remove record from the database
     if (!$this->_tbl->delete()) {
         $this->setError($this->_tbl->getError());
         return false;
     }
     $this->log('page_deleted');
     // Clear cached data
     \Cache::clean('wiki');
     // Hey, no errors!
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:48,代码来源:page.php

示例14: deleteVersionExistence

 /**
  * Deletes assoc with pub version
  *
  * @param   integer  $vid
  * @param   integer  $pid
  * @return  void
  */
 public function deleteVersionExistence($vid, $pid)
 {
     // Delete authors
     $pa = new Tables\Author($this->database);
     $authors = $pa->deleteAssociations($vid);
     // Delete attachments
     $pContent = new Tables\Attachment($this->database);
     $pContent->deleteAttachments($vid);
     // Delete screenshots
     $pScreenshot = new Tables\Screenshot($this->database);
     $pScreenshot->deleteScreenshots($vid);
     // Delete access accosiations
     $pAccess = new Tables\Access($this->database);
     $pAccess->deleteGroups($vid);
     // Delete audience
     $pAudience = new Tables\Audience($this->database);
     $pAudience->deleteAudience($vid);
     // Build publication path
     $path = Helpers\Html::buildPubPath($pid, $vid, $this->config->get('webpath'), '', 1);
     // Delete all files
     if (is_dir($path)) {
         Filesystem::deleteDirectory($path);
     }
     return true;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:32,代码来源:items.php

示例15: delete

 /**
  * Deletes paths from the current path
  *
  * @since 1.5
  */
 public function delete()
 {
     Session::checkToken(['get', 'post']);
     // Get some data from the request
     $tmpl = Request::getCmd('tmpl');
     $paths = Request::getVar('rm', array(), '', 'array');
     $folder = Request::getVar('folder', '', '', 'path');
     $redirect = 'index.php?option=com_media&folder=' . $folder;
     if ($tmpl == 'component') {
         // We are inside the iframe
         $redirect .= '&view=mediaList&tmpl=component';
     }
     $this->setRedirect($redirect);
     // Nothing to delete
     if (empty($paths)) {
         return true;
     }
     // Authorize the user
     if (!$this->authoriseUser('delete')) {
         return false;
     }
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Initialise variables.
     $ret = true;
     foreach ($paths as $path) {
         if ($path !== Filesystem::clean($path)) {
             // filename is not safe
             $filename = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
             Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', substr($filename, strlen(COM_MEDIA_BASE))));
             continue;
         }
         $fullPath = Filesystem::cleanPath(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path)));
         $object_file = new \Hubzero\Base\Object(array('filepath' => $fullPath));
         if (is_file($fullPath)) {
             // Trigger the onContentBeforeDelete event.
             $result = Event::trigger('content.onContentBeforeDelete', array('com_media.file', &$object_file));
             if (in_array(false, $result, true)) {
                 // There are some errors in the plugins
                 Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                 continue;
             }
             $ret &= Filesystem::delete($fullPath);
             // Trigger the onContentAfterDelete event.
             Event::trigger('content.onContentAfterDelete', array('com_media.file', &$object_file));
             $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
         } elseif (is_dir($fullPath)) {
             $contents = Filesystem::files($fullPath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'));
             if (empty($contents)) {
                 // Trigger the onContentBeforeDelete event.
                 $result = Event::trigger('content.onContentBeforeDelete', array('com_media.folder', &$object_file));
                 if (in_array(false, $result, true)) {
                     // There are some errors in the plugins
                     Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                     continue;
                 }
                 $ret &= Filesystem::deleteDirectory($fullPath);
                 // Trigger the onContentAfterDelete event.
                 Event::trigger('content.onContentAfterDelete', array('com_media.folder', &$object_file));
                 $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
             } else {
                 // This makes no sense...
                 Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', substr($fullPath, strlen(COM_MEDIA_BASE))));
             }
         }
     }
     return $ret;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:73,代码来源:file.php


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