mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Fix sub views substitution
This commit is contained in:
committed by
Romain Neutron
parent
04dad80692
commit
93aa9be0fa
@@ -205,13 +205,13 @@ class Tools implements ControllerProviderInterface
|
|||||||
, $request->get('record_id')
|
, $request->get('record_id')
|
||||||
);
|
);
|
||||||
|
|
||||||
$media = $app['Core']['mediavorus']->guess($file);
|
$media = $app['Core']['mediavorus']->guess(new \SplFileInfo($tmpFile));
|
||||||
|
|
||||||
$record->substitute_subdef('thumbnail', $media);
|
$record->substitute_subdef('thumbnail', $media);
|
||||||
|
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$errorMessage = $e->getMessage();
|
$errorMessage = _('An error occured');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = _('file is not valid');
|
$errorMessage = _('file is not valid');
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if selectionLength == 1 and registry.get('GV_seeOngChgDoc') %}
|
{% if selectionLength == 1 and (registry.get('GV_seeOngChgDoc') or registry.get('GV_seeNewThumb')) %}
|
||||||
<li>
|
<li>
|
||||||
<a href="#substitution">
|
<a href="#substitution">
|
||||||
{% trans "substitution" %}
|
{% trans "substitution" %}
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{# subef section #}
|
{# subdef section #}
|
||||||
<div id="subdefs" class="tabBox">
|
<div id="subdefs" class="tabBox">
|
||||||
<form id="new-img-form" action="/prod/tools/image/" method="post">
|
<form id="new-img-form" action="/prod/tools/image/" method="post">
|
||||||
<fieldset style='border:1px solid #999; padding:20px;'>
|
<fieldset style='border:1px solid #999; padding:20px;'>
|
||||||
@@ -269,70 +269,74 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# hd sub section #}
|
{# hd sub section #}
|
||||||
{% if selectionLength == 1 %}
|
{% if selectionLength == 1 and (registry.get('GV_seeOngChgDoc') or registry.get('GV_seeNewThumb')) %}
|
||||||
{% for record in selection %}
|
{% for record in selection %}
|
||||||
<div id="substitution" class="tabBox">
|
<div id="substitution" class="tabBox">
|
||||||
|
|
||||||
{% if registry.get('GV_seeOngChgDoc') %}
|
{% if "unknown" == record.get_type() %}
|
||||||
<div id="substitution-hd">
|
<i class="icon-warning-sign icon-white"></i>{% trans "Substitution is not possible for this kind of record" %}
|
||||||
<form
|
{% else %}
|
||||||
name ="formchgHD"
|
{% if registry.get('GV_seeOngChgDoc') %}
|
||||||
action="/prod/tools/hddoc/"
|
<div id="substitution-hd">
|
||||||
enctype="multipart/form-data"
|
<form
|
||||||
method="post"
|
name ="formchgHD"
|
||||||
target="uploadHdsub">
|
action="/prod/tools/hddoc/"
|
||||||
|
enctype="multipart/form-data"
|
||||||
|
method="post"
|
||||||
|
target="uploadHdsub">
|
||||||
|
|
||||||
<fieldset style='border:1px solid #999;padding:20px;'>
|
<fieldset style='border:1px solid #999;padding:20px;'>
|
||||||
<legend style='color:#EEE'> <b>{% trans "substitution HD" %}</b> </legend>
|
<legend style='color:#EEE'> <b>{% trans "substitution HD" %}</b> </legend>
|
||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
|
<input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
|
||||||
<input id='new-hd-file' name="newHD" type="file" />
|
<input id='new-hd-file' name="newHD" type="file"/>
|
||||||
<br />
|
<br />
|
||||||
<label for="CCFNALP" class="checkbox">
|
<label for="CCFNALP" class="checkbox">
|
||||||
<input type="checkbox" name="ccfilename" id="CCFNALP" value="1">
|
<input type="checkbox" name="ccfilename" id="CCFNALP" value="1">
|
||||||
{% trans "mettre a jour le nom original de fichier apres substitution"%}
|
{% trans "mettre a jour le nom original de fichier apres substitution"%}
|
||||||
</label>
|
</label>
|
||||||
<input type="hidden" name="ACT" value="SEND" />
|
<input type="hidden" name="ACT" value="SEND" />
|
||||||
<input type="hidden" name="sbas_id" value="{{record.get_sbas_id()}}"/>
|
<input type="hidden" name="sbas_id" value="{{record.get_sbas_id()}}"/>
|
||||||
<input type="hidden" name="record_id" value="{{record.get_record_id()}}" />
|
<input type="hidden" name="record_id" value="{{record.get_record_id()}}" />
|
||||||
<div class="load"></div>
|
<div class="load"></div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div style='text-align:right;padding-top:10px;'>
|
<div style='text-align:right;padding-top:10px;'>
|
||||||
<button class="iframe_submiter btn btn-inverse">{% trans "validate" %}</button>
|
<button class="iframe_submiter btn btn-inverse">{% trans "validate" %}</button>
|
||||||
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
|
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class='resultAction'></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
{% endif %}
|
||||||
<div class='resultAction'></div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if registry.get('GV_seeNewThumb') %}
|
{% if registry.get('GV_seeNewThumb') %}
|
||||||
<div id="substitution-sd">
|
<div id="substitution-sd">
|
||||||
<form
|
<form
|
||||||
name="formchgHD"
|
name="formchgHD"
|
||||||
action="/prod/tools/chgthumb/"
|
action="/prod/tools/chgthumb/"
|
||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
method="post"
|
method="post"
|
||||||
target="uploadHdsub">
|
target="uploadHdsub">
|
||||||
<fieldset style='border:1px solid #999;padding:20px;'>
|
<fieldset style='border:1px solid #999;padding:20px;'>
|
||||||
<legend style='color:#EEE'> <b>{% trans "substitution SD" %}</b> </legend>
|
<legend style='color:#EEE'> <b>{% trans "substitution SD" %}</b> </legend>
|
||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
|
<input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
|
||||||
<input id='new-sd-file' name="newThumb" type="file" />
|
<input id='new-sd-file' name="newThumb" type="file" />
|
||||||
<input type="hidden" name="sbas_id" value="{{record.get_sbas_id()}}" />
|
<input type="hidden" name="sbas_id" value="{{record.get_sbas_id()}}" />
|
||||||
<input type="hidden" name="record_id" value="{{record.get_record_id()}}" />
|
<input type="hidden" name="record_id" value="{{record.get_record_id()}}" />
|
||||||
<div class="load"></div>
|
<div class="load"></div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div style='text-align:right;padding-top:10px;'>
|
<div style='text-align:right;padding-top:10px;'>
|
||||||
<button class="iframe_submiter btn btn-inverse">{% trans "validate" %}</button>
|
<button class="iframe_submiter btn btn-inverse">{% trans "validate" %}</button>
|
||||||
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
|
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class='resultAction'></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
{% endif %}
|
||||||
<div class='resultAction'></div>
|
{% endif %}
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
59
tests/Alchemy/Phrasea/Controller/Prod/ToolsTest.php
Normal file
59
tests/Alchemy/Phrasea/Controller/Prod/ToolsTest.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
|
||||||
|
class ControllerToolsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
|
{
|
||||||
|
protected $client;
|
||||||
|
protected $tmpFile;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->client = $this->createClient();
|
||||||
|
$this->tmpFile = sys_get_temp_dir() . '/' . time() . mt_rand(1000, 9999) . '.jpg';
|
||||||
|
copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $this->tmpFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
if (file_exists($this->tmpFile)) {
|
||||||
|
unlink($this->tmpFile);
|
||||||
|
}
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createApplication()
|
||||||
|
{
|
||||||
|
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
|
||||||
|
|
||||||
|
$app['debug'] = true;
|
||||||
|
unset($app['exception_handler']);
|
||||||
|
|
||||||
|
return $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRouteChangeThumb()
|
||||||
|
{
|
||||||
|
$record = static::$records['record_1'];
|
||||||
|
|
||||||
|
$this->client->request('POST', '/tools/chgthumb/', array(
|
||||||
|
'sbas_id' => $record->get_sbas_id(),
|
||||||
|
'record_id' => $record->get_record_id(),
|
||||||
|
), array(
|
||||||
|
'newThumb' => new UploadedFile(
|
||||||
|
$this->tmpFile, 'KIKOO.JPG', 'image/jpg', 2000
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
$this->assertFalse(strpos(_('An error occured'), $content));
|
||||||
|
$this->assertFalse(strpos(_('file is not valid'), $content));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user