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


PHP file_unmanaged_save_data函数代码示例

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


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

示例1: at_core_submit_mobile_blocks

/**
 * Submit Mobile Blocks settings.
 * @param $values
 * @param $theme
 * @param $generated_files_path
 */
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path)
{
    $mobile_blocks_css = array();
    // TODO entityManager() is deprecated, but how to replace?
    $theme_blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
    if (!empty($theme_blocks)) {
        foreach ($theme_blocks as $block_key => $block_values) {
            $block_id = $block_values->id();
            if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
                $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
                $mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
                $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
            }
            if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
                $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
                $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
                $mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
            }
        }
    }
    if (!empty($mobile_blocks_css)) {
        $file_name = 'mobile-blocks.css';
        $filepath = $generated_files_path . '/' . $file_name;
        file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
    }
}
开发者ID:neetumorwani,项目名称:blogging,代码行数:32,代码来源:mobile_blocks_submit.php

示例2: dump

 /**
  * {@inheritdoc}
  *
  * The file name for the CSS or JS cache file is generated from the hash of
  * the aggregated contents of the files in $data. This forces proxies and
  * browsers to download new CSS when the CSS changes.
  */
 public function dump($data, $file_extension)
 {
     // Prefix filename to prevent blocking by firewalls which reject files
     // starting with "ad*".
     $filename = $file_extension . '_' . Crypt::hashBase64($data) . '.' . $file_extension;
     // Create the css/ or js/ path within the files folder.
     $path = 'public://' . $file_extension;
     $uri = $path . '/' . $filename;
     // Create the CSS or JS file.
     file_prepare_directory($path, FILE_CREATE_DIRECTORY);
     if (!file_exists($uri) && !file_unmanaged_save_data($data, $uri, FILE_EXISTS_REPLACE)) {
         return FALSE;
     }
     // If CSS/JS gzip compression is enabled and the zlib extension is available
     // then create a gzipped version of this file. This file is served
     // conditionally to browsers that accept gzip using .htaccess rules.
     // It's possible that the rewrite rules in .htaccess aren't working on this
     // server, but there's no harm (other than the time spent generating the
     // file) in generating the file anyway. Sites on servers where rewrite rules
     // aren't working can set css.gzip to FALSE in order to skip
     // generating a file that won't be used.
     if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) {
         if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
             return FALSE;
         }
     }
     return $uri;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:35,代码来源:AssetDumper.php

示例3: complie

 function complie($file = null)
 {
     $update = drupalexp_is_settings_change();
     $ftime = $this->filetime($file);
     if (!empty($this->theme->lessc)) {
         foreach ($this->theme->lessc as $lessc_file) {
             if ($ftime < $this->filetime($lessc_file)) {
                 $update = true;
             }
             $this->output .= "@import \"{$lessc_file}\";\n";
         }
     }
     if ($update) {
         try {
             $this->css = $this->lessc->compile($this->output);
         } catch (exception $e) {
             drupal_set_message("fatal error: " . $e->getMessage(), 'error');
             return FALSE;
         }
         if ($file) {
             file_unmanaged_save_data($this->css, $file, FILE_EXISTS_REPLACE);
         }
     }
     return $this->css;
 }
开发者ID:TommyTran1,项目名称:excelpoint,代码行数:25,代码来源:lessc.php

