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


PHP file_unmanaged_delete函数代码示例

本文整理汇总了PHP中file_unmanaged_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP file_unmanaged_delete函数的具体用法?PHP file_unmanaged_delete怎么用?PHP file_unmanaged_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: black_lagoon_settings_submit

/**
 * Save settings data.
 */
function black_lagoon_settings_submit($form, &$form_state)
{
    $settings = array();
    // Update image field
    foreach ($form_state['input']['images'] as $image) {
        if (is_array($image)) {
            $image = $image['image'];
            if ($image['image_delete']) {
                // Delete banner file
                file_unmanaged_delete($image['image_path']);
                // Delete banner thumbnail file
                file_unmanaged_delete($image['image_thumb']);
            } else {
                // Update image
                $settings[] = $image;
            }
        }
    }
    // Check for a new uploaded file, and use that if available.
    if ($file = file_save_upload('image_upload')) {
        $file->status = FILE_STATUS_PERMANENT;
        if ($image = _black_lagoon_save_image($file)) {
            // Put new image into settings
            $settings[] = $image;
        }
    }
    // Save settings
    black_lagoon_set_banners($settings);
}
开发者ID:jcubed22,项目名称:Drupal_Space_Pirates,代码行数:32,代码来源:theme-settings.php

示例2: testFileRetrieving

 /**
  * Invokes system_retrieve_file() in several scenarios.
  */
 function testFileRetrieving()
 {
     // Test 404 handling by trying to fetch a randomly named file.
     drupal_mkdir($sourcedir = 'public://' . $this->randomMachineName());
     $filename = 'Файл для тестирования ' . $this->randomMachineName();
     $url = file_create_url($sourcedir . '/' . $filename);
     $retrieved_file = system_retrieve_file($url);
     $this->assertFalse($retrieved_file, 'Non-existent file not fetched.');
     // Actually create that file, download it via HTTP and test the returned path.
     file_put_contents($sourcedir . '/' . $filename, 'testing');
     $retrieved_file = system_retrieve_file($url);
     // URLs could not contains characters outside the ASCII set so $filename
     // has to be encoded.
     $encoded_filename = rawurlencode($filename);
     $this->assertEqual($retrieved_file, 'public://' . $encoded_filename, 'Sane path for downloaded file returned (public:// scheme).');
     $this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (public:// scheme).');
     $this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (public:// scheme).');
     file_unmanaged_delete($retrieved_file);
     // Test downloading file to a different location.
     drupal_mkdir($targetdir = 'temporary://' . $this->randomMachineName());
     $retrieved_file = system_retrieve_file($url, $targetdir);
     $this->assertEqual($retrieved_file, "{$targetdir}/{$encoded_filename}", 'Sane path for downloaded file returned (temporary:// scheme).');
     $this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (temporary:// scheme).');
     $this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (temporary:// scheme).');
     file_unmanaged_delete($retrieved_file);
     file_unmanaged_delete_recursive($sourcedir);
     file_unmanaged_delete_recursive($targetdir);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:RetrieveFileTest.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $messageHelper = $this->getHelperSet()->get('message');
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $config = $this->getConfigFactory()->get('system.file');
         $directory = $config->get('path.temporary') ?: file_directory_temp();
         $directory .= '/' . CONFIG_STAGING_DIRECTORY;
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     $config_export_file = $directory . '/config.tar.gz';
     file_unmanaged_delete($config_export_file);
     try {
         $archiver = new ArchiveTar($config_export_file, 'gz');
         $this->configManager = $this->getConfigManager();
         // Get raw configuration data without overrides.
         foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
             $archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
         }
         $this->targetStorage = $this->getConfigStorage();
         // Get all override data from the remaining collections.
         foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
             $collection_storage = $this->targetStorage->createCollection($collection);
             foreach ($collection_storage->listAll() as $name) {
                 $archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
             }
         }
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $e->getMessage() . '</error>');
         return;
     }
     $messageHelper->addSuccessMessage(sprintf($this->trans('commands.config.export.messages.directory'), $config_export_file));
 }
开发者ID:amira2r,项目名称:DrupalConsole,代码行数:38,代码来源:ConfigExportCommand.php

示例4: complete

 /**
  * Complete remote export.
  */
 function complete()
 {
     // Download the export file.
     $this->download();
     // Remove the export file from the server.
     file_unmanaged_delete($this->file_location);
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:10,代码来源:BackupDatabaseRemote.php

示例5: generate

 /**
  * {@inheritdoc}
  */
 public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL)
 {
     $filename = isset($bundle) && $bundle->isProfile() ? $bundle->getProfileName() : 'generated_features';
     // If no packages were specified, get all packages.
     if (empty($packages)) {
         $packages = $this->featuresManager->getPackages();
     } elseif (count($packages) == 1) {
         // Single package export, so name tar archive by package name.
         $filename = current($packages)['machine_name'];
     }
     $return = [];
     $this->archiveName = $filename . '.tar.gz';
     $archive_name = file_directory_temp() . '/' . $this->archiveName;
     if (file_exists($archive_name)) {
         file_unmanaged_delete($archive_name);
     }
     $archiver = new ArchiveTar($archive_name);
     // Add package files.
     foreach ($packages as $package) {
         if (count($packages) == 1) {
             // Single module export, so don't generate entire modules dir structure.
             $package['directory'] = $package['machine_name'];
         }
         $this->generatePackage($return, $package, $archiver);
     }
     return $return;
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:30,代码来源:FeaturesGenerationArchive.php

示例6: testDirectory

 /**
  * Try deleting a directory.
  */
 function testDirectory()
 {
     // A directory to operate on.
     $directory = $this->createDirectory();
     // Try to delete a directory
     $this->assertFalse(file_unmanaged_delete($directory), 'Could not delete the delete directory.');
     $this->assertTrue(file_exists($directory), 'Directory has not been deleted.');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:UnmanagedDeleteTest.php

示例7: downloadExport

 /**
  * Downloads a tarball of the site configuration.
  */
 public function downloadExport()
 {
     file_unmanaged_delete(file_directory_temp() . '/config.tar.gz');
     $archiver = new ArchiveTar(file_directory_temp() . '/config.tar.gz', 'gz');
     // Get raw configuration data without overrides.
     foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
         $archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
     }
     // Get all override data from the remaining collections.
     foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->targetStorage->createCollection($collection);
         foreach ($collection_storage->listAll() as $name) {
             $archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
         }
     }
     $request = new Request(array('file' => 'config.tar.gz'));
     return $this->fileDownloadController->download($request, 'temporary');
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:21,代码来源:ConfigController.php

示例8: parallax_bg_region5_validate

function parallax_bg_region5_validate($element, &$form_state)
{
    global $base_url;
    $validateFile = array('file_validate_is_image' => array());
    $UploadedFile = file_save_upload('parallax_bg_region5_image', $validateFile, "public://", FILE_EXISTS_REPLACE);
    if ($form_state['values']['delete_parallax_bg_region5_image'] == TRUE) {
        file_unmanaged_delete($form_state['values']['parallax_bg_region5_preview']);
        $form_state['values']['parallax_bg_region5_preview'] = NULL;
    }
    if ($UploadedFile) {
        $UploadedFile->status = FILE_STATUS_PERMANENT;
        file_save($UploadedFile);
        $file_url = file_create_url($UploadedFile->uri);
        $file_url = str_ireplace($base_url, '', $file_url);
        // set to form
        $form_state['values']['parallax_bg_region5_preview'] = $file_url;
    }
}
开发者ID:ApsGitAdmin,项目名称:APS,代码行数:18,代码来源:parallax-image-validate.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $configFile = $input->getOption('file');
     $removeFiles = $input->getOption('remove-files');
     $configSyncDir = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
     if ($configFile) {
         $archiveTar = new ArchiveTar($configFile, 'gz');
         $io->simple($this->trans('commands.config.import.messages.config_files_imported'));
         foreach ($archiveTar->listContent() as $file) {
             $io->info('[-] ' . $file['filename']);
         }
         try {
             $archiveTar->extract($configSyncDir . '/');
         } catch (\Exception $e) {
             $io->error($e->getMessage());
             return;
         }
     }
     $finder = new Finder();
     $finder->in($configSyncDir);
     $finder->name("*.yml");
     foreach ($finder as $configFile) {
         $configName = $configFile->getBasename('.yml');
         $configFilePath = sprintf('%s/%s', $configSyncDir, $configFile->getBasename());
         $config = $this->getConfigFactory()->getEditable($configName);
         $parser = new Parser();
         $configData = $parser->parse(file_get_contents($configFilePath));
         $config->setData($configData);
         if ($removeFiles) {
             file_unmanaged_delete($configFilePath);
         }
         try {
             $config->save();
         } catch (\Exception $e) {
             $io->error($e->getMessage());
             return;
         }
     }
     $io->success(sprintf($this->trans('commands.config.import.messages.imported'), CONFIG_SYNC_DIRECTORY));
 }
开发者ID:larowlan,项目名称:DrupalConsole,代码行数:44,代码来源:ImportCommand.php

示例10: cleanup

 /**
  * Cleanup files created during download().
  *
  * It is expected that $files is returned from download(). Also, be aware that
  * each parent directory in the hierarchy may be removed if there are no more
  * files left in that directory.
  *
  * @param [] $files
  *   Array of files as returned from download() method.
  */
 public static function cleanup(array $files)
 {
     foreach ($files as $file_path => $file_name) {
         // Handle managed files.
         if (count(file_load_multiple([], ['uri' => $file_path])) > 0) {
             $file_obj = new \stdClass();
             $file_obj->uri = $file_path;
             file_delete($file_obj);
         } else {
             file_unmanaged_delete($file_path);
         }
         // Remove all directories in the tree if the file was the last one in this
         // directory.
         $file_dir = dirname($file_path);
         while (count(file_scan_directory($file_dir, '/.*/')) === 0) {
             if (!is_dir($file_dir)) {
                 break;
             }
             drupal_rmdir($file_dir);
             $file_dir = dirname($file_dir);
         }
     }
 }
开发者ID:alexdesignworks,项目名称:drupal_file_downloader,代码行数:33,代码来源:Downloader.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $directory = $input->getOption('directory');
     if (!$directory) {
         $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     $configName = $input->getArgument('config-name');
     $configExportFile = $directory . '/' . $configName . '.yml';
     file_unmanaged_delete($configExportFile);
     $config = $this->getConfigFactory()->getEditable($configName);
     if ($config) {
         $yaml = Yaml::encode($config->getRawData());
         // Save release file
         file_put_contents($configExportFile, $yaml);
         $output->writeln('[+] <info>' . sprintf($this->trans('commands.config.export.single.messages.export'), $configExportFile) . '</info>');
     } else {
         $output->writeln('[+] <error>' . $this->trans('commands.config.export.single.messages.config-not-found') . '</error>');
     }
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:25,代码来源:ExportSingleCommand.php

示例12: site_bg_validate

function site_bg_validate($element, &$form_state)
{
    global $base_url;
    $validateFile = array('file_validate_is_image' => array());
    $UploadedFile = file_save_upload('site_bg_image', $validateFile, "public://", FILE_EXISTS_REPLACE);
    if ($form_state['values']['delete_site_bg_image'] == TRUE) {
        // Delete layer file
        file_unmanaged_delete($form_state['values']['site_bg_preview']);
        $form_state['values']['site_bg_preview'] = NULL;
    }
    if ($UploadedFile) {
        // change file's status from temporary to permanent and update file database
        $UploadedFile->status = FILE_STATUS_PERMANENT;
        file_save($UploadedFile);
        $file_url = file_create_url($UploadedFile->uri);
        $file_url = str_ireplace($base_url, '', $file_url);
        // set to form
        $form_state['values']['site_bg_preview'] = $file_url;
    }
}
开发者ID:vfokov,项目名称:videosite,代码行数:20,代码来源:theme-settings.php

示例13: testJavaScriptTranslation

 public function testJavaScriptTranslation()
 {
     $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages'));
     $this->drupalLogin($user);
     $config = \Drupal::config('locale.settings');
     $langcode = 'xx';
     // The English name for the language. This will be translated.
     $name = $this->randomMachineName(16);
     // Add custom language.
     $edit = array('predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR);
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
     $this->container->get('language_manager')->reset();
     // Build the JavaScript translation file.
     // Retrieve the source string of the first string available in the
     // {locales_source} table and translate it.
     $source = db_select('locales_source', 'l')->fields('l', array('source'))->condition('l.source', '%.js%', 'LIKE')->range(0, 1)->execute()->fetchField();
     $search = array('string' => $source, 'langcode' => $langcode, 'translation' => 'all');
     $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
     $textarea = current($this->xpath('//textarea'));
     $lid = (string) $textarea[0]['name'];
     $edit = array($lid => $this->randomMachineName());
     $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
     // Trigger JavaScript translation parsing and building.
     _locale_rebuild_js($langcode);
     $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
     $js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
     $this->assertTrue($result = file_exists($js_file), String::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
     // Test JavaScript translation rebuilding.
     file_unmanaged_delete($js_file);
     $this->assertTrue($result = !file_exists($js_file), String::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
     _locale_rebuild_js($langcode);
     $this->assertTrue($result = file_exists($js_file), String::format('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:33,代码来源:LocaleTranslationUiTest.php

示例14: stability_settings_submit

/**
 * Save settings data.
 */
function stability_settings_submit($form, &$form_state)
{
    $settings = array();
    if (isset($form_state['input']['sub_header_images'])) {
        foreach ($form_state['input']['sub_header_images'] as $image) {
            if (is_array($image)) {
                $image = $image['image'];
                if ($image['image_delete']) {
                    $image['fid'] && ($file = file_load($image['fid'])) ? file_delete($file) : file_unmanaged_delete($image['image_path']);
                } else {
                    $settings[] = $image;
                }
            }
        }
    }
    if ($file = file_save_upload('image_upload', array(), 'public://')) {
        $file->status = 1;
        file_save($file);
        $settings[] = array('fid' => $file->fid, 'image_path' => $file->uri);
    }
    variable_set(variable_get('theme_default', 'none') . '_sub_headers', $settings);
}
开发者ID:harryboulderdash,项目名称:PlayGFC,代码行数:25,代码来源:theme-settings.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $messageHelper = $this->getMessageHelper();
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $config = $this->getConfigFactory()->get('system.file');
         $directory = $config->get('path.temporary') ?: file_directory_temp();
         $directory .= '/' . CONFIG_STAGING_DIRECTORY;
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     $config_name = $input->getArgument('config-name');
     $config_export_file = $directory . '/' . $config_name . '.yml';
     file_unmanaged_delete($config_export_file);
     $config = $this->getConfigFactory()->getEditable($config_name);
     if ($config) {
         $yaml = Yaml::encode($config->getRawData());
         // Save release file
         file_put_contents($config_export_file, $yaml);
         $output->writeln('[+] <info>' . sprintf($this->trans('commands.config.export.single.messages.export'), $config_export_file) . '</info>');
     } else {
         $output->writeln('[+] <error>' . $this->trans('commands.config.export.single.messages.config-not-found') . '</error>');
     }
 }
开发者ID:janstoeckler,项目名称:DrupalConsole,代码行数:28,代码来源:ConfigExportSingleCommand.php


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