• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_unmanaged_copy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: asu_webspark_bootstrap_settings_submit

function asu_webspark_bootstrap_settings_submit($form, &$form_state)
{
    // Set the variables, need to use this instead of theme_get_settings
    // because the scop of the vars is more global.
    if ($form_state['values']['asu_brand_header_selector'] != 'custom') {
        variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_selector']);
    } else {
        variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_template']);
    }
    variable_set('asu_brand_is_student', $form_state['values']['asu_brand_is_student']);
    variable_set('asu_brand_student_color', $form_state['values']['asu_brand_student_color']);
    variable_set('asu_brand_header_selector', $form_state['values']['asu_brand_header_selector']);
    if ($file = $form_state['values']['picture_upload']) {
        unset($form_state['values']['picture_upload']);
        $filename = file_unmanaged_copy($file->uri);
        $form_state['values']['default_picture'] = 1;
        $form_state['values']['picture_path'] = $filename;
    }
    // If the user entered a path relative to the system files directory for
    // a logo or favicon, store a public:// URI so the theme system can handle it.
    if (!empty($form_state['values']['picture_path'])) {
        $form_state['values']['picture_path'] = _system_theme_settings_validate_path($form_state['values']['picture_path']);
    }
    // ASU header needs a cache_clear
    if (module_exists('asu_brand')) {
        asu_brand_cache_clear();
    }
}
开发者ID:niner9,项目名称:webspark-drops-drupal7,代码行数:28,代码来源:theme-settings.php


