Merge remote-tracking branch 'upstream/master' into 20150306-elastic-indexer

Conflicts:
	bin/console
	bower.json
	composer.json
	composer.lock
	lib/Alchemy/Phrasea/Application.php
	lib/Alchemy/Phrasea/Border/Manager.php
	lib/Alchemy/Phrasea/Controller/Api/V1.php
	lib/Alchemy/Phrasea/Core/PhraseaEvents.php
	lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php
	lib/classes/caption/field.php
	lib/classes/record/Interface.php
	templates/web/prod/index.html.twig
	www/skins/prod/000000/prodcolor.css
This commit is contained in:
Nicolas Le Goff
2015-03-06 14:35:29 +01:00
committed by Mathieu Darse
1078 changed files with 7964 additions and 16363 deletions

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -131,7 +131,9 @@ use Alchemy\Phrasea\Twig\Camelize;
use Alchemy\Phrasea\Twig\BytesConverter;
use Alchemy\Phrasea\Twig\PhraseanetExtension;
use Alchemy\Phrasea\Utilities\CachedTranslator;
use Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider;
use FFMpeg\FFMpegServiceProvider;
use Gedmo\DoctrineExtensions as GedmoExtension;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Neutron\Silex\Provider\ImagineServiceProvider;
@@ -145,6 +147,7 @@ use PHPExiftool\PHPExiftoolServiceProvider;
use Silex\Application as SilexApplication;
use Silex\Application\UrlGeneratorTrait;
use Silex\Application\TranslationTrait;
use Silex\Provider\DoctrineServiceProvider;
use Silex\Provider\FormServiceProvider;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\SessionServiceProvider;
@@ -159,7 +162,6 @@ use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Unoconv\UnoconvServiceProvider;
use XPDF\PdfToText;
use XPDF\XPDFServiceProvider;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -201,116 +203,66 @@ class Application extends SilexApplication
$this->environment = $environment;
$this->setupApplicationPaths($this);
$this['charset'] = 'UTF-8';
mb_internal_encoding($this['charset']);
$this->setupCharset();
$this->setupApplicationPaths();
$this->setupConstants();
$this['debug'] = $this->share(function (Application $app) {
return Application::ENV_PROD !== $app->getEnvironment();
});
if ($this['debug'] === true) {
if ($this['debug']) {
ini_set('log_errors', 'on');
ini_set('error_log', $this['root.path'].'/logs/php_error.log');
}
$this->register(new ConfigurationServiceProvider());
$this->register(new MonologServiceProvider());
$this->setupMonolog();
$this->register(new FilesystemServiceProvider());
$this->register(new CacheServiceProvider());
$this->register(new CacheConnectionServiceProvider());
$this->register(new PhraseanetServiceProvider());
$this->register(new ConfigurationTesterServiceProvider());
$this->register(new ORMServiceProvider());
$this->register(new DoctrineServiceProvider(), $this['dbs.service.conf']);
$this->setupDBAL();
$this->register(new DoctrineOrmServiceProvider(), $this['orm.service.conf']);
$this->setupOrms();
$this->register(new BasketMiddlewareProvider());
$this->register(new TokenMiddlewareProvider());
$this->register(new ApiApplicationMiddlewareProvider());
$this->register(new ACLServiceProvider());
$this->register(new APIServiceProvider());
$this->register(new AuthenticationManagerServiceProvider());
$this->register(new BrowserServiceProvider());
$this->register(new FilesystemServiceProvider());
$this->register(new ConfigurationServiceProvider());
$this->register(new ConfigurationTesterServiceProvider);
$this->register(new ConvertersServiceProvider());
$this->register(new CSVServiceProvider());
$this->register(new RegistrationServiceProvider());
$this->register(new CacheServiceProvider());
$this->register(new CacheConnectionServiceProvider());
$this->register(new ImagineServiceProvider());
$this->setUpImagine();
$this->register(new JMSSerializerServiceProvider());
$this->register(new FFMpegServiceProvider());
$this->register(new FeedServiceProvider());
$this->register(new FtpServiceProvider());
$this->register(new GeonamesServiceProvider());
$this->register(new StatusServiceProvider());
$this['geonames.server-uri'] = $this->share(function (Application $app) {
return $app['conf']->get(['registry', 'webservices', 'geonames-server'], 'http://geonames.alchemyasp.com/');
});
$this->setupGeonames();
$this->register(new MediaAlchemystServiceProvider());
$this['media-alchemyst.configuration'] = $this->share(function (Application $app) {
$configuration = [];
foreach ([
'swftools.pdf2swf.binaries' => 'pdf2swf_binary',
'swftools.swfrender.binaries' => 'swf_render_binary',
'swftools.swfextract.binaries' => 'swf_extract_binary',
'unoconv.binaries' => 'unoconv_binary',
'mp4box.binaries' => 'mp4box_binary',
'gs.binaries' => 'ghostscript_binary',
'ffmpeg.ffmpeg.binaries' => 'ffmpeg_binary',
'ffmpeg.ffprobe.binaries' => 'ffprobe_binary',
'ffmpeg.ffmpeg.timeout' => 'ffmpeg_timeout',
'ffmpeg.ffprobe.timeout' => 'ffprobe_timeout',
'gs.timeout' => 'gs_timeout',
'mp4box.timeout' => 'mp4box_timeout',
'swftools.timeout' => 'swftools_timeout',
'unoconv.timeout' => 'unoconv_timeout',
] as $parameter => $key) {
if ($this['conf']->has(['main', 'binaries', $key])) {
$configuration[$parameter] = $this['conf']->get(['main', 'binaries', $key]);
}
}
$configuration['ffmpeg.threads'] = $app['conf']->get(['registry', 'executables', 'ffmpeg-threads']) ?: null;
$configuration['imagine.driver'] = $app['conf']->get(['registry', 'executables', 'imagine-driver']) ?: null;
return $configuration;
});
$this['media-alchemyst.logger'] = $this->share(function (Application $app) {
return $app['monolog'];
});
$this->setupMediaAlchemyst();
$this->register(new MediaVorusServiceProvider());
$this->register(new MonologServiceProvider());
$this['monolog.name'] = 'Phraseanet logger';
$this['monolog.handler'] = $this->share(function () {
return new NullHandler();
});
$this['monolog'] = $this->share($this->extend('monolog', function (Logger $monolog) {
$monolog->pushProcessor(new IntrospectionProcessor());
return $monolog;
}));
$this->register(new MP4BoxServiceProvider());
$this->register(new NotificationDelivererServiceProvider());
$this->register(new ORMServiceProvider());
$this->register(new RepositoriesServiceProvider());
$this->register(new ManipulatorServiceProvider());
$this->register(new InstallerServiceProvider());
$this->register(new PhraseanetServiceProvider());
$this->register(new PhraseaVersionServiceProvider());
$this->register(new PHPExiftoolServiceProvider());
$this->register(new RandomGeneratorServiceProvider());
$this->register(new ReCaptchaServiceProvider());
$this->register(new SubdefServiceProvider());
$this->register(new ZippyServiceProvider());
$this['recaptcha.public-key'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
return $app['conf']->get(['registry', 'webservices', 'recaptcha-public-key']);
}
});
$this['recaptcha.private-key'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
return $app['conf']->get(['registry', 'webservices', 'recaptcha-private-key']);
}
});
$this->setupRecaptacha();
if ($this['configuration.store']->isSetup()) {
$this->register(new SearchEngineServiceProvider());
@@ -322,21 +274,11 @@ class Application extends SilexApplication
'session.test' => $this->getEnvironment() === static::ENV_TEST,
'session.storage.options' => ['cookie_lifetime' => 0]
]);
$this['session.storage.test'] = $this->share(function ($app) {
return new MockArraySessionStorage();
});
$this['session.storage.handler'] = $this->share(function ($app) {
if (!$this['phraseanet.configuration-tester']->isInstalled()) {
return new NullSessionHandler();
}
return $this['session.storage.handler.factory']->create($app['conf']);
});
$this->setupSession();
$this->register(new SerializerServiceProvider());
$this->register(new ServiceControllerServiceProvider());
$this->register(new SwiftmailerServiceProvider());
$this->setupSwiftMailer();
$this->register(new TasksServiceProvider());
$this->register(new TemporaryFilesystemServiceProvider());
$this->register(new TokensServiceProvider());
@@ -345,179 +287,39 @@ class Application extends SilexApplication
'cache' => $this->share(function($app) {return $app['cache.path'].'/twig';}),
],
]);
$this->setupTwig();
$this->register(new TranslationServiceProvider(), [
'locale_fallbacks' => ['fr'],
'translator.cache-options' => [
'debug' => $this['debug'],
'cache_dir' => $this->share(function($app) {return $app['cache.path'].'/translations';}),
'cache_dir' => $this->share(function($app) {
return $app['cache.path'].'/translations';
}),
],
]);
$this['translator'] = $this->share($this->extend('translator', function (CachedTranslator $translator, $app) {
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.fr.xlf', 'fr', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.fr.xlf', 'fr', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.en.xlf', 'en', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.en.xlf', 'en', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.de.xlf', 'de', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.de.xlf', 'de', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.nl.xlf', 'nl', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.nl.xlf', 'nl', 'validators');
return $translator;
}));
$this->setupTranslation();
$this->register(new FormServiceProvider());
$this['form.type.extensions'] = $this->share($this->extend('form.type.extensions', function ($extensions) {
$extensions[] = new HelpTypeExtension();
return $extensions;
}));
$this->setupTwig();
$this->setupForm();
$this->register(new UnoconvServiceProvider());
$this->register(new UrlGeneratorServiceProvider());
$this->setupUrlGenerator();
$this->register(new UnicodeServiceProvider());
$this->register(new ValidatorServiceProvider());
$this->register(new XPDFServiceProvider());
$this->setupXpdf();
$this->register(new FileServeServiceProvider());
$this->register(new ManipulatorServiceProvider());
$this->register(new PluginServiceProvider());
$this->register(new PhraseaEventServiceProvider());
$this->register(new ContentNegotiationServiceProvider());
$this->register(new LocaleServiceProvider());
$this->setupEventDispatcher();
$this['phraseanet.exception_handler'] = $this->share(function ($app) {
$handler = PhraseaExceptionHandler::register($app['debug']);
$handler->setTranslator($app['translator']);
return $handler;
});
$this['swiftmailer.transport'] = $this->share(function ($app) {
if ($app['conf']->get(['registry', 'email', 'smtp-enabled'])) {
$transport = new \Swift_Transport_EsmtpTransport(
$app['swiftmailer.transport.buffer'],
[$app['swiftmailer.transport.authhandler']],
$app['swiftmailer.transport.eventdispatcher']
);
$encryption = null;
if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tls'])) {
$encryption = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);
}
$options = $app['swiftmailer.options'] = array_replace([
'host' => $app['conf']->get(['registry', 'email', 'smtp-host']),
'port' => $app['conf']->get(['registry', 'email', 'smtp-port']),
'username' => $app['conf']->get(['registry', 'email', 'smtp-user']),
'password' => $app['conf']->get(['registry', 'email', 'smtp-password']),
'encryption' => $encryption,
'auth_mode' => null,
], $app['swiftmailer.options']);
$transport->setHost($options['host']);
$transport->setPort($options['port']);
// tls or ssl
$transport->setEncryption($options['encryption']);
if ($app['conf']->get(['registry', 'email', 'smtp-auth-enabled'])) {
$transport->setUsername($options['username']);
$transport->setPassword($options['password']);
$transport->setAuthMode($options['auth_mode']);
}
} else {
$transport = new \Swift_Transport_MailTransport(
new \Swift_Transport_SimpleMailInvoker(),
$app['swiftmailer.transport.eventdispatcher']
);
}
return $transport;
});
$this['imagine.factory'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'executables', 'imagine-driver']) != '') {
return $app['conf']->get(['registry', 'executables', 'imagine-driver']);
}
if (class_exists('\Gmagick')) {
return 'gmagick';
}
if (class_exists('\Imagick')) {
return 'imagick';
}
if (extension_loaded('gd')) {
return 'gd';
}
throw new \RuntimeException('No Imagine driver available');
});
$app = $this;
$this['phraseanet.logger'] = $this->protect(function ($databox) use ($app) {
try {
return \Session_Logger::load($app, $databox);
} catch (\Exception_Session_LoggerNotFound $e) {
return \Session_Logger::create($app, $databox, $app['browser']);
}
});
$this['date-formatter'] = $this->share(function (Application $app) {
return new \phraseadate($app);
});
$this['xpdf.pdftotext'] = $this->share(
$this->extend('xpdf.pdftotext', function (PdfToText $pdftotext, Application $app) {
if ($app['conf']->get(['registry', 'executables', 'pdf-max-pages'])) {
$pdftotext->setPageQuantity($app['conf']->get(['registry', 'executables', 'pdf-max-pages']));
}
return $pdftotext;
})
);
$this['dispatcher'] = $this->share(
$this->extend('dispatcher', function ($dispatcher, Application $app) {
$dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128);
$dispatcher->addSubscriber($app['phraseanet.logout-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.locale-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.content-negotiation-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']);
$dispatcher->addSubscriber(new PhraseaInstallSubscriber($app));
$dispatcher->addSubscriber(new FeedEntrySubscriber($app));
$dispatcher->addSubscriber(new RegistrationSubscriber($app));
$dispatcher->addSubscriber(new BridgeSubscriber($app));
$dispatcher->addSubscriber(new ExportSubscriber($app));
$dispatcher->addSubscriber(new OrderSubscriber($app));
$dispatcher->addSubscriber(new BasketSubscriber($app));
$dispatcher->addSubscriber(new LazaretSubscriber($app));
$dispatcher->addSubscriber(new ValidationSubscriber($app));
return $dispatcher;
})
);
$this['log.channels'] = ['monolog', 'task-manager.logger'];
$this->register(new LocaleServiceProvider());
$this->mount('/include/minify/', new Minifier());
$this->mount('/permalink/', new Permalink());
$this->mount('/lightbox/', new Lightbox());
$app['plugins.directory'] = $app->share(function () {
$dir = __DIR__ . '/../../../plugins';
if (is_dir($dir)) {
return realpath($dir);
}
return $dir;
});
}
/**
@@ -526,7 +328,7 @@ class Application extends SilexApplication
public function loadPlugins()
{
call_user_func(function ($app) {
require $app['plugins.directory'] . '/services.php';
require $app['plugin.path'] . '/services.php';
}, $this);
}
@@ -575,40 +377,13 @@ class Application extends SilexApplication
return $this->redirect($this->url($route, $parameters));
}
public function addUTF8Charset(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$event->getResponse()->setCharset('UTF-8');
}
private function setupUrlGenerator()
{
$this['url_generator'] = $this->share($this->extend('url_generator', function ($urlGenerator, $app) {
if ($app['configuration.store']->isSetup()) {
$data = parse_url($app['conf']->get('servername'));
if (isset($data['scheme'])) {
$urlGenerator->getContext()->setScheme($data['scheme']);
}
if (isset($data['host'])) {
$urlGenerator->getContext()->setHost($data['host']);
}
}
return $urlGenerator;
}));
}
public function setupTwig()
{
$this['twig'] = $this->share(
$this->extend('twig', function ($twig, $app) {
$twig->setCache($app['cache.path'].'/twig');
$paths = require $app['plugins.directory'] . '/twig-paths.php';
$paths = require $app['plugin.path'] . '/twig-paths.php';
if ($app['browser']->isTablet() || $app['browser']->isMobile()) {
$paths[] = $app['root.path'] . '/config/templates/mobile';
@@ -832,6 +607,9 @@ class Application extends SilexApplication
return [];
}
/**
* Mount all controllers
*/
public function bindRoutes()
{
$this->mount('/', new Root());
@@ -898,6 +676,11 @@ class Application extends SilexApplication
$this->mount('/thesaurus', new Thesaurus());
$this->mount('/xmlhttp', new ThesaurusXMLHttp());
$this->mount('/include/minify/', new Minifier());
$this->mount('/permalink/', new Permalink());
$this->mount('/lightbox/', new Lightbox());
}
/**
@@ -920,38 +703,44 @@ class Application extends SilexApplication
return static::$flashTypes;
}
private function setupApplicationPaths(Application $app)
private function setupApplicationPaths()
{
// app root path
$this['root.path'] = realpath(__DIR__ . '/../../..');
// temporary resources default path such as download zip, quarantined documents etc ..
$this['tmp.path'] = $this['root.path'].'/tmp';
// plugin path
$this['plugin.path'] = $dir = $this['root.path'].'/plugins';
// thumbnails path
$this['thumbnail.path'] = $dir = $this['root.path'].'/www/thumbnails';
// cache path for dev env
$this['cache.dev.path'] = $app->share(function() use ($app) {
$path = sys_get_temp_dir().'/'.md5($app['root.path']);
$this['cache.dev.path'] = $this->share(function() {
$path = sys_get_temp_dir().'/'.md5($this['root.path']);
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
// cache path (twig, minify, translations, configuration, doctrine metas serializer metas, profiler etc ...)
$this['cache.path'] = $app->share(function() use ($app) {
// if ($app->getEnvironment() !== Application::ENV_PROD) {
$this['cache.path'] = $this->share(function() {
// if ($this->getEnvironment() !== Application::ENV_PROD) {
// return $this['cache.dev.path'];
// }
$path = $app['root.path'].'/cache';
if ($app['phraseanet.configuration']->isSetup()) {
$path = $app['conf']->get(['main', 'storage', 'cache'], $path);
$defaultPath = $path = $this['root.path'].'/cache';
if ($this['phraseanet.configuration']->isSetup()) {
$path = $this['conf']->get(['main', 'storage', 'cache'], $path);
}
$path = $path ?: $defaultPath;
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
$app['cache.paths'] = $app->share(function() use ($app) {
$this['cache.paths'] = $this->share(function() {
return array(
self::ENV_DEV => $this['cache.path'],
self::ENV_TEST => $this['cache.path'],
@@ -960,51 +749,357 @@ class Application extends SilexApplication
});
// log path
$this['log.path'] = $app->share(function() use ($app) {
$path = $this['root.path'].'/logs';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'log'], $path);
$this['log.path'] = $this->share(function() {
$defaultPath = $path = $this['root.path'].'/logs';
if ($this['phraseanet.configuration']->isSetup()) {
return $this['conf']->get(['main', 'storage', 'log'], $path);
}
$path = $path ?: $defaultPath;
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
// temporary download file path (zip file)
$this['tmp.download.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/download';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'download'], $path);
$this['tmp.download.path'] = $this->share(function() {
$defaultPath = $path = $this['tmp.path'].'/download';
if ($this['phraseanet.configuration']->isSetup()) {
return $this['conf']->get(['main', 'storage', 'download'], $path);
}
$path = $path ?: $defaultPath;
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
// quarantined file path
$this['tmp.lazaret.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/lazaret';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'quarantine'], $path);
$this['tmp.lazaret.path'] = $this->share(function() {
$defaultPath = $path = $this['tmp.path'].'/lazaret';
if ($this['phraseanet.configuration']->isSetup()) {
return $this['conf']->get(['main', 'storage', 'quarantine'], $path);
}
$path = $path ?: $defaultPath;
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
// document caption file path
$this['tmp.caption.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/caption';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'caption'], $path);
$this['tmp.caption.path'] = $this->share(function() {
$defaultPath = $path = $this['tmp.path'].'/caption';
if ($this['phraseanet.configuration']->isSetup()) {
return $this['conf']->get(['main', 'storage', 'caption'], $path);
}
$path = $path ?: $defaultPath;
// ensure path is created
$app['filesystem']->mkdir($path);
$this['filesystem']->mkdir($path);
return $path;
});
}
private function setupXpdf()
{
$this['xpdf.pdftotext'] = $this->share(
$this->extend('xpdf.pdftotext', function (PdfToText $pdftotext, Application $app) {
if ($app['conf']->get(['registry', 'executables', 'pdf-max-pages'])) {
$pdftotext->setPageQuantity($app['conf']->get(['registry', 'executables', 'pdf-max-pages']));
}
return $pdftotext;
})
);
}
private function setupForm()
{
$this['form.type.extensions'] = $this->share($this->extend('form.type.extensions', function ($extensions, Application $app) {
$extensions[] = new HelpTypeExtension();
return $extensions;
}));
}
private function setUpImagine()
{
$this['imagine.factory'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'executables', 'imagine-driver']) != '') {
return $app['conf']->get(['registry', 'executables', 'imagine-driver']);
}
if (class_exists('\Gmagick')) {
return 'gmagick';
}
if (class_exists('\Imagick')) {
return 'imagick';
}
if (extension_loaded('gd')) {
return 'gd';
}
throw new \RuntimeException('No Imagine driver available');
});
}
private function setupTranslation()
{
$this['translator'] = $this->share($this->extend('translator', function (CachedTranslator $translator, Application $app) {
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.fr.xlf', 'fr', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.fr.xlf', 'fr', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.en.xlf', 'en', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.en.xlf', 'en', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.de.xlf', 'de', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.de.xlf', 'de', 'validators');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/messages.nl.xlf', 'nl', 'messages');
$translator->addResource('xlf', __DIR__.'/../../../resources/locales/validators.nl.xlf', 'nl', 'validators');
return $translator;
}));
}
private function setupOrms()
{
$this['orm.ems'] = $this->share($this->extend('orm.ems', function ($ems, $app) {
GedmoExtension::registerAnnotations();
foreach ($ems->keys() as $key) {
$app['orm.annotation.register']($key);
$connection = $ems[$key]->getConnection();
$app['connection.pool.manager']->add($connection);
$types = $app['orm.ems.options'][$key]['types'];
$app['dbal.type.register']($connection, $types);
}
return $ems;
}));
}
private function setupSession()
{
$this['session.storage.test'] = $this->share(function (Application $app) {
return new MockArraySessionStorage();
});
$this['session.storage.handler'] = $this->share(function (Application $app) {
if (!$this['phraseanet.configuration-tester']->isInstalled()) {
return new NullSessionHandler();
}
return $this['session.storage.handler.factory']->create($app['conf']);
});
}
private function setupRecaptacha()
{
$this['recaptcha.public-key'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
return $app['conf']->get(['registry', 'webservices', 'recaptcha-public-key']);
}
});
$this['recaptcha.private-key'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'webservices', 'captcha-enabled'])) {
return $app['conf']->get(['registry', 'webservices', 'recaptcha-private-key']);
}
});
}
private function setupGeonames()
{
$this['geonames.server-uri'] = $this->share(function (Application $app) {
return $app['conf']->get(['registry', 'webservices', 'geonames-server'], 'http://geonames.alchemyasp.com/');
});
}
private function setupDBAL()
{
$this['dbs.config'] = $this->share($this->extend('dbs.config', function ($configs, $app) {
if ($app->getEnvironment() !== self::ENV_DEV) {
return $configs;
}
foreach($configs->keys() as $service) {
$app['dbal.config.register.loggers']($configs[$service]);
}
return $configs;
}));
$this['dbs.event_manager'] = $this->share($this->extend('dbs.event_manager', function ($eventManagers, $app) {
foreach ($eventManagers->keys() as $name) {
$app['dbal.evm.register.listeners']($eventManagers[$name]);
}
return $eventManagers;
}));
}
private function setupMediaAlchemyst()
{
$this['media-alchemyst.configuration'] = $this->share(function (Application $app) {
$configuration = [];
foreach ([
'swftools.pdf2swf.binaries' => 'pdf2swf_binary',
'swftools.swfrender.binaries' => 'swf_render_binary',
'swftools.swfextract.binaries' => 'swf_extract_binary',
'unoconv.binaries' => 'unoconv_binary',
'mp4box.binaries' => 'mp4box_binary',
'gs.binaries' => 'ghostscript_binary',
'ffmpeg.ffmpeg.binaries' => 'ffmpeg_binary',
'ffmpeg.ffprobe.binaries' => 'ffprobe_binary',
'ffmpeg.ffmpeg.timeout' => 'ffmpeg_timeout',
'ffmpeg.ffprobe.timeout' => 'ffprobe_timeout',
'gs.timeout' => 'gs_timeout',
'mp4box.timeout' => 'mp4box_timeout',
'swftools.timeout' => 'swftools_timeout',
'unoconv.timeout' => 'unoconv_timeout',
] as $parameter => $key) {
if ($this['conf']->has(['main', 'binaries', $key])) {
$configuration[$parameter] = $this['conf']->get(['main', 'binaries', $key]);
}
}
$configuration['ffmpeg.threads'] = $app['conf']->get(['registry', 'executables', 'ffmpeg-threads']) ?: null;
$configuration['imagine.driver'] = $app['conf']->get(['registry', 'executables', 'imagine-driver']) ?: null;
return $configuration;
});
$this['media-alchemyst.logger'] = $this->share(function (Application $app) {
return $app['monolog'];
});
}
private function setupUrlGenerator()
{
$this['url_generator'] = $this->share($this->extend('url_generator', function ($urlGenerator, Application $app) {
if ($app['configuration.store']->isSetup()) {
$data = parse_url($app['conf']->get('servername'));
if (isset($data['scheme'])) {
$urlGenerator->getContext()->setScheme($data['scheme']);
}
if (isset($data['host'])) {
$urlGenerator->getContext()->setHost($data['host']);
}
}
return $urlGenerator;
}));
}
private function setupSwiftMailer()
{
$this['swiftmailer.transport'] = $this->share(function (Application $app) {
if ($app['conf']->get(['registry', 'email', 'smtp-enabled'])) {
$transport = new \Swift_Transport_EsmtpTransport(
$app['swiftmailer.transport.buffer'],
[$app['swiftmailer.transport.authhandler']],
$app['swiftmailer.transport.eventdispatcher']
);
$encryption = null;
if (in_array($app['conf']->get(['registry', 'email', 'smtp-secure-mode']), ['ssl', 'tls'])) {
$encryption = $app['conf']->get(['registry', 'email', 'smtp-secure-mode']);
}
$options = $app['swiftmailer.options'] = array_replace([
'host' => $app['conf']->get(['registry', 'email', 'smtp-host']),
'port' => $app['conf']->get(['registry', 'email', 'smtp-port']),
'username' => $app['conf']->get(['registry', 'email', 'smtp-user']),
'password' => $app['conf']->get(['registry', 'email', 'smtp-password']),
'encryption' => $encryption,
'auth_mode' => null,
], $app['swiftmailer.options']);
$transport->setHost($options['host']);
$transport->setPort($options['port']);
// tls or ssl
$transport->setEncryption($options['encryption']);
if ($app['conf']->get(['registry', 'email', 'smtp-auth-enabled'])) {
$transport->setUsername($options['username']);
$transport->setPassword($options['password']);
$transport->setAuthMode($options['auth_mode']);
}
} else {
$transport = new \Swift_Transport_MailTransport(
new \Swift_Transport_SimpleMailInvoker(),
$app['swiftmailer.transport.eventdispatcher']
);
}
return $transport;
});
}
private function setupMonolog()
{
$this['monolog.name'] = 'phraseanet';
$this['monolog.handler'] = $this->share(function () {
return new NullHandler();
});
$this['monolog'] = $this->share($this->extend('monolog', function (Logger $logger) {
$logger->pushProcessor(new IntrospectionProcessor());
return $logger;
}));
}
private function setupEventDispatcher()
{
$this['dispatcher'] = $this->share(
$this->extend('dispatcher', function ($dispatcher, Application $app) {
//$dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128);
$dispatcher->addSubscriber($app['phraseanet.logout-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.locale-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.content-negotiation-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.record-edit-subscriber']);
$dispatcher->addSubscriber(new PhraseaInstallSubscriber($app));
$dispatcher->addSubscriber(new FeedEntrySubscriber($app));
$dispatcher->addSubscriber(new RegistrationSubscriber($app));
$dispatcher->addSubscriber(new BridgeSubscriber($app));
$dispatcher->addSubscriber(new ExportSubscriber($app));
$dispatcher->addSubscriber(new OrderSubscriber($app));
$dispatcher->addSubscriber(new BasketSubscriber($app));
$dispatcher->addSubscriber(new LazaretSubscriber($app));
$dispatcher->addSubscriber(new ValidationSubscriber($app));
return $dispatcher;
})
);
}
private function setupConstants()
{
if (!defined('JETON_MAKE_SUBDEF')) {
define('JETON_MAKE_SUBDEF', 0x01);
}
if (!defined('JETON_WRITE_META_DOC')) {
define('JETON_WRITE_META_DOC', 0x02);
}
if (!defined('JETON_WRITE_META_SUBDEF')) {
define('JETON_WRITE_META_SUBDEF', 0x04);
}
if (!defined('JETON_WRITE_META')) {
define('JETON_WRITE_META', 0x06);
}
}
private function setupCharset()
{
$this['charset'] = 'UTF-8';
mb_internal_encoding($this['charset']);
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -12,6 +12,9 @@
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Minifier;
use Alchemy\Phrasea\Controller\Permalink;
use Alchemy\Phrasea\Controller\Datafiles;
use Alchemy\Phrasea\Core\Event\Subscriber\ApiCorsSubscriber;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Controller\Api\Oauth2;
@@ -51,7 +54,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
$priorities = array('application/json', 'application/yaml', 'text/yaml', 'text/javascript', 'application/javascript');
foreach (V1::$extendedContentTypes['json'] as $priorities[]);
foreach (V1::$extendedContentTypes['yaml'] as $priorities[]);
$format = $app['format.negociator']->getBest($request->headers->get('accept') ,$priorities);
$format = $app['format.negociator']->getBest($request->headers->get('accept', 'application/json') ,$priorities);
// throw unacceptable http error if API can not handle asked format
if (null === $format) {
@@ -107,7 +110,10 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
});
$app->mount('/api/oauthv2', new Oauth2());
$app->mount('/datafiles/', new Datafiles());
$app->mount('/api/v1', new V1());
$app->mount('/permalink/', new Permalink());
$app->mount('/include/minify/', new Minifier());
$app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, PhraseaApplication $app) {
$dispatcher->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator']));

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -68,7 +68,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
if ($app['phraseanet.configuration-tester']->isInstalled()) {
$app->register(new DoctrineProfilerServiceProvider());
$app['db'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getConnection();
return $app['orm.em']->getConnection();
});
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Border\Checker\CheckerInterface;
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
use Alchemy\Phrasea\Media\Subdef\OptionType\Boolean;
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
@@ -80,7 +81,7 @@ class Manager
* @param type $forceBehavior Force a behavior, one of the self::FORCE_* constant
* @return int One of the self::RECORD_CREATED or self::LAZARET_CREATED constants
*/
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null)
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null, $nosubdef = false)
{
$visa = $this->getVisa($file);
@@ -93,7 +94,7 @@ class Manager
$this->addMediaAttributes($file);
$element = $this->createRecord($file);
$element = $this->createRecord($file, $nosubdef);
$code = self::RECORD_CREATED;
} else {
@@ -128,7 +129,7 @@ class Manager
$visa = new Visa();
foreach ($this->checkers as $checker) {
$visa->addResponse($checker->check($this->app['EM'], $file));
$visa->addResponse($checker->check($this->app['orm.em'], $file));
}
return $visa;
@@ -229,10 +230,9 @@ class Manager
* @param File $file The package file
* @return \record_adater
*/
protected function createRecord(File $file)
protected function createRecord(File $file, $nosubdef=false)
{
$element = \record_adapter::createFromFile($file, $this->app);
$date = new \DateTime();
$file->addAttribute(
@@ -303,7 +303,9 @@ class Manager
$this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element);
$element->rebuild_subdefs();
if(!$nosubdef) {
$element->rebuild_subdefs();
}
return $element;
}
@@ -358,7 +360,7 @@ class Manager
$lazaretFile->setSession($session);
$this->app['EM']->persist($lazaretFile);
$this->app['orm.em']->persist($lazaretFile);
foreach ($file->getAttributes() as $fileAttribute) {
$attribute = new LazaretAttribute();
@@ -367,7 +369,7 @@ class Manager
$attribute->setLazaretFile($lazaretFile);
$lazaretFile->addAttribute($attribute);
$this->app['EM']->persist($attribute);
$this->app['orm.em']->persist($attribute);
}
foreach ($visa->getResponses() as $response) {
@@ -379,11 +381,11 @@ class Manager
$lazaretFile->addCheck($check);
$this->app['EM']->persist($check);
$this->app['orm.em']->persist($check);
}
}
$this->app['EM']->flush();
$this->app['orm.em']->flush();
return $lazaretFile;
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -137,7 +137,7 @@ class CLI extends Application
parent::loadPlugins();
call_user_func(function ($cli) {
require $cli['plugins.directory'] . '/commands.php';
require $cli['plugin.path'] . '/commands.php';
}, $this);
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -46,7 +46,7 @@ class Factory
$cache = $this->createMemcache($options);
break;
case 'memcached':
case 'memcachecached':
case 'memcachedcache':
$cache = $this->createMemcached($options);
break;
case 'redis':

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -38,9 +38,6 @@ class BuildMissingSubdefs extends Command
$n = 0;
foreach ($this->container['phraseanet.appbox']->get_databoxes() as $databox) {
$subdefStructure = $databox->get_subdef_structure();
$sql = 'SELECT record_id FROM record WHERE parent_record_id = 0';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
@@ -50,38 +47,14 @@ class BuildMissingSubdefs extends Command
foreach ($rs as $row) {
$record = $databox->get_record($row['record_id']);
try {
$record->get_hd_file();
} catch (FileNotFoundException $e) {
continue;
}
$wanted_subdefs = $record->get_missing_subdefs();
$group = $subdefStructure->getSubdefGroup($record->get_type());
if (count($wanted_subdefs) > 0) {
$record->generate_subdefs($databox, $this->container, $wanted_subdefs);
if ($group) {
foreach ($group as $subdef) {
$todo = false;
if ( ! $record->has_subdef($subdef->get_name())) {
$todo = true;
}
if (in_array($subdef->get_name(), ['preview', 'thumbnail', 'thumbnailgif'])) {
try {
$sub = $record->get_subdef($subdef->get_name());
if ( ! $sub->is_physically_present()) {
$todo = true;
}
} catch (\Exception_Media_SubdefNotFound $e) {
$todo = true;
}
}
if ($todo) {
$this->container['subdef.generator']->generateSubdefs($record, [$subdef->get_name()]);
$this->container['monolog']->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id());
$n ++;
}
foreach ($wanted_subdefs as $subdef) {
$this->container['monolog']->addInfo("generate " .$subdef . " for record " . $record->get_record_id());
$n ++;
}
}

View File

@@ -0,0 +1,196 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Command;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\SQLParserUtils;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class BuildSubdefs extends Command
{
/**
* Constructor
*/
public function __construct($name = null)
{
parent::__construct($name);
$this->setDescription('Build subviews for given subview names and record types');
$this->addArgument('databox', InputArgument::REQUIRED, 'The databox id');
$this->addArgument('type', InputArgument::REQUIRED, 'Types of the document to rebuild');
$this->addArgument('subdefs', InputArgument::REQUIRED, 'Names of sub-definition to re-build');
$this->addOption('max_record', 'max', InputOption::VALUE_OPTIONAL, 'Max record id');
$this->addOption('min_record', 'min', InputOption::VALUE_OPTIONAL, 'Min record id');
$this->addOption('with-substitution', 'wsubstit', InputOption::VALUE_NONE, 'Regenerate subdefs for substituted records as well');
$this->addOption('substitution-only', 'substito', InputOption::VALUE_NONE, 'Regenerate subdefs for substituted records only');
return $this;
}
/**
* {@inheritdoc}
*/
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$availableTypes = array('document', 'audio', 'video', 'image', 'flash', 'map');
$typesOption = $input->getArgument('type');
$recordsType = explode(',', $typesOption);
$recordsType = array_filter($recordsType, function($type) use($availableTypes) {
return in_array($type, $availableTypes);
});
if (count($recordsType) === 0) {
$output->write(sprintf('Invalid records type provided %s', implode(', ', $availableTypes)));
return;
}
$subdefsOption = $input->getArgument('subdefs');
$subdefsName = explode(',', $subdefsOption);
if (count($subdefsOption) === 0) {
$output->write('No subdef options provided');
return;
}
$sqlCount = "
SELECT COUNT(DISTINCT(r.record_id)) AS nb_records
FROM record r
INNER JOIN subdef s
ON (r.record_id = s.record_id)
WHERE s.name IN (?)
AND r.type IN (?)
";
$types = array(Connection::PARAM_STR_ARRAY, Connection::PARAM_STR_ARRAY);
$params = array($subdefsName, $recordsType);
if (null !== $min = $input->getOption('min_record')) {
$sqlCount .= " AND (r.record_id >= ?)";
$params[] = (int) $min;
$types[] = \PDO::PARAM_INT;
}
if (null !== $max = $input->getOption('max_record')) {
$sqlCount .= " AND (r.record_id <= ?)";
$params[] = (int) $max;
$types[] = \PDO::PARAM_INT;
}
$substitutionOnly = $input->getOption('substitution-only');
$withSubstitution = $input->getOption('with-substitution');
if (false === $withSubstitution) {
if (true === $substitutionOnly) {
$sqlCount .= " AND (s.substit = 1)";
} else {
$sqlCount .= " AND (s.substit = 0)";
}
} elseif ($substitutionOnly) {
throw new InvalidArgumentException('Conflict, you can not ask for --substituion-only && --with-substitution parameters at the same time');
}
list($sqlCount, $stmtParams) = SQLParserUtils::expandListParameters($sqlCount, $params, $types);
$databox = $this->container['phraseanet.appbox']->get_databox($input->getArgument('databox'));
$connection = $databox->get_connection();
$stmt = $connection->prepare($sqlCount);
$stmt->execute($stmtParams);
$row = $stmt->fetch();
$totalRecords = $row['nb_records'];
if ($totalRecords === 0) {
return;
}
$progress = $this->getHelperSet()->get('progress');
$progress->start($output, $totalRecords);
$progress->display();
$sql = "
SELECT DISTINCT(r.record_id)
FROM record r
INNER JOIN subdef s
ON (r.record_id = s.record_id)
WHERE s.name IN (?)
AND r.type IN (?)
";
$types = array(Connection::PARAM_STR_ARRAY, Connection::PARAM_STR_ARRAY);
$params = array($subdefsName, $recordsType);
if ($min) {
$sql .= " AND (r.record_id >= ?)";
$params[] = (int) $min;
$types[] = \PDO::PARAM_INT;
}
if ($max) {
$sql .= " AND (r.record_id <= ?)";
$params[] = (int) $max;
$types[] = \PDO::PARAM_INT;
}
if (false === $withSubstitution) {
if (true === $substitutionOnly) {
$sql .= " AND (s.substit = 1)";
} else {
$sql .= " AND (s.substit = 0)";
}
}
list($sql, $stmtParams) = SQLParserUtils::expandListParameters($sql, $params, $types);
$connection = $databox->get_connection();
$stmt = $connection->prepare($sql);
$stmt->execute($stmtParams);
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$output->write(sprintf(' (#%s)', $row['record_id']));
$record = new \record_adapter($this->container, $databox->get_sbas_id(), $row['record_id']);
$subdefs = array_filter($record->get_subdefs(), function($subdef) use ($subdefsName) {
return in_array($subdef->get_name(), $subdefsName);
});
foreach ($subdefs as $subdef) {
$subdef->remove_file();
if (($withSubstitution && $subdef->is_substituted()) || $substitutionOnly) {
$subdef->set_substituted(false);
}
}
$record->generate_subdefs($databox, $this->container, $subdefsName);
$stmt->closeCursor();
$progress->advance();
}
unset($rows, $record, $stmt, $connection);
$progress->finish();
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -37,8 +37,7 @@ class CreateCollection extends Command
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$databox = $this->container['phraseanet.appbox']
->get_databox((int) $input->getArgument('databox_id'));
$databox = $this->container['phraseanet.appbox']->get_databox((int) $input->getArgument('databox_id'));
$new_collection = \collection::create($this->container, $databox, $this->container['phraseanet.appbox'], $input->getArgument('collname'));

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -49,11 +49,11 @@ class ComposerInstall extends Command
try {
if ($input->getOption('no-dev')) {
$output->write("Installing dependencies <info>without</info> developer packages ");
$output->write("Installing composer dependencies <info>without</info> developer packages ");
$composer->command(array_merge($commands, ['--no-dev']));
$output->writeln("<comment>OK</comment>");
} else {
$output->write("Installing dependencies <info>with</info> developer packages ");
$output->write("Installing composer dependencies <info>with</info> developer packages ");
$composer->command(array_merge($commands, ['--dev']));
$output->writeln("<comment>OK</comment>");
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -36,6 +36,7 @@ class IniReset extends Command
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Databox name to reset, in case of multiple databox are mounted', null)
->addOption('dependencies', null, InputOption::VALUE_NONE, 'Fetch dependencies', null)
->addOption('run-patches', null, InputOption::VALUE_NONE, 'Reset in v3.1 states & apply all patches', null)
->addOption('no-setup-dbs', null, InputOption::VALUE_NONE, 'Do not create dbs for setup tests used in phpunit test suite', null)
;
}
@@ -114,7 +115,7 @@ class IniReset extends Command
// get data paths
$dataPath = $this->container['conf']->get(['main', 'storage', 'subdefs'], $this->container['root.path'].'/datas');
$schema = $this->container['EM']->getConnection()->getSchemaManager();
$schema = $this->container['orm.em']->getConnection()->getSchemaManager();
$output->writeln('Creating database "'.$dbs['ab'].'"...<info>OK</info>');
$schema->dropAndCreateDatabase($dbs['ab']);
$output->writeln('Creating database "'.$dbName.'"...<info>OK</info>');
@@ -163,7 +164,7 @@ class IniReset extends Command
'command' => 'system:uninstall'
)), $output);
$process = new Process(sprintf('php ' . __DIR__ . '/../../../../../bin/setup system:install --email=%s --password=%s --db-user=%s --db-template=%s --db-password=%s --databox=%s --appbox=%s --server-name=%s --db-host=%s --db-port=%s -y',
$cmd = sprintf('php ' . __DIR__ . '/../../../../../bin/setup system:install --email=%s --password=%s --db-user=%s --db-template=%s --db-password=%s --databox=%s --appbox=%s --server-name=%s --db-host=%s --db-port=%s -y',
$input->getOption('email'),
$input->getOption('password'),
$conf['main']['database']['user'],
@@ -171,12 +172,22 @@ class IniReset extends Command
$conf['main']['database']['password'],
$dbName,
$dbs['ab'],
$conf['main']['servername'],
$conf['servername'],
$conf['main']['database']['host'],
$conf['main']['database']['port']
));
$process->run();
);
$process = new Process($cmd);
$process->setTimeout(300);
$process->run(function ($type, $buffer) {
if ('err' === $type) {
echo 'ERR > ' . $buffer;
}
});
if (false === $process->isSuccessful()) {
$output->writeln('<error>Failed to execute the following command "'.$cmd.'"</error>');
return 1;
}
$output->writeln("<info>Install successful !</info>");
}
@@ -197,15 +208,38 @@ class IniReset extends Command
$output->writeln('Mounting database "'.$databox->get_dbname().'"...<info>OK</info>');
}
$process = new Process(('php ' . __DIR__ . '/../../../../../bin/setup system:upgrade -y -f'));
$process->run();
if ($input->getOption('run-patches') || false === $this->container['phraseanet.configuration']->isUpToDate()) {
if ($input->getOption('run-patches')) {
$output->write(sprintf('Upgrading... from version <info>3.1.21</info> to <info>%s</info>', Version::getNumber()), true);
} else {
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->app['phraseanet.appbox']->get_version(), Version::getNumber()), true);
}
$cmd = 'php ' . __DIR__ . '/../../../../../bin/setup system:upgrade -y -f -v';
$process = new Process($cmd);
$process->setTimeout(600);
$process->run(function ($type, $buffer) {
if ('err' === $type) {
echo 'ERR > ' . $buffer;
}
})
;
if (false === $process->isSuccessful()) {
$output->writeln('<error>Failed to execute the following command "' . $cmd . '"</error>');
// create setup dbs
$command = $this->getApplication()->find('ini:setup-tests-dbs');
$input = new ArrayInput(array(
'command' => 'ini:setup-tests-dbs'
));
$command->run($input, $output);
return 1;
}
}
if (!$input->getOption('no-setup-dbs')) {
// create setup dbs
$command = $this->getApplication()->find('ini:setup-tests-dbs');
$input = new ArrayInput(array(
'command' => 'ini:setup-tests-dbs'
));
$command->run($input, $output);
}
$this->container['conf']->set(['main', 'storage', 'subdefs'], $dataPath);

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -30,12 +30,13 @@ class JsFixtures extends Command
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$dbRefPath = sys_get_temp_dir() . '/db-ref.sqlite';
if (!file_exists($dbRefPath)) {
if (!file_exists($this->container['db.fixture.info']['path'])) {
throw new RuntimeException('You must generate sqlite db first, run "bin/console phraseanet:regenerate-sqlite" command.');
}
copy($dbRefPath, sys_get_temp_dir().'/db.sqlite');
$this->container['orm.em'] = $this->container->extend('orm.em', function($em, $app) {
return $app['orm.ems'][$app['db.fixture.hash.key']];
});
$sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id();
$this->writeResponse($output, 'GET', '/login/', '/home/login/index.html');
@@ -55,6 +56,7 @@ class JsFixtures extends Command
private function deleteUser(User $user)
{
$user = $this->container['orm.em']->find('Phraseanet:User', $user->getId());
$this->container['manipulator.user']->delete($user);
}
@@ -103,6 +105,9 @@ class JsFixtures extends Command
{
$environment = Application::ENV_TEST;
$app = require __DIR__ . '/../../Application/Root.php';
$app['orm.em'] = $app->extend('orm.em', function($em, $app) {
return $app['orm.ems'][$app['db.fixture.hash.key']];
});
$user = $this->createUser($app);

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -25,7 +25,6 @@ use Alchemy\Phrasea\Model\Entities\FeedPublisher;
use Alchemy\Phrasea\Model\Entities\FeedToken;
use Alchemy\Phrasea\Model\Entities\LazaretSession;
use Alchemy\Phrasea\Model\Entities\Registration;
use Alchemy\Phrasea\Model\Entities\Session;
use Alchemy\Phrasea\Model\Entities\Task;
use Alchemy\Phrasea\Model\Entities\Token;
use Alchemy\Phrasea\Model\Entities\User;
@@ -36,7 +35,6 @@ use Alchemy\Phrasea\Model\Entities\UsrListOwner;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
use Alchemy\Phrasea\Model\Entities\StoryWZ;
use Alchemy\Phrasea\Core\Provider\ORMServiceProvider;
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
@@ -61,133 +59,119 @@ class RegenerateSqliteDb extends Command
{
$fs = new Filesystem();
$source = sys_get_temp_dir().'/db-ref.sqlite';
$target = sys_get_temp_dir().'/db-ref.sqlite.bkp';
$json = sys_get_temp_dir().'/fixtures.json';
$renamed = false;
$json = sprintf('%s/fixtures.json', sys_get_temp_dir());
if (is_file($source)) {
$renamed = true;
$fs->rename($source, $target, true);
if ($fs->exists($json)) {
$fs->remove($json);
}
try {
$dbParams = [
'driver' => 'pdo_sqlite',
'path' => $source,
'charset' => 'UTF8',
];
$this->container['orm.em'] = $this->container->extend('orm.em', function($em, $app) {
return $app['orm.ems'][$app['db.fixture.hash.key']];
});
$this->container->register(new ORMServiceProvider());
$this->container['EM.dbal-conf'] = $dbParams;
$em = $this->container['orm.em'];
$metadatas = $this->container['EM']->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($this->container['EM']);
$schemaTool->createSchema($metadatas);
$fixtures = [];
$DI = new \Pimple();
$this->generateUsers($this->container['EM'], $DI);
$this->insertOauthApps($DI);
$this->insertOauthAccounts($DI);
$this->insertNativeApps();
$this->generateCollection($DI);
$this->generateRecord($DI);
$this->insertTwoTasks($this->container['EM']);
$this->insertTwoBasket($this->container['EM'], $DI);
$this->insertOneStoryInWz($this->container['EM'], $DI);
$this->insertUsrLists($this->container['EM'], $DI);
$this->insertOnePrivateFeed($this->container['EM'], $DI);
$this->insertOnePublicFeed($this->container['EM'], $DI);
$this->insertOneExtraFeed($this->container['EM'], $DI);
$this->insertOneAggregateToken($this->container['EM'], $DI);
$this->insertLazaretFiles($this->container['EM'], $DI);
$this->insertAuthFailures($this->container['EM'], $DI);
$this->insertOneRegistration($DI, $this->container['EM'], $DI['user_alt1'], $DI['coll'], 'now', 'registration_1');
$this->insertOneRegistration($DI, $this->container['EM'], $DI['user_alt2'], $DI['coll'], '-3 months', 'registration_2');
$this->insertOneRegistration($DI, $this->container['EM'], $DI['user_notAdmin'], $DI['coll'], 'now', 'registration_3');
$this->insertTwoTokens($this->container['EM'], $DI);
$this->insertOneInvalidToken($this->container['EM'], $DI);
$this->insertOneValidationToken($this->container['EM'], $DI);
$this->insertWebhookEvent($this->container['EM'], $DI);
$this->insertWebhookEventDelivery($this->container['EM'], $DI);
$this->container['EM']->flush();
$fixtures['basket']['basket_1'] = $DI['basket_1']->getId();
$fixtures['basket']['basket_2'] = $DI['basket_2']->getId();
$fixtures['basket']['basket_3'] = $DI['basket_3']->getId();
$fixtures['basket']['basket_4'] = $DI['basket_4']->getId();
$fixtures['token']['token_1'] = $DI['token_1']->getValue();
$fixtures['token']['token_2'] = $DI['token_2']->getValue();
$fixtures['token']['token_invalid'] = $DI['token_invalid']->getValue();
$fixtures['token']['token_validation'] = $DI['token_validation']->getValue();
$fixtures['user']['test_phpunit'] = $DI['user']->getId();
$fixtures['user']['test_phpunit_not_admin'] = $DI['user_notAdmin']->getId();
$fixtures['user']['test_phpunit_alt1'] = $DI['user_alt1']->getId();
$fixtures['user']['test_phpunit_alt2'] = $DI['user_alt2']->getId();
$fixtures['user']['user_guest'] = $DI['user_guest']->getId();
$fixtures['oauth']['user'] = $DI['api-app-user']->getId();
$fixtures['oauth']['acc-user'] = $DI['api-app-acc-user']->getId();
$fixtures['oauth']['user-not-admin'] = $DI['api-app-user-not-admin']->getId();
$fixtures['oauth']['acc-user-not-admin'] = $DI['api-app-acc-user-not-admin']->getId();
$fixtures['databox']['records'] = $DI['databox']->get_sbas_id();
$fixtures['collection']['coll'] = $DI['coll']->get_base_id();
$fixtures['collection']['coll_no_access'] = $DI['coll_no_access']->get_base_id();
$fixtures['collection']['coll_no_status'] = $DI['coll_no_status']->get_base_id();
$fixtures['record']['record_story_1'] = $DI['record_story_1']->get_record_id();
$fixtures['record']['record_story_2'] = $DI['record_story_2']->get_record_id();
$fixtures['record']['record_story_3'] = $DI['record_story_3']->get_record_id();
$fixtures['record']['record_1'] = $DI['record_1']->get_record_id();
$fixtures['record']['record_2'] = $DI['record_2']->get_record_id();
$fixtures['record']['record_3'] = $DI['record_3']->get_record_id();
$fixtures['record']['record_4'] = $DI['record_4']->get_record_id();
$fixtures['record']['record_5'] = $DI['record_5']->get_record_id();
$fixtures['record']['record_6'] = $DI['record_6']->get_record_id();
$fixtures['record']['record_7'] = $DI['record_7']->get_record_id();
$fixtures['registrations']['registration_1'] = $DI['registration_1']->getId();
$fixtures['registrations']['registration_2'] = $DI['registration_2']->getId();
$fixtures['registrations']['registration_3'] = $DI['registration_3']->getId();
$fixtures['lazaret']['lazaret_1'] = $DI['lazaret_1']->getId();
$fixtures['user']['user_1'] = $DI['user_1']->getId();
$fixtures['user']['user_2'] = $DI['user_1']->getId();
$fixtures['user']['user_3'] = $DI['user_1']->getId();
$fixtures['user']['user_1_deleted'] = $DI['user_1_deleted']->getId();
$fixtures['user']['user_2_deleted'] = $DI['user_2_deleted']->getId();
$fixtures['user']['user_3_deleted'] = $DI['user_3_deleted']->getId();
$fixtures['user']['user_template'] = $DI['user_template']->getId();
$fixtures['feed']['public']['feed'] = $DI['feed_public']->getId();
$fixtures['feed']['public']['entry'] = $DI['feed_public_entry']->getId();
$fixtures['feed']['public']['token'] = $DI['feed_public_token']->getId();
$fixtures['feed']['private']['feed'] = $DI['feed_private']->getId();
$fixtures['feed']['private']['entry'] = $DI['feed_private_entry']->getId();
$fixtures['feed']['private']['token'] = $DI['feed_private_token']->getId();
$fixtures['webhook']['event'] = $DI['event_webhook_1']->getId();
} catch (\Exception $e) {
$output->writeln("<error>".$e->getMessage()."</error>");
if ($renamed) {
$fs->remove($source);
$fs->rename($target, $source);
}
throw $e;
if ($fs->exists($em->getConnection()->getParams()['path'])) {
$fs->remove($em->getConnection()->getParams()['path']);
}
$fs->remove($target);
$schemaTool = new SchemaTool($em);
$schemaTool->createSchema($em->getMetadataFactory()->getAllMetadata());
$fixtures = [];
$DI = new \Pimple();
$this->generateUsers($em, $DI);
$this->insertOauthApps($DI);
$this->insertOauthAccounts($DI);
$this->insertNativeApps();
$this->generateCollection($DI);
$this->generateRecord($DI);
$this->insertTwoTasks($em);
$this->insertTwoBasket($em, $DI);
$this->insertOneStoryInWz($em, $DI);
$this->insertUsrLists($em, $DI);
$this->insertOnePrivateFeed($em, $DI);
$this->insertOnePublicFeed($em, $DI);
$this->insertOneExtraFeed($em, $DI);
$this->insertOneAggregateToken($em, $DI);
$this->insertLazaretFiles($em, $DI);
$this->insertAuthFailures($em, $DI);
$this->insertOneRegistration($DI, $em, $DI['user_alt1'], $DI['coll'], 'now', 'registration_1');
$this->insertOneRegistration($DI, $em, $DI['user_alt2'], $DI['coll'], '-3 months', 'registration_2');
$this->insertOneRegistration($DI, $em, $DI['user_notAdmin'], $DI['coll'], 'now', 'registration_3');
$this->insertTwoTokens($em, $DI);
$this->insertOneInvalidToken($em, $DI);
$this->insertOneValidationToken($em, $DI);
$this->insertWebhookEvent($em, $DI);
$this->insertWebhookEventDelivery($em, $DI);
$em->flush();
$fixtures['basket']['basket_1'] = $DI['basket_1']->getId();
$fixtures['basket']['basket_2'] = $DI['basket_2']->getId();
$fixtures['basket']['basket_3'] = $DI['basket_3']->getId();
$fixtures['basket']['basket_4'] = $DI['basket_4']->getId();
$fixtures['token']['token_1'] = $DI['token_1']->getValue();
$fixtures['token']['token_2'] = $DI['token_2']->getValue();
$fixtures['token']['token_invalid'] = $DI['token_invalid']->getValue();
$fixtures['token']['token_validation'] = $DI['token_validation']->getValue();
$fixtures['user']['test_phpunit'] = $DI['user']->getId();
$fixtures['user']['test_phpunit_not_admin'] = $DI['user_notAdmin']->getId();
$fixtures['user']['test_phpunit_alt1'] = $DI['user_alt1']->getId();
$fixtures['user']['test_phpunit_alt2'] = $DI['user_alt2']->getId();
$fixtures['user']['user_guest'] = $DI['user_guest']->getId();
$fixtures['oauth']['user'] = $DI['api-app-user']->getId();
$fixtures['oauth']['acc-user'] = $DI['api-app-acc-user']->getId();
$fixtures['oauth']['user-not-admin'] = $DI['api-app-user-not-admin']->getId();
$fixtures['oauth']['acc-user-not-admin'] = $DI['api-app-acc-user-not-admin']->getId();
$fixtures['databox']['records'] = $DI['databox']->get_sbas_id();
$fixtures['collection']['coll'] = $DI['coll']->get_base_id();
$fixtures['collection']['coll_no_access'] = $DI['coll_no_access']->get_base_id();
$fixtures['collection']['coll_no_status'] = $DI['coll_no_status']->get_base_id();
$fixtures['record']['record_story_1'] = $DI['record_story_1']->get_record_id();
$fixtures['record']['record_story_2'] = $DI['record_story_2']->get_record_id();
$fixtures['record']['record_story_3'] = $DI['record_story_3']->get_record_id();
$fixtures['record']['record_1'] = $DI['record_1']->get_record_id();
$fixtures['record']['record_2'] = $DI['record_2']->get_record_id();
$fixtures['record']['record_3'] = $DI['record_3']->get_record_id();
$fixtures['record']['record_4'] = $DI['record_4']->get_record_id();
$fixtures['record']['record_5'] = $DI['record_5']->get_record_id();
$fixtures['record']['record_6'] = $DI['record_6']->get_record_id();
$fixtures['record']['record_7'] = $DI['record_7']->get_record_id();
$fixtures['registrations']['registration_1'] = $DI['registration_1']->getId();
$fixtures['registrations']['registration_2'] = $DI['registration_2']->getId();
$fixtures['registrations']['registration_3'] = $DI['registration_3']->getId();
$fixtures['lazaret']['lazaret_1'] = $DI['lazaret_1']->getId();
$fixtures['user']['user_1'] = $DI['user_1']->getId();
$fixtures['user']['user_2'] = $DI['user_1']->getId();
$fixtures['user']['user_3'] = $DI['user_1']->getId();
$fixtures['user']['user_1_deleted'] = $DI['user_1_deleted']->getId();
$fixtures['user']['user_2_deleted'] = $DI['user_2_deleted']->getId();
$fixtures['user']['user_3_deleted'] = $DI['user_3_deleted']->getId();
$fixtures['user']['user_template'] = $DI['user_template']->getId();
$fixtures['feed']['public']['feed'] = $DI['feed_public']->getId();
$fixtures['feed']['public']['entry'] = $DI['feed_public_entry']->getId();
$fixtures['feed']['public']['token'] = $DI['feed_public_token']->getId();
$fixtures['feed']['private']['feed'] = $DI['feed_private']->getId();
$fixtures['feed']['private']['entry'] = $DI['feed_private_entry']->getId();
$fixtures['feed']['private']['token'] = $DI['feed_private_token']->getId();
$fixtures['webhook']['event'] = $DI['event_webhook_1']->getId();
$fs->dumpFile($json, json_encode($fixtures, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
return 0;
@@ -195,23 +179,28 @@ class RegenerateSqliteDb extends Command
private function insertOauthApps(\Pimple $DI)
{
$DI['api-app-user'] = $this->container['manipulator.api-application']->create(
'test application for user',
ApiApplication::WEB_TYPE,
'an api application description',
'http://website.com/',
$DI['user'],
'http://callback.com/callback/'
);
if (null === $DI['api-app-user'] = $this->container['repo.api-applications']->findOneByName('api-app-user')) {
$DI['api-app-user'] = $this->container['manipulator.api-application']->create(
'test-web',
ApiApplication::WEB_TYPE,
'',
'http://website.com/',
$DI['user'],
'http://callback.com/callback/'
);
}
if (null === $DI['api-app-user-not-admin'] = $this->container['repo.api-applications']->findOneByName('test-desktop')) {
$DI['api-app-user-not-admin'] = $this->container['manipulator.api-application']->create(
'test-desktop',
ApiApplication::WEB_TYPE,
'',
'http://website.com/',
$DI['user_notAdmin'],
'http://callback.com/callback/'
);
}
$DI['api-app-user-not-admin'] = $this->container['manipulator.api-application']->create(
'test application for user',
ApiApplication::WEB_TYPE,
'an api application description',
'http://website.com/',
$DI['user_notAdmin'],
'http://callback.com/callback/'
);
}
public function insertOauthAccounts(\Pimple $DI)

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -44,22 +44,22 @@ class SetupTestsDbs extends Command
$dbs[] = $settings['database']['ab_name'];
$dbs[] = $settings['database']['db_name'];
$schema = $this->container['EM']->getConnection()->getSchemaManager();
$schema = $this->container['orm.em']->getConnection()->getSchemaManager();
foreach($dbs as $name) {
$output->writeln('Creating database "'.$name.'"...<info>OK</info>');
$schema->dropAndCreateDatabase($name);
}
$this->container['EM']->getConnection()->executeUpdate('
$this->container['orm.em']->getConnection()->executeUpdate('
GRANT ALL PRIVILEGES ON '.$settings['database']['ab_name'].'.* TO \''.$settings['database']['user'].'\'@\''.$settings['database']['host'].'\' IDENTIFIED BY \''.$settings['database']['password'].'\' WITH GRANT OPTION
');
$this->container['EM']->getConnection()->executeUpdate('
$this->container['orm.em']->getConnection()->executeUpdate('
GRANT ALL PRIVILEGES ON '.$settings['database']['db_name'].'.* TO \''.$settings['database']['user'].'\'@\''.$settings['database']['host'].'\' IDENTIFIED BY \''.$settings['database']['password'].'\' WITH GRANT OPTION
');
$this->container['EM']->getConnection()->executeUpdate('SET @@global.sql_mode= ""');
$this->container['orm.em']->getConnection()->executeUpdate('SET @@global.sql_mode= ""');
return 0;
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -40,7 +40,7 @@ class AddPlugin extends AbstractPluginCommand
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($temporaryDir);
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
$targetDir = $this->container['plugins.directory'] . DIRECTORY_SEPARATOR . $manifest->getName();
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
$output->write("Setting up composer...");
$this->container['plugins.composer-installer']->install($temporaryDir);

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -40,7 +40,7 @@ class RemovePlugin extends AbstractPluginCommand
$this->container['plugins.assets-manager']->remove($name);
$output->writeln(" <comment>OK</comment>");
$path = $this->container['plugins.directory'] . DIRECTORY_SEPARATOR . $name;
$path = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $name;
$output->write("Removing <info>$name</info>...");
$this->container['filesystem']->remove($path);

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -83,7 +83,7 @@ class RecordAdd extends Command
$file = new File($this->container, $media, $collection, $originalName);
$session = new LazaretSession();
$this->container['EM']->persist($session);
$this->container['orm.em']->persist($session);
$forceBehavior = null;

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

Some files were not shown because too many files have changed in this diff Show More