mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
Add aggregable property to metadata fields
This commit is contained in:
@@ -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'
|
||||
];
|
||||
|
@@ -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'))
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -2654,6 +2654,14 @@
|
||||
<default></default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>aggregable</name>
|
||||
<type>int(1) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>indexable</name>
|
||||
<type>int(1) unsigned</type>
|
||||
|
@@ -176,6 +176,14 @@
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<label for="aggregable" class="checkbox">
|
||||
<input id="aggregable" type="checkbox" <%= field.aggregable ? "checked='checked'" : "" %> />
|
||||
{% trans %}Aggregable fields{% endtrans %}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="separator">{% trans %}Separator{% endtrans %}</label></td>
|
||||
<td><input id="separator" type="text" value="<%= field.separator %>" /></td>
|
||||
|
@@ -221,6 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'thumbtitle' => false,
|
||||
'tag' => 'XMP:XMP',
|
||||
'business' => false,
|
||||
'aggregable' => false,
|
||||
'indexable' => true,
|
||||
'required' => true,
|
||||
'labels' => [
|
||||
|
Reference in New Issue
Block a user