Allow to rotate thumbnails on all type of records

This commit is contained in:
Nicolas Le Goff
2014-06-12 17:13:45 +02:00
parent 26190331ed
commit fe6bdb21b2
2 changed files with 34 additions and 46 deletions

View File

@@ -68,26 +68,23 @@ class Tools implements ControllerProviderInterface
}); });
$controllers->post('/rotate/', function (Application $app, Request $request) { $controllers->post('/rotate/', function (Application $app, Request $request) {
$return = array('success' => true, 'errorMessage' => '');
$records = RecordsRequest::fromRequest($app, $request, false); $records = RecordsRequest::fromRequest($app, $request, false);
$rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90; $rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90;
foreach ($records as $record) { foreach ($records as $record) {
foreach ($record->get_subdefs() as $name => $subdef) { foreach ($record->get_subdefs() as $subdef) {
if ($name == 'document') if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
continue; continue;
}
try { try {
$subdef->rotate($rotation, $app['media-alchemyst'], $app['mediavorus']); $subdef->rotate($rotation, $app['media-alchemyst'], $app['mediavorus']);
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }
} }
return $app->json($return); return $app->json(array('success' => true, 'errorMessage' => ''));
})->bind('prod_tools_rotate'); })->bind('prod_tools_rotate');
$controllers->post('/image/', function (Application $app, Request $request) { $controllers->post('/image/', function (Application $app, Request $request) {

View File

@@ -19,14 +19,6 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{# image section #}
{% set allowRotate = '0' %}
{% for record in records %}
{% if record.get_type() == 'image' %}
{% set allowRotate = '1' %}
{% endif %}
{% endfor %}
<div id='prod-tool-box' class="PNB10"> <div id='prod-tool-box' class="PNB10">
{# jquery Tabs #} {# jquery Tabs #}
@@ -50,13 +42,11 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if allowRotate == 1%}
<li> <li>
<a href="#image"> <a href="#image">
{% trans "image tool"%} {% trans "image tool"%}
</a> </a>
</li> </li>
{% endif %}
{% if selectionLength == 1 and (app['phraseanet.registry'].get('GV_seeOngChgDoc') or app['phraseanet.registry'].get('GV_seeNewThumb')) %} {% if selectionLength == 1 and (app['phraseanet.registry'].get('GV_seeOngChgDoc') or app['phraseanet.registry'].get('GV_seeNewThumb')) %}
<li> <li>
<a href="#substitution"> <a href="#substitution">
@@ -242,8 +232,10 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if allowRotate == 1 %}
<div id="image" class="tabBox"> <div id="image" class="tabBox">
<div class="text-info">
<i class=" icon-info-sign"></i> {% trans %}Changes for rotation will be applied only on the sub-definitions of "image" type.{% endtrans %}
</div>
<form name="formpushdoc" action="{{ path('prod_tools_rotate') }}" method="post"> <form name="formpushdoc" action="{{ path('prod_tools_rotate') }}" method="post">
<fieldset style='border:1px solid #999;padding:20px;'> <fieldset style='border:1px solid #999;padding:20px;'>
<legend style='color:#EEE'>&nbsp;<b>{% trans "image rotation" %}</b>&nbsp;</legend> <legend style='color:#EEE'>&nbsp;<b>{% trans "image rotation" %}</b>&nbsp;</legend>
@@ -266,7 +258,6 @@
</div> </div>
</form> </form>
</div> </div>
{% endif %}
{# hd sub section #} {# hd sub section #}
{% if selectionLength == 1 and (app['phraseanet.registry'].get('GV_seeOngChgDoc') or app['phraseanet.registry'].get('GV_seeNewThumb')) %} {% if selectionLength == 1 and (app['phraseanet.registry'].get('GV_seeOngChgDoc') or app['phraseanet.registry'].get('GV_seeNewThumb')) %}