mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Add better support for stories
This commit is contained in:
@@ -596,7 +596,7 @@ return call_user_func(function() {
|
|||||||
$route = '/stories/{databox_id}/{story_id}/embed/';
|
$route = '/stories/{databox_id}/{story_id}/embed/';
|
||||||
$app->get(
|
$app->get(
|
||||||
$route, function($databox_id, $story_id) use ($app) {
|
$route, function($databox_id, $story_id) use ($app) {
|
||||||
$result = $app['api']->get_record_embed($app['request'], $databox_id, $story_id);
|
$result = $app['api']->get_story_embed($app['request'], $databox_id, $story_id);
|
||||||
|
|
||||||
return $result->get_response();
|
return $result->get_response();
|
||||||
}
|
}
|
||||||
|
@@ -117,8 +117,11 @@ class Tooltip implements ControllerProviderInterface
|
|||||||
$controllers->post('/tc_datas/{sbas_id}/{record_id}/'
|
$controllers->post('/tc_datas/{sbas_id}/{record_id}/'
|
||||||
, function(Application $app, $sbas_id, $record_id) {
|
, function(Application $app, $sbas_id, $record_id) {
|
||||||
$record = new \record_adapter($sbas_id, $record_id);
|
$record = new \record_adapter($sbas_id, $record_id);
|
||||||
|
try {
|
||||||
$document = $record->get_subdef('document');
|
$document = $record->get_subdef('document');
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
$document = null;
|
||||||
|
}
|
||||||
/* @var $twig \Twig_Environment */
|
/* @var $twig \Twig_Environment */
|
||||||
$twig = $app['Core']->getTwig();
|
$twig = $app['Core']->getTwig();
|
||||||
|
|
||||||
|
@@ -1026,7 +1026,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$stories = array_map(function ($story) use ($that) {
|
$stories = array_map(function ($story) use ($that) {
|
||||||
return $that->list_story($story);
|
return $that->list_story($story);
|
||||||
}, $record->get_grouping_parents()->get_elements());
|
}, array_values($record->get_grouping_parents()->get_elements()));
|
||||||
|
|
||||||
$result->set_datas(array(
|
$result->set_datas(array(
|
||||||
"baskets" => $baskets,
|
"baskets" => $baskets,
|
||||||
@@ -1120,6 +1120,36 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an API_V1_result containing the story embed files
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $databox_id
|
||||||
|
* @param int $record_id
|
||||||
|
* @param string $response_type
|
||||||
|
* @return API_V1_result
|
||||||
|
*/
|
||||||
|
public function get_story_embed(Request $request, $databox_id, $record_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
|
$record = $this->appbox->get_databox($databox_id)->get_record($record_id);
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
$devices = $request->get('devices', array());
|
||||||
|
$mimes = $request->get('mimes', array());
|
||||||
|
|
||||||
|
foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) {
|
||||||
|
$ret[] = $this->list_embedable_media($media, $this->appbox->get_registry());
|
||||||
|
}
|
||||||
|
|
||||||
|
$result->set_datas(array("embed" => $ret));
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function set_record_metadatas(Request $request, $databox_id, $record_id)
|
public function set_record_metadatas(Request $request, $databox_id, $record_id)
|
||||||
{
|
{
|
||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
@@ -371,7 +371,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function get_embedable_medias($devices = null, $mimes = null)
|
public function get_embedable_medias($devices = null, $mimes = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->getSubdfefByDeviceAndMime($devices, $mimes);
|
return $this->getSubdfefByDeviceAndMime($devices, $mimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,9 +706,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$searchDevices = array_merge((array) $devices, (array) databox_subdef::DEVICE_ALL);
|
$searchDevices = array_merge((array) $devices, (array) databox_subdef::DEVICE_ALL);
|
||||||
|
|
||||||
|
$type = $this->is_grouping() ? 'image' : $this->get_type();
|
||||||
|
|
||||||
foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) {
|
foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) {
|
||||||
|
|
||||||
if ($this->get_type() != $group) {
|
if ($type != $group) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,8 @@
|
|||||||
|
{% if record.is_grouping() %}
|
||||||
|
{% trans 'Story_id' %} : {{ record.get_record_id() }}<br/>
|
||||||
|
{% else %}
|
||||||
{% trans 'Record_id' %} : {{ record.get_record_id() }}<br/>
|
{% trans 'Record_id' %} : {{ record.get_record_id() }}<br/>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if record.is_grouping() == false %}
|
{% if record.is_grouping() == false %}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user