diff --git a/library/Class/Notice/Field.php b/library/Class/Notice/Field.php index 1b3f50359ccf7ca41a725856973599b42790d178..c56025d09ad791143c9d8f68bce97942c49edd91 100644 --- a/library/Class/Notice/Field.php +++ b/library/Class/Notice/Field.php @@ -37,6 +37,13 @@ class Class_Notice_Field extends Class_Entity { } + public function getUrlForLink() { + return ($params = $this->getUrlParams()) + ? Class_Url::relative($params) + : $this->getUrl(); + } + + public function addUrlParams($params) { if (!is_array($current_params = $this->getUrlParams())) return $this; diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 6c1e29c8dcc643d746ff1d91a116ee60d1a56db1..9a4328b437cc2bb475db56c135d61f724b3cfd9a 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -66,6 +66,8 @@ div:hover > .img_as_background { color: var(--front-overlay-text); } +.card-link + .card-link, +.badge, i:first-child, p > i { margin-right: 0.5em; @@ -110,10 +112,6 @@ pre { border-right: 5px solid; } -.badge + .badge { - margin-left: 0.5em; -} - [class*="position_fixed"] { position: fixed !important; width: auto; @@ -216,4 +214,12 @@ pre { .card { white-space: pre-line; +} + +.card-text { + margin-top: 1rem; +} + +.card-link + .card-link { + margin-left: 0; } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index b9d0cf4cc481abf80ea9756a524964d73d65c6ac..06ba9bc2a33d9ee327929fe5ddbbe6772f14e48d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -84,13 +84,19 @@ class Intonation_Library_View_Wrapper_Article { } + public function getLinkText() { + return $this->_('Voir l\'article'); + } + + public function getPicture() { return $this->_model->getFirstImageAbsoluteURL(); } public function getDescription() { - return $this->_view->renderArticleBadges($this->_model); + return $this->_view->renderArticleBadges($this->_model) + . $this->_view->truncate($this->_model->getSummary()); } @@ -111,4 +117,9 @@ class Intonation_Library_View_Wrapper_Article { return $this->_('Voir tous les documents de l\'auteur principal "%s"', $this->getAuthor()); } + + + public function getAuthorLink() { + return ''; + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 54676c8a04dfecc269230d55eff34416cf544f60..49e85ad9f71daef970c06e5cf54206dd6a87fabb 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -80,6 +80,11 @@ class Intonation_Library_View_Wrapper_Record { } + public function getLinkText() { + return $this->_('Voir le document'); + } + + public function getPicture() { return $this->_model->getUrlImage(); } @@ -107,4 +112,16 @@ class Intonation_Library_View_Wrapper_Record { return $this->_('Voir tous les documents de l\'auteur principal "%s"', $this->getAuthor()); } + + + public function getAuthorLink() { + if(!$author = $this->getAuthor()) + return ''; + + if (!$facet = Class_CodifAuteur::findWithFullName($author)) + return ''; + + return (new Class_Notice_FieldAuthor($facet)) + ->getUrlParams(); + } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Cardify.php b/library/templates/Intonation/View/Cardify.php index 75d0328bcae3f5523afcbd4e56e257f5f4f56ed2..227671da958c9a83f7c2b282d004431ca4468c77 100644 --- a/library/templates/Intonation/View/Cardify.php +++ b/library/templates/Intonation/View/Cardify.php @@ -51,26 +51,26 @@ class Intonation_View_Cardify extends ZendAfi_View_Helper_BaseHelper { if ($summary = $element->getDescription()) $content [] = $this->_tag('p', $element->getDescription(), - ['title' => $element->getDescriptionTitle(), + ['title' => strip_tags($element->getDescriptionTitle()), 'class' => 'card-text']); $links = [$this->view->tagAnchor($element->getUrl(), - $this->_('Voir le document'), - ['title' => $element->getLinkTitle(), - 'class' => 'card-link'])]; + $element->getLinkText(), + ['title' => $element->getLinkTitle(), + 'class' => 'card-link'])]; - if ($author_name) - $links [] = $this->view->authorAnchor($element->getAuthor(), - [], - ['title' => $element->getAuthorLinkTitle(), - 'class' => 'card-link']); + if ($author_link = $element->getAuthorLink()) + $links [] = $this->view->tagAnchor($author_link, + $this->_('Voir l\'auteur'), + ['title' => $element->getAuthorLinkTitle(), + 'class' => 'card-link']); return $this->_tag('div', implode($content), ['class' => 'card-body']) . $this->_tag('div', - implode($links), - ['class' => 'card-footer']); + implode($links), + ['class' => 'card-footer d-flex flex-column flex-md-row']); } diff --git a/library/templates/Intonation/View/RenderArticleBadges.php b/library/templates/Intonation/View/RenderArticleBadges.php index 6f146ec6107d8b4f0a8db9a43697cdc2043e6b37..c12bd45cbc2ba430fd244c0713edc8bfce5fe6e7 100644 --- a/library/templates/Intonation/View/RenderArticleBadges.php +++ b/library/templates/Intonation/View/RenderArticleBadges.php @@ -79,14 +79,18 @@ class Intonation_View_RenderArticleBadges extends ZendAfi_View_Helper_BaseHelper $time)]; } - if ($tags = $article->getTags()) - foreach(array_filter(explode(';', $tags)) as $tag) - $badges [] = ['tag' => 'spand', + if ($tags = $article->getTags()) { + foreach(array_filter(explode(';', $tags)) as $tag) { + $tag = trim(strip_tags($tag)); + $badges [] = ['tag' => 'span', 'class' => 'dark', - 'text' => trim($tag), + 'text' => $tag, 'title' => $this->_('L\'étiquette "%s" de l\'article "%s".', $tag, $article->getTitre())]; + } + } + $instances = []; foreach($badges as $data) if ($data['text']) diff --git a/library/templates/Intonation/View/Truncate.php b/library/templates/Intonation/View/Truncate.php new file mode 100644 index 0000000000000000000000000000000000000000..029e77fc9569c5fd02ae89bfecd44b983a0f643e --- /dev/null +++ b/library/templates/Intonation/View/Truncate.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_Truncate extends ZendAfi_View_Helper_BaseHelper { + public function truncate($text, $size = '20', $tag = 'p', $attribs = []) { + if (! $text) + return ''; + + $text = strip_tags(html_entity_decode($text)); + + $text = preg_replace('/(\t|\n|\v|\f|\r| |\xC2\x85|\xc2\xa0|\xe1\xa0\x8e|\xe2\x80[\x80-\x8D]|\xe2\x80\xa8|\xe2\x80\xa9|\xe2\x80\xaF|\xe2\x81\x9f|\xe2\x81\xa0|\xe3\x80\x80|\xef\xbb\xbf)+/', ' ', $text); + + $ellipsis = array_filter(explode(' ', $text)); + + if ($size >= count($ellipsis)) + return $text; + + $ellipsis = array_slice($ellipsis, 0, $size); + + $ellipsis [] = $this->_('…'); + + return $this->_tag($tag, + implode(' ', $ellipsis), + $attribs); + } +} \ No newline at end of file