diff --git a/.gitattributes b/.gitattributes index 7af53848c42ca529422798972c59ad7818e0901b..7cae8dd51d1c72f4baa8b8bd68f4eaaca0c0c1b0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2584,6 +2584,7 @@ library/ZendAfi/Controller/Action/RessourceDefinitions.php -text library/ZendAfi/Controller/Plugin/AdminAuth.php -text library/ZendAfi/Controller/Plugin/DefineURLs.php -text library/ZendAfi/Controller/Plugin/InitModule.php -text +library/ZendAfi/Controller/Plugin/Popup.php -text library/ZendAfi/Controller/Plugin/SelectionBib.php -text library/ZendAfi/Controller/Plugin/SetupLocale.php -text library/ZendAfi/Controller/Plugin/System.php -text diff --git a/application/modules/admin/views/scripts/cms/newsform.phtml b/application/modules/admin/views/scripts/cms/newsform.phtml index f1ac9fb214a4ee74826d5b4f5714416839297eef..31a8562b3dd4d843f9518034282ff58b49265ff4 100644 --- a/application/modules/admin/views/scripts/cms/newsform.phtml +++ b/application/modules/admin/views/scripts/cms/newsform.phtml @@ -17,14 +17,13 @@ Class_ScriptLoader::getInstance() <?php echo $this->partial('cms/_newsform_head.phtml', array('article' => $this->article)); ?> -<form - id="news_form" - class="form" - name="form" - action="<?php echo $this->url(); ?>" - method="post"> +<form id="news_form" + class="form" + name="form" + action="<?php echo $this->url(); ?>" + method="post"> - <span class="error"><?php echo implode('<br/>', $this->article->getErrors()); ?></span> + <span class="error"><?php echo implode('<br/>', $this->article->getErrors()); ?></span> <fieldset> <legend><?php echo $this->traduire('Publication'); ?></legend> @@ -32,22 +31,21 @@ Class_ScriptLoader::getInstance() <tr> <td><?php echo $this->traduire('Titre'); ?> *</td> <td> - <input - type="text" - name="titre" - id="titre" - value="<?php echo $this->escape($this->article->getTitre());?>" - size="100" - maxlength="<?php echo Class_Article::TITLE_MAX_LENGTH ?>" /> + <input type="text" + name="titre" + id="titre" + value="<?php echo $this->escape($this->article->getTitre());?>" + size="100" + maxlength="<?php echo Class_Article::TITLE_MAX_LENGTH ?>" /> </td> </tr> <tr> <td><?php echo $this->traduire("Titre caché"); ?></td> <td><?php echo $this->formCheckbox('cacher_titre', - (int)$this->article->getCacherTitre(), - null, - array(1, 0)); ?> + (int)$this->article->getCacherTitre(), + null, + array(1, 0)); ?> </td> </tr> @@ -60,21 +58,21 @@ Class_ScriptLoader::getInstance() <tr> <td><?php echo $this->traduire('Statut'); ?></td> <td><?php - $element = new Zend_Form_Element_Radio('status', array( - 'multiOptions' => $this->article->getKnownStatus(), - 'separator' => ' ', - 'value' => (int)$this->article->getStatus(), - )); + $element = new Zend_Form_Element_Radio('status', array( + 'multiOptions' => $this->article->getKnownStatus(), + 'separator' => ' ', + 'value' => (int)$this->article->getStatus(), + )); - if (Class_Users::getLoader()->getIdentity()->isRedacteur()) { - $element->setOptions(array('disable' => array(Class_Article::STATUS_VALIDATED))); - } + if (Class_Users::getLoader()->getIdentity()->isRedacteur()) { + $element->setOptions(array('disable' => array(Class_Article::STATUS_VALIDATED))); + } - $element->removeDecorator('label') - ->removeDecorator('HtmlTag'); + $element->removeDecorator('label') + ->removeDecorator('HtmlTag'); - echo $element; - ?></td> + echo $element; + ?></td> </tr> <?php } ?> @@ -84,21 +82,21 @@ Class_ScriptLoader::getInstance() <span><?php echo $this->traduire('du'); ?></span> <span class="date_picker"> <?php - echo $this->datePicker( - 'debut', - $this->article->DEBUT, - $currentYear, - $limitYear); + echo $this->datePicker( + 'debut', + $this->article->DEBUT, + $currentYear, + $limitYear); ?> </span> <span><?php echo $this->traduire('au'); ?></span> <span> <?php - echo $this->datePicker( - 'fin', - $this->article->getFin(), - $currentYear, - $limitYear); + echo $this->datePicker( + 'fin', + $this->article->getFin(), + $currentYear, + $limitYear); ?> </span> </td> @@ -110,21 +108,21 @@ Class_ScriptLoader::getInstance() <span><?php echo $this->traduire('du'); ?></span> <span class="date_picker"> <?php - echo $this->datePicker( - 'events_debut', - $this->article->getEventsDebut(), - $currentYear, - $limitYear); + echo $this->datePicker( + 'events_debut', + $this->article->getEventsDebut(), + $currentYear, + $limitYear); ?> </span> <span><?php echo $this->traduire('au'); ?></span> <span> <?php - echo $this->datePicker( - 'events_fin', - $this->article->getEventsFin(), - $currentYear, - $limitYear); + echo $this->datePicker( + 'events_fin', + $this->article->getEventsFin(), + $currentYear, + $limitYear); ?> </span> </td> @@ -189,9 +187,9 @@ Class_ScriptLoader::getInstance() <td><?php echo $this->traduire('Autoriser les commentaires d\'internautes (Mode blog) ?'); ?></td> <td> <?php echo $this->formCheckbox('avis', - (int)$this->article->getAvis(), - null, - array(1, 0)); ?> + (int)$this->article->getAvis(), + null, + array(1, 0)); ?> </td> </tr> @@ -199,33 +197,33 @@ Class_ScriptLoader::getInstance() <td><?php echo $this->traduire('Indexer l\'article dans le catalogue ?'); ?></td> <td> <?php echo $this->formCheckbox('indexation', - (int)$this->article->getIndexation(), - null, - array(1, 0)); ?> + (int)$this->article->getIndexation(), + null, + array(1, 0)); ?> </td> </tr> </table> </fieldset> -<?php -if (defined('DEVELOPMENT')) { -?> + <?php + if (defined('DEVELOPMENT')) { + ?> <fieldset> <legend><?php echo $this->traduire('Indexation'); ?></legend> - <table > - <tr> - <td> - <?php echo $this->domaineSelect($this->article); ?> - </td> - </tr> - </table> + <table > + <tr> + <td> + <?php echo $this->domaineSelect($this->article); ?> + </td> + </tr> + </table> </fieldset> -<?php } ?> + <?php } ?> -<?php echo $this->partial('cms/_newsform_buttons.phtml',['id_categorie'=> $this->article->getCategorie()->getId()]); ?> + <?php echo $this->partial('cms/_newsform_buttons.phtml',['id_categorie'=> $this->article->getCategorie()->getId()]); ?> </form> <script type="text/javascript"> - oField = document.getElementById('titre'); - oField.focus(); +oField = document.getElementById('titre'); +oField.focus(); </script> diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index e7dc174a15f2ef44d7c4847ec03b413d69a6510d..4df3c06be6ac015d10d0d76a4716db8a38a05775 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -23,7 +23,7 @@ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AuthController extends Zend_Controller_Action { +class AuthController extends ZendAfi_Controller_Action { function init() { $this->view->locale = Zend_Registry::get('locale'); } @@ -112,28 +112,30 @@ class AuthController extends Zend_Controller_Action { function ajaxLoginAction(){ $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); - $this->view->id_notice = $this->_getParam('ajoutPanier'); + $redirect = urldecode($this->_getParam('redirect')); $this->_loginResult('',true); - - $viewRenderer = $this->getHelper('ViewRenderer'); + if (!Class_Users::getLoader()->getIdentity()==null) { - $viewRenderer->setLayoutScript('_retour.phtml'); + $this->renderPopup($redirect); return ; } + + $this->view->redirect = $redirect; + $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->setLayoutScript('subModal.phtml'); } function popupLoginAction() { - $viewRenderer = $this->getHelper('ViewRenderer'); - $viewRenderer->setNoRender(); + $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); + $this->view->redirect = $this->_getParam('redirect'); + + $this->getHelper('ViewRenderer')->setNoRender(); $this->getResponse()->setHeader('Content-Type', 'application/json'); - $this->getResponse()->setBody(json_encode(['result' => 'AUTH', - 'redirect' => $this->view->url(['action'=>'ajax-login', - 'controller'=>'auth', - 'id_notice' => null, - 'ajoutPanier'=>$this->_getParam('id_notice')])])); + $this->getResponse()->setBody(json_encode(['result' => 'CONTENT', + 'title' => $this->view->_('Authentification'), + 'content' => $this->view->render('auth/ajax-login.phtml')])); } diff --git a/application/modules/opac/controllers/PanierController.php b/application/modules/opac/controllers/PanierController.php index 2a59f134e522ff7a73ee8a5f5eca2d38a6d99fb8..d9aaf50a300192d3206475d86c11eadd51edf2ed 100644 --- a/application/modules/opac/controllers/PanierController.php +++ b/application/modules/opac/controllers/PanierController.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class PanierController extends Zend_Controller_Action { +class PanierController extends ZendAfi_Controller_Action { use Trait_Translator; private $_user = null; // User connecté (auth) @@ -105,6 +105,17 @@ class PanierController extends Zend_Controller_Action { } + public function ajoutAjaxSuccessAction() { + $this->view->notice = Class_Notice::find($this->_getParam('id_notice')); + $this->view->panier = Class_PanierNotice::find($this->_getParam('id_panier')); + $this->getHelper('ViewRenderer')->setNoRender(); + + print json_encode(['result' => 'CONTENT', + 'title' => $this->_('Ajout panier'), + 'content' => $this->view->render('panier/ajout-ajax-success.phtml')]); + } + + public function ajoutAjaxAction() { $this->getHelper('ViewRenderer')->setNoRender(); if (!$notice = Class_Notice::find($this->_getParam('id_notice'))) { @@ -114,7 +125,7 @@ class PanierController extends Zend_Controller_Action { } if (!$user = Class_Users::getLoader()->getIdentity()) { - $this->_forward('popup-login', 'auth', 'opac'); + $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]); return; } @@ -123,11 +134,13 @@ class PanierController extends Zend_Controller_Action { if ($this->_request->isPost()) { $panier = $this->ensurePanier(); $this->addNoticeToPanier($notice, $panier); - $this->view->notice = $notice; - $this->view->panier = $panier; - print json_encode(['result' => 'CONTENT', - 'title' => $notice->getTitrePrincipal(), - 'content' => $this->view->render('panier/ajout-ajax-success.phtml')]); + + $this->renderPopup($this->view->url(['controller' => 'panier', + 'action' => 'ajout-ajax-success', + 'id_notice' => $notice->getId(), + 'id_panier' => $panier->getId()], + null, + true)); return; } @@ -141,6 +154,7 @@ class PanierController extends Zend_Controller_Action { )->render()]); } + function paniersupprimernoticeAction() { $notice = Class_Notice::find($this->_getParam('id_notice')); $panier = Class_PanierNotice::find($this->_getParam('id_panier')); diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index decd538ad8df58472a6bce5978c50f7b8697523d..9d9ba428375df96accde312e10a6087d01bcaf55 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -22,8 +22,7 @@ // OPAC3 - Controleur pour toutes les recherches ////////////////////////////////////////////////////////////////////////////////////////// -class RechercheController extends Zend_Controller_Action -{ +class RechercheController extends Zend_Controller_Action { private $moteur; // Instance du moteur de recherche private $liste; // Instance de la classe de liste de notices private $preferences; // Préférences pour la liste du résultat @@ -124,8 +123,6 @@ class RechercheController extends Zend_Controller_Action Class_ScriptLoader::getInstance()->addJQueryReady("$('<div></div>').load('".$this->view->url($criteres_recherche->getCVSUrlCriteresWithFacettes(),null,true)."').appendTo($('.cvs_boite'))"); } - $this->view->id_notice = $this->_getParam('ajoutPanier'); - $this->renderResultatRecherche($criteres_recherche,$ret); } @@ -199,10 +196,6 @@ class RechercheController extends Zend_Controller_Action // AFFICHAGE NOTICE //------------------------------------------------------------------------------------------------------ public function viewnoticeAction() { - -// if ((new Zend_Controller_Request_Http($this->view->absoluteUrl($this->_request->REQUEST_URI)))->getModuleName() !== 'admin') -// $_SESSION["recherche"]["retour_notice"] = $this->_request->REQUEST_URI; - $id_notice = (int)$this->_getParam('id'); $clef_alpha = $this->_getParam('clef'); @@ -476,7 +469,7 @@ class RechercheController extends Zend_Controller_Action $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->setNoRender(); if (!Class_Users::getLoader()->getIdentity()) { - print(json_encode('http://' . $_SERVER['SERVER_NAME'] . BASE_URL.'/opac/auth/ajax-login')); + $this->_forward('login', 'auth', 'opac', ['redirect' => $this->view->url()]); return; } @@ -503,6 +496,12 @@ class RechercheController extends Zend_Controller_Action public function reservationPickupAjaxAction() { + if (!Class_Users::getLoader()->getIdentity()) { + $this->_redirect('auth/ajax-login?redirect='); + return; + } + + $this->getHelper('ViewRenderer')->setLayoutScript('iframe.phtml'); Class_ScriptLoader::getInstance() ->loadJQuery() diff --git a/application/modules/opac/views/scripts/_retour.phtml b/application/modules/opac/views/scripts/_retour.phtml index 8ca23153c126fef35ab157adebe0a71c1e02ad5c..f6f15c1eb4f1ef4a4ebaa7c911cad25bb0c632c5 100644 --- a/application/modules/opac/views/scripts/_retour.phtml +++ b/application/modules/opac/views/scripts/_retour.phtml @@ -1,7 +1,3 @@ - <script> - parent.hidePopWin(); - var url= window.parent.location.href; - url = url.replace('#',''); - url = url + (url.indexOf('?') > 0 ? '&' : '?') + '<?php echo $this->id_notice ? "ajoutPanier=".$this->id_notice : ''; ?>'; - window.parent.location.href = url; -</script> \ No newline at end of file +<script> + window.parent.location.href = "<?php echo $this->url; ?>"; +</script> diff --git a/application/modules/opac/views/scripts/auth/ajax-login.phtml b/application/modules/opac/views/scripts/auth/ajax-login.phtml index 9bd4bbe827757f757a56e26e0f07b6d1883badcb..941e000052921593bcfae7a383f3956d3acaa462 100644 --- a/application/modules/opac/views/scripts/auth/ajax-login.phtml +++ b/application/modules/opac/views/scripts/auth/ajax-login.phtml @@ -1,10 +1,9 @@ <script> -function getUsername() -{ - oUser = document.getElementById('username'); - username = oUser.value; - var url = window.location.href="ajaxlostpass?id="+username; - return(url); +function getUsername(){ + oUser = document.getElementById('username'); + username = oUser.value; + var url = window.location.href="ajaxlostpass?id="+username; + return(url); } function submit() { @@ -12,34 +11,36 @@ function submit() { } </script> <center> -<h1> -<?php -$titre = $this->preferences['titre']; -if($user = Class_Users::getLoader()->getIdentity()) { - $titre = $this->preferences['titre_connecte']; -} -echo sprintf("<div class='head title'>%s</div>", $titre); ?> -</h1> -<?php -if($user = Class_Users::getLoader()->getIdentity()) { - echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff()); - echo sprintf('<a href="%s/abonne/fiche" target="_parent">» %s</a>', BASE_URL, $this->_($this->preferences['lien_compte'])); - if ($user->hasIdabon()) + <h1> + <?php + $titre = $this->preferences['titre']; + if($user = Class_Users::getLoader()->getIdentity()) { + $titre = $this->preferences['titre_connecte']; + } + echo sprintf("<div class='head title'>%s</div>", $titre); ?> + </h1> + <?php + if($user = Class_Users::getLoader()->getIdentity()) { + echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff()); + echo sprintf('<a href="%s/abonne/fiche" target="_parent">» %s</a>', BASE_URL, $this->_($this->preferences['lien_compte'])); + if ($user->hasIdabon()) echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations()); - echo sprintf('<a href="%s/auth/logout" target="_parent">» %s</a>', BASE_URL, $this->_($this->preferences['lien_deconnection'])); -} else { ?> -<div class="formTable"> -<?php - $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge($this->preferences, - ['redirect_url' => $this->redirect, - 'id_notice' => $this->id_notice]), - 'action' => $this->url(['controller' => 'auth', - 'action' => 'boite-login', - 'id_module' => $this->id_module])]); + echo sprintf('<a href="%s/auth/logout" target="_parent">» %s</a>', BASE_URL, $this->_($this->preferences['lien_deconnection'])); + } else { ?> + <div class="formTable"> + <?php + $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge($this->preferences, + ['redirect_url' => $this->redirect, + 'id_notice' => $this->id_notice]), - echo $this->renderForm($form); + 'action' => $this->url(['controller' => 'auth', + 'action' => 'ajax-login'], + null, + true)]); -} -?> -</div> + echo $this->renderForm($form); + + } + ?> + </div> </center> diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index d63a446a3889a897eba5af8aba1111a606822219..3a49dde985db865ed3df93d59ad9f6413c7a881a 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -151,11 +151,5 @@ $this->openBoite($preferences['cvs_autres_resultats']); <?php Class_ScriptLoader::getInstance() ->addOPACScript('recherche') ->addSkinStyleSheet('recherche') ?> - - -<?php if(isset($this->id_notice)) { -Class_ScriptLoader::getInstance() - ->addJQueryReady('noticeMurPanier($(\'div[data-id="'.$this->id_notice.'"]\').find(\'a[href*=\"panier/ajout-ajax\"]\'));'); -} ?> diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 0858d2628d29ff14f5a2ac3fa78373c07757084f..13159d392997e007ddd61c52e37133418e0ee181 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -133,5 +133,19 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { protected function _stayOnPage() { $this->_redirect($this->_request->getServer('HTTP_REFERER')); } + + + + public function renderPopup($popup_url, $location = null) { + $this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml'); + + $queries = []; + $url = parse_url($location ? $location : $this->_request->getServer('HTTP_REFERER')); + parse_str($url['query'],$queries); + $queries['popup'] = $popup_url; + $path = $url['path'] ? $url['path'] : ''; + + return $this->_redirect('http://'.$url['host'].$path.'?'.http_build_query($queries)); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Popup.php b/library/ZendAfi/Controller/Plugin/Popup.php new file mode 100644 index 0000000000000000000000000000000000000000..d9c1e7d51593c9ac6432ed3fa24754e96f1c54ad --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/Popup.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_Controller_Plugin_Popup extends Zend_Controller_Plugin_Abstract { + function preDispatch(Zend_Controller_Request_Abstract $request) { + if ($popup=$request->getParam('popup')) { + Class_ScriptLoader::getInstance()->addJQueryReady('opacDialogFromUrl("'.$popup.'");'); + } + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Mur.php b/library/ZendAfi/View/Helper/Notice/Mur.php index 9e4992650a370b86c07e5c99fae6e3576f04d112..1d3b7c6193423c7a9e22219ee353b3b52d61d6f7 100644 --- a/library/ZendAfi/View/Helper/Notice/Mur.php +++ b/library/ZendAfi/View/Helper/Notice/Mur.php @@ -83,7 +83,7 @@ class ZendAfi_View_Helper_Notice_Mur extends Zend_View_Helper_HtmlElement { public function barreDeLienPanier($notice) { Class_ScriptLoader::getInstance()->addOPACScript("subModal"); $url = $this->view->url(['controller' => 'panier', - 'action' => 'ajout-ajax', + 'action' => 'ajout-ajax', 'id_notice' => $notice->getId()], null, true); return '<li><a href="' . $url . '" data-action="'. $url.'" title="'.$this->_("Ajouter au panier").'"> </a></li>'; } diff --git a/library/requires.php b/library/requires.php index d781bba1603c7d97eeda6f4482cd243e6b9b9392..c03e1b55e86d0462801b7c05e885ac3ed3bd7d7b 100644 --- a/library/requires.php +++ b/library/requires.php @@ -48,6 +48,7 @@ require_once(ROOT_PATH.'library/ZendAfi/Controller/Plugin/DefineURLs.php'); require_once(ROOT_PATH.'library/ZendAfi/Controller/Plugin/InitModule.php'); require_once(ROOT_PATH.'library/ZendAfi/Controller/Plugin/SelectionBib.php'); require_once(ROOT_PATH.'library/ZendAfi/Controller/Plugin/System.php'); +require_once(ROOT_PATH.'library/ZendAfi/Controller/Plugin/Popup.php'); require_once(ZEND_FRAMEWORK_PATH.'Zend/Auth.php'); require_once(ROOT_PATH.'library/Storm/Model/Loader.php'); diff --git a/library/startup.php b/library/startup.php index e27abee9c5bd89e14e1151c68fdeedc42fe450d8..3a860c0a54c1124cf60bacf77c4fe0e89d83aaa9 100644 --- a/library/startup.php +++ b/library/startup.php @@ -272,6 +272,7 @@ function setupFrontController() { ->registerPlugin(new ZendAfi_Controller_Plugin_SelectionBib()) ->registerPlugin(new ZendAfi_Controller_Plugin_System()) ->registerPlugin(new ZendAfi_Controller_Plugin_XHProfile()) + ->registerPlugin(new ZendAfi_Controller_Plugin_Popup()) ->setParam('useDefaultControllerAlways', true); return setupRoutes($front_controller); diff --git a/public/opac/js/liste_notices_mur.js b/public/opac/js/liste_notices_mur.js index 8d41bb95c2c3bec23106ad0490c2bd7e6002c356..74d63c8b50f99747d23b1dd7319c121f16d43bc8 100644 --- a/public/opac/js/liste_notices_mur.js +++ b/public/opac/js/liste_notices_mur.js @@ -1,120 +1,120 @@ var liste_resumes = {}; function vignetteHover(vignettes) { - vignettes.each(function() { - var notice = $(this); - notice.find('img').attr('title',''); - notice.find('.nothumbnail img').width(notice.parent('.notice_wrapper').width()); - noticeMurTooltip(notice);}); + vignettes.each(function() { + var notice = $(this); + notice.find('img').attr('title',''); + notice.find('.nothumbnail img').width(notice.parent('.notice_wrapper').width()); + noticeMurTooltip(notice);}); } function noticeMurOpen(context, id){ - if (null != liste_resumes[id]) { - context.tooltip('option', 'content', liste_resumes[id]); - return; - } - - $.get(resumeAjaxBaseUrl+'?id_notice='+id , function(data) { - var resume = ('' == data) ? 'Pas de résumé' : data; - if(!(undefined==disponibiliteAjaxBaseUrl)) + if (null != liste_resumes[id]) { + context.tooltip('option', 'content', liste_resumes[id]); + return; + } + + $.get(resumeAjaxBaseUrl+'?id_notice='+id , function(data) { + var resume = ('' == data) ? 'Pas de résumé' : data; + if(!(undefined==disponibiliteAjaxBaseUrl)) getDisponibilite(id, function(dispo) {popupResumeAndDispo(context, resume, dispo, id)}); - else + else popupResumeAndDispo(context, resume, '', id); - }); + }); } function getDisponibilite(id, callback){ - $.get(disponibiliteAjaxBaseUrl+'?id_notice='+id, function(data) { - var dispo = ('true' == data) ? '<span class="disponible">Disponible</span>' : '<span class="dispo">Non disponible</span>'; - callback(dispo); - }); + $.get(disponibiliteAjaxBaseUrl+'?id_notice='+id, function(data) { + var dispo = ('true' == data) ? '<span class="disponible">Disponible</span>' : '<span class="dispo">Non disponible</span>'; + callback(dispo); + }); } function popupResumeAndDispo(context, resume, dispo, id) { - var content = '<span class="resume">' + resume + '</span>' + dispo; - liste_resumes[id] = content; - context.tooltip('option', 'content', content); + var content = '<span class="resume">' + resume + '</span>' + dispo; + liste_resumes[id] = content; + context.tooltip('option', 'content', content); } function noticeMurTooltip(item) { - var id = $(item).data('id'); - $(item).tooltip({ - show:{delay:250}, - content:'<div style="text-align:center;padding:15px;"><img src="' + imagesUrl +'patience.gif" /></div>', - open:function(event, ui){ + var id = $(item).data('id'); + $(item).tooltip({ + show:{delay:250}, + content:'<div style="text-align:center;padding:15px;"><img src="' + imagesUrl +'patience.gif" /></div>', + open:function(event, ui){ var context = $(this); noticeMurOpen(context, id)}, - items: 'img:not(.icone_support, .reseau-social-img, .permalien-img )', - tooltipClass: 'notice-mur-tooltip', - position: {my: 'left top', at: 'right top' , collision: 'none'}} ); + items: 'img:not(.icone_support, .reseau-social-img, .permalien-img )', + tooltipClass: 'notice-mur-tooltip', + position: {my: 'left top', at: 'right top' , collision: 'none'}} ); - $(item).find('a[data-mur-partager]').each(function(){ - var anchor = $(this); - $(this).click(function(event) { + $(item).find('a[data-mur-partager]').each(function(){ + var anchor = $(this); + $(this).click(function(event) { event.preventDefault(); $(item).find('.vignette-reseaux-sociaux').toggle(); - })}); - - $(item).find('a[href*="panier/ajout-ajax"]').click(function(event){ - event.preventDefault(); - noticeMurPanier($(this)); - }); - - $(item).find('a[href*="noticeajax/avis-abonne/"]').click(function(event){ - event.preventDefault(); - noticeMurAvis($(this).attr("href"),'Commentaires'); - }); - - $(item).find('a[href*="noticeajax/avis-bibliothecaire/"]').click(function(event){ - event.preventDefault(); - noticeMurAvis($(this).attr("href"), 'Coups de coeur'); - }); + })}); + + $(item).find('a[href*="panier/ajout-ajax"]').click(function(event){ + event.preventDefault(); + opacDialogFromUrl($(this).attr('href')); + }); + + $(item).find('a[href*="noticeajax/avis-abonne/"]').click(function(event){ + event.preventDefault(); + noticeMurAvis($(this).attr("href"),'Commentaires'); + }); + + $(item).find('a[href*="noticeajax/avis-bibliothecaire/"]').click(function(event){ + event.preventDefault(); + noticeMurAvis($(this).attr("href"), 'Coups de coeur'); + }); } function noticeMurPanier(anchor) { - addLoadingClass(anchor); - var json = $.getJSON(anchor.data('action'), function(data){ - noticeMurPanierWithData(data, anchor); - }); + addLoadingClass(anchor); + var json = $.getJSON(anchor.data('action'), function(data){ + noticeMurPanierWithData(data, anchor); + }); } function noticeMurAvis(url,titleDialog) { - opacShowModal(url, 500, 400,function(){},'',titleDialog); + opacShowModal(url, 500, 400,function(){},'',titleDialog); } function noticeMurPanierWithData(data, anchor){ - var dialogContent = $('<div></div>'); - if ('AUTH' == data['result']) { - opacShowModalConnection(data, function(event, ui){ + var dialogContent = $('<div></div>'); + if ('AUTH' == data['result']) { + opacShowModalConnection(data, function(event, ui){ removeLoadingClass(anchor); opacHideModal(); if (undefined == event.currentTarget) - noticeMurPanier(anchor); - },400,250); - } - if ('CONTENT' == data['result']) { - var modal = opacDialog(dialogContent, - data, - 'ajout-panier', - function(){removeLoadingClass(anchor);},null,410,120); - dialogContent.find('a[href="#"]').click(function(event){ + noticeMurPanier(anchor); + },400,250); + } + if ('CONTENT' == data['result']) { + var modal = opacDialog(dialogContent, + data, + 'ajout-panier', + function(){removeLoadingClass(anchor);},null,410,120); + dialogContent.find('a[href="#"]').click(function(event){ event.preventDefault(); modal.dialog('close'); - }); + }); - dialogContent.find('form').submit(function(event){ +/* dialogContent.find('form').submit(function(event){ event.preventDefault(); modal.dialog('close'); var form = $(this); $.post(form.attr('action'), form.serialize(), function(data){ - noticeMurPanierWithData(data); + noticeMurPanierWithData(data); }, 'json'); - }); - } + });*/ + } } diff --git a/public/opac/js/subModal.js b/public/opac/js/subModal.js index b88dd0241353d17ffca9c6b356d85015e68e9bb6..1135ef5a18d7d04b749670a0fd2fb0d469d0cc35 100644 --- a/public/opac/js/subModal.js +++ b/public/opac/js/subModal.js @@ -25,6 +25,12 @@ function opacShowModalConnection(data, returnFunc ,width ,height ) { } +function opacDialogFromUrl(url) { + var dialog = $('<div></div>'); + $.getJSON(url, function(data) { opacDialog(dialog, data); }); +} + + function opacDialog(container, data, dialogClass, closeFunc, openFunc, width, height) { var modal_size = initModalSize(width, height); var titre = container.html(data['title']).html(); @@ -34,7 +40,7 @@ function opacDialog(container, data, dialogClass, closeFunc, openFunc, width, he modal:true, title: titre, dialogClass: dialogClass, - close: closeFunc() + close: closeFunc }); return modal; } diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index e144408fd09c8bbb4c173b79ecac5256100e80b5..f49f2e86ab336491239286160323d536acb0ceb6 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -356,13 +356,6 @@ class AuthControllerNobodyLoggedTest extends PortailWithOneLoginModuleTestCase { public function pageShouldNotContainsAjoutPanierInput() { $this->assertNotXPath('//input[@name="ajoutPanier"]'); } - - /** @test */ - public function withAjoutPanierParemPageShouldContainsAjoutPanierInput() { - $this->bootstrap(); - $this->dispatch('/opac/auth/ajax-login/ajoutPanier/23'); - $this->assertXPath('//input[@name="ajoutPanier"][@value="23"]'); - } } diff --git a/tests/application/modules/opac/controllers/PanierControllerTest.php b/tests/application/modules/opac/controllers/PanierControllerTest.php index 74ec572d4e441c1472ac9a7f08f22465a626eaf2..370a753b84ef49259ddde3d24c9e8d60d7fe435a 100644 --- a/tests/application/modules/opac/controllers/PanierControllerTest.php +++ b/tests/application/modules/opac/controllers/PanierControllerTest.php @@ -590,7 +590,7 @@ class PanierControllerAjoutAjaxNotLoggedTest extends PanierControllerTestCase { /** @test */ public function shouldRespondAuthUrl() { $json = json_decode($this->_response->getbody()); - $this->assertEquals('/auth/ajax-login/ajoutPanier/4', $json->redirect); + $this->assertEquals('/auth/ajax-login/id_notice/4/redirect/%252Fpanier%252Fajout-ajax%252Fid_notice%252F4', $json->redirect); } /** @test */