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 2328bc772d
commit 779c29dd16
2 changed files with 36 additions and 48 deletions

View File

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

View File

@@ -19,14 +19,6 @@
{% endif %}
{% 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">
{# jquery Tabs #}
@@ -50,14 +42,12 @@
{% endif %}
{% endfor %}
{% endif %}
{% if allowRotate == 1%}
<li>
<a href="#image">
{{ "image tool" | trans }}
</a>
</li>
{% endif %}
{% if selectionLength == 1 and (app['conf'].get(['registry', 'modules', 'doc-substitution']) or app['conf'].get(['registry', 'modules', 'thumb-substitution'])) %}
{% if selectionLength == 1 and (app['phraseanet.registry'].get('GV_seeOngChgDoc') or app['phraseanet.registry'].get('GV_seeNewThumb')) %}
<li>
<a href="#substitution">
{{ "substitution" | trans }}
@@ -242,11 +232,13 @@
{% endfor %}
{% endif %}
{% if allowRotate == 1 %}
<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">
<fieldset style='border:1px solid #999;padding:20px;'>
<legend style='color:#EEE'>&nbsp;<b>{{ "image rotation" | trans }}</b>&nbsp;</legend>
<legend style='color:#EEE'>&nbsp;<b>{% trans "image rotation" %}</b>&nbsp;</legend>
<label for="ROTA_90" class="radio">
<input type="radio" name="rotation" id="ROTA_90" value="90" checked="checked">
{{ "rotation 90 degres horaire" | trans }}
@@ -261,12 +253,11 @@
<input type="hidden" name="cchd" value="" />
</fieldset>
<div style='text-align:right;padding-top:10px;'>
<button class="action_submiter btn btn-inverse">{{ "validate" | trans }}</button>
<button class="action_cancel btn btn-inverse">{{ "cancel" | trans }}</button>
<button class="action_submiter btn btn-inverse">{% trans "validate" %}</button>
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
</div>
</form>
</div>
{% endif %}
{# hd sub section #}
{% if selectionLength == 1 and (app['conf'].get(['registry', 'modules', 'doc-substitution']) or app['conf'].get(['registry', 'modules', 'thumb-substitution'])) %}