mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
#PHRAS-325
add parameter "adapt" to route "/embed/substitute" fix : substituted was indicated only for thumbnails on prod/tools/recreate
This commit is contained in:
@@ -561,7 +561,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_label($this->app['locale.I18n'])));
|
throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_label($this->app['locale.I18n'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
$record->substitute_subdef($request->get('name'), $media, $app);
|
$adapt = $request->get('adapt')===null || !(\p4field::isno($request->get('adapt')));
|
||||||
|
$ret['adapt'] = $adapt;
|
||||||
|
$record->substitute_subdef($request->get('name'), $media, $app, $adapt);
|
||||||
foreach ($record->get_embedable_medias() as $name => $media) {
|
foreach ($record->get_embedable_medias() as $name => $media) {
|
||||||
if ($name == $request->get('name') &&
|
if ($name == $request->get('name') &&
|
||||||
null !== ($subdef = $this->list_embedable_media($record, $media, $this->app['phraseanet.registry']))) {
|
null !== ($subdef = $this->list_embedable_media($record, $media, $this->app['phraseanet.registry']))) {
|
||||||
|
@@ -14,6 +14,6 @@ class p4field
|
|||||||
{
|
{
|
||||||
$v = mb_strtolower(trim($v));
|
$v = mb_strtolower(trim($v));
|
||||||
|
|
||||||
return($v == '0' || $v == 'n' || $v == 'no' || $v == 'non' || $v = 'off' || $v == 'false');
|
return($v == '0' || $v == 'n' || $v == 'no' || $v == 'non' || $v == 'off' || $v == 'false');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -991,14 +991,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $this->get_databox()->get_sbas_id();
|
return $this->get_databox()->get_sbas_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function substitute_subdef($name, MediaInterface $media, Application $app)
|
public function substitute_subdef($name, MediaInterface $media, Application $app, $adapt=true)
|
||||||
{
|
{
|
||||||
$newfilename = $this->record_id . '_0_' . $name . '.' . $media->getFile()->getExtension();
|
$newfilename = $this->record_id . '_0_' . $name . '.' . $media->getFile()->getExtension();
|
||||||
|
|
||||||
$base_url = '';
|
|
||||||
|
|
||||||
$subdef_def = false;
|
|
||||||
|
|
||||||
if ($name == 'document') {
|
if ($name == 'document') {
|
||||||
$baseprefs = $this->get_databox()->get_sxml_structure();
|
$baseprefs = $this->get_databox()->get_sxml_structure();
|
||||||
|
|
||||||
@@ -1028,24 +1024,30 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$path_file_dest = $path . $newfilename;
|
$path_file_dest = $path . $newfilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if($adapt) {
|
||||||
$app['media-alchemyst']->turnInto(
|
try {
|
||||||
$media->getFile()->getRealPath(),
|
$app['media-alchemyst']->turnInto(
|
||||||
$path_file_dest,
|
$media->getFile()->getRealPath(),
|
||||||
$subdef_def->getSpecs()
|
$path_file_dest,
|
||||||
);
|
$subdef_def->getSpecs()
|
||||||
} catch (\MediaAlchemyst\Exception\ExceptionInterface $e) {
|
);
|
||||||
return $this;
|
} catch (\MediaAlchemyst\Exception\ExceptionInterface $e) {
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$subdefFile = $path_file_dest;
|
$subdefFile = $path_file_dest;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$app['filesystem']->copy($media->getFile()->getRealPath(), $path_file_dest);
|
||||||
|
|
||||||
|
$subdefFile = $path_file_dest;
|
||||||
|
}
|
||||||
|
|
||||||
$meta_writable = $subdef_def->meta_writeable();
|
$meta_writable = $subdef_def->meta_writeable();
|
||||||
}
|
}
|
||||||
|
|
||||||
$app['filesystem']->chmod($subdefFile, 0760);
|
$app['filesystem']->chmod($subdefFile, 0760);
|
||||||
$media = $app['mediavorus']->guess($subdefFile);
|
$media = $app['mediavorus']->guess($subdefFile);
|
||||||
|
|
||||||
$subdef = media_subdef::create($app, $this, $name, $media);
|
$subdef = media_subdef::create($app, $this, $name, $media);
|
||||||
$subdef->set_substituted(true);
|
$subdef->set_substituted(true);
|
||||||
|
|
||||||
@@ -1055,7 +1057,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$this->write_metas();
|
$this->write_metas();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name == 'document') {
|
if ($name == 'document' && $adapt) {
|
||||||
$this->rebuild_subdefs();
|
$this->rebuild_subdefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{% set selectionLength = records|length %}
|
{% set selectionLength = records|length %}
|
||||||
|
|
||||||
{% set nbHdSubstitute = 0 %}
|
{% set nbHdSubstitute = 0 %}
|
||||||
{% set nbThumbSubstitute = 0 %}
|
{% set nbSubdefSubstitute = 0 %}
|
||||||
|
|
||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
{% set subdefs = record.get_subdefs() %}
|
{% set subdefs = record.get_subdefs() %}
|
||||||
@@ -9,10 +9,8 @@
|
|||||||
{% for key, subdef in subdefs if subdef.is_substituted() %}
|
{% for key, subdef in subdefs if subdef.is_substituted() %}
|
||||||
{% if key == 'document' %}
|
{% if key == 'document' %}
|
||||||
{% set nbHdSubstitute = nbHdSubstitute + 1 %}
|
{% set nbHdSubstitute = nbHdSubstitute + 1 %}
|
||||||
{% endif%}
|
{% else %}
|
||||||
|
{% set nbSubdefSubstitute = nbSubdefSubstitute + 1 %}
|
||||||
{% if key == 'thumbnail' %}
|
|
||||||
{% set nbThumbSubstitute = nbThumbSubstitute + 1 %}
|
|
||||||
{% endif%}
|
{% endif%}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -68,7 +66,7 @@
|
|||||||
<form id="new-img-form" action="{{ path('prod_tools_image') }}" method="post">
|
<form id="new-img-form" action="{{ path('prod_tools_image') }}" method="post">
|
||||||
<fieldset style='border:1px solid #999; padding:20px;'>
|
<fieldset style='border:1px solid #999; padding:20px;'>
|
||||||
<legend style='color:#EEE'> <b>{% trans "Reconstruire les sous definitions" %}</b> </legend>
|
<legend style='color:#EEE'> <b>{% trans "Reconstruire les sous definitions" %}</b> </legend>
|
||||||
{% if nbThumbSubstitute > 0 %}
|
{% if nbSubdefSubstitute > 0 %}
|
||||||
<div style="color:#A00;">
|
<div style="color:#A00;">
|
||||||
{% trans "Attention, certain documents ont des sous-definitions substituees" %}
|
{% trans "Attention, certain documents ont des sous-definitions substituees" %}
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user