diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Description.php b/lib/Alchemy/Phrasea/Controller/Admin/Description.php index 2895be87f0..7c2ca179a1 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Description.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Description.php @@ -179,7 +179,6 @@ class Description implements ControllerProviderInterface $field->set_name($request->get('name_' . $id)); $field->set_thumbtitle($request->get('thumbtitle_' . $id)); $field->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id))); - $field->set_multi($request->get('multi_' . $id)); $field->set_business($request->get('business_' . $id)); $field->set_indexable($request->get('indexable_' . $id)); $field->set_required($request->get('required_' . $id)); @@ -215,7 +214,7 @@ class Description implements ControllerProviderInterface } if ($request->get('newfield')) { - $field = \databox_field::create($databox, $request->get('newfield')); + $field = \databox_field::create($databox, $request->get('newfield'), $request->get('newfield_multi')); } if (is_array($request->get('todelete_ids'))) { diff --git a/lib/classes/caption/field.class.php b/lib/classes/caption/field.class.php index 077d81eeda..21876ffa2d 100644 --- a/lib/classes/caption/field.class.php +++ b/lib/classes/caption/field.class.php @@ -337,74 +337,6 @@ class caption_field implements cache_cacheableInterface return; } - protected static function merge_metadatas(databox_field $databox_field, record_adapter $record) - { - $sql = 'SELECT record_id, id, value FROM metadatas - WHERE meta_struct_id = :meta_struct_id - AND record_id = :record_id'; - - $params = array( - ':meta_struct_id' => $databox_field->get_id(), - ':record_id' => $record->get_record_id() - ); - - $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $stmt->execute($params); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - unset($stmt); - - $values = $current_metadatas = array(); - - foreach ($rs as $row) { - $current_metadatas[] = array( - 'meta_id' => $row['id'] - , 'meta_struct_id' => $databox_field->get_id() - , 'value' => '' - ); - - $values[] = $row['value']; - } - - try { - $record = $databox_field->get_databox()->get_record($record->get_record_id()); - $record->set_metadatas($current_metadatas); - $record->set_metadatas(array(array( - 'meta_id' => null - , 'meta_struct_id' => $databox_field->get_id() - , 'value' => implode(' ; ', $values) - ))); - - unset($record); - } catch (Exception $e) { - - } - - return; - } - - public static function merge_all_metadatas(databox_field $databox_field) - { - $sql = 'SELECT distinct record_id FROM metadatas - WHERE meta_struct_id = :meta_struct_id '; - - $params = array( - ':meta_struct_id' => $databox_field->get_id() - ); - - $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $stmt->execute($params); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - unset($stmt); - - foreach ($rs as $row) { - self::merge_metadatas($databox_field, $databox_field->get_databox()->get_record($row['record_id'])); - } - - return; - } - public static function delete_all_metadatas(databox_field $databox_field) { $sql = 'SELECT count(id) as count_id FROM metadatas diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 2fce7fdb7a..0f84bc5883 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -858,7 +858,7 @@ class databox extends base ) ) ? $type : databox_field::TYPE_STRING; - $meta_struct_field = databox_field::create($this, $fname); + $meta_struct_field = databox_field::create($this, $fname, false); $meta_struct_field ->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0) ->set_indexable(isset($field['index']) ? $field['index'] : '1') @@ -867,7 +867,6 @@ class databox extends base ->set_type($type) ->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '') ->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) - ->set_multi(isset($field['multi']) ? $field['multi'] : 0) ->set_report(isset($field['report']) ? $field['report'] : '1') ->save(); diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index f1d54cc29d..bf8fab28aa 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -104,7 +104,6 @@ class databox_field implements cache_cacheableInterface */ protected $Business; protected $renamed = false; - protected $metaToMerge = false; /** * @@ -365,11 +364,6 @@ class databox_field implements cache_cacheableInterface $this->renamed = false; } - if ($this->metaToMerge) { - caption_field::merge_all_metadatas($this); - $this->metaToMerge = false; - } - $dom_struct = $this->databox->get_dom_structure(); $xp_struct = $this->databox->get_xpath_structure(); @@ -595,26 +589,6 @@ class databox_field implements cache_cacheableInterface return $this; } - /** - * - * @param boolean $bool - * @return databox_field - */ - public function set_multi($multi) - { - $multi = ! ! $multi; - - if ($this->multi !== $multi && ! $multi) { - $this->metaToMerge = true; - } - - $this->multi = $multi; - - $this->set_separator(';'); - - return $this; - } - /** * * @param boolean $bool @@ -804,7 +778,7 @@ class databox_field implements cache_cacheableInterface return $this->on_error; } - public static function create(databox $databox, $name) + public static function create(databox $databox, $name, $multi) { $sorter = 0; @@ -822,7 +796,7 @@ class databox_field implements cache_cacheableInterface `thumbtitle`, `multi`, `business`, `report`, `sorter`) VALUES (null, :name, '', 0, 1, 'string', '', - null, 0, + null, :multi, 0, 1, :sorter)"; $name = self::generateName($name); @@ -831,8 +805,10 @@ class databox_field implements cache_cacheableInterface throw new \Exception_InvalidArgument(); } + $multi = $multi ? 1 : 0; + $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array(':name' => $name, ':sorter' => $sorter)); + $stmt->execute(array(':name' => $name, ':sorter' => $sorter, ':multi' => $multi)); $id = $databox->get_connection()->lastInsertId(); $stmt->closeCursor(); diff --git a/templates/web/admin/databox/doc_structure.twig b/templates/web/admin/databox/doc_structure.twig index e2f480222c..bb4ab22d28 100644 --- a/templates/web/admin/databox/doc_structure.twig +++ b/templates/web/admin/databox/doc_structure.twig @@ -4,7 +4,7 @@ {% set disabled = 'disabled="disabled"' %} {% endif %} -