From 448f8df12d823040113cc9fa92f18c5c26cc5954 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Thu, 21 Feb 2019 15:11:25 +0100 Subject: [PATCH] dev #64573 wip on author view --- library/Class/CodifAuteur/Description.php | 13 ++++ .../Intonation/Assets/css/intonation.css | 48 ++++-------- .../Intonation/Library/InaInterview.php | 23 ++++++ .../Intonation/Library/InaInterviews.php | 76 +++++++++++++++++++ .../templates/Intonation/Library/Settings.php | 16 ++-- .../templates/Intonation/System/Abstract.php | 1 + .../Intonation/View/Abstract/Carousel.php | 5 +- .../View/Author/RenderCollaborations.php | 15 ++-- .../View/Author/RenderInterviews.php | 36 +++++++++ .../Intonation/View/Author/RenderRecords.php | 5 +- .../View/Author/RenderThumbnail.php | 5 +- .../View/Author/RenderYoutubeChan.php | 2 +- library/templates/Intonation/View/Gridify.php | 4 +- .../View/RenderAuthorDescription.php | 26 ++++--- .../Intonation/View/RenderCarousel.php | 2 +- .../Intonation/View/RenderInterviews.php | 48 ++++++++++++ .../View/RenderMultipleCarousel.php | 2 +- .../Intonation/View/RenderRecord.php | 3 +- .../Intonation/View/RenderRecord/Author.php | 3 +- 19 files changed, 263 insertions(+), 70 deletions(-) create mode 100644 library/templates/Intonation/Library/InaInterview.php create mode 100644 library/templates/Intonation/Library/InaInterviews.php create mode 100644 library/templates/Intonation/View/Author/RenderInterviews.php create mode 100644 library/templates/Intonation/View/RenderInterviews.php diff --git a/library/Class/CodifAuteur/Description.php b/library/Class/CodifAuteur/Description.php index 8758804c1cd..ecad640d23d 100644 --- a/library/Class/CodifAuteur/Description.php +++ b/library/Class/CodifAuteur/Description.php @@ -279,6 +279,19 @@ class Class_CodifAuteur_Description { $records_by_doctype[$record->getTypeDoc()][] = $record; } + uasort($records_by_doctype, function($a, $b) + { + $count_a = count($a); + $count_b = count($b); + + if ($count_a == $count_b) + return 0; + + return $count_a < $count_b + ? 1 + : -1; + }); + return $records_by_doctype; } diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 58a04d42b67..0563a9fc979 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -16,6 +16,7 @@ --front-navbar-background: #CCC; --front-background-overlay: rgba(0, 0 , 0 ,0.7); --front-background-modale: rgba(0, 0 , 0 ,0.95); + --front-background-youtube: #ff0000; } body { @@ -24,6 +25,10 @@ body { font-size: 16px; } +.bg_youtube { + background-color: var(--front-background-youtube); +} + .widget { background-color: var(--front-widget-background); box-shadow: 1px 1px 5px var(--front-shadow); @@ -236,38 +241,6 @@ pre { z-index: 3 !important; } -.margin_top_-1 { - margin-top: -5%; -} - -.margin_top_-2 { - margin-top: -10%; -} - -.margin_top_1 { - margin-top: 5%; -} - -.margin_top_2 { - margin-top: 10%; -} - -.margin_bottom_1 { - margin-bottom: 5%; -} - -.margin_bottom_2 { - margin-bottom: 10%; -} - -.margin_bottom_-1 { - margin-bottom: -5%; -} - -.margin_bottom_-2 { - margin-bottom: -10%; -} - .card { white-space: normal; } @@ -294,7 +267,7 @@ pre { } .carousel-indicators { - bottom: 5px; + bottom: -1em; margin-bottom: 0; } @@ -421,8 +394,17 @@ label[for=note] ~ div label.multi-element-label + br { position: relative; max-height: 500px; overflow-y: scroll; + word-break: break-word; } [class*='text-'] .btn-link { color: inherit; } + +.carousel-indicators:hover { + background-color: var(--front-background-overlay); +} + +.badge { + white-space: normal; +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/InaInterview.php b/library/templates/Intonation/Library/InaInterview.php new file mode 100644 index 00000000000..5b631bbf3be --- /dev/null +++ b/library/templates/Intonation/Library/InaInterview.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_Library_InaInterview extends Class_Entity {} \ No newline at end of file diff --git a/library/templates/Intonation/Library/InaInterviews.php b/library/templates/Intonation/Library/InaInterviews.php new file mode 100644 index 00000000000..32598a5f2e6 --- /dev/null +++ b/library/templates/Intonation/Library/InaInterviews.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_Library_InaInterviews { + protected $_model; + + + public function setModel($model) { + $this->_model = $model; + return $this; + } + + + public function collection() { + return new Storm_Collection($this->interviews()); + } + + + public function interviews() { + $args = ['auteur' => $this->_model->getLabel(), + 'width' => 500]; + + $data = Class_WebService_AllServices::runServiceAfiInterviews($args); + + if (!$videos = $data["videos"]) + return []; + + $interviews = []; + + foreach ($videos as $meta_data) + $interviews = $this->_extractInterviewFrom($meta_data, $interviews); + + return $interviews; + } + + + protected function _extractInterviewFrom($data, $interviews) { + $data = new Class_Entity($data); + + if (!$title = $data->gettitre()) + return $interviews; + + if (!$html = $data->getplayer()) + return $interviews; + + preg_match('/src="([^"]+)"/', $html, $match); + + if (!$url = $match[1]) + return $interviews; + + $interviews [] = new Intonation_Library_InaInterview(['Url' => $url, + 'Source' => 'ina.fr', + 'Title' => $title, + 'Description' => $data->getcontenu()]); + return $interviews; + } +} diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index d5cdf4834c8..fb591f41ebf 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -52,14 +52,14 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'z_index_1', 'z_index_2', 'z_index_3', - 'margin_top_-1', - 'margin_top_-2', - 'margin_top_1', - 'margin_top_2', - 'margin_bottom_1', - 'margin_bottom_2', - 'margin_bottom_-1', - 'margin_bottom_-2', + 'mt-n1', + 'mt-n2', + 'mt-1', + 'mt-2', + 'mb-1', + 'mb-2', + 'mb-n1', + 'mb-n2', 'align-items-center', ], diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php index 4e66efbda01..16580fc98b7 100644 --- a/library/templates/Intonation/System/Abstract.php +++ b/library/templates/Intonation/System/Abstract.php @@ -171,6 +171,7 @@ abstract class Intonation_System_Abstract { if($this->isVisibleForSearchController()) { $controllers [] = 'recherche'; $controllers [] = 'record'; + $controllers [] = 'author'; } if($this->isVisibleForUserController()) diff --git a/library/templates/Intonation/View/Abstract/Carousel.php b/library/templates/Intonation/View/Abstract/Carousel.php index 963bedf7785..21a46c7410e 100644 --- a/library/templates/Intonation/View/Abstract/Carousel.php +++ b/library/templates/Intonation/View/Abstract/Carousel.php @@ -39,6 +39,9 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas protected function _indicators($count, $id) { + if (1 >= $count) + return ''; + $lis = []; for ($i = 0; $i < $count; $i++) @@ -50,7 +53,7 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas return $this->_tag('ol', implode($lis), - ['class' => 'carousel-indicators']); + ['class' => 'carousel-indicators rounded']); } diff --git a/library/templates/Intonation/View/Author/RenderCollaborations.php b/library/templates/Intonation/View/Author/RenderCollaborations.php index 18a24bf083f..34838e77264 100644 --- a/library/templates/Intonation/View/Author/RenderCollaborations.php +++ b/library/templates/Intonation/View/Author/RenderCollaborations.php @@ -51,12 +51,13 @@ class Intonation_View_Author_RenderCollaborations extends ZendAfi_View_Helper_Ba 'title' => sprintf('Voir les documents du fonds issus d\'une collaboration entre %s et %s', $author_description->getLabel(), $author->getLibelle())]); - return $this->_div(['class' => 'p-1 bg-primary rounded pl-3 ml-3 mb-3'], - $this->_tag('span', - (new Class_Notice_FieldAuthor($author))->renderOn($this->view), - ['class' => 'mr-3 text-white']) - . $this->_tag('span', - $collaboration_link, - ['class' => 'badge badge-light'])); + return $this->_div(['class' => 'card'], + $this->_div(['class' => 'p-1 bg-primary rounded pl-3'], + $this->_tag('span', + (new Class_Notice_FieldAuthor($author))->renderOn($this->view), + ['class' => 'mr-3 text-white']) + . $this->_tag('span', + $collaboration_link, + ['class' => 'badge badge-light']))); } } diff --git a/library/templates/Intonation/View/Author/RenderInterviews.php b/library/templates/Intonation/View/Author/RenderInterviews.php new file mode 100644 index 00000000000..e1c788b1c02 --- /dev/null +++ b/library/templates/Intonation/View/Author/RenderInterviews.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_Author_RenderInterviews extends ZendAfi_View_Helper_BaseHelper { + public function Author_RenderInterviews($author) { + $interviews = (new Intonation_Library_InaInterviews) + ->setModel($author) + ->collection(); + + if ($interviews->isEmpty()) + return ''; + + return + $this->_tag('h2', $this->_('Reportages ina.fr')) + . $this->view->renderInterviews($interviews); + } +} diff --git a/library/templates/Intonation/View/Author/RenderRecords.php b/library/templates/Intonation/View/Author/RenderRecords.php index 444c275c332..d2d4bcbd61b 100644 --- a/library/templates/Intonation/View/Author/RenderRecords.php +++ b/library/templates/Intonation/View/Author/RenderRecords.php @@ -23,12 +23,13 @@ class Intonation_View_Author_RenderRecords extends ZendAfi_View_Helper_BaseHelper { public function Author_RenderRecords($author) { $records_by_doctype = []; + foreach($author->getRecordsByDocType() as $doc_type_id => $records) $records_by_doctype [] = $this->_renderRecord($author, $doc_type_id, $records); - return $this->view->grid(implode($records_by_doctype), ['class' => 'records']); + return $this->view->grid(implode($records_by_doctype), ['class' => 'records'], ['class' => ' justify-content-between']); } @@ -54,7 +55,7 @@ class Intonation_View_Author_RenderRecords extends ZendAfi_View_Helper_BaseHelpe $elements = new Storm_Collection($elements); - $records = $this->view->renderWall($elements, function($record) + $records = $this->view->renderMultipleCarousel($elements, function($record) { return $this->view->cardifyWithOverlay($record); }); diff --git a/library/templates/Intonation/View/Author/RenderThumbnail.php b/library/templates/Intonation/View/Author/RenderThumbnail.php index 67d7d6fdaa3..1aeaafd10ef 100644 --- a/library/templates/Intonation/View/Author/RenderThumbnail.php +++ b/library/templates/Intonation/View/Author/RenderThumbnail.php @@ -32,6 +32,9 @@ class Intonation_View_Author_RenderThumbnail extends ZendAfi_View_Helper_BaseHel $author->getLabel()), 'alt' => $this->_('%s. Source: Wikipedia', $author->getLabel())])) - : ''; + : Class_Template::current()->getIco($this->view, + 'author', + 'library', + ['class' => 'ico_xl m-0 text-center pt-5']); } } diff --git a/library/templates/Intonation/View/Author/RenderYoutubeChan.php b/library/templates/Intonation/View/Author/RenderYoutubeChan.php index 62c12988cb2..ed44d699163 100644 --- a/library/templates/Intonation/View/Author/RenderYoutubeChan.php +++ b/library/templates/Intonation/View/Author/RenderYoutubeChan.php @@ -34,7 +34,7 @@ class Intonation_View_Author_RenderYoutubeChan extends ZendAfi_View_Helper_BaseH $callback = function($video) { return - $this->_div(['class' => 'card bg-info text-white shadow'], + $this->_div(['class' => 'card bg_youtube text-white shadow'], $this->_div(['class' => 'card-body'], $this->_div(['class' => 'card-title'], $this->_tag('h3', diff --git a/library/templates/Intonation/View/Gridify.php b/library/templates/Intonation/View/Gridify.php index 2b11154130a..055fdbe1306 100644 --- a/library/templates/Intonation/View/Gridify.php +++ b/library/templates/Intonation/View/Gridify.php @@ -29,12 +29,12 @@ class Intonation_View_Gridify extends ZendAfi_View_Helper_BaseHelper { for ($i = 0; $i < $number_of_rows; $i++) { $items = array_slice($elements, - $i * $columns, + $i * $columns, $columns); $rows [$i] = $this->_tag('div', implode($items), - ['class' => 'card-deck']); + ['class' => 3 == count($items) ? 'card-deck' : 'card-columns']); } return new Storm_Collection($rows); diff --git a/library/templates/Intonation/View/RenderAuthorDescription.php b/library/templates/Intonation/View/RenderAuthorDescription.php index e066e9c0cbd..3a7f65fa76a 100644 --- a/library/templates/Intonation/View/RenderAuthorDescription.php +++ b/library/templates/Intonation/View/RenderAuthorDescription.php @@ -22,29 +22,33 @@ class Intonation_View_RenderAuthorDescription extends ZendAfi_View_Helper_BaseHelper { public function renderAuthorDescription($description) { - $html = [ - $this->_div(['class' => 'col-3'], + $html = [$this->_div(['class' => 'col-3 col-xl-2'], $this->view->Author_RenderThumbnail($description)), - $this->_div(['class' => 'col-9 col-xl-5 pl-3'], + $this->_div(['class' => 'col-9 col-xl-4 pl-3 pl-xl-0'], $this->view->Author_RenderFacets($description)), - $this->_div(['class' => 'col-12 col-xl-4 text-right'], + $this->_div(['class' => 'col-12 col-xl-5 mt-3'], + $this->view->Author_RenderWikipedia($description)), + + $this->_div(['class' => 'col-12 mt-3 text-right'], $this->view->Author_EditBiographyUrl($description)), - $this->_div(['class' => 'col-12 mt-3'], - $this->view->Author_RenderWikipedia($description)), + $this->_div(['class' => 'col-12 col-xl-6 mt-3'], + $this->view->Author_RenderRecords($description)), - $this->_div(['class' => 'col-12 mt-3'], + $this->_div(['class' => 'col-12 col-xl-5 mt-3'], $this->view->Author_RenderCollaborations($description)), - $this->_div(['class' => 'col-12 mt-3'], - $this->view->Author_RenderRecords($description)), + $this->_div(['class' => 'col-12'], ''), + + $this->_div(['class' => 'col-12 col-xl-6 mt-3'], + $this->view->Author_RenderInterviews($description)), - $this->_div(['class' => 'col-12 mt-3'], + $this->_div(['class' => 'col-12 col-xl-5 mt-3'], $this->view->Author_RenderYoutubeChan($description)), ]; - return $this->view->grid(implode($html)); + return $this->view->grid(implode($html), [], ['class' => 'justify-content-between']); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderCarousel.php b/library/templates/Intonation/View/RenderCarousel.php index cf0488809e5..82f8815266d 100644 --- a/library/templates/Intonation/View/RenderCarousel.php +++ b/library/templates/Intonation/View/RenderCarousel.php @@ -38,6 +38,6 @@ class Intonation_View_RenderCarousel extends Intonation_View_Abstract_Carousel { protected function _shouldShowControls($collection) { - return true; + return 1 < $this->_numberOfPages($collection); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderInterviews.php b/library/templates/Intonation/View/RenderInterviews.php new file mode 100644 index 00000000000..19b996dc244 --- /dev/null +++ b/library/templates/Intonation/View/RenderInterviews.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_RenderInterviews extends ZendAfi_View_Helper_BaseHelper { + + public function renderInterviews($interviews) { + if ($interviews->isEmpty()) + return ''; + + $callback = function($interview) { + return + $this->_div(['class' => 'card bg-dark text-white shadow'], + $this->_div(['class' => 'card-body'], + $this->_div(['class' => 'card-title'], + $this->_tag('h3', + Class_Template::current()->getIco($this->view, + 'video', + 'utils') + . $interview->getTitle())) + . $this->_div(['class' => 'text-center'], + $this->view->renderEmbed($interview->getSource(), + $interview->getUrl())) + . $this->_div(['class' => 'card-text'], + $interview->getDescription()))); + }; + + return $this->view->renderCarousel($interviews, $callback); + } +} diff --git a/library/templates/Intonation/View/RenderMultipleCarousel.php b/library/templates/Intonation/View/RenderMultipleCarousel.php index 94390ac40d6..80eda621940 100644 --- a/library/templates/Intonation/View/RenderMultipleCarousel.php +++ b/library/templates/Intonation/View/RenderMultipleCarousel.php @@ -36,7 +36,7 @@ class Intonation_View_RenderMultipleCarousel extends Intonation_View_Abstract_Ca protected function _shouldShowControls($collection) { - return (boolean) $collection->count(); + return 1 < $this->_numberOfPages($collection); } diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index c2e869ac87e..338de620d42 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -135,7 +135,8 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderAuthor() { return - $this->_renderBloc($this->_('Auteur principal'), + $this->_renderBloc($this->_('Auteur principal : %s', + $this->_record->getAuteurPrincipal()), $this->_renderAjaxBloc('author')); } diff --git a/library/templates/Intonation/View/RenderRecord/Author.php b/library/templates/Intonation/View/RenderRecord/Author.php index f653643de99..0057ee49ce5 100644 --- a/library/templates/Intonation/View/RenderRecord/Author.php +++ b/library/templates/Intonation/View/RenderRecord/Author.php @@ -27,7 +27,8 @@ class Intonation_View_RenderRecord_Author extends Intonation_View_RenderRecord { protected function _getSubtitle() { - return $this->_(' : Auteur principal'); + return $this->_(' : Auteur principal : %s', + $this->_record->getAuteurPrincipal()); } -- GitLab