From 47bb3331dd47373b08074ec33ae5f131442f2bae Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 13:00:16 +0200 Subject: [PATCH 01/14] Move substituion logger from class method to controllers --- lib/Alchemy/Phrasea/Controller/Prod/Edit.php | 6 ++++++ lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php | 6 ++++++ lib/Alchemy/Phrasea/Controller/Prod/Tools.php | 8 ++++++++ lib/classes/record/adapter.php | 5 ----- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index f5d95a70bb..7658079c3c 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -294,6 +294,12 @@ class Edit implements ControllerProviderInterface } $media = $app['mediavorus']->guess($value->get_pathfile()); $reg_record->substitute_subdef($name, $media, $app); + $app['phraseanet.logger']($reg_record->get_databox())->log( + $reg_record, + \Session_Logger::EVENT_SUBSTITUTE, + $name == 'document' ? 'HD' : $name, + '' + ); } } catch (\Exception $e) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index d6ed2e3e5d..516e85de2d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -483,6 +483,12 @@ class Lazaret implements ControllerProviderInterface $record = $lazaretFile->getCollection($app)->get_databox()->get_record($recordId); $record->substitute_subdef('document', $media, $app); + $app['phraseanet.logger']($record->get_databox())->log( + $record, + \Session_Logger::EVENT_SUBSTITUTE, + 'HD', + '' + ); //Delete lazaret file $app['EM']->remove($lazaretFile); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php index 873ded0ec5..7e6b6f4960 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php @@ -142,6 +142,7 @@ class Tools implements ControllerProviderInterface $media = $app['mediavorus']->guess($tempoFile); $record->substitute_subdef('document', $media, $app); + $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'HD', ''); if ((int) $request->request->get('ccfilename') === 1) { $record->set_original_name($fileName); @@ -194,6 +195,7 @@ class Tools implements ControllerProviderInterface $media = $app['mediavorus']->guess($tempoFile); $record->substitute_subdef('thumbnail', $media, $app); + $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', ''); unlink($tempoFile); rmdir($tempoDir); @@ -253,6 +255,12 @@ class Tools implements ControllerProviderInterface $media = $app['mediavorus']->guess($fileName); $record->substitute_subdef('thumbnail', $media, $app); + $app['phraseanet.logger']($record->get_databox())->log( + $record, + \Session_Logger::EVENT_SUBSTITUTE, + 'thumbnail', + '' + ); unset($media); $app['filesystem']->remove($fileName); diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 5d76249393..78aaa2c822 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -1036,11 +1036,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface $this->rebuild_subdefs(); } - $type = $name == 'document' ? 'HD' : $name; - - $this->app['phraseanet.logger']($this->get_databox()) - ->log($this, Session_Logger::EVENT_SUBSTITUTE, $type, ''); - return $this; } From db359920c86665aed9bc08a9f09d6d1b369fa4fb Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 13:45:58 +0200 Subject: [PATCH 02/14] Fix #1414 Add immediate thumbnail substitution after success download --- .../Phrasea/Controller/Prod/Upload.php | 26 +++++++++++++++++++ templates/web/prod/upload/upload.html.twig | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 8e96e4b69c..4fa1653265 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -13,6 +13,8 @@ namespace Alchemy\Phrasea\Controller\Prod; use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\Attribute\Status; +use DataURI; +use DataURI\Exception\Exception as DataUriException; use Entities\LazaretSession; use Silex\Application; use Silex\ControllerProviderInterface; @@ -243,6 +245,30 @@ class Upload implements ControllerProviderInterface $element = 'record'; $message = _('The record was successfully created'); $app['phraseanet.SE']->addRecord($elementCreated); + + // try to create thumbnail from data URI + if ('' !== $b64Image = $request->request->get('b64_image', '')) { + try { + $dataUri = DataURI\Parser::parse($b64Image); + + $fileName = sprintf('%s/tmp/%s.png', $app['root.path'], sprintf('base_64_thumb_%s', $id)); + file_put_contents($fileName, $dataUri->getData()); + + $media = $app['mediavorus']->guess($fileName); + $elementCreated->substitute_subdef('thumbnail', $media, $app); + $app['phraseanet.logger']($elementCreated->get_databox())->log( + $elementCreated, + \Session_Logger::EVENT_SUBSTITUTE, + 'thumbnail', + '' + ); + + unset($media); + $app['filesystem']->remove($fileName); + } catch (DataUriException $e) { + + } + } } else { $params = array('lazaret_file' => $elementCreated); diff --git a/templates/web/prod/upload/upload.html.twig b/templates/web/prod/upload/upload.html.twig index f9cc5145fc..94c331a368 100644 --- a/templates/web/prod/upload/upload.html.twig +++ b/templates/web/prod/upload/upload.html.twig @@ -336,6 +336,7 @@ $(document).ready(function () { UploaderManager.Preview.render(file, function(img){ context.find('.thumbnail .canva-wrapper').prepend(img); UploaderManager.addAttributeToData(uploadIndex, 'image', img); + UploaderManager.addAttributeToData(uploadIndex, 'b64_image', img.toDataURL("image/png") || ''); }); } }); @@ -390,6 +391,11 @@ $(document).ready(function () { $("select", UploaderManager.getSettingsBox()).serializeArray() ); + data.formData.push({ + "name": "b64_image", + "value": data["b64_image"] + }); + //remove current context data.context.remove(); From 74f8bc3c3c52d0135a4af7c75401d51db8e904a6 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 13:50:17 +0200 Subject: [PATCH 03/14] Fix CS --- lib/Alchemy/Phrasea/Controller/Prod/Tools.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php index 7e6b6f4960..d65a0d5499 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php @@ -142,7 +142,12 @@ class Tools implements ControllerProviderInterface $media = $app['mediavorus']->guess($tempoFile); $record->substitute_subdef('document', $media, $app); - $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'HD', ''); + $app['phraseanet.logger']($record->get_databox())->log( + $record, + \Session_Logger::EVENT_SUBSTITUTE, + 'HD', + '' + ); if ((int) $request->request->get('ccfilename') === 1) { $record->set_original_name($fileName); @@ -195,7 +200,12 @@ class Tools implements ControllerProviderInterface $media = $app['mediavorus']->guess($tempoFile); $record->substitute_subdef('thumbnail', $media, $app); - $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', ''); + $app['phraseanet.logger']($record->get_databox())->log( + $record, + \Session_Logger::EVENT_SUBSTITUTE, + 'thumbnail', + '' + ); unlink($tempoFile); rmdir($tempoDir); From 416113574d5231120636d956d25c5fb81dfa36b8 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 15:03:57 +0200 Subject: [PATCH 04/14] Use temporary file system --- lib/Alchemy/Phrasea/Controller/Prod/Upload.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 4fa1653265..52bc355032 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -251,9 +251,8 @@ class Upload implements ControllerProviderInterface try { $dataUri = DataURI\Parser::parse($b64Image); - $fileName = sprintf('%s/tmp/%s.png', $app['root.path'], sprintf('base_64_thumb_%s', $id)); + $fileName = $app['temporary-filesystem']->createTemporaryFile('base_64_thumb', null, "png"); file_put_contents($fileName, $dataUri->getData()); - $media = $app['mediavorus']->guess($fileName); $elementCreated->substitute_subdef('thumbnail', $media, $app); $app['phraseanet.logger']($elementCreated->get_databox())->log( @@ -264,7 +263,7 @@ class Upload implements ControllerProviderInterface ); unset($media); - $app['filesystem']->remove($fileName); + $app['temporary-filesystem']->clean('base_64_thumb'); } catch (DataUriException $e) { } From 04b40ad97a94ad5a8c7ed5da3fda27ad304c9b53 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 16:20:16 +0200 Subject: [PATCH 05/14] Fix & enhance unit tests --- .../Tests/Phrasea/Controller/Prod/LazaretTest.php | 10 ++++++++++ .../Tests/Phrasea/Controller/Prod/UploadTest.php | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php index 85eb660ea1..d233275c48 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php @@ -442,12 +442,22 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $em->expects($this->once()) ->method('flush'); + $called = false; + $phpunit = $this; + self::$DI['app']['phraseanet.logger'] = self::$DI['app']->protect(function () use (&$called, $phpunit) { + $called = true; + return $phpunit->getMockBuilder('\Session_Logger') + ->disableOriginalConstructor() + ->getMock(); + }); + self::$DI['app']['EM'] = $em; self::$DI['client'] = new Client(self::$DI['app'], array()); self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/', array( 'record_id' => self::$DI['record_1']->get_record_id() )); + $this->assertTrue($called); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index 11b2f42056..0e12b1dbb3 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -4,6 +4,7 @@ namespace Alchemy\Tests\Phrasea\Controller\Prod; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\Manager; +use DataURI; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Response; @@ -76,8 +77,10 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->disableOriginalConstructor() ->getMock(); + $data = DataUri\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg'); $params = array( - 'base_id' => self::$DI['collection']->get_base_id() + 'base_id' => self::$DI['collection']->get_base_id(), + 'b64_image' => DataUri\Dumper::dump($data) ); $files = array( From f20b916004c707aec12402ffc6cddb022c173579 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 16:22:11 +0200 Subject: [PATCH 06/14] Adressed @romainneutron 's comments --- .../Phrasea/Controller/Prod/Upload.php | 4 +- .../Phrasea/Controller/Prod/UploadTest.php | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 52bc355032..b393431bf8 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod; use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\Attribute\Status; -use DataURI; +use DataURI\Parser; use DataURI\Exception\Exception as DataUriException; use Entities\LazaretSession; use Silex\Application; @@ -249,7 +249,7 @@ class Upload implements ControllerProviderInterface // try to create thumbnail from data URI if ('' !== $b64Image = $request->request->get('b64_image', '')) { try { - $dataUri = DataURI\Parser::parse($b64Image); + $dataUri = Parser::parse($b64Image); $fileName = $app['temporary-filesystem']->createTemporaryFile('base_64_thumb', null, "png"); file_put_contents($fileName, $dataUri->getData()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index 0e12b1dbb3..78cd6ac926 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -104,6 +104,48 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); + $this->assertTrue($record->get_thumbnail()->is_physically_present()); + } + } + + + /** + * @covers Alchemy\Phrasea\Controller\Prod\Upload::upload + * @covers Alchemy\Phrasea\Controller\Prod\Upload::getJsonResponse + */ + public function testUploadWithoutB64Image() + { + self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer') + ->disableOriginalConstructor() + ->getMock(); + + $params = array( + 'base_id' => self::$DI['collection']->get_base_id() + ); + + $files = array( + 'files' => array( + new UploadedFile( + $this->tmpFile, 'KIKOO.JPG' + ) + ) + ); + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + + $response = self::$DI['client']->getResponse(); + + $this->checkJsonResponse($response); + + $datas = json_decode($response->getContent(), true); + + $this->assertTrue($datas['success']); + + if ($datas['element'] == 'record') { + $id = explode('_', $datas['id']); + + $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); + + $this->assertFalse($record->get_thumbnail()->is_physically_present()); } } From 7988114614132bcb64fdc2991c2d965fe1a771ac Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Sep 2013 12:21:11 +0200 Subject: [PATCH 07/14] Fix #1430 : Use strict standards, declare the method static --- lib/classes/task/abstract.php | 10 ++++++++-- lib/classes/task/period/RecordMover.php | 4 ++-- lib/classes/task/period/apibridge.php | 4 ++-- lib/classes/task/period/archive.php | 4 ++-- lib/classes/task/period/cindexer.php | 4 ++-- lib/classes/task/period/emptyColl.php | 4 ++-- lib/classes/task/period/ftp.php | 4 ++-- lib/classes/task/period/ftpPull.php | 4 ++-- lib/classes/task/period/subdef.php | 4 ++-- lib/classes/task/period/test.php | 4 ++-- lib/classes/task/period/writemeta.php | 4 ++-- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/classes/task/abstract.php b/lib/classes/task/abstract.php index e5bd318e7a..8d5032f85c 100644 --- a/lib/classes/task/abstract.php +++ b/lib/classes/task/abstract.php @@ -393,9 +393,15 @@ abstract class task_abstract return $this->completed_percentage; } - abstract public function getName(); + public static function getName() + { + throw new \LogicException('This method must be implemented'); + } - abstract public function help(); + public static function help() + { + throw new \LogicException('This method must be implemented'); + } /** * diff --git a/lib/classes/task/period/RecordMover.php b/lib/classes/task/period/RecordMover.php index 798995d191..26670d2139 100644 --- a/lib/classes/task/period/RecordMover.php +++ b/lib/classes/task/period/RecordMover.php @@ -16,7 +16,7 @@ class task_period_RecordMover extends task_appboxAbstract * * @return string */ - public function getName() + public static function getName() { return _("Record Mover"); } @@ -25,7 +25,7 @@ class task_period_RecordMover extends task_appboxAbstract * * @return string */ - public function help() + public static function help() { return ''; } diff --git a/lib/classes/task/period/apibridge.php b/lib/classes/task/period/apibridge.php index f299b0728e..ae316277bd 100644 --- a/lib/classes/task/period/apibridge.php +++ b/lib/classes/task/period/apibridge.php @@ -16,7 +16,7 @@ class task_period_apibridge extends task_appboxAbstract * Return the name of the task * @return string */ - public function getName() + public static function getName() { return 'API bridge uploader'; } @@ -25,7 +25,7 @@ class task_period_apibridge extends task_appboxAbstract * Get help * @return string */ - public function help() + public static function help() { return ''; } diff --git a/lib/classes/task/period/archive.php b/lib/classes/task/period/archive.php index a10fa8621c..6cfaa97992 100644 --- a/lib/classes/task/period/archive.php +++ b/lib/classes/task/period/archive.php @@ -64,7 +64,7 @@ class task_period_archive extends task_abstract * * @return string */ - public function getName() + public static function getName() { return _('task::archive:Archivage'); } @@ -284,7 +284,7 @@ class task_period_archive extends task_abstract * * @return string */ - public function help() + public static function help() { return _("task::archive:Archiving files found into a 'hotfolder'"); } diff --git a/lib/classes/task/period/cindexer.php b/lib/classes/task/period/cindexer.php index 8954a68475..399000bd2c 100644 --- a/lib/classes/task/period/cindexer.php +++ b/lib/classes/task/period/cindexer.php @@ -99,7 +99,7 @@ class task_period_cindexer extends task_abstract * * @return string */ - public function getName() + public static function getName() { return(_("Indexation task")); } @@ -108,7 +108,7 @@ class task_period_cindexer extends task_abstract * * @return string */ - public function help() + public static function help() { return(_("This task is used to index records for Phrasea engine.")); } diff --git a/lib/classes/task/period/emptyColl.php b/lib/classes/task/period/emptyColl.php index c9e4701a20..f855ad9d79 100644 --- a/lib/classes/task/period/emptyColl.php +++ b/lib/classes/task/period/emptyColl.php @@ -17,7 +17,7 @@ class task_period_emptyColl extends task_appboxAbstract protected $suicidable = true; protected $total_records = 0; - public function getName() + public static function getName() { return(_("Vidage de collection")); } @@ -27,7 +27,7 @@ class task_period_emptyColl extends task_appboxAbstract return false; } - public function help() + public static function help() { return("Vide une collection"); } diff --git a/lib/classes/task/period/ftp.php b/lib/classes/task/period/ftp.php index 8db4bf150e..42a8716b41 100644 --- a/lib/classes/task/period/ftp.php +++ b/lib/classes/task/period/ftp.php @@ -22,7 +22,7 @@ class task_period_ftp extends task_appboxAbstract * * @return string */ - public function getName() + public static function getName() { return(_("task::ftp:FTP Push")); } @@ -31,7 +31,7 @@ class task_period_ftp extends task_appboxAbstract * * @return string */ - public function help() + public static function help() { return ''; } diff --git a/lib/classes/task/period/ftpPull.php b/lib/classes/task/period/ftpPull.php index c9211b79ce..5ebb5a4cf1 100644 --- a/lib/classes/task/period/ftpPull.php +++ b/lib/classes/task/period/ftpPull.php @@ -23,12 +23,12 @@ class task_period_ftpPull extends task_appboxAbstract protected $ftppath; protected $localpath; - public function getName() + public static function getName() { return(_("task::ftp:FTP Pull")); } - public function help() + public static function help() { return ''; } diff --git a/lib/classes/task/period/subdef.php b/lib/classes/task/period/subdef.php index e5f8fa3f89..3bb096403b 100644 --- a/lib/classes/task/period/subdef.php +++ b/lib/classes/task/period/subdef.php @@ -41,7 +41,7 @@ class task_period_subdef extends task_databoxAbstract * * @return */ - public function help() + public static function help() { return( _("task::subdef:creation des sous definitions des documents d'origine") @@ -53,7 +53,7 @@ class task_period_subdef extends task_databoxAbstract * * @return string */ - public function getName() + public static function getName() { return(_('task::subdef:creation des sous definitions')); } diff --git a/lib/classes/task/period/test.php b/lib/classes/task/period/test.php index 6960457afc..ff3ebfd944 100644 --- a/lib/classes/task/period/test.php +++ b/lib/classes/task/period/test.php @@ -12,12 +12,12 @@ class task_period_test extends task_appboxAbstract { - public function getName() + public static function getName() { return "Test"; } - public function help() + public static function help() { return "just saying what i'm doing"; } diff --git a/lib/classes/task/period/writemeta.php b/lib/classes/task/period/writemeta.php index 3a0149aaf6..0bf40e9a6d 100644 --- a/lib/classes/task/period/writemeta.php +++ b/lib/classes/task/period/writemeta.php @@ -19,7 +19,7 @@ class task_period_writemeta extends task_databoxAbstract protected $clear_doc; protected $metasubdefs = array(); - public function help() + public static function help() { return(_("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)")); } @@ -30,7 +30,7 @@ class task_period_writemeta extends task_databoxAbstract parent::loadSettings($sx_task_settings); } - public function getName() + public static function getName() { return(_('task::writemeta:ecriture des metadatas')); } From 2192afc7021106bf0939234ef16ba4535ac40297 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Sep 2013 12:33:34 +0200 Subject: [PATCH 08/14] Fix #1422 : logfiles contain duplicates log messages --- lib/classes/module/console/taskrun.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/classes/module/console/taskrun.php b/lib/classes/module/console/taskrun.php index 55cd6867f5..582d844161 100644 --- a/lib/classes/module/console/taskrun.php +++ b/lib/classes/module/console/taskrun.php @@ -122,10 +122,6 @@ class module_console_taskrun extends Command $logger->pushHandler($handler); } - $logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log'; - $handler = new RotatingFileHandler($logfile, 10); - $logger->pushHandler($handler); - $this->task = $task_manager->getTask($task_id, $logger); register_tick_function(array($this, 'tick_handler'), true); From 3736510c729c630ab24b63981f34a8bf037dd8ef Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Sep 2013 13:57:22 +0200 Subject: [PATCH 09/14] Fix #1424 : Editing a story don't work --- lib/Alchemy/Phrasea/Controller/Prod/Edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index 7658079c3c..0a6c6ec23a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -270,7 +270,7 @@ class Edit implements ControllerProviderInterface $controllers->post('/apply/', function(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, array('canmodifrecord')); if (count($records->databoxes()) !== 1) { throw new \Exception('Unable to edit on multiple databoxes'); From f5cb2b993e0025308054f9435bf596f3409394ec Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Sep 2013 15:42:02 +0200 Subject: [PATCH 10/14] Fix #1427 stamp background --- lib/classes/recordutils/image.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/classes/recordutils/image.php b/lib/classes/recordutils/image.php index 89b8e337e0..4ae68ea737 100644 --- a/lib/classes/recordutils/image.php +++ b/lib/classes/recordutils/image.php @@ -34,19 +34,12 @@ class recordutils_image extends recordutils $palette = new RGB(); } - $xmlToColor = function($attr, $ret = array(255, 255, 255, 0)) use ($palette) { - foreach (explode(',', $attr) as $i => $v) { - if ($i > 3) { - break; - } - $v = (int) (trim($v)); - if ($v >= 0 && ($v <= 100 || ($i < 3 && $v < 256))) { - $ret[$i] = $v; - } + $xmlToColor = function($attr, $ret = array(255, 255, 255)) use ($palette) { + try { + return $palette->color($attr, 0); + } catch (ImagineException $e) { + return $palette->color($ret); } - $alpha = array_pop($ret); - - return $palette->color($ret, $alpha); }; $base_id = $subdef->get_record()->get_base_id(); @@ -151,8 +144,8 @@ class recordutils_image extends recordutils for ($istamp = 0; $istamp < $stampNodes->length; $istamp++) { $stamp = $stampNodes->item($istamp); - $stamp_background = $xmlToColor($stamp->getAttribute('background'), array(255, 255, 255, 0)); - + $stamp_background = $xmlToColor($stamp->getAttribute('background'), array(255, 255, 255)); + $stamp_position = strtoupper(trim($stamp->getAttribute('position'))); if (!in_array($stamp_position, array('TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'))) { $stamp_position = 'BOTTOM'; @@ -267,7 +260,7 @@ class recordutils_image extends recordutils $wrap = static::wrap($app['imagine'], $fontsize, 0, __DIR__ . '/arial.ttf', $txtline, $text_width); $txtblock[] = array( 'fontsize' => $fontsize, - 'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), array(0, 0, 0, 0)), + 'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), array(0, 0, 0)), 'h' => $wrap['toth'], 'lines' => $wrap['l'] ); From 6661b532eb7046124450abf96a9623124bf3adc1 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 2 Sep 2013 15:59:44 +0200 Subject: [PATCH 11/14] Fix #1426 : stamp text position --- lib/classes/recordutils/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/recordutils/image.php b/lib/classes/recordutils/image.php index 89b8e337e0..312d63a3ef 100644 --- a/lib/classes/recordutils/image.php +++ b/lib/classes/recordutils/image.php @@ -308,7 +308,7 @@ class recordutils_image extends recordutils $font = $app['imagine']->font(__DIR__ . '/arial.ttf', $block['fontsize'], $block['fontcolor']); foreach ($block['lines'] as $line) { if ($line['t'] != '') { - $draw->text($line['t'], $font, new Point(0, $txt_ypos), 0); + $draw->text($line['t'], $font, new Point($logo_reswidth, $txt_ypos), 0); } $txt_ypos += $line['h']; } From 1b5d6ba10e600d9149f31235035e879006d480d6 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 2 Sep 2013 16:03:14 +0200 Subject: [PATCH 12/14] Fix #1425 Zindex issue --- www/skins/prod/jquery.Dialog.js | 6 ++++-- www/skins/prod/jquery.edit.js | 10 ++++++---- www/skins/prod/jquery.main-prod.js | 13 ++++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/www/skins/prod/jquery.Dialog.js b/www/skins/prod/jquery.Dialog.js index b90f76a0a7..04106e58d8 100644 --- a/www/skins/prod/jquery.Dialog.js +++ b/www/skins/prod/jquery.Dialog.js @@ -140,8 +140,10 @@ var p4 = p4 || {}; modal:true, width:width, height:height, - close:CloseCallback, - zIndex:zIndex + open: function() { + $(this).dialog("widget").css("z-index", zIndex); + }, + close:CloseCallback }) .dialog('open').addClass('dialog-' + this.options.size); diff --git a/www/skins/prod/jquery.edit.js b/www/skins/prod/jquery.edit.js index da4f0def7b..2713ad757e 100644 --- a/www/skins/prod/jquery.edit.js +++ b/www/skins/prod/jquery.edit.js @@ -2075,8 +2075,7 @@ $('#EDIT_MID_R') }; - $("#Edit_copyPreset_dlg", p4.edit.editBox).dialog( { - zIndex:5000, + $("#Edit_copyPreset_dlg", p4.edit.editBox).dialog({ stack:true, closeOnEscape:true, resizable:false, @@ -2085,8 +2084,11 @@ $('#EDIT_MID_R') modal:true, width:600, title:language.newPreset, - open:function(event, ui) - { + close: function(event,ui) { + $(this).dialog("widget").css("z-index", "auto"); + }, + open:function(event, ui) { + $(this).dialog("widget").css("z-index", "5000"); $(".EDIT_presetTitle")[0].focus(); }, buttons:buttons diff --git a/www/skins/prod/jquery.main-prod.js b/www/skins/prod/jquery.main-prod.js index 4a08e741b6..56627efcfa 100644 --- a/www/skins/prod/jquery.main-prod.js +++ b/www/skins/prod/jquery.main-prod.js @@ -692,13 +692,15 @@ function triggerShortcuts() modal:true, width:600, height:400, - zIndex:1400, overlay: { backgroundColor: '#000', opacity: 0.7 }, + open: function(event, ui) { + $(this).dialog("widget").css("z-index", "1400"); + }, close : function(){ - + $(this).dialog("widget").css("z-index", "auto"); if($('#keyboard-stop').get(0).checked) { var dialog = $('#keyboard-dialog'); if (dialog.data("ui-dialog")) { @@ -2382,7 +2384,12 @@ function printThis(value) modal:true, width:'800', height:'500', - zIndex: 1999 + open: function(event, ui) { + $(this).dialog("widget").css("z-index", "1999"); + }, + close: function(event, ui) { + $(this).dialog("widget").css("z-index", "auto"); + } }) .dialog('open'); From ef81eb6edb7944cbd4a1e0a0a6086bb6fc5126fa Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 2 Sep 2013 16:51:38 +0200 Subject: [PATCH 13/14] Fix #1421 Overflow issue --- templates/web/admin/user/demand.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/web/admin/user/demand.html.twig b/templates/web/admin/user/demand.html.twig index 3f309b308b..f235048d72 100644 --- a/templates/web/admin/user/demand.html.twig +++ b/templates/web/admin/user/demand.html.twig @@ -220,10 +220,10 @@ - +

+ {{ basId| bas_labels(app) }} +

{% endfor %} From 6144f096ef0ff95c36918beea6fa6e4f71ac1388 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 2 Sep 2013 17:02:30 +0200 Subject: [PATCH 14/14] Fix #1420 Fix wording --- templates/web/admin/user/import/view.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/web/admin/user/import/view.html.twig b/templates/web/admin/user/import/view.html.twig index c91c5ff328..b13200c927 100644 --- a/templates/web/admin/user/import/view.html.twig +++ b/templates/web/admin/user/import/view.html.twig @@ -38,7 +38,7 @@ {% endfor %}
- + {% trans %}Cancel{% endtrans %}