diff --git a/library/Class/AvisNotice.php b/library/Class/AvisNotice.php index 5e2c05e622ace988bfc3c2bc19d5f4930da02c4d..23bee9c3d7e785d56de84361e89e270c5a813b7b 100644 --- a/library/Class/AvisNotice.php +++ b/library/Class/AvisNotice.php @@ -375,6 +375,13 @@ class Class_AvisNotice extends Storm_Model_Abstract { } + public function getAuthorName() { + return ($user = $this->getUser()) + ? $user->getNomAff() + : ''; + } + + public function validate() { if ($this->isImportMode()) return; @@ -469,4 +476,9 @@ class Class_AvisNotice extends Storm_Model_Abstract { public function isImportMode() { return $this->_import_mode; } + + + public function getHumanDate() { + return Class_Date::humanDate($this->getDateAvis(), 'd MMMM yyyy HH:mm'); + } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Review.php b/library/ZendAfi/Form/Review.php new file mode 100644 index 0000000000000000000000000000000000000000..bdd1de09ae0cf2e7e645d539ff2acb01faebc511 --- /dev/null +++ b/library/ZendAfi/Form/Review.php @@ -0,0 +1,51 @@ +<?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 ZendAfi_Form_Review extends ZendAfi_Form { + public function init() { + parent::init(); + + $this + + ->addElement('text', + 'note', + ['label' => $this->_('Note')]) + + ->addElement('text', + 'entete', + ['label' => $this->_('Titre')]) + + ->addElement('textarea', + 'avis', + ['label' => $this->_('Texte'), + 'required' => true, + 'allowEmpty' => false, + 'rows' => 3, + 'cols' => 25]) + + ->addUniqDisplayGroup('review', + ['legend' => $this->_('Mon avis')]); + + return $this; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/BaseHelper.php b/library/ZendAfi/View/Helper/BaseHelper.php index 884a7eb2e02a133aa3d19b47b7677f5cd1b84513..e712f7676d1ed9353d41f9b0e512a80f99c723ce 100644 --- a/library/ZendAfi/View/Helper/BaseHelper.php +++ b/library/ZendAfi/View/Helper/BaseHelper.php @@ -71,4 +71,11 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { protected function _tagWarning($message) { return call_user_func_array([$this->view, 'tagWarning'], func_get_args()); } + + + protected function _div($attributes, $content = '') { + return $this->_tag('div', + $content, + $attributes); + } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Articles.php b/library/ZendAfi/View/Helper/Notice/Articles.php new file mode 100644 index 0000000000000000000000000000000000000000..3038003fa7814c83e88e0e8eabcbfb436ee59999 --- /dev/null +++ b/library/ZendAfi/View/Helper/Notice/Articles.php @@ -0,0 +1,29 @@ +<?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 ZendAfi_View_Helper_Notice_Articles extends ZendAfi_View_Helper_BaseHelper { + public function Notice_Articles($record) { + $articles = $record->getArticlesPeriodique($record->getId()); + $notice_html = new Class_NoticeHtml(); + return $this->_sendResponseWithScripts($notice_html->getArticlesPeriodique($periodiques)); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Reviews.php b/library/ZendAfi/View/Helper/Notice/Reviews.php new file mode 100644 index 0000000000000000000000000000000000000000..842bc827647e4409f60ee1bde04c246c604dfa33 --- /dev/null +++ b/library/ZendAfi/View/Helper/Notice/Reviews.php @@ -0,0 +1,95 @@ +<?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 ZendAfi_View_Helper_Notice_Reviews extends ZendAfi_View_Helper_BaseHelper { + + protected $_record; + + + public function Notice_Reviews($record) { + $this->_record = $record; + + $html = [$this->_renderPro(), + $this->_renderUsers(), + $this->_mine()]; + + return $this->view->grid(implode($html), [], ['class' => 'justify-content-center']); + } + + + protected function _renderReview($title, $elements) { + if (empty($elements)) + return ''; + + $elements = array_map(function($element) + { + return (new Intonation_Library_View_Wrapper_Review) + ->setView($this->view) + ->setModel($element); + }, $elements); + + $callback = function ($element) { + return $this->_tag('div', + $this->view->cardifyOnlyDescription($element), + ['class' => 'card']); + }; + + return + $this->_div(['class' => 'col-12 col-md-6 col-xl-4'], + $this->_tag('h3', $title) + . $this->view->renderList(new Storm_Collection($elements), $callback)); + } + + + protected function _renderPro() { + return $this->_renderReview($this->_('Des professionels'), $this->_record->getAvisBibliothecaires()); + } + + + protected function _renderUsers() { + return $this->_renderReview($this->_('Des lecteurs'), $this->_record->getAvisAbonnes()); + } + + + protected function _mine() { + if (!$me = Class_Users::getIdentity()) + return ''; + + $mine = ($mine = $me->getFirstAvisByIdNotice($this->_record->getId())) + ? $mine + : new Class_Avis; + + $params = $mine->isNew() + ? ['action' => 'add-review'] + : ['action' => 'edit-review', + 'id' => $mine->getId()]; + + $form = ZendAfi_Form_Review::newWith($mine->toArray()) + ->setAction($this->view->url($params)); + + return $this->_div(['class' => 'col-12 col-md-6 col-xl-4'], + $this->_tag('h3', $this->_('Votre avis'), ['class' => 'card-title']) + . $this->_div(['class' => 'card'], + $this->_div(['class' => 'card-body'], + $this->view->renderForm($form)))); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 9c9133134419624eb2abc5ba40e9302c677b195d..4500d4d4e40a38e6c86a57c5546ae32f12930714 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -236,7 +236,7 @@ pre { } .card { - white-space: pre-line; + white-space: normal; } .card-text { @@ -265,32 +265,38 @@ pre { margin-bottom: 0; } -[id*='resources'] .list-group-item { +.list-group-item { padding-left: 0; padding-right: 0; } -[id*='resources'] .card-text { - * margin: 0; +[id*='resources'] .list-group { + max-height: 300px; + overflow: auto; + margin-top: 0.75rem; } -.list-group-item { - padding-bottom: 0; +[id*='resources'] .list-group-item { + padding-top: 0; } -.list-group-item .card-title, -.list-group-item .card-text { +[id*='resources'] .list-group-item .card-title, +[id*='resources'] .list-group-item .card-text { margin: 0; } -.list-group-item .text-muted { +[id*='resources'] .list-group-item .text-muted { font-size: 75%; } -.list-group-item .card-title, -.list-group-item .card-text, -.list-group-item .card-body, -.list-group-item .card-footer { +[id*='resources'] .list-group-item .card-title, +[id*='resources'] .list-group-item .card-text, +[id*='resources'] .list-group-item .card-body, +[id*='resources'] .list-group-item .card-footer { padding-bottom: 1px; padding-top: 1px; +} + +textarea { + width: 100%; } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 3938d198f70341a687b87f05e53216a3f28a94f6..4ecfb8f02d2e13a9427a167daa5a2f195b6761b1 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -65,7 +65,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class widget-header' => 'card-header', 'div class widget-body' => 'card-body', 'div class widget-footer' => 'card-footer', - 'label' => 'col-5 col-form-label col-form-label-sm', + 'div class boutons' => 'row justify-content-around', + 'label' => 'col-12 col-sm-5 col-form-label col-form-label-sm', 'label class multi-element-label' => 'col-form-label col-form-label-sm', 'input' => 'form-control form-control-sm', 'input data-spambots true' => '', @@ -86,8 +87,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'img class card-img-top' => '', 'img class img-thumbnail' => '', 'dl' => 'row', - 'dt' => 'col-3', - 'dd' => 'col-9', + 'dt' => 'col-12 col-sm-3', + 'dd' => 'col-12 col-sm-9', 'a' => 'btn-link', 'a class card-link' => '', 'a class account-loans' => 'list-group-item-info', diff --git a/library/templates/Intonation/Library/View/Wrapper/Review.php b/library/templates/Intonation/Library/View/Wrapper/Review.php new file mode 100644 index 0000000000000000000000000000000000000000..e885fb7d3efc3d3114f99755b8c63dae0121a280 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Review.php @@ -0,0 +1,66 @@ +<?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_Library_View_Wrapper_Review extends Intonation_Library_View_Wrapper_Abstract { + + public function getTitle() { + $badges = [['tag' => 'span', + 'class' => 'info float-right', + 'text' => $this->_('%d / 5', + $this->_model->getNote())], + + ['tag' => 'span', + 'class' => 'light text-muted float-right', + 'text' => $this->_model->getHumanDate()] + ]; + + return + $this->_model->getEntete() + . $this->_view->renderBadges($badges); + } + + + public function getAuthor() { + return $this->_model->getAuthorName(); + } + + + public function getDescription() { + return $this->_model->getAvis(); + } + + + public function getDescriptionTitle() { + } + + + public function getMainLink() { + } + + + public function getAuthorIco() { + return Class_Template::current() + ->getIco($this->_view, + 'author', + 'library'); + } +} diff --git a/library/templates/Intonation/View/Grid.php b/library/templates/Intonation/View/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..ce7876797a77814ecfa2f3af43ade4e94a65febb --- /dev/null +++ b/library/templates/Intonation/View/Grid.php @@ -0,0 +1,39 @@ +<?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_Grid extends ZendAfi_View_Helper_BaseHelper { + + public function grid($html, $container_attribs = [], $row_attribs = []) { + if (!isset($container_attribs['class'])) + $container_attribs ['class'] = ''; + + $container_attribs ['class'] .= ' container-fluid'; + + if (!isset($row_attribs['class'])) + $row_attribs ['class'] = ''; + + $row_attribs ['class'] .= ' row'; + + return $this->_div($container_attribs, + $this->_div($row_attribs, $html)); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Notice/Exemplaires.php b/library/templates/Intonation/View/Notice/Exemplaires.php index 41bdeb663189d1d1cebbf0a8030345a41bc5e087..4fac07c547faa5884a186e45a3ff6ecdbeaa9daa 100644 --- a/library/templates/Intonation/View/Notice/Exemplaires.php +++ b/library/templates/Intonation/View/Notice/Exemplaires.php @@ -29,7 +29,6 @@ class Intonation_View_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper ['class' => 'card']); }; - usort($exemplaires, function($a, $b) { diff --git a/library/templates/Intonation/View/RenderForm.php b/library/templates/Intonation/View/RenderForm.php index 7cbdf8a5202b1615390edce65e21820b83b774dc..e746816b4f53836404565dc7f79df80de3483bf5 100644 --- a/library/templates/Intonation/View/RenderForm.php +++ b/library/templates/Intonation/View/RenderForm.php @@ -30,7 +30,7 @@ class Intonation_View_RenderForm extends ZendAfi_View_Helper_RenderForm { protected function _labelForTableRendering($element, $decorator, $newDecorators, $name) { $newDecorators[] = [['input_data' => 'HtmlTag'], ['tag' => 'div', - 'class' => 'col-7']]; + 'class' => 'col']]; $decorator->setOptions([]); $newDecorators[$name] = $decorator; $newDecorators[] = ['HtmlTag', ['tag' => 'div', 'class' => 'form-group row']]; diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index ed9edf687a1e8d8327446e9a378d83ec792bc6bd..c42108ba68edd4eaeaa238576a7f1ce9f550d9eb 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -62,26 +62,8 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { } - protected function _div($attributes, $content = '') { - return $this->_tag('div', - $content, - $attributes); - } - - protected function _grid($html, $container_attribs = [], $row_attribs = []) { - if (!isset($container_attribs['class'])) - $container_attribs ['class'] = ''; - - $container_attribs ['class'] .= ' container-fluid'; - - if (!isset($row_attribs['class'])) - $row_attribs ['class'] = ''; - - $row_attribs ['class'] .= ' row'; - - return $this->_div($container_attribs, - $this->_div($row_attribs, $html)); + return $this->view->grid($html, $container_attribs, $row_attribs); } @@ -96,6 +78,9 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderBloc($title, $html) { + if (!$title || !$html) + return ''; + return $this->_div(['class' => 'border-bottom border-primary mb-3 pb-3'], $this->_tag('h2', $title) . $html); @@ -104,15 +89,18 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderReviews() { return $this->_renderBloc($this->_('Avis'), - $this->_renderAjaxBloc('avis')); + $this->view->Notice_Reviews($this->_record)); } protected function _renderDetails() { + $html = $this->_record->isPeriodique() + ? $this->view->Notice_Articles($this->_record) + : $this->view->Notice_Entete($this->_record, ['entete' => Class_Codification::CHAMPS]); + return $this->_renderBloc($this->_('Description'), - $this->_grid($this->_renderAjaxBloc('recounts') - . $this->_renderAjaxBloc('detail'))); + $html); } @@ -134,11 +122,9 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderHead() { $html = - $this->_div(['class' => 'col-12 col-md-4 col-lg-3 col-xl-2'], $this->_recordThumbnail()) -// . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-6'], -// $this->_div(['class' => 'row no-gutters'], + $this->_div(['class' => 'col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2 offset-xl-1'], $this->_recordThumbnail()) . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-4'], $this->_recordMetaData()) - . $this->_div(['class' => 'no-gutters col-12 col-md-10 col-xl-4'], $this->_recordItems()); + . $this->_div(['class' => 'mh-100 no-gutters col-12 col-md-10 col-xl-3'], $this->_recordItems()); return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 no_overflow'], $this->_grid($html, diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index b556c4c4af290856b214d86b6edb879dbbb35d3a..80c66879baf7b0355d590aab3836924e97d18fea 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1733,8 +1733,20 @@ class TemplatesViewRecordTest extends TemplatesIntonationTestCase { $this->fixture('Class_Notice', ['id' => 456, 'titre_principal' => 'Psycho', + 'clef_oeuvre' => 'PSYKO', 'facettes' => 'G13 M12']); + $this->fixture('Class_AvisNotice', + ['id' => 178, + 'entete' => "Lost héighway", + 'clef_oeuvre' => 'PSYKO', + 'avis' => 'Oh po po !', + 'note' => 5, + 'date_avis' => '2015-03-18 13:00:00', + 'statut' => 1, + 'abon_ou_bib' => 1, + 'id_notice' => 456]); + $this->dispatch('/opac/recherche/viewnotice/id/456/id_profil/72'); }