diff --git a/.env b/.env index 529bbcce4e..a72c96c854 100644 --- a/.env +++ b/.env @@ -134,7 +134,7 @@ PHRASEANET_DOCKER_REGISTRY=local # Docker images tag. # @run -PHRASEANET_DOCKER_TAG=4.1.8-rc6 +PHRASEANET_DOCKER_TAG=4.1.8-rc7 # Stack Name # An optionnal Name for the stack diff --git a/Phraseanet-production-client/dist/production.js b/Phraseanet-production-client/dist/production.js index f4f94a4b83..2241df118c 100644 --- a/Phraseanet-production-client/dist/production.js +++ b/Phraseanet-production-client/dist/production.js @@ -62775,6 +62775,7 @@ var recordToolsModal = function recordToolsModal(services, datas) { (0, _jquery2.default)('.iframe_submiter', $scope).bind('click', function () { var form = (0, _jquery2.default)(this).closest('form'); form.submit(); + form.find('.resultAction').empty(); form.find('.load').empty().html(localeService.t('loading') + ' ...'); (0, _jquery2.default)('#uploadHdsub').contents().find('.content').empty(); (0, _jquery2.default)('#uploadHdsub').load(function () { diff --git a/Phraseanet-production-client/dist/production.min.js b/Phraseanet-production-client/dist/production.min.js index f4f94a4b83..2241df118c 100644 --- a/Phraseanet-production-client/dist/production.min.js +++ b/Phraseanet-production-client/dist/production.min.js @@ -62775,6 +62775,7 @@ var recordToolsModal = function recordToolsModal(services, datas) { (0, _jquery2.default)('.iframe_submiter', $scope).bind('click', function () { var form = (0, _jquery2.default)(this).closest('form'); form.submit(); + form.find('.resultAction').empty(); form.find('.load').empty().html(localeService.t('loading') + ' ...'); (0, _jquery2.default)('#uploadHdsub').contents().find('.content').empty(); (0, _jquery2.default)('#uploadHdsub').load(function () { diff --git a/Phraseanet-production-client/src/components/record/tools/index.js b/Phraseanet-production-client/src/components/record/tools/index.js index 8343e2a825..1793fe8f55 100644 --- a/Phraseanet-production-client/src/components/record/tools/index.js +++ b/Phraseanet-production-client/src/components/record/tools/index.js @@ -51,6 +51,7 @@ const recordToolsModal = (services, datas, activeTab = false) => { $('.iframe_submiter', $scope).bind('click', function () { var form = $(this).closest('form'); form.submit(); + form.find('.resultAction').empty(); form.find('.load').empty().html(localeService.t('loading') + ' ...'); $('#uploadHdsub').contents().find('.content').empty(); $('#uploadHdsub').load(function () { diff --git a/cache/.gitkeep b/cache/.gitkeep old mode 100644 new mode 100755 diff --git a/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php b/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php index 65f72b6da3..52ec210100 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php @@ -14,12 +14,14 @@ use Alchemy\Phrasea\Databox\SubdefGroup; use Alchemy\Phrasea\Media\Subdef\Subdef; use Alchemy\Phrasea\Media\Type\Type; +use Exception; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Alchemy\Phrasea\Media\Subdef\Image; use Alchemy\Phrasea\Media\Subdef\Video; use Alchemy\Phrasea\Media\Subdef\Audio; use Alchemy\Phrasea\Media\Subdef\Gif; +use unicode; class SubdefsController extends Controller { @@ -44,7 +46,7 @@ function indexAction($sbas_id) { * @param Request $request * @param int $sbas_id * @return Response - * @throws \Exception + * @throws Exception */ function changeSubdefsAction(Request $request, $sbas_id) { $delete_subdef = $request->request->get('delete_subdef'); @@ -84,7 +86,7 @@ function changeSubdefsAction(Request $request, $sbas_id) { $subdefs = $databox->get_subdef_structure(); $group = $add_subdef['group']; - /** @var \unicode $unicode */ + /** @var unicode $unicode */ $unicode = $this->app['unicode']; $name = $unicode->remove_nonazAZ09($add_subdef['name'], false); $class = $add_subdef['class']; @@ -111,6 +113,7 @@ function changeSubdefsAction(Request $request, $sbas_id) { $options[Image::OPTION_FLATTEN] = $config["image"]["definitions"][$preset][Image::OPTION_FLATTEN]; $options[Image::OPTION_QUALITY] = $config["image"]["definitions"][$preset][Image::OPTION_QUALITY]; $options[Image::OPTION_ICODEC] = $config["image"]["definitions"][$preset][Image::OPTION_ICODEC]; + $options[Image::OPTION_BACKGROUNDCOLOR] = $config["image"]["definitions"][$preset][Image::OPTION_BACKGROUNDCOLOR]; foreach ($config["image"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) { $options[Subdef::OPTION_DEVICE][] = $devices; } @@ -182,6 +185,7 @@ function changeSubdefsAction(Request $request, $sbas_id) { $class = $request->request->get($post_sub . '_class'); $downloadable = $request->request->get($post_sub . '_downloadable'); $orderable = $request->request->get($post_sub . '_orderable'); + $substituable = $request->request->get($post_sub . '_substituable'); $toBuild = $request->request->get($post_sub . '_tobuild'); $defaults = ['path', 'meta', 'mediatype']; @@ -208,7 +212,7 @@ function changeSubdefsAction(Request $request, $sbas_id) { } $labels = $request->request->get($post_sub . '_label', []); - $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable, $preset, $toBuild); + $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable, $preset, $toBuild, $substituable); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 6a30a0c055..9c522a6ee5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -44,14 +44,14 @@ public function indexAction(Request $request) $metadatas = false; $record = null; - $recordAccessibleSubdefs = array(); - $listsubdef= null; + $recordAccessibleSubdefs = []; + $listsubdef = null; if (count($records) == 1) { /** @var record_adapter $record */ $record = $records->first(); /**Array list of subdefs**/ - $listsubdef = array_keys($record-> get_subdefs()); + $listsubdef = array_keys($record->get_subdefs()); // fetch subdef list: $subdefs = $record->get_subdefs(); @@ -73,18 +73,19 @@ public function indexAction(Request $request) continue; } $label = $this->app->trans('prod::tools: document'); - } elseif ($databoxSubdefs !== null && $databoxSubdefs->hasSubdef($subdefName)) { + } + elseif ($databoxSubdefs !== null && $databoxSubdefs->hasSubdef($subdefName)) { if (!$acl->has_access_to_subdef($record, $subdefName)) { continue; } $label = $databoxSubdefs->getSubdef($subdefName)->get_label($this->app['locale']); } - $recordAccessibleSubdefs[] = array( - 'name' => $subdef->get_name(), + $recordAccessibleSubdefs[] = [ + 'name' => $subdef->get_name(), 'state' => $permalink->get_is_activated(), 'label' => $label, - ); + ]; } } if (!$record->isStory()) { @@ -95,8 +96,13 @@ public function indexAction(Request $request) $availableSubdefLabel = []; $countSubdefTodo = []; + $substituables = []; + if ($this->getConf()->get(['registry', 'modules', 'doc-substitution'])) { + $substituables[] = 'document'; + } /** @var record_adapter $rec */ foreach ($records as $rec) { + $databoxSubdefs = $rec->getDatabox()->get_subdef_structure()->getSubdefGroup($rec->getType()); if ($databoxSubdefs !== null) { foreach ($databoxSubdefs as $sub) { @@ -104,29 +110,38 @@ public function indexAction(Request $request) $label = trim($sub->get_label($this->app['locale'])); $availableSubdefLabel[] = $label; if (isset($countSubdefTodo[$label])) { - $countSubdefTodo[$label] ++; - } else { + $countSubdefTodo[$label]++; + } + else { $countSubdefTodo[$label] = 1; } } + if ($sub->isSubstituable()) { + $substituables[] = $sub->get_name(); + } } } } + if (count($records) > 1) { + $substituables = []; + } + $this->setSessionFormToken('prodToolsSubdef'); $this->setSessionFormToken('prodToolsRotate'); $this->setSessionFormToken('prodToolsHDSubstitution'); $this->setSessionFormToken('prodToolsThumbSubstitution'); return $this->render('prod/actions/Tools/index.html.twig', [ - 'records' => $records, - 'record' => $record, - 'recordSubdefs' => $recordAccessibleSubdefs, - 'metadatas' => $metadatas, - 'listsubdef' => $listsubdef, + 'records' => $records, + 'record' => $record, + 'recordSubdefs' => $recordAccessibleSubdefs, + 'metadatas' => $metadatas, + 'listsubdef' => $listsubdef, 'availableSubdefLabel' => array_unique($availableSubdefLabel), - 'nbRecords' => count($records), - 'countSubdefTodo' => $countSubdefTodo + 'nbRecords' => count($records), + 'countSubdefTodo' => $countSubdefTodo, + 'substituables' => $substituables, ]); } @@ -161,7 +176,8 @@ public function rotateAction(Request $request) try { $subdef->rotate($rotation, $this->getMediaAlchemyst(), $this->getMediaVorus()); - } catch (\Exception $e) { + } + catch (\Exception $e) { // ignore exception } } @@ -256,31 +272,34 @@ public function hddocAction(Request $request) $this->getSubDefinitionSubstituer()->substituteDocument($record, $media); $record->insertTechnicalDatas($this->getMediaVorus()); - $this->getMetadataSetter()->replaceMetadata($this->getMetadataReader() ->read($media), $record); + $this->getMetadataSetter()->replaceMetadata($this->getMetadataReader()->read($media), $record); $this->getDataboxLogger($record->getDatabox()) - ->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'HD', '' ); + ->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'HD', ''); - if ((int) $request->request->get('ccfilename') === 1) { + if ((int)$request->request->get('ccfilename') === 1) { $record->set_original_name($fileName); } unlink($tempoFile); rmdir($tempoDir); $success = true; $message = $this->app->trans('Document has been successfully substitued'); - } catch (\Exception $e) { + } + catch (\Exception $e) { $message = $this->app->trans('file is not valid'); } - } else { + } + else { $message = $this->app->trans('file is not valid'); } - } else { + } + else { $this->app->abort(400, 'Missing file parameter'); } return $this->render('prod/actions/Tools/iframeUpload.html.twig', [ - 'success' => $success, - 'message' => $message, + 'success' => $success, + 'message' => $message, ]); } @@ -296,10 +315,10 @@ public function changeThumbnailAction(Request $request) $this->app->abort(400, 'Missing file parameter'); } - if (! $file->isValid()) { + if (!$file->isValid()) { return $this->render('prod/actions/Tools/iframeUpload.html.twig', [ - 'success' => false, - 'message' => $this->app->trans('file is not valid'), + 'success' => false, + 'message' => $this->app->trans('file is not valid'), ]); } @@ -318,22 +337,28 @@ public function changeThumbnailAction(Request $request) $media = $this->app->getMediaFromUri($tempoFile); - $this->getSubDefinitionSubstituer()->substituteSubdef($record, 'thumbnail', $media); + // no BC break before PHRAS-3918 when only "thumbnail" was substituable + if(($subdef = $request->get('subdef')) === null) { + $subdef = 'thumbnail'; + } + + $this->getSubDefinitionSubstituer()->substituteSubdef($record, $subdef, $media); $this->getDataboxLogger($record->getDatabox()) - ->log($record, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', ''); + ->log($record, \Session_Logger::EVENT_SUBSTITUTE, $subdef, ''); unlink($tempoFile); rmdir($tempoDir); $success = true; - $message = $this->app->trans('Thumbnail has been successfully substitued'); - } catch (\Exception $e) { + $message = sprintf($this->app->trans('Subdef "%s" has been successfully substitued'), $subdef); + } + catch (\Exception $e) { $success = false; $message = $this->app->trans('file is not valid'); } return $this->render('prod/actions/Tools/iframeUpload.html.twig', [ - 'success' => $success, - 'message' => $message, + 'success' => $success, + 'message' => $message, ]); } @@ -344,14 +369,15 @@ public function submitConfirmBoxAction(Request $request) try { $record = new record_adapter($this->app, $request->request->get('sbas_id'), $request->request->get('record_id')); $var = [ - 'video_title' => $record->get_title(['encode'=> record_adapter::ENCODE_NONE]), + 'video_title' => $record->get_title(['encode' => record_adapter::ENCODE_NONE]), 'image' => $request->request->get('image', ''), ]; $return = [ 'error' => false, 'datas' => $this->render($template, $var), ]; - } catch (\Exception $e) { + } + catch (\Exception $e) { $return = [ 'error' => true, 'datas' => $this->app->trans('an error occured'), @@ -378,7 +404,8 @@ public function applyThumbnailExtractionAction(Request $request) } $return = ['success' => true, 'message' => '']; - } catch (\Exception $e) { + } + catch (\Exception $e) { $return = ['success' => false, 'message' => $e->getMessage()]; } @@ -418,7 +445,8 @@ public function editRecordSharing(Request $request, $base_id, $record_id) try { $permalink->set_is_activated($state); $return = ['success' => true, 'state' => $permalink->get_is_activated()]; - } catch (\Exception $e) { + } + catch (\Exception $e) { $return = ['success' => false, 'state' => $permalink->get_is_activated()]; } @@ -474,13 +502,14 @@ private function substituteMedia(record_adapter $record, $subDefName, $subDefDat $media = $this->app->getMediaFromUri($fileName); - if($subDefName == 'document') { + if ($subDefName == 'document') { $this->getSubDefinitionSubstituer()->substituteDocument($record, $media); - } else { + } + else { $this->getSubDefinitionSubstituer()->substituteSubdef($record, $subDefName, $media); } $this->getDataboxLogger($record->getDatabox()) - ->log($record, \Session_Logger::EVENT_SUBSTITUTE, $subDefName, ''); + ->log($record, \Session_Logger::EVENT_SUBSTITUTE, $subDefName, ''); unset($media); $this->getFilesystem()->remove($fileName); @@ -574,7 +603,7 @@ public function videoEditorAction(Request $request) '_value' => $record->getCaption([$meta->get_name()]), ]; - if (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $matches) && !empty($matches[1]) && strlen($matches[1]) == 2 ) { + if (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $matches) && !empty($matches[1]) && strlen($matches[1]) == 2) { $field['label'] = $matches[1]; $field['meta_struct_id'] = $meta->get_id(); $field['value'] = ''; @@ -595,12 +624,12 @@ public function videoEditorAction(Request $request) $conf = $this->getConf(); return $this->render('prod/actions/Tools/videoEditor.html.twig', [ - 'records' => $records, - 'record' => $record, - 'videoEditorConfig' => $conf->get(['video-editor']), - 'metadatas' => $metadatas, - 'JSonFields' => json_encode($JSFields), - 'videoTextTrackFields' => $videoTextTrackFields + 'records' => $records, + 'record' => $record, + 'videoEditorConfig' => $conf->get(['video-editor']), + 'metadatas' => $metadatas, + 'JSonFields' => json_encode($JSFields), + 'videoTextTrackFields' => $videoTextTrackFields ]); } @@ -608,7 +637,8 @@ private function isPhysicallyPresent(record_adapter $record, $subdefName) { try { return $record->get_subdef($subdefName)->is_physically_present(); - } catch (\Exception $e) { + } + catch (\Exception $e) { unset($e); } diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php index 91d8eb07c2..2bdcd22686 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php @@ -44,10 +44,12 @@ public function connect(Application $app) ->requireRightOnSbas($request->attributes->get('sbas_id'), \ACL::BAS_MODIFY_STRUCT); }); + /** @uses SubdefsController::indexAction */ $controllers->get('/{sbas_id}/', 'controller.admin.subdefs:indexAction') ->bind('admin_subdefs_subdef') ->assert('sbas_id', '\d+'); + /** @uses SubdefsController::changeSubdefsAction */ $controllers->post('/{sbas_id}/', 'controller.admin.subdefs:changeSubdefsAction') ->bind('admin_subdefs_subdef_update') ->assert('sbas_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php index 07f8810ad4..dd7913a317 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php @@ -57,9 +57,11 @@ public function connect(Application $app) $controllers->post('/image/', 'controller.prod.tools:imageAction') ->bind('prod_tools_image'); + /** @uses \Alchemy\Phrasea\Controller\Prod\ToolsController::hddocAction */ $controllers->post('/hddoc/', 'controller.prod.tools:hddocAction') ->bind('prod_tools_hd_substitution'); + /** @uses \Alchemy\Phrasea\Controller\Prod\ToolsController::changeThumbnailAction */ $controllers->post('/chgthumb/', 'controller.prod.tools:changeThumbnailAction') ->bind('prod_tools_thumbnail_substitution'); diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index ed7b9b1805..e695c846ab 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -17,7 +17,7 @@ class Version * @var string */ - private $number = '4.1.8-rc6'; + private $number = '4.1.8-rc7'; /** * @var string diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 144c3033a8..4a881696b1 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -36,7 +36,7 @@ public function __construct(TranslatorInterface $translator) $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 20, 5000, 800)); $this->registerOption(new OptionType\Range($this->translator->trans('Resolution'), self::OPTION_RESOLUTION, 50, 1000, 72)); $this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false)); - $this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, false)); + $this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, true)); $this->registerOption(new OptionType\Range($this->translator->trans('Quality'), self::OPTION_QUALITY, 0, 100, 75)); $this->registerOption(new OptionType\Enum('Image Codec', self::OPTION_ICODEC, array('jpeg', 'png', 'tiff'), 'jpeg')); $this->registerOption(new OptionType\EnumButton($this->translator->trans('Watermark'), self::OPTION_WATERMARK, array('no' => 'no', 'yes' => 'yes'), 'no')); diff --git a/lib/classes/databox/subdef.php b/lib/classes/databox/subdef.php index 9ae75c6878..2bc32f4361 100644 --- a/lib/classes/databox/subdef.php +++ b/lib/classes/databox/subdef.php @@ -43,6 +43,8 @@ class databox_subdef */ private $requiresMetadataUpdate; protected $downloadable; + protected $orderable; + protected $substituable; protected $tobuild; protected $translator; protected static $mediaTypeToSubdefTypes = [ @@ -67,8 +69,8 @@ class databox_subdef * * @param SubdefType $type * @param SimpleXMLElement $sd - * - * @return databox_subdef + * @param TranslatorInterface $translator + * @param databox|null $databox */ public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator, databox $databox = null) { @@ -81,8 +83,9 @@ public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorIn } $this->name = strtolower($sd->attributes()->name); $this->downloadable = p4field::isyes($sd->attributes()->downloadable); - $this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true; - $this->tobuild = isset($sd->attributes()->tobuild) ? p4field::isyes($sd->attributes()->tobuild) : true; + $this->substituable = isset($sd->attributes()->substituable) && p4field::isyes($sd->attributes()->substituable); + $this->orderable = !isset($sd->attributes()->orderable) || p4field::isyes($sd->attributes()->orderable); + $this->tobuild = !isset($sd->attributes()->tobuild) || p4field::isyes($sd->attributes()->tobuild); $this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : ''; $this->preset = $sd->attributes()->presets; $this->requiresMetadataUpdate = p4field::isyes((string)$sd->meta); @@ -368,8 +371,6 @@ public function isOrderable() } /** - * boolean - * * @return bool */ public function isTobuild() @@ -377,6 +378,14 @@ public function isTobuild() return $this->tobuild; } + /** + * @return bool + */ + public function isSubstituable() + { + return $this->substituable; + } + /** * Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type * diff --git a/lib/classes/databox/subdefsStructure.php b/lib/classes/databox/subdefsStructure.php index ffd6927b8a..69261f1bd1 100644 --- a/lib/classes/databox/subdefsStructure.php +++ b/lib/classes/databox/subdefsStructure.php @@ -246,7 +246,7 @@ public function add_subdef($groupname, $name, $class, $mediatype, $preset, $path * @return databox_subdefsStructure * @throws Exception */ - public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true, $preset = "Custom", $toBuild = true) + public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true, $preset = "Custom", $toBuild = true, $substituable = false) { $dom_struct = $this->databox->get_dom_structure(); @@ -256,6 +256,7 @@ public function set_subdef($group, $name, $class, $downloadable, $options, $labe $subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false')); $subdef->setAttribute('orderable', ($orderable ? 'true' : 'false')); $subdef->setAttribute('tobuild', ($toBuild ? 'true' : 'false')); + $subdef->setAttribute('substituable', ($substituable ? 'true' : 'false')); $subdef->setAttribute('presets', $preset); foreach ($labels as $code => $label) { diff --git a/lib/classes/patch/418RC7.php b/lib/classes/patch/418RC7.php new file mode 100644 index 0000000000..71a2a4db9c --- /dev/null +++ b/lib/classes/patch/418RC7.php @@ -0,0 +1,92 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $base, Application $app) + { + if ($base->get_base_type() === base::DATA_BOX) { + $this->patch_databox($base, $app); + } + elseif ($base->get_base_type() === base::APPLICATION_BOX) { + $this->patch_appbox($base, $app); + } + + return true; + } + + private $thumbSubstitution = null; + + public function patch_databox(databox $databox, Application $app) + { + /** @var PropertyAccess $conf */ + $conf = $app['conf']; + + if ($this->thumbSubstitution === null) { + // first db + $this->thumbSubstitution = $conf->get(['registry', 'modules', 'thumb-substitution']); + $conf->remove(['registry', 'modules', 'thumb-substitution']); + } + + if ($this->thumbSubstitution) { + $dom_struct = $databox->get_dom_structure(); + $dom_xp = $databox->get_xpath_structure(); + + $nodes = $dom_xp->query('//record/subdefs/subdefgroup/subdef[@name="thumbnail"]'); + for ($i = 0; $i < $nodes->length; $i++) { + /** @var \DOMElement $node */ + $node = $nodes->item($i); + $node->setAttribute('substituable', 'true'); + } + + $databox->saveStructure($dom_struct); + } + } + + private function patch_appbox(base $appbox, Application $app) + { + } +} diff --git a/logs/.gitkeep b/logs/.gitkeep old mode 100644 new mode 100755 diff --git a/templates/web/admin/subdefs.html.twig b/templates/web/admin/subdefs.html.twig index b94e27c043..0fb71104b3 100644 --- a/templates/web/admin/subdefs.html.twig +++ b/templates/web/admin/subdefs.html.twig @@ -456,6 +456,13 @@ + + {{ 'subdef.substituable' | trans }} + + + + {{ 'classe' | trans }} diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 2df6f62224..9740756b84 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -4,23 +4,23 @@ {% set nbSubdefSubstitute = 0 %} {% for record in records %} - {% set subdefs = record.get_subdefs() %} - {% if subdefs|length > 0 %} - {% for key, subdef in subdefs if subdef.is_substituted() %} - {% if key == 'document' %} - {% set nbHdSubstitute = nbHdSubstitute + 1 %} - {% else %} - {% set nbSubdefSubstitute = nbSubdefSubstitute + 1 %} - {% endif%} + {% set subdefs = record.get_subdefs() %} + {% if subdefs|length > 0 %} + {% for key, subdef in subdefs if subdef.is_substituted() %} + {% if key == 'document' %} + {% set nbHdSubstitute = nbHdSubstitute + 1 %} + {% else %} + {% set nbSubdefSubstitute = nbSubdefSubstitute + 1 %} + {% endif %} - {% endfor %} - {% endif %} + {% endfor %} + {% endif %} {% endfor %}
{# jquery Tabs #} -
+
{# jquery menu #}