示例2: doTestContrastOperations

 /**
  * Contrast operations test.
  */
 public function doTestContrastOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $image_toolkit_id = $image_factory->getToolkitId();
     // Test on the PNG test image.
     $test_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     // Test data.
     $test_data = ['0' => [$this->red, $this->green, $this->transparent, $this->blue], '-50' => [$image_toolkit_id === 'imagemagick' ? array(180, 75, 75, 0) : array(159, 95, 95, 0), $image_toolkit_id === 'imagemagick' ? array(75, 180, 75, 0) : array(95, 159, 95, 0), $this->transparent, $image_toolkit_id === 'imagemagick' ? array(75, 75, 180, 0) : array(95, 95, 159, 0)], '-100' => [$image_toolkit_id === 'imagemagick' ? array(128, 128, 128, 0) : array(127, 127, 127, 0), $image_toolkit_id === 'imagemagick' ? array(128, 128, 128, 0) : array(127, 127, 127, 0), $this->transparent, $image_toolkit_id === 'imagemagick' ? array(128, 128, 128, 0) : array(127, 127, 127, 0)], '50' => [array(255, 0, 0, 0), array(0, 255, 0, 0), $this->transparent, array(0, 0, 255, 0)], '100' => [array(255, 0, 0, 0), array(0, 255, 0, 0), $this->transparent, array(0, 0, 255, 0)]];
     foreach ($test_data as $key => $colors) {
         // Add contrast effect to the test image style.
         $effect = ['id' => 'image_effects_contrast', 'data' => ['level' => $key]];
         $uuid = $this->addEffectToTestStyle($effect);
         // Load Image Style.
         $image_style = ImageStyle::load('image_effects_test');
         // Check that ::applyEffect generates image with expected contrast.
         $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
         $image = $image_factory->get($generated_uri, 'gd');
         $this->assertTrue($this->colorsAreEqual($colors[0], $this->getPixelColor($image, 0, 0)));
         $this->assertTrue($this->colorsAreEqual($colors[1], $this->getPixelColor($image, 39, 0)));
         $this->assertTrue($this->colorsAreEqual($colors[2], $this->getPixelColor($image, 0, 19)));
         $this->assertTrue($this->colorsAreEqual($colors[3], $this->getPixelColor($image, 39, 19)));
         // Remove effect.
         $uuid = $this->removeEffectFromTestStyle($uuid);
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:30,代码来源:ImageEffectsContrastTest.php


示例3: doTestAutoOrientOperations

 /**
  * Auto Orientation operations test.
  */
 public function doTestAutoOrientOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $test_data = [['test_file' => drupal_get_path('module', 'image_effects') . '/misc/portrait-painting.jpg', 'original_width' => 640, 'original_height' => 480, 'derivative_width' => 200, 'derivative_height' => 267], ['test_file' => drupal_get_path('module', 'simpletest') . '/files/image-test.jpg', 'original_width' => 40, 'original_height' => 20, 'derivative_width' => 200, 'derivative_height' => 100], ['test_file' => drupal_get_path('module', 'simpletest') . '/files/image-1.png', 'original_width' => 360, 'original_height' => 240, 'derivative_width' => 200, 'derivative_height' => 133]];
     foreach ($test_data as $data) {
         // Get expected URIs.
         $original_uri = file_unmanaged_copy($data['test_file'], 'public://', FILE_EXISTS_RENAME);
         $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
         // Test source image dimensions.
         $image = $image_factory->get($original_uri);
         $this->assertEqual($data['original_width'], $image->getWidth());
         $this->assertEqual($data['original_height'], $image->getHeight());
         // Load Image Style and get expected derivative URL.
         $image_style = ImageStyle::load('image_effects_test');
         $url = file_url_transform_relative($image_style->buildUrl($original_uri));
         // Check that ::transformDimensions returns expected dimensions.
         $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
         $this->assertEqual('<img src="' . $url . '" width="' . $data['derivative_width'] . '" height="' . $data['derivative_height'] . '" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
         // Check that ::applyEffect generates image with expected dimensions.
         $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
         $image = $image_factory->get($generated_uri);
         $this->assertEqual($data['derivative_width'], $image->getWidth());
         $this->assertEqual($data['derivative_height'], $image->getHeight());
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:28,代码来源:ImageEffectsAutoOrientTest.php


示例4: doTestWatermarkOperations

 /**
  * Watermark operations test.
  */
 public function doTestWatermarkOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $test_file = drupal_get_path('module', 'simpletest') . '/files/image-1.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     $watermark_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $watermark_uri = file_unmanaged_copy($watermark_file, 'public://', FILE_EXISTS_RENAME);
     $effect = ['id' => 'image_effects_watermark', 'data' => ['placement' => 'left-top', 'x_offset' => 1, 'y_offset' => 1, 'opacity' => 100, 'watermark_image' => $watermark_uri]];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::applyEffect generates image with expected watermark.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $watermark = $image_factory->get($watermark_uri, 'gd');
     $this->assertFalse($this->colorsAreEqual($this->getPixelColor($watermark, 0, 0), $this->getPixelColor($image, 0, 0)));
     $this->assertTrue($this->colorsAreEqual($this->getPixelColor($watermark, 0, 0), $this->getPixelColor($image, 1, 1)));
     $this->assertTrue($this->colorsAreEqual($this->getPixelColor($watermark, 0, 1), $this->getPixelColor($image, 1, 2)));
     $this->assertTrue($this->colorsAreEqual($this->getPixelColor($watermark, 0, 3), $this->getPixelColor($image, 1, 4)));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
     // Test for watermark PNG image with full transparency set, 100% opacity
     // watermark.
     $test_file = drupal_get_path('module', 'image_effects') . '/tests/images/fuchsia.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     $watermark_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $watermark_uri = file_unmanaged_copy($watermark_file, 'public://', FILE_EXISTS_RENAME);
     $effect = ['id' => 'image_effects_watermark', 'data' => ['placement' => 'left-top', 'x_offset' => 0, 'y_offset' => 0, 'opacity' => 100, 'watermark_image' => $watermark_uri]];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::applyEffect generates image with expected transparency.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertTrue($this->colorsAreEqual($this->getPixelColor($image, 0, 19), $this->fuchsia));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
     // Test for watermark PNG image with full transparency set, 50% opacity
     // watermark.
     $test_file = drupal_get_path('module', 'image_effects') . '/tests/images/fuchsia.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     $watermark_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $watermark_uri = file_unmanaged_copy($watermark_file, 'public://', FILE_EXISTS_RENAME);
     $effect = ['id' => 'image_effects_watermark', 'data' => ['placement' => 'left-top', 'x_offset' => 0, 'y_offset' => 0, 'opacity' => 50, 'watermark_image' => $watermark_uri]];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::applyEffect generates image with expected alpha.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertTrue($this->colorsAreEqual($this->getPixelColor($image, 0, 19), $this->fuchsia));
     // GD and ImageMagick return slightly different colors, use the
     // ::colorsAreClose method.
     $this->assertTrue($this->colorsAreClose($this->getPixelColor($image, 39, 0), [127, 127, 127, 0]));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:63,代码来源:ImageEffectsWatermarkTest.php


示例5: testOverwriteSelf

 /**
  * Copy a file onto itself.
  */
 function testOverwriteSelf()
 {
     // Create a file for testing
     $uri = $this->createUri();
     // Copy the file onto itself with renaming works.
     $new_filepath = file_unmanaged_copy($uri, $uri, FILE_EXISTS_RENAME);
     $this->assertTrue($new_filepath, 'Copying onto itself with renaming works.');
     $this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
     $this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
     $this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.');
     $this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FILE_CHMOD_FILE));
     // Copy the file onto itself without renaming fails.
     $new_filepath = file_unmanaged_copy($uri, $uri, FILE_EXISTS_ERROR);
     $this->assertFalse($new_filepath, 'Copying onto itself without renaming fails.');
     $this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
     // Copy the file into same directory without renaming fails.
     $new_filepath = file_unmanaged_copy($uri, drupal_dirname($uri), FILE_EXISTS_ERROR);
     $this->assertFalse($new_filepath, 'Copying onto itself fails.');
     $this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
     // Copy the file into same directory with renaming works.
     $new_filepath = file_unmanaged_copy($uri, drupal_dirname($uri), FILE_EXISTS_RENAME);
     $this->assertTrue($new_filepath, 'Copying into same directory works.');
     $this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
     $this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
     $this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.');
     $this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FILE_CHMOD_FILE));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:30,代码来源:UnmanagedCopyTest.php


