diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index dd1feffa2639dc791f2fc03523fd5dd1aca80574..52e7589a81b9ea15718e85491645931b1623adf3 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -1390,13 +1390,52 @@ class AbonneController extends ZendAfi_Controller_Action { } + public function ajaxReviewAction() { + session_write_close(); + $this->getHelper('ViewRenderer')->setNoRender(); + + if(!$this->_user) + return $this->_response->setHttpResponseCode(520); + + if(!$this->_request->isPost()) + return $this->_response->setHttpResponseCode(520); + + $form = new ZendAfi_Form_Review; + + $post = $this->_request->getPost(); + $form->populate($post); + + $rating = ($mine = Class_AvisNotice::find($this->_getParam('id'))) + ? $mine + : new Class_AvisNotice; + + $rating + ->beImportMode() + ->setUser($this->_user) + ->setIdNotice($this->_getParam('record_id')) + ->setClefOeuvre($this->_getParam('record_key')) + ->setUserRole($this->_user) + ->setModerationOK() + ->updateAttributes($post); + + if ($this->_getPost('entete') || $this->_getPost('avis')) + $rating->setModerationNOK(); + + if (!$form->isValidModelAndArray($rating, $post)) + return $this->_response->setHttpResponseCode(520); + + if (!$rating->save()) + return $this->_response->setHttpResponseCode(520); + + return $this->_response->setHttpResponseCode(200); + } + + public function editReviewAction() { - if (!$review = Class_AvisNotice::find($this->_getParam('id', null))) + if (!$this->view->review = Class_AvisNotice::find($this->_getParam('id', null))) return $this->_redirectClose($this->_getReferer()); $this->view->titre = $this->_('Modifier l\'avis'); - - $this->view->review = $review; } @@ -1404,13 +1443,10 @@ class AbonneController extends ZendAfi_Controller_Action { if (!$review = Class_AvisNotice::find($this->_getParam('id', null))) return $this->_redirectClose($this->_getReferer()); - $this->view->titre = $this->_('Supprimer l\'avis'); + $this->view->titre = $this->_('Supprimer un avis'); $this->view->review = $review; - if ($this->_getParam('redirect')) - return $this->_redirectClose($this->_getReferer()); - if ($this->_getParam('delete')) { $review->delete(); $this->_helper->notify($this->_('L\'avis a bien été supprimé'), @@ -1478,6 +1514,11 @@ class AbonneController extends ZendAfi_Controller_Action { return $this->_redirectClose($this->_getReferer()); } + if (!$this->view->selection->isMine()) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + $this->view->criteria = (new Class_CriteresRecherche()) ->setParams(array_merge($this->_request->getParams(), @@ -1485,6 +1526,80 @@ class AbonneController extends ZendAfi_Controller_Action { } + public function ajouterLeDocumentALaSelectionAction() { + session_write_close(); + $this->getHelper('ViewRenderer')->setNoRender(); + + if (!$selection = Class_PanierNotice::find($this->_getParam('id'))) + return $this->_response->setHttpResponseCode(404); + + + if (!$selection->isMine()) + return $this->_response->setHttpResponseCode(404); + + if (!$record = Class_Notice::find($this->_getParam('record_id'))) + return $this->_response->setHttpResponseCode(404); + + $selection->addNotice($record); + $selection->save(); + } + + + public function supprimerDeLaSelectionAction() { + $this->view->titre = $this->_('Retirer un document'); + + if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$this->view->selection->isMine()) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$this->view->record = Class_Notice::find($this->_getParam('record_id'))) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if ($this->_getParam('delete')) { + $this->view->selection + ->removeNotice($this->view->record) + ->save(); + $this->_helper->notify($this->_('Le document a bien été retiré'), + ['status' => 'delete']); + return $this->_redirectClose($this->_getReferer()); + } + } + + + public function creerSelectionAction() { + $this->view->titre = $this->view->_('Créer une sélection'); + $this->view->form = new ZendAfi_Form(); + $this->view->form + ->addElement('text', + 'libelle', + ['placeholder' => 'Titre de la sélection']) + ->addUniqDisplayGroup('group') + ->populate($this->_request->getParams()) + ->setAction($this->view->url()); + + if(!$this->_request->isPost()) + return; + + $selection = Class_PanierNotice::newForUser($this->_user); + $selection->setLibelle($this->_request->getPost('libelle')); + + if(!$this->view->form->isValidModelAndArray($selection, $this->_request->getPost())) + return; + + $selection->save(); + $selection->index(); + return $this->_redirectClose($this->_getReferer()); + } + + public function mesAvisAction() { } @@ -1494,10 +1609,18 @@ class AbonneController extends ZendAfi_Controller_Action { public function donnerDesAvisAction() { + $this->view->criteria = + (new Class_CriteresRecherche()) + ->setParams(array_merge($this->_request->getParams(), + ['tri' => Class_CriteresRecherche::SORT_PUBLICATION])); } public function suivreUneRechercheAction() { + $this->view->criteria = + (new Class_CriteresRecherche()) + ->setParams(array_merge($this->_request->getParams(), + ['tri' => Class_CriteresRecherche::SORT_PUBLICATION])); } @@ -1539,4 +1662,44 @@ class AbonneController extends ZendAfi_Controller_Action { $form->addDecorator('Errors'); } } + + + public function exporterLaSelectionAction() { + $this->view->titre = $this->_('Exporter la sélection'); + + if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$this->view->selection->isMine()) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$format = $this->_getParam('format')) + return; + + $data = ('unimarc' == $format) + ? $this->view->selection->toUnimarcIso2709() + : $this->view->selection->toTabbedList(); + + $this->getHelper('ViewRenderer')->setNoRender(); + + $name = sprintf('%s_id_%s_%s', + (new Class_TimeSource)->dateYmd(), + $this->view->selection->getId(), + str_replace(' ', '_', $this->view->selection->getLibelle())); + + $response = $this->_response; + $response->clearAllHeaders(); + $response->setHeader('Content-Type', 'text/plain; name="' . $name . '.txt"', true); + $response->setHeader('Content-Disposition', 'attachment; filename="' . $name . '.txt"', true); + $response->setHeader('Content-Transfer-Encoding', 'base64', true); + $response->setHeader('Expires', '0'); + $response->setHeader('Cache-Control', 'no-cache, must-revalidate'); + $response->setHeader('Pragma', 'no-cache'); + $response->setHeader('Access-Control-Allow-Origin', '*'); + $response->setBody($data); + } } \ No newline at end of file diff --git a/application/modules/opac/views/scripts/abonne/creer-selection.phtml b/application/modules/opac/views/scripts/abonne/creer-selection.phtml new file mode 100644 index 0000000000000000000000000000000000000000..b82cdce927555473ea654bdc9ad145060a057aef --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/creer-selection.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->renderInlineForm($this->form); \ No newline at end of file diff --git a/application/modules/opac/views/scripts/abonne/delete-review.phtml b/application/modules/opac/views/scripts/abonne/delete-review.phtml index 94887ae42f88e374a7baa3037572bd75421769f6..6e4e52aba21b1fcbcfc583803dbd9ecb79b4c8ad 100644 --- a/application/modules/opac/views/scripts/abonne/delete-review.phtml +++ b/application/modules/opac/views/scripts/abonne/delete-review.phtml @@ -2,21 +2,17 @@ $wrapper = (new Intonation_Library_View_Wrapper_Review) ->setModel($this->review) ->setView($this); -$html = [$this->div(['class' => 'col-10 p-2 m-2 text-left'], - $this->cardifyFullDescription($wrapper)), - - $this->div(['class' => 'col-10'], +$html = [$this->div(['class' => 'col-10'], $this->tag('h3', - $this->_('Supprimer l\'avis'), + $this->_('Supprimer l\'avis %s', + $wrapper->getMainTitle()), ['class' => 'pt-2 mx-2 border-top border-danger'])), $this->div(['class' => 'col-10'], $this->div(['class' => 'm-2 p-2 btn-group text-white'], - $this->tagAnchor(['redirect' => '1'], - $this->_('Non'), - ['class' => 'btn btn-info']) + $this->Button_Back(new Class_Entity(['Attribs' => ['class' => 'btn btn-info']])) . $this->tagAnchor(['delete' => '1'], $this->_('Oui'), ['class' => 'btn btn-danger'])))]; -echo $this->grid(implode($html), [], ['class' => 'justify-content-center']); +echo $this->grid(implode($html), [], ['class' => 'justify-content-center text-center']); diff --git a/application/modules/opac/views/scripts/abonne/donner-des-avis.phtml b/application/modules/opac/views/scripts/abonne/donner-des-avis.phtml index 63735afda3a39482a8b83d939e4b5f38880ddf32..6e64044a143bbb488dd776239e48615b7510217f 100644 --- a/application/modules/opac/views/scripts/abonne/donner-des-avis.phtml +++ b/application/modules/opac/views/scripts/abonne/donner-des-avis.phtml @@ -1,2 +1,2 @@ <?php -echo $this->abonne_RateRecords($this->user); +echo $this->abonne_RateRecords($this->user, $this->criteria); diff --git a/application/modules/opac/views/scripts/abonne/exporter-la-selection.phtml b/application/modules/opac/views/scripts/abonne/exporter-la-selection.phtml new file mode 100644 index 0000000000000000000000000000000000000000..3f32279db50d1573b163ee951a80e61ad4bd0ed1 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/exporter-la-selection.phtml @@ -0,0 +1,22 @@ +<?php +$html = [$this->div(['class' => 'col-10'], + $this->tag('h3', + $this->_('Exporter la sélection %s', + $this->selection->getLibelle()), + ['class' => 'pt-2 mx-2 border-top border-danger'])), + + $this->div(['class' => 'col-10'], + $this->div(['class' => 'm-2 p-2 btn-group text-white'], + $this->Button_Back(new Class_Entity(['Attribs' => ['class' => 'btn btn-info']])) + + . $this->tagAnchor(['format' => 'unimarc', + 'render' => null], + $this->_('UNIMARC'), + ['class' => 'btn btn-success']) + + . $this->tagAnchor(['format' => 'list', + 'render' => null], + $this->_('Liste'), + ['class' => 'btn btn-warning'])))]; + +echo $this->grid(implode($html), [], ['class' => 'justify-content-center text-center']); diff --git a/application/modules/opac/views/scripts/abonne/suivre-une-recherche.phtml b/application/modules/opac/views/scripts/abonne/suivre-une-recherche.phtml index c74daff822299b02ab391573bbfc4730338b18bf..68119bf58c1a6f927eaaddec91f0ba5cac2ffa29 100644 --- a/application/modules/opac/views/scripts/abonne/suivre-une-recherche.phtml +++ b/application/modules/opac/views/scripts/abonne/suivre-une-recherche.phtml @@ -1,2 +1,2 @@ <?php -echo $this->abonne_FollowASearch($this->user); +echo $this->abonne_FollowASearch($this->user, $this->criteria); diff --git a/application/modules/opac/views/scripts/abonne/supprimer-de-la-selection.phtml b/application/modules/opac/views/scripts/abonne/supprimer-de-la-selection.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ce847a17a31345d763d8c5d8e1db3c6fb9d66766 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/supprimer-de-la-selection.phtml @@ -0,0 +1,19 @@ +<?php +$wrapper = (new Intonation_Library_View_Wrapper_Record) + ->setModel($this->record) + ->setView($this); +$html = [$this->div(['class' => 'col-10'], + $this->tag('h3', + $this->_('Retirer le document %s de la sélection %s', + $wrapper->getMainTitle(), + $this->selection->getLibelle()), + ['class' => 'pt-2 mx-2 border-top border-danger'])), + + $this->div(['class' => 'col-10'], + $this->div(['class' => 'm-2 p-2 btn-group text-white'], + $this->Button_Back(new Class_Entity(['Attribs' => ['class' => 'btn btn-info']])) + . $this->tagAnchor(['delete' => '1'], + $this->_('Oui'), + ['class' => 'btn btn-danger'])))]; + +echo $this->grid(implode($html), [], ['class' => 'justify-content-center text-center']); diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 935d368fb725928297ccd84b45ae75e19e42eb6a..a4ed9fa41db1d7549509d432444eccc8f7ab7e4e 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1603,7 +1603,7 @@ class Class_Notice extends Storm_Model_Abstract { $sep=chr(9); $enreg = Class_Codification::getInstance()->getLibelleFacette("T".$this->getTypeDoc()).$sep; - $enreg .= $this->getTitrePrincipal().$sep; + $enreg .= $this->getTitrePrincipal(' ').$sep; $enreg .= $this->getAuteurPrincipal().$sep; $enreg .= $this->getEditeur().$sep; $enreg .= implode(',', $this->getCollections()).$sep; diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index 504c9d9e2c047862ae545215024d1b8c29844700..8f335b6cde302d214113f1100530684704e91a1c 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -390,4 +390,10 @@ class ZendAfi_Form extends Zend_Form { return $this; } + + + public function setId($id) { + $this->setAttrib('id', $id); + return $this; + } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Review.php b/library/ZendAfi/Form/Review.php index 7308aae68dd65db6218f7b69c828587d8bdd45af..57aaf483db4b61cde0c16f1841458d8524526079 100644 --- a/library/ZendAfi/Form/Review.php +++ b/library/ZendAfi/Form/Review.php @@ -33,7 +33,8 @@ $("#%1$s input[name=note]").click(function() { $("#%1$s input[name=note]").parent().removeClass("checked"); if (!$(this).is("checked")) return $(this).parent().addClass("checked"); -});', +}); +', $id)); $this diff --git a/library/ZendAfi/Form/Search/Advanced.php b/library/ZendAfi/Form/Search/Advanced.php index 1a7d6f58f48741b84b80d258e04ea881bd2ee9bf..77f2996fee5e8f5de31a27f44e08ed55ac2f71c4 100644 --- a/library/ZendAfi/Form/Search/Advanced.php +++ b/library/ZendAfi/Form/Search/Advanced.php @@ -48,6 +48,7 @@ class ZendAfi_Form_Search_Advanced extends ZendAfi_Form { ->addElement('select', 'operateur_editeur', ['multiOptions' => $this->_getOperators()]) + ->addElement('text', 'rech_editeur', ['label' => $this->_('Editeurs')]) diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 9a260609cb140137c08f773f5b10ed6ca2e3e5f2..0c57fdf2908e23a6e035950967f7427ab5df821d 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -34,11 +34,6 @@ body { box-shadow: 1px 1px 5px var(--front-shadow); } -[class*="carousel-control"]:hover, -.carousel-indicators li:hover { - background-color: var(--front-background-overlay); -} - #site_web_wrapper { background-color: var(--front-background); } @@ -251,6 +246,7 @@ pre { .card { white-space: normal; + word-wrap: normal; } .card-text { @@ -261,22 +257,21 @@ pre { margin-left: 0; } -[class*="carousel-control"] { - width: 5%; +[class*="carousel-control"], +.carousel-indicators li { + transition: all 0.4s; } -[class*="carousel-control"]:hover { - width: 15%; +[class*="carousel-control"] { + width: auto; } -[class*="carousel-control"], .carousel-indicators li { - transition: all 0.4s; + height: 7px; } -.carousel-indicators { - bottom: -1em; - margin-bottom: 0; +.carousel-indicators li:hover { + opacity: 1; } [id*='resources'] .list-group-item { @@ -409,10 +404,6 @@ label[data-name=note] ~ div label.multi-element-label + br { color: inherit; } -.carousel-indicators:hover { - background-color: var(--front-background-overlay); -} - .badge { text-transform: lowercase; } @@ -477,4 +468,8 @@ dl.row { .card-img-overlay .card-link > * { display: inline-block; white-space: normal; +} + +.rating-score { + display: inline-flex; } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index bb10ad8b07a96bc0a80c382fdded6fb4441f7545..fb14f5d02999e3f8593d5460562c2e06abe95fdb 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -104,7 +104,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'a' => 'btn-link', 'a class active' => '', 'a class nav-link' => '', - 'a class card-link' => 'no_wrap', + 'a class card-link' => '', 'a class list-group-item' => '', 'a class account-loans' => 'btn btn-sm list-group-item-info', 'ul' => 'list-unstyled', @@ -171,6 +171,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'add' => 'class fas fa-plus-square', 'delete' => 'class fas fa-minus', 'edit' => 'class fas fa-edit', + 'check-list' => 'class fas fa-tasks', 'rename' => 'class fas fa-edit', 'rss' => 'class fas fa-rss', @@ -258,7 +259,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { protected function _mergeData($default, $data) { - $merged = array_merge($default, $data); + $merged = array_merge($data, $default); if (count(array_filter(array_keys($default), 'is_string'))) return $merged; diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 715ecef735144ccc8e33998201324c3c3529e52a..eaef1eb109b85bb1d3a5f2290a0617dc20eb650a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -89,6 +89,7 @@ abstract class Intonation_Library_View_Wrapper_Abstract { abstract public function getActions(); abstract public function getDescription(); + abstract public function getFullDescription(); abstract public function getDescriptionTitle(); abstract public function getBadges(); diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index 0af9bb71f81ec1ac5a2b54d1e530f71643c2a7c4..e852acd23362895001f49b3289b865938fc7b2c6 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -77,6 +77,12 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr } + public function getFullDescription() { + return $this->_view->renderArticleBadges($this->_model) + . $this->_model->getSummary(); + } + + public function getDescriptionTitle() { return $this->_('Résumé de l\'article "%s"', $this->_model->getTitre()); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index 8f4f46d92ba9af961ab4688b5016a88d06476ca0..7334e181039ca73917e1ce1f2cb849a3b0ace4aa 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -79,6 +79,18 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp } + public function getFullDescription() { + if (!$this->_model->getNoticeOPAC()) + return ''; + + $wrapper = (new Intonation_Library_View_Wrapper_Record) + ->setView($this->_view) + ->setModel($this->_model->getNoticeOPAC()); + + return $wrapper->getFullDescription(); + } + + public function getDescriptionTitle() { return ''; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php index 44d4b62e64dff18993bc08a51e048f1cb24098fb..f5551c0e509c87223b11473abda9793badade5fa 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Item.php +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -63,6 +63,11 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } + public function getFullDescription() { + return $this->getDescription(); + } + + public function getDescriptionTitle() { return ''; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Loan.php b/library/templates/Intonation/Library/View/Wrapper/Loan.php index 25cb764c2d1882c26ba17e21a6c87a3ee66319fe..9d4ab25e4ca5b418d3b68e992443565b357d2f91 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Loan.php +++ b/library/templates/Intonation/Library/View/Wrapper/Loan.php @@ -79,6 +79,19 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp } + public function getFullDescription() { + if (!$this->_model->getNoticeOPAC()) + return ''; + + $wrapper = (new Intonation_Library_View_Wrapper_Record) + ->setView($this->_view) + ->setModel($this->_model->getNoticeOPAC()); + + return $this->getBadges() + . $wrapper->getFullDescription(); + } + + public function getDescriptionTitle() { return ''; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php index e316bc46fb4e05742f4525edc96a454ba542f17a..13f7973fcea00c184ebec5002aa739ed8b383c22 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php +++ b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php @@ -92,6 +92,12 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View } + public function getFullDescription() { + $template = $this->_model->newTemplate(); + return $template->getBodyHTML(); + } + + public function getDescriptionTitle() { } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 7ac69fd2b535dff86e295099039a35e98856e9cf..f6a91dfc431f332e6e3c8c5fde7609dc15d2895e 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -74,6 +74,12 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra } + public function getFullDescription() { + return $this->getBadges() + . $this->_model->getResume(); + } + + public function getDescriptionTitle() { return $this->_('Résumé du document "%s"', $this->getMainTitle()); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php b/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php index 9c3a92504662aa7cea4a09f163be99b7f0158d1c..053e2822ea9fed5f1d07b0c65f913e1d76a33eee 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php +++ b/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php @@ -32,10 +32,11 @@ class Intonation_Library_View_Wrapper_RecordInSelection extends Intonation_Libra public function getActions() { return [new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', - 'action' => 'supprimer-de-selection', - 'selection' => $this->_selection->getId(), - 'id' => $this->_model->getId()]), + 'action' => 'supprimer-de-la-selection', + 'selection_id' => $this->_selection->getId(), + 'record_id' => $this->_model->getId()]), 'Text' => $this->_('Supprimer'), + 'Popup' => true, 'Title' => $this->_('Supprimer le document %s de la sélection %s', $this->_model->getTitrePrincipal(' '), $this->_selection->getLibelle()), diff --git a/library/templates/Intonation/Library/View/Wrapper/RecordToRate.php b/library/templates/Intonation/Library/View/Wrapper/RecordToRate.php index c20e3631fec8c7931bfc244ceea6fa7ee2b7082b..0aa409e2a1236ffc36c3e1ce474e82d36b558327 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RecordToRate.php +++ b/library/templates/Intonation/Library/View/Wrapper/RecordToRate.php @@ -27,23 +27,19 @@ class Intonation_Library_View_Wrapper_RecordToRate extends Intonation_Library_Vi ? $mine : new Class_AvisNotice; - $params = ['controller' => 'abonne', - 'action' => 'review', - 'record_id' => $this->_model->getId(), - 'record_key' => $this->_model->getClefOeuvre(), - 'id' => $mine->getId()]; - - $form = ZendAfi_Form_Review::newWith($mine->toArray()) - ->setAction($this->_view->url($params, null, true)); - - $form->getElement('entete')->setValue($this->_model->getTitrePrincipal(' ')); + $mine->setNotice($this->_model); return parent::getDescription() . $this->_view->grid($this->_view->div(['class' => 'col-12 py-3 my-3'], $this->_view->tag('h3', $this->_('Donnez votre avis'), ['class' => 'card-title']) . $this->_view->div(['class' => 'card'], $this->_view->div(['class' => 'card-body'], - $this->_view->renderForm($form))))); + $this->_view->renderReviewForm($mine, true))))); + } + + + public function getFullDescription() { + return $this->getDescription(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php b/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php index 65eaced3a9029472dc507b2f3ab69f46a4a8ec88..a786df0eb9735faf8da11a6aee60712bb0910f72 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php +++ b/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php @@ -36,9 +36,20 @@ class Intonation_Library_View_Wrapper_RecordToSelect extends Intonation_Library_ } + public function getFullDescription() { + return ''; + } + + public function getMainLink() { + $url = $this->_view->url(['controller' => 'abonne', + 'action' => 'ajouter-le-document-a-la-selection', + 'record_id' => $this->_model->getId(), + 'id' => $this->_selection->getId()]); + return new Intonation_Library_Link(['Text' => $this->_('Ajouter'), - 'Attribs' => ['onclick' => '$(this).closest(\'.card\').slideUp();return true;', + 'Attribs' => ['onclick' => sprintf('$.ajax(\'%s\');$(this).closest(\'.card\').addClass(\'border border-success\').slideUp(1000);', + $url), 'style' => 'cursor: pointer;'], 'Title' => $this->_('Ajouter le document %s à la sélection %s', $this->getMainTitle(), diff --git a/library/templates/Intonation/Library/View/Wrapper/Review.php b/library/templates/Intonation/Library/View/Wrapper/Review.php index 898737be0f295231ca513b49589dc7814e1f8434..e826e093269253b9e531b80140b2b4e1d463cb1e 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Review.php +++ b/library/templates/Intonation/Library/View/Wrapper/Review.php @@ -39,9 +39,12 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra public function getSecondaryTitle() { - return $this->_model->isMine() - ? $this->_('Vous') + $author = $this->_model->isMine() + ? $this->_('vous') : $this->_model->getAuthorName(); + + return $this->_('Écrit par %s', + $author); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php index d143a95c031a5dff3cd2615393224302eddb306b..d65354f84242b3d59ca5697f7f7b3a8aa912e414 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php @@ -30,7 +30,8 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { $_model, $_content, $_visible = false, - $_ajax = false; + $_ajax = false, + $_is_active = false; public function setView($view) { @@ -77,6 +78,17 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { } + public function beActive() { + $this->_is_active = true; + return $this; + } + + + public function getActiveClass() { + return $this->_is_active ? 'active' : ''; + } + + abstract public function getTitle(); abstract public function getContent(); abstract public function getClass(); diff --git a/library/templates/Intonation/Library/View/Wrapper/Search.php b/library/templates/Intonation/Library/View/Wrapper/Search.php index 8819927f71af4116da15726e33431650a3705166..0fb26b7ee7c49c46f3b78ee8da3be1b453630c39 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Search.php +++ b/library/templates/Intonation/Library/View/Wrapper/Search.php @@ -110,6 +110,11 @@ class Intonation_Library_View_Wrapper_Search extends Intonation_Library_View_Wra } + public function getFullDescription() { + return $this->getDescription(); + } + + public function getDescriptionTitle() { return $this->_('Détail des critères de recherche'); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index ac904aa0844bba6aadc3b23acefcd1a6a0ede783..accb0eaab9f865c815e9181fb58e732a3b9a06fe 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -60,6 +60,20 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ } + public function getFullDescription() { + $records = $this->_model->getNoticesAsArray(); + + $records_title = []; + foreach ($records as $record) + $records_title [] = $record->getTitrePrincipal(' '); + + return $this->getBadges() + . BR + . $this->_('Liste des documents : %s', + implode(', ', $records_title)); + } + + public function getDescriptionTitle() { return ''; } @@ -69,11 +83,11 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', 'action' => 'selection', 'id' => $this->_model->getId()]), - 'Text' => $this->_('Voir'), - 'Title' => $this->_('Voir la sélection'), + 'Text' => $this->_('Gérer'), + 'Title' => $this->_('Gérer la sélection'), 'Image' => Class_Template::current()->getIco($this->_view, - 'search_more', - 'library')]); + 'check-list', + 'utils')]); } @@ -119,9 +133,10 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ public function getActions() { $actions = [new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', - 'action' => 'exporter-selection', - 'id' => $this->_model->getId()]), + 'action' => 'exporter-la-selection', + 'selection_id' => $this->_model->getId()]), 'Text' => $this->_('Exporter'), + 'Popup' => true, 'Title' => $this->_('Exporter la sélection %s', $this->_model->getLibelle()), 'Image' => Class_Template::current()->getIco($this->_view, @@ -136,7 +151,16 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ $this->_model->getLibelle()), 'Image' => Class_Template::current()->getIco($this->_view, 'add', - 'utils')])]; + 'utils')]), + + new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'recherche', + 'action' => 'simple', + 'id_panier' => $this->_model->getId()]), + 'Text' => $this->_('Voir'), + 'Title' => $this->_('Voir la sélection dans la recherche'), + 'Image' => Class_Template::current()->getIco($this->_view, + 'search_more', + 'library')])]; if ((new Intonation_Library_UserPatcher)->isSelectionDefault($this->_model)) return $actions; diff --git a/library/templates/Intonation/Library/View/Wrapper/User.php b/library/templates/Intonation/Library/View/Wrapper/User.php index 377cd559f5d8601484d3a38365fcd159ff5ead32..2ac35340ad4639c6ae0466802c4fd6a8fc828a50 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User.php +++ b/library/templates/Intonation/Library/View/Wrapper/User.php @@ -76,6 +76,11 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp } + public function getFullDescription() { + return $this->getDescription(); + } + + public function getDescriptionTitle() { return $this->_('Mes Informations'); } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/AddRecordsToSelection.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/AddRecordsToSelection.php new file mode 100644 index 0000000000000000000000000000000000000000..05b20540f8a630c26a1ef4bca5a2c85d5fae9101 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/AddRecordsToSelection.php @@ -0,0 +1,94 @@ +<?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_View_Wrapper_User_RichContent_AddRecordsToSelection extends Intonation_Library_View_Wrapper_User_RichContent_Selections { + + protected $_criteria, + $_selection; + + + public function setCriteria($criteria) { + $this->_criteria = $criteria; + return $this; + } + + + public function setSelection($selection) { + $this->_selection = $selection; + return $this; + } + + + public function getTitle() { + return $this->_('Ajouter des documents à la sélection %s', + $this->_selection->getLibelle()); + } + + + public function getContent() { + $engine = Class_MoteurRecherche::getInstance(); + + $result = $engine->lancerRecherche($this->_criteria); + + $all_records = $result->fetchRecords(); + + $records = []; + foreach ($all_records as $record) + if (!$this->_selection->contains($record)) + $records [] = $record; + + $records = array_map(function($record) + { + return (new Intonation_Library_View_Wrapper_RecordToSelect) + ->setSelection($this->_selection) + ->setModel($record) + ->setView($this->_view); + }, $records); + + $callback = function($wrapped) { + return $this->_view->cardifyWithOverlay($wrapped); + }; + + $form = (new ZendAfi_Form) + ->setMethod('GET') + ->setAction($this->_view->url()) + ->addElement('search', + 'expressionRecherche', + ['label' => $this->_('Rechercher'), + 'value' => $this->_criteria->getExpressionRecherche(), + 'id' => 'expressionRecherche' . uniqid(), + 'class' => 'expressionRecherche', + 'placeholder' => $this->_('Un titre, un auteur')]) + + ->addElement('submit', + 'search_submit', + ['label' => $this->_('Ok'), + 'onclick' => '$(this).parents(\'form\').submit()', + 'order' => 10]) + ->addUniqDisplayGroup('group'); + + return $this->_view->grid($this->_view->div(['class' => 'col-12 col-sm-6 py-3'], + $this->_view->renderInlineForm($form)) + . $this->_view->div(['class' => 'col-12'], + $this->_view->renderWall(new Storm_Collection($records), $callback))); + } +} diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/FollowASearch.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/FollowASearch.php new file mode 100644 index 0000000000000000000000000000000000000000..ca437766fd6e5c55d2d893b1e31851314d998882 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/FollowASearch.php @@ -0,0 +1,131 @@ +<?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_View_Wrapper_User_RichContent_FollowASearch extends Intonation_Library_View_Wrapper_User_RichContent_Selections { + + protected $_criteria; + + + public function setCriteria($criteria) { + $this->_criteria = $criteria; + return $this; + } + + + public function getTitle() { + return $this->_('Suivre une recherche'); + } + + + public function getContent() { + $form = (new ZendAfi_Form) + ->setMethod('GET') + ->setAction($this->_view->url()) + + ->addElement('search', + 'expressionRecherche', + ['label' => $this->_('Rechercher'), + 'id' => 'expressionRecherche' . uniqid(), + 'class' => 'expressionRecherche', + 'placeholder' => $this->_('Un titre, un auteur')]) + + ->addElement('select', 'type_doc', + ['label' => $this->_('Type de document'), + 'multiOptions' => Class_TypeDoc::getMultiOptions()]) + + ->addElement('select', 'section', + ['label' => $this->_('Section'), + 'multiOptions' => Class_CodifSection::getMultiOptions()]) + + ->addElement('cochesSuggestion', 'genre', + ['label' => $this->_('Genres'), + 'rubrique' => 'genre']) + + ->addElement('submit', + 'search_submit', + ['label' => $this->_('Rechercher'), + 'onclick' => '$(this).parents(\'form\').submit()', + 'order' => 10]) + + ->addUniqDisplayGroup('group') + + ->populate($this->_criteria->getCriteres()); + + return + $this->_view->grid($this->_view->div(['class' => 'col-12'], + $this->_view->tag('p', $this->_('Suivez une recherche pour être informé dès qu\'une nouveauté est ajoutée.')) + . $this->_view->tag('p', $this->_('Lancez une recherche puis appuyez sur le bouton suivre.'))) + . $this->_view->div(['class' => 'col-12 col-sm-8 col-md-6 mb-5'], + $this->_view->renderForm($form)) + + . $this->_getSearches($this->_model, $this->_criteria)); + } + + + protected function _getSearches($user, $criteria) { + $params = $criteria->hasExpressionRecherche() + ? [['label' => $criteria->getExpressionRecherche(), + 'criteria' => $criteria->getCriteres()]] + + : [['label' => $this->_('Les livres de Jean De Brunhoff'), + 'criteria' => ['rech_auteurs' => 'Jean De Brunhoff', + 'multifacets' => 'T1', + 'no_extension' => '1', + 'tri' => 'annee desc']], + + ['label' => $this->_('Les CD de Daft Punk'), + 'criteria' => ['rech_auteurs' => 'Daft Punk', + 'multifacets' => 'T3', + 'no_extension' => '1', + 'tri' => 'annee desc']], + + ['label' => $this->_('Les revues Science et Vie Junior'), + 'criteria' => ['rech_titres' => 'science et vie junior', + 'multifacets' => 'T2', + 'no_extension' => '1', + 'tri' => 'annee desc']], + ]; + + $result_header = $criteria->hasExpressionRecherche() + ? $this->_view->tag('h5', + $this->_('Résultat de la recherche :')) + : $this->_view->tag('h5', + $this->_('Exemples de recherches :')); + + $searches = []; + foreach ($params as $param) + $searches [] = + (new Intonation_Library_View_Wrapper_Search) + ->setModel((new Class_User_BookmarkedSearch) + ->setLabel($param['label']) + ->setCriterias((new Class_CriteresRecherche)->setParams($param['criteria']))) + ->setView($this->_view); + + $callback = function($search) { + return $this->_view->cardifyHorizontal($search); + }; + + return $this->_view->div(['class' => 'col-12'], + $result_header + . $this->_view->renderList(new Storm_Collection($searches), $callback)); + } +} diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/RateRecords.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/RateRecords.php new file mode 100644 index 0000000000000000000000000000000000000000..6b3eec62530ef65ed201c9053bedacf49277da99 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/RateRecords.php @@ -0,0 +1,117 @@ +<?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_View_Wrapper_User_RichContent_RateRecords extends Intonation_Library_View_Wrapper_User_RichContent_Reviews { + + protected $_criteria; + + + public function setCriteria($criteria) { + $this->_criteria = $criteria; + return $this; + } + + + public function getTitle() { + return $this->_('Donner des avis'); + } + + + public function getContent() { + $criteria = $this->_criteria; + $records_to_rate = $this->_getRecordsToRate($this->getModel(), $criteria); + + $records_to_rate = array_map(function($loan) + { + return (new Intonation_Library_View_Wrapper_RecordToRate) + ->setModel($loan) + ->setView($this->_view); + }, $records_to_rate); + + $callback = function($wrapped) { + return $this->_view->cardifyHorizontal($wrapped); + }; + + $form = (new ZendAfi_Form) + ->setMethod('GET') + ->setAction($this->_view->url()) + ->addElement('search', + 'expressionRecherche', + ['label' => $this->_('Rechercher'), + 'value' => $criteria->getExpressionRecherche(), + 'id' => 'expressionRecherche' . uniqid(), + 'class' => 'expressionRecherche', + 'placeholder' => $this->_('Un titre, un auteur')]) + + ->addElement('submit', + 'search_submit', + ['label' => $this->_('Ok'), + 'onclick' => '$(this).parents(\'form\').submit()', + 'order' => 10]) + + ->addUniqDisplayGroup('group'); + + return + $this->_view->grid($this->_view->div(['class' => 'col-12 col-sm-6 py-3'], + $this->_view->renderInlineForm($form)) + + . $this->_view->div(['class' => 'col-12'], + $this->_view->renderList(new Storm_Collection($records_to_rate), + $callback))); + } + + + protected function _getRecordsToRate($user, $criteria) { + if ($criteria->hasExpressionRecherche()) { + $engine = Class_MoteurRecherche::getInstance(); + + $result = $engine->lancerRecherche($criteria); + + return $this->_removeRated($result->fetchRecords(), $user); + } + + $cards = new Class_User_Cards($user); + $loans = $cards->getLoans()->getArrayCopy(); + $loans = array_merge($loans, $user->getLoansHistory()->getArrayCopy()); + $records_to_rate = []; + + foreach ($loans as $loan) + $records_to_rate [] = $loan->getNoticeOPAC(); + + if (empty($records_to_rate)) + $records_to_rate = Class_Notice::findAllBy(['limit' => 10, + 'order' => 'date_maj']); + + return $this->_removeRated($records_to_rate, $user); + } + + + protected function _removeRated($records, $user) { + $unrated_records = []; + foreach ($records as $record) + if (!Class_AvisNotice::findFirstBy(['id_user' => $user->getId(), + 'clef_oeuvre' => $record->getClefOeuvre()])) + $unrated_records [] = $record; + + return $unrated_records; + } +} diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php index 4129a4888882c1e834b3d3c4fdf40ba1cafcc90e..45d057357fcba62fc501f7d164ea8e9cb2baf097 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php @@ -40,11 +40,15 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio ->setView($this->_view); }, $reviews); - $callback = function($wrapped) { - return $this->_view->cardifyHorizontal($wrapped); - }; + $actions = [new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', + 'action' => 'donner-des-avis']), + 'Text' => $this->_('Écrire'), + 'Title' => $this->_('Écrire un avis'), + 'Image' => Class_Template::current()->getIco($this->_view, + 'add', + 'utils')])]; - return $this->_view->renderTruncateList(new Storm_Collection($reviews), $callback); + return $this->_view->renderCollection(new Storm_Collection($reviews), $actions); } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php index 2ca9552f089320a9b517d84a50c58a3c333f0c38..53f5563346ca801fcfcfafa92a581d6022e98cb3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php @@ -20,7 +20,7 @@ */ -class Intonation_Library_View_Wrapper_User_RichContent_Selection extends Intonation_Library_View_Wrapper_User_RichContent_Section { +class Intonation_Library_View_Wrapper_User_RichContent_Selection extends Intonation_Library_View_Wrapper_User_RichContent_Selections { public function getTitle() { return $this->_('La sélection %s', @@ -57,26 +57,4 @@ class Intonation_Library_View_Wrapper_User_RichContent_Selection extends Intonat return $this->_view->grid(implode($html)); } - - - public function getClass() { - return 'user_selections'; - } - - - public function getNavUrl() { - return ['controller' => 'abonne', - 'action' => 'selection']; - } - - - public function getNavIco() { - return 'selection'; - } - - - public function getNavTitle() { - return $this->_('La sélection sélection %s', - $this->_model->getLibelle()); - } } diff --git a/library/templates/Intonation/View/Abonne.php b/library/templates/Intonation/View/Abonne.php index 15ad274f627847c300c621f7483890babb0f0f4c..b743e4f9d2e6d53df2a5bacbff5e909d3feee645 100644 --- a/library/templates/Intonation/View/Abonne.php +++ b/library/templates/Intonation/View/Abonne.php @@ -46,6 +46,7 @@ class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper { protected function _showSections($sections) { + $sections[0]->beActive(); foreach($sections as $section) $section->beVisible(); } diff --git a/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php b/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php index 0d0a53085712e4d6b31dbdd2123ad1db42242c64..40930f83eeaa0d555318de5f52bc0514b7987349 100644 --- a/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php +++ b/library/templates/Intonation/View/Abonne/AddRecordsToSelection.php @@ -20,58 +20,39 @@ */ -class Intonation_View_Abonne_AddRecordsToSelection extends ZendAfi_View_Helper_BaseHelper { - public function abonne_AddRecordsToSelection($user, $selection, $criteria) { - $this->view->titre = $this->_('Ajouter des documents à la sélection %s', - $selection->getLibelle()); +class Intonation_View_Abonne_AddRecordsToSelection extends Intonation_View_Abonne { - $engine = Class_MoteurRecherche::getInstance(); + protected $_selection, + $_criteria; - $result = $engine->lancerRecherche($criteria); - $all_records = $result->fetchRecords(); + public function abonne_AddRecordsToSelection($user, $selection, $criteria) { + $this->_criteria = $criteria; + $this->_selection = $selection; + + $html = $this->abonne($user); + $this->view->titre = $this->_('%s : Ajouter des documents à la sélection %s', + $this->view->titre, + $selection->getLibelle()); + return $html; + } - $records = []; - foreach ($all_records as $record) - if (!$selection->contains($record)) - $records [] = $record; - $records = array_map(function($record) use ($selection) - { - return (new Intonation_Library_View_Wrapper_RecordToSelect) - ->setSelection($selection) - ->setModel($record) - ->setView($this->view); - }, $records); + protected function _showSections($sections) { + } - $callback = function($wrapped) { - return $this->view->cardifyWithOverlay($wrapped); - }; - $form = (new ZendAfi_Form) - ->setMethod('GET') - ->setAction($this->view->url()) - ->addElement('search', - 'expressionRecherche', - ['label' => $this->_('Rechercher'), - 'value' => $criteria->getExpressionRecherche(), - 'id' => 'expressionRecherche' . uniqid(), - 'class' => 'expressionRecherche', - 'placeholder' => $this->_('Un titre, un auteur')]) + protected function _hookOn($rich_content) { + $sections = $rich_content->getSections(); - ->addElement('submit', - 'search_submit', - ['label' => $this->_('Ok'), - 'onclick' => '$(this).parents(\'form\').submit()', - 'order' => 10]) - ->addUniqDisplayGroup('group'); + $sections [4] = (new Intonation_Library_View_Wrapper_User_RichContent_AddRecordsToSelection) + ->setModel($rich_content->getModel()) + ->setCriteria($this->_criteria) + ->setSelection($this->_selection) + ->setView($this->view) + ->beActive() + ->beVisible(); - return $this->view->grid( - $this->view->div(['class' => 'col-12'], - $this->_tag('h1', $this->view->titre)) - . $this->view->div(['class' => 'col-12 col-sm-6 py-3'], - $this->view->renderInlineForm($form)) - . $this->view->div(['class' => 'col-12'], - $this->view->renderWall(new Storm_Collection($records), $callback))); + $rich_content->setSections($sections); } } diff --git a/library/templates/Intonation/View/Abonne/ChangeImage.php b/library/templates/Intonation/View/Abonne/ChangeImage.php index 756bdbbdc87f84d2c21087dc631681e4efcfdaa9..7344a8722218b24713cc5aef394188237f8a108d 100644 --- a/library/templates/Intonation/View/Abonne/ChangeImage.php +++ b/library/templates/Intonation/View/Abonne/ChangeImage.php @@ -35,6 +35,7 @@ class Intonation_View_Abonne_ChangeImage extends Intonation_View_Abonne { $sections [6] = (new Intonation_Library_View_Wrapper_User_RichContent_ChangeImage) ->setModel($this->view->user) ->setView($this->view) + ->beActive() ->beVisible(); $rich_content->setSections($sections); diff --git a/library/templates/Intonation/View/Abonne/ConfigurationsBoard.php b/library/templates/Intonation/View/Abonne/ConfigurationsBoard.php index c9953b0edfc5421d24b6645ae3ce3e71bf0c6119..33be6930ae5b6579d0f04357bf82aad7d9ee72ae 100644 --- a/library/templates/Intonation/View/Abonne/ConfigurationsBoard.php +++ b/library/templates/Intonation/View/Abonne/ConfigurationsBoard.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_ConfigurationsBoard extends Intonation_View_Abonne protected function _showSections($sections) { foreach($sections as $section) if ('user_settings' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/Edit.php b/library/templates/Intonation/View/Abonne/Edit.php index e47ec97f451000208e6914003f670291cf6b0653..7094d5ddb4eff2261fe19ed3c6cdf4a0b034a40e 100644 --- a/library/templates/Intonation/View/Abonne/Edit.php +++ b/library/templates/Intonation/View/Abonne/Edit.php @@ -40,6 +40,7 @@ class Intonation_View_Abonne_Edit extends Intonation_View_Abonne { ->setModel($this->view->user) ->setView($this->view) ->setContent($this->view->renderForm($this->view->form)) + ->beActive() ->beVisible(); $rich_content->setSections($sections); diff --git a/library/templates/Intonation/View/Abonne/FollowASearch.php b/library/templates/Intonation/View/Abonne/FollowASearch.php index f20024d231e07e3907eda7ff11c534bcb0857dc5..c521ca955ede72126eff2fb863898e1c45c4b88c 100644 --- a/library/templates/Intonation/View/Abonne/FollowASearch.php +++ b/library/templates/Intonation/View/Abonne/FollowASearch.php @@ -20,53 +20,32 @@ */ -class Intonation_View_Abonne_FollowASearch extends ZendAfi_View_Helper_BaseHelper { - public function abonne_FollowASearch($user) { - $this->view->titre = $this->_('Suivre une recherche'); +class Intonation_View_Abonne_FollowASearch extends Intonation_View_Abonne { - $callback = function($search) { - return $this->view->cardify($search); - }; + public function abonne_FollowASearch($user, $criteria) { + $this->_criteria = $criteria; - return - $this->view->grid( $this->_div(['class' => 'col-12'], - $this->_tag('h1', $this->view->titre)) - . $this->_div(['class' => 'col-12'], - $this->_tag('p', $this->_('Suivez une recherche pour être informé dès qu\'une nouveauté est ajoutée.'))) - . $this->_div(['class' => 'col-12'], - $this->view->renderList($this->_getSearches($user), $callback))); + $html = $this->abonne($user); + $this->view->titre = $this->_('%s : Suivre une recherches', + $this->view->titre); + return $html; } - protected function _getSearches($user) { - $params = [['label' => $this->_('Les livres de Jean De Brunhoff'), - 'criteria' => ['rech_auteurs' => 'Jean De Brunhoff', - 'multifacets' => 'T1', - 'no_extension' => '1', - 'tri' => 'annee desc']], + protected function _showSections($sections) { + } - ['label' => $this->_('Les CD de Daft Punk'), - 'criteria' => ['rech_auteurs' => 'Daft Punk', - 'multifacets' => 'T3', - 'no_extension' => '1', - 'tri' => 'annee desc']], - ['label' => $this->_('Les revues Science et Vie Junior'), - 'criteria' => ['rech_titres' => 'science et vie junior', - 'multifacets' => 'T2', - 'no_extension' => '1', - 'tri' => 'annee desc']], - ]; + protected function _hookOn($rich_content) { + $sections = $rich_content->getSections(); - $searches = []; - foreach ($params as $param) - $searches [] = - (new Intonation_Library_View_Wrapper_Search) - ->setModel((new Class_User_BookmarkedSearch) - ->setLabel($param['label']) - ->setCriterias((new Class_CriteresRecherche)->setParams($param['criteria']))) - ->setView($this->view); + $sections [4] = (new Intonation_Library_View_Wrapper_User_RichContent_FollowASearch) + ->setModel($rich_content->getModel()) + ->setCriteria($this->_criteria) + ->setView($this->view) + ->beActive() + ->beVisible(); - return new Storm_Collection($searches); + $rich_content->setSections($sections); } } diff --git a/library/templates/Intonation/View/Abonne/HoldsBoard.php b/library/templates/Intonation/View/Abonne/HoldsBoard.php index a9156c6408d129c50bbbd390ff10bfffbe5c1e43..b10dd9abb551476e8b464cee787da8bda0fbc2b5 100644 --- a/library/templates/Intonation/View/Abonne/HoldsBoard.php +++ b/library/templates/Intonation/View/Abonne/HoldsBoard.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_HoldsBoard extends Intonation_View_Abonne { protected function _showSections($sections) { foreach($sections as $section) if ('user_holds' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/Informations.php b/library/templates/Intonation/View/Abonne/Informations.php index 363fcfc6ecc8f4f7fa2d52dbef58095651c89f16..4bfeadb91f83311cd894248e38f4e753a90a9268 100644 --- a/library/templates/Intonation/View/Abonne/Informations.php +++ b/library/templates/Intonation/View/Abonne/Informations.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_Informations extends Intonation_View_Abonne { protected function _showSections($sections) { foreach($sections as $section) if ('user_informations' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } diff --git a/library/templates/Intonation/View/Abonne/LoansBoard.php b/library/templates/Intonation/View/Abonne/LoansBoard.php index 59d3fcde5253d21438f5b27cc3943780d4d2cb84..156e34f6cc36f333b61798c17e60c96d54134757 100644 --- a/library/templates/Intonation/View/Abonne/LoansBoard.php +++ b/library/templates/Intonation/View/Abonne/LoansBoard.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_LoansBoard extends Intonation_View_Abonne { protected function _showSections($sections) { foreach($sections as $section) if ('user_loans' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/RateRecords.php b/library/templates/Intonation/View/Abonne/RateRecords.php index 2d3b6473de54790b2ff754943957f5ffa6defbdc..3fe7b34f27913eeabca34014a59ec75287866e90 100644 --- a/library/templates/Intonation/View/Abonne/RateRecords.php +++ b/library/templates/Intonation/View/Abonne/RateRecords.php @@ -20,48 +20,32 @@ */ -class Intonation_View_Abonne_RateRecords extends ZendAfi_View_Helper_BaseHelper { - public function abonne_RateRecords($user) { - $this->view->titre = $this->_('Donner des avis'); - - $cards = new Class_User_Cards($user); - $loans = $cards->getLoans()->getArrayCopy(); - $loans = array_merge($loans, $user->getLoansHistory()->getArrayCopy()); - $records_to_rate = []; - - foreach ($loans as $loan) - $records_to_rate [] = $loan->getNoticeOPAC(); - - if (empty($records_to_rate)) - $records_to_rate = Class_Notice::findAllBy(['limit' => 10, - 'order' => 'date_maj']); - - $records_to_rate = $this->_removeRated($records_to_rate, $user); - - $records_to_rate = array_map(function($loan) - { - return (new Intonation_Library_View_Wrapper_RecordToRate) - ->setModel($loan) - ->setView($this->view); - }, $records_to_rate); +class Intonation_View_Abonne_RateRecords extends Intonation_View_Abonne { + protected $_criteria; + + public function abonne_RateRecords($user, $criteria) { + $this->_criteria = $criteria; + $html = $this->abonne($user); + $this->view->titre = $this->_('%s : Donner des avis', + $this->view->titre); + return $html; + } - $callback = function($wrapped) { - return $this->view->cardifyHorizontal($wrapped); - }; - return - $this->_tag('h1', $this->view->titre) - . $this->view->renderCarousel(new Storm_Collection($records_to_rate), $callback); + protected function _showSections($sections) { } - protected function _removeRated($records, $user) { - $unrated_records = []; - foreach ($records as $record) - if (!Class_AvisNotice::findFirstBy(['id_user' => $user->getId(), - 'clef_oeuvre' => $record->getClefOeuvre()])) - $unrated_records [] = $record; + protected function _hookOn($rich_content) { + $sections = $rich_content->getSections(); + + $sections [5] = (new Intonation_Library_View_Wrapper_User_RichContent_RateRecords) + ->setModel($rich_content->getModel()) + ->setCriteria($this->_criteria) + ->setView($this->view) + ->beActive() + ->beVisible(); - return $unrated_records; + $rich_content->setSections($sections); } } diff --git a/library/templates/Intonation/View/Abonne/ReviewsBoard.php b/library/templates/Intonation/View/Abonne/ReviewsBoard.php index b6e8def92e86844c73db0752a156d4201d4a1d77..898ef97a9e6c2a9f7adac41ff76d9903354302aa 100644 --- a/library/templates/Intonation/View/Abonne/ReviewsBoard.php +++ b/library/templates/Intonation/View/Abonne/ReviewsBoard.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_ReviewsBoard extends Intonation_View_Abonne { protected function _showSections($sections) { foreach($sections as $section) if ('user_reviews' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/SelectionBoard.php b/library/templates/Intonation/View/Abonne/SelectionBoard.php index 5d6b3e01b4ec0aa809453351f656cc7fe9bdcb28..7018a4417f43e6e77041f448af149b61a1a60490 100644 --- a/library/templates/Intonation/View/Abonne/SelectionBoard.php +++ b/library/templates/Intonation/View/Abonne/SelectionBoard.php @@ -41,6 +41,7 @@ class Intonation_View_Abonne_SelectionBoard extends Intonation_View_Abonne { $sections [4] = (new Intonation_Library_View_Wrapper_User_RichContent_Selection) ->setModel($this->view->selection) ->setView($this->view) + ->beActive() ->beVisible(); $rich_content->setSections($sections); diff --git a/library/templates/Intonation/View/Abonne/Selections.php b/library/templates/Intonation/View/Abonne/Selections.php index e930080de9df8b926ea1219287767e2102e7f9bf..c312508932f2997ec56c41b15dfcf91a27491619 100644 --- a/library/templates/Intonation/View/Abonne/Selections.php +++ b/library/templates/Intonation/View/Abonne/Selections.php @@ -34,6 +34,7 @@ class Intonation_View_Abonne_Selections extends ZendAfi_View_Helper_BaseHelper { $actions = [new Intonation_Library_Link(['Url' => $this->view->url(['controller' => 'abonne', 'action' => 'creer-selection']), + 'Popup' => true, 'Text' => $this->_('Créer'), 'Title' => $this->_('Créer une nouvelle sélection'), 'Image' => Class_Template::current()->getIco($this->view, diff --git a/library/templates/Intonation/View/Abonne/SelectionsBoard.php b/library/templates/Intonation/View/Abonne/SelectionsBoard.php index 4642c4941335855c33ba25caeefab3a5e11e8534..7073a617bbd5f8f835351673e38291a3d6f611fc 100644 --- a/library/templates/Intonation/View/Abonne/SelectionsBoard.php +++ b/library/templates/Intonation/View/Abonne/SelectionsBoard.php @@ -32,6 +32,8 @@ class Intonation_View_Abonne_SelectionsBoard extends Intonation_View_Abonne { protected function _showSections($sections) { foreach($sections as $section) if ('user_selections' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abstract/Carousel.php b/library/templates/Intonation/View/Abstract/Carousel.php index 50656e51a6a9ca86ef2bac44b930eb884497d8a1..025e5ab0d46317c8110d993d3f192c0e07f4cdc5 100644 --- a/library/templates/Intonation/View/Abstract/Carousel.php +++ b/library/templates/Intonation/View/Abstract/Carousel.php @@ -50,13 +50,13 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas for ($i = 0; $i < $count; $i++) $lis [] = $this->_tag('li', '', - ['class' => (($i == 0) ? 'active' : ''), + ['class' => 'bg-dark ' . (($i == 0) ? 'active' : ''), 'data-target' => '#' . $id, 'data-slide-to' => $i]); return $this->_tag('ol', implode($lis), - ['class' => 'carousel-indicators rounded']); + ['class' => 'carousel-indicators']); } @@ -85,7 +85,7 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas ['href' => '#' . $id, 'data-slide' => 'prev', 'role' => 'button', - 'class' => 'carousel-control-prev']) + 'class' => 'carousel-control-prev text-dark px-3']) . $this->_tag('a', Class_Template::current()->getIco($this->view, 'next', 'utils', ['class' => 'ico_xl']) @@ -93,7 +93,7 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas ['href' => '#' . $id, 'data-slide' => 'next', 'role' => 'button', - 'class' => 'carousel-control-next']); + 'class' => 'carousel-control-next text-dark px-3']); } diff --git a/library/templates/Intonation/View/CardifyFullDescription.php b/library/templates/Intonation/View/CardifyFullDescription.php index 28f48c9dc5750ffb7605f5116d41c12a760e8623..d6e1a0c9e824e9a3a1db1f2534b439d5b3892d17 100644 --- a/library/templates/Intonation/View/CardifyFullDescription.php +++ b/library/templates/Intonation/View/CardifyFullDescription.php @@ -26,9 +26,9 @@ class Intonation_View_CardifyFullDescription extends ZendAfi_View_Helper_BaseHel $content = [$element->getContentForJSSearch()]; if ($title = $element->getMainTitle()) - $content [] = $title = $this->_tag('h5', - $title, - ['class' => 'card-title']); + $content [] = $this->_tag('h5', + $title, + ['class' => 'card-title']); if ($author_name = $element->getSecondaryTitle()) $content [] = $this->_tag('h6', @@ -49,6 +49,20 @@ class Intonation_View_CardifyFullDescription extends ZendAfi_View_Helper_BaseHel implode($content), ['class' => 'card-body']); + $links = []; + if ($link = $element->getMainLink()) + $links [] = $this->view->tagAction($link); + + foreach($element->getActions() as $action) + $links [] = is_string($action) + ? $action + : $this->view->tagAction($action); + + if (!empty($links)) + $html [] = $this->_tag('div', + implode($links), + ['class' => 'card-footer d-flex flex-column flex-md-row justify-content-between']); + return $this->view->div(['class' => 'card'], implode($html)); } diff --git a/library/templates/Intonation/View/Jumbotron.php b/library/templates/Intonation/View/Jumbotron.php index 307a98708f3848fab84386c4324beedf02f43715..ee3e8e23c051dcd695db102d2c8a9d53b1b5de74 100644 --- a/library/templates/Intonation/View/Jumbotron.php +++ b/library/templates/Intonation/View/Jumbotron.php @@ -31,8 +31,10 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { $this->_element = $element; $this->_current_url = $this->view->url(); + $content = $this->_renderContent(); + $html = [$this->_renderHead(), - $this->_renderContent()]; + $content]; return implode($html); } @@ -139,7 +141,7 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { $id = $item->getModel()->getId(); $params = ['title' => $item->getNavTitle(), - 'class' => 'nav-link' . ((false !== strpos($this->_current_url, implode('/', $item->getNavUrl()))) ? ' active' : '') . ' ' . $item->getClass()]; + 'class' => 'nav-link ' . $item->getClass() . ' ' . $item->getActiveClass()]; if ($item->isAjax() || (!$item->getContent())) $params ['class'] .= ' disabled text-black-50'; diff --git a/library/templates/Intonation/View/Notice/Reviews.php b/library/templates/Intonation/View/Notice/Reviews.php index 59bafa4681bad6e39f366250df8bdf985c800401..0c11efe01804827c0295acff33817ff9780ffd96 100644 --- a/library/templates/Intonation/View/Notice/Reviews.php +++ b/library/templates/Intonation/View/Notice/Reviews.php @@ -75,10 +75,13 @@ class Intonation_View_Notice_Reviews extends ZendAfi_View_Helper_BaseHelper { if ($me->getFirstAvisByIdNotice($this->_record->getId())) return ''; - return $this->_div(['class' => 'col-12'], - $this->_tag('h3', $this->_('Donnez votre avis'), ['class' => 'card-title']) - . $this->_div(['class' => 'card'], - $this->_div(['class' => 'card-body'], - $this->view->renderReviewForm(new Class_AvisNotice)))); + $new_review = (new Class_AvisNotice)->setNotice($this->_record); + + return + $this->_div(['class' => 'col-12'], + $this->_tag('h3', $this->_('Donnez votre avis'), ['class' => 'card-title']) + . $this->_div(['class' => 'card'], + $this->_div(['class' => 'card-body'], + $this->view->renderReviewForm($new_review)))); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index 23303a3849756b99fb1d5c9b30efd2d02009f2f7..3290c1de23f220a126e5a8f4f7a17c78b43be567 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -42,7 +42,9 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _showSections($sections) { + $sections[0]->beActive(); foreach($sections as $section) - $section->beVisible(); + $section + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Author.php b/library/templates/Intonation/View/RenderRecord/Author.php index e62094ac590483581e52ed9e07d342a330ae4fab..d6bc1417916913cb3b1f49a5967f37ccd3c28c12 100644 --- a/library/templates/Intonation/View/RenderRecord/Author.php +++ b/library/templates/Intonation/View/RenderRecord/Author.php @@ -34,6 +34,8 @@ class Intonation_View_RenderRecord_Author extends Intonation_View_RenderRecord { protected function _showSections($sections) { foreach($sections as $section) if ('document_author' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Description.php b/library/templates/Intonation/View/RenderRecord/Description.php index fc2c5f107df1676c661b3e436641ecae1dc98d48..d03d98abe8606c9c0b397f4a37cfb00fc50fb525 100644 --- a/library/templates/Intonation/View/RenderRecord/Description.php +++ b/library/templates/Intonation/View/RenderRecord/Description.php @@ -23,7 +23,8 @@ class Intonation_View_RenderRecord_Description extends Intonation_View_RenderRecord { public function RenderRecord_Description($record) { $html = $this->renderRecord($record); - $this->view->titre = $this->_('%s : Description'); + $this->view->titre = $this->_('%s : Description', + $this->view->titre); return $html; } @@ -31,6 +32,8 @@ class Intonation_View_RenderRecord_Description extends Intonation_View_RenderRec protected function _showSections($sections) { foreach($sections as $section) if ('description' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Media.php b/library/templates/Intonation/View/RenderRecord/Media.php index 686d57a469ba3808273d1963c59873477d9e0750..d76c6d46c25f2f26b2b3c1fcfdc48d86ffdbe6cb 100644 --- a/library/templates/Intonation/View/RenderRecord/Media.php +++ b/library/templates/Intonation/View/RenderRecord/Media.php @@ -32,6 +32,8 @@ class Intonation_View_RenderRecord_Media extends Intonation_View_RenderRecord { protected function _showSections($sections) { foreach($sections as $section) if ('document_media' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Related.php b/library/templates/Intonation/View/RenderRecord/Related.php index 07fb812c4fee76ee0f340f26e0fc3b670dad89bd..7a5c99bdd237b12c799a265443a8f90444ae5e7b 100644 --- a/library/templates/Intonation/View/RenderRecord/Related.php +++ b/library/templates/Intonation/View/RenderRecord/Related.php @@ -33,6 +33,8 @@ class Intonation_View_RenderRecord_Related extends Intonation_View_RenderRecord protected function _showSections($sections) { foreach($sections as $section) if ('related' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Reviews.php b/library/templates/Intonation/View/RenderRecord/Reviews.php index fbbfa53edf2d0af690e807e6a5fa5d5af36341fc..b974a4d2a5d21e631496ac2bcae7d9e2824dd9af 100644 --- a/library/templates/Intonation/View/RenderRecord/Reviews.php +++ b/library/templates/Intonation/View/RenderRecord/Reviews.php @@ -33,6 +33,8 @@ class Intonation_View_RenderRecord_Reviews extends Intonation_View_RenderRecord protected function _showSections($sections) { foreach($sections as $section) if ('reviews' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Summary.php b/library/templates/Intonation/View/RenderRecord/Summary.php index cc274fb7c6704f0288abc5eaa2e768ce8bb554f8..2bba5e032b95c8d4d0677b0f9d60a9c037dcbf4a 100644 --- a/library/templates/Intonation/View/RenderRecord/Summary.php +++ b/library/templates/Intonation/View/RenderRecord/Summary.php @@ -33,6 +33,8 @@ class Intonation_View_RenderRecord_Summary extends Intonation_View_RenderRecord protected function _showSections($sections) { foreach($sections as $section) if ('summary' == $section->getClass()) - return $section->beVisible(); + return $section + ->beActive() + ->beVisible(); } } diff --git a/library/templates/Intonation/View/RenderReviewForm.php b/library/templates/Intonation/View/RenderReviewForm.php index cba2b0edaf5ad1d27f4833e8d8b38d67c1cd8e1e..86635146ea2b8ee57dc48b6040b71938463f310b 100644 --- a/library/templates/Intonation/View/RenderReviewForm.php +++ b/library/templates/Intonation/View/RenderReviewForm.php @@ -21,7 +21,7 @@ class Intonation_View_RenderReviewForm extends ZendAfi_View_Helper_BaseHelper { - public function renderReviewForm($review) { + public function renderReviewForm($review, $ajax = false) { if (!$record = $review->getFirstNotice()) return ''; @@ -31,10 +31,38 @@ class Intonation_View_RenderReviewForm extends ZendAfi_View_Helper_BaseHelper { 'record_key' => $record->getClefOeuvre(), 'id' => $review->getId()]; - $form = ZendAfi_Form_Review::newWith($review->toArray()) - ->setAction($this->view->url($params,null,true)); - + $form = ZendAfi_Form_Review::newWith($review->toArray()); $form->getElement('entete')->setValue($record->getTitrePrincipal(' ')); + + if ($ajax) { + $form->addElement('submit', + 'submit' . $form->getAttrib('id'), + ['label' => $this->_('Valider')]); + + Class_ScriptLoader::getInstance() + ->addJQueryReady( + sprintf(' +$("#%s").submit(function(e) { +e.preventDefault(); +e.stopPropagation(); +var form = $(this); +var url = form.attr("action"); +$.ajax( + {type: "POST", + url: url, + data: form.serialize(), + success: function(data) { + var li = form.closest(".list-group-item"); + li.find(".card").addClass("bg-success"); + li.slideUp(1000); + }}); +});', $form->getAttrib('id'))); + + $params['action'] = 'ajax-review'; + } + + $form->setAction($this->view->url($params, null, true)); + return $this->view->renderForm($form); } } diff --git a/library/templates/Intonation/View/RenderUserBadges.php b/library/templates/Intonation/View/RenderUserBadges.php index ba9ed5b49e987b509618ac94ae39c6abe22edfe3..b232f95b3ef26b4f6b3c0a43b51a2583d5b31b18 100644 --- a/library/templates/Intonation/View/RenderUserBadges.php +++ b/library/templates/Intonation/View/RenderUserBadges.php @@ -142,6 +142,21 @@ class Intonation_View_RenderUserBadges extends ZendAfi_View_Helper_BaseHelper { 'title' => $this->_('Vous suivez %d recherche(s)', $number_of_searches)]; + if ($number_of_reviews = $user->numberOfAvis()) + $badges [] = ['tag' => 'a', + 'url' => $this->view->url(['controller' => 'abonne', + 'action' => 'mes-avis']), + 'class' => 'warning', + 'text' => (Class_Template::current() + ->getIco($this->view, + 'reviews', + 'library') + . $this->_('%d avis', + $number_of_reviews)), + 'title' => $this->_('Vous avez écrit %d avis', + $number_of_reviews)]; + + return $this->view->renderBadges($badges); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/TagAction.php b/library/templates/Intonation/View/TagAction.php index 8b756bf5018ad27b9051e91b1948cdf932bc32e2..637a71cc12910eefd7655dde1ed6a55720955336 100644 --- a/library/templates/Intonation/View/TagAction.php +++ b/library/templates/Intonation/View/TagAction.php @@ -22,6 +22,9 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper { public function tagAction($action) { + if (!$action) + return ''; + $attribs = ($attribs = $action->getAttribs()) ? $attribs : []; diff --git a/library/templates/Intonation/View/TagMedia.php b/library/templates/Intonation/View/TagMedia.php index 4203a5a9025ffa87798df43e0342afd3ddc6b196..c4cd5e6b13d43ac0f9f237a238799bb61b816832 100644 --- a/library/templates/Intonation/View/TagMedia.php +++ b/library/templates/Intonation/View/TagMedia.php @@ -29,12 +29,11 @@ class Intonation_View_TagMedia extends ZendAfi_View_Helper_BaseHelper { if (!$media = $this->_getMedia($instance, $attribs, $img_attribs)) return ''; - if ($img_link = $instance->getMainLink()) - return $this->view->tagAction($img_link + return ($img_link = $instance->getMainLink()) + ? $this->view->tagAction($img_link ->setText($media) - ->setImage('')); - - return ''; + ->setImage('')) + : $media; } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 16b6bb2166106a13c90ea8f13cd9f4cf56da315b..ec3437d004b60cb365eebda492ddf2349dd17d82 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1962,6 +1962,52 @@ class TemplatesAddReviewTest extends TemplatesIntonationTestCase { } +class TemplatesAddReviewAjaxTest extends TemplatesIntonationTestCase { + + protected $_review; + + + public function setUp() { + parent::setUp(); + $this->postDispatch('/opac/abonne/ajax-review/record_id/456/record_key/mykey' , + ['note' => 5, + 'entete' => '', + 'avis' => '']); + + $this->_review = Class_AvisNotice::find(1); + } + + + /** @test */ + public function noEnteteRatingShouldHaveBeenCreated() { + $this->assertNotNull($this->_review); + } + + + /** @test */ + public function ratingShouldBeSetToUser() { + $this->assertEquals(666, $this->_review->getIdUser()); + } + + + /** @test */ + public function ratingShouldBeSetToNotice() { + $this->assertEquals(456,$this->_review->getIdNotice()); + } + + /** @test */ + public function ratingShouldBeAutoModerated() { + $this->assertEquals(Trait_Avis::$STATUT_OK, $this->_review->getStatut()); + } + + /** @test */ + public function ratingRecordKeyShouldBeSaved() { + $this->assertEquals('mykey', $this->_review->getClefOeuvre()); + } + +} + + class TemplatesReviewsWidgetTest extends TemplatesIntonationTestCase { @@ -3011,10 +3057,12 @@ class TemplatesDispatchAbonneDonnerDesAvisTest extends TemplatesIntonationAccoun - class TemplatesDispatchAbonneSuivreUneRechercheTest extends TemplatesIntonationAccountTestCase { /** @test */ public function selectionMesBDShouldBeDisplay() { + $this->onLoaderOfModel('Class_TypeDoc') + ->whenCalled('findUsedTypeDocIds') + ->answers([]); $this->dispatch('/opac/abonne/suivre-une-recherche/id_profil/72'); $this->assertXPathContentContains('//div', 'Suivre une recherche'); } @@ -3047,7 +3095,7 @@ class TemplatesIntonationDispatchAbonneSelectionTest extends TemplatesIntonation /** @test */ public function exporterSelection2LinkShouldBePresent() { $this->dispatch('/opac/abonne/selection/id/2/id_profil/72'); - $this->assertXPathContentContains('//a[contains(@href, "/abonne/exporter-selection/id/2")]', 'Exporter'); + $this->assertXPathContentContains('//a[contains(@href, "/abonne/exporter-la-selection/id/2")]', 'Exporter'); } } @@ -3055,8 +3103,88 @@ class TemplatesIntonationDispatchAbonneSelectionTest extends TemplatesIntonation class TemplatesIntonationDispatchAbonneAjouterASelectionTest extends TemplatesIntonationAccountTestCase { /** @test */ - public function exporterSelection2LinkShouldBePresent() { + public function titleShouldBeAjouterDesDocumentsALaSelection() { $this->dispatch('/opac/abonne/ajouter-a-la-selection/id/2/id_profil/72'); - $this->assertXPathContentContains('//h1', 'Ajouter des documents à la sélection'); + $this->assertXPathContentContains('//h2', 'Ajouter des documents à la sélection'); + } + + + /** @test */ + public function onclickShouldContainsAddItemToSelection() { + $records = [$this->fixture('Class_Notice', + ['id' => 89]), + $this->fixture('Class_Notice', + ['id' => 99])]; + + Class_MoteurRecherche::setInstance($this->mock() + ->whenCalled('lancerRecherche') + ->answers($this->mock() + ->whenCalled('fetchRecords') + ->answers($records))); + $this->dispatch('/opac/abonne/ajouter-a-la-selection/id/2/id_profil/72'); + $this->assertXPath('//a[contains(@onclick, "abonne/ajouter-le-document-a-la-selection/id/2/id_profil/72/record_id/89")]'); + } +} + + + +class TemplatesIntonationDispatchAbonneAjouterLeDocumentALaSelectionTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function recordId89ShouldHaveBeenHadedToSelection2() { + $this->fixture('Class_Notice', + ['id' => 89, + 'titre_principal' => 'Neige', + 'type_doc' => 2, + 'clef_alpha' => 'NEIGE']); + + $this->dispatch('/opac/abonne/ajouter-le-document-a-la-selection/id/2/id_profil/72/record_id/89'); + $this->assertEquals('COMBAT ORDINAIRE;BLACKSAD;NEIGE', Class_PanierNotice::find(2)->getNotices()); + } +} + + + +class TemplatesIntonationDispatchCreerSelectionTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function dispatchCreerSelectionShouldRenderForm() { + $this->dispatch('/opac/abonne/creer-selection/id_profil/72'); + $this->assertXPathContentContains('//div', 'Titre'); + } + + + /** @test */ + public function postDispatchCreerSelectionShouldCreateMaLectureDuDimanche() { + $this->postDispatch('/opac/abonne/creer-selection/id_profil/72', + ['libelle' => 'Lecture du dimanche']); + $this->assertNotNull(Class_PanierNotice::findFirstBy(['libelle' => 'Lecture du dimanche'])); + } +} + + + +class TemplatesIntonationDispatchAbonneSupprimerDeLaSelectionTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function recordId89ShouldHaveBeenHadedToSelection2() { + $record = $this->fixture('Class_Notice', + ['id' => 89, + 'titre_principal' => 'Neige', + 'type_doc' => 2, + 'clef_alpha' => 'NEIGE']); + + Class_PanierNotice::find(2)->addNotice($record)->save(); + + $this->dispatch('/opac/abonne/supprimer-de-la-selection/selection_id/2/id_profil/72/record_id/89/delete/1'); + $this->assertEquals('COMBAT ORDINAIRE;BLACKSAD', Class_PanierNotice::find(2)->getNotices()); } -} \ No newline at end of file +} + + + + +class TemplatesIntonationDispatchAbonneExporterLaSelectionTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function buttonUnimarcShoulbBePresent() { + $this->dispatch('/opac/abonne/exporter-la-selection/selection_id/2/id_profil/72'); + $this->assertXPathContentContains('//div', 'UNIMARC'); + } +}