mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Merge pull request #3982 from alchemy-fr/revert-3976-revert-3973-PHRAS-3215_orientation-facet-of-thumbnail
PHRAS-3215 : merge add ThumbnailOrientation facet
This commit is contained in:
@@ -2813,7 +2813,7 @@ class V1Controller extends Controller
|
|||||||
{
|
{
|
||||||
$ret = [
|
$ret = [
|
||||||
"meta_fields" => $this->listUserAuthorizedMetadataFields($this->getAuthenticatedUser()),
|
"meta_fields" => $this->listUserAuthorizedMetadataFields($this->getAuthenticatedUser()),
|
||||||
"aggregable_fields" => $this->buildUserFieldList(ElasticsearchOptions::getAggregableTechnicalFields(), ['choices']),
|
"aggregable_fields" => $this->buildUserFieldList(ElasticsearchOptions::getAggregableTechnicalFields($this->app['translator']), ['choices']),
|
||||||
"technical_fields" => $this->buildUserFieldList(media_subdef::getTechnicalFieldsList()),
|
"technical_fields" => $this->buildUserFieldList(media_subdef::getTechnicalFieldsList()),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -76,7 +76,8 @@ class QueryController extends Controller
|
|||||||
$this->app['elasticsearch.client'],
|
$this->app['elasticsearch.client'],
|
||||||
$query_context_factory,
|
$query_context_factory,
|
||||||
$this->app['elasticsearch.facets_response.factory'],
|
$this->app['elasticsearch.facets_response.factory'],
|
||||||
$this->app['elasticsearch.options']
|
$this->app['elasticsearch.options'],
|
||||||
|
$this->app['translator']
|
||||||
);
|
);
|
||||||
|
|
||||||
$autocomplete = $engine->autocomplete($word, $options);
|
$autocomplete = $engine->autocomplete($word, $options);
|
||||||
@@ -351,7 +352,7 @@ class QueryController extends Controller
|
|||||||
|
|
||||||
// add technical fields
|
// add technical fields
|
||||||
$fieldsInfosByName = [];
|
$fieldsInfosByName = [];
|
||||||
foreach(ElasticsearchOptions::getAggregableTechnicalFields() as $k => $f) {
|
foreach(ElasticsearchOptions::getAggregableTechnicalFields($this->app['translator']) as $k => $f) {
|
||||||
$fieldsInfosByName[$k] = $f;
|
$fieldsInfosByName[$k] = $f;
|
||||||
$fieldsInfosByName[$k]['trans_label'] = $this->app->trans( /** @ignore */ $f['label']);
|
$fieldsInfosByName[$k]['trans_label'] = $this->app->trans( /** @ignore */ $f['label']);
|
||||||
$fieldsInfosByName[$k]['labels'] = [];
|
$fieldsInfosByName[$k]['labels'] = [];
|
||||||
|
@@ -96,7 +96,8 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
|
|||||||
$app['elasticsearch.client'],
|
$app['elasticsearch.client'],
|
||||||
$app['query_context.factory'],
|
$app['query_context.factory'],
|
||||||
$app['elasticsearch.facets_response.factory'],
|
$app['elasticsearch.facets_response.factory'],
|
||||||
$app['elasticsearch.options']
|
$app['elasticsearch.options'],
|
||||||
|
$app['translator']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ use Closure;
|
|||||||
use databox_field;
|
use databox_field;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Elasticsearch\Client;
|
use Elasticsearch\Client;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class ElasticSearchEngine implements SearchEngineInterface
|
class ElasticSearchEngine implements SearchEngineInterface
|
||||||
{
|
{
|
||||||
@@ -59,6 +60,8 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
*/
|
*/
|
||||||
private $context_factory;
|
private $context_factory;
|
||||||
|
|
||||||
|
private $translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param GlobalStructure $structure
|
* @param GlobalStructure $structure
|
||||||
@@ -66,8 +69,9 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
* @param QueryContextFactory $context_factory
|
* @param QueryContextFactory $context_factory
|
||||||
* @param Closure $facetsResponseFactory
|
* @param Closure $facetsResponseFactory
|
||||||
* @param ElasticsearchOptions $options
|
* @param ElasticsearchOptions $options
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
*/
|
*/
|
||||||
public function __construct(Application $app, GlobalStructure $structure, Client $client, QueryContextFactory $context_factory, Closure $facetsResponseFactory, ElasticsearchOptions $options)
|
public function __construct(Application $app, GlobalStructure $structure, Client $client, QueryContextFactory $context_factory, Closure $facetsResponseFactory, ElasticsearchOptions $options, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->structure = $structure;
|
$this->structure = $structure;
|
||||||
@@ -75,6 +79,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
$this->context_factory = $context_factory;
|
$this->context_factory = $context_factory;
|
||||||
$this->facetsResponseFactory = $facetsResponseFactory;
|
$this->facetsResponseFactory = $facetsResponseFactory;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
$this->translator = $translator;
|
||||||
|
|
||||||
$this->indexName = $options->getIndexName();
|
$this->indexName = $options->getIndexName();
|
||||||
}
|
}
|
||||||
@@ -780,7 +785,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
{
|
{
|
||||||
$aggs = [];
|
$aggs = [];
|
||||||
// technical aggregates (enable + optional limit)
|
// technical aggregates (enable + optional limit)
|
||||||
foreach (ElasticsearchOptions::getAggregableTechnicalFields() as $k => $f) {
|
foreach (ElasticsearchOptions::getAggregableTechnicalFields($this->translator) as $k => $f) {
|
||||||
$size = $this->options->getAggregableFieldLimit($k);
|
$size = $this->options->getAggregableFieldLimit($k);
|
||||||
if ($size !== databox_field::FACET_DISABLED) {
|
if ($size !== databox_field::FACET_DISABLED) {
|
||||||
if ($size === databox_field::FACET_NO_LIMIT) {
|
if ($size === databox_field::FACET_NO_LIMIT) {
|
||||||
@@ -793,6 +798,13 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
$aggs[$k] = $agg;
|
$aggs[$k] = $agg;
|
||||||
|
if($options->getIncludeUnsetFieldFacet() === true) {
|
||||||
|
$aggs[$k . '#empty'] = [
|
||||||
|
'missing' => [
|
||||||
|
'field' => $f['esfield'],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fields aggregates
|
// fields aggregates
|
||||||
|
@@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\SearchEngine\Elastic;
|
|||||||
|
|
||||||
use databox_field;
|
use databox_field;
|
||||||
use igorw;
|
use igorw;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
|
||||||
class ElasticsearchOptions
|
class ElasticsearchOptions
|
||||||
@@ -312,7 +313,7 @@ class ElasticsearchOptions
|
|||||||
$this->_customValues = igorw\assoc_in($this->_customValues, $keys, $value);
|
$this->_customValues = igorw\assoc_in($this->_customValues, $keys, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAggregableTechnicalFields()
|
public static function getAggregableTechnicalFields(TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'_base' => [
|
'_base' => [
|
||||||
@@ -338,21 +339,21 @@ class ElasticsearchOptions
|
|||||||
],
|
],
|
||||||
'_camera_model' => [
|
'_camera_model' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Camera Model',
|
'label' => 'prod::facet:CameraModel_label',
|
||||||
'field' => "meta.CameraModel",
|
'field' => "meta.CameraModel",
|
||||||
'esfield' => 'metadata_tags.CameraModel',
|
'esfield' => 'metadata_tags.CameraModel',
|
||||||
'query' => 'meta.CameraModel:%s',
|
'query' => 'meta.CameraModel=%s',
|
||||||
],
|
],
|
||||||
'_iso' => [
|
'_iso' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'label' => 'ISO',
|
'label' => 'prod::facet:ISO_label',
|
||||||
'field' => "meta.ISO",
|
'field' => "meta.ISO",
|
||||||
'esfield' => 'metadata_tags.ISO',
|
'esfield' => 'metadata_tags.ISO',
|
||||||
'query' => 'meta.ISO=%s',
|
'query' => 'meta.ISO=%s',
|
||||||
],
|
],
|
||||||
'_aperture' => [
|
'_aperture' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'label' => 'Aperture',
|
'label' => 'prod::facet:Aperture_label',
|
||||||
'field' => "meta.Aperture",
|
'field' => "meta.Aperture",
|
||||||
'esfield' => 'metadata_tags.Aperture',
|
'esfield' => 'metadata_tags.Aperture',
|
||||||
'query' => 'meta.Aperture=%s',
|
'query' => 'meta.Aperture=%s',
|
||||||
@@ -362,7 +363,7 @@ class ElasticsearchOptions
|
|||||||
],
|
],
|
||||||
'_shutterspeed' => [
|
'_shutterspeed' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'label' => 'Shutter speed',
|
'label' => 'prod::facet:ShutterSpeed_label',
|
||||||
'field' => "meta.ShutterSpeed",
|
'field' => "meta.ShutterSpeed",
|
||||||
'esfield' => 'metadata_tags.ShutterSpeed',
|
'esfield' => 'metadata_tags.ShutterSpeed',
|
||||||
'query' => 'meta.ShutterSpeed=%s',
|
'query' => 'meta.ShutterSpeed=%s',
|
||||||
@@ -375,63 +376,86 @@ class ElasticsearchOptions
|
|||||||
],
|
],
|
||||||
'_flashfired' => [
|
'_flashfired' => [
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'label' => 'FlashFired',
|
'label' => 'prod::facet:FlashFired_label',
|
||||||
'field' => "meta.FlashFired",
|
'field' => "meta.FlashFired",
|
||||||
'esfield' => 'metadata_tags.FlashFired',
|
'esfield' => 'metadata_tags.FlashFired',
|
||||||
'query' => 'meta.FlashFired=%s',
|
'query' => 'meta.FlashFired=%s',
|
||||||
'choices' => [
|
'choices' => [
|
||||||
"aggregated (2 values: fired = 0 or 1)" => -1,
|
"aggregated (2 values: fired = 0 or 1)" => -1,
|
||||||
],
|
],
|
||||||
'output_formatter' => function($value) {
|
'output_formatter' => function($value) use($translator) {
|
||||||
static $map = ["false"=>"No flash", "true"=>"Flash", '0'=>"No flash", '1'=>"Flash"];
|
$map = [
|
||||||
|
"false" => $translator->trans("facet.flashfired:no"),
|
||||||
|
"true" => $translator->trans("facet.flashfired:yes"),
|
||||||
|
'0' => $translator->trans("facet.flashfired:no"),
|
||||||
|
'1' => $translator->trans("facet.flashfired:yes")
|
||||||
|
];
|
||||||
return array_key_exists($value, $map) ? $map[$value] : $value;
|
return array_key_exists($value, $map) ? $map[$value] : $value;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'_framerate' => [
|
'_framerate' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'label' => 'FrameRate',
|
'label' => 'prod::facet:FrameRate_label',
|
||||||
'field' => "meta.FrameRate",
|
'field' => "meta.FrameRate",
|
||||||
'esfield' => 'metadata_tags.FrameRate',
|
'esfield' => 'metadata_tags.FrameRate',
|
||||||
'query' => 'meta.FrameRate=%s',
|
'query' => 'meta.FrameRate=%s',
|
||||||
],
|
],
|
||||||
'_audiosamplerate' => [
|
'_audiosamplerate' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'label' => 'Audio Samplerate',
|
'label' => 'prod::facet:AudioSamplerate_label',
|
||||||
'field' => "meta.AudioSamplerate",
|
'field' => "meta.AudioSamplerate",
|
||||||
'esfield' => 'metadata_tags.AudioSamplerate',
|
'esfield' => 'metadata_tags.AudioSamplerate',
|
||||||
'query' => 'meta.AudioSamplerate=%s',
|
'query' => 'meta.AudioSamplerate=%s',
|
||||||
],
|
],
|
||||||
'_videocodec' => [
|
'_videocodec' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Video codec',
|
'label' => 'prod::facet:VideoCodec_label',
|
||||||
'field' => "meta.VideoCodec",
|
'field' => "meta.VideoCodec",
|
||||||
'esfield' => 'metadata_tags.VideoCodec',
|
'esfield' => 'metadata_tags.VideoCodec',
|
||||||
'query' => 'meta.VideoCodec:%s',
|
'query' => 'meta.VideoCodec:%s',
|
||||||
],
|
],
|
||||||
'_audiocodec' => [
|
'_audiocodec' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Audio codec',
|
'label' => 'prod::facet:AudioCodec_label',
|
||||||
'field' => "meta.AudioCodec",
|
'field' => "meta.AudioCodec",
|
||||||
'esfield' => 'metadata_tags.AudioCodec',
|
'esfield' => 'metadata_tags.AudioCodec',
|
||||||
'query' => 'meta.AudioCodec:%s',
|
'query' => 'meta.AudioCodec:%s',
|
||||||
],
|
],
|
||||||
'_orientation' => [
|
'_orientation' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Orientation',
|
'label' => 'prod::facet.Orientation_label',
|
||||||
'field' => "meta.Orientation",
|
'field' => "meta.Orientation",
|
||||||
'esfield' => 'metadata_tags.Orientation',
|
'esfield' => 'metadata_tags.Orientation',
|
||||||
'query' => 'meta.Orientation=%s',
|
'query' => 'meta.Orientation=%s',
|
||||||
],
|
],
|
||||||
|
'_thumbnail_orientation' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'prod::facet.ThumbnailOrientation_label',
|
||||||
|
'field' => "meta.ThumbnailOrientation",
|
||||||
|
'esfield' => 'metadata_tags.ThumbnailOrientation',
|
||||||
|
'query' => 'meta.ThumbnailOrientation=%s',
|
||||||
|
'choices' => [
|
||||||
|
"aggregated (4 values: '', 'S', 'L', 'P')" => -1,
|
||||||
|
],
|
||||||
|
'output_formatter' => function($value) use($translator) {
|
||||||
|
$map = [
|
||||||
|
"L" => $translator->trans("facet.ThumbnailOrientation:Landscape"),
|
||||||
|
"P" => $translator->trans("facet.ThumbnailOrientation:Portrait"),
|
||||||
|
'S' => $translator->trans("facet.ThumbnailOrientation:Square")
|
||||||
|
];
|
||||||
|
return array_key_exists($value, $map) ? $map[$value] : $value;
|
||||||
|
},
|
||||||
|
],
|
||||||
'_colorspace' => [
|
'_colorspace' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Colorspace',
|
'label' => 'prod::facet:Colorspace_label',
|
||||||
'field' => "meta.ColorSpace",
|
'field' => "meta.ColorSpace",
|
||||||
'esfield' => 'metadata_tags.ColorSpace',
|
'esfield' => 'metadata_tags.ColorSpace',
|
||||||
'query' => 'meta.ColorSpace:%s',
|
'query' => 'meta.ColorSpace:%s',
|
||||||
],
|
],
|
||||||
'_mimetype' => [
|
'_mimetype' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'MimeType',
|
'label' => 'prod::facet:MimeType_label',
|
||||||
'field' => "meta.MimeType",
|
'field' => "meta.MimeType",
|
||||||
'esfield' => 'metadata_tags.MimeType',
|
'esfield' => 'metadata_tags.MimeType',
|
||||||
'query' => 'meta.MimeType:%s',
|
'query' => 'meta.MimeType:%s',
|
||||||
|
@@ -137,7 +137,7 @@ class ElasticsearchSettingsFormType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add or replace hardcoded tech fields
|
// add or replace hardcoded tech fields
|
||||||
foreach(ElasticsearchOptions::getAggregableTechnicalFields() as $k => $f) {
|
foreach(ElasticsearchOptions::getAggregableTechnicalFields($this->translator) as $k => $f) {
|
||||||
$choices = array_key_exists('choices', $f) ? $f['choices'] : null; // a tech-field can publish it's own choices
|
$choices = array_key_exists('choices', $f) ? $f['choices'] : null; // a tech-field can publish it's own choices
|
||||||
$help = null;
|
$help = null;
|
||||||
$label = '#' . $k;
|
$label = '#' . $k;
|
||||||
|
@@ -18,7 +18,18 @@ use media_Permalink_Adapter;
|
|||||||
|
|
||||||
class SubDefinitionHydrator implements HydratorInterface
|
class SubDefinitionHydrator implements HydratorInterface
|
||||||
{
|
{
|
||||||
/** @var Application */
|
const ORIENTATION_SQUARE = 'S';
|
||||||
|
const ORIENTATION_LANDSCAPE = 'L';
|
||||||
|
const ORIENTATION_PORTRAIT = 'P';
|
||||||
|
const ORIENTATION_UNKNOW = '';
|
||||||
|
|
||||||
|
// const ORIENTATION_SQUARE = 1;
|
||||||
|
// const ORIENTATION_LANDSCAPE = 2;
|
||||||
|
// const ORIENTATION_PORTRAIT = 3;
|
||||||
|
// const ORIENTATION_UNKNOW = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Application */
|
||||||
private $app;
|
private $app;
|
||||||
|
|
||||||
/** @var databox */
|
/** @var databox */
|
||||||
@@ -38,45 +49,50 @@ class SubDefinitionHydrator implements HydratorInterface
|
|||||||
{
|
{
|
||||||
if ($this->populatePermalinks) {
|
if ($this->populatePermalinks) {
|
||||||
$this->hydrateRecordsWithPermalinks($records);
|
$this->hydrateRecordsWithPermalinks($records);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$this->hydrateRecordsWithoutPermalinks($records);
|
$this->hydrateRecordsWithoutPermalinks($records);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function hydrateRecordsWithPermalinks(&$records)
|
private function hydrateRecordsWithPermalinks(&$records)
|
||||||
{
|
{
|
||||||
foreach(array_keys($records) as $rid) {
|
foreach (array_keys($records) as $rid) {
|
||||||
|
|
||||||
|
$record = &$records[$rid];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$subdefs = $this->databox->getRecordRepository()->find($rid)->get_subdefs();
|
$subdefs = $this->databox->getRecordRepository()->find($rid)->get_subdefs();
|
||||||
|
|
||||||
$pls = array_map(
|
$pls = array_map(
|
||||||
/** media_Permalink_Adapter|null $plink */
|
/** media_Permalink_Adapter|null $plink */
|
||||||
function($plink) {
|
function ($plink) {
|
||||||
return $plink ? ((string) $plink->get_url()) : null;
|
return $plink ? ((string)$plink->get_url()) : null;
|
||||||
},
|
},
|
||||||
media_Permalink_Adapter::getMany($this->app, $subdefs, false) // false: don't create missing plinks
|
media_Permalink_Adapter::getMany($this->app, $subdefs, false) // false: don't create missing plinks
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($subdefs as $subdef) {
|
foreach ($subdefs as $subdef) {
|
||||||
$name = $subdef->get_name();
|
$name = $subdef->get_name();
|
||||||
if(substr(($path = $subdef->get_path()), -1) !== '/') {
|
if (substr(($path = $subdef->get_path()), -1) !== '/') {
|
||||||
$path .= '/';
|
$path .= '/';
|
||||||
}
|
}
|
||||||
$records[$rid]['subdefs'][$name] = array(
|
$record['subdefs'][$name] = [
|
||||||
'path' => $path . $subdef->get_file(),
|
'path' => $path . $subdef->get_file(),
|
||||||
'width' => $subdef->get_width(),
|
'width' => $subdef->get_width(),
|
||||||
'height' => $subdef->get_height(),
|
'height' => $subdef->get_height(),
|
||||||
'size' => $subdef->get_size(),
|
'size' => $subdef->get_size(),
|
||||||
'mime' => $subdef->get_mime(),
|
'mime' => $subdef->get_mime(),
|
||||||
'permalink' => array_key_exists($name, $pls) ? $pls[$name] : null
|
'permalink' => array_key_exists($name, $pls) ? $pls[$name] : null
|
||||||
);
|
];
|
||||||
|
if ($name == "thumbnail") {
|
||||||
|
$this->setOrientation($record, $subdef->get_width(), $subdef->get_height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
// cant get record ? ignore
|
// cant get record ? ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,22 +112,42 @@ class SubDefinitionHydrator implements HydratorInterface
|
|||||||
ORDER BY s.record_id
|
ORDER BY s.record_id
|
||||||
SQL;
|
SQL;
|
||||||
$statement = $this->databox->get_connection()->executeQuery($sql,
|
$statement = $this->databox->get_connection()->executeQuery($sql,
|
||||||
array(array_keys($records)),
|
[array_keys($records)],
|
||||||
array(Connection::PARAM_INT_ARRAY)
|
[Connection::PARAM_INT_ARRAY]
|
||||||
);
|
);
|
||||||
|
|
||||||
$current_rid = null;
|
$current_rid = null;
|
||||||
$record = null;
|
$record = null;
|
||||||
while ($subdef = $statement->fetch()) {
|
while ($subdef = $statement->fetch()) {
|
||||||
|
$rid = $subdef['record_id'];
|
||||||
|
$record = &$records[$rid];
|
||||||
$name = $subdef['name'];
|
$name = $subdef['name'];
|
||||||
$records[$subdef['record_id']]['subdefs'][$name] = array(
|
$record['subdefs'][$name] = [
|
||||||
'path' => $subdef['path'],
|
'path' => $subdef['path'],
|
||||||
'width' => $subdef['width'],
|
'width' => $subdef['width'],
|
||||||
'height' => $subdef['height'],
|
'height' => $subdef['height'],
|
||||||
'size' => $subdef['size'],
|
'size' => $subdef['size'],
|
||||||
'mime' => $subdef['mime'],
|
'mime' => $subdef['mime'],
|
||||||
'permalink' => null
|
'permalink' => null
|
||||||
);
|
];
|
||||||
|
if ($name == "thumbnail") {
|
||||||
|
$this->setOrientation($record, $subdef['width'], $subdef['height']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setOrientation(&$record, $w, $h)
|
||||||
|
{
|
||||||
|
$o = self::ORIENTATION_UNKNOW;
|
||||||
|
if ($w !== '' && $h !== '' && !is_null($w) && !is_null($h)) {
|
||||||
|
$w = (int)$w;
|
||||||
|
$h = (int)$h;
|
||||||
|
$o = $w == $h ? self::ORIENTATION_SQUARE : ($w > $h ? self::ORIENTATION_LANDSCAPE : self::ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
if(!array_key_exists('metadata_tags', $record)) {
|
||||||
|
$record['metadata_tags'] = [];
|
||||||
|
}
|
||||||
|
$record['metadata_tags']['ThumbnailOrientation'] = $o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,25 @@ class MetadataTagToFieldMappingConverter
|
|||||||
{
|
{
|
||||||
|
|
||||||
public function convertTag(Tag $tag)
|
public function convertTag(Tag $tag)
|
||||||
|
{
|
||||||
|
if ($tag->getType() === FieldMapping::TYPE_STRING) {
|
||||||
|
|
||||||
|
$fieldMapping = new StringFieldMapping($tag->getName());
|
||||||
|
$fieldMapping->addChild((new StringFieldMapping('raw'))->enableRawIndexing());
|
||||||
|
if ($tag->isAnalyzable()) {
|
||||||
|
$fieldMapping->enableAnalysis();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$fieldMapping->disableAnalysis();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fieldMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FieldMapping($tag->getName(), $tag->getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dead_convertTag(Tag $tag)
|
||||||
{
|
{
|
||||||
if ($tag->getType() === FieldMapping::TYPE_STRING) {
|
if ($tag->getType() === FieldMapping::TYPE_STRING) {
|
||||||
$fieldMapping = new StringFieldMapping($tag->getName());
|
$fieldMapping = new StringFieldMapping($tag->getName());
|
||||||
|
@@ -24,7 +24,7 @@ class FacetsResponse
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$atf = ElasticsearchOptions::getAggregableTechnicalFields();
|
$atf = ElasticsearchOptions::getAggregableTechnicalFields($this->translator);
|
||||||
|
|
||||||
// sort facets respecting the order defined in options
|
// sort facets respecting the order defined in options
|
||||||
foreach($options->getAggregableFields() as $name=>$foptions) {
|
foreach($options->getAggregableFields() as $name=>$foptions) {
|
||||||
@@ -35,9 +35,11 @@ class FacetsResponse
|
|||||||
|
|
||||||
$tf = null;
|
$tf = null;
|
||||||
$valueFormatter = function($v){ return $v; }; // default equality formatter
|
$valueFormatter = function($v){ return $v; }; // default equality formatter
|
||||||
|
$label = $name;
|
||||||
|
|
||||||
if(array_key_exists($name, $atf)) {
|
if(array_key_exists($name, $atf)) {
|
||||||
$tf = $atf[$name];
|
$tf = $atf[$name];
|
||||||
|
$label = $tf['label'];
|
||||||
if(array_key_exists('output_formatter', $tf)) {
|
if(array_key_exists('output_formatter', $tf)) {
|
||||||
$valueFormatter = $tf['output_formatter'];
|
$valueFormatter = $tf['output_formatter'];
|
||||||
}
|
}
|
||||||
@@ -56,7 +58,8 @@ class FacetsResponse
|
|||||||
if($response['aggregations'][$name . '#empty']['doc_count'] > 0) { // don't add a facet for 0 results
|
if($response['aggregations'][$name . '#empty']['doc_count'] > 0) { // don't add a facet for 0 results
|
||||||
$aggregation['buckets'][] = [
|
$aggregation['buckets'][] = [
|
||||||
'key' => '_unset_',
|
'key' => '_unset_',
|
||||||
'value' => $this->translator->trans('prod:workzone:facetstab:unset_field_facet_label_(%fieldname%)', ['%fieldname%' =>$name]), // special homemade prop to display a human value instead of the key
|
'value' => $this->translator->trans('prod:workzone:facetstab:unset_field_facet_label_(%fieldname%)', ['%fieldname%' =>$label]), // special homemade prop to display a human value instead of the key
|
||||||
|
// 'value' => 'unset '.$name, // special homemade prop to display a human value instead of the key
|
||||||
'doc_count' => $response['aggregations'][$name . '#empty']['doc_count']
|
'doc_count' => $response['aggregations'][$name . '#empty']['doc_count']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -70,8 +73,15 @@ class FacetsResponse
|
|||||||
$key = array_key_exists('key_as_string', $bucket) ? $bucket['key_as_string'] : $bucket['key'];
|
$key = array_key_exists('key_as_string', $bucket) ? $bucket['key_as_string'] : $bucket['key'];
|
||||||
if($tf) {
|
if($tf) {
|
||||||
// the field is one of the hardcoded tech fields
|
// the field is one of the hardcoded tech fields
|
||||||
|
if($key == '_unset_' && array_key_exists('value', $bucket)) {
|
||||||
|
// don't use the valueformatter since 'value' if already translated
|
||||||
|
$v = $bucket['value'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$v = $valueFormatter($key);
|
||||||
|
}
|
||||||
$value = [
|
$value = [
|
||||||
'value' => $valueFormatter($key),
|
'value' => $v,
|
||||||
'raw_value' => $key,
|
'raw_value' => $key,
|
||||||
'count' => $bucket['doc_count'],
|
'count' => $bucket['doc_count'],
|
||||||
'query' => sprintf($tf['query'], $this->escaper->escapeWord($key))
|
'query' => sprintf($tf['query'], $this->escaper->escapeWord($key))
|
||||||
|
@@ -109,6 +109,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
const TC_DATA_COLORSPACE = 'ColorSpace';
|
const TC_DATA_COLORSPACE = 'ColorSpace';
|
||||||
const TC_DATA_CHANNELS = 'Channels';
|
const TC_DATA_CHANNELS = 'Channels';
|
||||||
const TC_DATA_ORIENTATION = 'Orientation';
|
const TC_DATA_ORIENTATION = 'Orientation';
|
||||||
|
const TC_DATA_THUMBNAILORIENTATION = 'ThumbnailOrientation';
|
||||||
const TC_DATA_COLORDEPTH = 'ColorDepth';
|
const TC_DATA_COLORDEPTH = 'ColorDepth';
|
||||||
const TC_DATA_DURATION = 'Duration';
|
const TC_DATA_DURATION = 'Duration';
|
||||||
const TC_DATA_AUDIOCODEC = 'AudioCodec';
|
const TC_DATA_AUDIOCODEC = 'AudioCodec';
|
||||||
@@ -864,6 +865,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
|||||||
self::TC_DATA_VIDEOCODEC => ['method' => 'getVideoCodec', 'type' => 'string', 'analyzable' => false],
|
self::TC_DATA_VIDEOCODEC => ['method' => 'getVideoCodec', 'type' => 'string', 'analyzable' => false],
|
||||||
self::TC_DATA_AUDIOCODEC => ['method' => 'getAudioCodec', 'type' => 'string', 'analyzable' => false],
|
self::TC_DATA_AUDIOCODEC => ['method' => 'getAudioCodec', 'type' => 'string', 'analyzable' => false],
|
||||||
self::TC_DATA_ORIENTATION => ['method' => 'getOrientation', 'type' => 'integer', 'analyzable' => false],
|
self::TC_DATA_ORIENTATION => ['method' => 'getOrientation', 'type' => 'integer', 'analyzable' => false],
|
||||||
|
self::TC_DATA_THUMBNAILORIENTATION => ['type' => 'string', 'analyzable' => false],
|
||||||
self::TC_DATA_LONGITUDE => ['method' => 'getLongitude', 'type' => 'float', 'analyzable' => false],
|
self::TC_DATA_LONGITUDE => ['method' => 'getLongitude', 'type' => 'float', 'analyzable' => false],
|
||||||
self::TC_DATA_LONGITUDE_REF => ['method' => 'getLongitudeRef'],
|
self::TC_DATA_LONGITUDE_REF => ['method' => 'getLongitudeRef'],
|
||||||
self::TC_DATA_LATITUDE => ['method' => 'getLatitude', 'type' => 'float', 'analyzable' => false],
|
self::TC_DATA_LATITUDE => ['method' => 'getLatitude', 'type' => 'float', 'analyzable' => false],
|
||||||
|
Reference in New Issue
Block a user