diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index 8e2080745e..015dd54d8d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -326,6 +326,7 @@ class Fields implements ControllerProviderInterface ->set_thumbtitle($data['thumbtitle']) ->set_tag(\databox_field::loadClassFromTagName($data['tag'])) ->set_business($data['business']) + ->set_aggregable($data['aggregable']) ->set_indexable($data['indexable']) ->set_required($data['required']) ->set_separator($data['separator']) @@ -366,7 +367,7 @@ class Fields implements ControllerProviderInterface private function getMandatoryFieldProperties() { return [ - 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', + 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'aggregable', 'required', 'separator', 'readonly', 'type', 'tbranch', 'report', 'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels' ]; diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 2e3a14874a..50067011fa 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -986,6 +986,7 @@ class databox extends base ->set_separator(isset($field['separator']) ? (string) $field['separator'] : '') ->set_required((isset($field['required']) && (string) $field['required'] == 1)) ->set_business((isset($field['business']) && (string) $field['business'] == 1)) + ->set_aggregable((isset($field['aggregable']) && (string) $field['aggregable'] == 1)) ->set_type($type) ->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '') ->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index f521ade653..193ff36a4f 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -117,6 +117,9 @@ class databox_field implements cache_cacheableInterface * @var boolean */ protected $Business; + + protected $aggregable; + protected $renamed = false; /** @@ -180,7 +183,7 @@ class databox_field implements cache_cacheableInterface $sql = "SELECT `thumbtitle`, `separator`, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`, `readonly`, `indexable`, - `name`, `src`, `business`, `VocabularyControlType`, + `name`, `src`, `business`, `aggregable`, `VocabularyControlType`, `RestrictToVocabularyControl`, `sorter`, `label_en`, `label_fr`, `label_de`, `label_nl` FROM metadatas_structure WHERE id=:id"; @@ -214,6 +217,7 @@ class databox_field implements cache_cacheableInterface $this->multi = (Boolean) $row['multi']; $this->Business = (Boolean) $row['business']; $this->report = (Boolean) $row['report']; + $this->aggregable = (Boolean) $row['aggregable']; $this->position = (Int) $row['sorter']; $this->type = $row['type'] ? : self::TYPE_STRING; $this->tbranch = $row['tbranch']; @@ -261,6 +265,11 @@ class databox_field implements cache_cacheableInterface return $this->Business; } + public function isAggregable() + { + return $this->aggregable; + } + /** * * @param Application $app @@ -370,6 +379,7 @@ class databox_field implements cache_cacheableInterface `separator` = :separator, `multi` = :multi, `business` = :business, + `aggregable` = :aggregable, `report` = :report, `type` = :type, `tbranch` = :tbranch, @@ -392,6 +402,7 @@ class databox_field implements cache_cacheableInterface ':separator' => $this->separator, ':multi' => $this->multi ? '1' : '0', ':business' => $this->Business ? '1' : '0', + ':aggregable' => $this->aggregable ? '1' : '0', ':report' => $this->report ? '1' : '0', ':type' => $this->type, ':tbranch' => $this->tbranch, @@ -443,6 +454,7 @@ class databox_field implements cache_cacheableInterface $meta->setAttribute('multi', $this->multi ? '1' : '0'); $meta->setAttribute('report', $this->report ? '1' : '0'); $meta->setAttribute('business', $this->Business ? '1' : '0'); + $meta->setAttribute('aggregable', $this->aggregable ? '1' : '0'); $meta->setAttribute('type', $this->type); $meta->setAttribute('tbranch', $this->tbranch); if ($this->multi) { @@ -601,6 +613,7 @@ class databox_field implements cache_cacheableInterface { $connbas = $this->get_connection(); + if (null !== $DCES_element) { $sql = 'UPDATE metadatas_structure SET dces_element = null WHERE dces_element = :dces_element'; @@ -695,6 +708,14 @@ class databox_field implements cache_cacheableInterface return $this; } + public function set_aggregable($boolean) + { + $this->aggregable = ! ! $boolean; + + + return $this; + } + /** * * @param boolean $required @@ -932,6 +953,7 @@ class databox_field implements cache_cacheableInterface 'name' => $this->name, 'tag' => $this->tag->getTagname(), 'business' => $this->Business, + 'aggregable' => $this->aggregable, 'type' => $this->type, 'sorter' => $this->position, 'thumbtitle' => $this->thumbtitle, @@ -975,11 +997,11 @@ class databox_field implements cache_cacheableInterface $sql = "INSERT INTO metadatas_structure (`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`, - `thumbtitle`, `multi`, `business`, + `thumbtitle`, `multi`, `business`, `aggregable`, `report`, `sorter`) VALUES (null, :name, '', 0, 1, 'string', '', null, :multi, - 0, 1, :sorter)"; + 0, 0, 1, :sorter)"; $name = self::generateName($name); diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index f87ffc59ba..d1b9d8f122 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -2654,6 +2654,14 @@ + + aggregable + int(1) unsigned + + + 0 + + indexable int(1) unsigned diff --git a/templates/web/admin/fields/templates.html.twig b/templates/web/admin/fields/templates.html.twig index a03479166a..abd2e20672 100644 --- a/templates/web/admin/fields/templates.html.twig +++ b/templates/web/admin/fields/templates.html.twig @@ -176,6 +176,14 @@ + + + + /> + {% trans %}Aggregable fields{% endtrans %} + + + {% trans %}Separator{% endtrans %} diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php index 92d401a199..935e5e8467 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php @@ -221,6 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase 'thumbtitle' => false, 'tag' => 'XMP:XMP', 'business' => false, + 'aggregable' => false, 'indexable' => true, 'required' => true, 'labels' => [