From cea47e87258070178db982f9204778ccf6ba13cf Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Thu, 26 Sep 2019 16:52:20 +0200 Subject: [PATCH 01/12] kubernetes #comment remove unused server_name directive in nginx --- docker/nginx/nginx.conf.sample | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/nginx/nginx.conf.sample b/docker/nginx/nginx.conf.sample index c1f0150c1e..0284f137d9 100644 --- a/docker/nginx/nginx.conf.sample +++ b/docker/nginx/nginx.conf.sample @@ -46,7 +46,6 @@ http { server { listen 80; - server_name localhost; error_log on; access_log on; root /var/alchemy/Phraseanet/www; From b7f5a4cf3c68fbcdcce2f6e620174940439688f3 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Thu, 26 Sep 2019 17:39:00 +0200 Subject: [PATCH 02/12] kubernetes #comment Fix the owner of config to app at the fpm container startup --- docker/phraseanet/boot.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/phraseanet/boot.sh b/docker/phraseanet/boot.sh index 4b2cf2baa2..e4e17aec7d 100755 --- a/docker/phraseanet/boot.sh +++ b/docker/phraseanet/boot.sh @@ -1,5 +1,6 @@ #!/bin/bash +chown -R app:app /var/alchemy/Phraseanet/config FILE=/var/alchemy/Phraseanet/config/configuration.yml if [ -f "$FILE" ]; then echo "$FILE exist, skip setup." From b66aae50470d3ae287bed3448009f07ea4bdaa07 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 27 Sep 2019 14:31:17 +0200 Subject: [PATCH 03/12] kubernetes #comment Reconfigure nginx to serve log on stdout --- docker/nginx/boot.sh | 4 +- docker/nginx/nginx.conf.sample | 101 +++++++++------------------------ 2 files changed, 31 insertions(+), 74 deletions(-) diff --git a/docker/nginx/boot.sh b/docker/nginx/boot.sh index 49e6b8a3b7..2684d8c0f7 100755 --- a/docker/nginx/boot.sh +++ b/docker/nginx/boot.sh @@ -1,4 +1,6 @@ #!/bin/bash -cat nginx.conf.sample | sed "s/\$MAX_BODY_SIZE/$MAX_BODY_SIZE/g" > /etc/nginx/nginx.conf +set -xe + +cat nginx.conf.sample | sed "s/\$MAX_BODY_SIZE/$MAX_BODY_SIZE/g" > /etc/nginx/conf.d/default.conf nginx -g "daemon off;" diff --git a/docker/nginx/nginx.conf.sample b/docker/nginx/nginx.conf.sample index 0284f137d9..ad015e7c5a 100644 --- a/docker/nginx/nginx.conf.sample +++ b/docker/nginx/nginx.conf.sample @@ -1,84 +1,39 @@ -user app; -worker_processes auto; - -#error_log /var/log/ngnix_error.log info; -error_log /dev/stdout info; - -pid /var/run/nginx.pid; -#daemon off; - -events { - worker_connections 1024; - multi_accept on; +upstream backend { + server phraseanet:9000; } -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - server_tokens off; +server { + listen 80; + root /var/alchemy/Phraseanet/www; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; + index index.php; + client_max_body_size $MAX_BODY_SIZE; - access_log /dev/stdout main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - reset_timedout_connection on; - - proxy_connect_timeout 300s; - proxy_send_timeout 300s; - proxy_read_timeout 300s; - fastcgi_send_timeout 300s; - fastcgi_read_timeout 300; - - resolver 127.0.0.11; - - upstream backend { - server phraseanet:9000; + location /api { + rewrite ^(.*)$ /api.php/$1 last; } - server { - listen 80; - error_log on; - access_log on; - root /var/alchemy/Phraseanet/www; + location / { + # First attempt to serve request as file, then + # as directory, then fall back to index.html + try_files $uri $uri/ @rewriteapp; + } - index index.php; - client_max_body_size $MAX_BODY_SIZE; + location @rewriteapp { + rewrite ^(.*)$ /index.php/$1 last; + } - location /api { - rewrite ^(.*)$ /api.php/$1 last; - } + # PHP scripts -> PHP-FPM server listening on 127.0.0.1:9000 + location ~ ^/(index|index_dev|api)\.php(/|$) { + fastcgi_pass backend; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } - location / { - # First attempt to serve request as file, then - # as directory, then fall back to index.html - try_files $uri $uri/ @rewriteapp; - } - - location @rewriteapp { - rewrite ^(.*)$ /index.php/$1 last; - } - - # PHP scripts -> PHP-FPM server listening on 127.0.0.1:9000 - location ~ ^/(index|index_dev|api)\.php(/|$) { - fastcgi_pass backend; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - - location ~ ^/(status|ping)$ { - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_pass backend; - } + location ~ ^/(status|ping)$ { + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_pass backend; } } From b87ab0cd0809282abda1cda65d939c74c35e52c4 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 27 Sep 2019 16:28:49 +0200 Subject: [PATCH 04/12] kubernetes #comment fpm stop on failure --- docker/phraseanet/boot.sh | 2 ++ docker/phraseanet/phraseanet-entrypoint.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/phraseanet/boot.sh b/docker/phraseanet/boot.sh index e4e17aec7d..120f750684 100755 --- a/docker/phraseanet/boot.sh +++ b/docker/phraseanet/boot.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -xe + chown -R app:app /var/alchemy/Phraseanet/config FILE=/var/alchemy/Phraseanet/config/configuration.yml if [ -f "$FILE" ]; then diff --git a/docker/phraseanet/phraseanet-entrypoint.sh b/docker/phraseanet/phraseanet-entrypoint.sh index de763cd13a..225b56a672 100755 --- a/docker/phraseanet/phraseanet-entrypoint.sh +++ b/docker/phraseanet/phraseanet-entrypoint.sh @@ -5,4 +5,4 @@ set -e envsubst < /php.ini.sample > /usr/local/etc/php/php.ini envsubst < /php-fpm.conf.sample > /usr/local/etc/php-fpm.conf -docker-php-entrypoint $@ +bash -e docker-php-entrypoint $@ From c85796fb29b38552b6897ae14cfadd993870d0c3 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 27 Sep 2019 17:02:51 +0200 Subject: [PATCH 05/12] kubernetes #comment fix permissions on datas and thumbnails directory at startup --- docker/phraseanet/boot.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/phraseanet/boot.sh b/docker/phraseanet/boot.sh index 120f750684..ede2f1db60 100755 --- a/docker/phraseanet/boot.sh +++ b/docker/phraseanet/boot.sh @@ -3,6 +3,8 @@ set -xe chown -R app:app /var/alchemy/Phraseanet/config +chown -R app:app /var/alchemy/Phraseanet/datas +chown -R app:app /var/alchemy/Phraseanet/www/thumbnails FILE=/var/alchemy/Phraseanet/config/configuration.yml if [ -f "$FILE" ]; then echo "$FILE exist, skip setup." From 6660c7fe32ca9b6b32ded2679e6c55f358a82c3f Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Thu, 3 Oct 2019 16:40:02 +0200 Subject: [PATCH 06/12] kubernetes #comment tmp owner is root at fpm startup --- docker/phraseanet/boot.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/phraseanet/boot.sh b/docker/phraseanet/boot.sh index ede2f1db60..444b63a64c 100755 --- a/docker/phraseanet/boot.sh +++ b/docker/phraseanet/boot.sh @@ -4,6 +4,7 @@ set -xe chown -R app:app /var/alchemy/Phraseanet/config chown -R app:app /var/alchemy/Phraseanet/datas +chown -R app:app /var/alchemy/Phraseanet/tmp chown -R app:app /var/alchemy/Phraseanet/www/thumbnails FILE=/var/alchemy/Phraseanet/config/configuration.yml if [ -f "$FILE" ]; then From 9fdd704d5a2d518392746cfb65c23a700004a09f Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 4 Oct 2019 09:06:14 +0200 Subject: [PATCH 07/12] kubernetes #comment create needed directory for worker --- Dockerfile | 24 ++++++++++++------------ docker/phraseanet/worker-boot.sh | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ff718ab2c..00ef2acfdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,6 +86,18 @@ COPY grammar /var/alchemy/grammar COPY templates-profiler /var/alchemy/templates-profiler COPY templates /var/alchemy/templates COPY tests /var/alchemy/tests +RUN mkdir -p /var/alchemy/Phraseanet/logs \ + && chmod -R 777 /var/alchemy/Phraseanet/logs \ + && mkdir -p /var/alchemy/Phraseanet/cache \ + && chmod -R 777 /var/alchemy/Phraseanet/cache \ + && mkdir -p /var/alchemy/Phraseanet/datas \ + && chmod -R 777 /var/alchemy/Phraseanet/datas \ + && mkdir -p /var/alchemy/Phraseanet/tmp \ + && chmod -R 777 /var/alchemy/Phraseanet/tmp \ + && mkdir -p /var/alchemy/Phraseanet/www/custom \ + && chmod -R 777 /var/alchemy/Phraseanet/www/custom \ + && mkdir -p /var/alchemy/Phraseanet/config \ + && chmod -R 777 /var/alchemy/Phraseanet/config # Phraseanet FROM php:7.0-fpm-stretch as phraseanet-fpm @@ -136,18 +148,6 @@ RUN mkdir /entrypoint /var/alchemy \ COPY --from=builder --chown=app /var/alchemy /var/alchemy/Phraseanet ADD ./docker/phraseanet/ / -RUN mkdir -p /var/alchemy/Phraseanet/logs \ - && chmod -R 777 /var/alchemy/Phraseanet/logs \ - && mkdir -p /var/alchemy/Phraseanet/cache \ - && chmod -R 777 /var/alchemy/Phraseanet/cache \ - && mkdir -p /var/alchemy/Phraseanet/datas \ - && chmod -R 777 /var/alchemy/Phraseanet/datas \ - && mkdir -p /var/alchemy/Phraseanet/tmp \ - && chmod -R 777 /var/alchemy/Phraseanet/tmp \ - && mkdir -p /var/alchemy/Phraseanet/www/custom \ - && chmod -R 777 /var/alchemy/Phraseanet/www/custom \ - && mkdir -p /var/alchemy/Phraseanet/config \ - && chmod -R 777 /var/alchemy/Phraseanet/config WORKDIR /var/alchemy/Phraseanet ENTRYPOINT ["/phraseanet-entrypoint.sh"] CMD ["/boot.sh"] diff --git a/docker/phraseanet/worker-boot.sh b/docker/phraseanet/worker-boot.sh index 1b972c6cdb..4c1b76b02f 100755 --- a/docker/phraseanet/worker-boot.sh +++ b/docker/phraseanet/worker-boot.sh @@ -1,3 +1,4 @@ #!/bin/bash +mkdir /var/alchemy/Phraseanet/tmp/locks && chown -R app:app /var/alchemy/Phraseanet/tmp runuser app -c 'php /var/alchemy/Phraseanet/bin/console task-manager:scheduler:run' From 9b25efdc6701763c0534dd393c1d705dff38fdba Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 4 Oct 2019 15:56:38 +0200 Subject: [PATCH 08/12] kubernetes #comment add global nginx configuration --- docker/nginx/etc/nginx/nginx.conf | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 docker/nginx/etc/nginx/nginx.conf diff --git a/docker/nginx/etc/nginx/nginx.conf b/docker/nginx/etc/nginx/nginx.conf new file mode 100755 index 0000000000..71a94ee98f --- /dev/null +++ b/docker/nginx/etc/nginx/nginx.conf @@ -0,0 +1,31 @@ + +user app; +worker_processes 1; + +error_log /var/log/ngnix_error.log info; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; + +} From 5f1f8b3b438459a60f0f5e3c4ec4c24c465f3e69 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 18 Oct 2019 16:09:08 +0200 Subject: [PATCH 09/12] kubernetes #comment add composer in the fpm/worker images --- Dockerfile | 5 +++++ README.md | 14 ++++++-------- build.sh | 11 +++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile index 00ef2acfdc..ca4e87b204 100644 --- a/Dockerfile +++ b/Dockerfile @@ -141,6 +141,11 @@ RUN apt-get update \ && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ + && php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ + && php -r "unlink('composer-setup.php');" + RUN mkdir /entrypoint /var/alchemy \ && useradd -u 1000 app \ && mkdir -p /home/app/.composer \ diff --git a/README.md b/README.md index 9fb4237d25..fb4b34870d 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,12 @@ The docker distribution come with 3 differents containers : ## How to build -The three images can be built respectively with these commands : +You can build all the images with the following command at the root directory : - # nginx server - docker build --target phraseanet-nginx -t local/phraseanet-nginx . + ./build - # php-fpm application - docker build --target phraseanet-fpm -t local/phraseanet-fpm . - - # worker - docker build --target phraseanet-worker -t local/phraseanet-worker . +It will build and tag the following images : + local/phraseanet-worker: + local/phraseanet-fpm: + local/phraseanet-nginx: diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000..0f983ccac4 --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# nginx server +docker build --target phraseanet-nginx -t local/phraseanet-nginx:$1 . + +# php-fpm application +docker build --target phraseanet-fpm -t local/phraseanet-fpm:$1 . + +# worker +docker build --target phraseanet-worker -t local/phraseanet-worker:$1 . + From ccef7b11dc722757ba8300edf3070caea28bbd98 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Fri, 18 Oct 2019 16:45:57 +0200 Subject: [PATCH 10/12] kubernetes #comment add yarn in the fpm/worker images --- Dockerfile | 12 ++++++++++++ yarn.lock | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca4e87b204..c40dfc4347 100644 --- a/Dockerfile +++ b/Dockerfile @@ -146,6 +146,18 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ && php -r "unlink('composer-setup.php');" +# Node Installation (node + yarn) +# Reference : +# https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/ +# https://yarnpkg.com/lang/en/docs/install/#debian-stable +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ + && apt install -y nodejs \ + && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ + && apt-get update && apt-get install -y --no-install-recommends yarn \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/ + RUN mkdir /entrypoint /var/alchemy \ && useradd -u 1000 app \ && mkdir -p /home/app/.composer \ diff --git a/yarn.lock b/yarn.lock index 4cfedda66c..0e79ed1adf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5283,10 +5283,14 @@ jquery-simplecolorpicker@^0.3.1: resolved "https://registry.yarnpkg.com/jquery-simplecolorpicker/-/jquery-simplecolorpicker-0.3.1.tgz#4f6befd380ab05470f585d5482e5180556e460eb" integrity sha1-T2vv04CrBUcPWF1UguUYBVbkYOs= -"jquery-treeview@git+https://github.com/alchemy-fr/jquery-treeview.git", "jquery-treeview@git+https://github.com/alchemy-fr/jquery-treeview.git#1e9e5a49d2875b878801e904cd08c2d25e85af1e": +"jquery-treeview@git+https://github.com/alchemy-fr/jquery-treeview.git#1e9e5a49d2875b878801e904cd08c2d25e85af1e": + version "1.4.2" + resolved "git+https://github.com/alchemy-fr/jquery-treeview.git#1e9e5a49d2875b878801e904cd08c2d25e85af1e" + +"jquery-treeview@https://github.com/alchemy-fr/jquery-treeview.git": version "1.4.2" uid "1e9e5a49d2875b878801e904cd08c2d25e85af1e" - resolved "git+https://github.com/alchemy-fr/jquery-treeview.git#1e9e5a49d2875b878801e904cd08c2d25e85af1e" + resolved "https://github.com/alchemy-fr/jquery-treeview.git#1e9e5a49d2875b878801e904cd08c2d25e85af1e" jquery-ui-datepicker-with-i18n@^1.10.4: version "1.10.4" From beb57b3af2f6fa716e4b1b5f8be1557e0407a4e2 Mon Sep 17 00:00:00 2001 From: Harrys Ravalomanana Date: Mon, 11 Nov 2019 15:47:11 +0400 Subject: [PATCH 11/12] PHRAS-2816 #comment hidden fields on roll over and detailled view depending on gui_editable attribute #time 6h --- .../Phrasea/Twig/PhraseanetExtension.php | 24 +++++++++++++++++++ templates/web/common/macro_caption.html.twig | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index c39271db6a..1c48a54d52 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -48,6 +48,7 @@ class PhraseanetExtension extends \Twig_Extension new \Twig_SimpleFunction('border_checker_from_fqcn', array($this, 'getCheckerFromFQCN')), new \Twig_SimpleFunction('caption_field', array($this, 'getCaptionField')), new \Twig_SimpleFunction('caption_field_label', array($this, 'getCaptionFieldLabel')), + new \Twig_SimpleFunction('caption_field_gui_editable', array($this, 'getCaptionFieldGuiEditable')), new \Twig_SimpleFunction('caption_field_order', array($this, 'getCaptionFieldOrder')), new \Twig_SimpleFunction('flag_slugify', array(Flag::class, 'normalizeName')), @@ -77,6 +78,29 @@ class PhraseanetExtension extends \Twig_Extension return ''; } + /** + * get localized field's gui_editable + * @param RecordInterface $record + * @param $fieldName + * @return string - the name gui_editable + */ + public function getCaptionFieldGuiEditable(RecordInterface $record, $fieldName) + { + if ($record) { + /** @var \appbox $appbox */ + $appbox = $this->app['phraseanet.appbox']; + $databox = $appbox->get_databox($record->getDataboxId()); + foreach ($databox->get_meta_structure() as $meta) { + /** @var \databox_field $meta */ + if ($meta->get_name() === $fieldName) { + return $meta->get_gui_editable($this->app['locale']); + } + } + } + + return ''; + } + public function getCaptionField(RecordInterface $record, $field, $value) { if ($record instanceof ElasticsearchRecord) { diff --git a/templates/web/common/macro_caption.html.twig b/templates/web/common/macro_caption.html.twig index 21a1fab40d..78b269515f 100644 --- a/templates/web/common/macro_caption.html.twig +++ b/templates/web/common/macro_caption.html.twig @@ -1,8 +1,10 @@ {% macro caption(record, can_see_business, display_exif, limitedWidth = false) %}
{% for name, value in record.getCaption(caption_field_order(record, can_see_business)) %} -
{{ caption_field_label(record, name) }}
-
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
+ {% if caption_field_gui_editable(record, name) == 1 %} +
{{ caption_field_label(record, name) }}
+
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
+ {% endif %} {% endfor %}
{% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %} From 5f2617e5f7dd1e6305f3c315ac6fdafe53144c64 Mon Sep 17 00:00:00 2001 From: Harrys Ravalomanana Date: Tue, 12 Nov 2019 18:13:05 +0400 Subject: [PATCH 12/12] PHRAS-2816 #comment add attribute gui_visible to show fields on roll over and detailled view #time 2h --- .../Controller/Admin/FieldsController.php | 3 +- .../Phrasea/Controller/Api/V1Controller.php | 1 + .../Controller/Prod/EditController.php | 1 + lib/Alchemy/Phrasea/Core/Version.php | 2 +- .../Field/DbalDataboxFieldRepository.php | 1 + .../Phrasea/Twig/PhraseanetExtension.php | 10 +++---- lib/classes/databox.php | 1 + lib/classes/databox/field.php | 30 +++++++++++++++++-- lib/conf.d/bases_structure.xml | 8 +++++ .../web/admin/fields/templates.html.twig | 8 +++++ templates/web/common/macro_caption.html.twig | 2 +- .../Phrasea/Controller/Admin/FieldsTest.php | 1 + www/scripts/models/field.js | 1 + www/scripts/tests/specs/models.js | 4 +++ 14 files changed, 63 insertions(+), 10 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/FieldsController.php b/lib/Alchemy/Phrasea/Controller/Admin/FieldsController.php index 51ac40ab51..dc81bc67c3 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/FieldsController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/FieldsController.php @@ -316,6 +316,7 @@ class FieldsController extends Controller ->set_tbranch($data['tbranch']) ->set_generate_cterms($data['generate_cterms']) ->set_gui_editable($data['gui_editable']) + ->set_gui_visible($data['gui_visible']) ->set_report($data['report']) ->setVocabularyControl(null) ->setVocabularyRestricted(false); @@ -351,7 +352,7 @@ class FieldsController extends Controller { return [ 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'aggregable', - 'required', 'separator', 'readonly', 'gui_editable', 'type', 'tbranch', 'generate_cterms', 'report', + 'required', 'separator', 'readonly', 'gui_editable', 'gui_visible' , 'type', 'tbranch', 'generate_cterms', 'report', 'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels' ]; } diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 0c3bffb63e..9b8f4ed04d 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -596,6 +596,7 @@ class V1Controller extends Controller 'thesaurus_branch' => $databox_field->get_tbranch(), 'generate_cterms' => $databox_field->get_generate_cterms(), 'gui_editable' => $databox_field->get_gui_editable(), + 'gui_visible' => $databox_field->get_gui_visible(), 'type' => $databox_field->get_type(), 'indexable' => $databox_field->is_indexable(), 'multivalue' => $databox_field->is_multi(), diff --git a/lib/Alchemy/Phrasea/Controller/Prod/EditController.php b/lib/Alchemy/Phrasea/Controller/Prod/EditController.php index e164221a51..29ef942919 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/EditController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/EditController.php @@ -77,6 +77,7 @@ class EditController extends Controller 'tbranch' => $meta->get_tbranch(), 'generate_cterms' => $meta->get_generate_cterms(), 'gui_editable' => $meta->get_gui_editable(), + 'gui_visible' => $meta->get_gui_visible(), 'maxLength' => $meta->get_tag() ->getMaxLength(), 'minLength' => $meta->get_tag() diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index c525bf815c..19011867d9 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -16,7 +16,7 @@ class Version /** * @var string */ - private $number = '4.1.0-alpha.17a'; + private $number = '4.1.0-alpha.18a'; /** * @var string diff --git a/lib/Alchemy/Phrasea/Databox/Field/DbalDataboxFieldRepository.php b/lib/Alchemy/Phrasea/Databox/Field/DbalDataboxFieldRepository.php index 5f7e210a76..3e247d99c9 100644 --- a/lib/Alchemy/Phrasea/Databox/Field/DbalDataboxFieldRepository.php +++ b/lib/Alchemy/Phrasea/Databox/Field/DbalDataboxFieldRepository.php @@ -38,6 +38,7 @@ final class DbalDataboxFieldRepository implements DataboxFieldRepository 'label_nl', 'generate_cterms', 'gui_editable', + 'gui_visible', ]; /** @var DataboxFieldFactory */ diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index 1c48a54d52..efbf36fe81 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -48,7 +48,7 @@ class PhraseanetExtension extends \Twig_Extension new \Twig_SimpleFunction('border_checker_from_fqcn', array($this, 'getCheckerFromFQCN')), new \Twig_SimpleFunction('caption_field', array($this, 'getCaptionField')), new \Twig_SimpleFunction('caption_field_label', array($this, 'getCaptionFieldLabel')), - new \Twig_SimpleFunction('caption_field_gui_editable', array($this, 'getCaptionFieldGuiEditable')), + new \Twig_SimpleFunction('caption_field_gui_visible', array($this, 'getCaptionFieldGuiVisible')), new \Twig_SimpleFunction('caption_field_order', array($this, 'getCaptionFieldOrder')), new \Twig_SimpleFunction('flag_slugify', array(Flag::class, 'normalizeName')), @@ -79,12 +79,12 @@ class PhraseanetExtension extends \Twig_Extension } /** - * get localized field's gui_editable + * get localized field's gui_visible * @param RecordInterface $record * @param $fieldName - * @return string - the name gui_editable + * @return string - the name gui_visible */ - public function getCaptionFieldGuiEditable(RecordInterface $record, $fieldName) + public function getCaptionFieldGuiVisible(RecordInterface $record, $fieldName) { if ($record) { /** @var \appbox $appbox */ @@ -93,7 +93,7 @@ class PhraseanetExtension extends \Twig_Extension foreach ($databox->get_meta_structure() as $meta) { /** @var \databox_field $meta */ if ($meta->get_name() === $fieldName) { - return $meta->get_gui_editable($this->app['locale']); + return $meta->get_gui_visible($this->app['locale']); } } } diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 01aa2eea31..c961f1e58c 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -464,6 +464,7 @@ class databox extends base implements ThumbnailedElement ->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '') ->set_generate_cterms((isset($field['generate_cterms']) && (string) $field['generate_cterms'] == 1)) ->set_gui_editable((isset($field['gui_editable']) && (string) $field['gui_editable'] == 1)) + ->set_gui_visible((isset($field['gui_editable']) && (string) $field['gui_visible'] == 1)) ->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) ->set_report(isset($field['report']) ? (string) $field['report'] : '1') ->save(); diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index 09dab67d46..85e9089cad 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -45,6 +45,7 @@ class databox_field implements cache_cacheableInterface protected $tbranch; protected $generate_cterms; protected $gui_editable; + protected $gui_visible; protected $separator; protected $thumbtitle; @@ -170,6 +171,7 @@ class databox_field implements cache_cacheableInterface $this->tbranch = $row['tbranch']; $this->generate_cterms = (bool)$row['generate_cterms']; $this->gui_editable = (bool)$row['gui_editable']; + $this->gui_visible = (bool)$row['gui_visible']; $this->VocabularyType = $row['VocabularyControlType']; $this->VocabularyRestriction = (bool)$row['RestrictToVocabularyControl']; @@ -312,6 +314,7 @@ class databox_field implements cache_cacheableInterface `tbranch` = :tbranch, `generate_cterms` = :generate_cterms, `gui_editable` = :gui_editable, + `gui_visible` = :gui_visible, `sorter` = :position, `thumbtitle` = :thumbtitle, `VocabularyControlType` = :VocabularyControlType, @@ -337,6 +340,7 @@ class databox_field implements cache_cacheableInterface ':tbranch' => $this->tbranch, ':generate_cterms' => $this->generate_cterms ? '1' : '0', ':gui_editable' => $this->gui_editable ? '1' : '0', + ':gui_visible' => $this->gui_visible ? '1' : '0', ':position' => $this->position, ':thumbtitle' => $this->thumbtitle, ':VocabularyControlType' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null, @@ -390,6 +394,7 @@ class databox_field implements cache_cacheableInterface $meta->setAttribute('tbranch', $this->tbranch); $meta->setAttribute('generate_cterms', $this->generate_cterms ? '1' : '0'); $meta->setAttribute('gui_editable', $this->gui_editable ? '1' : '0'); + $meta->setAttribute('gui_visible', $this->gui_visible ? '1' : '0'); if ($this->multi) { $meta->setAttribute('separator', $this->separator); } @@ -743,6 +748,17 @@ class databox_field implements cache_cacheableInterface return $this; } + /** + * @param boolean $gui_visible + * @return databox_field + */ + public function set_gui_visible($gui_visible) + { + $this->gui_visible = $gui_visible; + + return $this; + } + /** * * @param string $separator @@ -845,6 +861,15 @@ class databox_field implements cache_cacheableInterface return $this->gui_editable; } + /** + * + * @return boolean + */ + public function get_gui_visible() + { + return $this->gui_visible; + } + /** * @param Boolean $all If set to false, returns a one-char separator to use for serialiation * @@ -957,6 +982,7 @@ class databox_field implements cache_cacheableInterface 'tbranch' => $this->tbranch, 'generate_cterms' => $this->generate_cterms, 'gui_editable' => $this->gui_editable, + 'gui_visible' => $this->gui_visible, 'separator' => $this->separator, 'required' => $this->required, 'report' => $this->report, @@ -995,10 +1021,10 @@ class databox_field implements cache_cacheableInterface } $sql = "INSERT INTO metadatas_structure - (`id`, `name`, `src`, `readonly`, `gui_editable`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`, + (`id`, `name`, `src`, `readonly`, `gui_editable`,`gui_visible`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`, `thumbtitle`, `multi`, `business`, `aggregable`, `report`, `sorter`, `separator`) - VALUES (null, :name, '', 0, 1, 0, 1, 'string', '', 1, + VALUES (null, :name, '', 0, 1, 1, 0, 1, 'string', '', 1, null, 0, 0, 0, 1, :sorter, '')"; diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index b989e2f9d6..8cfcd692fd 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -2049,6 +2049,14 @@ 1 + + gui_visible + int(1) unsigned + + + 1 + + diff --git a/templates/web/admin/fields/templates.html.twig b/templates/web/admin/fields/templates.html.twig index 191f3f18b8..f0757d3d37 100644 --- a/templates/web/admin/fields/templates.html.twig +++ b/templates/web/admin/fields/templates.html.twig @@ -197,6 +197,14 @@ + + + + +