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_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_aggregable((isset($field['aggregable']) ? (string) $field['aggregable'] : 0))
|
||||
->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'))
|
||||
|
@@ -122,8 +122,6 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
protected $Business;
|
||||
|
||||
protected $aggregable;
|
||||
|
||||
protected $renamed = false;
|
||||
|
||||
/**
|
||||
@@ -146,6 +144,7 @@ class databox_field implements cache_cacheableInterface
|
||||
protected $VocabularyRestriction = false;
|
||||
protected $on_error = false;
|
||||
protected $original_src;
|
||||
protected $aggregable;
|
||||
|
||||
const TYPE_TEXT = "text";
|
||||
const TYPE_DATE = "date";
|
||||
@@ -221,7 +220,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->aggregable = (Int) $row['aggregable'];
|
||||
$this->position = (Int) $row['sorter'];
|
||||
$this->type = $row['type'] ? : self::TYPE_STRING;
|
||||
$this->tbranch = $row['tbranch'];
|
||||
@@ -271,7 +270,7 @@ class databox_field implements cache_cacheableInterface
|
||||
|
||||
public function isAggregable()
|
||||
{
|
||||
return $this->aggregable;
|
||||
return $this->aggregable != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +407,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',
|
||||
':aggregable' => $this->aggregable,
|
||||
':report' => $this->report ? '1' : '0',
|
||||
':type' => $this->type,
|
||||
':tbranch' => $this->tbranch,
|
||||
@@ -460,7 +459,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('aggregable', $this->aggregable);
|
||||
$meta->setAttribute('type', $this->type);
|
||||
$meta->setAttribute('tbranch', $this->tbranch);
|
||||
if ($this->multi) {
|
||||
@@ -721,9 +720,9 @@ class databox_field implements cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_aggregable($boolean)
|
||||
public function set_aggregable($int)
|
||||
{
|
||||
$this->aggregable = ! ! $boolean;
|
||||
$this->aggregable = $int;
|
||||
|
||||
|
||||
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>
|
||||
<name>aggregable</name>
|
||||
<type>int(1) unsigned</type>
|
||||
<type>int(5)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>0</default>
|
||||
|
@@ -177,11 +177,18 @@
|
||||
</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>
|
||||
<label for="aggregable">{% trans %}Aggregation{% endtrans %}</label>
|
||||
</td>
|
||||
<td>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@@ -221,7 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'thumbtitle' => false,
|
||||
'tag' => 'XMP:XMP',
|
||||
'business' => false,
|
||||
'aggregable' => false,
|
||||
'aggregable' => 0,
|
||||
'indexable' => true,
|
||||
'required' => true,
|
||||
'labels' => [
|
||||
|
Reference in New Issue
Block a user