Commit 99686d8d authored by Ghislain Loas's avatar Ghislain Loas

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

dev#64573 work on account

See merge request afi/opacce!3124
parents 6129a8ad 6fc5ba09
...@@ -466,7 +466,7 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -466,7 +466,7 @@ class AbonneController extends ZendAfi_Controller_Action {
protected function _userForm($user) { protected function _userForm($user) {
$fields_to_show = Class_AdminVar::getChampsFicheUtilisateur(); $fields_to_show = Class_AdminVar::getChampsFicheUtilisateur();
$form = new Zend_Form; $form = new ZendAfi_Form;
$form $form
->setAction($this->view->url(['action' => 'edit', ->setAction($this->view->url(['action' => 'edit',
'id' => $user->getId()])) 'id' => $user->getId()]))
...@@ -1446,4 +1446,48 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -1446,4 +1446,48 @@ class AbonneController extends ZendAfi_Controller_Action {
public function donnerDesAvisAction() { public function donnerDesAvisAction() {
} }
public function suivreUneRechercheAction() {
}
public function modifierAction() {
$form = $this->_userForm($this->_user);
$form->setAction($this->view->url());
$this->view->form = $form;
if (!$this->_request->isPost())
return ;
if (!$form->isValid($this->_request->getPost()))
return;
$fields_to_save = Class_AdminVar::getChampsFicheUtilisateur();
$attributes = [];
foreach($fields_to_save as $field)
$attributes[$field] = $this->_request->getParam($field);
$this->_user
->updateAttributes($attributes);
$patron = $this->_user->getEmprunteur();
$patron->updateFromUser($this->_user);
try {
if ($this->_user->save()) {
$patron->ensureService($this->_user)->save();
$this->_helper->notify($this->_('Vos modifications ont bien été enregistrées'));
$this->_redirectClose('/abonne/informations');
}
$form->addDecorator('Errors');
foreach($this->_user->getErrors() as $error)
$form->addError($error);
} catch(Exception $e) {
$form->addError($e->getMessage());
$form->addDecorator('Errors');
}
}
} }
\ No newline at end of file
<?php
echo $this->abonne_Edit($this->user, $this->form);
?>
<?php
echo $this->abonne_FollowASearch($this->user);
...@@ -30,7 +30,15 @@ class Class_MoteurRecherche_Facettes { ...@@ -30,7 +30,15 @@ class Class_MoteurRecherche_Facettes {
public function buildFacetsData($preferences, $facets, $criterias) { public function buildFacetsData($preferences, $facets, $criterias) {
$this->_preferences = $preferences; $this->_preferences = array_merge(['suggests_enabled' => '',
'bookmarks_enabled' => '',
'facettes_actif' => '',
'facettes_codes' => '',
'facettes_nombre' => '',
'tags_actif' => '',
'tags_codes' => '',
'tags_nombres' => ''],
$preferences);
$this->_criterias = $criterias; $this->_criterias = $criterias;
$this->_codes_count = $this->fetchFacetsRows($facets); $this->_codes_count = $this->fetchFacetsRows($facets);
......
...@@ -90,6 +90,8 @@ class Class_Newsletter extends Storm_Model_Abstract { ...@@ -90,6 +90,8 @@ class Class_Newsletter extends Storm_Model_Abstract {
protected $_recipent_size = 20; protected $_recipent_size = 20;
protected $_default_attribute_values = ['titre' => '', protected $_default_attribute_values = ['titre' => '',
'draft' => 0, 'draft' => 0,
'id_catalogue' => '',
'id_panier' => '',
'articles_ids' => '', 'articles_ids' => '',
'articles_categories_ids' => '']; 'articles_categories_ids' => ''];
...@@ -209,14 +211,14 @@ class Class_Newsletter extends Storm_Model_Abstract { ...@@ -209,14 +211,14 @@ class Class_Newsletter extends Storm_Model_Abstract {
public function getNotices() { public function getNotices() {
if (!$this->getIdPanier() and !$this->getIdCatalogue()) if (!$this->getIdPanier() and !$this->getIdCatalogue())
return array(); return [];
$preferences = array( 'id_catalogue' => $this->getIdCatalogue(), $preferences = ['id_catalogue' => $this->getIdCatalogue(),
'id_panier' => $this->getIdPanier(), 'id_panier' => $this->getIdPanier(),
'nb_notices' => $this->getNbNotices(), 'nb_notices' => $this->getNbNotices(),
'only_img' => false, 'only_img' => false,
'aleatoire' => 0, 'aleatoire' => 0,
'tri' => 1); 'tri' => 1];
return Class_Notice::getNoticesFromPreferences($preferences); return Class_Notice::getNoticesFromPreferences($preferences);
} }
...@@ -428,6 +430,17 @@ class Class_Newsletter extends Storm_Model_Abstract { ...@@ -428,6 +430,17 @@ class Class_Newsletter extends Storm_Model_Abstract {
return $this; return $this;
} }
public function getFirstImageUrl() {
$template = $this->newTemplate();
$text = $template->getBodyHTML();
$matches = [];
return (preg_match('/< *img[^>]*src *= *["\']?([^"\'>]*)/i', $text, $matches) > 0)
? $matches[1]
: '';
}
} }
......
...@@ -24,6 +24,10 @@ class NoticeLoader extends Storm_Model_Loader { ...@@ -24,6 +24,10 @@ class NoticeLoader extends Storm_Model_Loader {
public function getNoticesFromPreferences($preferences) { public function getNoticesFromPreferences($preferences) {
$requetes = Class_Catalogue::getRequetes($preferences); $requetes = Class_Catalogue::getRequetes($preferences);
if (!isset($requetes['req_liste']))
return [];
$notices = $this->findAll($requetes["req_liste"]); $notices = $this->findAll($requetes["req_liste"]);
// Tirage aleatoire // Tirage aleatoire
......
...@@ -442,6 +442,6 @@ header.col { ...@@ -442,6 +442,6 @@ header.col {
max-height: 300px; max-height: 300px;
} }
.recherche_avancee .bouton.back { .opac .bouton.back {
display: none; display: none;
} }
\ No newline at end of file
<?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_Newsletter extends Intonation_Library_View_Wrapper_Abstract {
public function getMainTitle() {
return $this->_model->getTitre();
}
public function getMainLink() {
}
public function getPicture() {
return $this->_model->getFirstImageUrl();
}
public function getPictureAction() {
}
public function getSecondaryTitle() {
}
public function getSecondaryLink() {
}
public function getSecondaryIco() {
}
public function getActions() {
}
public function getDescription() {
$template = $this->_model->newTemplate();
return $this->_view->truncate($template->getBodyHTML());
}
public function getDescriptionTitle() {
}
public function getBadges() {
}
public function getDocType() {
}
public function getDocTypeLabel() {
}
}
...@@ -51,7 +51,8 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { ...@@ -51,7 +51,8 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section {
public function beVisible() { public function beVisible() {
return $this->_visible = true; $this->_visible = true;
return $this;
} }
...@@ -65,6 +66,12 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { ...@@ -65,6 +66,12 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section {
} }
public function setContent($content) {
$this->_content = $content;
return $this;
}
abstract public function getTitle(); abstract public function getTitle();
abstract public function getContent(); abstract public function getContent();
abstract public function getClass(); abstract public function getClass();
......
...@@ -56,6 +56,12 @@ class Intonation_Library_View_Wrapper_User_RichContent { ...@@ -56,6 +56,12 @@ class Intonation_Library_View_Wrapper_User_RichContent {
} }
public function setSections($sections) {
$this->_sections = $sections;
return $this;
}
public function getSections() { public function getSections() {
if ($this->_sections) if ($this->_sections)
return $this->_sections; return $this->_sections;
......
<?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_ChangeImage extends Intonation_Library_View_Wrapper_User_RichContent_Settings {
public function getTitle() {
return $this->_('Modifier mon image de profil');
}
public function getContent() {
return $this->_content;
}
public function getClass() {
return 'image_user_informations';
}
public function getNavUrl() {
return ['controller' => 'abonne',
'action' => 'change-image'];
}
public function getNavTitle() {
return $this->_('Modifier l\'image de mon profil');
}
}
<?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_EditInformations extends Intonation_Library_View_Wrapper_User_RichContent_Settings {
public function getTitle() {
return $this->_('Modifier mes informations');
}
public function getContent() {
return $this->_content;
}
public function getClass() {
return 'form_user_informations';
}
public function getNavUrl() {
return ['controller' => 'abonne',
'action' => 'modifier'];
}
public function getNavTitle() {
return $this->_('Modifier les informations de mon compte');
}
}
...@@ -29,7 +29,12 @@ class Intonation_Library_View_Wrapper_User_RichContent_Holds extends Intonation_ ...@@ -29,7 +29,12 @@ class Intonation_Library_View_Wrapper_User_RichContent_Holds extends Intonation_
public function getContent() { public function getContent() {
$cards = new Class_User_Cards($this->_model); $cards = new Class_User_Cards($this->_model);
return $this->_view->abonne_Holds($cards->getHolds()); $holds = $cards->getHolds();
if ($holds->isEmpty())
return '';
return $this->_view->abonne_Holds($holds);
} }
......
...@@ -28,7 +28,10 @@ class Intonation_Library_View_Wrapper_User_RichContent_Informations extends Into ...@@ -28,7 +28,10 @@ class Intonation_Library_View_Wrapper_User_RichContent_Informations extends Into
public function getContent() { public function getContent() {
return $this->_view->User_Informations($this->_model); if ($this->_content)
return $this->_content;
return $this->_content = $this->_view->User_Informations($this->_model);
} }
......
...@@ -33,6 +33,10 @@ class Intonation_Library_View_Wrapper_User_RichContent_Loans extends Intonation_ ...@@ -33,6 +33,10 @@ class Intonation_Library_View_Wrapper_User_RichContent_Loans extends Intonation_
$cards = new Class_User_Cards($this->_model); $cards = new Class_User_Cards($this->_model);
$loans = $cards->getLoansWithOutPNB([]); $loans = $cards->getLoansWithOutPNB([]);
if ($loans->isEmpty())
return '';
$fiche = $this->_model->getFicheSigb(); $fiche = $this->_model->getFicheSigb();
$error = (isset($fiche['error']) && $fiche['error']) $error = (isset($fiche['error']) && $fiche['error'])
? $fiche['error'] ? $fiche['error']
......
...@@ -32,7 +32,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio ...@@ -32,7 +32,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio
return $this->_('Vous n\'avez pas encore donné d\'avis. %s !', return $this->_('Vous n\'avez pas encore donné d\'avis. %s !',
$this->_view->tagAnchor(['controller' => 'abonne', $this->_view->tagAnchor(['controller' => 'abonne',
'action' => 'donner-des-avis'], 'action' => 'donner-des-avis'],
$this->_('Commencer dès maintenant'))); $this->_('Commencer maintenant')));
$reviews = array_map(function($review) $reviews = array_map(function($review)
{ {
return (new Intonation_Library_View_Wrapper_Review) return (new Intonation_Library_View_Wrapper_Review)
...@@ -44,7 +44,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio ...@@ -44,7 +44,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio
return $this->_view->cardifyHorizontal($wrapped); return $this->_view->cardifyHorizontal($wrapped);
}; };
return $this->_view->renderList(new Storm_Collection($reviews), $callback); return $this->_view->renderTruncateList(new Storm_Collection($reviews), $callback);
} }
......
...@@ -31,7 +31,8 @@ class Intonation_Library_View_Wrapper_User_RichContent_Selections extends Intona ...@@ -31,7 +31,8 @@ class Intonation_Library_View_Wrapper_User_RichContent_Selections extends Intona
return return
$this->_view->paniers($this->_model->getPaniers()) $this->_view->paniers($this->_model->getPaniers())
. $this->_view->bookmarkedSearches(Class_User_BookmarkedSearch::findAllBy(['id_user' => $this->_model->getId(), . $this->_view->bookmarkedSearches(Class_User_BookmarkedSearch::findAllBy(['id_user' => $this->_model->getId(),
'order' => 'creation_date desc'])); 'order' => 'creation_date desc']))
. $this->_view->user_Newsletters($this->_model);
} }
......
...@@ -28,7 +28,12 @@ class Intonation_Library_View_Wrapper_User_RichContent_Settings extends Intonati ...@@ -28,7 +28,12 @@ class Intonation_Library_View_Wrapper_User_RichContent_Settings extends Intonati
public function getContent() { public function getContent() {
return $this->_view->renderForm(ZendAfi_Form_User_Settings::forUser($this->_model)); $form = ZendAfi_Form_User_Settings::forUser($this->_model);
if (!$form->getElements())
return '';
return $this->_view->renderForm($form);
} }
......
...@@ -32,6 +32,7 @@ class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper { ...@@ -32,6 +32,7 @@ class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper {
->setView($this->view) ->setView($this->view)
->setModel($user); ->setModel($user);
$this->_hookOn($rich_content);
$this->_showSections($rich_content->getSections()); $this->_showSections($rich_content->getSections());
$wrapped->setRichContent($rich_content); $wrapped->setRichContent($rich_content);
...@@ -40,6 +41,10 @@ class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper { ...@@ -40,6 +41,10 @@ class Intonation_View_Abonne extends ZendAfi_View_Helper_BaseHelper {
} }
protected function _hookOn($rich_content) {
}
protected function _showSections($sections) { protected function _showSections($sections) {
foreach($sections as $section) foreach($sections as $section)
$section->beVisible(); $section->beVisible();
......
...@@ -20,10 +20,33 @@ ...@@ -20,10 +20,33 @@
*/ */
class Intonation_View_Abonne_ChangeImage extends ZendAfi_View_Helper_BaseHelper { class Intonation_View_Abonne_ChangeImage extends Intonation_View_Abonne {
public function abonne_ChangeImage($user) { public function abonne_ChangeImage($user) {
$this->view->titre = $this->_('Changer l\'image de mon profil'); $html = $this->abonne($user);
$this->view->titre = $this->_('%s : Modifier mon image de profil',
$this->view->titre);
return $html;
}
protected function _hookOn(