mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +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'])));
|
||||
}
|
||||
|
||||
$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) {
|
||||
if ($name == $request->get('name') &&
|
||||
null !== ($subdef = $this->list_embedable_media($record, $media, $this->app['phraseanet.registry']))) {
|
||||
|
@@ -14,6 +14,6 @@ class p4field
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$base_url = '';
|
||||
|
||||
$subdef_def = false;
|
||||
|
||||
if ($name == 'document') {
|
||||
$baseprefs = $this->get_databox()->get_sxml_structure();
|
||||
|
||||
@@ -1028,6 +1024,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
$path_file_dest = $path . $newfilename;
|
||||
}
|
||||
|
||||
if($adapt) {
|
||||
try {
|
||||
$app['media-alchemyst']->turnInto(
|
||||
$media->getFile()->getRealPath(),
|
||||
@@ -1039,13 +1036,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
}
|
||||
|
||||
$subdefFile = $path_file_dest;
|
||||
}
|
||||
else{
|
||||
$app['filesystem']->copy($media->getFile()->getRealPath(), $path_file_dest);
|
||||
|
||||
$subdefFile = $path_file_dest;
|
||||
}
|
||||
|
||||
$meta_writable = $subdef_def->meta_writeable();
|
||||
}
|
||||
|
||||
$app['filesystem']->chmod($subdefFile, 0760);
|
||||
$media = $app['mediavorus']->guess($subdefFile);
|
||||
|
||||
$subdef = media_subdef::create($app, $this, $name, $media);
|
||||
$subdef->set_substituted(true);
|
||||
|
||||
@@ -1055,7 +1057,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
$this->write_metas();
|
||||
}
|
||||
|
||||
if ($name == 'document') {
|
||||
if ($name == 'document' && $adapt) {
|
||||
$this->rebuild_subdefs();
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% set selectionLength = records|length %}
|
||||
|
||||
{% set nbHdSubstitute = 0 %}
|
||||
{% set nbThumbSubstitute = 0 %}
|
||||
{% set nbSubdefSubstitute = 0 %}
|
||||
|
||||
{% for record in records %}
|
||||
{% set subdefs = record.get_subdefs() %}
|
||||
@@ -9,10 +9,8 @@
|
||||
{% for key, subdef in subdefs if subdef.is_substituted() %}
|
||||
{% if key == 'document' %}
|
||||
{% set nbHdSubstitute = nbHdSubstitute + 1 %}
|
||||
{% endif%}
|
||||
|
||||
{% if key == 'thumbnail' %}
|
||||
{% set nbThumbSubstitute = nbThumbSubstitute + 1 %}
|
||||
{% else %}
|
||||
{% set nbSubdefSubstitute = nbSubdefSubstitute + 1 %}
|
||||
{% endif%}
|
||||
|
||||
{% endfor %}
|
||||
@@ -68,7 +66,7 @@
|
||||
<form id="new-img-form" action="{{ path('prod_tools_image') }}" method="post">
|
||||
<fieldset style='border:1px solid #999; padding:20px;'>
|
||||
<legend style='color:#EEE'> <b>{% trans "Reconstruire les sous definitions" %}</b> </legend>
|
||||
{% if nbThumbSubstitute > 0 %}
|
||||
{% if nbSubdefSubstitute > 0 %}
|
||||
<div style="color:#A00;">
|
||||
{% trans "Attention, certain documents ont des sous-definitions substituees" %}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user