mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Change on embed bundle handling
This commit is contained in:
@@ -28,13 +28,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://github.com/alchemy-fr/embed-bundle.git"
|
"url": "https://github.com/bburnichon/embed-bundle.git"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5",
|
"php": ">=5.5",
|
||||||
"alchemy-fr/tcpdf-clone": "~6.0",
|
"alchemy-fr/tcpdf-clone": "~6.0",
|
||||||
"alchemy/embed-bundle": "~0.1.0",
|
"alchemy/embed-bundle": "dev-OpenEmbed@dev",
|
||||||
"alchemy/geonames-api-consumer": "~0.1.0",
|
"alchemy/geonames-api-consumer": "~0.1.0",
|
||||||
"alchemy/google-plus-api-client": "~0.6.2",
|
"alchemy/google-plus-api-client": "~0.6.2",
|
||||||
"alchemy/mediavorus": "^0.4.4",
|
"alchemy/mediavorus": "^0.4.4",
|
||||||
|
24
composer.lock
generated
24
composer.lock
generated
@@ -4,8 +4,8 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "32865d9f1fb5a0d8ead56364bc5db5c7",
|
"hash": "cddd55809cd44a4f9d87bfd47079e793",
|
||||||
"content-hash": "1212545fbe0ee56e58d31f099da0e819",
|
"content-hash": "e92d5f3befc203c4ce18b110e83123f0",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "alchemy-fr/tcpdf-clone",
|
"name": "alchemy-fr/tcpdf-clone",
|
||||||
@@ -122,16 +122,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "alchemy/embed-bundle",
|
"name": "alchemy/embed-bundle",
|
||||||
"version": "v0.1.1",
|
"version": "dev-OpenEmbed",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/alchemy-fr/embed-bundle.git",
|
"url": "https://github.com/bburnichon/embed-bundle.git",
|
||||||
"reference": "422f4835a812d916e6ae81bfb842dad10a0f3a2a"
|
"reference": "859f19891a794fee4ed81bc4b55e9fb2d19e6a48"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/alchemy-fr/embed-bundle/zipball/422f4835a812d916e6ae81bfb842dad10a0f3a2a",
|
"url": "https://api.github.com/repos/bburnichon/embed-bundle/zipball/859f19891a794fee4ed81bc4b55e9fb2d19e6a48",
|
||||||
"reference": "422f4835a812d916e6ae81bfb842dad10a0f3a2a",
|
"reference": "859f19891a794fee4ed81bc4b55e9fb2d19e6a48",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@@ -169,10 +169,9 @@
|
|||||||
],
|
],
|
||||||
"description": "Embed resources bundle",
|
"description": "Embed resources bundle",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/alchemy-fr/embed-bundle/tree/v0.1.1",
|
"source": "https://github.com/bburnichon/embed-bundle/tree/OpenEmbed"
|
||||||
"issues": "https://github.com/alchemy-fr/embed-bundle/issues"
|
|
||||||
},
|
},
|
||||||
"time": "2016-01-06 17:34:21"
|
"time": "2016-01-12 16:51:22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "alchemy/geonames-api-consumer",
|
"name": "alchemy/geonames-api-consumer",
|
||||||
@@ -2583,7 +2582,7 @@
|
|||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/hoaproject/Stream/zipball/011ab91d942f1d7096deade4c8a10fe57d51c5b3",
|
"url": "https://api.github.com/repos/hoaproject/Stream/zipball/3bc446bc00849bf51166adc415d77aa375d48d8c",
|
||||||
"reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3",
|
"reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
@@ -4440,7 +4439,7 @@
|
|||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/8ea5840ad835444627de70a706aabd8c9aa41df8",
|
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9835fc4f8463c944bdc2617cbbdb6b688ca17944",
|
||||||
"reference": "a6a3d39d1f68e3e04555a2d6b43a9df0977d96d9",
|
"reference": "a6a3d39d1f68e3e04555a2d6b43a9df0977d96d9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
@@ -6474,6 +6473,7 @@
|
|||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
|
"alchemy/embed-bundle": 20,
|
||||||
"alchemy/rest-bundle": 20,
|
"alchemy/rest-bundle": 20,
|
||||||
"alchemy/task-manager": 20,
|
"alchemy/task-manager": 20,
|
||||||
"goodby/csv": 20,
|
"goodby/csv": 20,
|
||||||
|
@@ -18,7 +18,6 @@ use Alchemy\Phrasea\Application\Helper\AclAware;
|
|||||||
use Alchemy\Phrasea\Application\Helper\ApplicationBoxAware;
|
use Alchemy\Phrasea\Application\Helper\ApplicationBoxAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\AuthenticatorAware;
|
use Alchemy\Phrasea\Application\Helper\AuthenticatorAware;
|
||||||
use Alchemy\Phrasea\Authorization\AuthorizationServiceProvider;
|
use Alchemy\Phrasea\Authorization\AuthorizationServiceProvider;
|
||||||
use Alchemy\Phrasea\Cache\Factory;
|
|
||||||
use Alchemy\Phrasea\Cache\Manager;
|
use Alchemy\Phrasea\Cache\Manager;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
|
||||||
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
|
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
|
||||||
@@ -75,6 +74,8 @@ use Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider;
|
|||||||
use Alchemy\Phrasea\Core\Provider\ZippyServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\ZippyServiceProvider;
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Alchemy\Phrasea\Form\Extension\HelpTypeExtension;
|
use Alchemy\Phrasea\Form\Extension\HelpTypeExtension;
|
||||||
|
use Alchemy\Phrasea\Media\MediaAccessorResolver;
|
||||||
|
use Alchemy\Phrasea\Media\PermalinkMediaResolver;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
use Alchemy\Phrasea\Twig\BytesConverter;
|
use Alchemy\Phrasea\Twig\BytesConverter;
|
||||||
use Alchemy\Phrasea\Twig\Camelize;
|
use Alchemy\Phrasea\Twig\Camelize;
|
||||||
@@ -93,11 +94,8 @@ use MediaAlchemyst\MediaAlchemystServiceProvider;
|
|||||||
use MediaVorus\Media\MediaInterface;
|
use MediaVorus\Media\MediaInterface;
|
||||||
use MediaVorus\MediaVorus;
|
use MediaVorus\MediaVorus;
|
||||||
use MediaVorus\MediaVorusServiceProvider;
|
use MediaVorus\MediaVorusServiceProvider;
|
||||||
use Monolog\Handler\NullHandler;
|
|
||||||
use Monolog\Handler\RotatingFileHandler;
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
use Monolog\Handler\SyslogHandler;
|
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Processor\IntrospectionProcessor;
|
|
||||||
use MP4Box\MP4BoxServiceProvider;
|
use MP4Box\MP4BoxServiceProvider;
|
||||||
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
|
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
|
||||||
use Neutron\Silex\Provider\FilesystemServiceProvider;
|
use Neutron\Silex\Provider\FilesystemServiceProvider;
|
||||||
@@ -372,11 +370,25 @@ class Application extends SilexApplication
|
|||||||
'Alchemy\Phrasea\ControllerProvider\User\Notifications' => [],
|
'Alchemy\Phrasea\ControllerProvider\User\Notifications' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\User\Preferences' => [],
|
'Alchemy\Phrasea\ControllerProvider\User\Preferences' => [],
|
||||||
'Alchemy\EmbedProvider\EmbedServiceProvider' => [],
|
'Alchemy\EmbedProvider\EmbedServiceProvider' => [],
|
||||||
'Alchemy\EmbedProvider\OembedServiceProvider' => [],
|
|
||||||
];
|
];
|
||||||
foreach ($providers as $class => $values) {
|
foreach ($providers as $class => $values) {
|
||||||
$this->register(new $class, $values);
|
$this->register(new $class, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$resolvers = $this['alchemy_embed.resource_resolvers'];
|
||||||
|
$resolvers['datafiles'] = $resolvers->share(function () {
|
||||||
|
return new DatafilesResolver($this->getApplicationBox(), $this['url_generator']);
|
||||||
|
});
|
||||||
|
$resolvers['permalinks_permalink'] = $resolvers->share(function () {
|
||||||
|
return new PermalinkMediaResolver($this->getApplicationBox(), $this['url_generator']);
|
||||||
|
});
|
||||||
|
$resolvers['media_accessor'] = $resolvers->share(function () {
|
||||||
|
return new MediaAccessorResolver(
|
||||||
|
$this->getApplicationBox(),
|
||||||
|
$this['url_generator'],
|
||||||
|
$this['controller.media_accessor']
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -695,7 +707,6 @@ class Application extends SilexApplication
|
|||||||
'/developers/' => 'Alchemy\Phrasea\ControllerProvider\Root\Developers',
|
'/developers/' => 'Alchemy\Phrasea\ControllerProvider\Root\Developers',
|
||||||
'/download/' => 'Alchemy\Phrasea\ControllerProvider\Prod\DoDownload',
|
'/download/' => 'Alchemy\Phrasea\ControllerProvider\Prod\DoDownload',
|
||||||
'/embed/' => 'Alchemy\EmbedProvider\EmbedServiceProvider',
|
'/embed/' => 'Alchemy\EmbedProvider\EmbedServiceProvider',
|
||||||
'/oembed/' => 'Alchemy\EmbedProvider\OembedServiceProvider',
|
|
||||||
'/feeds/' => 'Alchemy\Phrasea\ControllerProvider\Root\RSSFeeds',
|
'/feeds/' => 'Alchemy\Phrasea\ControllerProvider\Root\RSSFeeds',
|
||||||
'/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier',
|
'/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier',
|
||||||
'/login/' => 'Alchemy\Phrasea\ControllerProvider\Root\Login',
|
'/login/' => 'Alchemy\Phrasea\ControllerProvider\Root\Login',
|
||||||
|
@@ -52,18 +52,7 @@ class MediaAccessorController extends Controller
|
|||||||
|
|
||||||
public function showAction(Request $request, $token)
|
public function showAction(Request $request, $token)
|
||||||
{
|
{
|
||||||
try {
|
list($sbas_id, $record_id, $subdef) = $this->validateToken($token);
|
||||||
$token = JWT::decode($token, $this->keyStorage, $this->allowedAlgorithms);
|
|
||||||
} catch (\UnexpectedValueException $exception) {
|
|
||||||
throw new NotFoundHttpException('Resource not found', $exception);
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
throw new BadRequestHttpException('Invalid token', $exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! isset($token->sdef) || !is_array($token->sdef) || count($token->sdef) !== 3) {
|
|
||||||
throw new BadRequestHttpException('sdef should be a sub-definition identifier.');
|
|
||||||
}
|
|
||||||
list ($sbas_id, $record_id, $subdef) = $token->sdef;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$databox = $this->findDataboxById($sbas_id);
|
$databox = $this->findDataboxById($sbas_id);
|
||||||
@@ -93,4 +82,39 @@ class MediaAccessorController extends Controller
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $token
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function decodeToken($token)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return JWT::decode($token, $this->keyStorage, $this->allowedAlgorithms);
|
||||||
|
} catch (\UnexpectedValueException $exception) {
|
||||||
|
throw new NotFoundHttpException('Resource not found', $exception);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
throw new BadRequestHttpException('Invalid token', $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate token and returns triplet containing sbas_id, record_id and subdef.
|
||||||
|
*
|
||||||
|
* @param string|object $token
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function validateToken($token)
|
||||||
|
{
|
||||||
|
if (is_string($token)) {
|
||||||
|
$token = $this->decodeToken($token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($token->sdef) || !is_array($token->sdef) || count($token->sdef) !== 3) {
|
||||||
|
throw new BadRequestHttpException('sdef should be a sub-definition identifier.');
|
||||||
|
}
|
||||||
|
list ($sbas_id, $record_id, $subdef) = $token->sdef;
|
||||||
|
|
||||||
|
return array($sbas_id, $record_id, $subdef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,13 @@ class PermalinkController extends AbstractDelivery
|
|||||||
'view' => 'overview',
|
'view' => 'overview',
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'record' => $record,
|
'record' => $record,
|
||||||
|
'recordUrl' => $this->app->url('permalinks_permalink', [
|
||||||
|
'sbas_id' => $sbas_id,
|
||||||
|
'record_id' => $record_id,
|
||||||
|
'subdef' => $subdefName,
|
||||||
|
'label' => $record->get_title(),
|
||||||
|
'token' => $token,
|
||||||
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,35 +41,13 @@ class ShareController extends Controller
|
|||||||
|
|
||||||
$preview = $record->get_preview();
|
$preview = $record->get_preview();
|
||||||
|
|
||||||
if ($preview->get_permalink() !== null) {
|
if (null !== $previewLink = $preview->get_permalink()) {
|
||||||
|
$permalinkUrl = $previewLink->get_url();
|
||||||
|
$permaviewUrl = $previewLink->get_page();
|
||||||
|
$previewWidth = $preview->get_width();
|
||||||
|
$previewHeight = $preview->get_height();
|
||||||
|
|
||||||
|
$embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]);
|
||||||
$subdefName = $preview->get_name();
|
|
||||||
$subdef = $record->get_subdef($subdefName);
|
|
||||||
|
|
||||||
switch ($record->getType()) {
|
|
||||||
|
|
||||||
case 'flexpaper':
|
|
||||||
case 'document':
|
|
||||||
case 'audio':
|
|
||||||
case 'video':
|
|
||||||
default:
|
|
||||||
$token = $preview->get_permalink()->get_token();
|
|
||||||
$permalinkUrl = $preview->get_permalink()->get_url();
|
|
||||||
$permaviewUrl = $preview->get_permalink()->get_page();
|
|
||||||
$previewWidth = $preview->get_width();
|
|
||||||
$previewHeight = $preview->get_height();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$sbas_id = $record->getDataboxId();
|
|
||||||
$embedUrl = $this->app->url('alchemy_embed_view', [
|
|
||||||
'sbas_id' => $sbas_id,
|
|
||||||
'record_id' => $record_id,
|
|
||||||
'subdefName' => $subdefName,
|
|
||||||
'token' => $token,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$outputVars = [
|
$outputVars = [
|
||||||
'isAvailable' => true,
|
'isAvailable' => true,
|
||||||
|
51
lib/Alchemy/Phrasea/Media/DatafilesResolver.php
Normal file
51
lib/Alchemy/Phrasea/Media/DatafilesResolver.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
namespace Alchemy\Phrasea\Media;
|
||||||
|
|
||||||
|
use Alchemy\Embed\Media\MediaInformation;
|
||||||
|
use Alchemy\Embed\Media\ResourceResolver;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
|
class DatafilesResolver implements ResourceResolver
|
||||||
|
{
|
||||||
|
/** @var \appbox */
|
||||||
|
private $appbox;
|
||||||
|
/** @var UrlGeneratorInterface */
|
||||||
|
private $urlGenerator;
|
||||||
|
|
||||||
|
public function __construct(\appbox $appbox, UrlGeneratorInterface $urlGenerator)
|
||||||
|
{
|
||||||
|
$this->appbox = $appbox;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(Request $request, $routeName, array $routeParameters)
|
||||||
|
{
|
||||||
|
$parameters = array_replace(
|
||||||
|
$request->query->all(),
|
||||||
|
array_intersect_key($routeParameters, [
|
||||||
|
'sbas_id' => null,
|
||||||
|
'record_id' => null,
|
||||||
|
'subdef' => null,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$databox = $this->appbox->get_databox((int) $parameters['sbas_id']);
|
||||||
|
$record = $databox->get_record((int)$parameters['record_id']);
|
||||||
|
$subdef = $record->get_subdef($parameters['subdef']);
|
||||||
|
|
||||||
|
$urlGenerator = $this->urlGenerator;
|
||||||
|
$url = $urlGenerator->generate($routeName, $parameters, $urlGenerator::ABSOLUTE_URL);
|
||||||
|
$embedUrl = $urlGenerator->generate('alchemy_embed_view', ['url' => $url], $urlGenerator::ABSOLUTE_URL);
|
||||||
|
|
||||||
|
return new MediaInformation($subdef, $url, $embedUrl);
|
||||||
|
}
|
||||||
|
}
|
55
lib/Alchemy/Phrasea/Media/MediaAccessorResolver.php
Normal file
55
lib/Alchemy/Phrasea/Media/MediaAccessorResolver.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
namespace Alchemy\Phrasea\Media;
|
||||||
|
|
||||||
|
use Alchemy\Embed\Media\MediaInformation;
|
||||||
|
use Alchemy\Embed\Media\ResourceResolver;
|
||||||
|
use Alchemy\Phrasea\Controller\MediaAccessorController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
|
class MediaAccessorResolver implements ResourceResolver
|
||||||
|
{
|
||||||
|
/** @var \appbox */
|
||||||
|
private $appbox;
|
||||||
|
/** @var MediaAccessorController */
|
||||||
|
private $controller;
|
||||||
|
/** @var UrlGeneratorInterface */
|
||||||
|
private $urlGenerator;
|
||||||
|
|
||||||
|
public function __construct(\appbox $appbox, UrlGeneratorInterface $urlGenerator, MediaAccessorController $controller)
|
||||||
|
{
|
||||||
|
$this->appbox = $appbox;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
$this->controller = $controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(Request $request, $routeName, array $routeParameters)
|
||||||
|
{
|
||||||
|
$parameters = array_replace(
|
||||||
|
$request->query->all(),
|
||||||
|
array_intersect_key($routeParameters, [
|
||||||
|
'token' => null,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
list ($sbas_id, $record_id, $subdefName) = $this->controller->validateToken($parameters['token']);
|
||||||
|
|
||||||
|
$databox = $this->appbox->get_databox($sbas_id);
|
||||||
|
$record = $databox->get_record($record_id);
|
||||||
|
$subdef = $record->get_subdef($subdefName);
|
||||||
|
|
||||||
|
$urlGenerator = $this->urlGenerator;
|
||||||
|
$url = $urlGenerator->generate($routeName, $parameters, $urlGenerator::ABSOLUTE_URL);
|
||||||
|
$embedUrl = $urlGenerator->generate('alchemy_embed_view', ['url' => $url], $urlGenerator::ABSOLUTE_URL);
|
||||||
|
|
||||||
|
return new MediaInformation($subdef, $url, $embedUrl);
|
||||||
|
}
|
||||||
|
}
|
52
lib/Alchemy/Phrasea/Media/PermalinkMediaResolver.php
Normal file
52
lib/Alchemy/Phrasea/Media/PermalinkMediaResolver.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
namespace Alchemy\Phrasea\Media;
|
||||||
|
|
||||||
|
use Alchemy\Embed\Media\MediaInformation;
|
||||||
|
use Alchemy\Embed\Media\ResourceResolver;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
|
class PermalinkMediaResolver implements ResourceResolver
|
||||||
|
{
|
||||||
|
/** @var \appbox */
|
||||||
|
private $appbox;
|
||||||
|
/** @var UrlGeneratorInterface */
|
||||||
|
private $urlGenerator;
|
||||||
|
|
||||||
|
public function __construct(\appbox $appbox, UrlGeneratorInterface $urlGenerator)
|
||||||
|
{
|
||||||
|
$this->appbox = $appbox;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(Request $request, $routeName, array $routeParameters)
|
||||||
|
{
|
||||||
|
$parameters = array_replace(
|
||||||
|
$request->query->all(),
|
||||||
|
array_intersect_key($routeParameters, [
|
||||||
|
'sbas_id' => null,
|
||||||
|
'record_id' => null,
|
||||||
|
'subdef' => null,
|
||||||
|
'label' => null,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$databox = $this->appbox->get_databox((int) $parameters['sbas_id']);
|
||||||
|
$record = $databox->get_record((int)$parameters['record_id']);
|
||||||
|
$subdef = $record->get_subdef($parameters['subdef']);
|
||||||
|
|
||||||
|
$urlGenerator = $this->urlGenerator;
|
||||||
|
$url = $urlGenerator->generate($routeName, $parameters, $urlGenerator::ABSOLUTE_URL);
|
||||||
|
$embedUrl = $urlGenerator->generate('alchemy_embed_view', ['url' => $url], $urlGenerator::ABSOLUTE_URL);
|
||||||
|
|
||||||
|
return new MediaInformation($subdef, $url, $embedUrl);
|
||||||
|
}
|
||||||
|
}
|
@@ -33,15 +33,15 @@
|
|||||||
|
|
||||||
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %}
|
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% elseif record_type == 'FLEXPAPER' %}
|
{% elseif record_type == 'FLEXPAPER' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% elseif record_type == 'AUDIO_MP3' %}
|
{% elseif record_type == 'AUDIO_MP3' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% else %}
|
{% else %}
|
||||||
<img class="record record_image imgTips zoomable thumb" oncontextMenu="return(false);"
|
<img class="record record_image imgTips zoomable thumb" oncontextMenu="return(false);"
|
||||||
@@ -58,15 +58,15 @@
|
|||||||
{% set record_type = thumbnail.get_type() %}
|
{% set record_type = thumbnail.get_type() %}
|
||||||
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %}
|
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% elseif record_type == 'FLEXPAPER' %}
|
{% elseif record_type == 'FLEXPAPER' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% elseif record_type == 'AUDIO_MP3' %}
|
{% elseif record_type == 'AUDIO_MP3' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% else %}
|
{% else %}
|
||||||
<img style="max-height: 100%;max-width:100%" class="record record_image imgTips zoomable thumb" oncontextMenu="return(false);"
|
<img style="max-height: 100%;max-width:100%" class="record record_image imgTips zoomable thumb" oncontextMenu="return(false);"
|
||||||
|
@@ -13,16 +13,16 @@
|
|||||||
<div style="width:{{original_w}}px;height: {{ original_h }}px" class="videoTips">
|
<div style="width:{{original_w}}px;height: {{ original_h }}px" class="videoTips">
|
||||||
|
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
</div>
|
</div>
|
||||||
{% elseif record_type == 'FLEXPAPER' %}
|
{% elseif record_type == 'FLEXPAPER' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% elseif record_type == 'AUDIO_MP3' %}
|
{% elseif record_type == 'AUDIO_MP3' %}
|
||||||
<iframe width="100%" height="100%"
|
<iframe width="100%" height="100%"
|
||||||
src="{{ app['request'].baseUrl }}/embed/datafiles/?url={{ url|url_encode }}&autoplay={{ autoplay|default('false') }}"
|
src="{{ url('alchemy_embed_view', ['url': url, 'autoplay': autoplay|default('false')]) }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set fit_size = fitIn(
|
{% set fit_size = fitIn(
|
||||||
|
@@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content-container" >
|
<div class="content-container" >
|
||||||
<h1>{{ record.get_title() }}</h1>
|
<h1>{{ local_title }}</h1>
|
||||||
|
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
<iframe width="100%" height="{{ subdef.get_height() }}"
|
<iframe width="100%" height="{{ subdef.get_height() }}"
|
||||||
src="{{ app['request'].baseUrl }}/embed/{{ subdef.get_sbas_id() }}/{{ record.getRecordId() }}/{{ subdef.get_name() }}/?token={{ token }}"
|
src="{{ recordUrl }}"
|
||||||
frameborder="0" allowfullscreen></iframe>
|
frameborder="0" allowfullscreen></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user