Commit 7cb93c66 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#64573_55_templates_pour_l_interface_publique_libraire_bootstrap' into 'master'

dev#64573 bootstrap

See merge request !3142
parents 9ba76db1 ff444c11
Pipeline #7151 passed with stage
in 35 minutes and 51 seconds
......@@ -147,9 +147,6 @@ class AbonneController extends ZendAfi_Controller_Action {
}
public function viewavisAction(){
$this->_forward('viewauteur', 'blog', 'opac', ['id' => $this->_user->getId()]);
}
......@@ -1355,7 +1352,7 @@ class AbonneController extends ZendAfi_Controller_Action {
return $this->_forward('popup-login', 'auth', 'opac');
if(!$this->_request->isPost())
return $this->_redirectToReferer();
return $this->_redirectClose($this->_getReferer());
$form = new ZendAfi_Form_Review;
......@@ -1379,7 +1376,7 @@ class AbonneController extends ZendAfi_Controller_Action {
$rating->setModerationNOK();
if (!$form->isValidModelAndArray($rating, $post))
return $this->_redirectToReferer();
return $this->_redirectClose($this->_getReferer());
if (!$rating->save())
return false;
......@@ -1388,7 +1385,37 @@ class AbonneController extends ZendAfi_Controller_Action {
$this->_getPost('note'),
5));
return $this->_redirectToReferer();
return $this->_redirectClose($this->_getReferer());
}
public function editReviewAction() {
if (!$review = Class_AvisNotice::find($this->_getParam('id', null)))
return $this->_redirectClose($this->_getReferer());
$this->view->titre = $this->_('Modifier l\'avis');
$this->view->review = $review;
}
public function deleteReviewAction() {
if (!$review = Class_AvisNotice::find($this->_getParam('id', null)))
return $this->_redirectClose($this->_getReferer());
$this->view->titre = $this->_('Supprimer l\'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é'),
['status' => 'delete']);
return $this->_redirectClose($this->_getReferer());
}
}
......
<?php
$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'],
$this->tag('h3',
$this->_('Supprimer l\'avis'),
['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->tagAnchor(['delete' => '1'],
$this->_('Oui'),
['class' => 'btn btn-danger'])))];
echo $this->grid(implode($html), [], ['class' => 'justify-content-center']);
<?php
echo $this->div(['class' => 'p-3 m-3'],
$this->renderReviewForm($this->review));
......@@ -518,4 +518,12 @@ class Class_AvisNotice extends Storm_Model_Abstract {
public function getHumanDate() {
return Class_Date::humanDate($this->getDateAvis(), 'd MMMM yyyy HH:mm');
}
public function isMine() {
if (!$user = Class_Users::getIdentity())
return false;
return $user == $this->getUser();
}
}
\ No newline at end of file
......@@ -842,6 +842,17 @@ class Class_ScriptLoader {
}
public function addSearchInputToContainer($container, $input, $toggle_selectors) {
$options = json_encode(['input' => $input,
'fixed_display' => $toggle_selectors]);
$jquery = sprintf('$("%s").search_input(%s);', $container, $options);
return $this->addOPACPluginScript('search_input/search_input.js')
->addJQueryReady($jquery);
}
public function formToTabs($node) {
return $this->addOPACPluginScript('form_to_tabs/form_to_tabs.js')
->addJQueryReady(sprintf('$("%s").form_to_tabs();',
......
......@@ -46,26 +46,70 @@ class Class_User_BookmarkedSearch extends Storm_Model_Abstract {
'notified' => 0,
'creation_date' => '',
'criterias' => '',
'id_user' => '']
;
'id_user' => ''],
$_search_result = null,
$_records = [];
public function getUnserializedCriterias() {
if(!$criterias = unserialize($this->getCriterias()))
$criterias = $this->getCriterias();
if (is_object($criterias))
return $criterias
->unsetParam('tri')
->unsetParam('page')
->unsetParam('liste_format')
->unsetParam('page_size');
if(!$criterias = unserialize($criterias))
return null;
return $criterias->unsetParam('page');
if (is_object($criterias))
return $criterias
->unsetParam('tri')
->unsetParam('page')
->unsetParam('liste_format')
->unsetParam('page_size');
return null;
}
public function getCriteriasUrl() {
if (!$criterias = $this->getUnserializedCriterias())
return '/recherche/simple';
return ['controller'=>'recherche',
'action' => 'simple'];
return $criterias->getUrlCriteresWithFacettes();
}
public function belongsTo($user) {
return $this->getIdUser() == $user->getId();
if ($this->getIdUser() == $user->getId())
return true;
return $this->getExistingFor($user) ? true : false;
}
public function getExistingFor($user) {
foreach($user->getBookmarkedSearches() as $search)
if ($search->getCriteriasUrl() == $this->getCriteriasUrl())
return $search;
return null;
}
public function getExistingIdFor($user) {
if (!$user)
return null;
if (!$search = $this->getExistingFor($user))
return null;
return $search->getId();
}
......@@ -89,6 +133,27 @@ class Class_User_BookmarkedSearch extends Storm_Model_Abstract {
}
public function getSearchResult() {
if ($this->_search_result)
return $this->_search_result;
if (!$criterias = $this->getUnserializedCriterias())
return new Class_MoteurRecherche_Result;
return $this->_search_result =
Class_MoteurRecherche::getInstance()
->lancerRecherche($criterias);
}
public function getRecords() {
if ($this->_records)
return $this->_records;
return $this->_records = $this->getSearchResult()->fetchRecords();
}
public function beforeSave() {
if ($this->isNew())
$this->setCreationDate($this->getCurrentDateTime());
......
......@@ -56,6 +56,4 @@ class ZendAfi_Controller_Action_Helper_FlashMessenger_Notification {
public function getActions() {
return $this->hasActions() ? $this->_params[self::ACTIONS] : [];
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -39,9 +39,13 @@ class ZendAfi_Controller_Plugin_Manager_BookmarkedSearches extends ZendAfi_Contr
protected function _getCriterias() {
if (!$searches = (new Class_SearchHistory())->getHistory())
return null;
$criteria = (new Class_CriteresRecherche)
->setParams($this->_request->getParams());
if (!empty($criteria->getCriteres()))
return serialize($criteria);
$searches = (new Class_SearchHistory())->getHistory();
return array_pop($searches);
}
......@@ -64,7 +68,7 @@ class ZendAfi_Controller_Plugin_Manager_BookmarkedSearches extends ZendAfi_Contr
protected function _redirectToIndex() {
return $this->_redirectClose('abonne/settings');
return $this->_redirectClose($this->_getReferer());
}
......
......@@ -21,7 +21,7 @@
class ZendAfi_View_Helper_Div extends ZendAfi_View_Helper_BaseHelper {
public function div($attributes = [], $content = []) {
public function div($attributes = [], $content = '') {
return $this->_tag('div',
$content,
$attributes);
......
......@@ -24,6 +24,6 @@ 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));
return $notice_html->getArticlesPeriodique($periodiques);
}
}
\ No newline at end of file
......@@ -444,4 +444,8 @@ header.col {
.opac .bouton.back {
display: none;
}
.card .card-columns {
column-gap: 0.05rem;
}
\ No newline at end of file
......@@ -74,12 +74,12 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'div class boutons' => 'row justify-content-around my-3',
'label' => 'col-12 col-sm-5 col-form-label col-form-label-sm pr-1',
'label class multi-element-label' => 'col-form-label col-form-label-sm',
'input' => 'mb-2 form-control form-control-sm',
'input' => 'mb-2 form-control',
'input data-spambots true' => '',
'input type checkbox' => 'form-check-input form-check-input-sm mr-1',
'input type submit' => 'btn btn-sm btn-primary',
'textarea' => 'form-control form-control-sm',
'select' => 'form-control form-control-sm custom-select',
'textarea' => 'form-control',
'select' => 'form-control form-control custom-select',
'button' => 'btn btn-secondary',
'button class btn' => '',
'button class accessibility' => 'btn btn-light',
......@@ -106,7 +106,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'a class list-group-item' => '',
'a class account-loans' => 'btn btn-sm list-group-item-info',
'ul' => 'list-unstyled',
'div class _notify' => 'alert-warning',
'div class success_notify' => 'alert-success',
'div class delete_notify' => 'alert-danger',
'form class indent-form' => 'px-4 py-1',
'div class card_article' => 'col-12 mb-3',
'h1 class content_title' => 'p-3 m-1',
......@@ -145,8 +147,12 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'date-edition' => 'class fas fa-file-signature',
'settings' => 'class fas fa-user-cog',
'selection' => 'class fas fa-heart',
'no-selection' => 'class far fa-heart',
'subscription' => 'class fas fa-euro-sign',
'card-number' => 'class fas fa-barcode',
'read-document' => 'class far fa-arrow-alt-circle-right',
'read-review' => 'class far fa-comment-dots',
],
'icons_map_utils' => ['image_place_holder' => '/library/templates/Intonation/Assets/images/image_place_holder.png',
......
......@@ -65,9 +65,20 @@ abstract class Intonation_Library_View_Wrapper_Abstract {
}
public function getContentForJSSearch() {
return $this->_view->dNone(implode(' ', [$this->getMainTitle(),
$this->getSecondaryTitle(),
$this->getDescription(),
$this->getBadges(),
'%s']));
}
abstract public function getMainTitle();
abstract public function getMainLink();
abstract public function getEmbedMedia();
abstract public function getHtmlPicture();
abstract public function getPicture();
abstract public function getPictureAction();
......
......@@ -78,7 +78,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr
public function getDescriptionTitle() {
return $this->_('Résumé de l\'article "%s"', $this->getTitle());
return $this->_('Résumé de l\'article "%s"', $this->_model->getTitre());
}
......@@ -103,4 +103,14 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr
public function getActions() {
return [];
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
\ No newline at end of file
......@@ -86,7 +86,7 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp
public function getMainLink() {
if (!$this->_model->getNoticeOPAC())
return '';
return null;
$wrapper = (new Intonation_Library_View_Wrapper_Record)
->setView($this->_view)
......@@ -95,7 +95,7 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp
return $wrapper->getMainLink();
if (!$this->_model->isRenewable())
return '';
return null;
return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne',
'action' => 'prolongerPret',
......@@ -169,4 +169,14 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp
public function getActions() {
return [];
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
......@@ -147,4 +147,14 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp
public function getActions() {
return [];
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
......@@ -45,7 +45,7 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
->setView($this->_view)
->setModel($this->_model->getNoticeOPAC());
return $wrapper->getAuthor();
return $wrapper->getSecondaryTitle();
}
......@@ -74,7 +74,8 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
->setView($this->_view)
->setModel($this->_model->getNoticeOPAC());
return $wrapper->getDescription();
return $this->getBadges()
. $wrapper->getDescription();
}
......@@ -85,7 +86,7 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
public function getMainLink() {
if (!$this->_model->getNoticeOPAC())
return '';
return null;
$wrapper = (new Intonation_Library_View_Wrapper_Record)
->setView($this->_view)
......@@ -144,14 +145,48 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
public function getBadges() {
if (!$this->_model->getNoticeOPAC())
return null;
$wrapper = (new Intonation_Library_View_Wrapper_Record)
->setView($this->_view)
->setModel($this->_model->getNoticeOPAC());
return $wrapper->getBadges();
$issue_date = $this->_model->getIssueDate();
$return_date = $this->_model->getDateRetour();
$badges = [
['tag' => 'span',
'class' => 'info',
'text' => Class_Template::current()->getIco($this->_view,
'loan',
'library')
. $issue_date,
'title' => $this->_('Date d\'emprunt : %s', $issue_date)],
['tag' => 'span',
'class' => ($this->_model->isLate()
? 'danger'
: 'success'),
'text' => Class_Template::current()->getIco($this->_view,
'return-date',
'library')
. $return_date,
'title' => $this->_('Date de retour : %s', $return_date)],
['tag' => 'span',
'class' => 'info',
'text' => ($this->_model->getOnHold()
? (Class_Template::current()->getIco($this->_view,
'thumbtack',
'library')
. $this->_('Réservé'))
: ''),
'title' => $this->_('Exemplaire réservé')],
['tag' => 'span',
'class' => 'info',
'text' => ($this->_model->getRenewals()
? (Class_Template::current()->getIco($this->_view,
'available',
'library')
. $this->_('Déjà prolongé')) : ''),
'title' => $this->_('Exemplaire déjà prolongé')]];
return $this->_view->renderBadges($badges);
}
......@@ -166,4 +201,14 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
'Title' => $this->_('Prolonger l\'emprunt %s',
$this->_model->getTitre())])];
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
......@@ -27,6 +27,27 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View
public function getMainLink() {
$params = $this->_model->hasRecipient(Class_Users::getIdentity())
? ['Url' => $this->_view->url(['controller' => 'abonne',
'action' => 'unsubscribe-newsletter',
'id' => $this->_model->getId()]),
'Text' => $this->_view->_("Me désinscrire"),
'Title' => $this->_view->_("Me désinscrire à la lettre d'information %s", $this->_model->getTitre()),
'Image' => Class_Template::current()->getIco($this->_view,
'selection',
'library'),
'Popup' => true]
: ['Url' => $this->_view->url(['controller' => 'abonne',
'action' => 'subscribe-newsletter',
'id' => $this->_model->getId()]),
'Text' => $this->_view->_("M'inscrire"),
'Title' => $this->_view->_("M'inscrire à la lettre d'information %s", $this->_model->getTitre()),
'Image' => Class_Template::current()->getIco($this->_view,
'no-selection',
'library'),
'Popup' => true];
return new Intonation_Library_Link($params);
}
......@@ -52,6 +73,7 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View
public function getActions() {
return [];
}
......@@ -75,4 +97,14 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View
public function getDocTypeLabel() {
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
......@@ -107,4 +107,14 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
public function getActions() {
return [];
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@
class Intonation_Library_View_Wrapper_RecordToRate extends Intonation_Library_View_Wrapper_Record {
public function getActions() {
public function getDescription() {
$me = Class_Users::getIdentity();
$mine = ($mine = $me->getFirstAvisByIdNotice($this->_model->getId()))
? $mine
......@@ -36,10 +36,23 @@ class Intonation_Library_View_Wrapper_RecordToRate extends Intonation_Library_Vi
$form = ZendAfi_Form_Review::newWith($mine->toArray())
->setAction($this->_view->url($params, null, true));
return [$this->_view->div(['class' => 'col-12'],
$this->_view->tag('h3', $this->_('Votre avis'), ['class' => 'card-title'])
. $this->_view->div(['class' => 'card'],
$this->_view->div(['class' => 'card-body'],
$this->_view->renderForm($form))))];
$form->getElement('entete')->setValue($this->_model->getTitrePrincipal(' '));
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)))));
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
}
\ No newline at end of file
......@@ -39,7 +39,9 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra
public function getSecondaryTitle() {
return $this->_model->getAuthorName();
return $this->_model->isMine()
? $this->_('Vous')
: $this->_model->getAuthorName();
}
......@@ -61,6 +63,10 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra
'id' => $this->_model->getId()],
null,
true),
'Image' => Class_Template::current()->getIco($this->_view,
'read-review',
'library'),
'Text' => $this->_('Lire l\'avis'),
'Title' => $this->_getMainLinkTitle(),
'Popup' => true]);
......@@ -122,9 +128,54 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra
if (!$record = $this->_model->getFirstNotice())
return [];
return [$this->_view->tagAnchor($record->getAbsoluteUrl(),
$this->_('Voir le document'),
['title' => $this->_('Voir le document %s',
$record->getTitrePrincipal(' '))])];
$actions = [new Intonation_Library_Link(['Url' => $record->getAbsoluteUrl(),
'Image' => Class_Template::current()->getIco($this->_view,
'read-document',
'library'),
'Text' => $this->_('Voir le document'),
'Title' => $this->_('Voir le document %s',
$record->getTitrePrincipal(' '))])];
if (!$this->_model->isMine())
return $actions;
$actions [] = new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne',
'action' => 'edit-review',
'id' => $this->_model->getId()]),