mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
change field.aggregable from bool to int -> allows to set the number of aggregation values
This commit is contained in:
@@ -992,7 +992,7 @@ class databox extends base
|
|||||||
->set_separator(isset($field['separator']) ? (string) $field['separator'] : '')
|
->set_separator(isset($field['separator']) ? (string) $field['separator'] : '')
|
||||||
->set_required((isset($field['required']) && (string) $field['required'] == 1))
|
->set_required((isset($field['required']) && (string) $field['required'] == 1))
|
||||||
->set_business((isset($field['business']) && (string) $field['business'] == 1))
|
->set_business((isset($field['business']) && (string) $field['business'] == 1))
|
||||||
->set_aggregable((isset($field['aggregable']) && (string) $field['aggregable'] == 1))
|
->set_aggregable((isset($field['aggregable']) ? (string) $field['aggregable'] : 0))
|
||||||
->set_type($type)
|
->set_type($type)
|
||||||
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
|
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
|
||||||
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
|
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
|
||||||
|
@@ -122,8 +122,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected $Business;
|
protected $Business;
|
||||||
|
|
||||||
protected $aggregable;
|
|
||||||
|
|
||||||
protected $renamed = false;
|
protected $renamed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,6 +144,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
protected $VocabularyRestriction = false;
|
protected $VocabularyRestriction = false;
|
||||||
protected $on_error = false;
|
protected $on_error = false;
|
||||||
protected $original_src;
|
protected $original_src;
|
||||||
|
protected $aggregable;
|
||||||
|
|
||||||
const TYPE_TEXT = "text";
|
const TYPE_TEXT = "text";
|
||||||
const TYPE_DATE = "date";
|
const TYPE_DATE = "date";
|
||||||
@@ -221,7 +220,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$this->multi = (Boolean) $row['multi'];
|
$this->multi = (Boolean) $row['multi'];
|
||||||
$this->Business = (Boolean) $row['business'];
|
$this->Business = (Boolean) $row['business'];
|
||||||
$this->report = (Boolean) $row['report'];
|
$this->report = (Boolean) $row['report'];
|
||||||
$this->aggregable = (Boolean) $row['aggregable'];
|
$this->aggregable = (Int) $row['aggregable'];
|
||||||
$this->position = (Int) $row['sorter'];
|
$this->position = (Int) $row['sorter'];
|
||||||
$this->type = $row['type'] ? : self::TYPE_STRING;
|
$this->type = $row['type'] ? : self::TYPE_STRING;
|
||||||
$this->tbranch = $row['tbranch'];
|
$this->tbranch = $row['tbranch'];
|
||||||
@@ -271,7 +270,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
public function isAggregable()
|
public function isAggregable()
|
||||||
{
|
{
|
||||||
return $this->aggregable;
|
return $this->aggregable != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -408,7 +407,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
':separator' => $this->separator,
|
':separator' => $this->separator,
|
||||||
':multi' => $this->multi ? '1' : '0',
|
':multi' => $this->multi ? '1' : '0',
|
||||||
':business' => $this->Business ? '1' : '0',
|
':business' => $this->Business ? '1' : '0',
|
||||||
':aggregable' => $this->aggregable ? '1' : '0',
|
':aggregable' => $this->aggregable,
|
||||||
':report' => $this->report ? '1' : '0',
|
':report' => $this->report ? '1' : '0',
|
||||||
':type' => $this->type,
|
':type' => $this->type,
|
||||||
':tbranch' => $this->tbranch,
|
':tbranch' => $this->tbranch,
|
||||||
@@ -460,7 +459,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$meta->setAttribute('multi', $this->multi ? '1' : '0');
|
$meta->setAttribute('multi', $this->multi ? '1' : '0');
|
||||||
$meta->setAttribute('report', $this->report ? '1' : '0');
|
$meta->setAttribute('report', $this->report ? '1' : '0');
|
||||||
$meta->setAttribute('business', $this->Business ? '1' : '0');
|
$meta->setAttribute('business', $this->Business ? '1' : '0');
|
||||||
$meta->setAttribute('aggregable', $this->aggregable ? '1' : '0');
|
$meta->setAttribute('aggregable', $this->aggregable);
|
||||||
$meta->setAttribute('type', $this->type);
|
$meta->setAttribute('type', $this->type);
|
||||||
$meta->setAttribute('tbranch', $this->tbranch);
|
$meta->setAttribute('tbranch', $this->tbranch);
|
||||||
if ($this->multi) {
|
if ($this->multi) {
|
||||||
@@ -721,9 +720,9 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_aggregable($boolean)
|
public function set_aggregable($int)
|
||||||
{
|
{
|
||||||
$this->aggregable = ! ! $boolean;
|
$this->aggregable = $int;
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
65
lib/classes/patch/390alpha22a.php
Normal file
65
lib/classes/patch/390alpha22a.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2015 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
|
||||||
|
class patch_390alpha22a implements patchInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $release = '3.9.0-alpha.22';
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $concern = [base::DATA_BOX];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getDoctrineMigrations()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(base $databox, Application $app)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE metadatas_structure SET `aggregable`=20 WHERE `aggregable`=1";
|
||||||
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -2655,7 +2655,7 @@
|
|||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>aggregable</name>
|
<name>aggregable</name>
|
||||||
<type>int(1) unsigned</type>
|
<type>int(5)</type>
|
||||||
<null></null>
|
<null></null>
|
||||||
<extra></extra>
|
<extra></extra>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
|
@@ -177,11 +177,18 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td>
|
||||||
<label for="aggregable" class="checkbox">
|
<label for="aggregable">{% trans %}Aggregation{% endtrans %}</label>
|
||||||
<input id="aggregable" type="checkbox" <%= field.aggregable ? "checked='checked'" : "" %> />
|
</td>
|
||||||
{% trans %}Aggregable fields{% endtrans %}
|
<td>
|
||||||
</label>
|
<select id="aggregable">
|
||||||
|
<option <%= field['aggregable'] == "0" ? 'selected' : '' %> value='0'>{% trans %}Not aggregated{% endtrans %}</option>
|
||||||
|
<option <%= field['aggregable'] == "10" ? 'selected' : '' %> value='10'>10 values</option>
|
||||||
|
<option <%= field['aggregable'] == "20" ? 'selected' : '' %> value='20'>20 values</option>
|
||||||
|
<option <%= field['aggregable'] == "50" ? 'selected' : '' %> value='50'>50 values</option>
|
||||||
|
<option <%= field['aggregable'] == "100" ? 'selected' : '' %> value='100'>100 values</option>
|
||||||
|
<option <%= field['aggregable'] == "-1" ? 'selected' : '' %> value='-1'>{% trans %}All values{% endtrans %}</option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -221,7 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
'thumbtitle' => false,
|
'thumbtitle' => false,
|
||||||
'tag' => 'XMP:XMP',
|
'tag' => 'XMP:XMP',
|
||||||
'business' => false,
|
'business' => false,
|
||||||
'aggregable' => false,
|
'aggregable' => 0,
|
||||||
'indexable' => true,
|
'indexable' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'labels' => [
|
'labels' => [
|
||||||
|
Reference in New Issue
Block a user