示例4: testExport

 /**
  * Tests export of configuration.
  */
 function testExport()
 {
     // Verify the export page with export submit button is available.
     $this->drupalGet('admin/config/development/configuration/full/export');
     $this->assertFieldById('edit-submit', t('Export'));
     // Submit the export form and verify response.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
     $this->assertResponse(200, 'User can access the download callback.');
     // Get the archived binary file provided to user for download.
     $archive_data = $this->drupalGetContent();
     // Temporarily save the archive file.
     $uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
     // Extract the archive and verify it's not empty.
     $file_path = file_directory_temp() . '/' . file_uri_target($uri);
     $archiver = new Tar($file_path);
     $archive_contents = $archiver->listContents();
     $this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
     // Prepare the list of config files from active storage, see
     // \Drupal\config\Controller\ConfigController::downloadExport().
     $storage_active = $this->container->get('config.storage');
     $config_files = array();
     foreach ($storage_active->listAll() as $config_name) {
         $config_files[] = $config_name . '.yml';
     }
     // Assert that the downloaded archive file contents are the same as the test
     // site active store.
     $this->assertIdentical($archive_contents, $config_files);
     // Ensure the test configuration override is in effect but was not exported.
     $this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
     $archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
     $file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
     $exported = Yaml::decode($file_contents);
     $this->assertNotIdentical($exported['message'], 'Foo');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:37,代码来源:ConfigExportUITest.php

示例5: denormalize

 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = NULL, array $context = array())
 {
     $file_data = (string) $this->httpClient->get($data['uri'][0]['value'])->getBody();
     $path = 'temporary://' . drupal_basename($data['uri'][0]['value']);
     $data['uri'] = file_unmanaged_save_data($file_data, $path);
     return $this->entityManager->getStorage('file')->create($data);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:FileEntityNormalizer.php

示例6: at_core_submit_mobile_blocks

/**
 * @file
 * Save Breadcrumb CSS to file
 */
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path) {
  $mobile_blocks_css = array();
  $theme_blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]);

  if (!empty($theme_blocks)) {
    foreach ($theme_blocks as $block_key => $block_values) {
      $block_id = $block_values->id();
      if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
        $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
        $mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
        $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
      }
      if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
        $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
        $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
        $mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
      }
    }
  }

  if (!empty($mobile_blocks_css)) {
    $file_name = 'mobile-blocks.css';
    $filepath = $generated_files_path . '/' . $file_name;
    file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
  }
}
开发者ID:jno84,项目名称:drupal8,代码行数:30,代码来源:mobile_blocks_submit.php

示例7: outputFile

 public function outputFile($file, $force = FALSE)
 {
     if (file_exists($file) && !$force) {
         $update = FALSE;
         $last_modified = filemtime($file);
         if (!empty($this->theme->lessc)) {
             foreach ($this->theme->lessc as $lessc) {
                 $path = $this->theme_path . '/lessc/' . $lessc;
                 if (filemtime($path) > $last_modified) {
                     $update = TRUE;
                     break;
                 }
             }
         }
     } else {
         $update = TRUE;
     }
     if ($update) {
         if ($this->css == '') {
             $this->compileLessc();
         }
         $file_update = file_unmanaged_save_data($this->css, $file, FILE_EXISTS_REPLACE);
         if (!$file_update) {
             return FALSE;
         }
     }
     return $file;
 }
开发者ID:Anasss,项目名称:blogphoto,代码行数:28,代码来源:superhero_lessc.php

示例8: complie

 function complie($file = null)
 {
     $update = drupalexp_is_settings_change();
     $ftime = $this->filetime($file);
     if (!empty($this->theme->lessc)) {
         foreach ($this->theme->lessc as $lessc_file) {
             if ($ftime < $this->filetime($lessc_file)) {
                 $update = true;
             }
             $this->output .= "@import \"{$lessc_file}\";\n";
         }
     }
     if ($update) {
         try {
             $this->css = $this->lessc->compile($this->output);
         } catch (exception $e) {
             drupal_set_message("fatal error: " . $e->getMessage(), 'error');
             return FALSE;
         }
         if ($file) {
             $css_output = "/*This file is generated by less css (http://lesscss.org) using drupalexp framework (http://drupalexp.com)*/\n/*Please do not modify this file content*/\n" . $this->css;
             file_unmanaged_save_data($css_output, $file, FILE_EXISTS_REPLACE);
         }
     }
     return $this->css;
 }
开发者ID:benelori,项目名称:lori,代码行数:26,代码来源:lessc.php

