diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 5d1398c71a..d8ff6ec9f3 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -128,6 +128,7 @@ use Alchemy\Phrasea\Twig\JSUniqueID; use Alchemy\Phrasea\Twig\Fit; use Alchemy\Phrasea\Twig\Camelize; use Alchemy\Phrasea\Twig\BytesConverter; +use Alchemy\Phrasea\Twig\PhraseanetExtension; use Alchemy\Phrasea\Utilities\CachedTranslator; use FFMpeg\FFMpegServiceProvider; use Monolog\Logger; @@ -645,6 +646,7 @@ class Application extends SilexApplication $twig->addExtension(new Fit()); $twig->addExtension(new Camelize()); $twig->addExtension(new BytesConverter()); + $twig->addExtension(new PhraseanetExtension($app)); $twig->addFilter('serialize', new \Twig_Filter_Function('serialize')); $twig->addFilter('stristr', new \Twig_Filter_Function('stristr')); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index 9b1025c125..221e656f50 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -207,7 +207,7 @@ class Feed implements ControllerProviderInterface $feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', [ + $datas = $app['twig']->render('prod/results/feeds.html.twig', [ 'feeds' => $feeds, 'feed' => new Aggregate($app['EM'], $feeds), 'page' => $page diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 9c14a2851a..b4c51edad5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -52,8 +52,6 @@ class Query implements ControllerProviderInterface { $query = (string) $request->request->get('qry'); - $mod = $app['settings']->getUserSetting($app['authentication']->getUser(), 'view'); - $json = []; $options = SearchEngineOptions::fromRequest($app, $request); @@ -176,21 +174,10 @@ class Query implements ControllerProviderInterface if ($result->getTotal() === 0) { $template = 'prod/results/help.html.twig'; } else { - if ($mod == 'thumbs') { - $template = 'prod/results/answergrid.html.twig'; - } else { - $template = 'prod/results/answerlist.html.twig'; - } + $template = 'prod/results/records.html.twig'; } - $json['results'] = $app['twig']->render($template, [ - 'results' => $result, - 'highlight' => $result->getQuery(), - 'searchEngine' => $app['phraseanet.SE'], - 'searchOptions' => $options, - 'suggestions' => $prop - ] - ); + $json['results'] = $app['twig']->render($template, ['results'=> $result]); $json['query'] = $query; diff --git a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php index b8308bd431..b77269543a 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php +++ b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Media; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\SearchEngine\Elastic\ElasticSearchEngine; use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Specification\SpecificationInterface; use MediaVorus\MediaVorus; @@ -72,6 +73,10 @@ class SubdefGenerator } $record->clearSubdefCache($subdefname); + + if ($this->app['phraseanet.SE'] instanceof ElasticSearchEngine && in_array($subdefname, ['thumbnail', 'thumbnailgif', 'preview'])) { + $this->app['phraseanet.SE']->updateRecord($record); + } } return $this; diff --git a/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php new file mode 100644 index 0000000000..e649546204 --- /dev/null +++ b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php @@ -0,0 +1,288 @@ +getDataboxId(), $this->getRecordId()); + } + + /** {@inheritdoc} */ + public function getBaseId() + { + return $this->baseId; + } + + /** {@inheritdoc} */ + public function setBaseId($baseId) + { + $this->baseId = $baseId; + } + + /** {@inheritdoc} */ + public function getCollectionId() + { + return $this->collectionId; + } + + /** {@inheritdoc} */ + public function setCollectionId($collectionId) + { + $this->collectionId = $collectionId; + } + + /** {@inheritdoc} */ + public function getCreated() + { + return $this->created; + } + + /** {@inheritdoc} */ + public function setCreated(\DateTime $created = null) + { + $this->created = $created; + } + + /** {@inheritdoc} */ + public function getDataboxId() + { + return $this->databoxId; + } + + /** {@inheritdoc} */ + public function setDataboxId($databoxId) + { + $this->databoxId = $databoxId; + } + + /** {@inheritdoc} */ + public function isStory() + { + return $this->isStory; + } + + /** {@inheritdoc} */ + public function setIsStory($isStory) + { + $this->isStory = (bool) $isStory; + } + + /** {@inheritdoc} */ + public function getMimeType() + { + return $this->mimeType; + } + + /** {@inheritdoc} */ + public function setMimeType($mimeType) + { + if (null === $mimeType || '' === $mimeType) { + $mimeType = 'application/octet-stream'; + } + $this->mimeType = $mimeType; + } + + /** {@inheritdoc} */ + public function getOriginalName() + { + return $this->originalName; + } + + /** {@inheritdoc} */ + public function setOriginalName($originalName) + { + $this->originalName = $originalName; + } + + /** {@inheritdoc} */ + public function getRecordId() + { + return $this->recordId; + } + + /** {@inheritdoc} */ + public function setRecordId($recordId) + { + $this->recordId = $recordId; + } + + /** {@inheritdoc} */ + public function getSha256() + { + return $this->sha256; + } + + /** {@inheritdoc} */ + public function setSha256($sha256) + { + $this->sha256 = $sha256; + } + + /** + * @param string|null $locale + * + * @return string + */ + public function getTitle($locale = null) + { + if ($locale && $this->title->containsKey($locale)) { + return $this->title->get($locale); + } + + if ($this->title->containsKey('default')) { + return $this->title->get('default'); + } + + return $this->getOriginalName(); + } + + /** + * Sets a collection of titles + * + * @param ArrayCollection $titles + */ + public function setTitles(ArrayCollection $titles) + { + $this->title = $titles; + } + + /** + * Available types are ['document', 'audio', 'video', 'image', 'flash', 'map', 'unknown'] + */ + public function getType() + { + return $this->type; + } + + public function setType($type) + { + $this->type = $type; + } + + /** @return \DateTime */ + public function getUpdated() + { + return $this->updated; + } + + public function setUpdated(\DateTime $updated = null) + { + $this->updated = $updated; + } + + public function getUuid() + { + return $this->uuid; + } + + public function setUuid($uuid) + { + $this->uuid = $uuid; + } + + /** @return ArrayCollection */ + public function getCaption() + { + return $this->caption; + } + + public function setCaption(ArrayCollection $caption) + { + $this->caption = $caption; + } + + /** @return ArrayCollection */ + public function getExif() + { + return $this->exif; + } + + /** + * @param mixed $exif + */ + public function setExif(ArrayCollection $exif) + { + $this->exif = $exif; + } + + /** @return ArrayCollection */ + public function getSubdefs() + { + return $this->subdefs; + } + + /** @return ArrayCollection */ + public function setSubdefs(ArrayCollection $subdefs) + { + $this->subdefs = $subdefs; + } + + public function setStatus($status) + { + $this->status = $status; + } + + /** + * Get status of current current as 32 bits binary string + * + * Eg: 00000000001011100000000000011111 + */ + public function getStatus() + { + return $this->status; + } + + /** + * Returns the position of the record in the result set + */ + public function getPosition() + { + return $this->position; + } + + public function setPosition($position) + { + $this->position = $position; + } +} diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedItem.php b/lib/Alchemy/Phrasea/Model/Entities/FeedItem.php index 014e394363..054622a7c4 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedItem.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedItem.php @@ -216,7 +216,7 @@ class FeedItem */ public function setLastInFeedItem() { - $this->setOrd($this->getEntry()->getItems()->count() + 1); + $this->setOrd($this->getEntry()->getItems()->count()); } /** diff --git a/lib/Alchemy/Phrasea/Model/MutableRecordInterface.php b/lib/Alchemy/Phrasea/Model/MutableRecordInterface.php new file mode 100644 index 0000000000..6c6ed8d30f --- /dev/null +++ b/lib/Alchemy/Phrasea/Model/MutableRecordInterface.php @@ -0,0 +1,45 @@ +app, $databoxId, $recordId, $n++); + $results[] = ElasticsearchRecordHydrator::hydrate($hit['_source'], $n++); } $query['_ast'] = $searchQuery->dump(); @@ -446,7 +444,6 @@ class ElasticSearchEngine implements SearchEngineInterface 'index' => $this->indexName, 'type' => RecordIndexer::TYPE_NAME, 'body' => [ - 'fields' => ['databox_id', 'record_id'], 'sort' => $this->createSortQueryParams($options), ] ]; diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php new file mode 100644 index 0000000000..ea75f32a71 --- /dev/null +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php @@ -0,0 +1,47 @@ +setPosition($position); + $record->setBaseId(igorw\get_in($data, ['base_id'], 0)); + $record->setCollectionId(igorw\get_in($data, ['collection_id'], 0)); + $createdOn = igorw\get_in($data, ['created_on']); + $record->setCreated($createdOn ? new \DateTime($createdOn) : $createdOn); + $record->setDataboxId(igorw\get_in($data, ['databox_id'], 0)); + $record->setIsStory(igorw\get_in($data, ['type']) === 'story'); + $record->setMimeType(igorw\get_in($data, ['mime'], 'application/octet-stream')); + $record->setOriginalName(igorw\get_in($data, ['original_name'], '')); + $record->setRecordId(igorw\get_in($data, ['record_id'], 0)); + $record->setSha256(igorw\get_in($data, ['sha256'], '')); + $record->setType(igorw\get_in($data, ['type'], 'unknown')); + $updatedOn = igorw\get_in($data, ['updated_on']); + $record->setUpdated($updatedOn ? new \DateTime($updatedOn) : $updatedOn); + $record->setUuid(igorw\get_in($data, ['uuid'], '')); + $record->setStatus(igorw\get_in($data, ['bin_status'], str_repeat('0', 32))); + $record->setTitles(new ArrayCollection((array) igorw\get_in($data, ['title'], []))); + $record->setCaption(new ArrayCollection((array) igorw\get_in($data, ['caption'], []))); + $record->setExif(new ArrayCollection((array) igorw\get_in($data, ['exif'], []))); + $record->setSubdefs(new ArrayCollection((array) igorw\get_in($data, ['subdefs'], []))); + + return $record; + } +} diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php index 7f73c6f922..105f5f9f2d 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php @@ -158,6 +158,27 @@ class RecordIndexer ->addRawVersion() ; + // Index title + $titleMapping = new Mapping(); + $titleMapping->add('default', 'string')->notAnalyzed()->notIndexed(); + foreach ($this->locales as $locale) { + $titleMapping->add($locale, 'string')->notAnalyzed()->notIndexed(); + } + $mapping->add('title', $titleMapping); + + // Minimal subdefs mapping info for display purpose + $subdefMapping = new Mapping(); + $subdefMapping->add('path', 'string')->notAnalyzed()->notIndexed(); + $subdefMapping->add('height', 'integer')->notIndexed(); + $subdefMapping->add('width', 'integer')->notIndexed(); + + $subdefsMapping = new Mapping(); + $subdefsMapping->add('thumbnail', $subdefMapping); + $subdefsMapping->add('thumbnailgif', $subdefMapping); + $subdefsMapping->add('preview', $subdefMapping); + + $mapping->add('subdefs', $subdefsMapping); + // Caption mapping $captionMapping = new Mapping(); $mapping->add('caption', $captionMapping); @@ -306,15 +327,13 @@ class RecordIndexer private function getFlagsMapping() { $mapping = new Mapping(); - $seen = array(); foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_statusbits() as $bit => $status) { $key = self::normalizeFlagKey($status['labelon']); // We only add to mapping new statuses - if (!in_array($key, $seen)) { + if (!$mapping->has($key)) { $mapping->add($key, 'boolean'); - $seen[] = $key; } } } @@ -337,14 +356,13 @@ class RecordIndexer { $dateFields = $this->elasticSearchEngine->getAvailableDateFields(); $structure = $this->getFieldsStructure(); - $fullStatus = str_pad($record['bin_status'], 32, "0", STR_PAD_LEFT); foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_statusbits() as $bit => $status) { $key = self::normalizeFlagKey($status['labelon']); $position = 31-$bit; - $record['flags'][$key] = isset($fullStatus{$position}) ? (bool) $fullStatus{$position} : null; + $record['flags'][$key] = isset($record['bin_status']{$position}) ? (bool) $record['bin_status']{$position} : null; } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php index a5e3f06f51..2232d65d19 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php @@ -176,6 +176,11 @@ class Mapping return $this; } + public function has($name) + { + return isset($this->fields[$name]); + } + protected function ¤tField() { if (null === $this->current) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/RecordFetcher.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/RecordFetcher.php index 37846a65f8..073658b39b 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/RecordFetcher.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/RecordFetcher.php @@ -55,8 +55,9 @@ class RecordFetcher return false; // End } - // Fetch metadata - $records = $this->addMetadataToRecords($records); + $this->addTitleToRecord($records); + $this->addMetadataToRecords($records); + $this->addSubdefsToRecord($records); // Hydrate records foreach ($records as $key => $record) { @@ -70,8 +71,12 @@ class RecordFetcher { $stmt = $this->statementRecord($record_adapter->get_record_id()); $stmt->execute(); - $record = $stmt->fetchAll(); - $records = $this->addMetadataToRecords($record); + + $records = $stmt->fetchAll(); + $this->addTitleToRecord($records); + $this->addMetadataToRecords($records); + $this->addSubdefsToRecord($records); + foreach ($records as $key => $record) { $records[$key] = $this->hydrate($record); } @@ -90,7 +95,7 @@ class RecordFetcher private function hydrate(array $record) { // Some casting - $record['record_id'] = (int) $record['record_id']; + $record['record_id'] = (int) $record['record_id']; $record['collection_id'] = (int) $record['collection_id']; // Some identifiers $record['id'] = $this->helper->getUniqueRecordId($this->databoxId, $record['record_id']); @@ -103,6 +108,10 @@ class RecordFetcher $record['record_type'] = SearchEngineInterface::GEM_TYPE_RECORD; } + if (false == $record['mime']) { + $record['mime'] = 'application/octet-stream'; + } + unset($record['parent_record_id']); return $record; @@ -115,7 +124,7 @@ class RecordFetcher SELECT r.record_id , r.coll_id as collection_id , r.uuid - , BIN(r.status) as bin_status + , LPAD(BIN(r.status), 32, "0") as bin_status , r.sha256 -- TODO rename in "hash" , r.originalname as original_name , r.mime @@ -143,7 +152,7 @@ SQL; SELECT r.record_id , r.coll_id as collection_id , r.uuid - , BIN(r.status) as bin_status + , LPAD(BIN(r.status), 32, "0") as bin_status , r.sha256 -- TODO rename in "hash" , r.originalname as original_name , r.mime @@ -179,7 +188,7 @@ SQL; return $this->connection->executeQuery($sql, array($ids, $ids), array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY)); } - private function addMetadataToRecords($records) + private function addMetadataToRecords(&$records) { $statementMetadata = $this->execStatementMetadata(array_keys($records)); @@ -200,14 +209,70 @@ SQL; // Metadata can be multi-valued if (!isset($records[$metadata['record_id']] [$type][$key])) { - $records[$metadata['record_id']] [$type][$key] = $value; + $records[$metadata['record_id']][$type][$key] = $value; } elseif (is_array($records[$metadata['record_id']] [$type][$key])) { - $records[$metadata['record_id']] [$type][$key][] = $value; + $records[$metadata['record_id']][$type][$key][] = $value; } else { - $records[$metadata['record_id']] [$type][$key] = array($records[$metadata['record_id']] [$type][$key], $value); + $records[$metadata['record_id']][$type][$key] = array($records[$metadata['record_id']][$type][$key], $value); } } + } + + private function execStatementTitle($ids) + { + $sql = <<connection->executeQuery($sql, array($ids), array(Connection::PARAM_INT_ARRAY)); + } + + private function addTitleToRecord(&$records) + { + $statementTitle = $this->execStatementTitle(array_keys($records)); + + while ($row = $statementTitle->fetch()) { + $records[$row['record_id']]['title'][$row['locale']] = $row['title']; + } + } + + private function addSubdefsToRecord(&$records) + { + $statementSubdef = $this->execStatementSubdefs(array_keys($records)); + + while ($subdefs = $statementSubdef->fetch()) { + $records[$subdefs['record_id']]['subdefs'][$subdefs['name']] = array( + 'path' => $subdefs['path'], + 'width' => $subdefs['width'], + 'height' => $subdefs['height'], + ); + } + } + + private function execStatementSubdefs($ids) + { + $sql = <<connection->executeQuery($sql, array($ids), array(Connection::PARAM_INT_ARRAY)); - return $records; } } diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php new file mode 100644 index 0000000000..0624d7d3c2 --- /dev/null +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -0,0 +1,188 @@ +app = $app; + } + + public function getFilters() + { + return array( + ); + } + + public function getFunctions() + { + return array( + new \Twig_SimpleFunction('user_setting', array($this, 'getUserSetting')), + new \Twig_SimpleFunction('record_thumbnail_url', array($this, 'getThumbnailUrl')), + new \Twig_SimpleFunction('record_doctype_icon', array($this, 'getDoctypeIcon'), array( + 'is_safe' => array('html') + )), + new \Twig_SimpleFunction('has_access_subdef', array($this, 'hasAccessSubDefinition')), + new \Twig_SimpleFunction('record_thumbnailgif_url', array($this, 'getThumbnailGifUrl')), + new \Twig_SimpleFunction('granted_on_collection', array($this, 'isGrantedOnCollection')), + new \Twig_SimpleFunction('granted_on_databox', array($this, 'isGrantedOnDatabox')), + new \Twig_SimpleFunction('collection_logo', array($this, 'getCollectionLogo'), array( + 'is_safe' => array('html') + )), + ); + } + + public function isGrantedOnDatabox($databoxId, $rights) + { + if (false === ($this->app['authentication']->getUser() instanceof User)) { + + return false; + } + + $rights = (array) $rights; + foreach ($rights as $right) { + if (false === $this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_sbas($databoxId, $right)) { + + return false; + } + } + + return true; + } + + public function isGrantedOnCollection($baseId, $rights) + { + if (false === ($this->app['authentication']->getUser() instanceof User)) { + + return false; + } + + $rights = (array) $rights; + foreach ($rights as $right) { + if (false === $this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($baseId, $right)) { + + return false; + } + } + + return true; + } + + public function getCollectionLogo($baseId) + { + if (false === $this->app['filesystem']->exists(sprintf('%s/config/minilogos/%s', $this->app['root.path'], $baseId))) { + return ''; + } + + return sprintf( + '', + \phrasea::bas_labels($baseId, $this->app), + $baseId + ); + } + + public function hasAccessSubDefinition(RecordInterface $record, $subDefinition) + { + if (false === ($this->app['authentication']->getUser() instanceof User)) { + + return false; + } + + return $this->app['acl']->get($this->app['authentication']->getUser())->has_access_to_subdef($record, $subDefinition); + } + + public function getDoctypeIcon(RecordInterface $record) + { + $src = $title = ''; + if ($record->isStory()) { + $src = '/skins/icons/icon_story.gif'; + $title = $this->app['translator']->trans('reportage'); + + return sprintf('', $src, $title); + } + + switch ($record->getType()) { + case 'image': + $src = '/skins/icons/icon_image.gif'; + $title = $this->app['translator']->trans('image'); + break; + case 'document': + $src = '/skins/icons/icon_document.gif'; + $title = $this->app['translator']->trans('document'); + break; + case 'video': + $src = '/skins/icons/icon_video.gif'; + $title = $this->app['translator']->trans('reportage'); + break; + case 'audio': + $src = '/skins/icons/icon_audio.gif'; + $title = $this->app['translator']->trans('audio'); + break; + case 'flash': + $src = '/skins/icons/icon_flash.gif'; + $title = $this->app['translator']->trans('flash'); + break; + } + + return sprintf('', $src, $title); + } + + public function getThumbnailUrl(RecordInterface $record) + { + return $this->getSubdefUrl($record, 'thumbnail'); + } + + public function getThumbnailGifUrl(RecordInterface $record) + { + return $this->getSubdefUrl($record, 'thumbnailgif'); + } + + public function getSubdefUrl(RecordInterface $record, $subdefName) + { + if ($record instanceof ElasticsearchRecord) { + if ($record->getSubdefs()->containsKey($subdefName)) { + $thumbnail = $record->getSubdefs()->get($subdefName); + if (null !== $path = $thumbnail['path']) { + if (is_string($path) && '' !== $path) { + return $this->app['phraseanet.static-file']->getUrl($path); + } + } + } + } elseif ($record instanceof \record_adapter) { + if (null !== $thumbnail = $record->get_subdef($subdefName)) { + if ('' !== $path = $thumbnail->get_pathfile()) { + return $this->app['phraseanet.static-file']->getUrl($path); + } + } + } + + $path = sprintf('/skins/icons/substitution/%s.png', + str_replace('/', '_', $record->getMimeType()) + ); + + return $path; + } + + public function getUserSetting($setting, $default = null) + { + if (false === ($this->app['authentication']->getUser() instanceof User)) { + + return $default; + } + + return $this->app['settings']->getUserSetting($this->app['authentication']->getUser(), $setting, $default); + } + + public function getName() + { + return 'phraseanet'; + } +} diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php index c777f6693c..303a888abb 100644 --- a/lib/classes/ACL.php +++ b/lib/classes/ACL.php @@ -12,6 +12,7 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\User; use Doctrine\DBAL\DBALException; +use Alchemy\Phrasea\Model\RecordInterface; class ACL implements cache_cacheableInterface { @@ -118,24 +119,22 @@ class ACL implements cache_cacheableInterface /** * Check if a hd grant has been received for a record * - * @param record_Interface $record + * @param \record_adapter $record * @return boolean */ - public function has_hd_grant(record_Interface $record) + public function has_hd_grant(RecordInterface $record) { $this->load_hd_grant(); - $key = $record->get_serialize_key(); - - if (array_key_exists($key, $this->_rights_records_document)) { + if (array_key_exists($record->getId(), $this->_rights_records_document)) { return true; } return false; } - public function grant_hd_on(record_adapter $record, User $pusher, $action) + public function grant_hd_on(RecordInterface $record, User $pusher, $action) { $sql = 'REPLACE INTO records_rights (id, usr_id, sbas_id, record_id, document, `case`, pusher_usr_id) @@ -144,8 +143,8 @@ class ACL implements cache_cacheableInterface $params = [ ':usr_id' => $this->user->getId() - , ':sbas_id' => $record->get_sbas_id() - , ':record_id' => $record->get_record_id() + , ':sbas_id' => $record->getDataboxId() + , ':record_id' => $record->getRecordId() , ':case' => $action , ':pusher' => $pusher->getId() ]; @@ -159,7 +158,7 @@ class ACL implements cache_cacheableInterface return $this; } - public function grant_preview_on(record_adapter $record, User $pusher, $action) + public function grant_preview_on(RecordInterface $record, User $pusher, $action) { $sql = 'REPLACE INTO records_rights (id, usr_id, sbas_id, record_id, preview, `case`, pusher_usr_id) @@ -168,8 +167,8 @@ class ACL implements cache_cacheableInterface $params = [ ':usr_id' => $this->user->getId() - , ':sbas_id' => $record->get_sbas_id() - , ':record_id' => $record->get_record_id() + , ':sbas_id' => $record->getDataboxId() + , ':record_id' => $record->getRecordI() , ':case' => $action , ':pusher' => $pusher->getId() ]; @@ -186,49 +185,48 @@ class ACL implements cache_cacheableInterface /** * Check if a hd grant has been received for a record * - * @param record_Interface $record + * @param \record_adapter $record * @return boolean */ - public function has_preview_grant(record_Interface $record) + public function has_preview_grant(RecordInterface $record) { $this->load_hd_grant(); - $key = $record->get_serialize_key(); - - if (array_key_exists($key, $this->_rights_records_preview)) { + if (array_key_exists($record->getId(), $this->_rights_records_preview)) { return true; } return false; } - public function has_access_to_record(\record_adapter $record) + public function has_access_to_record(RecordInterface $record) { - if ($this->has_access_to_base($record->get_base_id()) && $this->has_status_access_to_record($record)) { + if ($this->has_access_to_base($record->getBaseId()) && $this->has_status_access_to_record($record)) { return true; } return $this->has_preview_grant($record) || $this->has_hd_grant($record); } - public function has_status_access_to_record(record_adapter $record) + public function has_status_access_to_record(RecordInterface $record) { - return 0 === ((bindec($record->get_status()) ^ $this->get_mask_xor($record->get_base_id())) & $this->get_mask_and($record->get_base_id())); + return 0 === ((bindec($record->getStatus()) ^ $this->get_mask_xor($record->getBaseId())) & $this->get_mask_and($record->getBaseId())); } - public function has_access_to_subdef(record_Interface $record, $subdef_name) + public function has_access_to_subdef(RecordInterface $record, $subdef_name) { if ($subdef_name == 'thumbnail') { return true; } - if ($record->is_grouping()) { + if ($record->isStory()) { return true; } + $databox = $this->app['phraseanet.appbox']->get_databox($record->getDataboxId()); try { - $subdef_class = $record->get_databox()->get_subdef_structure() - ->get_subdef($record->get_type(), $subdef_name) + $subdef_class = $databox->get_subdef_structure() + ->get_subdef($record->getType(), $subdef_name) ->get_class(); } catch (\Exception $e) { return false; @@ -238,17 +236,17 @@ class ACL implements cache_cacheableInterface if ($subdef_class == databox_subdef::CLASS_THUMBNAIL) { $granted = true; - } elseif ($subdef_class == databox_subdef::CLASS_PREVIEW && $this->has_right_on_base($record->get_base_id(), 'candwnldpreview')) { + } elseif ($subdef_class == databox_subdef::CLASS_PREVIEW && $this->has_right_on_base($record->getBaseId(), 'candwnldpreview')) { $granted = true; } elseif ($subdef_class == databox_subdef::CLASS_PREVIEW && $this->has_preview_grant($record)) { $granted = true; - } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_right_on_base($record->get_base_id(), 'candwnldhd')) { + } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_right_on_base($record->getBaseId(), 'candwnldhd')) { $granted = true; } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_hd_grant($record)) { $granted = true; } - if (false === $granted && $this->app['repo.feed-items']->isRecordInPublicFeed($this->app, $record->get_sbas_id(), $record->get_record_id())) { + if (false === $granted && $this->app['repo.feed-items']->isRecordInPublicFeed($this->app, $record->getDataboxId(), $record->getRecordId())) { $granted = true; } diff --git a/lib/classes/caption/Field/Value.php b/lib/classes/caption/Field/Value.php index 5eea6200ed..8137647df6 100644 --- a/lib/classes/caption/Field/Value.php +++ b/lib/classes/caption/Field/Value.php @@ -290,7 +290,7 @@ class caption_Field_Value implements cache_cacheableInterface return $this; } - public static function create(Application $app, databox_field $databox_field, record_Interface $record, $value, Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null) + public static function create(Application $app, databox_field $databox_field, \record_adapter $record, $value, Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null) { $connbas = $databox_field->get_connection(); diff --git a/lib/classes/caption/field.php b/lib/classes/caption/field.php index e720ca73d2..12fcd542f9 100644 --- a/lib/classes/caption/field.php +++ b/lib/classes/caption/field.php @@ -38,11 +38,11 @@ class caption_field implements cache_cacheableInterface * * @param Application $app * @param databox_field $databox_field - * @param record_Interface $record + * @param record_adapter $record * * @return caption_field */ - public function __construct(Application $app, databox_field $databox_field, record_Interface $record) + public function __construct(Application $app, databox_field $databox_field, \record_adapter $record) { $this->app = $app; $this->record = $record; diff --git a/lib/classes/caption/interface.php b/lib/classes/caption/interface.php index c523b22f54..450e8550c6 100644 --- a/lib/classes/caption/interface.php +++ b/lib/classes/caption/interface.php @@ -16,7 +16,7 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; interface caption_interface { - public function __construct(Application $app, record_Interface $record, databox $databox); + public function __construct(Application $app, \record_adapter $record, databox $databox); public function get_highlight_fields($highlight = '', Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false, SearchEngineOptions $options = null); } diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 9718b399cd..a985fff764 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -38,12 +38,12 @@ class caption_record implements caption_interface, cache_cacheableInterface /** * * @param Application $app - * @param record_Interface $record + * @param record_adapter $record * @param databox $databox * * @return caption_record */ - public function __construct(Application $app, record_Interface $record, databox $databox) + public function __construct(Application $app, \record_adapter $record, databox $databox) { $this->app = $app; $this->sbas_id = $record->get_sbas_id(); diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index e28e82763d..0359862de8 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -655,7 +655,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface return $datas; } - public static function create(Application $app, record_Interface $record, $name, MediaInterface $media) + public static function create(Application $app, \record_adapter $record, $name, MediaInterface $media) { $databox = $record->get_databox(); $connbas = $databox->get_connection(); diff --git a/lib/classes/record/Interface.php b/lib/classes/record/Interface.php deleted file mode 100644 index b88880691a..0000000000 --- a/lib/classes/record/Interface.php +++ /dev/null @@ -1,100 +0,0 @@ -technical_datas) { try { $this->technical_datas = $this->get_data_from_cache(self::CACHE_TECHNICAL_DATAS); @@ -1839,4 +1840,105 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $this; } + + /** {@inheritdoc} */ + public function getBaseId() + { + return $this->get_base_id(); + } + + /** {@inheritdoc} */ + public function getCollectionId() + { + return $this->get_collection()->get_coll_id(); + } + + /** {@inheritdoc} */ + public function getCreated() + { + return $this->get_creation_date(); + } + + /** {@inheritdoc} */ + public function getDataboxId() + { + return $this->get_databox()->get_sbas_id(); + } + + /** {@inheritdoc} */ + public function isStory() + { + return $this->is_grouping(); + } + + /** {@inheritdoc} */ + public function getMimeType() + { + return $this->get_mime(); + } + + /** {@inheritdoc} */ + public function getOriginalName() + { + return $this->get_original_name(); + } + + /** {@inheritdoc} */ + public function setOriginalName($originalName) + { + $this->set_original_name($originalName); + } + + /** {@inheritdoc} */ + public function getRecordId() + { + return $this->get_record_id(); + } + + /** {@inheritdoc} */ + public function getSha256() + { + return $this->get_sha256(); + } + + /** {@inheritdoc} */ + public function getType() + { + return $this->get_type(); + } + + /** {@inheritdoc} */ + public function getUpdated() + { + return $this->get_modification_date(); + } + + /** {@inheritdoc} */ + public function getUuid() + { + return $this->get_uuid(); + } + + /** {@inheritdoc} */ + public function getId() + { + return $this->get_serialize_key(); + } + + public function setStatus($status) + { + $this->set_binary_status($status); + } + + /** {@inheritdoc} */ + public function getStatus() + { + return $this->get_status(); + } + + /** {@inheritdoc} */ + public function getExif() + { + return new ArrayCollection($this->get_technical_infos()); + } } diff --git a/lib/classes/record/preview.php b/lib/classes/record/preview.php index 3ddb20ff19..011f3542ff 100644 --- a/lib/classes/record/preview.php +++ b/lib/classes/record/preview.php @@ -111,8 +111,8 @@ class record_preview extends record_adapter foreach ($results->getResults() as $record) { $number = $pos; $this->original_item = $record; - $sbas_id = $record->get_sbas_id(); - $record_id = $record->get_record_id(); + $sbas_id = $record->getDataboxId(); + $record_id = $record->getRecordId(); break; } break; @@ -270,7 +270,7 @@ class record_preview extends record_adapter * * @return String */ - public function get_title($highlight = '', SearchEngineInterface $search_engine = null) + public function get_title($highlight = false, SearchEngineInterface $searchEngine = null, $removeExtension = null, SearchEngineOptions $options = null) { if ($this->title) { return $this->title; @@ -282,10 +282,10 @@ class record_preview extends record_adapter case "RESULT": $this->title .= $this->app->trans('preview:: resultat numero %number%', ['%number%' => '' . ($this->number + 1) . ' : ']); - $this->title .= parent::get_title($highlight, $search_engine); + $this->title .= parent::get_title($highlight, $searchEngine); break; case "BASK": - $this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine) + $this->title .= $this->name . ' - ' . parent::get_title($highlight, $searchEngine) . ' (' . $this->get_number() . '/' . $this->total . ') '; break; case "REG": @@ -299,7 +299,7 @@ class record_preview extends record_adapter } break; default: - $this->title .= parent::get_title($highlight, $search_engine); + $this->title .= parent::get_title($highlight, $searchEngine); break; } diff --git a/lib/classes/set/abstract.php b/lib/classes/set/abstract.php index cb1ba7e8fc..58cdf24dc9 100644 --- a/lib/classes/set/abstract.php +++ b/lib/classes/set/abstract.php @@ -139,10 +139,10 @@ abstract class set_abstract implements IteratorAggregate /** * - * @param record_Interface $record + * @param record_adapter $record * @return set */ - public function add_element(record_Interface $record) + public function add_element(\record_adapter $record) { $this->elements[$record->get_serialize_key()] = $record; @@ -151,10 +151,10 @@ abstract class set_abstract implements IteratorAggregate /** * - * @param record_Interface $record + * @param record_adapter $record * @return set */ - public function remove_element(record_Interface $record) + public function remove_element(\record_adapter $record) { $key = $record->get_serialize_key(); if (isset($this->elements[$key])) diff --git a/templates/mobile/lightbox/feed.html.twig b/templates/mobile/lightbox/feed.html.twig index 0aca4f732c..7c41cdf8ce 100644 --- a/templates/mobile/lightbox/feed.html.twig +++ b/templates/mobile/lightbox/feed.html.twig @@ -29,7 +29,7 @@ {% for item in feed_entry.getItems() %}
  • - {{thumbnail.format(item.getRecord(app).get_thumbnail(), 80, 80, '', true, false)}} + {{ thumbnail.format(item.getRecord(app).get_thumbnail(), 80, 80, '', true, false) }}
  • diff --git a/templates/web/common/doctype_icons.html.twig b/templates/web/common/doctype_icons.html.twig deleted file mode 100644 index 8136b910f1..0000000000 --- a/templates/web/common/doctype_icons.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{% macro format(record)%} - {% set doctype = record.get_type() %} - {% if record.is_grouping() %} - - {% elseif doctype == 'image' %} - - {% elseif doctype == 'document' %} - - {% elseif doctype == 'flash' %} - - {% elseif doctype == 'video' %} - - {% elseif doctype == 'audio' %} - - {% endif %} -{% endmacro %} \ No newline at end of file diff --git a/templates/web/common/drop_down_options.html.twig b/templates/web/common/drop_down_options.html.twig deleted file mode 100644 index 1b7fdec14a..0000000000 --- a/templates/web/common/drop_down_options.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{% macro prod(record, entry_id)%} - {% if not entry_id %} - - - - - - - - - {% endif %} -{% endmacro %} diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig index a931c1a4ec..8ca21a3577 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macros.html.twig @@ -4,7 +4,7 @@ theme : 'custom', custom_theme_widget: 'recaptcha_widget', lang : '{{ app['locale'] }}' - }; + };
    @@ -46,7 +46,7 @@ -
    + @@ -54,9 +54,9 @@ {% set public_key = app["conf"].get(['registry', 'webservices', 'recaptcha-public-key']) %} {% endmacro %} @@ -115,3 +115,21 @@ {% include 'common/technical_datas.html.twig' %} {% endif %} {% endmacro %} + +{% macro caption(record, business, technical) %} + {# @todo handle business fields #} + {% for name, value in record.caption %} +
    + {{ name }} : + {% if value is iterable %} + {{ value | join(' ; ') }} + {% else %} + {{ value }} + {% endif %} +
    + {% endfor %} + {% if technical|default(true) and app['authentication'].user is not none and user_setting('technical_display') == 'group' %} +
    + {% include 'common/technical_datas.html.twig' %} + {% endif %} +{% endmacro %} diff --git a/templates/web/common/technical_datas.html.twig b/templates/web/common/technical_datas.html.twig index e1c0b630a6..64b9de9412 100644 --- a/templates/web/common/technical_datas.html.twig +++ b/templates/web/common/technical_datas.html.twig @@ -1,160 +1,145 @@ -{% if record.is_grouping() %} - {{ 'Story_id' | trans }} : {{ record.get_record_id() }}
    +{% if record.story %} + {{ 'Story_id' | trans }} : {{ record.recordId }}
    {% else %} - {{ 'Record_id' | trans }} : {{ record.get_record_id() }}
    + {{ 'Record_id' | trans }} : {{ record.recordId }}
    {% endif %} -{% if record.is_grouping() == false %} +{% if not record.story %} + {% block td_original_name %} + {{ 'Nom Original' | trans }} : {{ record.originalName }} + {% endblock %} - {% set document = record.get_subdef('document') %} + {% block td_mime %} + {{ record.mimeType }} + {% endblock %} -{% block td_original_name %} - {{ 'Nom Original' | trans }} : - {{ record.get_original_name() }} -{% endblock %} + {% block td_weight %} + {# @todo we should index document weight as well #} + {% endblock %}
    -{% block td_mime %} - {{ record.get_mime() }} -{% endblock %} - -{% block td_weight %} - {% if document and document.get_size() %} - - {{document.get_size()| formatOctets}} - {% endif %} -{% endblock %} -
    - -{% block td_size %} - {% if document and document.get_width() and document.get_height() %} - {{ 'Size' | trans }} : - {{document.get_width()}} x {{document.get_height()}} px -
    - {% if record.get_type() == 'image' and document.get_width() and document.get_height() %} - {% set size_w = (document.get_width() * (254/100) / 300) %} - {% set size_h = (document.get_height() * (254/100) / 300) %} - {{ size_w|round(1) }} x {{ size_h|round(1) }} cm (300dpi) - {% set size_w = (document.get_width() * (254/100) / 72) %}
    - {% set size_h = (document.get_height() * (254/100) / 72) %} - {{ size_w|round(1) }} x {{ size_h|round(1) }} cm (72dpi) + {% block td_size %} + {% set width = record.exif.get(constant('media_subdef::TC_DATA_WIDTH')) %} + {% set height = record.exif.get(constant('media_subdef::TC_DATA_HEIGHT')) %} + {% if width is not none and height is not none %} + {{ width ~ " x " ~ height }} {% endif %} - {% endif %} -{% endblock %} -
    -{% block td_camera_model %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_CAMERAMODEL')) is not empty %} - {{ 'Camera Model' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_CAMERAMODEL')) }} -
    - {% endif %} -{% endblock %} -{% block td_color_space %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_COLORSPACE')) is not empty %} - {{ 'Color space' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_COLORSPACE')) }} -
    - {% endif %} -{% endblock %} -{% block td_channels %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_CHANNELS')) is not empty %} - {{ 'Channels' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_CHANNELS')) }} -
    - {% endif %} -{% endblock %} -{% block td_color_depth %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_COLORDEPTH')) is not empty %} - {{ 'Color Depth' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_COLORDEPTH')) }} bits -
    - {% endif %} -{% endblock %} -{% block td_iso_sensibility %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_ISO')) is not empty %} - {{ 'ISO sensibility' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_ISO')) }} -
    - {% endif %} -{% endblock %} -{% block td_flash %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_FLASHFIRED')) is not empty %} - {{ 'Flash' | trans }} : - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_FLASHFIRED')) %} - {{ 'yes' | trans }} - {% else %} - {{ 'no' | trans }} - {% endif %} -
    - {% endif %} -{% endblock %} -{% block td_shutter_speed %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_SHUTTERSPEED')) is not empty %} - {{ 'Shutter speed' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_SHUTTERSPEED')) }} s. -
    - {% endif %} -{% endblock %} -{% block td_apeture %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_APERTURE')) is not empty %} - {{ 'Aperture' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_APERTURE')) | round(2) }} -
    - {% endif %} -{% endblock %} -{% block td_focal_length %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_FOCALLENGTH')) is not empty %} - {{ 'Focal length' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_FOCALLENGTH')) }} mm -
    - {% endif %} -{% endblock %} -{% block td_hyperfocal_distance %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) is not empty %} - {{ 'Hyperfocal distance' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) | round(2) }} mm -
    - {% endif %} -{% endblock %} -{% block td_light_value %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_LIGHTVALUE')) is not empty %} - {{ 'Light Value' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_LIGHTVALUE')) | round(2) }} -
    - {% endif %} -{% endblock %} -{% block td_duration %} - {% if record.get_formated_duration() %} - {{ 'Duree' | trans }} : - {{ record.get_formated_duration() }} -
    - {% endif %} -{% endblock %} -{% block td_framerate %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_FRAMERATE')) is not empty %} - {{ 'Images par secondes' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_FRAMERATE')) | round(2) }} ips -
    - {% endif %} -{% endblock %} -{% block td_codec_audio %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) %} - {{ 'Codec Audio' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) }} -
    - {% endif %} -{% endblock %} -{% block td_codec_video %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOCODEC')) %} - {{ 'Codec Video' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOCODEC')) }} -
    - {% endif %} -{% endblock %} -{% block td_audio_rate %} - {% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) %} - {{ 'Frequence d\'echantillonage' | trans }} : - {{ record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) | round(2) }} kHz -
    - {% endif %} -{% endblock %} + {% endblock %} +
    + {% block td_camera_model %} + {% if record.exif.get(constant('media_subdef::TC_DATA_CAMERAMODEL')) is not none %} + {{ 'Camera Model' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_CAMERAMODEL')) }} +
    + {% endif %} + {% endblock %} + {% block td_color_space %} + {% if record.exif.get(constant('media_subdef::TC_DATA_COLORSPACE')) is not none %} + {{ 'Color space' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_COLORSPACE')) }} +
    + {% endif %} + {% endblock %} + {% block td_channels %} + {% if record.exif.get(constant('media_subdef::TC_DATA_CHANNELS')) is not none %} + {{ 'Channels' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_CHANNELS')) }} +
    + {% endif %} + {% endblock %} + {% block td_color_depth %} + {% if record.exif.get(constant('media_subdef::TC_DATA_COLORDEPTH')) is not none %} + {{ 'Color Depth' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_COLORDEPTH')) }} bits +
    + {% endif %} + {% endblock %} + {% block td_iso_sensibility %} + {% if record.exif.get(constant('media_subdef::TC_DATA_ISO')) is not none %} + {{ 'ISO sensibility' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_ISO')) }} +
    + {% endif %} + {% endblock %} + {% block td_flash %} + {% if record.exif.get(constant('media_subdef::TC_DATA_FLASHFIRED')) is not none %} + {{ 'Flash' | trans }} : + {% if record.exif.get(constant('media_subdef::TC_DATA_FLASHFIRED')) %} + {{ 'yes' | trans }} + {% else %} + {{ 'no' | trans }} + {% endif %} +
    + {% endif %} + {% endblock %} + {% block td_shutter_speed %} + {% if record.exif.get(constant('media_subdef::TC_DATA_SHUTTERSPEED')) is not none %} + {{ 'Shutter speed' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_SHUTTERSPEED')) }} s. +
    + {% endif %} + {% endblock %} + {% block td_apeture %} + {% if record.exif.get(constant('media_subdef::TC_DATA_APERTURE')) is not none %} + {{ 'Aperture' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_APERTURE')) | round(2) }} +
    + {% endif %} + {% endblock %} + {% block td_focal_length %} + {% if record.exif.get(constant('media_subdef::TC_DATA_FOCALLENGTH')) is not none %} + {{ 'Focal length' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_FOCALLENGTH')) }} mm +
    + {% endif %} + {% endblock %} + {% block td_hyperfocal_distance %} + {% if record.exif.get(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) is not none %} + {{ 'Hyperfocal distance' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) | round(2) }} mm +
    + {% endif %} + {% endblock %} + {% block td_light_value %} + {% if record.exif.get(constant('media_subdef::TC_DATA_LIGHTVALUE')) is not none %} + {{ 'Light Value' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_LIGHTVALUE')) | round(2) }} +
    + {% endif %} + {% endblock %} + {% block td_duration %} + {% if record.exif.get(constant('media_subdef::TC_DATA_DURATION')) is not none %} + {{ 'Duree' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_DURATION')) }} +
    + {% endif %} + {% endblock %} + {% block td_framerate %} + {% if record.exif.get(constant('media_subdef::TC_DATA_FRAMERATE')) is not none %} + {{ 'Images par secondes' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_FRAMERATE')) | round(2) }} ips +
    + {% endif %} + {% endblock %} + {% block td_codec_audio %} + {% if record.exif.get(constant('media_subdef::TC_DATA_AUDIOCODEC')) %} + {{ 'Codec Audio' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_AUDIOCODEC')) }} +
    + {% endif %} + {% endblock %} + {% block td_codec_video %} + {% if record.exif.get(constant('media_subdef::TC_DATA_VIDEOCODEC')) %} + {{ 'Codec Video' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_VIDEOCODEC')) }} +
    + {% endif %} + {% endblock %} + {% block td_audio_rate %} + {% if record.exif.get(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) %} + {{ 'Frequence d\'echantillonage' | trans }} : + {{ record.exif.get(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) | round(2) }} kHz +
    + {% endif %} + {% endblock %} {% endif %} diff --git a/templates/web/common/thumbnail.html.twig b/templates/web/common/thumbnail.html.twig index 6b030d09bb..d5227bf4e7 100644 --- a/templates/web/common/thumbnail.html.twig +++ b/templates/web/common/thumbnail.html.twig @@ -1,65 +1,64 @@ {% macro format(thumbnail, box_w, box_h, extra_class, wrap, lazyload) %} - {% set record_type = thumbnail.get_type() %} - {% set box_w = box_w|round %} - {% set box_h = box_h|default(box_w)|round %} + {# @todo remove lazyload #} - {% if record_type == 'AUDIO_MP3' %} - {% set original_w = 320 %} - {% set original_h = 60 %} + {% set record_type = thumbnail.get_type() %} + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} - {% set fit_size = { - "width":original_w, - "height":original_h, - "top":0, - "left": 0 - } %} - {% elseif record_type == 'FLEXPAPER' %} - {% set original_w = 800 %} - {% set original_h = 600 %} + {% if record_type == 'AUDIO_MP3' %} + {% set original_w = 320 %} + {% set original_h = 60 %} - {% set fit_size = { - "width":800, - "height":600, - "top":0, - "left": 0 - } %} - {% else %} - {% set original_h = thumbnail.get_height() > 0 ? thumbnail.get_height() : 120 %} - {% set original_w = thumbnail.get_width() > 0 ? thumbnail.get_width() : 120 %} + {% set fit_size = { + "width":original_w, + "height":original_h, + "top":0, + "left": 0 + } %} + {% elseif record_type == 'FLEXPAPER' %} + {% set original_w = 800 %} + {% set original_h = 600 %} - {% set fit_size = fitIn( - {"width":original_w, "height":original_h}, - {"width":box_w, "height":box_h} - )%} - {% endif %} + {% set fit_size = { + "width":800, + "height":600, + "top":0, + "left": 0 + } %} + {% else %} + {% set original_h = thumbnail.get_height() > 0 ? thumbnail.get_height() : 120 %} + {% set original_w = thumbnail.get_width() > 0 ? thumbnail.get_width() : 120 %} - {% set url = app['authentication'].isAuthenticated() ? thumbnail.get_url() : thumbnail.get_permalink().get_url() %} + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + )%} + {% endif %} - {% if wrap %} -
    - {% endif %} + {% set url = app['authentication'].isAuthenticated() ? thumbnail.get_url() : thumbnail.get_permalink().get_url() %} - {% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} - {% import 'common/players/video.html.twig' as player %} - {{ player.video_player(thumbnail, url, original_w, original_h, fit_size) }} - {% elseif record_type == 'FLEXPAPER' %} - {% import 'common/players/pdf.html.twig' as player %} - {{ player.pdf_player(thumbnail, url, original_w, original_h, fit_size) }} - {% elseif record_type == 'AUDIO_MP3' %} - {% import 'common/players/audio.html.twig' as player %} - {{ player.audio_player(thumbnail, url, original_w, original_h, fit_size) }} - {% else %} - - - - {% endif %} + {% if wrap %} +
    + {% endif %} - {% if wrap %} + {% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} + {% import 'common/players/video.html.twig' as player %} + {{ player.video_player(thumbnail, url, original_w, original_h, fit_size) }} + {% elseif record_type == 'FLEXPAPER' %} + {% import 'common/players/pdf.html.twig' as player %} + {{ player.pdf_player(thumbnail, url, original_w, original_h, fit_size) }} + {% elseif record_type == 'AUDIO_MP3' %} + {% import 'common/players/audio.html.twig' as player %} + {{ player.audio_player(thumbnail, url, original_w, original_h, fit_size) }} + {% else %} + + + + {% endif %} + + {% if wrap %}
    - {% endif %} -{% endmacro %} + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/templates/web/prod/feeds/entry.html.twig b/templates/web/prod/feeds/entry.html.twig deleted file mode 100644 index 699d111ebd..0000000000 --- a/templates/web/prod/feeds/entry.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{% import 'prod/feeds/entry_macro.html.twig' as _entry %} -{{ _entry.format(entry.getFeed(), entry) }} \ No newline at end of file diff --git a/templates/web/prod/feeds/entry_macro.html.twig b/templates/web/prod/feeds/entry_macro.html.twig deleted file mode 100644 index 2edf5ce097..0000000000 --- a/templates/web/prod/feeds/entry_macro.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{% macro format(feed, entry)%} - {% import 'prod/results/record.html.twig' as record_format %} - -
    - - - - - -
    -

    - {% if feed.isAggregated() %} - - {% endif %} - {{ entry.getTitle() }} - {% set author = entry.getAuthorName() %} - {% trans with {'%author%' : author} %}Par %author%{% endtrans %} -

    -
    - {% if entry.getFeed().isOwner(app['authentication'].getUser()) or entry.isPublisher(app['authentication'].getUser()) %} - - - - - - - {% endif %} -
    - -

    {{ entry.getSubtitle()|nl2br|raw }}

    -
    - {% for item in entry.getItems() %} - {% set record = item.getRecord(app) %} - {% set prefix = 'PUBLI_' ~ item.getId() %} - {{record_format.block(record, false, null, prefix, entry.getId())}} - {% endfor %} -
    -
    -{% endmacro %} diff --git a/templates/web/prod/feeds/feeds.html.twig b/templates/web/prod/feeds/feeds.html.twig deleted file mode 100644 index f192ce1c66..0000000000 --- a/templates/web/prod/feeds/feeds.html.twig +++ /dev/null @@ -1,84 +0,0 @@ -{% import 'prod/feeds/entry_macro.html.twig' as _entry %} -
    - {% if page == 1 %} -
    - - - - - -
    -

    - - {% if feed.isAggregated %} - {{ 'Toutes les publications' | trans }} - - - - {% else %} - {{ feed.getTitle() }} - - - - {% endif %} - {% if feed.isAggregated %} - - {% else %} - - {% endif %} -

    -
    - -
    -
    - {% endif %} - - {% set offset_start = ((page - 1) * 5 )%} - {% set entries = feed.getEntries(offset_start,5) %} - - {% for entry in entries %} - {{ _entry.format(feed, entry) }} - {% endfor %} - {% if entries|length == 0 %} -

    {{ 'Aucune entree pour le moment' | trans }}

    - {% endif %} - - {% if feed.getCountTotalEntries() > (page*5) %} - {% set next_page = page + 1 %} - - {% endif %} -
    diff --git a/templates/web/prod/preview/basket_train.html.twig b/templates/web/prod/preview/basket_train.html.twig index 0d9a3a46b0..3741fa220f 100644 --- a/templates/web/prod/preview/basket_train.html.twig +++ b/templates/web/prod/preview/basket_train.html.twig @@ -1,35 +1,48 @@
      - {% for child in record.get_container().getElements() %} + {% set basket = record.get_container %} + {% for element in basket.elements %} - {% set thumbnail = child.getRecord(app).get_thumbnail() %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% if thumbnail.get_width() > 0 and thumbnail.get_height() > 0 %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% else %} - {% set top = 65 %} + {% set record_item = element.record(app) %} + + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} + + {% set thumbnail = record_item.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} {% endif %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} - {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : child.getRecord(app).get_sbas_id(), 'record_id' : child.getRecord(app).get_record_id(), 'context' : 'basket' }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if record.get_number() == child.getOrd() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • + +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/caption.html.twig b/templates/web/prod/preview/caption.html.twig index 15933d9f2b..4cd602fc7c 100644 --- a/templates/web/prod/preview/caption.html.twig +++ b/templates/web/prod/preview/caption.html.twig @@ -15,5 +15,5 @@ {% if record.is_from_reg() %} {{macro.format_caption(record, '', null, null, business, false, true)}} {% else %} - {{macro.format_caption(record, highlight, searchEngine, business, false, true)}} + {{macro.format_caption(record, null, null, business, false, true)}} {% endif %} diff --git a/templates/web/prod/preview/feed_train.html.twig b/templates/web/prod/preview/feed_train.html.twig index d6535074e9..0aeb0c4624 100644 --- a/templates/web/prod/preview/feed_train.html.twig +++ b/templates/web/prod/preview/feed_train.html.twig @@ -1,35 +1,46 @@
      - {% for child in record.get_container() %} + {% set entry = record.get_container() %} + {% for item in entry.items %} + {% set record_item = item.record(app) %} - {% set thumbnail = child.getRecord(app).get_thumbnail() %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% if thumbnail.get_width() > 0 and thumbnail.get_height() > 0 %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% else %} - {% set top = 65 %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} + + {% set thumbnail = record_item.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} {% endif %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} - {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_preview', { 'sbas_id' : child.get_record().get_sbas_id(), 'record_id' : child.get_record().get_record_id() }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if record.get_number() == child.getOrd() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/reg_train.html.twig b/templates/web/prod/preview/reg_train.html.twig index 6dbb115d0a..7fb00de4b2 100644 --- a/templates/web/prod/preview/reg_train.html.twig +++ b/templates/web/prod/preview/reg_train.html.twig @@ -1,54 +1,79 @@ + {% set story = record.get_container %} - {% set regroupement = record.get_container() %} - {% set thumbnail = regroupement.get_thumbnail() %} + {% set thumb_w = 90 %} + {% set thumb_h = 90 %} - {% if thumbnail.get_height() > 0 %} - {% set ratio = thumbnail.get_width() / thumbnail.get_height() %} - {% else %} - {% set ratio = 1 %} - {% endif %} - {% if thumbnail.is_paysage %} - {% set style = 'width:80px;top:' %} - {% set top = (8 + (80 - (80 / ratio)) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:80px;top:8px;' %} - {% endif %} + {% set thumbnail = story.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} + {% endif %} + + {% set url = record_thumbnail_url(story) %} + + {% set box_w = 90 %} + {% set box_h = 96 %} + + {% set original_h = thumb_h > 0 ? thumb_h : 90 %} + {% set original_w = thumb_w > 0 ? thumb_w : 90 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %}
    - +
    + +
      + {% for record_item in record.get_train %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} - {% for contained in record.get_train %} - {% set thumbnail = contained.get_thumbnail() %} + {% set thumbnail = record_item.get_thumbnail %} - {% if thumbnail.is_paysage %} - {% set style = 'width:65px;top:' %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:8px;' %} - {% endif %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} + {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : contained.get_sbas_id(), 'record_id' : contained.get_record_id(), 'context' : 'preview', 'number' : contained.get_number() }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if loop.index == record.get_number() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/result_train.html.twig b/templates/web/prod/preview/result_train.html.twig index ecead5183c..fc2ad2c1bd 100644 --- a/templates/web/prod/preview/result_train.html.twig +++ b/templates/web/prod/preview/result_train.html.twig @@ -1,30 +1,41 @@
      - {% for rec in records %} + {% for record in records %} - {% set thumbnail = rec.get_thumbnail() %} - {% set w = thumbnail.get_width() %} - {% set h = thumbnail.get_height() %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% set top = ((66 - (65 / (w / h))) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} + {% set thumbnail = record.subdefs.get('thumbnail') %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} {% endif %} - {% if selected == rec.get_number() %} - {% set class = ' selected ' %} - {% else %} - {% set class = '' %} - {% endif %} + {% set url = record_thumbnail_url(record) %} -
    • - - + {% set box_w = 70 %} + {% set box_h = 80 %} + + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %} diff --git a/templates/web/prod/results/answerabstract.html.twig b/templates/web/prod/results/answerabstract.html.twig deleted file mode 100644 index b3b200f95e..0000000000 --- a/templates/web/prod/results/answerabstract.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% import 'prod/results/record.html.twig' as record_format %} - -{% if results.getError() %} -
      {{results.getError()}}
      -{% else %} - {% if results.getWarning() %} -
      {{results.getWarning()}}
      - {% endif %} - - {% if suggestions %} - {% set suggestions = suggestions|e %} - {% set link = '' ~ suggestions ~ '' %} - {% trans with {'%link%' : link} %}Voulez-vous dire %link% ?{% endtrans %} -
      - {% endif %} - {% set th_size = app['settings'].getUserSetting(app['authentication'].getUser(), 'images_size')%} -
      - {% block content %}{% endblock %} -
      -{% endif %} diff --git a/templates/web/prod/results/answergrid.html.twig b/templates/web/prod/results/answergrid.html.twig deleted file mode 100644 index ec14ec78e0..0000000000 --- a/templates/web/prod/results/answergrid.html.twig +++ /dev/null @@ -1,11 +0,0 @@ - -{% extends "prod/results/answerabstract.html.twig" %} - -{% block content %} - - {% for record in results.getResults() %} - {{record_format.block(record, highlight, searchEngine, 'IMGT', false)}} - {% endfor %} - -{% endblock %} - diff --git a/templates/web/prod/results/answerlist.html.twig b/templates/web/prod/results/answerlist.html.twig deleted file mode 100644 index 277b496d97..0000000000 --- a/templates/web/prod/results/answerlist.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "prod/results/answerabstract.html.twig" %} -{% block content %} - -{% import 'common/macros.html.twig' as macro %} - -{% for record in results.getResults() %} -
      - - - - - -
      - {{ record_format.block(record, highlight, searchEngine, 'IMGT', false) }} - -
      -
      - {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %} - {{ macro.format_caption(record, highlight, searchEngine, searchOptions, business, true, true) }} -
      -
      -
      -
      -{% endfor %} - -{% endblock %} - diff --git a/templates/web/prod/results/entry.html.twig b/templates/web/prod/results/entry.html.twig new file mode 100644 index 0000000000..c785c61655 --- /dev/null +++ b/templates/web/prod/results/entry.html.twig @@ -0,0 +1,70 @@ +{% import 'prod/results/macro.html.twig' as result_macro %} + +
      + + + + + +
      +

      + {% if feed.aggregated %} + + {% endif %} + {{ entry.title }} + {% set author = entry.authorName %} + + {% trans with {'%author%' : author} %}Par %author%{% endtrans %} + +

      +
      + {% if entry.feed.isOwner(app['authentication'].user) or entry.isPublisher(app['authentication'].user) %} + + + + + + + {% endif %} +
      + + +

      {{ entry.getSubtitle()|nl2br|raw }}

      + +
      + {% for item in entry.items %} + {% block item %} + {% include 'prod/results/item.html.twig' with { + 'item' : item, + 'entry': entry, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% endfor %} +
      +
      diff --git a/templates/web/prod/results/feeds.html.twig b/templates/web/prod/results/feeds.html.twig new file mode 100644 index 0000000000..fd03064ef6 --- /dev/null +++ b/templates/web/prod/results/feeds.html.twig @@ -0,0 +1,97 @@ +{% block result %} +
      + {# header for first page #} + {% if page == 1 %} +
      + + + + + +
      +

      + + {% if feed.isAggregated %} + {{ 'Toutes les publications' | trans }} + + + + + {% else %} + {{ feed.title }} + + + + + {% endif %} +

      +
      + +
      +
      + {% endif %} + + {% block content %} + {% set images_size = user_setting('images_size') %} + {% set technical_display = user_setting('technical_display') %} + {% set rollover_thumbnail = user_setting('rollover_thumbnail') %} + {% set doctype_display = user_setting('doctype_display') %} + + {% set offset_start = ((page - 1) * 5 )%} + {% set entries = feed.getEntries(offset_start,5) %} + + {% for entry in entries %} + {% block content_item %} + {% include 'prod/results/entry.html.twig' with { + 'feed': feed, + 'entry': entry, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% else %} +

      {{ 'Aucune entree pour le moment' | trans }}

      + {% endfor %} + + {# pagination #} + {% if feed.countTotalEntries > (page * 5) %} + {% set next_page = page + 1 %} + + {% endif %} + {% endblock %} +
      +{% endblock %} diff --git a/templates/web/prod/results/grid.html.twig b/templates/web/prod/results/grid.html.twig new file mode 100644 index 0000000000..e797c96481 --- /dev/null +++ b/templates/web/prod/results/grid.html.twig @@ -0,0 +1,4 @@ +{% include 'prod/results/record.html.twig' with { + 'record': record, + 'settings': settings +} %} diff --git a/templates/web/prod/results/help.html.twig b/templates/web/prod/results/help.html.twig index c6e8bcd4fe..0d996489ec 100644 --- a/templates/web/prod/results/help.html.twig +++ b/templates/web/prod/results/help.html.twig @@ -1,85 +1,73 @@ {% block content %} -{% if results.getError() %} -
      {{results.getError()}}
      -{% else %} - {% if results.getWarning() %} -
      {{results.getWarning()}}
      - {% endif %} -{% endif %} + {% if results.error %} +
      {{ results.error }}
      + {% elseif results.warning %} +
      {{ results.warning }}
      + {% endif %} -

      - {{ 'Votre recherche ne retourne aucun resultat' | trans }} -

      +

      + {{ 'Votre recherche ne retourne aucun resultat' | trans }} +

      -{% if suggestions %} - {% set link = '' ~ suggestions ~ '' %} - {% trans with {'%link%' : link} %}Voulez-vous dire %link% ?{% endtrans %} -
      -{% endif %} - -{% set th_size = app['settings'].getUserSetting(app['authentication'].getUser(), 'images_size')%} - -{% if app['locale'] == 'fr' %}
      -
      {{ 'La recherche s\'effectue grâce à la boîte de dialogue qui se trouve en haut à gauche de l\'écran.' | trans }} - {{ 'Sachez que vous pouvez utiliser les opérateurs ou caractères spéciaux suivants :' | trans }}
      -
      {{ '* , ? , ET , OU , SAUF , DANS , DERNIERS , TOUT (ou AND , OR , EXCEPT , LAST , ALL)' | trans }}
      +
      {{ 'La recherche s\'effectue grâce à la boîte de dialogue qui se trouve en haut à gauche de l\'écran.' | trans }} + {{ 'Sachez que vous pouvez utiliser les opérateurs ou caractères spéciaux suivants :' | trans }}
      +
      {{ '* , ? , ET , OU , SAUF , DANS , DERNIERS , TOUT (ou AND , OR , EXCEPT , LAST , ALL)' | trans }}
      -
      {{ 'Caractères de troncature' | trans }}
      +
      {{ 'Caractères de troncature' | trans }}
      - - - - - - - - - -
      {{ 'auto*' | trans }} {{ 'retourne "automobile", "automate", "autoroute", ...' | trans }}
      {{ 'dé?it' | trans }} {{ 'retourne "délit", "débit", ...' | trans }}
      + + + + + + + + + +
      {{ 'auto*' | trans }} {{ 'retourne "automobile", "automate", "autoroute", ...' | trans }}
      {{ 'dé?it' | trans }} {{ 'retourne "délit", "débit", ...' | trans }}
      -
      {{ 'Visualiser tous les enregistrements / les derniers enregistrements' | trans }}
      - - - - - - - - - -
      {{ 'TOUT' | trans }}{{ 'retourne tous les enregistrements des collections selectionnees' | trans }}
      {{ 'LAST 20' | trans }}{{ 'retourne les 20 derniers enregistrements archives dans les collections selectionnees' | trans }}
      +
      {{ 'Visualiser tous les enregistrements / les derniers enregistrements' | trans }}
      + + + + + + + + + +
      {{ 'TOUT' | trans }}{{ 'retourne tous les enregistrements des collections selectionnees' | trans }}
      {{ 'LAST 20' | trans }}{{ 'retourne les 20 derniers enregistrements archives dans les collections selectionnees' | trans }}
      -
      {{ 'Recherche multicritères' | trans }}
      - {{ 'Vous pouvez affiner votre recherche avec les opérateurs : ET, OU, SAUF ou DANS' | trans }}
      - - - - - - - - - - - - - - - - - -
      {{ 'sport' | trans }} ET {{ 'automobile' | trans }}{{ 'retourne les documents comprenant les deux mots.' | trans }}
      {{ 'journal OU jt' | trans }}{{ 'retourne les documents comprenant un mot et/ou l\'autre.' | trans }}
      {{ 'cannes SAUF festival' | trans }}{{ 'retourne les documents comprenant cannes sans le mot festival.' | trans }}
      {{ 'thalassa DANS titre' | trans }}{{ 'retourne les documents où le terme est au moins présent dans le titre, en évitant par exemple celles où le terme est uniquement cité dans la légende.' | trans }}
      +
      {{ 'Recherche multicritères' | trans }}
      + {{ 'Vous pouvez affiner votre recherche avec les opérateurs : ET, OU, SAUF ou DANS' | trans }}
      + + + + + + + + + + + + + + + + + +
      {{ 'sport' | trans }} ET {{ 'automobile' | trans }}{{ 'retourne les documents comprenant les deux mots.' | trans }}
      {{ 'journal OU jt' | trans }}{{ 'retourne les documents comprenant un mot et/ou l\'autre.' | trans }}
      {{ 'cannes SAUF festival' | trans }}{{ 'retourne les documents comprenant cannes sans le mot festival.' | trans }}
      {{ 'thalassa DANS titre' | trans }}{{ 'retourne les documents où le terme est au moins présent dans le titre, en évitant par exemple celles où le terme est uniquement cité dans la légende.' | trans }}
      -
      -

      {{ 'Attention' | trans }}

      -

      {{ 'pour chercher une phrase contenant un des mots-clé ci-dessus, utilisez les guillemets :' | trans }}

      - "{{ 'C dans l\'air' | trans }}" - , "{{ 'Et Dieu créa la femme' | trans }}" - , "{{ 'bijou en or' | trans }}" - , "{{ 'tout le sport' | trans }}" -
      +
      +

      {{ 'Attention' | trans }}

      +

      {{ 'pour chercher une phrase contenant un des mots-clé ci-dessus, utilisez les guillemets :' | trans }}

      + "{{ 'C dans l\'air' | trans }}" + , "{{ 'Et Dieu créa la femme' | trans }}" + , "{{ 'bijou en or' | trans }}" + , "{{ 'tout le sport' | trans }}" +
      -{% endif %} {% endblock %} diff --git a/templates/web/prod/results/item.html.twig b/templates/web/prod/results/item.html.twig new file mode 100644 index 0000000000..fc2eb5e5b9 --- /dev/null +++ b/templates/web/prod/results/item.html.twig @@ -0,0 +1,80 @@ +{% import 'common/thumbnail.html.twig' as thumbnail %} + +{% set record = item.record(app) %} + +
      +
      +
      +
      + {{ record.get_title }} +
      +
      + {{ record.get_status_icons|raw }} +
      +
      + + {% set rollover_gif = record.get_rollover_thumbnail %} + + {% if rollover_thumbnail == 'caption' %} + {% set tooltipsrc = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'publi' }) %} + {% elseif rollover_thumbnail == 'preview' %} + {% set tooltipsrc = path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) %} + {% endif %} + +
      +
      + {% if doctype_display %} + {{ record_doctype_icon(record) }} + {% endif %} + + {{ record.get_formated_duration }} + +
      +
      + {% set extraclass = rollover_gif ? 'rollover-gif-out' : '' %} + {{ thumbnail.format(record.get_thumbnail(), images_size, images_size, extraclass, true, false) }} + {% if rollover_gif %} + {{ thumbnail.format(rollover_gif, images_size, images_size, 'rollover-gif-hover', true, false) }} + {% endif %} +
      +
      + +
      + + + + {% set l_width = 30 %} + {% if rollover_thumbnail == 'preview' %} + {% set l_width = l_width + 20 %} + {% endif %} + {% if technical_display == '1' %} + {% set l_width = l_width + 20 %} + {% endif %} + + +
      + {{ record.get_collection_logo(app)|raw }} + + {% if record.has_preview and has_access_subdef(record, 'preview') %} +
      + {% endif %} + {% if rollover_thumbnail == 'preview' %} +
      + {% endif %} + {% if technical_display == '1' %} + + {% endif %} +
      +
      +
      +
      diff --git a/templates/web/prod/results/list.html.twig b/templates/web/prod/results/list.html.twig new file mode 100644 index 0000000000..81525af7d0 --- /dev/null +++ b/templates/web/prod/results/list.html.twig @@ -0,0 +1,24 @@ +{% import 'common/macros.html.twig' as macro %} + +{% block content_item %} +
      + + + + + +
      + {% include 'prod/results/record.html.twig' with { + 'record': record, + 'settings': settings + } %} + +
      +
      + {% set business = granted_on_collection(record.baseId, 'canmodifrecord') %} + {{ macro.caption(record, business) }} +
      +
      +
      +
      +{% endblock %} diff --git a/templates/web/prod/results/macro.html.twig b/templates/web/prod/results/macro.html.twig new file mode 100644 index 0000000000..63fa7cc7a0 --- /dev/null +++ b/templates/web/prod/results/macro.html.twig @@ -0,0 +1,69 @@ +{% macro thumbnail(record, box_w, box_h, extra_class) %} + {% set record_type = record.type %} + + {% set thumb_w = 256 %} + {% set thumb_h = 256 %} + + {% set thumbnail = record.subdefs.get('thumbnail') %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} + {% endif %} + + {% set url = record_thumbnail_url(record) %} + + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} + + {% set original_h = thumb_h > 0 ? thumb_h : 120 %} + {% set original_w = thumb_w > 0 ? thumb_w : 120 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
      + + + +
      +{% endmacro %} + +{% macro thumbnailgif(record, box_w, box_h, extra_class) %} + {% set record_type = record.type %} + + {% set thumb_w = 256 %} + {% set thumb_h = 256 %} + + {% set thumbnail = record.subdefs.get('thumbnailgif') %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} + {% endif %} + + {% set url = record_thumbnailgif_url(record) %} + + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} + + {% set original_h = thumb_h > 0 ? thumb_h : 120 %} + {% set original_w = thumb_w > 0 ? thumb_w : 120 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
      + + + +
      +{% endmacro %} \ No newline at end of file diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig index 5c514e8e92..5bece1fabc 100644 --- a/templates/web/prod/results/record.html.twig +++ b/templates/web/prod/results/record.html.twig @@ -1,105 +1,131 @@ -{% macro block(record, highlight, searchEngine, prefix, entry_id) %} - {% import 'common/thumbnail.html.twig' as thumbnail %} - {% import 'common/doctype_icons.html.twig' as doctype_icons %} - {% import 'common/drop_down_options.html.twig' as drop_down %} - {% set th_size = app['settings'].getUserSetting(app['authentication'].getUser(), 'images_size') %} - {% set sbas_id = record.get_sbas_id %} - {% set lazyload = app['phraseanet.configuration']['lazyload']|default(false) %} - {% set container_attributes %} - {% if entry_id %} - class="IMGT diapo type-{{ record.get_type }}" - onDblClick="openPreview('FEED',{{ record.get_number() }},{{ entry_id }});" - {% elseif record.is_grouping() %} - class="IMGT diapo grouping type-{{ record.get_type }}" - onDblClick="openPreview('REG','0','{{ record.get_serialize_key() }}');" - {% else %} - class="IMGT diapo type-{{ record.get_type }}" - onDblClick="openPreview('RESULT',{{ record.get_number }});" - {% endif %} - {% endset %} +{% import 'prod/results/macro.html.twig' as result_macro %} -
      -
      -
      -
      - {{ record.get_title() }} -
      -
      - {{ record.get_status_icons|raw }} -
      -
      - - {% set rollover_gif = record.get_rollover_thumbnail() %} - {% set user_technical_display = app['settings'].getUserSetting(app['authentication'].getUser(), 'technical_display') %} - {% set user_rollover_thumbnail =app['settings'].getUserSetting(app['authentication'].getUser(), 'rollover_thumbnail') %} - {% set extraclass = '' %} - - {% if user_rollover_thumbnail == 'caption' and searchEngine is not null %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltipsrc = path('prod_tooltip_caption', { 'sbas_id' : record.get_sbas_id(), 'record_id' : record.get_record_id(), 'context' : 'answer', 'number' : record.get_number() }) %} - {% elseif user_rollover_thumbnail == 'caption' and searchEngine is null %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltipsrc = path('prod_tooltip_caption', { 'sbas_id' : record.get_sbas_id(), 'record_id' : record.get_record_id(), 'context' : 'publi' }) %} - {% elseif user_rollover_thumbnail == 'preview' %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltipsrc = path('prod_tooltip_preview', { 'sbas_id' : record.get_sbas_id(), 'record_id' : record.get_record_id() }) %} - {% endif %} - -
      -
      - {% if app['settings'].getUserSetting(app['authentication'].getUser(), 'doctype_display') == '1' %} - {{ doctype_icons.format(record) }} - {% endif %} - - {{ record.get_formated_duration() }} - -
      -
      - {% set extraclass = '' %} - {% if rollover_gif %} - {% set extraclass = 'rollover-gif-out' %} - {% endif %} - {{ thumbnail.format(record.get_thumbnail(), th_size, th_size, extraclass, true, lazyload) }} - {% if rollover_gif %} - {{ thumbnail.format(rollover_gif, th_size, th_size, 'rollover-gif-hover', true, lazyload) }} - {% endif %} -
      -
      - -
      - - - - {% set l_width = 30 %} - {% if user_rollover_thumbnail == 'preview' %} - {% set l_width = l_width + 20 %} - {% endif %} - {% if user_technical_display == '1' %} - {% set l_width = l_width + 20 %} - {% endif %} - - -
      - {{ record.get_collection_logo(app)|raw }} - - {{ drop_down.prod(record, entry_id) }} - {% if record.has_preview() and app['acl'].get(app['authentication'].getUser()).has_access_to_subdef(record, 'preview') %} -
      - {% endif %} - {% if user_rollover_thumbnail == 'preview' %} -
      - {% endif %} - {% if user_technical_display == '1' %} - - {% endif %} -
      -
      +
      +
      +
      + {# @todo title should be localized #} +
      + {{ record.title }} +
      +
      + {# @todo find a proper way to map lifted flag to status icon img path #} + {#{{record.get_status_icons|raw}}#}
      -{% endmacro %} + + {% if settings.rollover_thumbnail == 'caption' %} + {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'answer', 'number' : record.position|default(0) }) %} + {% elseif settings.rollover_thumbnail == 'preview' %} + {% set tooltip = path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) %} + {% endif %} + +
      +
      + {% if settings.doctype_display == '1' %} + {{ record_doctype_icon(record) }} + {% endif %} + + {% if record.type == 'video' and attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION')) is defined %} + {{ attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION')) }} + {% endif %} + +
      + {% set rollover = record.subdefs.containsKey('thumbnailgif') %} + {% set extraclass = '' %} +
      + {% if rollover %} + {% set extraclass = 'rollover-gif-out' %} + {% endif %} + + {{ result_macro.thumbnail(record, settings.images_size, settings.images_size, extraclass) }} + + {% if rollover %} + {% set extraclass = 'rollover-gif-hover' %} + {{ result_macro.thumbnailgif(record, settings.images_size, settings.images_size, extraclass) }} + {% endif %} +
      +
      +
      + + + + + {% set l_width = 30 %} + + {% if settings.rollover_thumbnail == 'preview' %} + {% set l_width = l_width + 20 %} + {% elseif settings.technical_display == '1' %} + {% set l_width = l_width + 20 %} + {% endif %} + + {# drop down options #} + + +
      + {{ collection_logo(record.baseId) }} + + + + + + + + + + + {% if record.subdefs.containsKey('preview') and has_access_subdef(record, 'preview') %} +
      + {% endif %} + + {% if settings.rollover_thumbnail == 'preview' %} +
      + {% endif %} + + {% if settings.technical_display == '1' %} + + {% endif %} +
      +
      +
      +
      diff --git a/templates/web/prod/results/records.html.twig b/templates/web/prod/results/records.html.twig new file mode 100644 index 0000000000..9c024ec387 --- /dev/null +++ b/templates/web/prod/results/records.html.twig @@ -0,0 +1,38 @@ +{% if results.error %} + {% block result_error %} +
      + {{ results.error }} +
      + {% endblock %} +{% else %} + {% if results.warning %} + {% block result_warning %} +
      + {{ results.warning }} +
      + {% endblock %} + {% endif %} + + {% block content %} + {% set images_size = user_setting('images_size') %} + {% set technical_display = user_setting('technical_display') %} + {% set rollover_thumbnail = user_setting('rollover_thumbnail') %} + {% set doctype_display = user_setting('doctype_display') %} + +
      + {% for record in results.results %} + {% block content_item %} + {% include (user_setting('view', 'thumbs') == 'thumbs') ? 'prod/results/grid.html.twig' : 'prod/results/list.html.twig' with { + 'record': record, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% endfor %} +
      + {% endblock %} +{% endif %} diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml index 355ae28797..30230649f8 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml @@ -207,4 +207,4 @@ crossdomain: allow-access-from: - domain: '*.cooliris.com' - secure: 'false' + secure: 'false' \ No newline at end of file diff --git a/www/skins/prod/000000/prodcolor.css b/www/skins/prod/000000/prodcolor.css index 67f7335f8c..5d71da4138 100644 --- a/www/skins/prod/000000/prodcolor.css +++ b/www/skins/prod/000000/prodcolor.css @@ -1,5 +1,31 @@ /******* GLOBAL PROD **********************************************************/ +::-webkit-scrollbar-track +{ + border-radius: 7px; + background-color: #000; +} + +::-webkit-scrollbar { + width: 14px; +} +::-webkit-scrollbar-thumb { + height: 6px; + border: 4px solid rgba(0, 0, 0, 0); + background-clip: padding-box; + -webkit-border-radius: 7px; + background-color: #555; + -webkit-box-shadow: inset -1px -1px 0px rgba(0, 0, 0, 0.05), inset 1px 1px 0px rgba(0, 0, 0, 0.05); +} +::-webkit-scrollbar-button { + width: 0; + height: 0; + display: none; +} +::-webkit-scrollbar-corner { + background-color: transparent; +} + html { border: medium none; height: 100%; @@ -763,7 +789,7 @@ div.diapo { left: 0pt; right: 1px; bottom: 0px; - overflow-y: scroll; + overflow-y: hidden; overflow-x: hidden; background-color: #404040; } diff --git a/www/skins/prod/959595/prodcolor.css b/www/skins/prod/959595/prodcolor.css index 7fff4f9e24..488ef1ec48 100644 --- a/www/skins/prod/959595/prodcolor.css +++ b/www/skins/prod/959595/prodcolor.css @@ -1,5 +1,31 @@ /******* GLOBAL PROD **********************************************************/ +::-webkit-scrollbar-track +{ + border-radius: 7px; + background-color: #d9d9d9; +} + +::-webkit-scrollbar { + width: 14px; +} +::-webkit-scrollbar-thumb { + height: 6px; + border: 4px solid rgba(0, 0, 0, 0); + background-clip: padding-box; + -webkit-border-radius: 7px; + background-color: #555; + -webkit-box-shadow: inset -1px -1px 0px rgba(0, 0, 0, 0.05), inset 1px 1px 0px rgba(0, 0, 0, 0.05); +} +::-webkit-scrollbar-button { + width: 0; + height: 0; + display: none; +} +::-webkit-scrollbar-corner { + background-color: transparent; +} + html { border: medium none; height: 100%; @@ -779,7 +805,7 @@ div.diapo { left: 0pt; right: 1px; bottom: 0px; - overflow-y: scroll; + overflow-y: hidden; overflow-x: hidden; background-color: #B1B1B1; }