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


PHP Convert::base64url_encode方法代码示例

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


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

示例1: testResizedImageInsertion

 public function testResizedImageInsertion()
 {
     $obj = new HtmlEditorFieldTest_Object();
     $editor = new HtmlEditorField('Content');
     /*
      * Following stuff is neccessary to
      *     a) use the proper filename for the image we are referencing
      *     b) not confuse the "existing" filesystem by our test
      */
     $imageFile = $this->objFromFixture('Image', 'example_image');
     $imageFile->Filename = FRAMEWORK_DIR . '/' . $imageFile->Filename;
     $origUpdateFilesystem = Config::inst()->get('File', 'update_filesystem');
     Config::inst()->update('File', 'update_filesystem', false);
     $imageFile->write();
     Config::inst()->update('File', 'update_filesystem', $origUpdateFilesystem);
     /*
      * End of test bet setting
      */
     $editor->setValue('<img src="assets/HTMLEditorFieldTest_example.jpg" width="10" height="20" />');
     $editor->saveInto($obj);
     $parser = new CSSContentParser($obj->Content);
     $xml = $parser->getByXpath('//img');
     $this->assertEquals('', (string) $xml[0]['alt'], 'Alt tags are added by default.');
     $this->assertEquals('', (string) $xml[0]['title'], 'Title tags are added by default.');
     $this->assertEquals(10, (int) $xml[0]['width'], 'Width tag of resized image is set.');
     $this->assertEquals(20, (int) $xml[0]['height'], 'Height tag of resized image is set.');
     $neededFilename = 'assets/_resampled/ResizedImage' . Convert::base64url_encode(array(10, 20)) . '/HTMLEditorFieldTest_example.jpg';
     $this->assertEquals($neededFilename, (string) $xml[0]['src'], 'Correct URL of resized image is set.');
     $this->assertTrue(file_exists(BASE_PATH . DIRECTORY_SEPARATOR . $neededFilename), 'File for resized image exists');
     $this->assertEquals(false, $obj->HasBrokenFile, 'Referenced image file exists.');
 }
开发者ID:hpeide,项目名称:silverstripe-framework,代码行数:31,代码来源:HtmlEditorFieldTest.php

示例2: testBase64url

 /**
  * Tests {@link Convert::base64url_encode()} and {@link Convert::base64url_decode()}
  */
 public function testBase64url()
 {
     $data = 'Wëīrð characters ☺ such as ¤Ø¶÷╬';
     // This requires this test file to have UTF-8 character encoding
     $this->assertEquals($data, Convert::base64url_decode(Convert::base64url_encode($data)));
     $data = 654.423;
     $this->assertEquals($data, Convert::base64url_decode(Convert::base64url_encode($data)));
     $data = true;
     $this->assertEquals($data, Convert::base64url_decode(Convert::base64url_encode($data)));
     $data = array('simple', 'array', '¤Ø¶÷╬');
     $this->assertEquals($data, Convert::base64url_decode(Convert::base64url_encode($data)));
     $data = array('a' => 'associative', 4 => 'array', '☺' => '¤Ø¶÷╬');
     $this->assertEquals($data, Convert::base64url_decode(Convert::base64url_encode($data)));
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:17,代码来源:ConvertTest.php

示例3: testRegenerateImagesWithRenaming

 /**
  * Tests that cached images are regenerated properly after a cached file is renamed with new arguments
  * ToDo: This doesn't seem like something that is worth testing - what is the point of this?
  */
 public function testRegenerateImagesWithRenaming()
 {
     $image = $this->objFromFixture('Image', 'imageWithoutTitle');
     $image_generated = $image->ScaleWidth(200);
     $p = $image_generated->getFullPath();
     $this->assertTrue(file_exists($p), 'Resized image exists after creation call');
     // Encoding of the arguments is duplicated from cacheFilename
     $oldArgumentString = Convert::base64url_encode(array(200));
     $newArgumentString = Convert::base64url_encode(array(300));
     $newPath = str_replace($oldArgumentString, $newArgumentString, $p);
     if (!file_exists(dirname($newPath))) {
         mkdir(dirname($newPath));
     }
     $newRelative = str_replace($oldArgumentString, $newArgumentString, $image_generated->getFileName());
     rename($p, $newPath);
     $this->assertFalse(file_exists($p), 'Resized image does not exist at old path after renaming');
     $this->assertTrue(file_exists($newPath), 'Resized image exists at new path after renaming');
     $this->assertEquals(1, $image->regenerateFormattedImages(), 'Cached images were regenerated in the right number');
     $image_generated_2 = new Image_Cached($newRelative);
     $this->assertEquals(300, $image_generated_2->getWidth(), 'Cached image was regenerated with correct width');
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:25,代码来源:ImageTest.php

示例4: testCacheFilename

 public function testCacheFilename()
 {
     $image = $this->objFromFixture('Image', 'imageWithoutTitle');
     $imageFirst = $image->Pad(200, 200, 'CCCCCC');
     $imageFilename = $imageFirst->getURL();
     // Encoding of the arguments is duplicated from cacheFilename
     $neededPart = 'Pad' . Convert::base64url_encode(array(200, 200, 'CCCCCC'));
     $this->assertContains($neededPart, $imageFilename, 'Filename for cached image is correctly generated');
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:9,代码来源:ImageTest.php

示例5: cacheFilename

 /**
  * Return the filename for the cached image, given its format name and arguments.
  * @param string $format The format name.
  * @return string
  * @throws InvalidArgumentException
  */
 public function cacheFilename($format)
 {
     $args = func_get_args();
     array_shift($args);
     $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/";
     $format = $format . Convert::base64url_encode($args);
     $filename = $format . "-" . $this->Name;
     $patterns = $this->getFilenamePatterns($this->Name);
     if (!preg_match($patterns['FullPattern'], $filename)) {
         throw new InvalidArgumentException('Filename ' . $filename . ' that should be used to cache a resized image is invalid');
     }
     return $folder . "_resampled/" . $filename;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:19,代码来源:Image.php

示例6: cacheFilename

 /**
  * Return the filename for the cached image, given its format name and arguments.
  * @param string $format The format name.
  * @return string
  * @throws InvalidArgumentException
  */
 public function cacheFilename($format)
 {
     $args = func_get_args();
     array_shift($args);
     // Note: $folder holds the *original* file, while the Image we're working with
     // may be a formatted image in a child directory (this happens when we're chaining formats)
     $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/";
     $format = $format . Convert::base64url_encode($args);
     $filename = $format . "/" . $this->Name;
     $pattern = $this->getFilenamePatterns($this->Name);
     // Any previous formats need to be derived from this Image's directory, and prepended to the new filename
     $prepend = array();
     if (($pos = stripos($this->Filename, '_resampled')) !== false) {
         $candidate = substr($this->Filename, $pos + strlen('_resampled'));
         preg_match_all($pattern['GeneratorPattern'], $candidate, $matches, PREG_SET_ORDER);
         foreach ($matches as $formatdir) {
             $prepend[] = $formatdir[0];
         }
     }
     $filename = implode($prepend) . $filename;
     if (!preg_match($pattern['FullPattern'], $filename)) {
         throw new InvalidArgumentException('Filename ' . $filename . ' that should be used to cache a resized image is invalid');
     }
     return $folder . "_resampled/" . $filename;
 }
开发者ID:hpeide,项目名称:silverstripe-framework,代码行数:31,代码来源:Image.php


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