Skip to content

Commit

Permalink
Merge branch '4.0' of https://github.com/alchemy-fr/Phraseanet into P…
Browse files Browse the repository at this point in the history
…HRAS-1792_4.0.3_version
  • Loading branch information
nmaillat committed Apr 11, 2018
2 parents 3ca0e6e + e5a0b11 commit 4210981
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/Alchemy/Phrasea/Border/Checker/Colorspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\ORM\EntityManager;
use MediaVorus\Media\Document;
use Symfony\Component\Translation\TranslatorInterface;

class Colorspace extends AbstractChecker
Expand All @@ -23,6 +24,7 @@ class Colorspace extends AbstractChecker
const COLORSPACE_RGB = 'rgb';
const COLORSPACE_CMYK = 'cmyk';
const COLORSPACE_GRAYSCALE = 'grayscale';
const COLORSPACE_RGBA = 'rgba';

public function __construct(Application $app, array $options)
{
Expand All @@ -40,6 +42,8 @@ public function check(EntityManager $em, File $file)

if (0 === count($this->colorspaces)) {
$boolean = true; //bypass color if empty array
} elseif ($file->getMedia()->getType() === Document::TYPE_DOCUMENT) {
$boolean = true; //bypass color checker if file is of type document
} elseif (method_exists($file->getMedia(), 'getColorSpace')) {
$colorspace = null;
switch ($file->getMedia()->getColorSpace())
Expand All @@ -54,6 +58,9 @@ public function check(EntityManager $em, File $file)
case \MediaVorus\Media\Image::COLORSPACE_GRAYSCALE:
$colorspace = self::COLORSPACE_GRAYSCALE;
break;
case \MediaVorus\Media\Image::COLORSPACE_RGBA:
$colorspace = self::COLORSPACE_RGBA;
break;
}

$boolean = $colorspace !== null && in_array(strtolower($colorspace), $this->colorspaces);
Expand Down
24 changes: 12 additions & 12 deletions lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected function getConfiguration()
"JPG" => null,
"160px JPG" => array(
Image::OPTION_SIZE => "160",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -236,7 +236,7 @@ protected function getConfiguration()
),
"320 px JPG (thumbnail Phraseanet)" => array(
Image::OPTION_SIZE => "320",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -245,7 +245,7 @@ protected function getConfiguration()
),
"640px JPG" => array(
Image::OPTION_SIZE => "640",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -254,7 +254,7 @@ protected function getConfiguration()
),
"1280px JPG (preview Phraseanet)" => array(
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -263,7 +263,7 @@ protected function getConfiguration()
),
"2560px JPG" => array(
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -273,7 +273,7 @@ protected function getConfiguration()
"PNG" => null,
"160px PNG 8 bits" => array(
Image::OPTION_SIZE => "160",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -282,7 +282,7 @@ protected function getConfiguration()
),
"320px PNG 8 bits" => array(
Image::OPTION_SIZE => "320",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -291,7 +291,7 @@ protected function getConfiguration()
),
"640px PNG 8 bits" => array(
Image::OPTION_SIZE => "640",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -300,7 +300,7 @@ protected function getConfiguration()
),
"1280px PNG 8 bits" => array(
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -309,7 +309,7 @@ protected function getConfiguration()
),
"2560px PNG 8 bits" => array(
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -319,7 +319,7 @@ protected function getConfiguration()
"TIFF" => null,
"1280 TIFF" => array(
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand All @@ -328,7 +328,7 @@ protected function getConfiguration()
),
"2560px TIFF" => array(
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_RESOLUTION => "72",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Alchemy\Phrasea\Model\Entities\Token;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Symfony\Component\Yaml\Parser;

/**
* @group functional
Expand Down Expand Up @@ -95,11 +96,17 @@ public function testCreateDownloadToken()
$data = serialize(['some' => 'data']);
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
$token = $manipulator->createDownloadToken(self::$DI['user'], $data);
$parser = new Parser();
$config = $parser->parse(file_get_contents(__DIR__ . '/../../../../../../config/configuration.yml'));

$this->assertArrayHasKey('registry', $config);
$this->assertArrayHasKey('actions', $config['registry']);
$this->assertArrayHasKey('download-link-validity', $config['registry']['actions']);
$this->assertEquals(24, $config['registry']['actions']['download-link-validity']);

$this->assertSame($data, $token->getData());
$this->assertSame(self::$DI['user'], $token->getUser());
$this->assertSame(TokenManipulator::TYPE_DOWNLOAD, $token->getType());
var_dump($token->getExpiration());
$this->assertDateNear('+24 hours', $token->getExpiration());
}

Expand Down

0 comments on commit 4210981

Please sign in to comment.