示例9: testPiwikUninstall

 /**
  * Tests if the module cleans up the disk on uninstall.
  */
 public function testPiwikUninstall()
 {
     $cache_path = 'public://piwik';
     $site_id = '1';
     $this->config('piwik.settings')->set('site_id', $site_id)->save();
     $this->config('piwik.settings')->set('url_http', 'http://www.example.com/piwik/')->save();
     $this->config('piwik.settings')->set('url_https', 'https://www.example.com/piwik/')->save();
     // Enable local caching of piwik.js
     $this->config('piwik.settings')->set('cache', 1)->save();
     // Load front page to get the piwik.js downloaded into local cache. But
     // loading the piwik.js is not possible as "url_http" is a test dummy only.
     // Create a dummy file to complete the rest of the tests.
     file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY);
     file_unmanaged_save_data($this->randomMachineName(16), $cache_path . '/piwik.js');
     // Test if the directory and piwik.js exists.
     $this->assertTrue(file_prepare_directory($cache_path), 'Cache directory "public://piwik" has been found.');
     $this->assertTrue(file_exists($cache_path . '/piwik.js'), 'Cached piwik.js tracking file has been found.');
     // Uninstall the module.
     $edit = [];
     $edit['uninstall[piwik]'] = TRUE;
     $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
     $this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
     $this->drupalPostForm(NULL, NULL, t('Uninstall'));
     $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
     // Test if the directory and all files have been removed.
     $this->assertFalse(file_scan_directory($cache_path, '/.*/'), 'Cached JavaScript files have been removed.');
     $this->assertFalse(file_prepare_directory($cache_path), 'Cache directory "public://piwik" has been removed.');
 }
开发者ID:rsmccc,项目名称:drupal-bootstrap,代码行数:31,代码来源:PiwikUninstallTest.php

示例10: at_core_submit_custom_css

function at_core_submit_custom_css($values, $generated_files_path)
{
    $custom_css = '';
    if (!empty($values['settings_custom_css'])) {
        // sanitize user entered data
        $custom_css = Xss::filter($values['settings_custom_css']);
    }
    $file_name = 'custom-css.css';
    $filepath = $generated_files_path . '/' . $file_name;
    file_unmanaged_save_data($custom_css, $filepath, FILE_EXISTS_REPLACE);
}
开发者ID:neetumorwani,项目名称:blogging,代码行数:11,代码来源:custom_css_submit.php

示例11: at_core_submit_breadcrumb

/**
 * @file
 * Save Breadcrumb CSS to file
 */
function at_core_submit_breadcrumb($values, $theme, $generated_files_path) {
  $breadcrumb_css = '';
  if (!empty($values['settings_breadcrumb_separator'])) {
    $css = '.breadcrumb li:before {content: "' . Html::escape($values['settings_breadcrumb_separator']) . '"}';
  }
  if (!empty($css)) {
    $file_name = 'breadcrumb.css';
    $filepath = $generated_files_path . '/' . $file_name;
    file_unmanaged_save_data($css, $filepath, FILE_EXISTS_REPLACE);
  }
}
开发者ID:jno84,项目名称:drupal8,代码行数:15,代码来源:breadcrumb_submit.php