示例6: flux_theme_settings_submit

/**
 * Submit handler
 */
function flux_theme_settings_submit($form, &$form_state)
{
    $previous = theme_get_setting('cover_photo_path');
    // If the user uploaded a new cover_photo or favicon, save it to a permanent location
    // and use it in place of the default theme-provided file.
    if (!empty($form_state['values']['cover_photo_upload'])) {
        $file = $form_state['values']['cover_photo_upload'];
        unset($form_state['values']['cover_photo_upload']);
        $filename = file_unmanaged_copy($file->uri, NULL, FILE_EXISTS_REPLACE);
        $form_state['values']['default_cover_photo'] = 0;
        $form_state['values']['cover_photo_path'] = $filename;
        $form_state['values']['toggle_cover_photo'] = 1;
        // Remove previous file uploaded
        $current = $form_state['values']['cover_photo_path'];
        if ($previous != $current && is_file($previous)) {
            // Delete previous file
            drupal_unlink($previous);
        }
    }
    // If the user entered a path relative to the system files directory for
    // a cover_photo or favicon, store a public:// URI so the theme system can handle it.
    if (!empty($form_state['values']['cover_photo_path'])) {
        $form_state['values']['cover_photo_path'] = flux_system_theme_settings_validate_path($form_state['values']['cover_photo_path']);
    }
}
开发者ID:sheldonrampton,项目名称:pushtape-drops,代码行数:28,代码来源:theme-settings.php


