From 2b746714e7982bb0e5203439bf140130aee41401 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Tue, 10 Feb 2015 12:43:46 +0100 Subject: [PATCH 01/20] =?UTF-8?q?fix=20#PHRAS-404=20could=20not=20find=20"?= =?UTF-8?q?echapp=C3=A9es"=20=20if=20stemming=20(fr)=20was=20checked=20bec?= =?UTF-8?q?ause=20the=20qparser=20removed=20diacritics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchEngine/Phrasea/PhraseaEngineQueryParser.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php index 556b986b8c..2f8b605434 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php @@ -772,8 +772,11 @@ class PhraseaEngineQueryParser $prophtml = ""; $this->propAsHTML($domthe->documentElement, $prophtml, $path); $this->proposals["BASES"]["b$bid"]["TERMS"][$path]["HTML"] = $prophtml; + } else { + $tree = NULL; } + return($ambigus); } @@ -1864,7 +1867,8 @@ class PhraseaEngineQueryParser if (!$this->app['unicode']->has_indexer_bad_char(($c_utf8 = mb_substr($this->phq, $i, 1, 'UTF-8')))) { // $c = mb_strtolower($c); // $t .= isset($this->noaccent[$c]) ? $this->noaccent[$c] : $c; - $t .= $this->app['unicode']->remove_diacritics(mb_strtolower($c_utf8)); + // $t .= $this->app['unicode']->remove_diacritics(mb_strtolower($c_utf8)); + $t .= mb_strtolower($c_utf8); } else break; } From d25ce23f469cd2d192400f2098e9fd5407e65663 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Wed, 11 Feb 2015 17:01:33 +0100 Subject: [PATCH 02/20] PHRAS-394 #fix --- www/scripts/apps/login/home/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/scripts/apps/login/home/config.js b/www/scripts/apps/login/home/config.js index 81ffebb049..bd5820523d 100644 --- a/www/scripts/apps/login/home/config.js +++ b/www/scripts/apps/login/home/config.js @@ -17,7 +17,7 @@ require.config({ backbone: "../assets/backbone-amd/backbone", i18n: "../assets/i18next/release/i18next.amd-1.6.2.min", bootstrap: "../skins/build/bootstrap/js/bootstrap.min", - multiselect: "../assets/bootstrap-multiselect/js/bootstrap-multiselect", + multiselect: "../assets/bootstrap-multiselect/dist/js/bootstrap-multiselect", "jquery.geonames": "../assets/geonames-server-jquery-plugin/jquery.geonames" }, shim: { From 8fb20ac54e4df8f21965add02b0c7ffea908f3c9 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Wed, 11 Feb 2015 17:42:47 +0100 Subject: [PATCH 03/20] PHRAS-374 #fix --- lib/Alchemy/Phrasea/Command/BuildSubdefs.php | 30 +++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/BuildSubdefs.php b/lib/Alchemy/Phrasea/Command/BuildSubdefs.php index bcf1abdb82..cd579e777d 100644 --- a/lib/Alchemy/Phrasea/Command/BuildSubdefs.php +++ b/lib/Alchemy/Phrasea/Command/BuildSubdefs.php @@ -33,6 +33,8 @@ class BuildSubdefs extends Command $this->addArgument('subdefs', InputArgument::REQUIRED, 'Names of sub-definition to re-build'); $this->addOption('max_record', 'max', InputOption::VALUE_OPTIONAL, 'Max record id'); $this->addOption('min_record', 'min', InputOption::VALUE_OPTIONAL, 'Min record id'); + $this->addOption('with-substitution', 'wsubstit', InputOption::VALUE_NONE, 'Regenerate subdefs for substituted records as well'); + $this->addOption('substitution-only', 'substito', InputOption::VALUE_NONE, 'Regenerate subdefs for substituted records only'); return $this; } @@ -91,14 +93,13 @@ class BuildSubdefs extends Command list($sqlCount, $stmtParams) = SQLParserUtils::expandListParameters($sqlCount, $params, $types); - $totalRecords = 0; - foreach ($this->container['phraseanet.appbox']->get_databoxes() as $databox) { - $connection = $databox->get_connection(); - $stmt = $connection->prepare($sqlCount); - $stmt->execute($stmtParams); - $row = $stmt->fetch(); - $totalRecords += $row['nb_records']; - } + $databox = $this->container['phraseanet.appbox']->get_databox($input->getArgument('databox')); + + $connection = $databox->get_connection(); + $stmt = $connection->prepare($sqlCount); + $stmt->execute($stmtParams); + $row = $stmt->fetch(); + $totalRecords = $row['nb_records']; if ($totalRecords === 0) { return; @@ -110,8 +111,6 @@ class BuildSubdefs extends Command $progress->display(); - $databox = $this->container['phraseanet.appbox']->get_databox($input->getArgument('databox')); - $sql = " SELECT DISTINCT(r.record_id) FROM record r @@ -137,6 +136,14 @@ class BuildSubdefs extends Command $types[] = \PDO::PARAM_INT; } + if (false === $withSubstitution = $input->getOption('with-substitution')) { + $sql .= " AND (s.substit = 0)"; + } + + if ($substitutionOnly = $input->getOption('substitution-only')) { + $sql .= " AND (s.substit = 1)"; + } + list($sql, $stmtParams) = SQLParserUtils::expandListParameters($sql, $params, $types); $connection = $databox->get_connection(); @@ -155,6 +162,9 @@ class BuildSubdefs extends Command foreach ($subdefs as $subdef) { $subdef->remove_file(); + if (($withSubstitution && $subdef->is_substituted()) || $substitutionOnly) { + $subdef->set_substituted(false); + } } $record->generate_subdefs($databox, $this->container, $subdefsName); From 706b77ea84b96ff902e218fe9099524c0d191796 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 11 Feb 2015 18:15:24 +0100 Subject: [PATCH 04/20] fix #PHRAS-370 now empty 10 by 10 --- .../Phrasea/Controller/Prod/Lazaret.php | 29 ++++- templates/web/prod/upload/lazaret.html.twig | 105 ++++++++++++------ 2 files changed, 101 insertions(+), 33 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index 1152319c87..9e47857915 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -411,22 +411,49 @@ class Lazaret implements ControllerProviderInterface */ public function emptyLazaret(Application $app, Request $request) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = array( + 'success' => false, + 'message' => '', + 'result' => array( + 'tobedone' => 0, + 'done' => 0, + 'todo' => 0, + 'max' => '', + ) + ); + + $maxTodo = -1; // all + if($request->get('max') !== null) { + $maxTodo = (int)($request->get('max')); + $ret['result']['max'] = $maxTodo; + if( $maxTodo <= 0) { + $maxTodo = -1; // all + } + } + $ret['result']['max'] = $maxTodo; $lazaretFiles = $app['EM']->getRepository('Entities\LazaretFile')->findAll(); $app['EM']->beginTransaction(); + $ret['result']['tobedone'] = count($lazaretFiles); + $_done = 0; try { foreach ($lazaretFiles as $lazaretFile) { + if($maxTodo != -1 && --$maxTodo < 0) { + break; + } $this->denyLazaretFile($app, $lazaretFile); + $_done++; } $app['EM']->commit(); + $ret['result']['done'] = $_done; $ret['success'] = true; } catch (\Exception $e) { $app['EM']->rollback(); $ret['message'] = _('An error occured'); } + $ret['result']['todo'] = $ret['result']['tobedone'] - $ret['result']['done']; return $app->json($ret); } diff --git a/templates/web/prod/upload/lazaret.html.twig b/templates/web/prod/upload/lazaret.html.twig index d97b833e1f..2175efefac 100644 --- a/templates/web/prod/upload/lazaret.html.twig +++ b/templates/web/prod/upload/lazaret.html.twig @@ -2,13 +2,20 @@ {% if lazaretFiles is not none %} {% if lazaretFiles|length > 0 %} +
-
+
+ +
+
-
+
@@ -42,6 +49,8 @@ + {% endif %}
{% include 'common/menubar.html.twig' %}
diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index 99d17678e7..79b0bc2895 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -44,6 +44,7 @@ {% endmacro %} {% set jquery_theme = 'dark-hive' %} +{% set step = app.flash('step_by_step') %} {% extends "common/index_bootstrap.html.twig" %} @@ -100,6 +101,41 @@ background-color: #{% if app['authentication'].getUser().getPrefs('background-selection') != '' %}{{app['authentication'].getUser().getPrefs('background-selection')}}{% else %}404040{% endif %}; } + + {% if step %} + + + {% endif %} {% endblock %} {% block javascript %} @@ -117,22 +153,7 @@
-
- {% if app.flash('client_deprecated') %} - - - {% endif %} {% set ratio = app['authentication'].getUser().getPrefs('search_window') %} {% if ratio == 0 %} {% set ratio = '0.333' %} @@ -294,7 +315,7 @@
- + @@ -531,7 +552,7 @@
- @@ -1038,6 +1059,88 @@ + {% if step %} + + {% endif %} + @@ -1091,5 +1194,19 @@ + {% if step %} + + + + + {% endif %} {% endblock %} diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php index b1734e998b..49487bd125 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php @@ -10,6 +10,6 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->authenticate(self::$DI['app']); self::$DI['client']->request("GET", "/client/"); - $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); + $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } } From 76e046e1117b3eea084a8f99ec8a08f726961489 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Tue, 17 Feb 2015 17:28:06 +0100 Subject: [PATCH 17/20] #PHRAS-370 #time 2h faster empty --- .../Phrasea/Controller/Prod/Lazaret.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index 9e47857915..6c05987bb7 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -432,22 +432,32 @@ class Lazaret implements ControllerProviderInterface } $ret['result']['max'] = $maxTodo; - $lazaretFiles = $app['EM']->getRepository('Entities\LazaretFile')->findAll(); + $repo = $app['EM']->getRepository('Entities\LazaretFile'); + + $ret['result']['tobedone'] = $repo->createQueryBuilder('id') + ->select('COUNT(id)') + ->getQuery() + ->getSingleScalarResult(); + + if($maxTodo == -1) { + // all + $lazaretFiles = $repo->findAll(); + } + else { + // limit maxTodo + $lazaretFiles = $repo->findBy(array(), null, $maxTodo); + } + $app['EM']->beginTransaction(); - $ret['result']['tobedone'] = count($lazaretFiles); $_done = 0; try { foreach ($lazaretFiles as $lazaretFile) { - if($maxTodo != -1 && --$maxTodo < 0) { - break; - } $this->denyLazaretFile($app, $lazaretFile); - $_done++; + $ret['result']['done']++; } $app['EM']->commit(); - $ret['result']['done'] = $_done; $ret['success'] = true; } catch (\Exception $e) { $app['EM']->rollback(); From 41cd9c3f17806ff9d660f9c1f8f387989e649665 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 18 Feb 2015 18:12:11 +0100 Subject: [PATCH 18/20] #PHRAS-325 add parameter "adapt" to route "/embed/substitute" fix : substituted was indicated only for thumbnails on prod/tools/recreate --- lib/classes/API/V1/adapter.php | 4 ++- lib/classes/p4field.php | 2 +- lib/classes/record/adapter.php | 36 ++++++++++--------- .../web/prod/actions/Tools/index.html.twig | 10 +++--- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index fafa1c2e49..c9244fb808 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -561,7 +561,9 @@ class API_V1_adapter extends API_V1_Abstract throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_label($this->app['locale.I18n']))); } - $record->substitute_subdef($request->get('name'), $media, $app); + $adapt = $request->get('adapt')===null || !(\p4field::isno($request->get('adapt'))); + $ret['adapt'] = $adapt; + $record->substitute_subdef($request->get('name'), $media, $app, $adapt); foreach ($record->get_embedable_medias() as $name => $media) { if ($name == $request->get('name') && null !== ($subdef = $this->list_embedable_media($record, $media, $this->app['phraseanet.registry']))) { diff --git a/lib/classes/p4field.php b/lib/classes/p4field.php index db6f33418e..3cd3e1091b 100644 --- a/lib/classes/p4field.php +++ b/lib/classes/p4field.php @@ -14,6 +14,6 @@ class p4field { $v = mb_strtolower(trim($v)); - return($v == '0' || $v == 'n' || $v == 'no' || $v == 'non' || $v = 'off' || $v == 'false'); + return($v == '0' || $v == 'n' || $v == 'no' || $v == 'non' || $v == 'off' || $v == 'false'); } } diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 3579b1c96f..a8480f9aab 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -991,14 +991,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $this->get_databox()->get_sbas_id(); } - public function substitute_subdef($name, MediaInterface $media, Application $app) + public function substitute_subdef($name, MediaInterface $media, Application $app, $adapt=true) { $newfilename = $this->record_id . '_0_' . $name . '.' . $media->getFile()->getExtension(); - $base_url = ''; - - $subdef_def = false; - if ($name == 'document') { $baseprefs = $this->get_databox()->get_sxml_structure(); @@ -1028,24 +1024,30 @@ class record_adapter implements record_Interface, cache_cacheableInterface $path_file_dest = $path . $newfilename; } - try { - $app['media-alchemyst']->turnInto( - $media->getFile()->getRealPath(), - $path_file_dest, - $subdef_def->getSpecs() - ); - } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) { - return $this; - } + if($adapt) { + try { + $app['media-alchemyst']->turnInto( + $media->getFile()->getRealPath(), + $path_file_dest, + $subdef_def->getSpecs() + ); + } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) { + return $this; + } - $subdefFile = $path_file_dest; + $subdefFile = $path_file_dest; + } + else{ + $app['filesystem']->copy($media->getFile()->getRealPath(), $path_file_dest); + + $subdefFile = $path_file_dest; + } $meta_writable = $subdef_def->meta_writeable(); } $app['filesystem']->chmod($subdefFile, 0760); $media = $app['mediavorus']->guess($subdefFile); - $subdef = media_subdef::create($app, $this, $name, $media); $subdef->set_substituted(true); @@ -1055,7 +1057,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $this->write_metas(); } - if ($name == 'document') { + if ($name == 'document' && $adapt) { $this->rebuild_subdefs(); } diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 63aecdf671..76dc2b1add 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -1,7 +1,7 @@ {% set selectionLength = records|length %} {% set nbHdSubstitute = 0 %} -{% set nbThumbSubstitute = 0 %} +{% set nbSubdefSubstitute = 0 %} {% for record in records %} {% set subdefs = record.get_subdefs() %} @@ -9,10 +9,8 @@ {% for key, subdef in subdefs if subdef.is_substituted() %} {% if key == 'document' %} {% set nbHdSubstitute = nbHdSubstitute + 1 %} - {% endif%} - - {% if key == 'thumbnail' %} - {% set nbThumbSubstitute = nbThumbSubstitute + 1 %} + {% else %} + {% set nbSubdefSubstitute = nbSubdefSubstitute + 1 %} {% endif%} {% endfor %} @@ -68,7 +66,7 @@
 {% trans "Reconstruire les sous definitions" %}  - {% if nbThumbSubstitute > 0 %} + {% if nbSubdefSubstitute > 0 %}
{% trans "Attention, certain documents ont des sous-definitions substituees" %}
From 2b96a0b2388cc4b7da0ff3067d77dda4315e3c4e Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 20 Feb 2015 18:44:19 +0100 Subject: [PATCH 19/20] Revert downloadble subdef api expositioon --- lib/classes/API/V1/adapter.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index c9244fb808..e23138f47e 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -1527,18 +1527,6 @@ class API_V1_adapter extends API_V1_Abstract return null; } } - if($media->get_name() != 'document') { - $databox = $record->get_databox(); - try { - $subDefDefinition = $databox->get_subdef_structure()->get_subdef($record->get_type(), $media->get_name()); - } catch (Exception_Databox_SubdefNotFound $e) { - return null; - } - } - - if ($media->get_name() != 'document' && false === $subDefDefinition->is_downloadable()) { - return null; - } if ($media->get_permalink() instanceof media_Permalink_Adapter) { $permalink = $this->list_permalink($media->get_permalink(), $registry); From f7b9e2c00cfa8981f52857fb079651a867a2a601 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 20 Feb 2015 18:10:53 +0100 Subject: [PATCH 20/20] Update dependencies --- composer.json | 2 +- composer.lock | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ba3e73bbdb..0cf8812a79 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "gedmo/doctrine-extensions" : "~2.3.0", "alchemy/google-plus-api-client" : "~0.6.2", "alchemy/geonames-api-consumer" : "~0.1.0", - "goodby/csv" : "~1.0", + "goodby/csv" : "dev-master", "guzzle/guzzle" : "~3.0", "imagine/imagine" : "dev-alchemy-0.6.2 as 0.6.2", "jms/serializer" : "~0.10", diff --git a/composer.lock b/composer.lock index 8cc74d66cb..8f6741cf97 100644 --- a/composer.lock +++ b/composer.lock @@ -1082,16 +1082,16 @@ }, { "name": "goodby/csv", - "version": "1.1.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/goodby/csv.git", - "reference": "da672802985d196cae767da29b11618a676496b0" + "reference": "b289ca3e3f6ad3c76b7d8c3bef3effd0232ca13a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/goodby/csv/zipball/da672802985d196cae767da29b11618a676496b0", - "reference": "da672802985d196cae767da29b11618a676496b0", + "url": "https://api.github.com/repos/goodby/csv/zipball/b289ca3e3f6ad3c76b7d8c3bef3effd0232ca13a", + "reference": "b289ca3e3f6ad3c76b7d8c3bef3effd0232ca13a", "shasum": "" }, "require": { @@ -1135,7 +1135,7 @@ "export", "import" ], - "time": "2013-11-22 19:10:34" + "time": "2015-02-02 12:29:23" }, { "name": "guzzle/guzzle", @@ -4089,11 +4089,13 @@ ], "minimum-stability": "stable", "stability-flags": { + "goodby/csv": 20, "imagine/imagine": 20, "phpexiftool/phpexiftool": 20, "doctrine/data-fixtures": 20 }, "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.3.3" },