示例12: testUpdateDeleteFileIfStale

 /**
  * Tests the deletion of stale files.
  */
 function testUpdateDeleteFileIfStale()
 {
     $file_name = file_unmanaged_save_data($this->randomMachineName());
     $this->assertNotNull($file_name);
     // During testing the file change and the stale checking occurs in the same
     // request, so the beginning of request will be before the file changes and
     // REQUEST_TIME - $filectime is negative. Set the maximum age to a number
     // even smaller than that.
     $this->container->get('config.factory')->get('system.file')->set('temporary_maximum_age', -100000)->save();
     $file_path = drupal_realpath($file_name);
     update_delete_file_if_stale($file_path);
     $this->assertFalse(is_file($file_path));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:UpdateDeleteFileIfStaleTest.php

示例13: testExport

 /**
  * Tests export of configuration.
  */
 function testExport()
 {
     // Verify the export page with export submit button is available.
     $this->drupalGet('admin/config/development/configuration/full/export');
     $this->assertFieldById('edit-submit', t('Export'));
     // Submit the export form and verify response.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
     $this->assertResponse(200, 'User can access the download callback.');
     // Test if header contains file name with hostname and timestamp.
     $request = \Drupal::request();
     $hostname = str_replace('.', '-', $request->getHttpHost());
     $header_content_disposition = $this->drupalGetHeader('content-disposition');
     $header_match = (bool) preg_match('/attachment; filename="config-' . preg_quote($hostname) . '-\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}\\.tar\\.gz"/', $header_content_disposition);
     $this->assertTrue($header_match, "Header with filename matches the expected format.");
     // Get the archived binary file provided to user for download.
     $archive_data = $this->getRawContent();
     // Temporarily save the archive file.
     $uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
     // Extract the archive and verify it's not empty.
     $file_path = file_directory_temp() . '/' . file_uri_target($uri);
     $archiver = new Tar($file_path);
     $archive_contents = $archiver->listContents();
     $this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
     // Prepare the list of config files from active storage, see
     // \Drupal\config\Controller\ConfigController::downloadExport().
     $storage_active = $this->container->get('config.storage');
     $config_files = array();
     foreach ($storage_active->listAll() as $config_name) {
         $config_files[] = $config_name . '.yml';
     }
     // Assert that the downloaded archive file contents are the same as the test
     // site active store.
     $this->assertIdentical($archive_contents, $config_files);
     // Ensure the test configuration override is in effect but was not exported.
     $this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
     $archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
     $file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
     $exported = Yaml::decode($file_contents);
     $this->assertNotIdentical($exported['message'], 'Foo');
     // Check the single export form doesn't have "form-required" elements.
     $this->drupalGet('admin/config/development/configuration/single/export');
     $this->assertNoRaw('js-form-required form-required', 'No form required fields are found.');
     // Ensure the temporary file is not available to users without the
     // permission.
     $this->drupalLogout();
     $this->drupalGet('system/temporary', ['query' => ['file' => 'config.tar.gz']]);
     $this->assertResponse(403);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:51,代码来源:ConfigExportUITest.php

示例14: ophir_copy_file

function ophir_copy_file($from, $to)
{
    if (function_exists('file_unmanaged_copy')) {
        $filename = file_unmanaged_save_data(file_get_contents($from), $to, FILE_EXISTS_REPLACE);
        return $filename ? file_create_url($filename) : false;
    } else {
        if (file_exists($to)) {
            if (crc32(file_get_contents($from)) === crc32(file_get_contents($from))) {
                return $to;
            }
            $i = pathinfo($to);
            $to = $i['dirname'] . '/' . $i['filename'] . time() . '.' . $i['extension'];
        }
        return copy($from, $to) ? $to : FALSE;
    }
}
开发者ID:Dirbaio,项目名称:TurboFile,代码行数:16,代码来源:ophir.php

示例15: testFileSaveData

 /**
  * Test the file_unmanaged_save_data() function.
  */
 function testFileSaveData()
 {
     $contents = $this->randomMachineName(8);
     $this->settingsSet('file_chmod_file', 0777);
     // No filename.
     $filepath = file_unmanaged_save_data($contents);
     $this->assertTrue($filepath, 'Unnamed file saved correctly.');
     $this->assertEqual(file_uri_scheme($filepath), file_default_scheme(), "File was placed in Drupal's files directory.");
     $this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.');
     // Provide a filename.
     $filepath = file_unmanaged_save_data($contents, 'public://asdf.txt', FILE_EXISTS_REPLACE);
     $this->assertTrue($filepath, 'Unnamed file saved correctly.');
     $this->assertEqual('asdf.txt', drupal_basename($filepath), 'File was named correctly.');
     $this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.');
     $this->assertFilePermissions($filepath, 0777);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:UnmanagedSaveDataTest.php


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