diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8fc9b984619d79fc973f2906f85304b041364da..9166efa998851f03613016255f8379171b00a305 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ variables: test: script: - - wget http://sandbox.pergame.net/databases/default-ci-dump.sql.gz -O default-ci-dump.sql.gz + - wget http://sandbox.afi-sa.net/databases/default-ci-dump.sql.gz -O default-ci-dump.sql.gz - mysql -u$DBUSER -p$DBPASS -e "drop schema if exists ${DBNAME}; create schema ${DBNAME}" - zcat default-ci-dump.sql.gz | mysql -u$DBUSER -p$DBPASS $DBNAME - mysql -u$DBUSER -p$DBPASS -e "drop trigger if exists ${DBNAME}.datemaj_notices_update;update mysql.proc set definer='${DBUSER}@localhost' where db='${DBNAME}'" diff --git a/VERSIONS b/VERSIONS index bb6d89ea131acb27cb817d11838a7b56f2ec1d7c..e7fc9f78eb3d62b817e9c5367c54509c008d3f89 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,32 @@ +22/12/2016 - v7.7.22 + + - ticket #52395 : Résultat recherche mode mur : correction de l'affichage des liens + + - ticket #52410 : Administration : correction de la sauvegarde de la configuration des boites côté backoffice + + +19/12/2016 - v7.7.21 + + - ticket #49276 : Espace abonné : modification de l'affichage des formations + + - ticket #49216 : Charte graphique : suppression de l'effet responsive sur tous les menus verticaux. L'effet est conservé uniquement sur les menus horizontaux + + - ticket #50178 : Charte grahpique : Icone des menus : ajouter une fonction permettant d'intégrer les pictos dans les liens + + - ticket #14141 : Résultat de recherche : ajout d'un flag de disponibilité sur les documents. + + + +15/12/2016 - v7.7.20 + + - ticket #52108 : Administration des profils : Correction du paramètre de filtrage par bibliothèque. + + - ticket #51867 : Configuration : l'écran de login peut être configuré ou récupère la configuration d'une boite login du profil courant. + + - ticket #51866 : Boite Login : Correction du paramètre de profil de redirection à la connexion qui ne fonctionnait plus. + + + 05/12/2016 - v7.7.19 - ticket #50953 : Correction des liens vers les événements répétitifs dans la boite agenda diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index f597c0df6d4e2127c14a5f5a0306d5c0db44d139..d2e6064973d4d39786b0c5974342f73f63855585 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -491,16 +491,15 @@ class Admin_AccueilController extends ZendAfi_Controller_Action { protected function _updateEtRetour($data, $type) { $enreg = []; + $viewRenderer = $this->getHelper('ViewRenderer'); + foreach ($data as $clef => $valeur) $enreg[$clef] = addslashes($valeur); if ($this->config == "admin") { $this->view->id_module = $this->id_module; $this->view->properties = $this->_compactProperties($enreg); - - $viewRenderer = $this->getHelper('ViewRenderer'); - $viewRenderer->renderScript('accueil/_retour.phtml'); - return; + return $viewRenderer->renderScript('accueil/_retour.phtml'); } $module_config = $this->profil->getModuleAccueilConfig($this->id_module, $type); @@ -510,7 +509,8 @@ class Admin_AccueilController extends ZendAfi_Controller_Action { ->updateModuleConfigAccueil($this->id_module, $module_config) ->save(); - return $this->_javascriptRedirectToReferrer(); + $this->view->reload = 'SITE'; + $viewRenderer->renderScript('accueil/_retour.phtml'); } diff --git a/application/modules/admin/controllers/ModulesController.php b/application/modules/admin/controllers/ModulesController.php index 5524b1e65956d1006ecbb529694e42bd207d020c..37254e387b7af7874257cff8a39c3afe719990a2 100644 --- a/application/modules/admin/controllers/ModulesController.php +++ b/application/modules/admin/controllers/ModulesController.php @@ -97,10 +97,30 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { if ('lostpass' == $this->_getParam('action1')) return $this->_forward('auth-lost-pass'); + if ('login' == $this->_getParam('action1')) + return $this->_forward('auth-login'); + return $this->_simpleAction('auth_'.$this->_getParam('action1')); } + public function authLoginAction() { + $form = ZendAfi_Form_Configuration_Login::newWith($this->preferences); + $form->setAction($this->view->url(['controller' => 'modules', + 'action' => 'auth-login', + 'render' => 'popup'])); + + if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) { + $datas = $form->getValues(); + unset($datas['submit']); + + return $this->updateEtRetour($datas); + } + + $this->view->form = $form; + } + + public function authLostPassAction() { $form = ZendAfi_Form_Configuration_AuthLostPass::newWith($this->preferences); $form->setAction($this->view->url(['controller' => 'modules', diff --git a/application/modules/admin/views/scripts/modules/auth-login.phtml b/application/modules/admin/views/scripts/modules/auth-login.phtml new file mode 100644 index 0000000000000000000000000000000000000000..a77ca805bea2b10e567e9f4184a61fd9b389811a --- /dev/null +++ b/application/modules/admin/views/scripts/modules/auth-login.phtml @@ -0,0 +1,4 @@ +<center> + <h1><?php echo $this->_('Propriétés du module : %s', $this->titre_module); ?></h1> + <?php echo $this->renderForm($this->form); ?> +</center> diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 05f0122b4e21658be923e3d69e6aebdbd23a6dac..b3a1d86280c351a52cebcf0176be2361bb638da2 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -70,7 +70,7 @@ class AbonneController extends ZendAfi_Controller_Action { public function inscrireSessionAction() { $this->_redirect('/formations'); - if ((!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) + if ((!$session = Class_SessionFormation::find((int)$this->_getParam('id'))) || $session->isInscriptionClosed()) return $this->_helper->notify($this->_('L\'inscription à cette session est fermée')); @@ -87,9 +87,9 @@ class AbonneController extends ZendAfi_Controller_Action { public function desinscrireSessionAction() { - if (!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) { + if (!$session = Class_SessionFormation::find((int)$this->_getParam('id'))) { $this->_helper->notify($this->_('Session non trouvée')); - $this->_redirect('/formations'); + $this->_redirectToReferer(); return; } @@ -102,7 +102,7 @@ class AbonneController extends ZendAfi_Controller_Action { (new Class_Formation_UnregistrationMail($session, $this->_user))->send(); }; - $this->_redirect('/formations'); + $this->_redirectToReferer(); } diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index 8bb4bcb411d9032039384e37469f5da12f3d0204..f2cdd2421936a45e905b13bec78f669e131ec2e0 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -93,8 +93,8 @@ class AuthController extends ZendAfi_Controller_Action { } - function loginAction() { - $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); + public function loginAction() { + $this->view->preferences = $this->_loginPrefFromWidgetOrModule(); $redirect = $this->_getParam('redirect', '/opac'); $this->view->redirect = $redirect; $service = $this->_getParam('service',''); @@ -120,7 +120,7 @@ class AuthController extends ZendAfi_Controller_Action { $redirect = urldecode($this->_getParam('redirect')); $location = urldecode($this->_getParam('location')); - $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); + $this->view->preferences = $this->_loginPrefFromWidgetOrModule(); $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->disableRedirect(); @@ -139,15 +139,7 @@ class AuthController extends ZendAfi_Controller_Action { public function popupLoginAction() { - $page_settings = Class_Profil::getCurrentProfil() - ->getCfgModulesPreferences('auth','login'); - $widget_settings = Class_Profil::getCurrentProfil() - ->getModuleAccueilPreferencesByType('LOGIN'); - - $this->view->preferences = $widget_settings ? - $widget_settings : - ($page_settings ? $page_settings : []); - + $this->view->preferences = $this->_loginPrefFromWidgetOrModule(); $this->view->redirect = $this->_getParam('redirect'); $this->view->location = $this->_getParam('location'); @@ -156,12 +148,28 @@ class AuthController extends ZendAfi_Controller_Action { } + protected function _loginPrefFromWidgetOrModule() { + $module = Class_Profil::getCurrentProfil() + ->getCfgModulesPreferences('auth','login'); + + $widget = Class_Profil::getCurrentProfil() + ->getModuleAccueilPreferencesByType('LOGIN'); + + return $widget ? $widget : $module; + } + + public function boiteLoginAction() { $this->view->preferences = Class_Profil::getCurrentProfil() ->getModuleAccueilPreferencesByType('LOGIN'); + $url = ($target = Class_Profil::find((int)$this->view->preferences['profil_redirect'])) + ? $target->getUrl() + : $this->_request->getServer('HTTP_REFERER'); + + $strategy = Auth_Strategy_Abstract::strategyForController($this); - $strategy->setDefaultUrl($this->_request->getServer('HTTP_REFERER')); + $strategy->setDefaultUrl($url); $strategy->onLoginSuccess(function($user) { $user->registerNotificationsOn($this->getHelper('notify')->bePopup()); }); @@ -192,10 +200,7 @@ class AuthController extends ZendAfi_Controller_Action { public function lostpassAction() { - if(!$preferences = Class_Profil::getCurrentProfil() - ->getModuleAccueilPreferencesByType('LOGIN')) - $preferences = Class_Systeme_ModulesAccueil::getInstance() - ->getValeursParDefaut('LOGIN'); + $preferences = $this->_loginPrefFromWidgetOrModule(); $this->view->form = ZendAfi_Form_LostPassword::newWithOptions(['username_label' => $preferences["identifiant"], 'username_placeholder' => $preferences["identifiant_exemple"]]) diff --git a/application/modules/opac/controllers/FormationsController.php b/application/modules/opac/controllers/FormationsController.php index 2ad6163032b50e8a7b8b8268123ca6e17f6d5c84..cf677978caf86b0f713a6a4473d91cff526aad3b 100644 --- a/application/modules/opac/controllers/FormationsController.php +++ b/application/modules/opac/controllers/FormationsController.php @@ -28,9 +28,8 @@ class FormationsController extends ZendAfi_Controller_Action { public function indexAction() { - $this->sessions_inscrit = []; - $this->view->formations_by_year = Class_Formation::indexByYear(Class_Formation::findAll()); - $this->view->user = $this->_user; + $this->view->titre = $this->_('S\'inscrire à une formation'); + $this->view->sessions = Class_SessionFormation::findAllAvailable($this->_user); } @@ -47,5 +46,16 @@ class FormationsController extends ZendAfi_Controller_Action { null, true); $this->view->session = $session; } -} -?> \ No newline at end of file + + + public function registeredAction() { + $this->view->titre = $this->_('Mes inscriptions en cours'); + $this->view->sessions = Class_SessionFormation::findAllRegistered($this->_user); + } + + + public function doneAction() { + $this->view->titre = $this->_('Mes formations suivies'); + $this->view->sessions = Class_SessionFormation::findAllDone($this->_user); + } +} \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 994fe77db95508dc045f5b4011a395b544224034..3498df89531c852ceca3b7e0737d6654b3814295 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -22,7 +22,6 @@ class RechercheController extends ZendAfi_Controller_Action { protected $moteur, - $liste, $preferences; @@ -60,10 +59,8 @@ class RechercheController extends ZendAfi_Controller_Action { public function simpleAction() { - if ($this->view->statut == "saisie") { - $this->_redirect('opac/recherche/saisie'); - return; - } + if ($this->view->statut == "saisie") + return $this->_redirect('opac/recherche/saisie'); $params = $this->_request->getParams(); if (isset($params['q'])) { @@ -82,6 +79,7 @@ class RechercheController extends ZendAfi_Controller_Action { $search_start_time = microtime(true); $criteres_recherche = $this->newCriteresRecherches($params); + if ($this->view->statut == 'guidee') $criteres_recherche->updateRubrique('guidee'); @@ -92,18 +90,30 @@ class RechercheController extends ZendAfi_Controller_Action { && $ig->isEnabled()) $ig->logRecord($this->view->searchInspector($this->moteur)); - if ('json' == $this->_getParam('format', '')) { - $this->_renderJsonResult($search_result); - return; - } + if ('json' == $this->_getParam('format', '')) + return $this->_renderJsonResult($search_result); - if ('atom' == $this->_getParam('format', '')) { - $this->_renderAtomResult($search_result); - return; - } + if ('atom' == $this->_getParam('format', '')) + return $this->_renderAtomResult($search_result); - $this->_renderHtmlResult($search_result); - $this->view->search_duration = microtime(true) - $search_start_time; + $this->getFrontController()->getRouter()->getCurrentRoute() + ->match(str_replace(BASE_URL, + '', + $this->view->url($criteres_recherche->getCriteres()))); + + $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); + + if($criteres_recherche->getPertinence()) + $this->view->titre .= $this->_(' (recherche élargie triée par pertinence)'); + + $this->preferences['liste_format'] = $this->_getParam('liste_format', $this->preferences['liste_format']); + + if (!$search_result->isError()) + $this->addHistoRecherche(1, $criteres_recherche); + + $this->view->search_result = $search_result + ->setDuration(microtime(true) - $search_start_time) + ->setSettings($this->preferences); } @@ -120,24 +130,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function _renderHtmlResult($search_result) { - $criteres_recherche = $search_result->getCriteresRecherche(); - $this->getFrontController()->getRouter()->getCurrentRoute() - ->match(str_replace(BASE_URL, - '', - $this->view->url($criteres_recherche->getCriteres()))); - - $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); - - - $this->view->current_domain = $criteres_recherche->getCatalogue(); - - $this->showDomainBreadcrumbOnDomainBrowsing(); - $this->showCVSSearchResults($criteres_recherche); - $this->renderResultatRecherche($search_result); - } - - protected function _renderAtomResult($search_result) { $this->getHelper('ViewRenderer')->setNoRender(); @@ -166,30 +158,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function showDomainBreadcrumbOnDomainBrowsing() { - $id_module = $this->_getParam('id_module'); - if (($config = Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig($id_module)) - && ($config['type_module'] == 'DOMAIN_BROWSER')) { - $this->view->show_domain_browser = true; - $this->view->domain_id_module = $id_module; - $this->view->domain_preferences = $config['preferences']; - } - } - - - protected function showCVSSearchResults($criteres_recherche) { - $preferences = Class_Profil::getCurrentProfil()->getSearchResultSettings(); - $this->view->accessCVS = false; - if ( (new Class_AdminVar_CVS())->isCVSAccessOrDemo() - && !$preferences['cvs_display_position'] == 0) { - $this->view->accessCVS = true; - - Class_ScriptLoader::getInstance() - ->addJQueryReady("$('<div></div>').load('".$this->view->url($criteres_recherche->getCVSUrlCriteresWithFacettes(),null,true)."').appendTo($('.cvs_container'))"); - } - } - - protected function getTitreRechercheSimple($criteres_recherche) { if($title = $this->getTitleForPage($criteres_recherche)) return $title; @@ -251,42 +219,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - public function renderResultatRecherche($search_result) { - $criteres_recherche = $search_result->getCriteresRecherche(); - - $this->view->criteres_recherche = $criteres_recherche; - $this->view->url_facette=$this->view->url($criteres_recherche->getUrlCriteresWithFacettes(), - null, - true); - $this->view->url_retour = $this->view->url($criteres_recherche->getUrlRetourListe()); - $this->view->search_result = $search_result; - $this->view->tags = []; - $this->view->facettes = []; - - if ($search_result->isError()) - return; - - $this->addHistoRecherche(1, $criteres_recherche); - - $facettes_and_tags = $search_result->fetchFacetsAndTags($this->preferences); - $facettes = $facettes_and_tags['facettes']; - $tags = $facettes_and_tags['tags']; - - $this->view->getHelper('PageContext')->setContextHelper('Notice_FacettesTypeDoc', - [$facettes]); - - $this->view->_current_module['preferences']['liste_format'] = $this->_getParam('liste_format', - $this->preferences['liste_format']); - - $this->view->is_pertinence = $criteres_recherche->getPertinence(); - $this->view->tri = $criteres_recherche->getTri(); - $this->view->facettes = $facettes; - $this->view->tags = $tags; - $this->view->bookmarks = $facettes_and_tags['bookmarks']; - $this->view->suggests = $facettes_and_tags['suggests']; - } - - public function avanceeAction() { $annexes = Class_CodifAnnexe::findAllBy(['invisible' => 0, 'order' => 'libelle']); diff --git a/application/modules/opac/views/scripts/abonne/_formation.phtml b/application/modules/opac/views/scripts/abonne/_formation.phtml deleted file mode 100644 index 4d6924ab2534735fc147ef97537bdf25cfb3b297..0000000000000000000000000000000000000000 --- a/application/modules/opac/views/scripts/abonne/_formation.phtml +++ /dev/null @@ -1,3 +0,0 @@ -<?php -echo $this->renderFormation($this->formation); -?> diff --git a/application/modules/opac/views/scripts/formations/done.phtml b/application/modules/opac/views/scripts/formations/done.phtml new file mode 100644 index 0000000000000000000000000000000000000000..5792b31b0066ddf54134fc5f79d2fc1e73a481ce --- /dev/null +++ b/application/modules/opac/views/scripts/formations/done.phtml @@ -0,0 +1,29 @@ +<?php +$this->openBoite($this->titre); + +$details_link = $this->url(['action' => 'detail-session', + 'id' => null]); + +$current_link = $this->url(); + +echo $this->tagModelTable( + $this->sessions, + [$this->_('Formation'), + $this->_('Date'), + $this->_('Lieu')], + ['libelle_formation', + 'date_debut_texte', + 'libelle_lieu'], + [function($model) use($details_link, $current_link) { + return $this->modelActions($model, + [['url' => $details_link . '/id/%s?retour=' . $current_link, + 'icon' => 'view', + 'label' => $this->_('Details de la session %s', + $model->getLabel())]]); + }], + 'done_sessions' +); + +$this->closeBoite(); + +echo $this->abonne_RetourFiche(); diff --git a/application/modules/opac/views/scripts/formations/index.phtml b/application/modules/opac/views/scripts/formations/index.phtml index 865911adc5c220d07d66917eb976501391f710e8..c1566795908dd9c036dd79c6e1cbcb7b84783d11 100644 --- a/application/modules/opac/views/scripts/formations/index.phtml +++ b/application/modules/opac/views/scripts/formations/index.phtml @@ -1,20 +1,44 @@ <?php -echo $this->openBoite('Formations'); +echo $this->openBoite($this->titre); -if ($this->user && !$this->user->hasRightSuivreFormation()) - echo sprintf('<p class="error">%s</p>', - $this->_("Vous n'avez pas les droits suffisants pour vous inscrire à une formation")); +$details_link = $this->url(['action' => 'detail-session', + 'id' => null]); -foreach($this->formations_by_year as $year => $formations) { - echo '<div class="formations">'; - echo $this->partialCycle('formations/_formation.phtml', - 'formation', - $formations, - ['first', 'second']); - echo '</div>'; -} +$register_link = $this->url(['controller' => 'abonne', + 'action' => 'inscrire-session', + 'id' => null]); -echo $this->closeBoite(); -?> +$current_link = $this->url(); -<?php if ($this->user) echo $this->abonne_RetourFiche(); ?> +echo $this->tagModelTable( + $this->sessions, + [$this->_('Formation'), + $this->_('Date'), + $this->_('Lieu'), + $this->_('Informations')], + ['libelle_formation', + 'date_debut_texte', + 'libelle_lieu', + 'infos'], + [function($model) use($details_link, $register_link, $current_link) { + return $this->modelActions($model, + [['url' => $details_link . '/id/%s?retour=' . $current_link, + 'icon' => 'view', + 'label' => $this->_('Details de la session %s', + $model->getLabel())], + ['url' => $register_link . '/id/%s', + 'icon' => 'add_user', + 'label' => $this->_('S\'inscrire à la session %s', + $model->getLabel())]] + );}], + 'available_sessions', + null, + ['infos' => function($model) { + return $this->_('Date limite d\'inscription : %s', + $model->getDateLimiteInscriptionHumanRead()); + }] +); + +$this->closeBoite(); + +echo $this->abonne_RetourFiche(); diff --git a/application/modules/opac/views/scripts/formations/registered.phtml b/application/modules/opac/views/scripts/formations/registered.phtml new file mode 100644 index 0000000000000000000000000000000000000000..cedc05fb65ef486c36be93eb591b3eec5bde53a3 --- /dev/null +++ b/application/modules/opac/views/scripts/formations/registered.phtml @@ -0,0 +1,51 @@ +<?php +$this->openBoite($this->titre); + +$details_link = $this->url(['action' => 'detail-session', + 'id' => null]); + +$unregister_link = $this->url(['controller' => 'abonne', + 'action' => 'desinscrire-session', + 'id' => null]); +$current_link = $this->url(); + +Class_ScriptLoader::getInstance() +->addJQueryReady(' +$(".actions a[href*=\'desinscrire\']").click(function(event) { + return confirm($(this).find("img").attr("alt") + " ?"); +}); +'); + +echo $this->tagModelTable( + $this->sessions, + [$this->_('Formation'), + $this->_('Date'), + $this->_('Lieu'), + $this->_('Informations')], + ['libelle_formation', + 'date_debut_texte', + 'libelle_lieu', + 'infos'], + [function($model) use($details_link, $unregister_link, $current_link) { + return $this->modelActions($model, + [['url' => $details_link . '/id/%s?retour=' . $current_link, + 'icon' => 'view', + 'label' => $this->_('Details de la session %s', + $model->getLabel())], + + ['url' => $unregister_link . '/id/%s', + 'icon' => 'delete', + 'label' => $this->_('Se désinscrire de la session %s', + $model->getLabel())]]); + }], + 'registered_sessions', + null, + ['infos' => function($model) { + return $this->_('Date limite d\'inscription : %s', + $model->getDateLimiteInscriptionHumanRead()); + }] +); + +$this->closeBoite(); + +echo $this->abonne_RetourFiche(); diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index 57607f6b61c472f5b53828ce8a6e53bcaca66559..17c12220253400607b6ebdbdd4864aa47b73db08 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -1,145 +1,6 @@ <?php -$preferences = $this->_current_module["preferences"]; - -$hasFacettes = (1 == $preferences["facettes_actif"]) && $this->search_result->getRecordsCount(); -$hasTags = (1 == $preferences["tags_actif"]) && $this->search_result->getRecordsCount(); -$tagsPosition = $preferences["tags_position"]; - -if ($this->is_pertinence) { - $this->titre .= $this->_(" (recherche élargie triée par pertinence)"); -} - $this->openBoite($this->titre); -?> -<div class="resultats_page"> - <?php - echo $this->tagTriRecherche($this->criteres_recherche); - echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_duration); - echo $this->tagNombreDePages($this->criteres_recherche->getPage()); - - if ($this->search_result->getRubrics() || $this->search_result->getBreadcrumb()) { - echo $this->render('recherche/guidee.phtml'); - } else { - echo $this->tagCriteresRecherche($this->criteres_recherche); - } - - if ($this->show_domain_browser) - echo $this->renderDomainBrowser($this->current_domain, - $this->domain_id_module, - $this->domain_preferences); - ?> - - <div class="recherche_actions"> - <span> - <?php - echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlRetourRechercheInitiale(), null, true), - $this->_('Retour à la recherche initiale'), - ['title' => $this->_('Accéder au formulaire de recherche pré-rempli avec les critères actuels')]);?> - </span> - <span> - <?php echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlNouvelleRecherche(), null, true), - $this->_('Nouvelle recherche'), - ['title' => $this->_('Lancer une recherche avec réinitialisation des paramètres')]); ?> - </span> - <?php - if ((int)$preferences['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled()) - echo $this->tag('span', - $this->tagAnchor(['controller' => 'abonne', - 'action' => 'suggestion-achat'], - $this->_('Suggérer un achat'), - ['title' => $this->_('Envoyer une demande d\'achat de document')])); - ?> - <span class="print"> - <?php - echo $this->tagPrintLink($this->search_result->fetchRecords(), 'Notice_List'); - ?> - </span> - </div> - <?php echo $this->tagSearchExtension($this->criteres_recherche); ?> -</div> - -<?php +echo $this->Search_Header($this->search_result); $this->closeBoite(); -?> - - -<?php -$html_liste_notices = $this->listeNotices($this->search_result->fetchRecords(), - $this->search_result->getRecordsCount(), - $this->criteres_recherche->getPage(), - $preferences, - $this->criteres_recherche); - -$html_pager = $this->pager($this->search_result->getRecordsCount(), - $this->criteres_recherche->getPageSize(), - $this->criteres_recherche->getPage(), - array_merge($this->criteres_recherche->getUrlRetourListe(), - ['controller' => 'recherche', - 'action' => 'simple'])); - -$nuage_tags_title = $preferences["tags_message"] - ? $this->tag('h2', $preferences["tags_message"]) - : ''; - -$html_nuage_tags = $this->tag('div', - $nuage_tags_title - . $this->nuageTags($this->tags, null, $this->criteres_recherche), - ['class' => 'facette_outer nuage_outer']); - -$html_facettes = '<div class="facette_outer" style="margin-left:10px;margin-top:17px">'. - ($preferences["facettes_message"] - ? ('<h2>'.$preferences["facettes_message"].'</h2>') - : '') - . $this->facettes($this->facettes, - $preferences, - $this->criteres_recherche) - . '</div>'; -?> - - - -<div style="width:100%" class="conteneur_simple"> - - <?php - $html_result='<div class="resultat_recherche">'. - (!$preferences['cvs_autres_resultats'] == '' - ? '<h1>'.$preferences['cvs_autres_resultats'].'</h1>' - : ''); - - if (Class_AdminVar::displayPagerOnTop()) $html_result .= $html_pager; - $html_result .= $html_liste_notices; - if (Class_AdminVar::displayPagerOnBottom()) $html_result .= $html_pager; - $html_result .= '</div>'; - - $html_suggests = $this->suggests($this->suggests, $this->criteres_recherche); - $html_bookmarks = $this->bookmarks($this->bookmarks, $this->criteres_recherche, $preferences); - - $html_filters = ''; - if ($hasFacettes || $hasTags) { - $html_filters .= '<div class="filtre_recherche">'; - $html_filters .= $html_suggests; - $html_filters .= $html_bookmarks; - if ($hasTags && (1 == $tagsPosition)) $html_filters.= $html_nuage_tags; - if ($hasFacettes) $html_filters.= $html_facettes; - if ($hasTags && (2 == $tagsPosition)) $html_filters.= $html_nuage_tags; - $html_filters.= '</div>'; - } - ?> - <?php - $html_cvs=''; - if ($this->accessCVS) - $html_cvs .= '<div class="cvs_container position_'.$preferences['cvs_display_position'].'" style="display:none">'. - '<h1>'.$preferences['cvs_resultat_titre'].'</h1>'. - '</div>'; - - ?> - <?php - echo $this->Search_Result($preferences, $html_result, $html_filters, $html_cvs); - ?> - - <div class="clear"></div> -</div> - -<?php Class_ScriptLoader::getInstance() - ->addOPACScript('recherche') - ->addSkinStyleSheet('recherche'); ?> +echo $this->Search_Result($this->search_result); +?> \ No newline at end of file diff --git a/application/modules/telephone/views/scripts/recherche/simple.phtml b/application/modules/telephone/views/scripts/recherche/simple.phtml index abcca721d40c233497b051ffe78e67cb1a5c73d7..73acb99fa83bc114c769810bbd57c8cb7d8a504e 100644 --- a/application/modules/telephone/views/scripts/recherche/simple.phtml +++ b/application/modules/telephone/views/scripts/recherche/simple.phtml @@ -1,16 +1,19 @@ <ul data-role="listview"> <?php -echo $this->toolbar("Recherche", $this->url(array(), null, true)); -echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_duration); +$criteria = $this->search_result->getCriteresRecherche(); +$settings = $this->search_result->getSettings(); + +echo $this->toolbar($this->_('Recherche'), $this->url([], null, true)); +echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_result->getDuration()); echo $this->listeNotices($this->search_result->fetchRecords(), $this->search_result->getRecordsCount(), - $this->criteres_recherche->getPage(), - $this->preferences); + $criteria->getPage(), + $settings); echo $this->pager($this->search_result->getRecordsCount(), - $this->preferences["liste_nb_par_page"], - $this->criteres_recherche->getPage()); + $criteria->getPageSize(), + $criteria->getPage()); ?> </ul> diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 13f47b790d0ccd70376a14cfd9f33e5e404127fd..0db437f09cfe9acc8d3bca0c6828bcb4c6cf7ae4 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -823,6 +823,11 @@ class Class_CriteresRecherche { } + public function getIdModule() { + return $this->getParam('id_module', 0); + } + + function updateRubrique($rubrique) { return $this->_params['rubrique']=$rubrique; } diff --git a/library/Class/Indexation.php b/library/Class/Indexation.php index cf724ec69efe87b7573b2317f53259373fb00e90..4668308c8ca4913bcdf7f2c3aa20424089eae7d9 100644 --- a/library/Class/Indexation.php +++ b/library/Class/Indexation.php @@ -22,25 +22,74 @@ class Class_Indexation { protected static $_instance, - $_alpha_maj_cache = []; - - private $articles; // Articles rejetes - private $inclu; // Mots inclus - private $exclu; // Mots vides - private $pluriel; // Règles des pluriels - private $tableMajFrom, $tableMajTo = []; // Table de transco pour majuscules - private $tableMajUtf8; // Table de transco pour majuscules accentuées utf8 - - private $accents = ['É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E','Ã' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', - 'Ã…' => 'A', 'Ã' => 'A', 'Æ' => 'E','Ã' => 'I', 'ÃŽ' => 'I', 'ÃŒ' => 'I', 'Ã' => 'I', - 'Ô' => 'O', 'Ö' => 'O', 'Ã’' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O', 'Å’' => 'OEU', - 'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ãœ' => 'U','Ñ' => 'N', 'Ç' => 'S', '¿' => 'E']; - - private $min2maj = ['é' => 'É', 'è' => 'È', 'ë' => 'Ë', 'ê' => 'Ê','á' => 'Ã', 'â' => 'Â', 'à ' => 'À', 'Ä' => 'A', - 'Â' => 'A', 'Ã¥' => 'Ã…', 'ã' => 'Ã', 'æ' => 'Æ', 'ï' => 'Ã', 'î' => 'ÃŽ', 'ì' => 'ÃŒ', 'Ã' => 'Ã', - 'ô' => 'Ô', 'ö' => 'Ö', 'ò' => 'Ã’', 'ó' => 'Ó','õ' => 'Õ', 'ø' => 'Ø', 'Å“' => 'Å’', - 'ú' => 'Ú', 'ù' => 'Ù', 'û' => 'Û', 'ü' => 'Ãœ','ç' => 'Ç', 'ñ' => 'Ñ', 'ß' => 'S']; - + $_alpha_maj_cache = [], + $_accents = ['É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E','Ã' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', + 'Ã…' => 'A', 'Ã' => 'A', 'Æ' => 'E','Ã' => 'I', 'ÃŽ' => 'I', 'ÃŒ' => 'I', 'Ã' => 'I', + 'Ô' => 'O', 'Ö' => 'O', 'Ã’' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O', 'Å’' => 'OEU', + 'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ãœ' => 'U','Ñ' => 'N', 'Ç' => 'S', '¿' => 'E'], + + $_min2maj = ['é' => 'É', 'è' => 'È', 'ë' => 'Ë', 'ê' => 'Ê','á' => 'Ã', 'â' => 'Â', 'à ' => 'À', 'Ä' => 'A', + 'Â' => 'A', 'Ã¥' => 'Ã…', 'ã' => 'Ã', 'æ' => 'Æ', 'ï' => 'Ã', 'î' => 'ÃŽ', 'ì' => 'ÃŒ', 'Ã' => 'Ã', + 'ô' => 'Ô', 'ö' => 'Ö', 'ò' => 'Ã’', 'ó' => 'Ó','õ' => 'Õ', 'ø' => 'Ø', 'Å“' => 'Å’', + 'ú' => 'Ú', 'ù' => 'Ù', 'û' => 'Û', 'ü' => 'Ãœ','ç' => 'Ç', 'ñ' => 'Ñ', 'ß' => 'S'], + + $_articles = ['L\'','LE ','LA ','LES ','UN ','UNE '], + + $_inclu = ['AN','AS','OR','U2','AI','LU','XO','DO','RE','MI','FA','SI','AC','DC','XX','B','C','D','E','F','G','H','I','J','K','M','P','Q','R','S','T','V','W','X','Y','Z','L','YU','UT','LI','OC','PI','ZU','WU','TO','OZ','ZZ','XX', 'PC', 'DS'], + + $_exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES'], + + $_pluriel = [ ['AIL','AULX'], + ['AVAL','AVALS'], + ['BAIL','BAUX'], + ['BAL','BALS'], + ['BANAL','BANALS'], + ['BANCAL','BANCALS'], + ['BIJOU','BIJOUX'], + ['BLEU','BLEUS'], + ['CAILLOU','CAILLOUX'], + ['CAL','CALS'], + ['CARNAVAL','CARNAVALS'], + ['CEREMONIAL','CEREMONIALS'], + ['CHACAL','CHACALS'], + ['CHORAL','CHORALS'], + ['CHOU','CHOUX'], + ['CORAIL','CORAUX'], + ['DETAIL','DETAILS'], + ['EMAIL','EMAUX'], + ['EMEU','EMEUS'], + ['ETAL','ETALS'], + ['FATAL','FATALS'], + ['FESTIVAL','FESTIVALS'], + ['GEMMAIL','GEMMAUX'], + ['GENOU','GENOUX'], + ['HIBOU','HIBOUX'], + ['JOUJOU','JOUJOUX'], + ['LANDAU','LANDAUX'], + ['NATAL','NATALS'], + ['OEIL','YEUX'], + ['PAL','PALS'], + ['PNEU','PNEUS'], + ['POU','POUX'], + ['RECITAL','RECITALS'], + ['REGAL','REGALS'], + ['SARRAU','SARRAUS'], + ['SOUPIRAIL','SOUPIRAUX'], + ['TONAL','TONALS'], + ['TRAVAIL','TRAVAUX'], + ['VAL','VALS'], + ['VENTAIL','VENTAUX'], + ['VIRGINAL','VIRGINALS'], + ['VITRAIL','VITRAUX'], + ['*EAU','*EAUX'], + ['*AL','*AUX'], + ['*EU','*EUX'], + ['*AU','*AUX'], + ['PC','PC'], + ['DS','DS']], + + $_tableMajFrom, + $_tableMajTo; public static function getInstance() { if(!static::$_instance) @@ -50,104 +99,18 @@ class Class_Indexation { function __construct() { - // Lire formes rejetées - $this->articles = ['L\'','LE ','LA ','LES ','UN ','UNE ']; - - $this->inclu = ['AN','AS','OR','U2','AI','LU','XO','DO','RE','MI','FA','SI','AC','DC','XX','B','C','D','E','F','G','H','I','J','K','M','P','Q','R','S','T','V','W','X','Y','Z','L','YU','UT','LI','OC','PI','ZU','WU','TO','OZ','ZZ','XX', 'PC', 'DS']; - - $this->exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES']; - - // Pluriels - $this->pluriel = [ ['AIL','AULX'], - ['AVAL','AVALS'], - ['BAIL','BAUX'], - ['BAL','BALS'], - ['BANAL','BANALS'], - ['BANCAL','BANCALS'], - ['BIJOU','BIJOUX'], - ['BLEU','BLEUS'], - ['CAILLOU','CAILLOUX'], - ['CAL','CALS'], - ['CARNAVAL','CARNAVALS'], - ['CEREMONIAL','CEREMONIALS'], - ['CHACAL','CHACALS'], - ['CHORAL','CHORALS'], - ['CHOU','CHOUX'], - ['CORAIL','CORAUX'], - ['DETAIL','DETAILS'], - ['EMAIL','EMAUX'], - ['EMEU','EMEUS'], - ['ETAL','ETALS'], - ['FATAL','FATALS'], - ['FESTIVAL','FESTIVALS'], - ['GEMMAIL','GEMMAUX'], - ['GENOU','GENOUX'], - ['HIBOU','HIBOUX'], - ['JOUJOU','JOUJOUX'], - ['LANDAU','LANDAUX'], - ['NATAL','NATALS'], - ['OEIL','YEUX'], - ['PAL','PALS'], - ['PNEU','PNEUS'], - ['POU','POUX'], - ['RECITAL','RECITALS'], - ['REGAL','REGALS'], - ['SARRAU','SARRAUS'], - ['SOUPIRAIL','SOUPIRAUX'], - ['TONAL','TONALS'], - ['TRAVAIL','TRAVAUX'], - ['VAL','VALS'], - ['VENTAIL','VENTAUX'], - ['VIRGINAL','VIRGINALS'], - ['VITRAIL','VITRAUX'], - ['*EAU','*EAUX'], - ['*AL','*AUX'], - ['*EU','*EUX'], - ['*AU','*AUX'], - ['PC','PC'], - ['DS','DS']]; - - // Init table ascii pour majuscules - $this->tableMajTo = str_split(str_repeat( ' ', 42 ) - . '* 0123456789 ' - . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - . str_repeat( ' ', 63) - .'AAAAAAACEEEEIIII NOOOOO UUUUY AAAAAAACEEEEIIII NOOOOO UUUUY Y'); - - for($i=0; $i<count($this->tableMajTo); $i++) - $this->tableMajFrom[] = chr($i); - - - $this->tableMajUtf8 = [chr(0xC9) => 'E', - 'È' => 'E', - 'Ë' => 'E', - 'Ê' => 'E', - 'Ã' => 'A', - 'À' => 'A', - 'Ä' => 'A', - 'Â' => 'A', - 'Ã…' => 'A', - 'Ã' => 'A', - 'Æ' => 'E', - 'Ã' => 'I', - 'ÃŽ' => 'I', - 'ÃŒ' => 'I', - 'Ã' => 'I', - 'Ô' => 'O', - 'Ö' => 'O', - 'Ã’' => 'O', - 'Ó' => 'O', - 'Õ' => 'O', - 'Ø' => 'O', - 'Å’' => 'OEU', - 'Ú' => 'U', - 'Ù' => 'U', - 'Û' => 'U', - 'Ãœ' => 'U', - 'Ñ' => 'N', - 'Ç' => 'S', - '¿' => 'E']; + if (isset(static::$_tableMajTo)) + return; + + static::$_tableMajTo = str_split(str_repeat( ' ', 42 ) + . '* 0123456789 ' + . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + . str_repeat( ' ', 63) + .'AAAAAAACEEEEIIII NOOOOO UUUUY AAAAAAACEEEEIIII NOOOOO UUUUY Y'); + + for($i=0; $i<count(static::$_tableMajTo); $i++) + static::$_tableMajFrom[] = chr($i); } @@ -155,7 +118,7 @@ class Class_Indexation { public function codeAlphaTitre($titre) { $titre=$this->alphaMaj($titre); - foreach($this->articles as $article) + foreach(static::$_articles as $article) { $lg=strlen($article); if(strLeft($titre, $lg)==$article) {$titre=strMid($titre,$lg,256); break;} @@ -186,8 +149,8 @@ class Class_Indexation { if (isset(static::$_alpha_maj_cache[$chaine])) return static::$_alpha_maj_cache[$chaine]; - return static::$_alpha_maj_cache[$chaine] = trim(str_replace($this->tableMajFrom, - $this->tableMajTo, + return static::$_alpha_maj_cache[$chaine] = trim(str_replace(static::$_tableMajFrom, + static::$_tableMajTo, utf8_decode($chaine))); } @@ -222,14 +185,14 @@ class Class_Indexation { foreach($words as $word) { if(strlen($word) < 3 && intVal($word) == false) { - if(false == in_array($word, $this->inclu)) + if(false == in_array($word, static::$_inclu)) continue; if( 1 == strlen($word)) $word .= '00'; } - if(true == in_array($word, $this->exclu)) + if(true == in_array($word, static::$_exclu)) continue; $new[] = $word; @@ -266,7 +229,7 @@ class Class_Indexation { { if( strToUpper($mot) != $mot ) $mot=$this->alphaMaj($mot); if(!trim($mot)) return false; - foreach($this->pluriel as $regle) + foreach(static::$_pluriel as $regle) { if(strLeft($regle[0],1) != '*') { @@ -296,7 +259,7 @@ class Class_Indexation { // --------------------------------------------------- public function isMotInclu($mot) { - return in_array($mot, $this->inclu); + return in_array($mot, static::$_inclu); } // --------------------------------------------------- @@ -309,8 +272,8 @@ class Class_Indexation { } function phonetixCompute($sIn) { - $sIn = strtr( $sIn, $this->accents); // minuscules accentuées ou composées en majuscules simples - $sIn = strtr( $sIn, $this->min2maj); // majuscules accentuées ou composées en majuscules simples + $sIn = strtr( $sIn, static::$_accents); // minuscules accentuées ou composées en majuscules simples + $sIn = strtr( $sIn, static::$_min2maj); // majuscules accentuées ou composées en majuscules simples $sIn = strtoupper( $sIn ); // on passe tout le reste en majuscules $sIn = preg_replace( '`[^A-Z]`', '', $sIn ); // on garde uniquement les lettres de A à Z diff --git a/library/Class/MoteurRecherche/Result.php b/library/Class/MoteurRecherche/Result.php index ca7b2c8427f1833d05b4584957b0c41777bf1155..7cf041e9656adfcaf0516c5d882fecbbdfa9dd6f 100644 --- a/library/Class/MoteurRecherche/Result.php +++ b/library/Class/MoteurRecherche/Result.php @@ -33,7 +33,9 @@ class Class_MoteurRecherche_Result { $_error_message = '', $_records_query = '', $_facets, - $_criteres_recherche; + $_criteres_recherche, + $_duration, + $_settings; public function __construct($search_engine, $criteres_recherche) { $this->_criteres_recherche = $criteres_recherche; @@ -101,6 +103,11 @@ class Class_MoteurRecherche_Result { } + public function getRecords() { + return $this->_records; + } + + public function recordsDo($closure) { $this->fetchRecords(); array_map($closure, $this->_records); @@ -172,6 +179,26 @@ class Class_MoteurRecherche_Result { public function getWordCount() { return $this->_word_count; } -} -?> \ No newline at end of file + + public function getDuration() { + return $this->_duration; + } + + + public function setDuration($duration) { + $this->_duration = $duration; + return $this; + } + + + public function getSettings() { + return $this->_settings; + } + + + public function setSettings($settings) { + $this->_settings = $settings; + return $this; + } +} \ No newline at end of file diff --git a/library/Class/Notice.php b/library/Class/Notice.php index a987a5a9d1dcc74a9902c8dd7cfbf4cb3a79cdb3..028ba8b7baff0bd5eb15607d45ca04fd61316582 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1676,6 +1676,7 @@ class Class_Notice extends Storm_Model_Abstract { return $enreg; } + public function hasExemplaireDisponible() { foreach ($this->getExemplaires() as $exemplaire) if ($exemplaire->isDisponible()) @@ -1683,6 +1684,35 @@ class Class_Notice extends Storm_Model_Abstract { return false; } + + public function getAvailabilityFromFacet() { + $existing = $this->getAvailableLibrariesFromFacet(); + return !empty($existing); + } + + + public function getAvailableLibrariesFromFacet() { + $existing = array_filter( + Class_Notice_Facette::parseFacettesFromNoticeField($this->getFacettes()), + function($facet) { + return $facet->isAvailability(); + }); + + $values = array_unique( + array_filter( + array_map(function($facet) + { + return $facet->getValue(); + }, + $existing))); + + if(!$values) + return []; + + return Class_Bib::findAllBy(['id_site' => $values]); + } + + public function hasExemplaireReservable() { foreach ($this->getExemplaires() as $exemplaire) if ($exemplaire->isReservable()) @@ -1792,7 +1822,6 @@ class Class_Notice extends Storm_Model_Abstract { $facettes []= $f; } - $facettes []= Class_CodifTypeDoc::CODE_FACETTE. $this->getTypeDoc(); $date_nouveaute = ""; diff --git a/library/Class/Notice/Facette.php b/library/Class/Notice/Facette.php index f82d93c8207b5773fdc024d1b1526f18deba6e0f..3335598fb256ae59caa49f162e0a45b210ead9dd 100644 --- a/library/Class/Notice/Facette.php +++ b/library/Class/Notice/Facette.php @@ -98,4 +98,9 @@ class Class_Notice_Facette { [Class_CodifThesaurus::fixedIdOf('LibraryNovelty'), Class_CodifThesaurus::fixedIdOf('AnnexeNovelty')]); } + + + public function isAvailability() { + return Class_Codification::CODE_AVAILABILITY == $this->getGroupCodeFromKey(); + } } \ No newline at end of file diff --git a/library/Class/SessionFormation.php b/library/Class/SessionFormation.php index cc23ef3d06ca5762257ba0437f13967633c439a4..894b15e30d1b99411e67c40cc260ed68ec480831 100644 --- a/library/Class/SessionFormation.php +++ b/library/Class/SessionFormation.php @@ -21,10 +21,50 @@ class SessionFormationLoader extends Storm_Model_Loader { + public function findAllAvailable($user) { + if(!$user) + return []; + + return (new Storm_Model_Collection(Class_SessionFormation::findAllBy(['order' => 'date_debut']))) + ->reject(function($session) use ($user) + { + return in_array($session, $user->getSessionFormations()); + }) + ->select(function($session) use ($user) + { + return $session->isSubscriableFor($user) + && $session->isVisible(); + }) + ->getArrayCopy(); + } + + + public function findAllRegistered($user) { + if (!$user) + return []; + + return (new Storm_Model_Collection($user->getSessionFormations())) + ->reject('alreadyStarted') + ->getArrayCopy(); + } + + + public function findAllDone($user) { + if(!$user) + return []; + + return (new Storm_Model_Collection($user->getSessionFormations())) + ->select('alreadyStarted') + ->getArrayCopy(); + } + + public function getAllSessionsForYear($year) { return Class_SessionFormation::findAllBy(['where' => 'left(date_debut, 4)="'.$year.'"', 'order' => 'date_debut']); } + + public function getYears() { $sessions = Class_SessionFormation::findAllBy(['order' => 'id desc']); $years = []; @@ -35,10 +75,10 @@ class SessionFormationLoader extends Storm_Model_Loader { return $years; } + public function getCurrentYear() { return self::getCurrentYear(); } - } @@ -90,24 +130,24 @@ class Class_SessionFormation extends Storm_Model_Abstract { return $this->getLibelleFormation().', '.Class_Date::humanDate($this->getDateDebut(), 'd MMMM YYYY'); } + public function getLibelle() { return $this->getLabel(); } + + public function alreadyStarted() { + return strtotime($this->getDateDebut()) < strtotime($this->getTimeSource()->dateYmd()); + } + /** * @return bool */ public function isInscriptionClosed() { - if (strtotime($this->getDateDebut()) < strtotime(self::getTimeSource()->dateYmd())) - return true; - - if ($this->isAnnule()) - return true; - - if(!$this->hasDateLimiteInscription()) - return true; - - return $this->isDateSubscriptionExhausted(); + return $this->alreadyStarted() + || $this->isAnnule() + || (!$this->hasDateLimiteInscription()) + || $this->isDateSubscriptionExhausted(); } @@ -247,7 +287,7 @@ class Class_SessionFormation extends Storm_Model_Abstract { if($user && !$user->hasRightSuivreFormation()) return false; - if(!$this->isValid() || $this->isFull() || $this->isAnnule() || $this->isInscriptionClosed()) + if((!$this->isValid()) || $this->isFull() || $this->isAnnule() || $this->isInscriptionClosed()) return false; return true; diff --git a/library/Class/Systeme/ModulesAppli.php b/library/Class/Systeme/ModulesAppli.php index 2c5bc6383b727bb68a6a379af7d6225bc56b52af..b092975a7ce68ac3e86f6bacee8d95f2033f36c3 100644 --- a/library/Class/Systeme/ModulesAppli.php +++ b/library/Class/Systeme/ModulesAppli.php @@ -32,6 +32,12 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { const LISTE_FORMAT_MUR = 4; const LISTE_FORMAT_CHRONO = 5; + const + CVS_NONE = 0, + CVS_TOP_OF_FACETS = 1, + CVS_BOTTOM_OF_FACETS = 2, + CVS_TOP_OF_RESULT = 3, + CVS_BOTTOM_OF_RESULT = 4; /** @@ -168,6 +174,16 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { } + public static function getCVSPosition() { + $instance = new static(); + return [Class_Systeme_ModulesAppli::CVS_NONE => $instance->_('Ne pas afficher'), + Class_Systeme_ModulesAppli::CVS_TOP_OF_FACETS => $instance->_('Afficher au dessus des facettes'), + Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_FACETS => $instance->_('Afficher au dessous des facettes'), + Class_Systeme_ModulesAppli::CVS_TOP_OF_RESULT => $instance->_('Afficher au dessus des résultats'), + Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_RESULT => $instance->_('Afficher au dessous des résultats')]; + } + + /** * @param string $type_module * @param string $action diff --git a/library/Class/Zone.php b/library/Class/Zone.php index 26202a697e4c8823d8e415d0bc6fb6f8f16d0d3f..52cbf31e92d36a4f73b60d927ea5e7a39438f7fe 100644 --- a/library/Class/Zone.php +++ b/library/Class/Zone.php @@ -43,14 +43,13 @@ class ZoneLoader extends Storm_Model_Loader { } - public function getZones($id_zone=0) - { - return - Class_Zone::getLoader()->findAllBy(array_filter(['id_zone' => $id_zone, - 'order' => 'LIBELLE'])); + public function getZones($id_zone=0) { + $params = ['order' => 'libelle']; + if ((int)$id_zone) + $params['id_zone'] = (int)$id_zone; + return Class_Zone::findAllBy($params); } - } diff --git a/library/ZendAfi/Form/Configuration/ArticleWidget.php b/library/ZendAfi/Form/Configuration/ArticleWidget.php index 6b62053735120032bb302d82830dc83215a80c89..d019468266445778091a38af497ddcba168f4435 100644 --- a/library/ZendAfi/Form/Configuration/ArticleWidget.php +++ b/library/ZendAfi/Form/Configuration/ArticleWidget.php @@ -25,11 +25,11 @@ class ZendAfi_Form_Configuration_ArticleWidget extends ZendAfi_Form { public function init() { Class_ScriptLoader::getInstance() ->addJQueryReady( - 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(3)", ["DateCreationDesc", "DebutPublicationDesc", "EventDebut", "Random", "CommentCount"]);' + 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(2)", ["DateCreationDesc", "DebutPublicationDesc", "EventDebut", "Random", "CommentCount"]);' - . 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(4)", "Random");' + . 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(3)", "Random");' - . 'checkBoxToggleVisibilityForElement("#allow_link_on_title", "#fieldset-affichage tr:nth-child(4)", true);'); + . 'checkBoxToggleVisibilityForElement("#allow_link_on_title", "#fieldset-affichage tr:nth-child(3)", true);'); parent::init(); @@ -107,16 +107,14 @@ class ZendAfi_Form_Configuration_ArticleWidget extends ZendAfi_Form { 'general', ['legend' => $this->_('Généralités')]) - ->addDisplayGroup(['articles_selector', - 'display_order', - 'nb_aff', - 'nb_analyse'], - 'datas', + ->addDisplayGroup(['articles_selector'], + 'articles', ['legend' => $this->_('Articles à afficher')]) - ->addDisplayGroup(['articles_selector', 'display_order', 'nb_aff', 'nb_analyse'], + + ->addDisplayGroup(['display_order', 'nb_aff', 'nb_analyse'], 'datas', - ['legend' => $this->_('Articles à afficher')]) + ['legend' => $this->_('Mode sélection')]) ->addDisplayGroup(['boite', 'display_titles_only', diff --git a/library/ZendAfi/Form/Configuration/BaseLogin.php b/library/ZendAfi/Form/Configuration/BaseLogin.php new file mode 100644 index 0000000000000000000000000000000000000000..b4b0e75c5d642bbea6df0d174c909249bfdf5426 --- /dev/null +++ b/library/ZendAfi/Form/Configuration/BaseLogin.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Form_Configuration_BaseLogin extends ZendAfi_Form { + public function init() { + parent::init(); + + $this + ->setAttrib('id', 'configuration_login_widget') + + ->addElement('select', + 'boite', + ['label' => $this->_('Style de boite'), + 'multiOptions' => ( + new Class_Profil_Templates( + Class_Profil::getCurrentProfil()))->toArray()]) + + ->addElement('text', + 'titre', + ['label' => $this->_('Titre')]) + ->addElement('text', + 'titre_connecte', + ['label' => $this->_('Titre une fois connecté')]) + ->addElement('text', + 'message_connecte', + ['label' => $this->_('Message de bienvenue')]) + ->addElement('text', + 'identifiant', + ['label' => $this->_('Libellé identifiant')]) + ->addElement('text', + 'identifiant_exemple', + ['label' => $this->_('Texte dans le champ de saisie de l\'identifiant')]) + ->addElement('text', + 'mot_de_passe', + ['label' => $this->_('Libellé mot de passe')]) + ->addElement('text', + 'mot_de_passe_exemple', + ['label' => $this->_('Texte dans le champ de saisie du mot de passe')]) + ->addElement('checkbox', + 'autocomplete_off', + ['label' => $this->_('Désactiver l\'auto-complétion'), + 'multiOptions' => [1,0]]) + ->addElement('text', + 'lien_connexion', + ['label' => $this->_('Libellé du lien de connexion')]) + ->addElement('text', + 'lien_deconnection', + ['label' => $this->_('Libellé du lien de déconnexion')]) + ->addElement('text', + 'lien_mot_de_passe_oublie', + ['label' => $this->_('Libellé du lien de mot de passe oublié')]) + ->addElement('text', + 'lien_compte', + ['label' => $this->_('Libellé du lien d\'accès au compte')]) + ->addElement('text', + 'lien_creer_compte', + ['label' => $this->_('Libellé du lien de création d\'un compte')]) + ->addElement('text', + 'pre_registration', + ['label' => $this->_('Libellé du lien de préinscription')]) + ->addElement('comboProfils', + 'profil_redirect', + ['label' => $this->_('À la connextion : basculer automatiquement sur le profil'), + 'empty_option' => true]) + ->addElement('comboProfils', + 'profil_logout_redirect', + ['label' => $this->_('À la déconnextion : basculer automatiquement sur le profil'), + 'empty_option' => true]); + } +} diff --git a/library/ZendAfi/Form/Configuration/Login.php b/library/ZendAfi/Form/Configuration/Login.php new file mode 100644 index 0000000000000000000000000000000000000000..8ba0c90c7a270798cedb9ad5a30cda5431d029fc --- /dev/null +++ b/library/ZendAfi/Form/Configuration/Login.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Form_Configuration_Login extends ZendAfi_Form_Configuration_BaseLogin { + public function init() { + parent::init(); + + $this + ->setAttrib('id', 'auth_login_conf') + ->addDisplayGroup($this->getElementsNames(), + 'auth_login_fieldset', + ['legend' => '']) + + ->addElement('submit', 'submit', ['label' => $this->_('Valider'), + 'class' => 'bouton']) + ->addDisplayGroup(['submit'], 'auth_login_submit', ['legend' => '']) + + ; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/LoginWidget.php b/library/ZendAfi/Form/Configuration/LoginWidget.php index f0be486d452b76a5bb4b437b580e0e88995f4d79..6f552f8802a86e8e472dc26a9259f030cd4379c1 100644 --- a/library/ZendAfi/Form/Configuration/LoginWidget.php +++ b/library/ZendAfi/Form/Configuration/LoginWidget.php @@ -21,83 +21,12 @@ -class ZendAfi_Form_Configuration_LoginWidget extends ZendAfi_Form { +class ZendAfi_Form_Configuration_LoginWidget extends ZendAfi_Form_Configuration_BaseLogin { public function init() { - Class_ScriptLoader::getInstance() - ->addJQueryReady( - 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(3)", ["DateCreationDesc", "DebutPublicationDesc", "EventDebut", "Random", "CommentCount"]);' - - . 'formSelectToggleVisibilityForElement("input[name=\'display_order\']", "#fieldset-datas tr:nth-child(4)", "Random");' - - . 'checkBoxToggleVisibilityForElement("#allow_link_on_title", "#fieldset-affichage tr:nth-child(4)", true);'); - - parent::init(); $this - ->setAttrib('id', - 'configuration_login_widget') ->setMethod('post') - - ->addElement('select', - 'boite', - ['label' => $this->_('Style de boite'), - 'multiOptions' => ( - new Class_Profil_Templates( - Class_Profil::getCurrentProfil()))->toArray()]) - - ->addElement('text', - 'titre', - ['label' => $this->_('Titre')]) - ->addElement('text', - 'titre_connecte', - ['label' => $this->_('Titre une fois connecté')]) - ->addElement('text', - 'message_connecte', - ['label' => $this->_('Message de bienvenue')]) - ->addElement('text', - 'identifiant', - ['label' => $this->_('Libellé identifiant')]) - ->addElement('text', - 'identifiant_exemple', - ['label' => $this->_('Texte dans le champ de saisie de l\'identifiant')]) - ->addElement('text', - 'mot_de_passe', - ['label' => $this->_('Libellé mot de passe')]) - ->addElement('text', - 'mot_de_passe_exemple', - ['label' => $this->_('Texte dans le champ de saisie du mot de passe')]) - ->addElement('checkbox', - 'autocomplete_off', - ['label' => $this->_('Désactiver l\'auto-complétion'), - 'multiOptions' => [1,0]]) - ->addElement('text', - 'lien_connexion', - ['label' => $this->_('Libellé du lien de connexion')]) - ->addElement('text', - 'lien_deconnection', - ['label' => $this->_('Libellé du lien de déconnexion')]) - ->addElement('text', - 'lien_mot_de_passe_oublie', - ['label' => $this->_('Libellé du lien de mot de passe oublié')]) - ->addElement('text', - 'lien_compte', - ['label' => $this->_('Libellé du lien d\'accès au compte')]) - ->addElement('text', - 'lien_creer_compte', - ['label' => $this->_('Libellé du lien de création d\'un compte')]) - ->addElement('text', - 'pre_registration', - ['label' => $this->_('Libellé du lien de préinscription')]) - ->addElement('comboProfils', - 'profil_redirect', - ['label' => $this->_('À la connextion : basculer automatiquement sur le profil'), - 'empty_option' => true]) - ->addElement('comboProfils', - 'profil_logout_redirect', - ['label' => $this->_('À à déconnextion : basculer automatiquement sur le profil'), - 'empty_option' => true]) - ->addUniqDisplayGroup('login_widget_fieldset', ['legend' => $this->_('Propriétés de la boite de connexion')]); } diff --git a/library/ZendAfi/Form/Configuration/SearchResult.php b/library/ZendAfi/Form/Configuration/SearchResult.php index 01c66c341675c27bc4571b83184b9773db9fa8ea..98503bd944e92da72a7584593f73391c1da4afcb 100644 --- a/library/ZendAfi/Form/Configuration/SearchResult.php +++ b/library/ZendAfi/Form/Configuration/SearchResult.php @@ -270,11 +270,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ->addElement('select' , 'cvs_display_position', ['label' => $this->_('Affichage'), - 'multiOptions' => ['0' => $this->_('Ne pas afficher'), - '1' => $this->_('Afficher au dessus des facettes'), - '2' => $this->_('Afficher au dessous des facettes'), - '3' => $this->_('Afficher au dessus des résultats'), - '4' => $this->_('Afficher au dessous des résultats')]]) + 'multiOptions' => Class_Systeme_ModulesAppli::getCVSPosition()]) ->addElement('text', 'cvs_resultat_titre', ['label' => $this->_('Titre de la boîte'), diff --git a/library/ZendAfi/Translate.php b/library/ZendAfi/Translate.php index c38a53e75af615ffd63c23fa7da49a3560991fbe..f308e7ce0d76c859904261672ae6256afeb04c85 100644 --- a/library/ZendAfi/Translate.php +++ b/library/ZendAfi/Translate.php @@ -21,18 +21,14 @@ class ZendAfi_Translate extends Zend_Translate { public function _() { - $args = func_get_args(); - $num = func_num_args(); - - if (!$num) + if (!$num = func_num_args()) return ''; - $args[0] = parent::_(Class_TextReplacements::replace($args[0])); - - if($num <= 1) { - return $args[0]; - } + if ($num <= 1) + return parent::_(Class_TextReplacements::replace(func_get_args()[0])); + $args = func_get_args(); + $args[0] = parent::_(Class_TextReplacements::replace($args[0])); return call_user_func_array('sprintf', $args); } diff --git a/library/ZendAfi/View/Helper/Abonne/Formations.php b/library/ZendAfi/View/Helper/Abonne/Formations.php index 190a4c73968a106f5298359f27d8085d5992ca60..60766ac6627fae89ea4213dd421d2ea25b447f61 100644 --- a/library/ZendAfi/View/Helper/Abonne/Formations.php +++ b/library/ZendAfi/View/Helper/Abonne/Formations.php @@ -18,9 +18,11 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + class ZendAfi_View_Helper_Abonne_Formations extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_formations($user) { - if (!Class_AdminVar::isFormationEnabled() || !$user->hasRightSuivreFormation()) + if (!Class_AdminVar::isFormationEnabled() + || !$user->hasRightSuivreFormation()) return ''; $action_url = $this->view->url(['controller' => 'formations', @@ -31,25 +33,22 @@ class ZendAfi_View_Helper_Abonne_Formations extends ZendAfi_View_Helper_Abonne_A $html = $this->view->tagAnchor($action_url, $this->view->_("S'inscrire à une formation")); - $html .= '<ul>'; - - - - foreach ($user->getSessionFormations() as $session) { - $html .= sprintf('<li><a href="%s">%s, %s</li>', - $this->view->url(['controller' => 'formations', - 'action' => 'detail-session', - 'id' => $session->getId()], - null, true) - . '?retour=' . $this->view->url(), - $session->getLibelleFormation(), - $this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY')); - } - - $html .= '</ul>'; + $html .= $this->_renderSubscriptions(); return $this->tagFicheAbonne($html, 'formations', $action_url); } -} -?> \ No newline at end of file + + protected function _renderSubscriptions() { + return $this + ->_tag('ul', + $this->_tag('li', + $this->view->tagAnchor(['controller' => 'formations', + 'action' => 'done'], + $this->_('Mes formations suivies'))) + . $this->_tag('li', + $this->view->tagAnchor(['controller' => 'formations', + 'action' => 'registered'], + $this->_('Mes inscriptions en cours')))); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php index bb82e4d2fbae1caf4ddb69f6327f593db5e8cf5e..a560eb2fe95ef1cab45bf6baa6d1c5552da8e393 100644 --- a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php +++ b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php @@ -292,33 +292,33 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue * @param string $target * @return string */ - private function _renderListItem($menuitem, $url=null, $target=null) { + private function _renderListItem($menuitem, $url = '#', $target = null) { + $a_target = $target ? ['target' => $target] : []; + + $content = $this->view->tagAnchor($url, + $this->getMenuPicto($menuitem) + . htmlspecialchars($menuitem['libelle']), + array_merge($a_target, + $this->afficherSousMenu($url))); + + if($this->preferences['new_html']=='1') { + $content.= $this->_getSubItemsHtml($menuitem['sous_menus']); + } - $a_href = 'href="'. ($url ? htmlspecialchars($url) : '#') . '"'; - $a_target = $target ? "target='$target'" : ""; $profil_key = isset($menuitem["preferences"]["clef_profil"]) ? (int) $menuitem["preferences"]['clef_profil'] : '0'; $class[] = $this->_getContextClass($profil_key); $class[] = $this->_getContextClassByUrl($url); - $content ='<li class="' . implode(' ',array_filter($class)) . '" >'; - - $content .= $this->getMenuPicto($menuitem); - - $content .= - '<a '.$a_href.' '.$a_target.' '.$this->afficherSousMenu($a_href).'>'. - htmlspecialchars($menuitem["libelle"]). - '</a>'; - - if($this->preferences['new_html']=='1') { - $content.= $this->_getSubItemsHtml($menuitem['sous_menus']); - } - - $content .= '</li>'; + return $this->_tag('li', + $content, + ['class' => implode(' ', array_filter($class))]); + } - return $content; + protected function afficherSousMenu($href) { + return $href == '#' ? ['onclick' => 'afficher_sous_menu(this);return false'] : []; } @@ -331,11 +331,6 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue } - protected function afficherSousMenu($href) { - return $href == 'href="#"' ? 'onclick="afficher_sous_menu(this);return false"' : ''; - } - - /** * @param array $menuitem * @return string diff --git a/library/ZendAfi/View/Helper/Admin/SubscribeUsers.php b/library/ZendAfi/View/Helper/Admin/SubscribeUsers.php index abcfa3af027e9df7136b8a900b6f1e702cbd5a13..752cd3ee36bbb12e68c15c0388e81103299e9273 100644 --- a/library/ZendAfi/View/Helper/Admin/SubscribeUsers.php +++ b/library/ZendAfi/View/Helper/Admin/SubscribeUsers.php @@ -99,6 +99,9 @@ class ZendAfi_View_Helper_Admin_SubscribeUsers extends ZendAfi_View_Helper_BaseH protected function _renderUser($user, $odd) { + if(!$user) + $user = new Class_Users(); + return sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $odd ? 'first' : 'second', $user->getNom(), diff --git a/library/ZendAfi/View/Helper/Bookmarks.php b/library/ZendAfi/View/Helper/Bookmarks.php index 78c80f1c5b8a927231b5b7be247c779c2ab17727..8d07da3285f25ec361a87fc4ca965e7cb857bc1d 100644 --- a/library/ZendAfi/View/Helper/Bookmarks.php +++ b/library/ZendAfi/View/Helper/Bookmarks.php @@ -23,7 +23,11 @@ class ZendAfi_View_Helper_Bookmarks extends ZendAfi_View_Helper_BaseHelper { protected $_bookmarks, $_criteres; - public function bookmarks($bookmarks, $criteres, $preferences) { + public function bookmarks($search_result) { + $preferences = $search_result->getSettings(); + $bookmarks = $search_result->fetchFacetsAndTags($preferences)['bookmarks']; + $criteres = $search_result->getCriteresRecherche(); + if(!$preferences['bookmarks_enabled']) return ''; diff --git a/library/ZendAfi/View/Helper/ListeCVSNotices.php b/library/ZendAfi/View/Helper/ListeCVSNotices.php index a90f9d7969bb91e43218c1641301fdb39fc862f8..1651510413d7a0609839f299681980283499c4f4 100644 --- a/library/ZendAfi/View/Helper/ListeCVSNotices.php +++ b/library/ZendAfi/View/Helper/ListeCVSNotices.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,13 +24,11 @@ class ZendAfi_View_Helper_ListeCVSNotices extends ZendAfi_View_Helper_ListeNotices { public function listeCVSNotices($notices,$nombre_resultats,$page,$preferences) { - return - !$nombre_resultats - ? '<span>'. - $this->view->_('Aucun document trouvé'). - '</span>' - : '<div class="cvs_record_list">'. - $this->displayList('',$notices,$preferences). - '</div>'; + return $nombre_resultats + ? $this->_tag('div', + $this->_displayList($notices, $preferences), + ['class' => 'cvs_record_list']) + : $this->_tag('span', + $this->_('Aucun document trouvé')); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices.php b/library/ZendAfi/View/Helper/ListeNotices.php index d70c7ceb1a2f2968ffdd1de52d371f81c164d6e3..8c93a26a5bda68b33ee2dc123bfde246bb16ad98 100644 --- a/library/ZendAfi/View/Helper/ListeNotices.php +++ b/library/ZendAfi/View/Helper/ListeNotices.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ////////////////////////////////////////////////////////////////////////////////////////// // OPAC3 : Liste de notices @@ -27,39 +27,57 @@ ////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_ListeNotices extends ZendAfi_View_Helper_BaseHelper { - /** - * @param array $notices - * @param int $nombre_resultats - * @param int $page - * @param array $preferences - * @param string $url - * @param string $tri - * @return string - */ - public function listeNotices($notices, $nombre_resultats, $page, $preferences, $criteres_recherche) { - $html = '<div class="liste_notices" >'; - // Message d'erreur - if (!$notices) { - return $html.'<h2>'.$this->view->_('Aucun résultat trouvé').'</h2></div>'; - } + public function listeNotices($search_result) { + $criteres_recherche = $search_result->getCriteresRecherche(); + $notices = $search_result->getRecords(); + $nombre_resultats = $search_result->getRecordsCount(); + $page = $criteres_recherche->getPage(); + $preferences = $search_result->getSettings(); - return $html.$this->displayList($html,$notices,$preferences).'</div>'; + $html = $this->_tag('div', + $this->_recordsList($notices, $preferences), + ['class' => 'liste_notices']); + + if((!Class_AdminVar::displayPagerOnTop()) + &&(!Class_AdminVar::displayPagerOnBottom())) + return $html; + + $pager = $this->view->pager($nombre_resultats, + $criteres_recherche->getPageSize(), + $criteres_recherche->getPage(), + array_merge($criteres_recherche->getUrlRetourListe(), + ['controller' => 'recherche', + 'action' => 'simple'])); + + + if (Class_AdminVar::displayPagerOnTop()) + $html = $pager . $html; + + if (Class_AdminVar::displayPagerOnBottom()) + $html .= $pager; + + return $html; } - - public function displayList($html,$notices,$preferences) { + + protected function _recordsList($records, $settings) { + return $records + ? $this->_displayList($records, $settings) + : $this->_tag('h2', $this->_('Aucun résultat trouvé')); + } + + + protected function _displayList($notices,$preferences) { $helpers = [ - Class_Systeme_ModulesAppli::LISTE_FORMAT_TABLEAU => 'ListeNotices_Tableau', - Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON => 'ListeNotices_Accordeon', - Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES => 'ListeNotices_Vignettes', - Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR => 'ListeNotices_Mur', - Class_Systeme_ModulesAppli::LISTE_FORMAT_CHRONO => 'ListeNotices_Chrono', - ]; + Class_Systeme_ModulesAppli::LISTE_FORMAT_TABLEAU => 'ListeNotices_Tableau', + Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON => 'ListeNotices_Accordeon', + Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES => 'ListeNotices_Vignettes', + Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR => 'ListeNotices_Mur', + Class_Systeme_ModulesAppli::LISTE_FORMAT_CHRONO => 'ListeNotices_Chrono', + ]; $helper = $helpers[$preferences['liste_format']]; return call_user_func_array([$this->view, $helper], [$notices, $preferences]); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php index 79f6dc8dbece1b67b2f07bbcef0d2c1a181da050..e9121cf77ed11931cb31da1af79bb78f73a7948a 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php @@ -16,9 +16,48 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_Helper_BaseHelper { + + protected function _divRecord($html, $record, $class) { + return $this->_tag('div', + $html, + array_merge( + ['class' => $class, + 'data-id' => $record->getId(), + 'data-type' => $record->getTypeDoc()], + $this->_getDataAvailability($record))); + } + + + protected function _getDataAvailability($record) { + if(!$this->_isAllowedToDisplayAvailabilty($record)) + return []; + + return ['data-availability' => $record->getAvailabilityFromFacet()]; + } + + + protected function _recordAvailability($record) { + if(!$this->_isAllowedToDisplayAvailabilty($record)) + return ''; + + return $this->view->Notice_Availability($record); + } + + + protected function _isAllowedToDisplayAvailabilty($record) { + if(!Class_AdminVar::isAfficherDispoSurRechercheEnabled()) + return false; + + if($record->isRessourceNumerique()) + return false; + + return true; + } + + public function loadScript(){ Class_ScriptLoader::getInstance() ->addInlineScript("var resumeAjaxBaseUrl='".$this->view->url(['controller' => 'noticeajax', 'action' => 'resumenotice'],null,true)."';") @@ -31,7 +70,7 @@ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_He ->addJQueryReady("vignetteHover($('.liste_vignettes .vignette[data-id]'));"); else Class_ScriptLoader::getInstance()->addInlineScript("var disponibiliteAjaxBaseUrl;"); - + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Mur.php b/library/ZendAfi/View/Helper/ListeNotices/Mur.php index cd87599be8f25c14a682ff3cdcf06215a32a2b32..dbd8b95897de7c07cdf3226d8f338589d737c140 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Mur.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Mur.php @@ -16,17 +16,134 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_ListeNotices_Mur extends ZendAfi_View_Helper_ListeNotices_Abstract { - public function listeNotices_Mur($data, $preferences=[]) { + + public function ListeNotices_Mur($data, $preferences=[]) { $this->loadScript(); $notices = []; foreach($data as $notice) - $notices []= $this->view->notice_Mur($notice, $preferences); + $notices[] = $this->_notice_mur($notice, $preferences); + + return $this->_tag('div', + implode($notices) + . $this->_tag('div', '', ['class' => 'clear']), + ['class' => 'liste_mur']); + } + + + protected function _notice_mur($notice, $preferences=[]) { + $champs = isset($preferences['liste_codes']) + ? $preferences['liste_codes'] + : 'TANE'; + + $datas = [$this->_tag('span', + $this->view->tagAnchor($this->view->urlNotice($notice, $preferences), + $notice->getTitreEtSousTitre(), + ['title' => $this->_('Afficher "%s"', + $notice->getTitrePrincipal())]), + ['class' => 'notice_titre'])]; + + $datas [] = $this->_tag('span', + $this->view->notice_LienRebondAuteur($notice), + ['class' => 'notice_auteur']); + + $datas []= + (strrchr($champs,'9') && $notice->isNouveaute()) + ? $this->_tag('span', + $this->_('Nouveauté'), + ['class' => 'notice_nouveaute']) + : '' ; + + $html = $this->_tag('div', + $this->view->iconeSupport($notice->getTypeDoc())) + . $this->view->notice_Vignette($notice, $preferences) + . $this->_tag('div', + implode($datas), + ['class' => 'titre_auteur']) + . $this->barreDeLien($notice); + + $html = $this->_divRecord($html, $notice, 'notice'); + + return $this->_tag('div', + $html, + ['class' => 'notice_wrapper']); + } + + + protected function barreDeLien($notice){ + $html = [$this->_usersReviews($notice), + $this->_adminsReviews($notice), + $this->_socialNetwork($notice), + $this->barreDeLienPanier($notice), + $this->barreDeLienReserver($notice)]; + + return implode([$this->_recordAvailability($notice), + $this->_tag('ul', implode($html), ['class' => 'barre-de-lien']), + $this->view->reseauxSociaux($notice)]); + } + + + protected function _adminsReviews($record) { + return $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', + 'action' => 'avis-bibliothecaire', + 'id_notice' => $record->getId()], null, true) . '?iframe=true', + $record->numberOfAvisBibliothecaire(), + $this->_('Coups de coeur')); + } + + + protected function _usersReviews($record) { + return $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', + 'action' => 'avis-abonne', + 'id_notice' => $record->getId()], null, true) . '?iframe=true', + $record->numberOfAvisAbonne(), + $this->_('Avis des abonnés')); + + } + + + protected function _socialNetwork($record) { + return $this->_tag('li', $this->view->tagAnchor($this->view->urlNotice($record) .'#reseaux-sociaux', + ' ', + ['data-mur-partager' => $record->getId(), + 'title' => $this->view->_('Partager "%s" sur les réseaux sociaux', + $record->getTitrePrincipal())])); + + } + + + protected function barreDeLienReserver($notice) { + $attribs = ($link = $this->view->Notice_LienReserver($notice)) + ? ['data-reservable' => 'true'] + : []; + + return $this->_tag('li ', + $link, + $attribs); + } + + + protected function barreDeLienAvis($url, $count, $title) { + $html = $count + ? $this->view->tagAnchor($url, + $this->_tag('span', $count), + ['title' => $this->_('Voir les avis du document "%s"', $title)]) + : ''; + + $attribs = $count + ? ['data-avis' => 'true'] + : []; + + return $this->_tag('li', + $html, + $attribs); + } + - return '<div class="liste_mur">'.implode($notices).'<div class="clear"></div></div>'; + protected function barreDeLienPanier($notice) { + return $this->view->tag('li', $this->view->tagAddToCart($notice)); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php index 32bf40001c8ef097afd8615fe0089ba489503432..fdcb5e83d94bb16bdcfbc06ee4ddf67987e07eb9 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php @@ -42,6 +42,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis $html = $this->_hold($notice) . $this->_cart($notice) + . $this->_recordAvailability($notice) . $this->_title($notice, $url_notice) . $this->_author($notice, $url_notice) . $this->_docType($notice, $type_doc) @@ -50,8 +51,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis . $this->_info($notice, $champs) . $this->_pcTag($notice); - return $this->_tag('div', $html, ['class' => 'vignette', - 'data-id' => $notice->getId()]); + return $this->_divRecord($html, $notice, 'vignette'); } diff --git a/library/ZendAfi/View/Helper/MonocleReaderServerSide.php b/library/ZendAfi/View/Helper/MonocleReaderServerSide.php index c80c9421d9f8fbe6520f6b6be780ede2464c7ccf..8a710caa8a796f11f2f3fdffdeeb67fbfda6f73a 100644 --- a/library/ZendAfi/View/Helper/MonocleReaderServerSide.php +++ b/library/ZendAfi/View/Helper/MonocleReaderServerSide.php @@ -108,7 +108,8 @@ class ZendAfi_View_Helper_MonocleReaderServerSide extends Zend_View_Helper_HtmlE 'controller' => 'bib-numerique', 'action' => 'full-screen', 'id' => $ressource->getId()], - '<img src="'.URL_ADMIN_IMG.'picto/show.gif" title="'.$this->view->_('Plein écran').'">', + $this->view->tagImg(URL_ADMIN_IMG . 'picto/show.gif', + ['alt' => $this->view->_('Plein écran')]), ['data-ajax' => 'false'] ); } diff --git a/library/ZendAfi/View/Helper/Notice/Availability.php b/library/ZendAfi/View/Helper/Notice/Availability.php new file mode 100644 index 0000000000000000000000000000000000000000..7a9b22f47af0796ef4b90b384893c4504ecef94a --- /dev/null +++ b/library/ZendAfi/View/Helper/Notice/Availability.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Zendafi_View_Helper_Notice_Availability extends ZendAfi_View_Helper_BaseHelper { + public function Notice_Availability($record) { + return $this->_tag('div', + $this->_getLibraries($record), + ['class' => 'record_availability']); + } + + + protected function _getLibraries($record) { + $html = []; + foreach($record->getAvailableLibrariesFromFacet() as $library) + $html [] = $this->_tag('li', $library->getLabel()); + + $count = count($html); + return $this->_tag('div', + $this->_tag('p', $this->view->_plural($count, + 'Le document n\'est pas disponible', + 'Document disponible dans la bibliothèque suivante :', + 'Document disponible dans les bibliothèques suivantes :')) + . ($count ? $this->_tag('ul', implode($html)) : ''), + ['class' => 'tooltip']); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/LienReserver.php b/library/ZendAfi/View/Helper/Notice/LienReserver.php index f7ebc3aa51ee3418096bf2ca722c9636e37dd643..c0ef27a07d3ae79df0832e4b717730f61c21735f 100644 --- a/library/ZendAfi/View/Helper/Notice/LienReserver.php +++ b/library/ZendAfi/View/Helper/Notice/LienReserver.php @@ -22,6 +22,12 @@ class ZendAfi_View_Helper_Notice_LienReserver extends Zend_View_Helper_HtmlEleme protected $_script_added = false; public function Notice_LienReserver($notice) { + if ($notice->isRessourceNumerique() + || $notice->isSite() + || $notice->isArticleCms() + || $notice->isRSS()) + return ''; + $this->loadScript(); $can_request_sigb = Class_AdminVar::isAfficherDispoSurRechercheEnabled(); $id_notice = $notice->getId(); diff --git a/library/ZendAfi/View/Helper/Notice/Mur.php b/library/ZendAfi/View/Helper/Notice/Mur.php deleted file mode 100644 index e71a459fabf375ae70edca2ff7e6b1c112e45b29..0000000000000000000000000000000000000000 --- a/library/ZendAfi/View/Helper/Notice/Mur.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php -/** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -class ZendAfi_View_Helper_Notice_Mur extends Zend_View_Helper_HtmlElement { - use Trait_Translator; - - public function notice_Mur($notice, $preferences=[]) { - $champs = isset($preferences['liste_codes']) ? $preferences['liste_codes'] : 'TANE'; - - $datas = $this->view->tag('span', - $this->view->tagAnchor($this->view->urlNotice($notice, $preferences), - $notice->getTitreEtSousTitre(), - ['title' => $this->_('Afficher "%s"', - $notice->getTitrePrincipal())]), - ['class' => 'notice_titre']); - - $datas .= sprintf('- <span class="notice_auteur">%s</span>', - $this->view->notice_LienRebondAuteur($notice)); - - $datas .= - (strrchr($champs,'9') && $notice->isNouveaute()) - ? sprintf('- <span class="notice_nouveaute">%s</span>', $this->_('Nouveauté')) - : '' ; - - $html= '<div class="notice_wrapper">'; - $html.='<div class="notice" data-id="'.$notice->getId().'" data-type="'.$notice->getTypeDoc().'">'. - '<div>'.$this->view->iconeSupport($notice->getTypeDoc()).'</div>'. - $this->view->notice_Vignette($notice, $preferences). - '<div class="titre_auteur">'.$datas. - '</div>'. - $this->barreDeLien($notice). - '</div>'; - - return $html.'</div>'; - } - - - public function barreDeLien($notice){ - $html = '<ul class="barre-de-lien">'; - $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-abonne', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', - $notice->numberOfAvisAbonne(), - 'avis des abonnés'); - - $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-bibliothecaire', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', - $notice->numberOfAvisBibliothecaire(), - 'coups de coeur'); - - $html .= $this->view->tag('li', - $this->view->tagAnchor($this->view->urlNotice($notice) .'#reseaux-sociaux', - ' ', - ['data-mur-partager' => $notice->getId(), - 'title' => $this->view->_('Partager "%s" sur les réseaux sociaux', $notice->getTitrePrincipal())])); - - $html .= $this->barreDeLienPanier($notice); - - $html .= $this->barreDeLienReserver($notice); - - return $html.'</ul>'.$this->view->reseauxSociaux($notice); - } - - - public function barreDeLienReserver($notice) { - if ($notice->isRessourceNumerique() || $notice->isSite() || $notice->isArticleCms() || $notice->isRSS()) - return ''; - - $css='data-reservable='; - $lien=$this->view->Notice_LienReserver($notice); - if($lien!='') - $css .= '"true"'; - else - $css.= '"false"'; - return '<li '.$css.' >'.$lien.'</li>'; - } - - - public function barreDeLienAvis($url, $count, $title) { - if (0 < $count) - return '<li data-avis="true"><a href="' . $url .'" title="'.$this->_("Voir les ". $title ."").'"><span>'. sprintf('%02s', $count) . '</span></a></li>'; - return '<li></li>'; - } - - - public function barreDeLienPanier($notice) { - return $this->view->tag('li', $this->view->tagAddToCart($notice)); - } -} - -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Search/Header.php b/library/ZendAfi/View/Helper/Search/Header.php new file mode 100644 index 0000000000000000000000000000000000000000..346928ede44e6cb6132e755b112c619fe584c66b --- /dev/null +++ b/library/ZendAfi/View/Helper/Search/Header.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Search_Header extends ZendAfi_View_Helper_BaseHelper { + protected $_criteria, + $_search_result, + $_settings; + + + public function Search_Header($search_result) { + $this->_criteria = $search_result->getCriteresRecherche(); + $this->_search_result = $search_result; + $this->_settings = $search_result->getSettings(); + + $html = [$this->view->tagTriRecherche($this->_criteria), + $this->view->tagTitreEtNombreDeResultats($this->_search_result), + $this->view->tagNombreDePages($this->_criteria->getPage()), + $this->_tagCriteria(), + $this->_tagDomainBrowser(), + $this->_tagSearchActions(), + $this->view->tagSearchExtension($this->_criteria)]; + + return $this->_tag('div', + implode($html), + ['class' => 'resultats_page']); + } + + + protected function _tagCriteria() { + if ($this->_search_result->getRubrics() || $this->_search_result->getBreadcrumb()) + return $this->view->render('recherche/guidee.phtml'); + + return $this->view->tagCriteresRecherche($this->_criteria); + } + + + protected function _tagDomainBrowser() { + if(!$id_module = $this->_criteria->getIdModule()) + return ''; + + if (!$config = Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig($id_module)) + return ''; + + if(!isset($config['type_module'])) + return ''; + + if($config['type_module'] != 'DOMAIN_BROWSER') + return ''; + + return $this->view->renderDomainBrowser($this->_criteria->getCatalogue(), + $id_module, + $config['preferences']); + } + + + protected function _tagSearchActions() { + $actions = [$this->_tag('span', + $this->view->tagAnchor($this->view->url($this->_criteria->getUrlRetourRechercheInitiale(), null, true), + $this->_('Retour à la recherche initiale'), + ['title' => $this->_('Accéder au formulaire de recherche pré-rempli avec les critères actuels')])), + $this->_tag('span', + $this->view->tagAnchor($this->view->url($this->_criteria->getUrlNouvelleRecherche(), null, true), + $this->_('Nouvelle recherche'), + ['title' => $this->_('Lancer une recherche avec réinitialisation des paramètres')])), + $this->_tagSuggestAction(), + $this->_tag('span', + $this->view->tagPrintLink($this->_search_result->fetchRecords(), 'Notice_List'), + ['class' => 'print']) + ]; + + return $this->_tag('div', + implode($actions), + ['class' => 'recherche_actions']); + } + + + protected function _tagSuggestAction() { + if ((int)$this->_settings['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled()) + return $this->_tag('span', + $this->view->tagAnchor(['controller' => 'abonne', + 'action' => 'suggestion-achat'], + $this->_('Suggérer un achat'), + ['title' => $this->_('Envoyer une demande d\'achat de document')])); + return ''; + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Search/Result.php b/library/ZendAfi/View/Helper/Search/Result.php index fb90456e2c0cddafb1b4c3e9c3430be94638901d..5bb9f9fcb275e2c4e97f28aa65aa650443034bc7 100644 --- a/library/ZendAfi/View/Helper/Search/Result.php +++ b/library/ZendAfi/View/Helper/Search/Result.php @@ -16,51 +16,169 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 : Liste de notices -// formats : 1=liste normale -// 2=liste accordéon -// 3=liste vignette -// 4=Liste images mur -////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_Search_Result extends ZendAfi_View_Helper_BaseHelper { - /** - * @param array $notices - * @param int $nombre_resultats - * @param int $page - * @param array $preferences - * @param string $url - * @param string $tri - * @return string - */ - public function Search_Result($settings, $html_result, $html_filters, $html_cvs) { - $html = - $html_filters. - $html_result. - $html_cvs; - - if($settings['cvs_display_position']=='1') - $html= - $html_result. - $html_cvs. - $html_filters; - - if($settings['cvs_display_position']=='2' || $settings['cvs_display_position']=='4') - $html= - $html_result. - $html_filters. - $html_cvs; - - if($settings['cvs_display_position']=='3') - $html= - $html_cvs. - $html_result. - $html_filters; - - return $html; - + protected $_criteria, + $_settings, + $_search_result; + + + public function Search_Result($search_result) { + if(!$this->_search_result = $search_result) + return ''; + + $this->_criteria = $this->_search_result->getCriteresRecherche(); + $this->_settings = $this->_search_result->getSettings(); + + Class_ScriptLoader::getInstance() + ->addOPACScript('recherche') + ->addSkinStyleSheet('recherche'); + + return $this->_tag('div', + $this->_render(), + ['class' => 'conteneur_simple']); + } + + + protected function _render() { + return $this->_sort($this->_getResultWidget(), + $this->_getFilterWidgets(), + $this->_getCVSWidget()) + . $this->_tag('div', '', ['class' => 'clear']); + } + + + protected function _sort($result_widget, $filters_widget, $CVS_widget) { + $html = $result_widget . $filters_widget; + + if(!$cvs = $this->_settings['cvs_display_position']) + return $html; + + if(Class_Systeme_ModulesAppli::CVS_TOP_OF_FACETS == $cvs) + return $result_widget + . $CVS_widget + . $filters_widget; + + if(Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_FACETS == $cvs + || Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_RESULT == $cvs) + return $result_widget + . $filters_widget + . $CVS_widget; + + if(Class_Systeme_ModulesAppli::CVS_TOP_OF_RESULT == $cvs) + return $CVS_widget + . $result_widget + . $filters_widget; + } + + + protected function _CVSTitle() { + if(!$title = $this->_settings['cvs_autres_resultats']) + return ''; + + return $this->_tag('h1', $title); + } + + + protected function _getResultWidget() { + $html_result = [$this->_CVSTitle(), + $this->view->listeNotices($this->_search_result)]; + + return $this->_tag('div', + implode($html_result), + ['class' => 'resultat_recherche']); + } + + + protected function _cloudOfTags() { + $nuage_tags_title = $this->_settings["tags_message"] + ? $this->_tag('h2', $this->_settings["tags_message"]) + : ''; + $tags = $this->_search_result->fetchFacetsAndTags($this->_settings)['tags']; + return $this->_tag('div', + $nuage_tags_title + . $this->view->nuageTags($tags, null, $this->_criteria), + ['class' => 'facette_outer nuage_outer']); + } + + + protected function _facets() { + $title = ($this->_settings["facettes_message"] + ? $this->_tag('h2', $this->_settings["facettes_message"]) + : ''); + + $facets = $this->_search_result->fetchFacetsAndTags($this->_settings)['facettes']; + + return $this->_tag('div', + $title + . $this->view->facettes($facets, + $this->_settings, + $this->_criteria), + ['class' => 'facette_outer']); + } + + + protected function _getFilterWidgets() { + return $this->_tag('div', + $this->_orderFilterWidgets(), + ['class' => 'filtre_recherche']); + } + + + protected function _orderFilterWidgets() { + if(!$this->_search_result->getRecordsCount()) + return ''; + + $has_facettes = $this->_settings['facettes_actif']; + $has_tags = $this->_settings['tags_actif']; + + if((!$has_tags) && (!$has_facettes)) + return ''; + + $tags_position = $this->_settings['tags_position']; + + $html_suggests = $this->view->suggests($this->_search_result); + $html_bookmarks = $this->view->bookmarks($this->_search_result); + $html_nuage_tags = $this->_cloudOfTags(); + $html_facettes = $this->_facets(); + + $html_filters = [$html_suggests, + $html_bookmarks]; + + if ($has_tags && (1 == $tags_position)) + $html_filters[] = $html_nuage_tags; + + if ($has_facettes) + $html_filters[] = $html_facettes; + + if ($has_tags && (2 == $tags_position)) + $html_filters[] = $html_nuage_tags; + + return implode($html_filters); + } + + + protected function _getCVSWidget() { + if(!(new Class_AdminVar_CVS())->isCVSAccessOrDemo()) + return ''; + + if(!$this->_settings['cvs_display_position']) + return ''; + + $url = $this->view->url($this->_criteria->getCVSUrlCriteresWithFacettes(), + null, + true); + + Class_ScriptLoader::getInstance() + ->addJQueryReady(sprintf("$('<div></div>').load('%s').appendTo($('.cvs_container'))", + $url)); + + return $this->_tag('div', + $this->_tag('h1', + $this->_settings['cvs_resultat_titre']), + ['class' => sprintf('cvs_container position_%s', + $this->_settings['cvs_display_position'])]); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Suggests.php b/library/ZendAfi/View/Helper/Suggests.php index 7d0653b6ac1a5e6223b550e32a1fb3dc1767951d..c2c1bafc813329c5221896a97df531e4a240f5cc 100644 --- a/library/ZendAfi/View/Helper/Suggests.php +++ b/library/ZendAfi/View/Helper/Suggests.php @@ -20,7 +20,9 @@ */ class ZendAfi_View_Helper_Suggests extends ZendAfi_View_Helper_BaseHelper { - public function suggests($suggests, $criteres) { + public function suggests($search_result) { + $suggests = $search_result->fetchFacetsAndTags($search_result->getSettings())['suggests']; + $criteres = $search_result->getCriteresRecherche(); if (empty($suggests)) return ''; diff --git a/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php b/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php index 0cac7a7300ad018b14afbb56980c162eddcb6e2d..1b9f001c84b02d9116dcd70a6b168089dc31e9a5 100644 --- a/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php +++ b/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php @@ -20,7 +20,8 @@ */ class ZendAfi_View_Helper_TagTitreEtNombreDeResultats extends ZendAfi_View_Helper_BaseHelper { - public function tagTitreEtNombreDeResultats($search_result, $search_duration){ + public function tagTitreEtNombreDeResultats($search_result){ + $search_duration = $search_result->getDuration(); $criteres_recherche = $search_result->getCriteresRecherche(); $expression_recherche = $this->_getExpressionRecherche($criteres_recherche); diff --git a/library/startup.php b/library/startup.php index fad2e873b29a37b50212f683915cb17989249065..bbf599c51be81b9237c89c894cc266df04e14ce5 100644 --- a/library/startup.php +++ b/library/startup.php @@ -83,7 +83,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.7'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.19'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.22'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/library/storm b/library/storm index 580af71e233e87517e38d9fab12df9d3b7bcee29..57fb2c7f9ae96f2cb825484e4576619ffa2d91e7 160000 --- a/library/storm +++ b/library/storm @@ -1 +1 @@ -Subproject commit 580af71e233e87517e38d9fab12df9d3b7bcee29 +Subproject commit 57fb2c7f9ae96f2cb825484e4576619ffa2d91e7 diff --git a/public/admin/js/treeselect/treeselect.css b/public/admin/js/treeselect/treeselect.css index e747dd54c50dea8fcff0aec780975f8b0f3f5743..1ea20410416df383c522f54507672daac981bd12 100644 --- a/public/admin/js/treeselect/treeselect.css +++ b/public/admin/js/treeselect/treeselect.css @@ -146,6 +146,7 @@ .ui-treeselect-items-tree li { overflow: hidden; white-space:nowrap; + text-align: left; } .ui-treeselect-items-tree li>a { diff --git a/public/admin/skins/bokeh74/config.json b/public/admin/skins/bokeh74/config.json index fa1ce6497409c0fb7d48706e80c299cc97de597b..d8f18231dbb60fc18ecd6a8ca899fd54174c4bf1 100644 --- a/public/admin/skins/bokeh74/config.json +++ b/public/admin/skins/bokeh74/config.json @@ -80,7 +80,7 @@ "add_user": "icons/menu/demande_inscri_24.png", "edit": "icons/actions/edit_24.png", - "delete": "icons/actions/delete_24.png", + "delete": "icons/actions/delete_16.png", "print": "icons/actions/print_16.png", "copy": "icons/actions/copier_16.png", diff --git a/public/opac/css/global.css b/public/opac/css/global.css index f8c2f98749a1853e95e9a8cac908b5305a98ab5b..be3d94192414f3123296fb76926a12d1501ff498 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1726,7 +1726,7 @@ body.abonne_multimedia-hold-view .actions a { overflow: hidden; } -.liste_mur .notice>a + div + div { +.liste_mur .notice > a + div + div:not(.record_availability) { position: absolute; top: 86px; left: 0px; @@ -3490,3 +3490,50 @@ th.actions { margin: 1em auto; } +[data-availability] .record_availability { + display: block; + width: 16px; + height: 16px; + position: absolute; + border-radius: 50px; + top: 5px; + left: 5px; + z-index: 1; +} + +[data-availability="1"] .record_availability { + background-color: #21ff00; +} + +[data-availability=""] .record_availability { + background-color: red; +} + +.liste_mur [data-availability] .record_availability { + top: auto; + bottom: 5px; +} + +.liste_mur [data-availability] .record_availability .tooltip { + bottom: 2em; + left: 0; +} + +[data-availability] .record_availability .tooltip { + display: none; + position: absolute; + z-index: 101; + padding-left: 1em; + min-width: 300px; + background-color: #fff; + box-shadow: 1px 1px 5px rgba(0, 0 , 0 ,0.3); + left: 2em; +} + +[data-availability] .record_availability:hover .tooltip { + display: block; +} + +[data-availability] .record_availability:hover .tooltip ul { + padding-left: 1em; +} diff --git a/public/opac/css/responsive.css b/public/opac/css/responsive.css index 59471f5cbdf645620af67a4d3f33ab981f43135a..7beac40c235f8e4d0dfbfd7d658029b4a6956cc1 100644 --- a/public/opac/css/responsive.css +++ b/public/opac/css/responsive.css @@ -43,8 +43,8 @@ } - .boite[class*="menu"] .contenu, - .boite[class*="menu"] .content, + .boite[class*="menu_horizontal"] .contenu, + .boite[class*="menu_horizontal"] .content, #menu_horizontal , #header , #header > * { @@ -59,26 +59,26 @@ #menu_horizontal, - #header div[class*="menu"] { + #header div[class*="menu_horizontal"] { position: relative !important; } - div[class*="menu"].show_menu > ul ul, - div[class*="menu"].show_menu > ul li { + div[class*="menu_horizontal"].show_menu > ul ul, + div[class*="menu_horizontal"].show_menu > ul li { min-width: 0 !important; } - div[class*="menu"] li img { + div[class*="menu_horizontal"] li img { display: none !important; } - div[class*="menu"]:not(.show_menu) > ul > li , - div[class*="menu"]:not(.show_menu) > ul > li > ul , - div[class*="menu"]:not(.show_menu) > ul > li > ul > li { + div[class*="menu_horizontal"]:not(.show_menu) > ul > li , + div[class*="menu_horizontal"]:not(.show_menu) > ul > li > ul , + div[class*="menu_horizontal"]:not(.show_menu) > ul > li > ul > li { position: absolute !important; top: 0 !important; left: 0 !important; @@ -87,12 +87,12 @@ } - div[class*="menu"].show_menu > ul li { + div[class*="menu_horizontal"].show_menu > ul li { margin: auto !important } - div[class*="menu"] > ul > li { + div[class*="menu_horizontal"] > ul > li { display: block !important; height: auto !important; } @@ -101,8 +101,8 @@ #header > *, #menu_horizontal, - #header div[class*="menu"] , - div[class*="menu"] * { + #header div[class*="menu_horizontal"] , + div[class*="menu_horizontal"] * { display: block !important; left: auto !important; top: auto !important; @@ -391,7 +391,7 @@ /** MENU **/ - div:not(.show_menu)[class*="menu"], + div:not(.show_menu)[class*="menu_horizontal"], #menu_horizontal { background: none; height: auto; @@ -400,21 +400,21 @@ } - div[class*="menu"] * { + div[class*="menu_horizontal"] * { transition: none; } - div[class*="menu"] > ul { + div[class*="menu_horizontal"] > ul { } - div[class*="menu"] > ul > li > a { + div[class*="menu_horizontal"] > ul > li > a { text-transform: uppercase; } - div[class*="menu"] > ul { + div[class*="menu_horizontal"] > ul { display: block; position: absolute; height: 0; @@ -422,8 +422,8 @@ } - div[class*="menu"].show_menu > ul ul, - div[class*="menu"].show_menu > ul li, + div[class*="menu_horizontal"].show_menu > ul ul, + div[class*="menu_horizontal"].show_menu > ul li, #menu_horizontal.show_menu > ul ul, #menu_horizontal.show_menu > ul li { display: block; @@ -440,7 +440,7 @@ #menu_horizontal.show_menu > ul > li, - div[class*="menu"].show_menu > ul > li { + div[class*="menu_horizontal"].show_menu > ul > li { float: left; width: 100%; border-bottom: 1px solid #efefef; @@ -448,15 +448,15 @@ #menu_horizontal.show_menu > ul > li:last-of-type, - div[class*="menu"].show_menu > ul > li:last-of-type { + div[class*="menu_horizontal"].show_menu > ul > li:last-of-type { border: none; } - div[class*="menu"] > ul ul, - div[class*="menu"] > ul li, - div[class*="menu"] > ul li a, - div[class*="menu"] > ul li ul li a, + div[class*="menu_horizontal"] > ul ul, + div[class*="menu_horizontal"] > ul li, + div[class*="menu_horizontal"] > ul li a, + div[class*="menu_horizontal"] > ul li ul li a, #menu_horizontal > ul ul, #menu_horizontal > ul li, #menu_horizontal > ul li a , @@ -465,9 +465,9 @@ } - div[class*="menu"].show_menu > ul ul, - div[class*="menu"].show_menu > ul li, - div[class*="menu"].show_menu > ul li a, + div[class*="menu_horizontal"].show_menu > ul ul, + div[class*="menu_horizontal"].show_menu > ul li, + div[class*="menu_horizontal"].show_menu > ul li a, #menu_horizontal.show_menu > ul ul, #menu_horizontal.show_menu > ul li, #menu_horizontal.show_menu > ul li a { @@ -476,7 +476,7 @@ } - div[class*="menu"].show_menu > ul li { + div[class*="menu_horizontal"].show_menu > ul li { line-height: 2em; } @@ -487,17 +487,17 @@ #menu_horizontal, - #header div[class*="menu"] , - div[class*="menu"].show_menu > ul, + #header div[class*="menu_horizontal"] , + div[class*="menu_horizontal"].show_menu > ul, #menu_horizontal.show_menu > ul , - div:not(.show_menu)[class*="menu"] li.selected_profil > a[href*="/"], + div:not(.show_menu)[class*="menu_horizontal"] li.selected_profil > a[href*="/"], #menu_horizontal:not(.show_menu) li.selected_profil > a[href*="/"] , - div:not(.boite)[class*="menu"]:after { + div:not(.boite)[class*="menu_horizontal"]:after { background-color: #333; } - div[class*="menu"].show_menu > ul, + div[class*="menu_horizontal"].show_menu > ul, #menu_horizontal.show_menu > ul{ visibility: visible; width: auto; @@ -510,12 +510,12 @@ } - div[class*="menu"] li.selected_profil > a[href*="/"]:only-child { + div[class*="menu_horizontal"] li.selected_profil > a[href*="/"]:only-child { visibility: visible; } - div:not(.show_menu)[class*="menu"] li.selected_profil > a[href*="/"]:only-child, + div:not(.show_menu)[class*="menu_horizontal"] li.selected_profil > a[href*="/"]:only-child, #menu_horizontal:not(.show_menu) li.selected_profil > a[href*="/"]:only-child{ float: left; line-height: 3em; @@ -524,7 +524,7 @@ } - div[class*="menu"].show_menu li.selected_profil > a[href*="/"]:only-child, + div[class*="menu_horizontal"].show_menu li.selected_profil > a[href*="/"]:only-child, #menu_horizontal.show_menu li.selected_profil > a[href*="/"]:only-child { border-left: 5px solid #00C000; margin-left: -10px; @@ -532,7 +532,7 @@ } - div:not(.boite)[class*="menu"]:after { + div:not(.boite)[class*="menu_horizontal"]:after { content: ''; height: 3em; width: 3em; @@ -543,7 +543,7 @@ } - div:not(.boite)[class*="menu"].show_menu:after { + div:not(.boite)[class*="menu_horizontal"].show_menu:after { background: #333 url(../images/buttons/close_menu.png) no-repeat center center / 2em; } @@ -749,4 +749,4 @@ max-width: 100%; min-width: 100%; } -} \ No newline at end of file +} diff --git a/public/opac/java/slider_navigation/tests/agenda_slider_test.js b/public/opac/java/slider_navigation/tests/agenda_slider_test.js index dc6cbeeef1be6ef741df1d8ea7a24e803b09d51c..b9327a596ce7e24217f4b573f94492b3c4da2c43 100644 --- a/public/opac/java/slider_navigation/tests/agenda_slider_test.js +++ b/public/opac/java/slider_navigation/tests/agenda_slider_test.js @@ -103,21 +103,21 @@ test('window height should be 80px', function() { }); -QUnit.asyncTest('cycle should trigger click and move articles', function( assert ) { +QUnit.asyncTest('cycle should not trigger click and not move articles', function( assert ) { expect( 1 ); - + fixture.trigger('click'); setTimeout(function() { - deepEqual(fixture.find('div.news_row').css('margin-left'), '-110px', fixture.html()); + deepEqual(fixture.find('div.news_row').css('margin-left'), '0px', fixture.html()); QUnit.start(); - }, 1000); + }, 1500); }); -QUnit.asyncTest('cycle should not trigger click and not move articles', function( assert ) { +QUnit.asyncTest('cycle should trigger click and move articles', function( assert ) { expect( 1 ); - fixture.trigger('click'); + setTimeout(function() { - deepEqual(fixture.find('div.news_row').css('margin-left'), '0px', fixture.html()); + deepEqual(fixture.find('div.news_row').css('margin-left'), '-110px', fixture.html()); QUnit.start(); - }, 1500); + }, 1000); }); diff --git a/public/opac/js/liste_notices_mur.js b/public/opac/js/liste_notices_mur.js index c57079f4cd4e90009d71d562954bfc28777c47a6..cb11aea4fd8fe9e0cf751cabddc5379aa3093e60 100644 --- a/public/opac/js/liste_notices_mur.js +++ b/public/opac/js/liste_notices_mur.js @@ -40,8 +40,9 @@ function popupResumeAndDispo(context, resume, dispo, id) { if( window.noticeMurTooltip == undefined) { function noticeMurTooltip(item) { var id = $(item).data('id'); + $('.notice-mur-tooltip').hide(); $(item).tooltip({ - show:{delay:250}, + show:{delay:200}, content:'<div style="text-align:center;padding:15px;"><img src="' + imagesUrl +'patience.gif" /></div>', open:function(event, ui){ var context = $(this); diff --git a/public/opac/js/responsive.js b/public/opac/js/responsive.js index 8052bee673164b2c92c4064e92c73bbcd6776880..2c1d0ec63802d2cb9fdc601214b2dae4feb6a14e 100644 --- a/public/opac/js/responsive.js +++ b/public/opac/js/responsive.js @@ -1,11 +1,11 @@ $(document).ready(function() { var enableMenuButton = function() { - $("div:not(.boite)[class*='menu']").click(function(e) { - $("div:not(.boite)[class*='menu']").not(this).removeClass('show_menu'); + $("div:not(.boite)[class*='menu_horizontal']").click(function(e) { + $("div:not(.boite)[class*='menu_horizontal']").not(this).removeClass('show_menu'); $(this).toggleClass('show_menu'); }); - $("div:not(.boite)[class*='menu'] * ").not('.configuration_module *').click(function(e) { + $("div:not(.boite)[class*='menu_horizontal'] * ").not('.configuration_module *').click(function(e) { e.stopImmediatePropagation(); }); } diff --git a/scripts/emacs/phafi-mode.el b/scripts/emacs/phafi-mode.el index 155f20cff467bbc49690b67616948e692985ef32..5649758caa001e8b7807d27f5dd747f24138e244 100644 --- a/scripts/emacs/phafi-mode.el +++ b/scripts/emacs/phafi-mode.el @@ -50,7 +50,6 @@ (require 'phpunit) (require 'auto-complete-autoloads) (require 'auto-complete) - (require 'org-link-minor-mode) (require 'gtags) (add-hook 'gtags-mode-hook @@ -73,7 +72,6 @@ ) (auto-complete-mode t) (subword-mode t) - (org-link-minor-mode t) (gtags-mode t) (setq ag-highlight-search t) (setq ag-arguments (list "--smart-case" @@ -207,9 +205,9 @@ (setq phafi-phpunit-command (concat debug-mode - (if phafi-phpunit-profiling (phafi-phpunit-profiling-command) "phpunit") - " -c " - phafi-phpunit-config + "phpunit -c " + (phafi-selected-phpunit-config) + " " command-filter " " filename @@ -228,11 +226,6 @@ ) -(defun phafi-phpunit-profiling-command() - (concat (phafi-mode-dir) "profile-phpunit") - ) - - (defun phafi-run-phpunit(debug-mode) "Run all phpunit tests" (interactive "P" ) @@ -356,6 +349,12 @@ ) +(defun phafi-selected-phpunit-config() + (if phafi-phpunit-profiling + (concat (phafi-root-dir) "tests/phpunit_with_profiling.xml") + phafi-phpunit-config) + ) + (defun phafi-sql-patch(patch) "Force execution of db migration" (interactive (list (read-number "Enter patch number: "))) diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 87326f4c9dadb8f42341470c4897306091aa6b51..b6a06e301855c2ab6c7f0cc681dfb4c67d0efde0 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -181,7 +181,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe protected function _generateLoaderFor($model, $methods) { - $loader = $this->getMock('Mock'.$model, $methods); + $loader = $this->createMock('Mock'.$model, $methods); Storm_Model_Abstract::setLoaderFor($model, $loader); return $loader; } @@ -243,19 +243,26 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe if ($content == null) $content = $this->_response->getBody(); - $httpClient = (new Zend_Http_Client('http://sandbox.pergame.net/html-validator/')) + if (!$nu_validator_url = getenv('BOKEH_HTML_VALIDATOR_URL')) + $nu_validator_url ='https://validator.w3.org/nu/'; + + $httpClient = (new Zend_Http_Client($nu_validator_url)) ->setMethod(Zend_Http_Client::POST) + ->setHeaders('Content-Type', 'text/html; charset=utf-8') ->setEncType(Zend_Http_Client::ENC_FORMDATA) - ->setParameterPost('content', $content); + ->setParameterGet('out', 'text') + ->setRawData($content); $response = $httpClient->request()->getBody(); $content_lines = explode("\n", $content); - $content_with_lines = "HTML:\n"; + $content_with_lines = "HTML from: " . $nu_validator_url ."\n"; foreach($content_lines as $i => $line) { $content_with_lines .= sprintf("%4s %s\n", $i + 1, $line); } - $this->assertContains('No errors found', $response, $content_with_lines); + $this->assertNotContains('Error: ', + $response, + $content_with_lines); } diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 36f6adb4740a8ecbbae4fdbac2af8e28c3d3f433..d2d48edb96c18ae60643260dfc3ed7c45345ac11 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -489,7 +489,7 @@ class AccueilControllerConfigBoiteLoginPostTest extends AccueilControllerConfigB public function setUp() { parent::setUp(); - $this->postDispatch('/admin/accueil/login?config=accueil&type_module=LOGIN&id_module=32', + $this->postDispatch('/admin/accueil/login/render/popup?config=accueil&type_module=LOGIN&id_module=32', ['boite' => '', 'titre' => 'Se connecter', 'profil_redirect' => 678, @@ -510,6 +510,13 @@ class AccueilControllerConfigBoiteLoginPostTest extends AccueilControllerConfigB public function profilLogoutRedirectShouldBe345() { $this->assertEquals(345, $this->_prefs['profil_logout_redirect']); } + + + /** @test */ + public function responseShouldRedirectWithJS() { + $this->assertXPathContentContains('//script', + 'parent.window.location=parent.document.location.href'); + } } @@ -619,7 +626,7 @@ class AccueilControllerPostConfigBoiteKiosqueProfilLognesTest extends Admin_Abst /** @test **/ public function postConfigShouldRedirectToReferrer() { - $this->assertXpathContentContains('//script', 'parent.window.location = parent.document.location.href;'); + $this->assertXpathContentContains('//script', 'parent.window.location=parent.document.location.href;'); } diff --git a/tests/application/modules/admin/controllers/AmberControllerTest.php b/tests/application/modules/admin/controllers/AmberControllerTest.php index 808e8977df622e6be8f8d61787082a8a41339866..75bd96150b556f9b0549aff50c6d3bcaa5f56fec 100644 --- a/tests/application/modules/admin/controllers/AmberControllerTest.php +++ b/tests/application/modules/admin/controllers/AmberControllerTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AdminAbstractControllerTestCase.php'; require_once 'application/modules/admin/controllers/AmberController.php'; @@ -33,8 +33,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { parent::setUp(); $this->assertInstanceOf('Class_FileWriter', Admin_AmberController::getFileWriter()); - - $this->mock_filewriter = $this->getMock('Class_FileWriter', array('putContents')); + $this->mock_filewriter = $this->createMock('Class_FileWriter', array('putContents')); Admin_AmberController::setFileWriter($this->mock_filewriter); $this->_old_cfg = Zend_Registry::get('cfg'); @@ -48,7 +47,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { public function tearDown() { Zend_Registry::set('cfg', $this->_old_cfg); - + parent::tearDown(); } @@ -70,7 +69,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { ->expects($this->once()) ->method('putContents') ->with('./amber/src/js/Kernel.js', 'somejs'); - + $this->putDispatch('/admin/amber/commitJs/Kernel.js', 'somejs'); } @@ -82,7 +81,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { ->expects($this->once()) ->method('putContents') ->with('./amber/afi/js/AFI-Core.js', 'somejs'); - + $this->putDispatch('/admin/amber/commitJs/AFI-Core.js', 'somejs'); } @@ -95,7 +94,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { ->expects($this->once()) ->method('putContents') ->with('./amber/src/st/Kernel.st', 'some smalltalk'); - + $this->putDispatch('/admin/amber/commitSt/Kernel.st', 'some smalltalk'); } @@ -108,7 +107,7 @@ class AmberControllerTest extends Admin_AbstractControllerTestCase { ->mock_filewriter ->expects($this->never()) ->method('putContents'); - + $this->putDispatch('/admin/amber/commitJs/Kernel.js', 'somejs'); } } diff --git a/tests/application/modules/admin/controllers/NewsletterControllerTest.php b/tests/application/modules/admin/controllers/NewsletterControllerTest.php index 44b5a7511761730bb0a84d0fe93fd707689504bb..eeda907295e05d8dbea7b9c4abc5d1b5665f5572 100644 --- a/tests/application/modules/admin/controllers/NewsletterControllerTest.php +++ b/tests/application/modules/admin/controllers/NewsletterControllerTest.php @@ -424,6 +424,7 @@ class Admin_NewsletterControllerValidationsTest extends Admin_NewsletterControll + class Admin_NewsletterControllerDeleteActionTest extends Admin_AbstractControllerTestCase { protected $_storm_default_to_volatile = true; diff --git a/tests/application/modules/admin/controllers/ProfilControllerProfilJeunesseAndAdultesWithMenusTest.php b/tests/application/modules/admin/controllers/ProfilControllerProfilJeunesseAndAdultesWithMenusTest.php index 7fa275d49510d7defe688fde95ffefaffd4bcd61..ffd63cb87452fe0174d3a9320268f46ed7f60c71 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerProfilJeunesseAndAdultesWithMenusTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerProfilJeunesseAndAdultesWithMenusTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AdminAbstractControllerTestCase.php'; require_once 'ProfilControllerTest.php'; @@ -25,12 +25,12 @@ abstract class ProfilControllerProfilJeunesseAndAdultesWithMenusTestCase extends public function setUp() { parent::setUp(); - $picsou = $this->fixture('Class_Article', - ['id' => 4, + $picsou = $this->fixture('Class_Article', + ['id' => 4, 'titre' => 'Picsou fait faillite', 'contenu' => 'un drame familiale']); - $donald = $this->fixture('Class_Article', - ['id' => 5, + $donald = $this->fixture('Class_Article', + ['id' => 5, 'titre' => 'Donald a la plage', 'contenu' => 'des vacances de rêve']); @@ -59,7 +59,7 @@ abstract class ProfilControllerProfilJeunesseAndAdultesWithMenusTestCase extends ['type_menu' => 'NEWS', 'libelle' => 'Actu', - 'picto' => 'vide.gif', + 'picto' => 'chat.gif', 'preferences' => ['nb_aff' => '2', 'display_mode' => 'Submenu']]]]; @@ -217,7 +217,7 @@ class ProfilControllerProfilJeunesseAndAdultesWithMenusTestRender extends Profil /** @test */ public function boiteMenuVerticalMenuActuShouldOpenSubmenu() { - $this->assertXPathContentContains('//ul[@class="menuGauche"]/li/a[contains(@onclick, "afficher_sous_menu")]', + $this->assertXPathContentContains('//ul[@class="menuGauche"]/li/a[contains(@onclick, "afficher_sous_menu")]', 'Actu'); } @@ -305,12 +305,19 @@ class ProfilControllerProfilJeunesseAndAdultesWithMenusTestSwitchPageMusiqueToPr /** @test */ public function monMenuShouldBeDisplayedOnPageMusique() { $this->dispatch('/opac?id_profil='.$this->page_musique->getId()); - $this->assertXPathContentContains("//div[@class='boiteGauche']//div[@class='titre']", + $this->assertXPathContentContains("//div[@class='boiteGauche']//div[@class='titre']", 'Mon menu', $this->_response->getBody()); $this->assertXPathContentContains("//ul[@class='menuGauche']//li", 'Pratique'); $this->assertXPathContentContains("//ul[@class='menuGauche']//li", 'Google'); } + + + /** @test */ + public function actuEntryShouldContainsLinkWithImage() { + $this->dispatch('/opac?id_profil='.$this->page_musique->getId()); + $this->assertXPath('//ul[@class="menuGauche"]/li/a/img[contains(@src, "chat.gif")]'); + } } @@ -344,21 +351,21 @@ class ProfilControllerProfilJeunesseAndAdultesWithMenusTestMovePageMusiqueToProf class ProfilControllerProfilMediathequeMenuVerticalWithNoLinkToProfilTest extends Admin_AbstractControllerTestCase { - - protected + + protected $_menu_mediatheque, $_cfg_menus, $_profil_mediatheque; - + public function setup() { parent::setup(); $this->_menu_mediatheque = ['libelle' => 'menu de la mediatheque', - 'picto' => 'vide.gif', - 'menus' => ['type_menu' => 'MENU', - 'libelle' => 'Informations', - 'picto' => 'vide.gif', - 'preferences' => []]]; + 'picto' => 'vide.gif', + 'menus' => ['type_menu' => 'MENU', + 'libelle' => 'Informations', + 'picto' => 'vide.gif', + 'preferences' => []]]; $this->_cfg_menus = ['H' => $this->_menu_mediatheque]; @@ -370,7 +377,7 @@ class ProfilControllerProfilMediathequeMenuVerticalWithNoLinkToProfilTest extend ->setLibelle('Profil Mediatheque') ->setCfgMenus($this->_cfg_menus); } - + /** @test **/ public function paramsOfProfilMediathequeShouldContainsSelectProfil() { @@ -378,7 +385,7 @@ class ProfilControllerProfilMediathequeMenuVerticalWithNoLinkToProfilTest extend $this->assertXpath('//form//select',$this->_response->getBody()); } - + /** @test **/ public function withOutPreferencesProfilSelectShouldBeEmpty() { $this->dispatch('/admin/menus/lienprofil?id_profil=999&type_menu=MENU&id_module=1&libelle=menu%C3%de%C3%la%C3%mediatheque&picto=vide.gif&preferences='); @@ -389,12 +396,12 @@ class ProfilControllerProfilMediathequeMenuVerticalWithNoLinkToProfilTest extend class ProfilControllerProfilMediathequeMenuVerticalWithLinkToProfilTest extends Admin_AbstractControllerTestCase { - - protected + + protected $_menu_mediatheque, $_cfg_menus, $_profil_mediatheque; - + public function setup() { parent::setup(); @@ -416,9 +423,9 @@ class ProfilControllerProfilMediathequeMenuVerticalWithLinkToProfilTest extends ->setLibelle('Profil Mediatheque') ->setCfgMenus($this->_cfg_menus); } - - + + /** @test **/ public function withPreferencesProfilOneSelectedOptionShouldBeOne() { $this->dispatch('/admin/menus/lienprofil?id_profil=999&type_menu=MENU&id_module=1&libelle=menu%C3%de%C3%la%C3%mediatheque&picto=vide.gif&preferences=clef_profil=1'); diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index e16f1372da4df10b2ff0aa4b3bc00514d7bc9ab1..d25593e44e474a0372b06f6cd8391cf7cb8c14cb 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class Admin_ProfilControllerProfilJeunesseTestCase extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); $cfg_site = ['header_img' => "/public/jeunesse.png", @@ -1546,3 +1548,30 @@ class Admin_ProfilControllerProfilPortalLoginPagePostTest extends Admin_Abstract $this->assertEquals(2, Class_Profil::find(1)->getLoginPage()); } } + + + +/** @see http://forge.afi-sa.fr/issues/52108 */ +class Admin_ProfilControllerEditLibraryFilterTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Bib', + ['id' => 9, + 'libelle' => 'Annecy', + 'zone' => $this->fixture('Class_Zone', + ['id' => 12, + 'libelle' => 'Haute-Savoie'])]); + + $this->dispatch('/admin/profil/edit/id_profil/1', true); + } + + + /** @test */ + public function annecyFilterShouldBePresent() { + $this->assertXPathContentContains('//select[@name="id_site"]//option[@value="9"]', + 'Annecy'); + } +} diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index 9062378084801fd1c9b21a0123980eb58df41749..ebe8a4becd432c2aef16aee924ae773bb9cf4d11 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -590,7 +590,7 @@ class UsersControllerPostValidDataWithCommOpsysTest extends UsersControllerWithM public function setUp() { parent::setUp(); - $this->opsys_service = $this->getMock('MockOpsysService', ['saveEmprunteur']); + $this->opsys_service = $this->createMock('MockOpsysService', ['saveEmprunteur']); $this->emprunteur = new Class_WebService_SIGB_Emprunteur('2341', 'Marcus'); $this->emprunteur->setService($this->opsys_service); diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index de283d41216d91642241ae53a4261cd7b3047dc0..80d376e551e370e9975a40dbb528ffe02cd4b3b1 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -18,7 +18,9 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class AbstractAbonneControllerFormationsTestCase extends AbstractControllerTestCase { +abstract class AbstractAbonneControllerFormationsTestCase + extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true, $_amadou, @@ -94,7 +96,10 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'effectif_min' => 1, 'effectif_max' => 10, 'lieu' => $this->_gallice_cafe, - 'date_debut' => '2014-01-10']); + 'date_debut' => '2015-01-10', + 'date_fin' => '2015-01-10', + 'date_limite_inscription' => '2015-01-10', + 'stagiaires' => []]); $this->_session_smalltalk_juillet = $this->fixture('Class_SessionFormation', ['id' => 12, @@ -103,7 +108,9 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'effectif_max' => 10, 'lieu' => $this->_gallice_cafe, 'stagiaires' => [], - 'date_debut' => '2014-07-11']); + 'date_debut' => '2014-07-11', + 'date_fin' => '2014-07-15', + 'date_limite_inscription' => '2014-07-11']); $this->_learn_smalltalk = $this->fixture('Class_Formation', ['id' => 1, @@ -129,16 +136,20 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'effectif_min' => 2, 'effectif_max' => 5, 'lieu' => $this->_gallice_cafe, - 'date_debut' => '2014-03-01', + 'date_debut' => '2015-03-01', 'stagiaires' => [], - 'date_limite_inscription' => '2014-03-01']); + 'date_limite_inscription' => '2015-03-01']); $this->_session_java_septembre = $this->fixture('Class_SessionFormation', ['id' => 30, 'formation_id' => 3, - 'date_debut' => '2014-09-1', + 'effectif_min' => 2, + 'effectif_max' => 5, + 'date_debut' => '2014-09-10', + 'date_fin' => '2014-09-10', 'stagiaires' => [], - 'date_limit_inscription' => '2014-08-15']); + 'lieu' => $this->_gallice_cafe, + 'date_limit_inscription' => '2014-09-10']); $this->_session_java_septembre->beAnnule(); $this->_learn_java = $this->fixture('Class_Formation', @@ -153,6 +164,8 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro ['id' => 121, 'formation_id' => 12, 'date_debut' => '2014-07-10', + 'date_fin' => '2014-07-14', + 'date_limit_inscription' => '2014-07-10', 'contenu' => 'Introduction a la syntaxe', 'objectif' => 'Ecrire un premier programme', 'effectif_min' => 1, @@ -175,7 +188,7 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'nom' => 'Cerisier', 'prenom' => 'Christophe', 'mail' => 'cc@bokeh.fr']) - ]]); + ]]); $this->_learn_python = $this->fixture('Class_Formation', ['id' => 12, @@ -202,13 +215,13 @@ class AbonneControllerFormationsListWithLearnJavaNotVisibleTest extends Abstract } - /** @test */ + /** @test */ function noH2ShouldContainsLearnJava() { $this->assertNotXPathContentContains('//h2', 'Learn Java'); } - /** @test */ + /** @test */ function sessionMarsShouldNotBeVisible() { $this->assertNotXPathContentContains('//tbody//tr//td', '1 mars 2014'); } @@ -218,17 +231,16 @@ class AbonneControllerFormationsListWithLearnJavaNotVisibleTest extends Abstract class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest extends AbstractAbonneControllerFormationsTestCase { - public function setUp() { - parent::setUp(); - } /** @test */ public function trainingJavaShouldBeDisplayed() { $this->dispatch('/opac/formations', true); - $this->assertXPathContentContains('//h2', 'Learn Java',$this->response->getBody()); + $this->assertXPathContentContains('//td', 'Learn Java'); } - /** @test */ + + + /** @test */ function noH2ShouldContainsLearnSmalltalk() { $this->_learn_smalltalk->hide()->save(); $this->dispatch('/opac/formations', true); @@ -236,7 +248,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte } - /** @test */ + /** @test */ function sessionJuilletShouldNotBeVisibleIfParentTrainingIsHidden() { $this->_learn_smalltalk->hide()->save(); $this->dispatch('/opac/formations', true); @@ -244,7 +256,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte } - /** @test */ + /** @test */ function sessionJuilletShouldNotBeVisibleIfHidden() { $this->_learn_smalltalk->show()->save(); $this->_session_smalltalk_juillet->hide()->save(); @@ -252,12 +264,13 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte $this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014'); } - /** @test */ + + /** @test */ function sessionJuilletShouldBeVisibleIfShow() { $this->_learn_smalltalk->show()->save(); $this->_session_smalltalk_juillet->show()->save(); $this->dispatch('/opac/formations', true); - $this->assertXPathContentContains('//tbody//tr//td', '11 juillet 2014'); + $this->assertXPathContentContains('//td', '11 juillet 2014'); } } @@ -273,33 +286,32 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati ->setBarreNavOn(true) ->setLibelle('Mon compte') ->setParentProfil( - Class_Profil::newInstanceWithId(42, - ['cfg_modules' => ['abonne' => ['formations' => ['barre_nav' => 'Les formations']]]])); + Class_Profil::newInstanceWithId(42, + ['cfg_modules' => ['abonne' => ['formations' => ['barre_nav' => 'Les formations']]]])); - $this->dispatch('/opac/formations', true); - } + $this->_session_python_juillet + ->show() + ->assertSave(); - /** @test */ - function aH2ShouldContainsLearnJava() { - $this->assertXPathContentContains('//h2', 'Learn Java'); + $this->dispatch('/opac/formations', true); } /** @test */ - function aDivForDescriptionShouldContainsIfYouWantTo() { - $this->assertXPathContentContains('//div', 'whaaat ?'); + function aTdShouldContainsLearnJava() { + $this->assertXPathContentContains('//td', 'Learn Java'); } /** @test */ - function aH2ShouldContainsLearnPython() { - $this->assertXPathContentContains('//h2', 'Learn Python'); + function aTdShouldNotContainsLearnPythonBeCauseAmadouAlreadyRegistered() { + $this->assertNotXPathContentContains('//td', 'Learn Python'); } /** @test */ - function session_java_mars_ShouldNotHaveLinkForInscrireAsInscriptionClosed() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/32")]'); + function session_java_mars_ShouldHaveLinkForInscrire() { + $this->assertXPath('//a[contains(@href, "abonne/inscrire-session/id/32")]'); } @@ -310,8 +322,8 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ - function session_janvier_smalltalk_ShouldNotHaveLinkForInscrireAsFinished() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/11")]'); + function session_janvier_smalltalk_ShouldHaveLinkForInscrire() { + $this->assertXPath('//a[contains(@href, "abonne/inscrire-session/id/11")]'); } @@ -322,21 +334,20 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ - function sessionJanuary2014ShouldBeFirst() { - $this->assertXPathContentContains('//tbody//tr[1]//td', '10 janvier 2014'); + function sessionJanuary2015ShouldBeFirst() { + $this->assertXPathContentContains('//tr[2]//td', '10 janvier 2015'); } - /** @test */ function sessionMarsShouldBeFirst() { - $this->assertXPathContentContains('//tbody//tr[1]//td', '1 mars 2014'); + $this->assertXPathContentContains('//tr[4]//td', '1 mars 2015'); } - /** @test */ - function sessionSeptemberShouldBeSecond() { - $this->assertXPathContentContains('//tbody//tr[2]//td', ' septembre 2014'); + /** @test */ + function sessionJavaSeptemberShouldNotBeVisibleBecauseItHasBeenCancel() { + $this->assertNotXPathContentContains('//tr//td', '10 septembre 2014'); } @@ -347,160 +358,243 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ - function session10Juillet2014ShouldBeFirst() { - $this->assertXPathContentContains('//tbody//tr[1]//td', '10 juillet 2014'); - } + function sessionPython10Juillet2014ShouldNotBePresentBecauseAlreadyRegistered() { + $this->assertNotXPathContentContains('//tr//td', '10 juillet 2014'); + } - /** @test */ - function session11Juillet2014ShouldSecond() { - $this->assertXPathContentContains('//tbody//tr[2]//td', '11 juillet 2014'); - } + /** @test */ + function session11Juillet2014ShouldBePresend() { + $this->assertXPathContentContains('//tr//td', '11 juillet 2014'); + } - /** @test */ - function session_fevrier_17_lieuBonlieuShouldBeDisplayed() { - $this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu'); - } + /** @test */ + function session_fevrier_17_lieuBonlieuShouldBeDisplayed() { + $this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu'); + } - /** @test */ - function session_fevrier_17_ShouldHaveLinkForInscrire() { - $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]', - "S'inscrire"); - } + /** @test */ + function session_fevrier_17_ShouldHaveLinkForInscrire() { + $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]', + "S'inscrire"); + } - /** @test */ - function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { - $this->assertXPathContentContains('//tbody//tr/td', - '20 janvier 2015'); - } + /** @test */ + function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { + $this->assertXPathContentContains('//tbody//tr/td', + '20 janvier 2015'); + } - /** @test */ - function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { - $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "formations/detail-session/id/31")]', - 'Détails de la session'); - } + /** @test */ + function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { + $this->assertXPath('//tr//a[contains(@href, "formations/detail-session/id/31")]'); + } - /** @test */ - function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() { - $this->assertXPathContentContains('//tbody//tr[1]', '1 mars 2014'); - } + /** @test */ + function session_mars_27_ShouldBeDisplayed() { + $this->assertXPathContentContains('//tr', '1 mars 2015'); + } - /** @test */ - function session_septembre_java_ShouldBeAnnule() { - $this->assertXPathContentContains('//tr/td/span[@class="error"]', 'Annul'); - } + /** @test */ + function boiteTitleShouldBeFormations() { + $this->assertXPathContentContains('//h1', 'S\'inscrire à une formation'); + } - /** @test */ - function session_python_juillet_ShouldHaveLinkForDesinscrire() { - $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]', - "Se désinscrire"); - } + /** + * @test + * @group pagetitles + */ + public function barreNavShouldContainsMonCompte() { + $this->assertXPathContentContains('//div[@class="barre_nav"]//span//a[contains(@href, "index/index/id_profil/2")]', + 'Mon compte'); + } - /** @test */ - function boiteTitleShouldBeFormations() { - $this->assertXPathContentContains('//h1', 'Formations'); - } + /** @test */ + public function barreNavShouldContainsAccueilThatLinksToProfilOne() { + $this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index/id_profil/1")]', + 'Accueil'); + } +} - /** - * @test - * @group pagetitles - */ - public function barreNavShouldContainsMonCompte() { - $this->assertXPathContentContains('//div[@class="barre_nav"]//span//a[contains(@href, "index/index/id_profil/2")]', - 'Mon compte'); - } - /** @test */ - public function barreNavShouldContainsAccueilThatLinksToProfilOne() { - $this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index/id_profil/1")]', - 'Accueil'); - } - } +class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/fiche?retour=/opac/abonne/fiche', true); + } + /** @test */ + public function pageShouldContainsLinkToFormations() { + $this->assertXPathContentContains('//a[contains(@href, "/formations")]', + 'S\'inscrire à une formation'); + } - class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneControllerFormationsTestCase { - public function setUp() { - parent::setUp(); - $this->dispatch('/opac/abonne/fiche?retour=/opac/abonne/fiche'); - } - /** @test */ - public function pageShouldContainsLinkToFormations() { - $this->assertXPathContentContains('//a[contains(@href, "formations")]', 'S\'inscrire à une formation'); - } + /** @test */ + public function pageShouldNotContainsVousEtesInscritFormationPython() { + $this->assertNotXPathContentContains('//ul//li', 'Learn Python, 10 juillet 2014'); + } + + + /** @test */ + public function pageShouldContainsLinkToRegistrations() { + $this->assertXPathContentContains('//a[contains(@href, "/formations/registered")]', + 'Mes inscriptions en cours'); + } + + + /** @test */ + public function pageShouldContainsLinkToDone() { + $this->assertXPathContentContains('//a[contains(@href, "/formations/done")]', + 'Mes formations suivies'); + } +} - /** @test */ - public function pageShouldContainsVousEtesInscritFormationPython() { - $this->assertXPathContentContains('//ul//li', 'Learn Python, 10 juillet 2014'); - } - /** @test */ - public function pageShouldContainsLinkToDetailSessionPyhton() { - $this->assertXPath('//li//a[contains(@href, "formations/detail-session/id/121?retour=/abonne/fiche")]',$this->_response->getBody()); - } - } +class AbonneControllerFormationsRegisteredActionTest + extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/formations/registered', true); + } + /** @test */ + public function titleShouldBeMesInscriptionsEnCours() { + $this->assertXPathContentContains('//h1', 'Mes inscriptions en cours'); + } - Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends AbstractAbonneControllerFormationsTestCase { - /** @test */ - public function whenFormationsDisabledPageShouldNotContainsLinkToFormations() { - Class_AdminVar::getLoader() - ->newInstanceWithId('FORMATIONS') - ->setValeur('0'); - $this->dispatch('/opac/abonne/fiche'); - $this->assertNotXPath('//a[contains(@href, "formations")]'); - } + + /** @test */ + public function learnPythonShouldBePresent() { + $this->assertXPathContentContains('//td', 'Learn Python'); + } - /** @test */ - public function whenUserNotStagiairePageShouldNotContainsLinkToFormations() { - $this->_amadou->setUserGroups(array()); - $this->dispatch('/opac/abonne/fiche'); - $this->assertNotXPath('//a[contains(@href, "formations")]'); + /** @test */ + public function dateShouldBePresent() { + $this->assertXPathContentContains('//td', '10 juillet 2014'); + } + + + /** @test */ + public function locationShouldBePresent() { + $this->assertXPathContentContains('//td', 'Bibliothèque des romains'); + } + + + /** @test */ + public function limitDateShouldBePresent() { + $this->assertXPathContentContains('//td', 'Date limite d\'inscription'); + } + + + /** @test */ + public function detailLinkShouldBePresent() { + $this->assertXPath('//a[contains(@href, "formations/detail-session/id/121")]'); + } + + + /** @test */ + public function unregisterLinkShouldBePresent() { + $this->assertXPath('//a[contains(@href, "abonne/desinscrire-session/id/121")]'); } } -class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase { + +class AbonneControllerFormationsDoneActionTest + extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { + parent::setUp(); - $this->_amadou->setUserGroups([]); - $this->dispatch('/opac/formations'); + $this->_session_python_juillet->setDateDebut('2006-09-09')->assertSave(); + $this->dispatch('/formations/done', true); } /** @test */ - function linkForInscrireShouldNotExists() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session")]'); + public function titleShouldBeMesInscriptionsEnCours() { + $this->assertXPathContentContains('//h1', 'Mes formations suivies'); + } + + + /** @test */ + public function learnPythonShouldBePresent() { + $this->assertXPathContentContains('//td', 'Learn Python'); + } + + + /** @test */ + public function dateShouldBePresent() { + $this->assertXPathContentContains('//td', '9 septembre 2006'); + } + + + /** @test */ + public function locationShouldBePresent() { + $this->assertXPathContentContains('//td', 'Bibliothèque des romains'); } /** @test */ - function linkForDesinscrireShouldExists() { - $this->assertXPath('//a[contains(@href, "abonne/desinscrire-session")]'); + public function detailLinkShouldBePresent() { + $this->assertXPath('//a[contains(@href, "formations/detail-session/id/121")]'); } +} + + +Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends AbstractAbonneControllerFormationsTestCase { /** @test */ - public function messageVousNavezPasLesDroitsSuffisantsShouldBeVisible() { - $this->assertXPathContentContains('//p', "Vous n'avez pas les droits"); + public function whenFormationsDisabledPageShouldNotContainsLinkToFormations() { + Class_AdminVar::getLoader() + ->newInstanceWithId('FORMATIONS') + ->setValeur('0'); + $this->dispatch('/opac/abonne/fiche'); + $this->assertNotXPath('//a[contains(@href, "formations")]'); + } + + + /** @test */ + public function whenUserNotStagiairePageShouldNotContainsLinkToFormations() { + $this->_amadou->setUserGroups(array()); + $this->dispatch('/opac/abonne/fiche'); + $this->assertNotXPath('//a[contains(@href, "formations")]'); + } +} + + + +class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { + parent::setUp(); + $this->_amadou->setUserGroups([]); + $this->dispatch('/opac/formations'); + } + + + /** @test */ + function linkForInscrireShouldNotExists() { + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session")]'); } } @@ -509,6 +603,10 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); + $this->_session_java_mars + ->setDateDebut('2014-03-01') + ->setDateLimiteInscription('2014-03-01') + ->assertSave(); $this->dispatch('/opac/abonne/inscrire-session/id/32'); } @@ -726,12 +824,6 @@ class AbonneControllerFormationsSessionJavaFevrierFullListTest extends AbonneCon function session_fevrier_17_ShouldNotHaveLinkForInscrire() { $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/31")]'); } - - - /** @test */ - public function sessionShouldDisplayFull() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', 'Complet'); - } } @@ -741,7 +833,7 @@ class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends public function pageShouldHaveLinkToDesinscrire() { $this->_session_java_fevrier->addStagiaire($this->_amadou); $this->_amadou->setSessionFormations(array($this->_session_java_fevrier)); - $this->dispatch('/opac/formations'); + $this->dispatch('/opac/formations/registered'); $this->assertXPath('//a[contains(@href, "abonne/desinscrire-session/id/31")]'); } } @@ -792,16 +884,31 @@ class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest ex -class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends AbstractAbonneControllerFormationsTestCase { - protected $_mails; +class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest + extends AbstractAbonneControllerFormationsTestCase { + protected $_mails, $_previous_referer; public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/desinscrire-session/id/121', true); + $this->_previous_referer = isset($_SERVER['HTTP_REFERER']) + ? $_SERVER['HTTP_REFERER'] + : null; + $_SERVER['HTTP_REFERER'] = '/formations'; + + $this->dispatch('/opac/abonne/desinscrire-session/id/121', true); $this->_mails = $this->_mail_transport->getSentMails(); } + + public function tearDown() { + if ($this->_previous_referer) + $_SERVER['HTTP_REFERER'] = $this->_previous_referer; + + parent::tearDown(); + } + + /** @test */ function answerShouldRedirectToFormationList() { $this->assertRedirectTo('/formations'); @@ -991,121 +1098,43 @@ class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extend class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFormationsTestCase { - /** @test */ - public function onDetailSessionShouldRedirectToFormations() { - $this->dispatch('/opac/formations/detail-session/id/9999'); - $this->assertRedirectTo('/formations/index'); - } + protected $_previous_referer; + public function setUp() { + parent::setUp(); - /** @test */ - public function onInscrireSessionShouldRedirectToFormations() { - $this->dispatch('/opac/abonne/inscrire-session/id/9999'); - $this->assertRedirectTo('/formations'); - } - + $this->_previous_referer = isset($_SERVER['HTTP_REFERER']) + ? $_SERVER['HTTP_REFERER'] + : null; - /** @test */ - public function ondesinscrireSessionShouldRedirectToFormations() { - $this->dispatch('/opac/abonne/desinscrire-session/id/9999'); - $this->assertRedirectTo('/formations'); + $_SERVER['HTTP_REFERER'] = '/formations'; } -} + public function tearDown() { + if ($this->_previous_referer) + $_SERVER['HTTP_REFERER'] = $this->_previous_referer; - -Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestCase { - - public function setup() { - parent::setup(); - - $test_time = new TimeSourceForTest('2014-05-09 14:00:00'); - - Class_Formation::setTimeSource($test_time); - Class_SessionFormation::setTimeSource($test_time); - - - $current_user = $this->fixture('Class_Users', [ - 'id' => 1, - 'login' => 'log', - 'password' => 'pwd', - 'id_site' => 1, - 'idabon' => '00044958', - 'role_level' => 2, - 'user_groups' => [$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()] - ]); - - ZendAfi_Auth::getInstance()->logUser($current_user); - - $session_full = $this->fixture('Class_SessionFormation', - ['id' => 1, - 'formation_id' => 1, - 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-07-01', - 'effectif_min' => 1, - 'effectif_max' => 1, - 'stagiaires' => [$current_user]]); - - $session_canceled = $this->fixture('Class_SessionFormation', - ['id' => 1, - 'formation_id' => 1, - 'date_debut' => '2014-07-10', - 'effectif_min' => 1, - 'effectif_max' => 10, - 'stagiaires' => []]); - $session_canceled->beAnnule(); - - $session_subscription_exhausted = $this->fixture('Class_SessionFormation', - ['id' => 1, - 'formation_id' => 1, - 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-01-10', - 'effectif_min' => 1, - 'effectif_max' => 10, - 'stagiaires' => []]); - - $formation = $this->fixture('Class_Formation', - ['id' => 1, - 'libelle' => 'Farming cerths', - 'sessions' => [$session_full, - $session_canceled, - $session_subscription_exhausted]]); - - - $current_user->setSessionFormationInscriptions([$this->fixture('Class_SessionFormationInscription', - ['id' => 1, - 'stagiaire' => $current_user, - 'session_formation' => $formation])]); - $this->dispatch('/opac/formations', true); + parent::tearDown(); } - /** @test */ - function sessionShouldBeFull() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Complet'); - } - - - /** @test */ - function sessionShouldBeCanceld() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Annul'); + public function detailSessionShouldRedirectToFormations() { + $this->dispatch('/opac/formations/detail-session/id/9999'); + $this->assertRedirectTo('/formations/index'); } /** @test */ - function sessionShouldBeDisplaySubscribeTimeExhaust() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Date de limite d\'inscription dépassée:'); + public function inscrireSessionShouldRedirectToFormations() { + $this->dispatch('/opac/abonne/inscrire-session/id/9999'); + $this->assertRedirectTo('/formations'); } /** @test */ - function sessionShouldDisplaySubscribeTime() { - $this->assertXPathContentContains('//tbody//tr/td/span', - 'Date de limite d\'inscription:'); + public function desinscrireSessionShouldRedirectToFormations() { + $this->dispatch('/opac/abonne/desinscrire-session/id/9999'); + $this->assertRedirectTo('/formations'); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AbonneControllerNewslettersTest.php b/tests/application/modules/opac/controllers/AbonneControllerNewslettersTest.php index d22e3ed68756624696a567ac9aff581f114774d8..6e8916235efac1b809b927e5076dc15ab6f265ee 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerNewslettersTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerNewslettersTest.php @@ -385,7 +385,7 @@ class AbonneControllerNewslettersOpsysCommunicationTest extends AbonneController public function setUp() { parent::setUp(); - $this->opsys_service = $this->getMock('MockOpsysService', array('saveEmprunteur')); + $this->opsys_service = $this->createMock('MockOpsysService', array('saveEmprunteur')); $this->emprunteur = new Class_WebService_SIGB_Emprunteur('00123', 'Marcus'); $this->emprunteur->setService($this->opsys_service); diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 1ac62ad2f3e42711e4ce88b49039dbd52beae61e..d5bc413a20d165f47583e192e48eb8d651f65754 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -18,7 +18,6 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once 'AbstractControllerTestCase.php'; require_once 'tests/fixtures/KohaFixtures.php'; require_once 'tests/fixtures/NewsletterFixtures.php'; @@ -220,6 +219,106 @@ class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutTest +class AuthControllerNobodyLoggedBoiteLoginRedirectTest + extends PortailWithOneLoginModuleTestCase { + protected $_profile, $_parent_profile; + + public function setUp() { + parent::setUp(); + + $_SERVER['HTTP_REFERER'] = '/recherche/viewnotice/id/12'; + $this->fixture('Class_Users', + ['id' => 36, + 'login' => 'pourlecoup', + 'password' => 'puocelruop']); + + $this->_parent_profile = Class_Profil::getCurrentProfil(); + $this->_profile = $this->fixture('Class_Profil', + ['id' => 22, + 'browser' => 'opac', + 'libelle' => 'Profil Adulte', + 'hauteur_banniere' => 150, + 'couleur_texte_bandeau' => '#F2C', + 'couleur_lien_bandeau' => '#234', + 'menu_haut_on' => true, + 'cfg_menus' => [], + 'commentaire' => 'Super bib', + 'ref_tags' => 'bib,Adulte', + 'parent_profil' => $this->_parent_profile]); + + Class_Profil::setCurrentProfil($this->_profile); + $this->fixture('Class_Profil', + ['id' => 6, + 'browser' => 'opac', + 'libelle' => 'Profil To redirect', + 'hauteur_banniere' => 150, + 'couleur_texte_bandeau' => '#F2C', + 'couleur_lien_bandeau' => '#234', + 'menu_haut_on' => true, + 'cfg_menus' => [], + 'commentaire' => 'Super bib', + 'ref_tags' => 'bib,Adulte']); + + $authenticated = false; + ZendAfi_Auth::setInstance($this->mock() + ->whenCalled('getIdentity') + ->willDo( + function() use(&$authenticated) { + if (!$authenticated) + return null; + + $identity = new StdClass(); + $identity->ID_USER = 36; + return $identity; + }) + ->whenCalled('authenticateLoginPassword') + ->with('pourlecoup', 'puocelruop') + ->willDo( + function() use(&$authenticated) { + return $authenticated = true; + })); + } + + + public function tearDown() { + ZendAfi_Auth::setInstance(null); + parent::tearDown(); + } + + + /** @test **/ + public function withoutProfileShouldRedirectToReferer() { + $cfg_accueil = $this->_parent_profile->getCfgAccueilAsArray(); + $cfg_accueil['modules'][4]['preferences']['profil_redirect'] = 0; + $this->_parent_profile + ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil)); + + $this->postDispatch('/opac/auth/boite-login', ['username' => 'pourlecoup', + 'password' => 'puocelruop']); + + $this->assertNotNull(Class_Users::getIdentity()); + $this->assertRedirectTo('/recherche/viewnotice/id/12'); + } + + + /** @test **/ + public function withLoginProfile6InParentShouldRedirectToIt() { + $cfg_accueil = $this->_parent_profile->getCfgAccueilAsArray(); + $cfg_accueil['modules'][4]['preferences']['profil_redirect'] = 6; + $this->_parent_profile + ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil)); + + $this->postDispatch('/opac/auth/boite-login', ['username' => 'pourlecoup', + 'password' => 'puocelruop']); + + $this->assertNotNull(Class_Users::getIdentity()); + $this->assertRedirectTo(Class_Profil::find(6)->getUrl()); + } +} + + + + abstract class AuthControllerNobodyLoggedTestCase extends PortailWithOneLoginModuleTestCase { public function setUp() { parent::setUp(); @@ -765,7 +864,7 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase { /** @test */ public function emptyUsernameShouldRedirectToReferer() { $this->loggingWithOutFillingUsername(); - $this->assertRedirectTo($this->_referer); + $this->assertRedirectTo(Class_Profil::find(1)->getUrl()); } /* @test */ @@ -955,9 +1054,10 @@ class AuthControllerBoiteLoginPostTest extends AuthControllerPostSimpleSuccessfu 'display' => ZendAfi_Controller_Action_Helper_FlashMessenger::POPUP]]); } + /** @test */ public function responseShouldRedirectToReferrer() { - $this->assertRedirectTo('/recherche/viewnotice'); + $this->assertRedirectTo(Class_Profil::find(1)->getUrl()); } } diff --git a/tests/application/modules/opac/controllers/FormationsControllerTest.php b/tests/application/modules/opac/controllers/FormationsControllerTest.php index 7716f7ebbbac74fc2224f1bebd140dd53646e5c6..7bfdd5e7c8997b130fea130c200f727e1baf1864 100644 --- a/tests/application/modules/opac/controllers/FormationsControllerTest.php +++ b/tests/application/modules/opac/controllers/FormationsControllerTest.php @@ -127,25 +127,6 @@ class FormationsControllerFormationsSessionFevrierJavaTest extends AbstractForma - -class FormationsControllerAnonymousTest extends AbstractFormationsControllerTestCase { - public function setUp() { - parent::setUp(); - $this->dispatch('/opac/formations', true); - - } - - /** @test */ - function sessionShouldDisplaySubscribeTime() { - - $this->assertXPathContentContains('//tbody//tr/td/span', - 'Date de limite d\'inscription:'); - } -} - - - - class FormationsControllerFormationsSessionJuilletPythonDetailRetourFicheTest extends AbstractFormationsControllerTestCase { public function setUp() { parent::setUp(); @@ -157,6 +138,4 @@ class FormationsControllerFormationsSessionJuilletPythonDetailRetourFicheTest ex $this->assertXPathContentContains('//a[contains(@href, "abonne/fiche")]', 'Retour', $this->_response->getBody()); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index a79c352713387dbd46a0b91806fffd713a5c7a65..48fb3b8be0faf09b761c94e887dcbffb27beb59b 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -23,13 +23,13 @@ class RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); + parent::setUp(); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'recherche', - 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> {titre_principal} <div>{article.contenu}</div> + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'recherche', + 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> {titre_principal} <div>{article.contenu}</div> ]}</p>', - 'type' => 'Notice_List']); + 'type' => 'Notice_List']); $this->fixture('Class_Catalogue', ['id'=>3, @@ -63,27 +63,27 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); + parent::setUp(); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'recherche', - 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div> + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'recherche', + 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div> ]}</p>']); - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 10, - 'titre' => 'pomme', - 'contenu' => '<p>blabla</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 10, + 'titre' => 'pomme', + 'contenu' => '<p>blabla</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, - 'titre' => 'transmetropolitan', - 'contenu' => '<p>bd</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, + 'titre' => 'transmetropolitan', + 'contenu' => '<p>bd</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); - $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_List/ids/2;1/modele_fusion/1",true); + $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_List/ids/2;1/modele_fusion/1",true); } @@ -131,49 +131,49 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); - Class_AdminVar::set("AVIS_MIN_SAISIE", 5); - Class_AdminVar::set("AVIS_MAX_SAISIE", 500); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'article', - 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> + parent::setUp(); + Class_AdminVar::set("AVIS_MIN_SAISIE", 5); + Class_AdminVar::set("AVIS_MAX_SAISIE", 500); + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'article', + 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> <div>{notice.resume} </div> {notice.avis[<p>{avis}</p>]} </p>', - 'type' => 'Notice_View']); - - - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, - 'titre' => 'transmetropolitan', - 'contenu' => '<p>bd</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); - $avis = [ - $this->fixture('Class_AvisNotice', [ - 'id' => 1, - 'id_user' => 1, - 'avis' => 'Lies are news and truth is obsolete.', - 'entete' => 'quotes', - 'note' => 4, - 'clef_oeuvre' => 'TRANSMETROPOLITAN---', - 'notice' => 1, - 'date_avis' => '2012-01-01', - ]), - $this->fixture('Class_AvisNotice', [ - 'id' => 2, - 'id_user' => 1, - 'avis' => "The point is, the only real tools we have are our eyes and our heads. It's not the act of seeing with our eyes alone; it's correctly comprehending what we see. Treating life as an autopsy", - 'entete' => 'quotes', - 'note' => 4, - 'notice' => 1, - 'clef_oeuvre' => 'TRANSMETROPOLITAN---', - 'date_avis' => '2012-01-01', - ]), - ]; - - - - $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_View/id/1/modele_fusion/1",true); + 'type' => 'Notice_View']); + + + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, + 'titre' => 'transmetropolitan', + 'contenu' => '<p>bd</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); + $avis = [ + $this->fixture('Class_AvisNotice', [ + 'id' => 1, + 'id_user' => 1, + 'avis' => 'Lies are news and truth is obsolete.', + 'entete' => 'quotes', + 'note' => 4, + 'clef_oeuvre' => 'TRANSMETROPOLITAN---', + 'notice' => 1, + 'date_avis' => '2012-01-01', + ]), + $this->fixture('Class_AvisNotice', [ + 'id' => 2, + 'id_user' => 1, + 'avis' => "The point is, the only real tools we have are our eyes and our heads. It's not the act of seeing with our eyes alone; it's correctly comprehending what we see. Treating life as an autopsy", + 'entete' => 'quotes', + 'note' => 4, + 'notice' => 1, + 'clef_oeuvre' => 'TRANSMETROPOLITAN---', + 'date_avis' => '2012-01-01', + ]), + ]; + + + + $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_View/id/1/modele_fusion/1",true); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index bdcd45d9bd9578424bfef618f896618df157d179..d42a1f45c57a4631fbd0ce6af86892514a81f26a 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -209,7 +209,7 @@ class RechercheControllerPagerTest extends RechercheControllerNoticeTestCase { Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultatsimple' => ['search_term_editable' => 0]]]); $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/*/facette/T3/liste_format/4', true); - $this->assertXPath('//div[@class="expression-recherche"][contains(text(), "pomme")]',$this->_response->getBody()); + $this->assertXPath('//div[@class="resultats_page"]//div[@class="expression-recherche"][contains(text(), "pomme")]',$this->_response->getBody()); } @@ -232,7 +232,7 @@ class RechercheControllerPagerTest extends RechercheControllerNoticeTestCase { public function pagerShouldBeDisplayedOnBottom() { Class_AdminVar::newInstanceWithId('SEARCH_PAGINATE_POSITION', ['valeur' => 'BOTTOM']); $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/*/facette/T3/liste_format/4', true); - $this->assertXPath('//div[@class="liste_notices"]/following-sibling::node()[@class="pager"]'); + $this->assertXPath('//div[@class="liste_notices"]/following-sibling::node()[@class="pager"]', $this->_response->getBody()); } @@ -1179,8 +1179,22 @@ class RechercheAvanceeControllerSimpleActionWithDefaultConfigTest extends Recher "id" => "M12", "libelle" => "DVD", "nombre" => 5], + ]]) - ]]); + ->whenCalled('setDuration') + ->answers($mock_search_result) + + ->whenCalled('getDuration') + ->answers(0.4) + + ->whenCalled('setSettings') + ->answers($mock_search_result) + + ->whenCalled('getSettings') + ->answers(Class_Profil::getCurrentProfil()->getSearchResultSettings()) + + ->whenCalled('getRecords') + ->answers([]); $mock_moteur_recherche ->whenCalled('lancerRecherche') @@ -1431,12 +1445,12 @@ abstract class RechercheControllerSimpleActionListeFormatTestCase extends Abstra 'label' => 'Livres']); $this->fixture('Class_TypeDoc' , [ 'id' => 2, 'label' => 'Périodique']); - - } } + + class RechercheControllerSimpleActionWithListeFormatMurTest extends RechercheControllerSimpleActionListeFormatTestCase { protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR, @@ -1450,7 +1464,7 @@ class RechercheControllerSimpleActionWithListeFormatMurTest extends RechercheCon /** @test **/ public function resumeNoticeLinkShouldBeReset() { - $this->assertXPathContentContains('//head/script', "/noticeajax/resumenotice';"); + $this->assertXPathContentContains('//head/script', "/noticeajax/resumenotice';", $this->_response->getBody()); } @@ -2178,8 +2192,10 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext return $mock_search_result; }); - $mock_search_result + $settings = Class_Profil::getCurrentProfil()->getSearchResultSettings(); + $settings['liste_format'] = 3; + $mock_search_result ->whenCalled('isError') ->answers(false) @@ -2199,7 +2215,24 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext ->answers(['facettes' => [], 'tags' => [], 'suggests' => [], - 'bookmarks' => []]); + 'bookmarks' => []]) + + ->whenCalled('setDuration') + ->answers($mock_search_result) + + ->whenCalled('getDuration') + ->answers(0.5) + + ->whenCalled('setSettings') + ->answers($mock_search_result) + + ->whenCalled('getSettings') + ->answers($settings) + + ->whenCalled('getRecords') + ->answers([$this->fixture('Class_Notice', + ['id' => 1])]) +; Class_MoteurRecherche::setInstance($mock_moteur_recherche); @@ -2383,7 +2416,7 @@ class RechercheControllerAjoutNoticePanierUrlMurTest extends RechercheController public function setUp() { parent::setUp(); ZendAfi_Auth::getInstance()->clearIdentity(); - $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true); + $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur', true); } @@ -2703,6 +2736,7 @@ class RechercheControllerSimpleActionWithCvsActivatedTest extends RechercheContr public function setUp() { parent::setUp(); $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2', true); + Class_Profil::getCurrentProfil() ->setCfgModules(['recherche' => ['resultatsimple' => [ 'cvs_autres_resultats' => 'Results from opac', @@ -2746,6 +2780,7 @@ class RechercheControllerSimpleActionWithCvsActivatedTest extends RechercheContr return $xml; } + /** @test **/ public function titleResultFromOpacShouldBeDiplay() { $this->assertXPathContentContains('//h1','Results from opac'); diff --git a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php index bb3b1c787d9392d5426332b79bab9666ef6c9afb..f7d09f827d82eb46687adbdb94ddcaea6b9e88e6 100644 --- a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php +++ b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php @@ -87,6 +87,7 @@ class BibNumeriqueControllerTelephoneViewAlbumMonumentsTest extends BibNumerique $this->assertXPath('//ul[@data-role="listview"]//li[@data-role="list-divider"]//a[contains(@href, "media/versailles.epub")]//img[contains(@src, "epub.png")]'); } + /** @test */ public function pageShouldBeHTML5Valid() { $this->assertHTML5(); diff --git a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php index fff38f0f996e96209a6516dc3cf7a1d7936b44b0..cde47ac96c764a5d902e2dbc95f35cb0202f5517 100644 --- a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php +++ b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php @@ -20,7 +20,6 @@ */ abstract class TelephoneAbstractControllerTestCase extends AbstractControllerTestCase { - public function setUp() { parent::setUp(); $_SERVER['HTTP_USER_AGENT'] = 'iPhone'; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d2f3af4053c92dd09af1e2eb41de2d587f00fe1f..4e026a7b8f0af06d5e9396827b668ef844ef51c2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -86,6 +86,7 @@ $translate->setLocale('fr'); require_once 'tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php'; require_once 'tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php'; require_once 'tests/fixtures/RessourcesNumeriquesFixtures.php'; +require_once 'tests/fixtures/MockedClasses.php'; register_shutdown_function(function(){ TestSpeedTrap::printSpeedTrappedTests(); diff --git a/tests/fixtures/MockedClasses.php b/tests/fixtures/MockedClasses.php new file mode 100644 index 0000000000000000000000000000000000000000..bee98e902b6518ef9e4234332bd3595b55f892ff --- /dev/null +++ b/tests/fixtures/MockedClasses.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 + */ + + +abstract class BokehBaseMockClass { + public function select() {} + public function fetchall() {} + public function find() {} + public function findAllBy() {} + public function saveEmprunteur() {} + public function setOAIHandler(){} + public function getRecordsFromSet(){} + public function getListRecordsResumptionToken(){} + public function setListRecordsResumptionToken(){} + public function translate(){} + public function open_url(){} + public function getGUID(){} + public function OuvrirSession(){} + public function FermerSession(){} + public function getEmpruntsOf(){} + public function getReservationsOf(){} + public function getAvisFromPreferences(){} +} + + +class MockLoader extends BokehBaseMockClass {} +class MockOpsysService extends BokehBaseMockClass {} +class Mock_OpsysService extends BokehBaseMockClass {} +class OpsysFactory extends BokehBaseMockClass {} +class Class_WebServiceOAI extends BokehBaseMockClass {} +class MockTranslator extends BokehBaseMockClass {} +class Class_XMLMock extends BokehBaseMockClass {} +class OuvreSessionResponseMock extends BokehBaseMockClass{} +class MappedSoapClientMock extends BokehBaseMockClass{} +class Storm_Model_TableClass_Article extends BokehBaseMockClass {} +class Storm_Model_TableClass_AvisNotice extends BokehBaseMockClass {} +class Storm_Model_TableClass_PanierNotice extends BokehBaseMockClass {} +class Storm_Model_TableClass_NewsletterSubscription extends BokehBaseMockClass {} +class Storm_Model_TableClass_Newsletter extends BokehBaseMockClass {} +class Storm_Model_TableClass_Users extends BokehBaseMockClass {} +class Storm_Model_TableClass_Notice extends BokehBaseMockClass {} +class MockClass_Users extends BokehBaseMockClass {} +class MockClass_AvisNotice extends BokehBaseMockClass {} \ No newline at end of file diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index b454d8e0a335301c188986a00f1f5d2ae9f9c261..44eb3778cf616fdb7b6ac34d1585aeeb6d972618 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/ModelTestCase.php @@ -45,7 +45,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { protected function _buildTableMock($model, $methods) { - $table = $this->getMock('Storm_Model_Table'.$model,$methods); + $table = $this->createMock('Storm_Model_Table'.$model,$methods); $loader = call_user_func([$model, 'getLoader']); $loader->setTable($table); return $table; @@ -107,7 +107,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { protected function _generateLoaderFor($model, $methods) { - $loader = $this->getMock('Mock'.$model, $methods); + $loader = $this->createMock('Mock'.$model, $methods); Storm_Model_Abstract::setLoaderFor($model, $loader); return $loader; } diff --git a/tests/library/Class/NoticeOAITest.php b/tests/library/Class/NoticeOAITest.php index f1241a541eb801d872d8cfc7d5ece8ae1356f306..76d765ccb3ffb8c97e668bc1f309eb47ab01e8c5 100644 --- a/tests/library/Class/NoticeOAITest.php +++ b/tests/library/Class/NoticeOAITest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'Class/NoticeOAI.php'; require_once 'Class/WebService/OAI.php'; @@ -56,9 +56,9 @@ class OAINoticeTestHarverstWithOneRecord extends PHPUnit_Framework_TestCase { 'editeur' => 'T. Du Bray (Paris)', 'description' => ''); - $oai_service = $this->getMock('Class_WebServiceOAI', - array('getRecordsFromSet', - 'setOAIHandler', + $oai_service = $this->createMock('Class_WebServiceOAI', + array('getRecordsFromSet', + 'setOAIHandler', 'getNextRecords', 'getListRecordsResumptionToken')); @@ -96,13 +96,13 @@ class OAINoticeTestHarverstWithOneRecord extends PHPUnit_Framework_TestCase { } public function testDateIs1608() { - $this->assertEquals('1608', + $this->assertEquals('1608', $this->inserted_data_in_db['date']); } public function testIdOaiIsGallica() { - $this->assertEquals('http://gallica.bnf.fr/ark:/12148/bpt6k701371', + $this->assertEquals('http://gallica.bnf.fr/ark:/12148/bpt6k701371', $this->inserted_data_in_db['id_oai']); } @@ -135,9 +135,9 @@ class OAINoticeTestResume extends PHPUnit_Framework_TestCase { ->setLibelle('BNF gallica') ->setHandler('http://oai.bnf.fr/oai2/OAIHandler'); - $this->oai_service = $this->getMock('Class_WebServiceOAI', - array('getRecordsFromSet', - 'setOAIHandler', + $this->oai_service = $this->createMock('Class_WebServiceOAI', + array('getRecordsFromSet', + 'setOAIHandler', 'hasNextRecords', 'getNextRecords', 'getListRecordsResumptionToken', diff --git a/tests/library/Class/ProfilI18nStringExtractorTest.php b/tests/library/Class/ProfilI18nStringExtractorTest.php index 2acf4aaa69fa6025d801583730d4cf6892eb3ffc..c8f45687864a24ad1b47ec46f3289866af6d9618 100644 --- a/tests/library/Class/ProfilI18nStringExtractorTest.php +++ b/tests/library/Class/ProfilI18nStringExtractorTest.php @@ -133,7 +133,7 @@ class ChatenayMenusI18nStringExtractorTest extends I18nStringExtractorTestCase { /** @test */ public function withAnotherTranslatorExtractShouldGetOriginalText() { - $englishTranslator = $this->getMock('MockTranslator', array('translate')); + $englishTranslator = $this->createMock('MockTranslator', array('translate')); $englishTranslator ->expects($this->never()) ->method('translate'); diff --git a/tests/library/Class/UploadTest.php b/tests/library/Class/UploadTest.php index 1836cae8257cdc372cdb2262271d452dd2c1b0f3..352a6bee2cf632ffa6ee7784c2552e92725caff7 100644 --- a/tests/library/Class/UploadTest.php +++ b/tests/library/Class/UploadTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class UploadFichierTest extends PHPUnit_Framework_TestCase { @@ -29,7 +29,7 @@ class UploadFichierTest extends PHPUnit_Framework_TestCase { protected function setUp() { parent::setUp(); - $this->_folderManager = $this->getMock('Class_Folder_Manager'); + $this->_folderManager = $this->createMock('Class_Folder_Manager'); $this->_upload = Class_Upload::newInstanceFor('fichier') ->setFolderManager($this->_folderManager); } diff --git a/tests/library/Class/WebService/BabelioTest.php b/tests/library/Class/WebService/BabelioTest.php index 4cb34ee7a810c965822e7268c763a2d687ddcfbf..543c1fdeea9779deedd1503b6451182ffa92bf1e 100644 --- a/tests/library/Class/WebService/BabelioTest.php +++ b/tests/library/Class/WebService/BabelioTest.php @@ -16,12 +16,12 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_BabelioTest extends PHPUnit_Framework_TestCase { /** @test */ public function clientShouldBeCalledWithAuthAndTimestamp() { - $mock = $this->getMock('Zend_Http_Client'); + $mock = $this->createMock('Zend_Http_Client'); $mock ->expects($this->once()) ->method('setUri') @@ -30,11 +30,11 @@ class Class_WebService_BabelioTest extends PHPUnit_Framework_TestCase { $service = new Class_WebService_Babelio(); $service->setHttpClient($mock); - + $service ->setVolatileTime(1311003574) ->requete('999'); - + } - + } \ No newline at end of file diff --git a/tests/library/Class/WebService/OAITest.php b/tests/library/Class/WebService/OAITest.php index 1ec7e9d79f0b919017ce1e1d587c4d670a375c1f..6e4346ca8f00c6166cd8ed8afd00c051766d2db8 100644 --- a/tests/library/Class/WebService/OAITest.php +++ b/tests/library/Class/WebService/OAITest.php @@ -22,7 +22,7 @@ require_once 'Class/WebService/OAI.php'; class OAITestGetSets extends PHPUnit_Framework_TestCase { public function setUp() { - $xml_mock = $this->getMock('Class_XMLMock', + $xml_mock = $this->createMock('Class_XMLMock', array('open_url')); $xml_mock ->expects($this->any()) @@ -63,7 +63,7 @@ class OAITestGetRecordsOfSetGallica extends PHPUnit_Framework_TestCase { protected $oai_service; public function setUp() { - $xml_mock = $this->getMock('Class_XMLMock', + $xml_mock = $this->createMock('Class_XMLMock', array('open_url')); $xml_mock ->expects($this->any()) @@ -119,7 +119,7 @@ class OAITestGetRecordsOfSetGallica extends PHPUnit_Framework_TestCase { public function testNextRecordsUseResumptionTokenAndFetchNextRecords() { - $xml_mock = $this->getMock('Class_XMLMock', + $xml_mock = $this->createMock('Class_XMLMock', array('open_url')); $this->oai_service->setWebClient($xml_mock); $xml_mock diff --git a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php index 8a56bf9b70daa88c20203a87488022009d9d8638..a7a85ac98f7e034802d126bbbc5d88aa37611b1f 100644 --- a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php @@ -132,7 +132,7 @@ class OpsysServiceTestAutoConnect extends Storm_Test_ModelTestCase { private $client; public function setUp(){ - $this->ouvre_session_res = $this->getMock( + $this->ouvre_session_res = $this->createMock( 'OuvreSessionResponseMock', array('getGUID')); $this->ouvre_session_res @@ -140,7 +140,7 @@ class OpsysServiceTestAutoConnect extends Storm_Test_ModelTestCase { ->method('getGUID') ->will($this->returnValue("12345")); - $this->ouvre_session_error = $this->getMock( + $this->ouvre_session_error = $this->createMock( 'OuvreSessionResponseMock', array('getGUID')); $this->ouvre_session_error @@ -148,7 +148,7 @@ class OpsysServiceTestAutoConnect extends Storm_Test_ModelTestCase { ->method('getGUID') ->will($this->returnValue("")); - $this->search_client = $this->getMock( + $this->search_client = $this->createMock( 'MappedSoapClientMock', array('OuvrirSession', 'FermerSession')); } @@ -211,9 +211,9 @@ class Class_WebService_SIGB_OpsysServiceTestProxy extends Storm_Test_ModelTestCa private $mock_opsys_service; public function setUp(){ - $this->factory = $this->getMock('OpsysFactory', array('createOpsysService')); + $this->factory = $this->createMock('OpsysFactory', array('createOpsysService')); - $this->mock_opsys_service = $this->getMock( + $this->mock_opsys_service = $this->createMock( 'Class_WebService_SIGB_Opsys', array('newOpsysServiceFactory')); @@ -716,7 +716,7 @@ class OpsysServiceGetExemplaireFromCacheTestDisponibilite extends OpsysServiceWi $notice_potter->addExemplaire($ex); } - $recuperer_notice_res = $this->getMock('RecupererNoticeResponse', + $recuperer_notice_res = $this->createMock('RecupererNoticeResponse', array('createNotice')); $recuperer_notice_res ->expects($this->once()) @@ -1203,7 +1203,7 @@ class OpsysServiceEmprReserverResponseTest extends Storm_Test_ModelTestCase { class OpsysServiceEmprunteurAttributesTest extends Storm_Test_ModelTestCase { public function setUp(){ - $this->opsys_service = $this->getMock('Mock_OpsysService', + $this->opsys_service = $this->createMock('Mock_OpsysService', array('getEmpruntsOf', 'getReservationsOf')); @@ -1443,7 +1443,7 @@ class OpsysServiceEmpruntRetardAttributesTest extends Storm_Test_ModelTestCase { class OpsysServiceEmpruntTestSort extends Storm_Test_ModelTestCase { public function setUp() { - $this->opsys_service = $this->getMock('Mock_OpsysService', + $this->opsys_service = $this->createMock('Mock_OpsysService', array('getEmpruntsOf', 'getReservationsOf')); $this->opsys_service ->expects($this->any()) diff --git a/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php b/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php index 41ba510079cee5646cec19ca75433d50411d17b9..debc3a46391d977e83ae742f141bb50c599cc94c 100644 --- a/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php +++ b/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ include_once('VSmartFixtures.php'); @@ -182,8 +182,8 @@ class VSmartAuthenticateServiceTest extends PHPUnit_Framework_TestCase { Class_Exemplaire::getLoader() ->newInstanceWithId(234) - ->setIdOrigine('2/01234'), - + ->setIdOrigine('2/01234'), + '')); } @@ -202,7 +202,7 @@ class VSmartAuthenticateServiceTest extends PHPUnit_Framework_TestCase { Class_Exemplaire::getLoader() ->newInstanceWithId(234) - ->setIdOrigine('2/01234'), + ->setIdOrigine('2/01234'), '')); } @@ -233,7 +233,7 @@ class VSmartAuthenticateServiceTest extends PHPUnit_Framework_TestCase { $expected_url = sprintf('http://%s/LoginWebSso.csp?Token=ABCD&Function=UserActivities&Module=ADM', Class_WebService_SIGB_VSmart_Service::MOULINS_POPUP_SERVER); - $mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); + $mock_web_client = $this->createMock('Class_WebService_SimpleWebClient'); $mock_web_client ->expects($this->once()) ->method('open_url') diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CacheTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CacheTest.php index b82e82750784b1fff504d012edad95e26ca8d16b..9aeb2296104953c9b0cf3a1d3c79b41701a7e7d1 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/CacheTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/CacheTest.php @@ -36,7 +36,7 @@ class CacheWithCritiquesTest extends ViewHelperTestCase { 'display_order' => 'Random', 'only_img' => true]]; - $this->avis_loader = $this->getMock('MockLoader', ['getAvisFromPreferences']); + $this->avis_loader = $this->createMock('MockLoader', ['getAvisFromPreferences']); Storm_Model_Abstract::setLoaderFor('Class_AvisNotice', $this->avis_loader); $this->critiques_helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $params); diff --git a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php similarity index 84% rename from tests/library/ZendAfi/View/Helper/Notice/MurTest.php rename to tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php index 6127a6258961a40e71ed96dcb83ad72fdfab134c..c5de8c4ed166dfc407eb8ffb481a1a2e3543d7bf 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php @@ -20,15 +20,17 @@ */ -abstract class ZendAfi_View_Helper_Notice_MurTestCase extends ViewHelperTestCase { +abstract class ZendAfi_View_Helper_ListeNotices_MurTestCase extends ViewHelperTestCase { protected $_html; public function setUp() { parent::setUp(); - + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE', 'valeur'=>1] ); defineConstant("PATH_SKIN", "./public/opac/skins/original/"); - - $this->_helper = new ZendAfi_View_Helper_Notice_Mur(); + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => 'Boussy']); + $this->_helper = new ZendAfi_View_Helper_ListeNotices_Mur(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); } } @@ -36,7 +38,7 @@ abstract class ZendAfi_View_Helper_Notice_MurTestCase extends ViewHelperTestCase -class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForNoticeTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); $time_source = new TimeSourceForTest('2013-12-14 09:00:00'); @@ -46,11 +48,11 @@ class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_No ['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", 'url_vignette' => 'hp.png', 'url_image' => 'hp_big.png', - 'facettes' => 'D123 A400 Y2', + 'facettes' => 'D123 A400 Y2 V2 T2', 'clef_oeuvre' => 'HPELPA', 'date_creation' => '2013-12-27 00:00:00', 'exemplaires' => []]); - $this->_html = $this->_helper->notice_Mur($potter, ['liste_codes' =>'ATEN9']); + $this->_html = $this->_helper->listeNotices_Mur([$potter], ['liste_codes' =>'ATEN9']); } @@ -88,17 +90,40 @@ class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_No } + /** @test */ + public function linkBarShouldContains5lis() { + $this->assertXPathCount($this->_html, '//ul[@class="barre-de-lien"]/li', 5); + } + + /** @test **/ public function noticeInModeMurShouldDisplayNouveaute() { $this->assertXPathContentContains($this->_html, '//div//span[@class="notice_nouveaute"]','Nouveaut',$this->_html); } + + + /** @test */ + public function recordShouldBeAvailable() { + $this->assertXpath($this->_html, '//div[@class="notice"][@data-availability="1"]', $this->_html); + } + + + /** @test */ + public function boussyLibraryShouldBeInAvailabilityListShouldBePresent() { + $this->assertXPathContentContains($this->_html, '//div[@class="record_availability"]//div//ul//li', 'Boussy'); + } + + + protected function _unimarcFromFile($name) { + return file_get_contents(realpath(dirname(__FILE__)) . '/' . $name); + } } -class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForSiteTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); $site = $this->fixture('Class_Sitotheque', ['id' => 4, @@ -113,7 +138,7 @@ class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Noti 'type_doc' => Class_TypeDoc::SITE ]); - $this->_html = $this->_helper->notice_Mur($notice); + $this->_html = $this->_helper->listeNotices_Mur([$notice]); } public function tearDown() { @@ -131,7 +156,7 @@ class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Noti -class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForArticleTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); @@ -147,7 +172,7 @@ class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_N Class_Article::newInstanceWithId(5, ['titre' => 'Concert', 'description' => 'Ce soir <img src="concert.jpg">']); - $this->_html = $this->_helper->notice_Mur($concert); + $this->_html = $this->_helper->listeNotices_Mur([$concert]); } @@ -175,7 +200,7 @@ class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_N -class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_Mur_BarreDeLienTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { protected $_notice; public function setUp() { parent::setUp(); @@ -211,7 +236,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->whenCalled('countBy') ->answers(1); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); } @@ -243,7 +268,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->setSigbExemplaire(Storm_Test_ObjectWrapper::mock() ->whenCalled('isReservable') ->answers(true))]); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); $this->assertXPath($this->_html, '//a[contains(@onclick, "openDialogExemplaires")][contains(@onclick, "/noticeAjax/exemplaires/id_notice/34")]', $this->_html); @@ -266,7 +291,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->setSigbExemplaire(Storm_Test_ObjectWrapper::mock() ->whenCalled('isReservable') ->answers(false))]); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); $this->assertNotXPath($this->_html, '//a[contains(@onclick, "openDialogExemplaires")]'); } } diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php index fb2cfb491b19b4a34c34d21d436811db1e7235cd..bf63fa1058dd0cb1e44b3d8a9dcc8085b75dd465 100644 --- a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php @@ -20,21 +20,26 @@ */ -require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; - class VignettesRGAATest extends ViewHelperTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); - Storm_Model_Loader::defaultToVolatile(); + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE', 'valeur'=>1] ); defineConstant('PATH_SKIN', './public/opac/skins/original/'); $helper = new ZendAfi_View_Helper_ListeNotices_Vignettes(); $helper->setView($this->view); + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => 'Médiathèque de Pekin']); + $notice = $this ->fixture('Class_Notice', ['id' => 3455, - 'unimarc' => $this->_unimarcFromFile('beatrix_potter.txt')]); + 'unimarc' => $this->_unimarcFromFile('beatrix_potter.txt'), + 'facettes' => 'V2']); $this->_html = $helper->listeNotices_Vignettes([$notice]); } @@ -52,6 +57,18 @@ class VignettesRGAATest extends ViewHelperTestCase { } + /** @test */ + public function recordShouldBeAvailable() { + $this->assertXPath($this->_html, '//div[@class="vignette"][@data-availability="1"]', $this->_html); + } + + + /** @test */ + public function pekinLibrarySHouldBeInAvailabilityListShouldBePresent() { + $this->assertXPathContentContains($this->_html, '//div[@class="record_availability"]//div//ul//li', 'Pekin'); + } + + protected function _unimarcFromFile($name) { return file_get_contents(realpath(dirname(__FILE__)) . '/' . $name); } diff --git a/tests/library/ZendAfi/View/Helper/SuggestsTest.php b/tests/library/ZendAfi/View/Helper/SuggestsTest.php index 897e4c10b732e977d6d4737895087c71ad8b0197..df829a6a0d7b1b19d775f7cf2ba6657690f1a93a 100644 --- a/tests/library/ZendAfi/View/Helper/SuggestsTest.php +++ b/tests/library/ZendAfi/View/Helper/SuggestsTest.php @@ -22,11 +22,18 @@ class ZendAfi_View_Helper_SuggestsTest extends ViewHelperTestCase { protected $_html, - $_storm_default_to_volatile = true; + $_storm_default_to_volatile = true, + $_engine; public function setUp() { parent::setUp(); + $this->_engine = $this->mock() + ->whenCalled('getCriteresRecherche') + ->answers(new Class_CriteresRecherche()) + + ->whenCalled('getSettings') + ->answers([]); $this->_helper = new ZendAfi_View_Helper_Suggests(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); @@ -35,21 +42,25 @@ class ZendAfi_View_Helper_SuggestsTest extends ViewHelperTestCase { /** @test */ public function withEmptySuggestsShouldReturnEmptyString() { + $this->_engine->whenCalled('fetchFacetsAndTags') + ->answers(['suggests' => []]); $this->assertSame('', - $this->_helper->suggests([], new Class_CriteresRecherche())); + $this->_helper->suggests($this->_engine)); } /** @test */ public function withSuggestResultPommesShouldH2WithSuggestions() { - $html = $this->_helper->suggests([ - ['id' => 'M87', - 'label' => 'Pomme (sujet)'], - - ['id' => 'A43', - 'label' => 'Pomme d\'API (auteur)'], - ], - new Class_CriteresRecherche()); + $this->_engine->whenCalled('fetchFacetsAndTags') + ->answers(['suggests' => [ + ['id' => 'M87', + 'label' => 'Pomme (sujet)'], + + ['id' => 'A43', + 'label' => 'Pomme d\'API (auteur)'], + ]]); + + $html = $this->_helper->suggests($this->_engine); $this->assertXPathContentContains($html, '//div[@class="suggests_outer facette_outer"]/h2', 'Suggestions'); return $html; } diff --git a/tests/library/ZendAfi/View/Helper/TagBanniereTest.php b/tests/library/ZendAfi/View/Helper/TagBanniereTest.php index 9305baea4fc2ca4d05fba1075f3f56d5e28d2782..2034d0b007ed3e777ca69b018b56c608efcfc14a 100644 --- a/tests/library/ZendAfi/View/Helper/TagBanniereTest.php +++ b/tests/library/ZendAfi/View/Helper/TagBanniereTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_TagBanniereCycleTest extends ViewHelperTestCase { @@ -30,9 +30,9 @@ class ZendAfi_View_Helper_TagBanniereCycleTest extends ViewHelperTestCase { parent::setUp(); defineConstant("PATH_SKIN",""); - - $this->file_system=$this->getMock('Class_Testing_FileSystem',['readdir', + + $this->file_system=$this->createMock('Class_Testing_FileSystem',['readdir', 'opendir', 'file_exists', 'mkdir', @@ -47,9 +47,9 @@ class ZendAfi_View_Helper_TagBanniereCycleTest extends ViewHelperTestCase { $this->file_system->expects($this->any())->method('closedir')->will($this->returnValue(null)); Class_Profil::setFileSystem($this->file_system); - $this->profil = $this->fixture('Class_Profil', + $this->profil = $this->fixture('Class_Profil', ['id' => 999, 'header_img_cycle' => true]); - + $this->_helper = new ZendAfi_View_Helper_TagBanniere(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->_helper->view->profil = Class_Profil::getLoader() @@ -74,7 +74,7 @@ class ZendAfi_View_Helper_TagBanniereCycleTest extends ViewHelperTestCase { /** @test */ function ban2ShouldBeVisible() { $this->assertXPath($this->_html, "//img[@src='".USERFILESURL."bannieres/ban2.jpg']",$this->_html); - } + } } ?> \ No newline at end of file diff --git a/tests/phpunit-testlistener-xhprof/LICENSE b/tests/phpunit-testlistener-xhprof/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..97048642f8eb297b07fdfcb29b20d073a4168c34 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/LICENSE @@ -0,0 +1,33 @@ +PHPUnit_TestListener_XHProf + +Copyright (c) 2010-2015, Sebastian Bergmann <sebastian@phpunit.de>. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/phpunit-testlistener-xhprof/composer.json b/tests/phpunit-testlistener-xhprof/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..f6b45cb1bce7e05c8c370e58fa172b9d788c097f --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/composer.json @@ -0,0 +1,40 @@ +{ + "name": "phpunit/test-listener-xhprof", + "description": "A TestListener for PHPUnit that uses XHProf for automated profiling of the tested code", + "type": "library", + "keywords": [ + "phpunit", + "xhprof" + ], + "homepage": "https://github.com/phpunit/phpunit-testlistener-xhprof", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/phpunit/phpunit-testlistener-xhprof/issues" + }, + "require": { + "php": ">=5.3.3", + "phpunit/phpunit": "~4.0" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php b/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php new file mode 100755 index 0000000000000000000000000000000000000000..c71fb45918d6f7e2c6cefebf6d6b893706d7a8cf --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php @@ -0,0 +1,226 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +/** + * A TestListener that integrates with XHProf. + * + * Here is an example XML configuration for activating this listener: + * + * <code> + * <listeners> + * <listener class="PHPUnit\XHProfTestListener\XHProfTestListener"> + * <arguments> + * <array> + * <element key="xhprofLibFile"> + * <string>/var/www/xhprof_lib/utils/xhprof_lib.php</string> + * </element> + * <element key="xhprofRunsFile"> + * <string>/var/www/xhprof_lib/utils/xhprof_runs.php</string> + * </element> + * <element key="xhprofWeb"> + * <string>http://localhost/xhprof_html/index.php</string> + * </element> + * <element key="appNamespace"> + * <string>Doctrine2</string> + * </element> + * <element key="xhprofFlags"> + * <string>XHPROF_FLAGS_CPU,XHPROF_FLAGS_MEMORY</string> + * </element> + * <element key="xhprofIgnore"> + * <string>call_user_func,call_user_func_array</string> + * </element> + * </array> + * </arguments> + * </listener> + * </listeners> + * </code> + * + * @author Benjamin Eberlei <kontakt@beberlei.de> + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2011-2015 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since Class available since Release 1.0.0 + */ +class XHProfTestListener implements \PHPUnit_Framework_TestListener +{ + /** + * @var array + */ + protected $runs = array(); + + /** + * @var array + */ + protected $options = array(); + + /** + * @var integer + */ + protected $suites = 0; + + /** + * Constructor. + * + * @param array $options + */ + public function __construct(array $options = array()) + { + if (!isset($options['appNamespace'])) { + throw new InvalidArgumentException( + 'The "appNamespace" option is not set.' + ); + } + + if (!isset($options['xhprofLibFile']) || + !file_exists($options['xhprofLibFile'])) { + throw new InvalidArgumentException( + 'The "xhprofLibFile" option is not set or the configured file does not exist' + ); + } + + if (!isset($options['xhprofRunsFile']) || + !file_exists($options['xhprofRunsFile'])) { + throw new InvalidArgumentException( + 'The "xhprofRunsFile" option is not set or the configured file does not exist' + ); + } + + require_once $options['xhprofLibFile']; + require_once $options['xhprofRunsFile']; + + $this->options = $options; + } + + /** + * An error occurred. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * A failure occurred. + * + * @param \PHPUnit_Framework_Test $test + * @param \PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) + { + } + + /** + * Incomplete test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * Skipped test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * Risky test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * A test started. + * + * @param \PHPUnit_Framework_Test $test + */ + public function startTest(\PHPUnit_Framework_Test $test) + { + if (!isset($this->options['xhprofFlags'])) { + $flags = XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY; + } else { + $flags = 0; + + foreach (explode(',', $this->options['xhprofFlags']) as $flag) { + $flags += constant($flag); + } + } + + xhprof_enable($flags, array( + 'ignored_functions' => explode(',', $this->options['xhprofIgnore']) + )); + } + + /** + * A test ended. + * + * @param \PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(\PHPUnit_Framework_Test $test, $time) + { + $data = xhprof_disable(); + $runs = new \XHProfRuns_Default; + $run = $runs->save_run($data, $this->options['appNamespace']); + $test_name = get_class($test) . '::' . $test->getName(); + $this->runs[$test_name] = $this->options['xhprofWeb'] . '?run=' . $run . + '&source=' . $this->options['appNamespace']; + } + + /** + * A test suite started. + * + * @param \PHPUnit_Framework_TestSuite $suite + */ + public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) + { + $this->suites++; + } + + /** + * A test suite ended. + * + * @param \PHPUnit_Framework_TestSuite $suite + */ + public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) + { + $this->suites--; + + if ($this->suites == 0) { + print "\n\nXHProf runs: " . count($this->runs) . "\n"; + + foreach ($this->runs as $test => $run) { + print ' * ' . $test . "\n " . $run . "\n\n"; + } + + print "\n"; + } + } +} diff --git a/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php b/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php new file mode 100644 index 0000000000000000000000000000000000000000..db41f6117fcb1ac6a12964a454fb56087db1fd06 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php @@ -0,0 +1,15 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +interface Exception +{ +} diff --git a/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php b/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php new file mode 100644 index 0000000000000000000000000000000000000000..f2c57d64df8840bee072d89d4d41c79a40e2a10d --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php @@ -0,0 +1,15 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +class InvalidArgumentException extends \InvalidArgumentException implements Exception +{ +} diff --git a/tests/phpunit-testlistener-xhprof/src/load.php b/tests/phpunit-testlistener-xhprof/src/load.php new file mode 100644 index 0000000000000000000000000000000000000000..5fded844ea04bed435e6e79f3a5b2bba0d9e8488 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/load.php @@ -0,0 +1,5 @@ +<?php +require_once('XHProfTestListener.php'); +require_once('exceptions/Exception.php'); +require_once('exceptions/InvalidArgumentException.php'); +?> \ No newline at end of file diff --git a/tests/phpunit_with_profiling.xml b/tests/phpunit_with_profiling.xml new file mode 100644 index 0000000000000000000000000000000000000000..a279b67a2f100bf3d93ccb16c1d177a1bd979cc1 --- /dev/null +++ b/tests/phpunit_with_profiling.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit + bootstrap="./bootstrap.php" + colors="false" + backupGlobals="false" + stopOnFailure="false" + stopOnError="false" + > + <testsuites> + <testsuite name="DBTestSuite"> + <directory>./db/</directory> + </testsuite> + <testsuite name="ScenariosTestSuite"> + <directory>./scenarios/</directory> + </testsuite> + <testsuite name="ApplicationTestSuite"> + <directory>./scenarios/</directory> + <directory>./application/</directory> + <directory>./library/</directory> + <directory>./js/</directory> + <directory>../library/storm/tests/Storm/</directory> + </testsuite> + <testsuite name="DigitalResourcesTestSuite"> + <directory>../library/digital_resources/</directory> + </testsuite> + </testsuites> + <filter> + <whitelist> + <directory suffix=".php">../application</directory> + <directory suffix=".php">../library/Class</directory> + <directory suffix=".php">../library/Trait</directory> + <directory suffix=".php">../library/ZendAfi</directory> + <directory suffix=".php">../library/fonctions</directory> + <directory suffix=".php">./js/</directory> + <exclude> + <file>../index.php</file> + <directory>../library/Class/Pdf</directory> + <directory>../library/Thumbs</directory> + <directory>../library/storm/tests/Storm</directory> + </exclude> + </whitelist> + </filter> + <listeners> + <listener file = "./TestSpeedTrap.php" class="TestSpeedTrap"/> + <listener class="PHPUnit\XHProfTestListener\XHProfTestListener" file="phpunit-testlistener-xhprof/src/load.php"> + <arguments> + <array> + <element key="xhprofLibFile"> + <string>xhprof/xhprof_lib/utils/xhprof_lib.php</string> + </element> + <element key="xhprofRunsFile"> + <string>xhprof/xhprof_lib/utils/xhprof_runs.php</string> + </element> + <element key="xhprofWeb"> + <string>xhprof/xhprof_html/index.php</string> + </element> + <element key="xhprofFlags"> + <string>XHPROF_FLAGS_CPU,XHPROF_FLAGS_MEMORY</string> + </element> + <element key="xhprofIgnore"> + <string>call_user_func,call_user_func_array</string> + </element> + <element key="appNamespace"> + <string>Bokeh</string> + </element> + </array> + </arguments> + </listener> + </listeners> +</phpunit>