示例7: doTestColorshiftOperations

 /**
  * Color Shift operations test.
  */
 public function doTestColorshiftOperations()
 {
     $image_factory = $this->container->get('image.factory');
     // Test on the PNG test image.
     $test_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     // Test data.
     $test_data = ['#FF0000' => [$this->red, $this->yellow, $this->transparent, $this->fuchsia], '#00FF00' => [$this->yellow, $this->green, $this->transparent, $this->cyan], '#0000FF' => [$this->fuchsia, $this->cyan, $this->transparent, $this->blue], '#929BEF' => [[255, 155, 239, 0], [146, 255, 239, 0], $this->transparent, [146, 155, 255, 0]]];
     foreach ($test_data as $key => $colors) {
         // Add Color Shift effect to the test image style.
         $effect = ['id' => 'image_effects_color_shift', 'data' => ['RGB][hex' => $key]];
         $uuid = $this->addEffectToTestStyle($effect);
         // Load Image Style.
         $image_style = ImageStyle::load('image_effects_test');
         // Check that ::applyEffect generates image with expected color shift.
         $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
         $image = $image_factory->get($generated_uri, 'gd');
         $this->assertTrue($this->colorsAreEqual($colors[0], $this->getPixelColor($image, 0, 0)));
         $this->assertTrue($this->colorsAreEqual($colors[1], $this->getPixelColor($image, 39, 0)));
         $this->assertTrue($this->colorsAreEqual($colors[2], $this->getPixelColor($image, 0, 19)));
         $this->assertTrue($this->colorsAreEqual($colors[3], $this->getPixelColor($image, 39, 19)));
         // Remove effect.
         $uuid = $this->removeEffectFromTestStyle($uuid);
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:29,代码来源:ImageEffectsColorShiftTest.php


示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
     $this->drupalLogin($this->adminUser);
     // Copy test po files to the translations directory.
     file_unmanaged_copy(__DIR__ . '/../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     file_unmanaged_copy(__DIR__ . '/../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:12,代码来源:LocaleExportTest.php


示例9: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
     $this->drupalLogin($this->adminUser);
     // Copy test po files to the translations directory.
     file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:LocaleExportTest.php


示例10: setUp

 /**
  * {@inheritdoc}
  */
 function setUp()
 {
     parent::setUp();
     $this->addLanguage('de');
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML'));
     $filtered_html_format->save();
     $this->drupalCreateContentType(array('type' => 'test_bundle'));
     $this->loginAsAdmin(array('create translation jobs', 'submit translation jobs', 'create test_bundle content', $filtered_html_format->getPermissionName()));
     file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
     $this->image = File::create(array('uri' => 'public://example.jpg'));
     $this->image->save();
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:15,代码来源:TMGMTUiReviewTest.php


示例11: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Copy test po files to the translations directory.
     file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
     $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
     $this->drupalLogin($this->adminUser);
     // Enable import of translations. By default this is disabled for automated
     // tests.
     \Drupal::config('locale.settings')->set('translation.import_enabled', TRUE)->save();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:15,代码来源:LocaleImportFunctionalTest.php


示例12: doTestSetCanvasOperations

 /**
  * Set canvas operations test.
  */
 public function doTestSetCanvasOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $test_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     // Test EXACT size canvas.
     $effect = ['id' => 'image_effects_set_canvas', 'data' => ['canvas_size' => 'exact', 'canvas_color][container][transparent' => FALSE, 'canvas_color][container][hex' => '#FF00FF', 'canvas_color][container][opacity' => 100, 'exact][width' => '200%', 'exact][height' => '200%']];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::transformDimensions returns expected dimensions.
     $image = $image_factory->get($original_uri);
     $this->assertEqual(40, $image->getWidth());
     $this->assertEqual(20, $image->getHeight());
     $url = file_url_transform_relative($image_style->buildUrl($original_uri));
     $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
     $this->assertEqual('<img src="' . $url . '" width="80" height="40" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
     // Check that ::applyEffect generates image with expected canvas.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertEqual(80, $image->getWidth());
     $this->assertEqual(40, $image->getHeight());
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 0, 0)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 79, 0)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 0, 39)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 79, 39)));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
     // Test RELATIVE size canvas.
     $effect = ['id' => 'image_effects_set_canvas', 'data' => ['canvas_size' => 'relative', 'canvas_color][container][transparent' => FALSE, 'canvas_color][container][hex' => '#FFFF00', 'canvas_color][container][opacity' => 100, 'relative][right' => 10, 'relative][left' => 20, 'relative][top' => 30, 'relative][bottom' => 40]];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::transformDimensions returns expected dimensions.
     $image = $image_factory->get($original_uri);
     $this->assertEqual(40, $image->getWidth());
     $this->assertEqual(20, $image->getHeight());
     $url = file_url_transform_relative($image_style->buildUrl($original_uri));
     $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
     $this->assertEqual('<img src="' . $url . '" width="70" height="90" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
     // Check that ::applyEffect generates image with expected canvas.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertEqual(70, $image->getWidth());
     $this->assertEqual(90, $image->getHeight());
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 0, 0)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 69, 0)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 0, 89)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 69, 89)));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:56,代码来源:ImageEffectsSetCanvasTest.php


