Files
Phraseanet/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php
Nicolas Le Goff 9f38823f27 Merge branch '3.8'
Conflicts:
	composer.lock
	lib/Alchemy/Phrasea/Application.php
	lib/Alchemy/Phrasea/Command/Setup/H264MappingGenerator.php
	lib/Alchemy/Phrasea/Controller/AbstractDelivery.php
	lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php
	lib/Alchemy/Phrasea/Controller/Prod/Edit.php
	lib/Alchemy/Phrasea/Controller/Prod/Story.php
	lib/Alchemy/Phrasea/Controller/Prod/Upload.php
	lib/Alchemy/Phrasea/Controller/Report/Activity.php
	lib/Alchemy/Phrasea/Controller/Report/Root.php
	lib/Alchemy/Phrasea/Controller/Root/Account.php
	lib/Alchemy/Phrasea/Core/PhraseaEvents.php
	lib/Alchemy/Phrasea/Core/Version.php
	lib/classes/API/V1/adapter.php
	lib/classes/User/Adapter.php
	lib/classes/databox.php
	lib/classes/media/subdef.php
	lib/classes/module/report.php
	lib/classes/module/report/activity.php
	lib/classes/module/report/connexion.php
	lib/classes/module/report/download.php
	lib/classes/module/report/nav.php
	lib/classes/module/report/question.php
	lib/classes/module/report/sqlaction.php
	lib/classes/module/report/sqlconnexion.php
	lib/classes/module/report/sqldownload.php
	lib/classes/module/report/sqlfilter.php
	lib/classes/task/abstract.php
	locale/de_DE/LC_MESSAGES/phraseanet.mo
	locale/de_DE/LC_MESSAGES/phraseanet.po
	locale/en_GB/LC_MESSAGES/phraseanet.mo
	locale/en_GB/LC_MESSAGES/phraseanet.po
	locale/fr_FR/LC_MESSAGES/phraseanet.mo
	locale/fr_FR/LC_MESSAGES/phraseanet.po
	locale/nl_NL/LC_MESSAGES/phraseanet.mo
	locale/nl_NL/LC_MESSAGES/phraseanet.po
	locale/phraseanet.pot
	templates/web/prod/index.html.twig
	tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php
	tests/classes/api/v1/api_v1_adapterTest.php
	tests/classes/report/activityTest.php
	tests/classes/report/editTest.php
2014-12-09 13:59:29 +01:00

89 lines
2.7 KiB
PHP

<?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\Controller;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Http\DeliverDataInterface;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
abstract class AbstractDelivery implements ControllerProviderInterface
{
public function deliverContent(Request $request, \record_adapter $record, $subdef, $watermark, $stamp, Application $app)
{
$file = $record->get_subdef($subdef);
<<<<<<< HEAD
=======
>>>>>>> 3.8
$pathOut = $file->get_pathfile();
if ($watermark === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
$pathOut = \recordutils_image::watermark($app, $file);
} elseif ($stamp === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
$pathOut = \recordutils_image::stamp($app, $file);
}
<<<<<<< HEAD
$log_id = null;
try {
$logger = $app['phraseanet.logger']($record->get_databox());
$log_id = $logger->get_id();
$referrer = 'NO REFERRER';
if (isset($_SERVER['HTTP_REFERER'])) {
$referrer = $_SERVER['HTTP_REFERER'];
}
$record->log_view($log_id, $referrer, $app['conf']->get(['main', 'key']));
} catch (\Exception $e) {
}
=======
>>>>>>> 3.8
$disposition = $request->query->get('download') ? DeliverDataInterface::DISPOSITION_ATTACHMENT : DeliverDataInterface::DISPOSITION_INLINE;
$response = $app['phraseanet.file-serve']->deliverFile($pathOut, $file->get_file(), $disposition, $file->get_mime());
if (in_array($subdef, array('document', 'preview'))) {
$response->setPrivate();
$this->logView($app, $record, $request);
} elseif ($subdef !== 'thumbnail') {
try {
if ($file->getDataboxSubdef()->get_class() != \databox_subdef::CLASS_THUMBNAIL) {
$response->setPrivate();
$this->logView($app, $record, $request);
}
} catch (\Exception $e) {
}
}
$response->isNotModified($request);
return $response;
}
private function logView(Application $app, \record_adapter $record, Request $request)
{
try {
$logger = $app['phraseanet.logger']($record->get_databox());
$log_id = $logger->get_id();
$record->log_view($log_id, $request->headers->get('referer', 'NO REFERRER'), $app['phraseanet.configuration']['main']['key']);
} catch (\Exception $e) {
}
}
}