本文整理汇总了PHP中Convert::base64url_decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Convert::base64url_decode方法的具体用法?PHP Convert::base64url_decode怎么用?PHP Convert::base64url_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert::base64url_decode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGeneratedImages
/**
* Generate a list of images that were generated from this image
*/
private function getGeneratedImages()
{
$generatedImages = array();
$cachedFiles = array();
$folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . '/';
$cacheDir = Director::getAbsFile($folder . '_resampled/');
if (is_dir($cacheDir)) {
if ($handle = opendir($cacheDir)) {
while (($file = readdir($handle)) !== false) {
// ignore all entries starting with a dot
if (substr($file, 0, 1) != '.' && is_file($cacheDir . $file)) {
$cachedFiles[] = $file;
}
}
closedir($handle);
}
}
$pattern = $this->getFilenamePatterns($this->Name);
foreach ($cachedFiles as $cfile) {
if (preg_match($pattern['FullPattern'], $cfile, $matches)) {
if (Director::fileExists($cacheDir . $cfile)) {
$subFilename = substr($cfile, 0, -1 * strlen($this->Name));
preg_match_all($pattern['GeneratorPattern'], $subFilename, $subMatches, PREG_SET_ORDER);
$generatorArray = array();
foreach ($subMatches as $singleMatch) {
$generatorArray[] = array('Generator' => $singleMatch['Generator'], 'Args' => Convert::base64url_decode($singleMatch['Args']));
}
// Using array_reverse is important, as a cached image will
// have the generators settings in the filename in reversed
// order: the last generator given in the filename is the
// first that was used. Later resizements are prepended
$generatedImages[] = array('FileName' => $cacheDir . $cfile, 'Generators' => array_reverse($generatorArray));
}
}
}
return $generatedImages;
}
示例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)));
}
示例3: getGeneratedImages
/**
* Generate a list of images that were generated from this image
*
* @return array
*/
protected function getGeneratedImages()
{
$generatedImages = array();
$cachedFiles = array();
$folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . '/';
$cacheDir = Director::getAbsFile($folder . '_resampled/');
// Find all paths with the same filename as this Image (the path contains the transformation info)
if (is_dir($cacheDir)) {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cacheDir));
foreach ($files as $path => $file) {
if ($file->getFilename() == $this->Name) {
$cachedFiles[] = $path;
}
}
}
$pattern = $this->getFilenamePatterns($this->Name);
// Reconstruct the image transformation(s) from the format-folder(s) in the path
// (if chained, they contain the transformations in the correct order)
foreach ($cachedFiles as $cf_path) {
if (($pos = stripos($cf_path, '_resampled')) === false) {
continue;
}
$cf_generated = substr($cf_path, $pos + strlen('_resampled'));
preg_match_all($pattern['GeneratorPattern'], $cf_generated, $matches, PREG_SET_ORDER);
$generatorArray = array();
foreach ($matches as $singleMatch) {
$generatorArray[] = array('Generator' => $singleMatch['Generator'], 'Args' => Convert::base64url_decode($singleMatch['Args']) ?: array());
}
$generatedImages[] = array('FileName' => $cf_path, 'Generators' => $generatorArray);
}
return $generatedImages;
}