示例13: createSampleImage

 /**
  * Given an image style, generate an image.
  */
 function createSampleImage(ImageStyleInterface $style)
 {
     static $file_path;
     // First, we need to make sure we have an image in our testing
     // file directory. Copy over an image on the first run.
     if (!isset($file_path)) {
         $files = $this->drupalGetTestFiles('image');
         $file = reset($files);
         $file_path = file_unmanaged_copy($file->uri);
     }
     return $style->buildUrl($file_path) ? $file_path : FALSE;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:15,代码来源:ImageAdminStylesTest.php


示例14: testImageSource

 /**
  * Tests removal of images having a non-local source.
  */
 function testImageSource()
 {
     global $base_url;
     $public_files_path = PublicStream::basePath();
     $http_base_url = preg_replace('/^https?/', 'http', $base_url);
     $https_base_url = preg_replace('/^https?/', 'https', $base_url);
     $files_path = base_path() . $public_files_path;
     $csrf_path = $public_files_path . '/' . implode('/', array_fill(0, substr_count($public_files_path, '/') + 1, '..'));
     $druplicon = 'core/misc/druplicon.png';
     $red_x_image = base_path() . 'core/misc/icons/e32700/error.svg';
     $alt_text = t('Image removed.');
     $title_text = t('This image has been removed. For security reasons, only images from the local domain are allowed.');
     // Put a test image in the files directory.
     $test_images = $this->drupalGetTestFiles('image');
     $test_image = $test_images[0]->filename;
     // Put a test image in the files directory with special filename.
     $special_filename = 'tést fïle nàme.png';
     $special_image = rawurlencode($special_filename);
     $special_uri = str_replace($test_images[0]->filename, $special_filename, $test_images[0]->uri);
     file_unmanaged_copy($test_images[0]->uri, $special_uri);
     // Create a list of test image sources.
     // The keys become the value of the IMG 'src' attribute, the values are the
     // expected filter conversions.
     $host = \Drupal::request()->getHost();
     $host_pattern = '|^http\\://' . $host . '(\\:[0-9]{0,5})|';
     $images = array($http_base_url . '/' . $druplicon => base_path() . $druplicon, $https_base_url . '/' . $druplicon => base_path() . $druplicon, preg_replace($host_pattern, 'http://' . $host . ':', $http_base_url . '/' . $druplicon) => base_path() . $druplicon, preg_replace($host_pattern, 'http://' . $host . ':80', $http_base_url . '/' . $druplicon) => base_path() . $druplicon, preg_replace($host_pattern, 'http://' . $host . ':443', $http_base_url . '/' . $druplicon) => base_path() . $druplicon, preg_replace($host_pattern, 'http://' . $host . ':8080', $http_base_url . '/' . $druplicon) => base_path() . $druplicon, base_path() . $druplicon => base_path() . $druplicon, $files_path . '/' . $test_image => $files_path . '/' . $test_image, $http_base_url . '/' . $public_files_path . '/' . $test_image => $files_path . '/' . $test_image, $https_base_url . '/' . $public_files_path . '/' . $test_image => $files_path . '/' . $test_image, $http_base_url . '/' . $public_files_path . '/' . $special_image => $files_path . '/' . $special_image, $https_base_url . '/' . $public_files_path . '/' . $special_image => $files_path . '/' . $special_image, $files_path . '/example.png' => $red_x_image, 'http://example.com/' . $druplicon => $red_x_image, 'https://example.com/' . $druplicon => $red_x_image, 'javascript:druplicon.png' => $red_x_image, $csrf_path . '/logout' => $red_x_image);
     $comment = array();
     foreach ($images as $image => $converted) {
         // Output the image source as plain text for debugging.
         $comment[] = $image . ':';
         // Hash the image source in a custom test attribute, because it might
         // contain characters that confuse XPath.
         $comment[] = '<img src="' . $image . '" testattribute="' . hash('sha256', $image) . '" />';
     }
     $edit = array('comment_body[0][value]' => implode("\n", $comment));
     $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Save'));
     foreach ($images as $image => $converted) {
         $found = FALSE;
         foreach ($this->xpath('//img[@testattribute="' . hash('sha256', $image) . '"]') as $element) {
             $found = TRUE;
             if ($converted == $red_x_image) {
                 $this->assertEqual((string) $element['src'], $red_x_image);
                 $this->assertEqual((string) $element['alt'], $alt_text);
                 $this->assertEqual((string) $element['title'], $title_text);
                 $this->assertEqual((string) $element['height'], '16');
                 $this->assertEqual((string) $element['width'], '16');
             } else {
                 $this->assertEqual((string) $element['src'], $converted);
             }
         }
         $this->assertTrue($found, format_string('@image was found.', array('@image' => $image)));
     }
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:56,代码来源:FilterHtmlImageSecureTest.php


示例15: testImageItem

 /**
  * Tests using entity fields of the image field type.
  */
 public function testImageItem()
 {
     // Create a test entity with the image field set.
     $entity = EntityTest::create();
     $entity->image_test->target_id = $this->image->id();
     $entity->image_test->alt = $alt = $this->randomMachineName();
     $entity->image_test->title = $title = $this->randomMachineName();
     $entity->name->value = $this->randomMachineName();
     $entity->save();
     $entity = entity_load('entity_test', $entity->id());
     $this->assertTrue($entity->image_test instanceof FieldItemListInterface, 'Field implements interface.');
     $this->assertTrue($entity->image_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
     $this->assertEqual($entity->image_test->target_id, $this->image->id());
     $this->assertEqual($entity->image_test->alt, $alt);
     $this->assertEqual($entity->image_test->title, $title);
     $image = $this->imageFactory->get('public://example.jpg');
     $this->assertEqual($entity->image_test->width, $image->getWidth());
     $this->assertEqual($entity->image_test->height, $image->getHeight());
     $this->assertEqual($entity->image_test->entity->id(), $this->image->id());
     $this->assertEqual($entity->image_test->entity->uuid(), $this->image->uuid());
     // Make sure the computed entity reflects updates to the referenced file.
     file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example-2.jpg');
     $image2 = File::create(['uri' => 'public://example-2.jpg']);
     $image2->save();
     $entity->image_test->target_id = $image2->id();
     $entity->image_test->alt = $new_alt = $this->randomMachineName();
     // The width and height is only updated when width is not set.
     $entity->image_test->width = NULL;
     $entity->save();
     $this->assertEqual($entity->image_test->entity->id(), $image2->id());
     $this->assertEqual($entity->image_test->entity->getFileUri(), $image2->getFileUri());
     $image = $this->imageFactory->get('public://example-2.jpg');
     $this->assertEqual($entity->image_test->width, $image->getWidth());
     $this->assertEqual($entity->image_test->height, $image->getHeight());
     $this->assertEqual($entity->image_test->alt, $new_alt);
     // Check that the image item can be set to the referenced file directly.
     $entity->image_test = $this->image;
     $this->assertEqual($entity->image_test->target_id, $this->image->id());
     // Delete the image and try to save the entity again.
     $this->image->delete();
     $entity = EntityTest::create(array('mame' => $this->randomMachineName()));
     $entity->save();
     // Test image item properties.
     $expected = array('target_id', 'entity', 'alt', 'title', 'width', 'height');
     $properties = $entity->getFieldDefinition('image_test')->getFieldStorageDefinition()->getPropertyDefinitions();
     $this->assertEqual(array_keys($properties), $expected);
     // Test the generateSampleValue() method.
     $entity = EntityTest::create();
     $entity->image_test->generateSampleItems();
     $this->entityValidateAndSave($entity);
     $this->assertEqual($entity->image_test->entity->get('filemime')->value, 'image/jpeg');
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:55,代码来源:ImageItemTest.php


示例16: setUp

 /**
  * {@inheritdoc}
  */
 function setUp()
 {
     parent::setUp();
     $this->langcode = 'de';
     $this->context = 'default';
     file_unmanaged_copy(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     $file = new \stdClass();
     $file->uri = \Drupal::service('file_system')->realpath(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.xx.po');
     $file->langcode = $this->langcode;
     Gettext::fileToDatabase($file, array());
     $this->addLanguage($this->langcode);
     $this->addLanguage('gsw-berne');
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:16,代码来源:LocaleSourceUiTest.php


示例17: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Copy test po files to the translations directory.
     file_unmanaged_copy(__DIR__ . '/../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     file_unmanaged_copy(__DIR__ . '/../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
     $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
     $this->adminUserAccessSiteReports = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'access site reports'));
     $this->drupalLogin($this->adminUser);
     // Enable import of translations. By default this is disabled for automated
     // tests.
     $this->config('locale.settings')->set('translation.import_enabled', TRUE)->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:LocaleImportFunctionalTest.php


示例18: createSampleImage

 /**
  * Given an image style and a wrapper, generate an image.
  */
 function createSampleImage($style, $wrapper)
 {
     static $file;
     if (!isset($file)) {
         $files = $this->drupalGetTestFiles('image');
         $file = reset($files);
     }
     // Make sure we have an image in our wrapper testing file directory.
     $source_uri = file_unmanaged_copy($file->uri, $wrapper . '://');
     // Build the derivative image.
     $derivative_uri = $style->buildUri($source_uri);
     $derivative = $style->createDerivative($source_uri, $derivative_uri);
     return $derivative ? $derivative_uri : FALSE;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:17,代码来源:ImageStyleFlushTest.php


示例19: setUp

 /**
  * {@inheritdoc}
  */
 function setUp()
 {
     parent::setUp();
     $this->langcode = 'de';
     $this->context = 'default';
     \Drupal::service('router.builder')->rebuild();
     $this->installSchema('locale', array('locales_source', 'locales_target'));
     file_unmanaged_copy(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
     $file = new \stdClass();
     $file->uri = \Drupal::service('file_system')->realpath(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.xx.po');
     $file->langcode = $this->langcode;
     Gettext::fileToDatabase($file, array());
     $this->addLanguage('es');
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:17,代码来源:LocaleSourceTest.php


示例20: createFile

 /**
  * Saves a file for an entity and returns the file's ID.
  *
  * @param string $filename
  *   The file name given by the user.
  * @param string $files_path
  *   The file path where the file exists in.
  *
  * @return int
  *   The file ID returned by the File::save() method.
  *
  * @throws \Exception
  *   Throws an exception when the file is not found.
  */
 public function createFile($filename, $files_path)
 {
     $path = rtrim(realpath($files_path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $filename;
     if (!is_file($path)) {
         throw new \Exception("File '{$filename}' was not found in file path '{$files_path}'.");
     }
     // Copy the file into the public files folder and turn it into a File
     // entity before linking it to the collection.
     $uri = 'public://' . $filename;
     $destination = file_unmanaged_copy($path, $uri);
     $file = File::create(['uri' => $destination]);
     $file->save();
     $this->files[$file-& 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_unmanaged_delete函数代码示例发布时间:2022-05-15
下一篇:
PHP file_unlink函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap