diff --git a/VERSIONS b/VERSIONS index fe13cee6636ae63feaf018d6c23f4dae380cb741..60c9b5d29efa90a2372154d457cef4469a660a87 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,54 @@ +28/10/2015 - v7.3.22 + + - ticket #31941 : Correction compatibilité explorateur de fichier / hébergement mutualisé sans sous-répertoire + + - ticket #27768 : Affichage en mode liste des articles, correctif des problèmes suivant : + * le filtre ne descend pas dans les sous-catégories + * la pagination ne fonctionne pas après une recherche + * la recherche ne se fait que dans le portail + + - ticket #30552 : + - La longueur maxi d'un pseudo passe a 100 caractères + - correction du bug : lors de la mise a jour du pseudo l'abonné se retrouve en invite + + +27/10/2015 - v7.3.21 + + - mise sous test des migrations bases de données + + +26/10/2015 - v7.3.20 + + - ticket #31732 : correction des popups multiples en cliquant sur les vignettes de notices dans certains navigateurs + + - correction affichage des avis dans la boite avis. + + + +26/10/2015 - v7.3.19 + + - ticket #30918 : SIGB Nanook, envoie et récupération des suggestions d'achat + + - ticket #30329 : Corrige l'affichage en mode impression lorsque le modèle a une propriété vide. + + - ticket #29412 : Déplace la mise à jour des images d'article dans l'indexation + + - ticket #31427 : Dans un article avec formulaire, on n'a plus accès à la catégorie (régression) + + - ticket #31425 : Supprime la notice associée à un site ou un article lorsque ce dernier est supprimé + + - ticket #27974 : Elargir la recherche sur un autre site + + - ticket #24865 : PNB: Ergonomie interface emprunt + + - ticket #31743 : Correction du lien d'edition et suppression des sous catégories en mode liste + + - ticket #31793 : Activation du message CNIL par défaut, désactivable par la variable CNIL_CONSENT_ENABLE + + - ticket #23808 : Nouvelle interface de modération des avis + + + 19/10/2015 - v7.3.18 - fixe une erreur de session sur l'outil Inspecteur Gadget @@ -13,6 +64,10 @@ - ticket #26157 : Accès Kidilangues en test miop + + +26/10/2015 - v7.2.18 + - ticket #30479 : Erreur à l'affichage des plans de localisation. - ticket #30520 : CCEG : Ouvrir les lien sitothèque dans un nouvel onglet diff --git a/VERSIONS_WIP/25569 b/VERSIONS_WIP/25569 new file mode 100644 index 0000000000000000000000000000000000000000..c94f8bded989f66326903a4aca9260e71cca6e6d --- /dev/null +++ b/VERSIONS_WIP/25569 @@ -0,0 +1 @@ + - ticket #25569 : Boite sitothèque : afficher les derniers sites d'une catégorie \ No newline at end of file diff --git a/VERSIONS_WIP/25728 b/VERSIONS_WIP/25728 new file mode 100644 index 0000000000000000000000000000000000000000..76c10edf0cc64954f3251c567f70a337735fc124 --- /dev/null +++ b/VERSIONS_WIP/25728 @@ -0,0 +1 @@ + - ticket #25728 : Ajouter la possibilité de flux rss à la boite sitothèque \ No newline at end of file diff --git a/VERSIONS_WIP/27641 b/VERSIONS_WIP/27641 new file mode 100644 index 0000000000000000000000000000000000000000..8cbc32ed4041b8ee6f335c70925a2c72e39c43e3 --- /dev/null +++ b/VERSIONS_WIP/27641 @@ -0,0 +1 @@ + - ticket #27641 : Les renvois d'autorités BNF (auteur et mot matières) ne sont plus perdus à l'import total suivant \ No newline at end of file diff --git a/VERSIONS_WIP/32110 b/VERSIONS_WIP/32110 new file mode 100644 index 0000000000000000000000000000000000000000..29997c6f7bed124d548e236bc6afeb94e6fa492b --- /dev/null +++ b/VERSIONS_WIP/32110 @@ -0,0 +1 @@ + - ticket #32110 : [PNB] Ecran intermédiaire de prêt: texte riche d'aide paramétrable par la médiathèque \ No newline at end of file diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index 66d2bcc98328ce489415244c46aa825d4eac5c5a..6b08929418dee48a716211207d05318da235233d 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -48,8 +48,6 @@ class Admin_CmsController extends ZendAfi_Controller_Action { protected function _postEditAction($article) { $article->index(); - if($record = $article->getNotice()) - (new Class_WebService_Vignette())->updateUrlsFromCacheServer($record); } @@ -68,6 +66,7 @@ class Admin_CmsController extends ZendAfi_Controller_Action { $ids = array_map(function($model) { return $model->getId(); }, $bibs); $search = $this->_getParam('title_search', ''); + $id_bib = $this->_getParam('id_bib', $this->identity->isRoleLibraryLimited() ? $this->_bib->getId() @@ -98,6 +97,10 @@ class Admin_CmsController extends ZendAfi_Controller_Action { public function indexAction() { $this->view->titre = $this->view->_('Articles'); + if($this->_request->isPost() && ($search=$this->_getParam('title_search'))) { + return $this->_redirectToRefererWithNewParams(['title_search' => $search]); + } + if (Class_AdminVar::isArticlesListMode()) return $this->_renderList(); diff --git a/application/modules/admin/controllers/ModoController.php b/application/modules/admin/controllers/ModoController.php index a553de9ff0e5e637fce202d500decb3c8588c25a..8b7a8c8e0fc370ca24d9e3d98f687f46e8e16dd4 100644 --- a/application/modules/admin/controllers/ModoController.php +++ b/application/modules/admin/controllers/ModoController.php @@ -27,16 +27,64 @@ class Admin_ModoController extends ZendAfi_Controller_Action { public function avisnoticeAction() { + $this->subviewForStatus(0); + $this->_request->setParam('back', 'avisnotice'); + $this->_forward('index'); + + } + - $all_avis = Class_AvisNotice::getLoader()->findAllBy(['statut' => 0,'limit'=>100]); - $all_avis = Class_AvisNotice::sortByDateAvisDesc($all_avis); + public function invisibleavisnoticeAction() { + if (!$review_id=$this->_request->getParam('id',0)) + $this->_forward('index'); - $avis_bib = Class_AvisNotice::filterByBibliothecaire($all_avis); - $avis_abo = Class_AvisNotice::filterByAbonne($all_avis); + $review=Class_AvisNotice::find($review_id); + $review->setFlags(Class_AvisNotice::ARCHIVED_FLAG)->save(); + $this->_stayOnPage(); + } + + + public function visibleavisnoticeAction() { + if (!$review_id=$this->_request->getParam('id',0)) + $this->_forward('index'); + $review=Class_AvisNotice::find($review_id); + $review->setFlags(Class_AvisNotice::NO_FLAG)->save(); + $this->_stayOnPage(); + } + + protected function subviewForStatus($status) { + + $page = $this->_getParam('page',1); + $nb_bib=Class_AvisNotice::countBiblioReviews($status); + $nb_abo=Class_AvisNotice::countAboReviews($status); + $display_per_page=$page*10; + $avis_bib = Class_AvisNotice::findBiblioReviews($status, + [($nb_bib<=$display_per_page)? 1: $page,10]); + + $avis_abo = Class_AvisNotice::findAboReviews($status, + [($nb_abo<=$display_per_page)? 1 : $page,10]); + $nb_orphans=Class_AvisNotice::countOrphanReviews($status); + $nb_archived=Class_AvisNotice::countArchivedReviews($status); + $orphans = Class_AvisNotice::findOrphanReviews($status,[($nb_orphans<=$display_per_page)? 1: $page,10]); + $archived = Class_AvisNotice::findArchivedReviews($status,[($nb_archived<=$display_per_page)? 1: $page,10]); $this->view->subview = $this->view->partial('modo/avisnotice.phtml', ['list_avis_bibliothecaires' => $avis_bib, - 'list_avis_utilisateurs' => $avis_abo]); + 'list_avis_utilisateurs' => $avis_abo, + 'list_orphan_reviews' => $orphans, + 'list_archived_reviews' => $archived, + 'display_all' => $status, + 'nb_bib' => $nb_bib, + 'nb_abo' => $nb_abo, + 'nb_orphans' => $nb_orphans, + 'nb_archived' => $nb_archived, + 'page' => $page +]); + +} + public function allreviewsAction() { + $this->_request->setParam('back', 'avisnotice'); + $this->subviewForStatus(1); $this->_forward('index'); } @@ -44,7 +92,7 @@ class Admin_ModoController extends ZendAfi_Controller_Action { public function delavisnoticeAction() { $id = $this->_request->getParam('id'); Class_AvisNotice::find($id)->delete(); - $this->_redirect('admin/modo/avisnotice'); + $this->_stayOnPage(); } public function editavisnoticeAction() { @@ -77,7 +125,8 @@ class Admin_ModoController extends ZendAfi_Controller_Action { $avis = $this->_setAvisAndEntete($avis, $form); if ($record = $form->url->getRecord()) { - $avis->setClefOeuvre($record->getClefOeuvre())->save(); + + $avis->forceUpdateWithNotice($record)->save(); $this->_helper->notify($this->view->_('Avis rattaché à la notice "%s"', $record->getTitrePrincipal())); } diff --git a/application/modules/admin/controllers/UsersController.php b/application/modules/admin/controllers/UsersController.php index a47b5f01345f81e889f05e7ff97347a2491695f7..9df3a92f021410bb57b44997b780436602deeeef 100644 --- a/application/modules/admin/controllers/UsersController.php +++ b/application/modules/admin/controllers/UsersController.php @@ -172,8 +172,7 @@ class Admin_UsersController extends ZendAfi_Controller_Action { //------------------------------------------------------------------------------------------------------ function editAction() { $id_user = $this->_request->getParam('id',0); - $user = Class_Users::getLoader()->find($id_user); - + $user = Class_Users::find($id_user); $this->view->titre = "Modifier l'utilisateur: ".$user->getLogin(); if ($this->_request->isPost()) diff --git a/application/modules/admin/views/scripts/accueil/sitotheque.phtml b/application/modules/admin/views/scripts/accueil/sitotheque.phtml index 3d3d72d1c5ca7f9c0836f2290d73751b39cced2f..1e275938f040b9e9107d946ad5d5baf6568252c8 100644 --- a/application/modules/admin/views/scripts/accueil/sitotheque.phtml +++ b/application/modules/admin/views/scripts/accueil/sitotheque.phtml @@ -4,12 +4,15 @@ Class_ScriptLoader::getInstance() function toggleDisplayTypeDependents() { var dependents = $(".group_cat, #option_display_order, #option_nb_aff"); ("3" == $("#type_aff").val()) ? dependents.hide() : dependents.show(); + + var recentDependents = $("#option_display_order"); + ("2" == $("#type_aff").val()) ? recentDependents.hide() : recentDependents.show(); + } $("#type_aff").change(function () { toggleDisplayTypeDependents(); var value = $("#type_aff").val(); - $(".treeselect").treeselect("toggleVisibility", (value == "1" || value == "3")); }); toggleDisplayTypeDependents(); @@ -39,6 +42,15 @@ formSelectToggleVisibilityForElement("input[name=display_order]", "#option_nb_af <td class="droite">Titre </td> <td class="gauche"><input type="text" name="titre" size="50" value="<?php print($this->preferences['titre']); ?>"></td> </tr> + <tr> + <td class="droite">Proposer un fil Rss </td> + <td class="gauche"> + <?php echo $this->formCheckbox('rss', + $this->preferences['rss'], + null, + ['1', '0']) ?> + </td> + </tr> </table> </fieldset> <br> @@ -65,7 +77,7 @@ formSelectToggleVisibilityForElement("input[name=display_order]", "#option_nb_af <?php echo $this->treeSelect($this->preferences['id_items'], $this->preferences['id_categorie'], - ($this->preferences['type_aff'] != '2'), + true, BASE_URL . '/admin/bib/allitems?id_bib=' . $this->id_bib . '&type=sito', "form"); ?> diff --git a/application/modules/admin/views/scripts/modo/_avis_partial.phtml b/application/modules/admin/views/scripts/modo/_avis_partial.phtml index 5c62ec2e78c9c948d5b15f2dd01bbfb9548ed157..d62871b971ccfd30203be4720ce61bb401a814fb 100644 --- a/application/modules/admin/views/scripts/modo/_avis_partial.phtml +++ b/application/modules/admin/views/scripts/modo/_avis_partial.phtml @@ -1,4 +1,9 @@ <div class="<?php echo $this->item_class ?>"> + <?php + $actions = ['validate', 'edit', 'del']; + if ($this->avis->getFlags()>=0) + $actions[] = ($this->avis->getFlags()==0) ? 'invisible' :'visible'; + $this->getHelper('avis')->setActions($actions); ?> <?php echo $this->avis($this->avis) ?> <div class='clear'></div> -</div> \ No newline at end of file +</div> diff --git a/application/modules/admin/views/scripts/modo/avisnotice.phtml b/application/modules/admin/views/scripts/modo/avisnotice.phtml index c0cd162c77e71ce0bb572cc29da49069b4b29a1b..31e27bb605d21c2f368cc9e019569db2063bc650 100644 --- a/application/modules/admin/views/scripts/modo/avisnotice.phtml +++ b/application/modules/admin/views/scripts/modo/avisnotice.phtml @@ -1,24 +1,34 @@ -<?php +<?php -echo '<h1>'.$this->traduire('Modération des avis sur les notices').'</h1>'; +if ($this->display_all) { + echo '<h1>'.$this->traduire('Tous les avis de notices modérés').'</h1>'; + echo $this->tagAnchor(['action' => 'avisnotice'],"Afficher les avis non modérés"); +} +if (!$this->display_all) { + echo '<h1>'.$this->traduire('Modération des avis sur les notices').'</h1>'; + echo $this->tagAnchor(['action' => 'allreviews'],"Afficher tous les avis modérés"); +} echo '<div id="avis-notice-liste" >'; -echo $this->avisBloc('Bibliothécaires', $this->list_avis_bibliothecaires); +echo $this->avisBloc('Avis de bibliothécaires ('.$this->nb_bib.')', $this->list_avis_bibliothecaires,$this->page,$this->nb_bib); -echo $this->avisBloc('Abonnés', $this->list_avis_utilisateurs); -echo '</div>'; +echo $this->avisBloc('Avis d\'abonnés ('. $this->nb_abo.')', $this->list_avis_utilisateurs,$this->page,$this->nb_abo); + +echo $this->avisBloc('Avis orphelins ('.$this->nb_orphans.')', $this->list_orphan_reviews,$this->page,$this->nb_orphans); +echo $this->avisBloc('Avis archivés ('.$this->nb_archived.')', $this->list_archived_reviews,$this->page,$this->nb_archived); +echo '</div>'; -?> +?> <script type='text/javascript'> $(document).ready(function() { $('.critique a:not(.actions a)').attr('target', '_blank'); - $('#avis-notice-liste').accordion({heightStyle:'content',disabled:true, icons:null}); - $('#avis-notice-liste .ui-accordion-content').show(); + $('#avis-notice-liste').accordion({heightStyle:'content',collapsible:true,disabled:false}); +// $('#avis-notice-liste .ui-accordion-content').show(); }); </script> diff --git a/application/modules/admin/views/scripts/users/_form.phtml b/application/modules/admin/views/scripts/users/_form.phtml index 90416b49b38dfd094c2da396bdb3cc315bb202bf..221eb51d64f121ae87be3848c18d45c465ea3748 100644 --- a/application/modules/admin/views/scripts/users/_form.phtml +++ b/application/modules/admin/views/scripts/users/_form.phtml @@ -33,7 +33,7 @@ <tr> <td class="droite">Civilité </td> <td class="gauche"> - <?php + <?php echo $this->formSelect('civilite', $this->user->getCivilite(), null, @@ -52,10 +52,22 @@ <td class="droite"><?php echo $this->traduire('Rôle'); ?> </td> <td class="gauche"> <?php $comboListeRole = new ZendAfi_Acl_AdminControllerRoles(); - if ($this->user->getId() == '1') - echo '<select disabled="disabled"><option selected="selected" value="7">super_admin</option></select><input type="hidden" value="7" name="role" id="role"/>'; - else - print $this->user->getRoleLevel() != 2 ? $comboListeRole->rendCombo($this->user->getRole(),$this->authUser->ROLE_LEVEL) : ZendAfi_Acl_AdminControllerRoles::getLibelleRole(2); ; + if ($this->user->isSuperAdmin()) + echo '<select disabled="disabled"><option selected="selected" value="7">super_admin</option></select><input type="hidden" value="' . ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN . '" name="role" id="role"/>'; + else + echo $this->user->isAbonne() + ? ZendAfi_Acl_AdminControllerRoles::getLibelleRole($this->user->getRoleLevel()) + : $comboListeRole->rendCombo($this->user->getRole(), $this->authUser->ROLE_LEVEL); + + + if ($this->user->isAbonne()) + echo $this->tag('input','',['type' =>'hidden', + 'value' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'name' => 'role', + 'id' => 'role']); + + + ?> </td> @@ -64,7 +76,7 @@ <tr> <td class="droite"><?php echo $this->traduire('Groupes'); ?> </td> <td class="gauche"> - <?php + <?php echo $this->getHelper('TreeSelect') ->categoriesNotSelectable() ->treeSelect(implode('-', $this->user->getUserGroupsIds()), @@ -73,7 +85,7 @@ $this->url(['module' => 'admin', 'controller' => 'usergroup', 'action' => 'list.json']), - "form", + "form", "usergroup_categories_ids"); ?> </td> @@ -89,12 +101,12 @@ <input type="hidden" value="'.$this->id_bib.'" name="bib" id="bib"/>'; } else { $bib = new Class_Bib(); - echo $bib->getComboBib($this->user->getIdSite()); + echo $bib->getComboBib($this->user->getIdSite()); } ?> <script type="text/javascript"> formSelectToggleVisibilityForElement("select[name='role']", - "#option_bib", + "#option_bib", ["2", "3", "4"]); formSelectToggleVisibilityForElement("select[name='role']", "#abonne_sigb", "2"); @@ -160,4 +172,3 @@ </table> </form> </div> - diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 0bc78b5d31c4c38d758ebac40d175ffcc2b6e7a5..3a3b4714cac7ee77065f8a6fc4f9fba0d4de1798 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -148,6 +148,7 @@ class AbonneController extends ZendAfi_Controller_Action { ->setAvis($this->_request->getParam('avisTexte')) ->setNote($this->_request->getParam('avisNote')) ->setUser($this->_user) + ->setIdNotice($id_notice) ->setClefOeuvre($notice->getClefOeuvre()) ->setStatut(0); @@ -901,12 +902,16 @@ class AbonneController extends ZendAfi_Controller_Action { $suggestion = $form->newBuySuggest($post); if ($form->isValid($suggestion)) { + + // $suggestion->save(); always return true without considering webservice answers. UX choice ? $suggestion->save(); + try { $suggestion->sendMail('noreply@'.$this->_request->getHttpHost()); } catch (Zend_Mail_Exception $e) { $this->_helper->notify($this->_('Aucun courriel envoyé, erreur: ').$this->_($e->getMessage())); } + $this->_helper->notify($this->_('Suggestion d\'achat enregistrée')); $this->_redirect('/opac/abonne/suggestion-achat'); } @@ -923,7 +928,7 @@ class AbonneController extends ZendAfi_Controller_Action { return; } } - + public function suggestionAchatInactiveAction() {} diff --git a/application/modules/opac/controllers/BibNumeriqueController.php b/application/modules/opac/controllers/BibNumeriqueController.php index b9c837e88eafffd9c01061b10f1a60970421c606..cfcf36dbc56db9b4b7855a7b461679791f910471 100644 --- a/application/modules/opac/controllers/BibNumeriqueController.php +++ b/application/modules/opac/controllers/BibNumeriqueController.php @@ -255,11 +255,6 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { } - public function consultBookAjaxAction() { - if (!$this->_redirectToLogin()) - $this->_redirect($this->view->url(['action' => 'consult-book', 'render' =>null]), - ['prependBase' => false]); - } protected function _redirectToLogin() { if (!$this->_user = Class_Users::getLoader()->getIdentity()) { @@ -270,11 +265,100 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { } + protected function _redirectToPopupLogin($url) { + if (!$this->_user = Class_Users::getLoader()->getIdentity()) { + $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $url]); + return true; + } + return false; + } + + + protected function _userShouldBeRedirect() { + if($this->_redirectToPopupLogin($this->view->url())) + return true; + + if (!$this->_user->hasRightAccessDilicom()) + return $this->_ajaxRedirectToNotice(); + + if(!$this->view->album = Class_Album::find($this->_getParam('id'))) + return $this->_ajaxRedirectToNotice(); + + return false; + } + + public function loanBookAjaxAction() { - if ($this->_redirectToLogin()) - return ; - $this->_redirect($this->view->url(['action' => 'loan-book', 'render' => null]), ['prependBase' => false]); - return true; + if($this->_userShouldBeRedirect()) + return; + + return $this->renderPopupResult($this->_('Emprunter le livre au format EPUB'), + $this->view->render('bib-numerique/loan-book.phtml')); + } + + + public function consultBookAjaxAction() { + if($this->_userShouldBeRedirect()) + return; + + return $this->renderPopupResult($this->_('Consulter le livre en ligne'), + $this->view->render('bib-numerique/consult-book.phtml')); + } + + + public function consultBookOpenAjaxAction() { + if($this->_userShouldBeRedirect()) + return; + + $client_ip = (new Class_RemoteClient($this->_request))->getIpAddress(); + $response = (new Class_WebService_BibNumerique_Dilicom_Hub())->consultBook($this->view->album, + $client_ip, + $this->_user); + + return $this->_withContentDo(json_decode($response), + function($url) + { + $this->view->open_url = $url; + $this->renderPopupResult($this->_('Consultation'), + $this->view->render('bib-numerique/consult-book-open.phtml')); + }); + } + + + protected function _withContentDo($content, $closure) { + if(!$content) + return $this->_ajaxRedirectToNotice(); + + if ($content->returnMessage) { + $this->_helper->notify(implode(',', $content->returnMessage)); + return $this->_ajaxRedirectToNotice(); + } + + $closure($content->link->url); + } + + + public function downloadLoanBookAjaxAction() { + if($this->_userShouldBeRedirect()) + return; + + $content = (new Class_WebService_BibNumerique_Dilicom_Hub())->loanBook(Class_Album::find($this->_getParam('id'))); + + + return $this->_withContentDo($content, + function($url) + { + $this->view->download_url = $url; + $this->renderPopupResult($this->_('Téléchargement'), $this->view->render('bib-numerique/download-book.phtml')); + }); + } + + + protected function _ajaxRedirectToNotice() { + $this->view->redirect_url = $this->view->url(['controller' => 'recherche', + 'action' => 'viewnotice', + 'render' => 'false']); + return $this->renderPopupResult('', $this->view->render('bib-numerique/redirect.phtml')); } @@ -293,8 +377,7 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { $content = json_decode($response); if ($content->returnMessage) { $this->_helper->notify(implode(',', $content->returnMessage)); - $this->_redirectToNotice(); - return; + return $this->_redirectToNotice(); } $this->_redirect($content->link->url); diff --git a/application/modules/opac/controllers/BlogController.php b/application/modules/opac/controllers/BlogController.php index f54b71d4b7d75b836bf653f6ae4d8dc1c6deec7d..70b7d0a358d16a4e1a54afff318ffb9477bf580c 100644 --- a/application/modules/opac/controllers/BlogController.php +++ b/application/modules/opac/controllers/BlogController.php @@ -80,6 +80,7 @@ class BlogController extends ZendAfi_Controller_Action { public function lastcritiqueAction() { $nb_avis = (int)$this->_getParam('nb', 20); $liste_avis = Class_AvisNotice::findAllBy(['order' => 'date_avis desc', + 'flags' => Class_AvisNotice::NO_FLAG, 'limit' => $nb_avis]); $this->view->nb_aff = $nb_avis; diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index a682560e6a7ebd4a97394f7fb0e71cdc3d29efc0..cb1dcf37597122b38a2add249cae0ffcbb14af57 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -84,21 +84,7 @@ class CmsController extends ZendAfi_Controller_Action { public function calendarrssAction() { $id_profil = (int)$this->_getParam('id_profil'); $id_module = (int)$this->_getParam('id_module'); - $profil = Class_Profil::find($id_profil); - - $preferences = $profil->getModuleAccueilPreferences($id_module, 'NEWS'); - $articles=Class_Calendar::getAllNextEvents($id_module,$profil); - - $data_rss = [ - 'title' => trim($preferences['titre']) ? trim($preferences['titre']) : $profil->getLibelle(), - 'link' => $profil->urlForModule('cms', 'articleviewbydate', $id_module), - 'charset' => 'utf-8', - 'description' => 'Agenda: ' . $preferences['titre'], - 'lastUpdate' => time() - ]; - - $this->_renderRSS($articles, $data_rss); - + $this->_helper->renderRss($id_profil, $id_module, $this->view, 'NEWS'); } @@ -161,44 +147,18 @@ class CmsController extends ZendAfi_Controller_Action { } + public function reseauAction() { $this->view->article = Class_Article::getLoader() ->find((int)$this->_getParam('id_article')); $this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml'); } + public function rssAction(){ $id_profil = (int)$this->_getParam('id_profil'); $id_module = (int)$this->_getParam('id_module'); - - $articles = []; - - $data_rss = [ - 'title' => 'Flux indisponible', - 'link' => $this->_request->getScheme() . '://' - . $this->_request->getServer('HTTP_HOST'), - 'charset' => 'utf-8', - 'description' => '', - 'lastUpdate' => time() - ]; - - if (null != ($profil = Class_Profil::find($id_profil))) { - $preferences = $profil->getModuleAccueilPreferences($id_module, 'NEWS'); - - $data_rss = array_merge( - $data_rss, - [ - 'title' => $preferences['titre'], - 'link' => $profil->urlForModule('cms', 'viewselection', $id_module), - 'description' => 'Articles: '.$preferences['titre'] - ] - ); - - $articles = Class_Article::getArticlesByPreferences($preferences); - $articles = Class_Article::filterByLocaleAndWorkflow($articles); - } - - $this->_renderRSS($articles, $data_rss); + $this->_helper->renderRss($id_profil, $id_module, $this->view, 'ARTICLE'); } @@ -307,46 +267,6 @@ class CmsController extends ZendAfi_Controller_Action { $this->view->param = $param; } - - /** - * @param array $article - */ - protected function _getPubDate($article) { - if ($article->hasEventsDebut()) - return $article->getEventsDebut(); - - if ($article->hasDebut()) - return $article->getDebut(); - - return $article->getDateMaj(); - } - - /** - * @param array $articles - * @param array $rss_array - */ - private function _renderRSS($articles, $rss_array) { - $entries = []; - foreach ($articles as $article) { - $entries[] = - [ - 'title' => html_entity_decode($article->getTitre()), - 'link' => $this->_request->getScheme() . '://' - . $this->_request->getServer('HTTP_HOST') - . $this->view->url($article->getUrl()), - 'lastUpdate' => strtotime($this->_getPubDate($article)), - 'description' => html_entity_decode(Class_CmsUrlTransformer::imgUrlRelativeToAbsolute($this->view->tagArticleEvent($article).$article->getFullContent()))]; - } - - $rss_array['entries'] = $entries; - - $feed = Zend_Feed::importArray($rss_array, 'rss'); - - $this->getHelper('ViewRenderer')->setNoRender(); - $this->_response->setHeader('Content-Type', 'application/rss+xml;charset=utf-8') ; - $this->_response->setBody($feed->saveXML()); - } - /** * @param int $id_module * @param int $id_profil diff --git a/application/modules/opac/controllers/RssController.php b/application/modules/opac/controllers/RssController.php index 8efa311b86388edd2beb5c780cc7446680ccd99a..3ddbb1cd58be55ca156961e3452385b796ff4328 100644 --- a/application/modules/opac/controllers/RssController.php +++ b/application/modules/opac/controllers/RssController.php @@ -301,10 +301,11 @@ class RssController extends Zend_Controller_Action $avis_helper = $this->view->getHelper('Avis'); - $items = array(); + $items = []; foreach($user_avis as $avis) { $desc = $avis_helper->avis($avis, 0, $vignette_link_to_avis = true); - + if ($desc=='') + continue; $items [] = ['titre' => $avis->getEntete(), 'lien' => $this->view->absoluteUrl([ 'controller' => 'blog', diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index e10c79e9ddcd91a5c6cff4890a135b19f6e2a0e4..a6edf0648e429eaaab409628d98b27431319d0ec 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -38,14 +38,15 @@ class SitoController extends Zend_Controller_Action { public function viewrecentAction() { - $class_sito = new Class_Sitotheque(); - $nb_sito = (int)$this->_request->getParam('nb', 10); - $limit = ($nb_sito < 1) ? 10 : $nb_sito; - - $sites = Class_Sitotheque::findAllBy(['order' => 'date_maj desc', - 'limit' => $limit]); - $this->view->sitos = $sites; - $this->view->title = $this->view->_('Derniers Sites'); + $id_category = $this->_getParam('id_cat'); + $id_items = $this->_getParam('id', $this->_getParam('id_items')); + $limit = (int)$this->_request->getParam('nb', 10); + + $this->view->title = $id_category + ? $this->view->_('Derniers Sites de catégorie') + : $this->view->_('Derniers Sites'); + + $this->view->sitos = Class_Sitotheque::getLastSitos($id_category, $id_items, $limit); $this->renderScript('sito/viewsitos.phtml'); } @@ -86,4 +87,12 @@ class SitoController extends Zend_Controller_Action { $webThumbnail = new Class_WebService_WebSiteThumbnail(); $this->_redirect($webThumbnail->fetchFullUrl($url)); } + + + public function sitoRssAction() { + $id_profil = (int)$this->_getParam('id_profil'); + $id_module = (int)$this->_getParam('id_module'); + + $this->_helper->renderRss($id_profil, $id_module, $this->view, 'SITO'); + } } \ No newline at end of file diff --git a/application/modules/opac/views/scripts/bib-numerique/consult-book-open.phtml b/application/modules/opac/views/scripts/bib-numerique/consult-book-open.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ff9035862f5c5ca75bfb5e79d0cd8bb9ab9e2be6 --- /dev/null +++ b/application/modules/opac/views/scripts/bib-numerique/consult-book-open.phtml @@ -0,0 +1,8 @@ +<?php +echo '<div class="popup-content">'; +echo $this->tagAnchor($this->open_url, $this->_('Lire en ligne'), + ['target' => '_blank', + 'class' => 'button blue', + 'onclick' => 'opacDialogClose();']); +echo '</div>'; +?> diff --git a/application/modules/opac/views/scripts/bib-numerique/consult-book.phtml b/application/modules/opac/views/scripts/bib-numerique/consult-book.phtml new file mode 100644 index 0000000000000000000000000000000000000000..4d78b81e8719240168449d6ec9326c65012b3c23 --- /dev/null +++ b/application/modules/opac/views/scripts/bib-numerique/consult-book.phtml @@ -0,0 +1,9 @@ +<?php +echo '<div class="popup-content">'; +echo $this->tag('p', $this->_('Êtes vous sûr de vouloir consulter ce document ?')); +echo $this->tagAnchor($this->url(['action' => 'consult-book-open-ajax']), $this->_('oui'), ['data-popup' => 'true', + 'class' => 'button blue']); +echo $this->tagAnchor('', $this->_('non'), ['onclick' => 'opacDialogClose();return false', + 'class' => 'button red']); +echo '</div>'; +?> diff --git a/application/modules/opac/views/scripts/bib-numerique/download-book.phtml b/application/modules/opac/views/scripts/bib-numerique/download-book.phtml new file mode 100644 index 0000000000000000000000000000000000000000..a3f9ff0756eeac4493413c4590b98d734e36b0d9 --- /dev/null +++ b/application/modules/opac/views/scripts/bib-numerique/download-book.phtml @@ -0,0 +1,7 @@ +<?php +echo '<div class="popup-content">'; +echo $this->tagAnchor( $this->download_url, $this->_('Télécharger'), + ['class' => 'button blue', + 'onclick' => 'opacDialogClose();']); +echo '</div>'; +?> diff --git a/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml new file mode 100644 index 0000000000000000000000000000000000000000..094af95173656a593f2f3b5c40de5de29d931661 --- /dev/null +++ b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml @@ -0,0 +1,10 @@ +<?php +echo '<div class="popup-content">'; +echo $this->tag('p', $this->_('Êtes vous sûr de vouloir emprunter ce document ?')); +echo $this->tagAnchor($this->url(['action' => 'download-loan-book-ajax']), $this->_('oui'), ['data-popup' => 'true', + 'class' => 'button blue']); +echo $this->tagAnchor('', $this->_('non'), ['onclick' => 'opacDialogClose();return false', + 'class' => 'button red']); +echo $this->tag('p', Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE')); +echo '</div>'; +?> diff --git a/application/modules/opac/views/scripts/bib-numerique/redirect.phtml b/application/modules/opac/views/scripts/bib-numerique/redirect.phtml new file mode 100644 index 0000000000000000000000000000000000000000..62d794befca20953b0df4fb78e1ddd8f0d199d03 --- /dev/null +++ b/application/modules/opac/views/scripts/bib-numerique/redirect.phtml @@ -0,0 +1,4 @@ +<?php +echo $this->tag('script', 'window.open("'.$this->redirect_url.'")'); +echo $this->tag('script', 'opacDialogClose();'); +?> diff --git a/application/modules/opac/views/scripts/help/cookies.phtml b/application/modules/opac/views/scripts/help/cookies.phtml index 81fe0d8f1f4199c2d82ca8c25a5b8a59daf740cb..8d02f26d6056b8642e29ee68c94a0639785c85ed 100644 --- a/application/modules/opac/views/scripts/help/cookies.phtml +++ b/application/modules/opac/views/scripts/help/cookies.phtml @@ -1,15 +1,15 @@ -<h3>Qu'est-ce qu'un cookie ?</h3> +<h3><?php echo $this->_('Qu\'est-ce qu\'un cookie ?');?></h3> -<p>Un cookie est un fichier texte déposé, sous réserve de vos choix, sur votre ordinateur lors de la visite d'un site ou de la consultation d'une publicité. Il a pour but de collecter des informations relatives à votre navigation et de vous adresser des services adaptés à votre terminal (ordinateur, mobile ou tablette). +<p><?php echo $this->_('Un cookie est un fichier texte déposé, sous réserve de vos choix, sur votre ordinateur lors de la visite d\'un site ou de la consultation d\'une publicité. Il a pour but de collecter des informations relatives à votre navigation et de vous adresser des services adaptés à votre terminal (ordinateur, mobile ou tablette).');?> -Les cookies sont gérés par votre navigateur internet et seul l’émetteur d’un cookie est susceptible de lire ou de modifier les informations qui y sont contenues.</p> +<?php echo $this->_('Les cookies sont gérés par votre navigateur internet et seul l’émetteur d’un cookie est susceptible de lire ou de modifier les informations qui y sont contenues.');?></p> -<h3>A quoi servent les cookies émis sur notre site ?</h3> +<h3><?php echo $this->_('A quoi servent les cookies émis sur notre site ?');?></h3> -<p>Nous utilisons uniquement des cookies visant à faciliter votre navigation. Il s'agit notamment des cookies suivants: +<p><?php echo $this->_('Nous utilisons uniquement des cookies visant à faciliter votre navigation. Il s\'agit notamment des cookies suivants:');?> <ul> - <li>les cookies de session utilisés pour le maintient de l'authentification.</li> - <li>les cookies permettent d'identifier les services et rubriques que l'utilisateur a visités.</li> + <li><?php echo $this->_('les cookies de session utilisés pour le maintien de l\'authentification.');?></li> + <li><?php echo $this->_('les cookies permettent d\'identifier les services et rubriques que l\'utilisateur a visités.');?></li> </ul> <?php echo $this->ga_warning; ?> diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index be2ef739eee24891c8cef369a41446d2ad502115..b0acbffe11461fbbf61ced979e348dc8cd37be0f 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -36,14 +36,10 @@ if ($this->is_pertinence) { echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlRetourRechercheInitiale(), null, true), $this->_('Retour à la recherche initiale'));?> </span> - <span> <?php echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlNouvelleRecherche(), null, true), $this->_('Nouvelle recherche')); ?> </span> - - - <?php if ((int)$preferences['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled()) echo $this->tag('span', @@ -51,13 +47,13 @@ if ($this->is_pertinence) { 'action' => 'suggestion-achat'], $this->_('Suggérer un achat'))); ?> - <span class="print"> <?php echo $this->tagPrintLink($this->search_result->fetchRecords(), 'Notice_List'); ?> </span> </div> + <?php echo $this->tagSearchExtension($this->criteres_recherche); ?> </div> <?php diff --git a/ckeditor/core_five_filemanager/connectors/php/filemanager.php b/ckeditor/core_five_filemanager/connectors/php/filemanager.php index 482c7ca1a7291fd715cd69129990f8e2716bd2d8..efe4f4b5ca4c816e7876cfa9607d2e5851f7436e 100644 --- a/ckeditor/core_five_filemanager/connectors/php/filemanager.php +++ b/ckeditor/core_five_filemanager/connectors/php/filemanager.php @@ -24,18 +24,14 @@ header('Content-type: application/json'); * @param string $path */ function opacTraversalProtect ($path) { - $path = (string)$path; - $parts = explode('/', $path); - array_shift($parts); - if (2 > count($parts)) { - exit(); - } - if ('userfiles' != $parts[1]) { - exit(); - } - if (in_array('..', $parts)) { - exit(); - } + $path = (string)$path; + $parts = explode('/', $path); + array_shift($parts); + + if (in_array('..', $parts) + || 2 > count($parts) + || !in_array('userfiles', $parts)) + exit(); } @@ -64,7 +60,7 @@ if(!isset($_GET)) { } else { if(isset($_GET['mode']) && $_GET['mode']!='') { switch($_GET['mode']) { - + default: opacTraversalProtect($_GET['path']); $fm->error($fm->lang('MODE_ERROR')); @@ -78,7 +74,7 @@ if(!isset($_GET)) { break; case 'getfolder': - opacTraversalProtect($_GET['path']); + opacTraversalProtect($_GET['path']); if($fm->getvar('path')) { $response = $fm->getfolder(); } @@ -121,12 +117,12 @@ if(!isset($_GET)) { } else if(isset($_POST['mode']) && $_POST['mode']!='') { switch($_POST['mode']) { - + default: $fm->error($fm->lang('MODE_ERROR')); break; - + case 'add': if($fm->postvar('currentpath')) { opacTraversalProtect($_POST['currentpath']); diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 108498e35dacaf9d8db111ed839fcc4d36c2348f..6bf6f9b5653243208920ab0509930fc31376d559 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -2,7 +2,7 @@ error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","272"); +define("PATCH_LEVEL","276"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/php/classes/classe_http_request.php b/cosmogramme/php/classes/classe_http_request.php index d5efa92e1e7de4c7f8f500b84bcdad978de3160c..bfd1c8b7c50c6c26a8f0e76b8ed0ece469214aa7 100644 --- a/cosmogramme/php/classes/classe_http_request.php +++ b/cosmogramme/php/classes/classe_http_request.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 */ ////////////////////////////////////////////////////////////////////////////////////////// // RECUPERE LE CONTENU D'UNE URL @@ -31,7 +31,7 @@ class HTTPRequest private $_port; // port private $proxy; // Param�tres de connexion proxy private $header; // Header de retour - + // constructor function __construct($url) { @@ -40,30 +40,30 @@ class HTTPRequest $this->proxy["port"]=$cfg["PROXY_PORT"]; $this->proxy["user"]=$cfg["PROXY_USER"]; $this->proxy["passe"]=$cfg["PROXY_PASSE"]; - + $this->_url = $url; if((strScan(strtoupper($url),"LOCALHOST",0)>0) or (strScan($url,"127.0.0.1",0)>0)) unset($this->proxy); $this->_scan_url(); } - + // scan url function _scan_url() { - $req = $this->_url; + $req = $this->_url; $pos = strpos($req, '://'); $this->_protocol = strtolower(substr($req, 0, $pos)); - + $req = substr($req, $pos+3); $pos = strpos($req, '/'); if($pos === false) $pos = strlen($req); $host = substr($req, 0, $pos); - + if(strpos($host, ':') !== false) { list($this->_host, $this->_port) = explode(':', $host); } - else + else { $this->_host = $host; $this->_port = ($this->_protocol == 'https') ? 443 : 80; @@ -75,7 +75,7 @@ class HTTPRequest if($this->_uri == '') $this->_uri = '/'; } } - + // download URL to string function DownloadToString() { @@ -92,10 +92,10 @@ class HTTPRequest $req.='Content-type: text/html; charset=ISO-8859-1'.$crlf; $req.=$crlf; - - + + // print($req); exit; - + // open if($this->proxy["host"]) $fp = @fsockopen( $this->proxy["host"], $this->proxy["port"]); else $fp = @fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port); @@ -104,14 +104,14 @@ class HTTPRequest // get data while(is_resource($fp) && $fp && !feof($fp)) $response .= fread($fp, 512); fclose($fp); - + // split header and body $pos = strpos($response, $crlf . $crlf); if($pos === false) return($response); $header = substr($response, 0, $pos);$this->header=$header; $body = substr($response, $pos + 2 * strlen($crlf)); - + // parse headers $headers = array(); $lines = explode($crlf, $header); @@ -124,10 +124,9 @@ class HTTPRequest $http = new HTTPRequest($headers['location']); return($http->DownloadToString($http)); } - else + else { return($body); } } -} -?> +} \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_indexation.php b/cosmogramme/php/classes/classe_indexation.php index c340edaaea13d528dfb96521192569d5e18c8e52..dde19fe198ac13e7993f3b55e2da822a5440a76d 100644 --- a/cosmogramme/php/classes/classe_indexation.php +++ b/cosmogramme/php/classes/classe_indexation.php @@ -22,23 +22,10 @@ class indexation extends Class_Indexation { protected static $phonetixCache = []; - public function __construct() { - if (empty(static::$phonetixCache)) - static::$phonetixCache = unserialize(file_get_contents(dirname(__FILE__).'/phonetix.txt')); - parent::__construct(); - } - - - function phonetix($sIn) { + public function phonetix($sIn) { if (strlen($sIn)<4 || is_numeric($sIn)) return false; - /* if (count(static::$phonetixCache) > 60000) { */ - /* ksort(static::$phonetixCache); */ - /* file_put_contents('/tmp/phonetix.txt', serialize(static::$phonetixCache)); */ - /* exit; */ - /* } */ - return isset(static::$phonetixCache[$sIn]) ? static::$phonetixCache[$sIn] : static::$phonetixCache[$sIn] = $this->phonetixCompute($sIn); diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index aed9609ac8f23eca8c6488e3ad81815859f09875..5f369c6f244c4e5007cbbe0d6e54ef2c1ac8b356 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -19,12 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once("Class/Isbn.php"); -require_once("classe_indexation.php"); -require_once("classe_unimarc.php"); -require_once("classe_codif_matiere.php"); -require_once("classe_codif_langue.php"); -require_once("classe_profil_donnees.php"); +require_once 'Class/Isbn.php'; +require_once 'classe_indexation.php'; +require_once 'classe_unimarc.php'; +require_once 'classe_codif_matiere.php'; +require_once 'classe_codif_langue.php'; +require_once 'classe_profil_donnees.php'; +require_once 'classe_communication.php'; class notice_integration { const @@ -72,11 +73,13 @@ class notice_integration { /** @category testing */ protected $_service_runner; + protected $_codif_provider; + public function __construct() { - $this->indexation=new indexation(); + $this->indexation = indexation::getInstance(); $this->filtrer_fulltext = Class_CosmoVar::get("filtrer_fulltext"); $this->mode_doublon = Class_CosmoVar::get("mode_doublon"); - $this->notice_sgbd=new notice_unimarc(); + $this->notice_sgbd = new notice_unimarc(); } @@ -146,7 +149,7 @@ class notice_integration { global $sql; $id_bib=$this->id_bib; if(! $this->analyseur ) return false; - $this->statut=0; + $this->statut = static::RECORD_REJECT; $this->erreur=""; unset($this->notice); @@ -169,7 +172,7 @@ class notice_integration { // Traiter le type d'operation : suppressions if($this->type_operation == 1) { - $this->statut=2; + $this->statut = static::RECORD_DELETE; if($this->format == 0 )$this->supprimerNotice($id_notice,$this->notice["id_origine"]); else $this->supprimerExemplaire($id_notice,$this->notice["exemplaires"][0]); return; @@ -177,7 +180,7 @@ class notice_integration { // Notice a supprimer if($this->notice["statut"]==1) { - $this->statut=2; + $this->statut = static::RECORD_DELETE; $this->supprimerNotice($id_notice,$this->notice["id_origine"]); return; } @@ -236,7 +239,7 @@ class notice_integration { $this->notice["qualite"]=$this->qualite_bib; $id_notice=$this->insertNotice(); if(!$id_notice) return; - else $this->statut=1; + else $this->statut = static::RECORD_INSERT; } else { $this->updateNoticeWithId($id_notice); @@ -501,7 +504,7 @@ class notice_integration { private function insertNotice() { if(!$this->notice["statut_exemplaires"]["nb_ex"]) { $this->erreur = "notice sans exemplaire"; - $this->statut = 0; + $this->statut = static::RECORD_REJECT; return false; } @@ -514,12 +517,12 @@ class notice_integration { 'data' => serialize($this->notice)]) ->save(); - $this->statut=7; + $this->statut = static::RECORD_SUCCINCT; return false; } if($this->format == 0 or $this->format==10) $this->erreur="pas de titre principal"; else $this->erreur="Aucun identifiant valide"; - $this->statut=0; + $this->statut = static::RECORD_REJECT; return false; } @@ -528,43 +531,84 @@ class notice_integration { $notice = Class_Notice::newInstance($this->noticeToDBEnreg()); $notice->save(); - $this->statut=1; + $this->statut = static::RECORD_INSERT; return $notice->getId(); } public function noticeToDBEnreg() { - return [ - "type_doc" => $this->notice["type_doc"], - "alpha_titre" => $this->notice["alpha_titre"], - "alpha_auteur" => $this->notice["alpha_auteur"], - - "titres" => $this->indexation->getfullText(array_merge($this->notice["titres"], - [$this->notice["clef_chapeau"], - $this->notice["tome_alpha"]])), - - "auteurs" => $this->indexation->getfullText( $this->notice["auteurs"] - ? array_merge($this->notice["auteurs"],$this->notice["auteurs_renvois"]) - : $this->notice["200_f"]), - - "editeur" => $this->indexation->getfullText($this->notice["editeur"]), - "collection" => $this->indexation->getfullText($this->notice["collection"]), - "matieres" => $this->indexation->getfullText(array_merge($this->notice["matieres"],$this->notice["matieres_renvois"])), - "dewey" => $this->indexation->getfullText($this->notice["full_dewey"]), - "facettes" => $this->notice["facettes"], - "isbn" => $this->notice["isbn"], - "ean" => $this->notice["ean"], - "id_commerciale" => $this->notice["id_commerciale"], - "clef_alpha" => $this->notice["clef_alpha"], - "clef_chapeau" => $this->notice["clef_chapeau"], - "clef_oeuvre" => $this->notice["clef_oeuvre"], - "tome_alpha" => $this->notice["tome_alpha"], - "annee" => $this->notice["annee"], - "qualite" => $this->notice["qualite"], - "exportable" => $this->notice["exportable"], - "cote" => $this->notice["cote"], - "unimarc" => $this->notice['unimarc'], - "date_maj" => dateDuJour(2) ]; + return ["type_doc" => $this->notice["type_doc"], + "alpha_titre" => $this->notice["alpha_titre"], + "alpha_auteur" => $this->notice["alpha_auteur"], + + "titres" => $this->indexation->getfullText(array_merge($this->notice["titres"], + [$this->notice["clef_chapeau"], + $this->notice["tome_alpha"]])), + + "auteurs" => $this->indexation->getfullText($this->_getFulltextAuthors()), + + "editeur" => $this->indexation->getfullText($this->notice["editeur"]), + "collection" => $this->indexation->getfullText($this->notice["collection"]), + "matieres" => $this->indexation->getfullText($this->_getFulltextTopics()), + "dewey" => $this->indexation->getfullText($this->notice["full_dewey"]), + "facettes" => $this->notice["facettes"], + "isbn" => $this->notice["isbn"], + "ean" => $this->notice["ean"], + "id_commerciale" => $this->notice["id_commerciale"], + "clef_alpha" => $this->notice["clef_alpha"], + "clef_chapeau" => $this->notice["clef_chapeau"], + "clef_oeuvre" => $this->notice["clef_oeuvre"], + "tome_alpha" => $this->notice["tome_alpha"], + "annee" => $this->notice["annee"], + "qualite" => $this->notice["qualite"], + "exportable" => $this->notice["exportable"], + "cote" => $this->notice["cote"], + "unimarc" => $this->notice['unimarc'], + "date_maj" => dateDuJour(2) ]; + } + + + protected function _getFulltextAuthors() { + if (!$this->notice['auteurs']) + return $this->notice["200_f"]; + + return array_merge($this->notice["auteurs"], + $this->notice["auteurs_renvois"], + $this->_getCodifAuteurRenvois()); + } + + + protected function _getCodifAuteurRenvois() { + $see_also = []; + foreach($this->notice['auteurs'] as $author) { + if (($codif = $this->_getCodifAuteur($author)) + && $codif->hasMotsRenvois()) + $see_also[] = $codif->getMotsRenvois(); + } + + return $see_also; + } + + + protected function _getFulltextTopics() { + if (!$this->notice['matieres']) + return ; + + return array_merge($this->notice["matieres"], + $this->notice["matieres_renvois"], + $this->_getCodifTopicsRenvois()); + } + + + protected function _getCodifTopicsRenvois() { + $see_also = []; + + foreach($this->notice['matieres'] as $topic) { + if (($codif = $this->_getCodifTopic($topic)) + && $codif->hasMotsRenvois()) + $see_also[] = $codif->getMotsRenvois(); + } + return $see_also; } @@ -658,29 +702,29 @@ class notice_integration { foreach($valeurs as $valeur) $this->notice_sgbd->add_zone($zone,$valeur); - $this->statut = 3; + $this->statut = static::RECORD_FULLUPDATE; } // -------------------------------------------------------------------------------- // Suppression de notice (ne supprime pas l'enreg notice) // -------------------------------------------------------------------------------- - private function supprimerNotice($id_notice,$id_origine) - { - global $sql; - $id_bib=$this->id_bib; - if(!$id_notice) - { - // On cherche par id_origine - if($id_origine) $id_notice=$sql->fetchOne("select id_notice from exemplaires where id_origine='$id_origine'and id_bib=$id_bib"); - if(!$id_notice) - { - $this->statut=0; - $this->erreur="notice à supprimer non reconnue"; - return false; + private function supprimerNotice($id_notice,$id_origine) { + foreach (['id_notice' => $id_notice, + 'id_origine' => $id_origine] as $key => $value) { + + if ($exemplaires = Class_Exemplaire::findAllBy([$key => $value, + 'id_bib' => $this->id_bib])) { + foreach ($exemplaires as $exemplaire) + $exemplaire->delete(); + + return; } } - $sql->execute( "delete from exemplaires where id_notice=$id_notice and id_bib=$id_bib"); + + $this->statut = static::RECORD_REJECT; + $this->erreur="notice à supprimer non reconnue"; + return false; } @@ -731,7 +775,7 @@ class notice_integration { public function supprimerExemplaire($id_notice,$ex) { if(!$id_notice) { - $this->statut=0; + $this->statut = static::RECORD_REJECT; $this->erreur="notice de l'exemplaire à supprimer non trouvée"; return false; } @@ -740,7 +784,7 @@ class notice_integration { 'id_int_bib' => $this->id_int_bib, 'code_barres' => $ex['code_barres']]); if(!$exemplaires) { - $this->statut=0; + $this->statut = static::RECORD_REJECT; $this->erreur="code-barres à supprimer non trouvé"; return false; } @@ -832,18 +876,8 @@ class notice_integration { // Matieres if($this->notice["matieres"]) { foreach($this->notice["matieres"] as $matiere) { - // limit to the maximum size of code_alpha column in db to avoid duplicates - $code_alpha = substr($this->indexation->alphaMaj($matiere), 0, 255); - if(!$code_alpha) continue; - - if (!$codif_matiere = Class_CodifMatiere::findFirstBy(['code_alpha' => $code_alpha])) { - $codif_matiere = Class_CodifMatiere::newInstance(['libelle' => $matiere, - 'code_alpha' => $code_alpha]); - $codif_matiere->save(); - } - - $id_matiere = $codif_matiere->getId(); - $facettes[]="M".$id_matiere; + if (!$codif_matiere = $this->_getCodifTopic($matiere)) continue; + $facettes[]="M".$codif_matiere->getId(); } } @@ -897,24 +931,21 @@ class notice_integration { public function getFacetteAuteur($auteur) { - $code_alpha = $this->indexation->alphaMaj($auteur); - if (!$code_alpha = str_replace(" ","x",$code_alpha)) - return; + return ($codif = $this->_getCodifAuteur($auteur)) + ? 'A' . $codif->getId() : ''; + } - if (!$codif_auteur = Class_CodifAuteur::findByCodeAlpha($code_alpha)) { - $nom_prenom = (-1 < $pos=strscan($auteur,"|")) - ? trim(substr($auteur,($pos+1))." ".substr($auteur,0,$pos)) - : $auteur; - $codif_auteur = Class_CodifAuteur::newInstance() - ->setLibelle($nom_prenom) - ->setFormes($code_alpha); - $codif_auteur->save(); - } + protected function _getCodifAuteur($auteur) { + return $this->getCodifProvider()->getAuthor($auteur); + } + - return 'A'.$codif_auteur->getId(); + protected function _getCodifTopic($topic) { + return $this->getCodifProvider()->getTopic($topic); } + // -------------------------------------------------------------------------------- // Ecrit une notice : article de périodique // -------------------------------------------------------------------------------- @@ -988,7 +1019,7 @@ class notice_integration { $controle = $sql->execute("delete from notices_articles where clef_chapeau='$clef_chapeau' and clef_numero='$clef_numero' and clef_article='$clef_article'" ); if(!$controle) { - $this->statut = 0; + $this->statut = static::RECORD_REJECT; $this->erreur = "notice à supprimer non reconnue"; } } @@ -1347,18 +1378,44 @@ class notice_integration { } - /** @category testing */ - public function getServiceRunner() { - if (null != $this->_service_runner) - return $this->_service_runner; - return new Service_Runner(); + protected function getServiceRunner() { + return null != $this->_service_runner + ? $this->_service_runner : new Service_Runner(); } + /** @category testing */ public function setServiceRunner($runner) { $this->_service_runner = $runner; return $this; } + + + + public function getStatut() { + return $this->statut; + } + + + protected function getCodifProvider() { + if (null == $this->_codif_provider) + $this->_codif_provider = (new Class_Cosmogramme_Integration_CodifProvider) + ->setIndexation($this->indexation); + + return $this->_codif_provider; + } + + + protected function _isIncremental() { + return Class_Cosmogramme_Integration::TYPE_OPERATION_INCREMENT == $this->type_operation; + } + + + /** @category testing */ + public function setCodifProvider($provider) { + $this->_codif_provider = $provider; + return $this; + } } @@ -1366,6 +1423,4 @@ class Service_Runner { public function run($type, $args) { return communication::runService($type, $args); } -} - -?> +} \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index cafc31c55cfdd06d008e02f995c940233f234bd7..abeed734b48c4517d52499d60201586df3f5f563 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -45,7 +45,7 @@ class notice_unimarc extends iso2709_record { public function __construct() { $this->profil_unimarc = new profil_donnees(); - $this->indexation = new indexation(); + $this->indexation = indexation::getInstance(); $data = getVariable('non_exportable'); $this->copyright = explode(';', $data); $this->controle_codes_barres = getVariable('controle_codes_barres'); diff --git a/cosmogramme/php/fonctions/objets_saisie.php b/cosmogramme/php/fonctions/objets_saisie.php index d3a1632cefdc92be5e945ebc95fc33896f968e39..6566004dd600db17a3a66f0ad319e81e71affb90 100644 --- a/cosmogramme/php/fonctions/objets_saisie.php +++ b/cosmogramme/php/fonctions/objets_saisie.php @@ -91,7 +91,13 @@ function getBlocsParams($id_bib, $type, $valeurs) { $champs_params = []; $titres[0] = 'Paramètres'; - if (in_array($clef, [COM_VSMART, COM_NANOOK, COM_MICROBIB, COM_BIBLIXNET])) + if(in_array($clef, [COM_NANOOK])) + $champs_params[0] = ['url_serveur', + ['provide_suggest' => function($id, $valeur) { + return getOuiNon($id, $valeur); + }]]; + + if (in_array($clef, [COM_VSMART, COM_MICROBIB, COM_BIBLIXNET])) $champs_params[0] = ['url_serveur']; if (in_array($clef, [COM_CARTHAME])) diff --git a/cosmogramme/php/integre_traite_main.php b/cosmogramme/php/integre_traite_main.php index cf167dda41804d10ca4e4dbc446df3a8ceaf3932..54fbc4f4a5bf03e039a429375dbf57f2de405610 100644 --- a/cosmogramme/php/integre_traite_main.php +++ b/cosmogramme/php/integre_traite_main.php @@ -175,46 +175,16 @@ if ($phase >= 0 and $phase < 1) { if ($phase == 1 || $phase == 1.1) { startIntegrationPhase('DeleteItem'); - $phase = 1.2; + $phase = 2; } // ---------------------------------------------------------------- // Suppression des notices sans exemplaires (PHASE 2) // ---------------------------------------------------------------- +$log->ecrire('Suppression des notices sans exemplaire<br>'); setVariable("traitement_phase", "Suppression des notices sans exemplaire"); -if (!$mode_cron and $chrono->tempsPasse() > 10) sauveContexte(); -if ($phase == 1.2) -{ - $log->ecrire("<h4>Suppression des notices sans exemplaire</h4>"); - unset($phase_data); - $phase_data["nombre"] = 0; - $phase_data["timeStart"] = time(); - $phase = 2; -} -if ($phase == 2) -{ - if ($phase_data["nombre"] and !$mode_cron) print("<h4>Suppression des notices sans exemplaire</h4>"); - $chrono->start(); - $result = $sql->prepareListe("select id_notice from notices where id_notice not in(select id_notice from exemplaires)"); - while ($id_notice = $sql->fetchNext($result, 1)) - { - if (!$mode_cron and $chrono->tempsPasse() > $timeout) sauveContexte(); - $sql->execute("delete from notices where id_notice=$id_notice"); - $phase_data["nombre"]++; - if ($phase_data["nombre"] % 100 == 0) - { - print("notice " . $phase_data["nombre"] . "<br>"); - flush(); - } - } - if ($phase_data["nombre"] == 0) $log->ecrire('<span class="vert">Aucune notice sans exemplaire</span>'); - else - { - $log->ecrire('<span class="vert">' . $phase_data["nombre"] . ' notices(s) sans exemplaire supprimée(s)</span>' . BR); - $chrono->timeStart = $phase_data["timeStart"]; - $log->ecrire('<span class="vert">Temps de traitement : ' . $chrono->end() . " (" . $chrono->moyenne($phase_data["nombre"], "notices") . ")</span>" . BR); - } -} +startIntegrationPhase('DeleteRecordWithoutItem'); + if ($phase == 2) $phase = "PERIODIQUES_0"; // ---------------------------------------------------------------- @@ -496,7 +466,19 @@ if (!$mode_cron and $chrono->tempsPasse() > 5) sauveContexte(); startIntegrationPhase('ItemFacets'); -$phase = 8; +$phase = 7.5; + +// ---------------------------------------------------------------- +// Reattach Reviews +// ---------------------------------------------------------------- + +if ($phase == 7.5) { + startIntegrationPhase('Reviews'); + $phase = 8; +} + + + // ---------------------------------------------------------------- // Integration des abonnés diff --git a/cosmogramme/sql/patch/patch_264.php b/cosmogramme/sql/patch/patch_264.php index 8f3c084dc6e07f51eab19991dd393bb5fe4bdc78..f0b3f7c79dbd3cc85f6d66ec9fef7f04b0a377f5 100644 --- a/cosmogramme/sql/patch/patch_264.php +++ b/cosmogramme/sql/patch/patch_264.php @@ -7,7 +7,7 @@ $adapter->query('CREATE TABLE IF NOT EXISTS `premier_chapitre` ( ' .'`auteur` text NOT NULL, ' .'`couverture` varchar(250) NOT NULL, ' .'`couverture_mini` varchar(250) NOT NULL, ' - .'`clef_oeuvre` varchar(200) NOT NULL ' + .'`clef_oeuvre` varchar(200) NOT NULL, ' + .'PRIMARY KEY (`ean`)' .') engine=MyISAM default charset=utf8;'); -$adapter->query('ALTER TABLE `premier_chapitre` ADD PRIMARY KEY (`ean`), ADD UNIQUE KEY `ean` (`ean`);'); ?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_265.php b/cosmogramme/sql/patch/patch_265.php index f77c8e09eb4ec4d3506ad3e0090f65787d3bdb8c..6e852675b78ff96c56caf0037c9036658ea76fe6 100644 --- a/cosmogramme/sql/patch/patch_265.php +++ b/cosmogramme/sql/patch/patch_265.php @@ -1,5 +1,6 @@ <?php $adapter = Zend_Db_Table::getDefaultAdapter(); + foreach([['table' => 'album', 'id' => 'notice_id'], ['table' => 'cms_article', 'id' => 'id_notice'], ['table' => 'rss_flux', 'id' => 'id_notice'], @@ -12,3 +13,5 @@ foreach([['table' => 'album', 'id' => 'notice_id'], $adapter->query(sprintf('UPDATE `%s` SET `%s`=null WHERE `%s`=0', $params['table'], $params['id'], $params['id'])); } + +?> diff --git a/cosmogramme/sql/patch/patch_266.php b/cosmogramme/sql/patch/patch_266.php index b41562792ca763e6e3ff5aff6724d45ce044ab2d..f4564dcd2c5fd438eb3a1f431326d8af421aa41d 100644 --- a/cosmogramme/sql/patch/patch_266.php +++ b/cosmogramme/sql/patch/patch_266.php @@ -5,3 +5,5 @@ try { } catch(Exception $e) { $adapter->query('ALTER TABLE batchs ADD COLUMN data TEXT NULL'); } + +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_267.php b/cosmogramme/sql/patch/patch_267.php index d46e3ad56c003f7be0000240a6154dd94fb91c79..4a27ffba45badab52d631b04cd2da84adf95e5b1 100644 --- a/cosmogramme/sql/patch/patch_267.php +++ b/cosmogramme/sql/patch/patch_267.php @@ -7,4 +7,4 @@ try { $adapter->query('alter table cms_article add column destination_email varchar(255);'); } -?> +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_272.php b/cosmogramme/sql/patch/patch_272.php index 22d3d441547068882622d3cae656716a3337dd71..4972c7b96fb5a405915bc7170b1ddaf07bf08be9 100644 --- a/cosmogramme/sql/patch/patch_272.php +++ b/cosmogramme/sql/patch/patch_272.php @@ -2,5 +2,10 @@ $adapter = Zend_Db_Table::getDefaultAdapter(); try { - $adapter->query('alter table `sito_url` add column `indexation` boolean default true'); -} catch (Exception $e) {} + $adapter->query('select flags from notices_avis limit 1'); +} catch (Exception $e) { + $adapter->query('ALTER TABLE notices_avis ADD COLUMN flags tinyint default 0'); + $adapter->query('ALTER TABLE notices_avis ADD INDEX (flags)'); +} + +?> diff --git a/cosmogramme/sql/patch/patch_273.php b/cosmogramme/sql/patch/patch_273.php new file mode 100644 index 0000000000000000000000000000000000000000..80a0ac787095a4dacff694c047f13c3337cada29 --- /dev/null +++ b/cosmogramme/sql/patch/patch_273.php @@ -0,0 +1,5 @@ +<?php +// update reviews to attach reviews to notices +// $reviews = Class_Cosmogramme_Integration_PhaseReviews::getPhaseWithoutContext(); +// $reviews->_execute(); +?> diff --git a/cosmogramme/sql/patch/patch_274.php b/cosmogramme/sql/patch/patch_274.php new file mode 100644 index 0000000000000000000000000000000000000000..5727d2064b9b0003195f0d731aed31d1f054e94f --- /dev/null +++ b/cosmogramme/sql/patch/patch_274.php @@ -0,0 +1,8 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try { + $adapter->query('replace into bib_admin_var (clef, valeur) values ("CNIL_CONSENT_ENABLE", "1");'); +} catch (Exception $e) {} + +?> diff --git a/cosmogramme/sql/patch/patch_275.php b/cosmogramme/sql/patch/patch_275.php new file mode 100644 index 0000000000000000000000000000000000000000..037c4dddd9e20eaee63c5611f968f3b0785984d5 --- /dev/null +++ b/cosmogramme/sql/patch/patch_275.php @@ -0,0 +1,4 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); +$adapter->query("ALTER TABLE bib_admin_users MODIFY pseudo varchar(100) NULL default ''"); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_276.php b/cosmogramme/sql/patch/patch_276.php new file mode 100644 index 0000000000000000000000000000000000000000..096640528ce212670b6ba600adbd41c3b2e6eda4 --- /dev/null +++ b/cosmogramme/sql/patch/patch_276.php @@ -0,0 +1,7 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try { + $adapter->query('alter table `sito_url` add column `indexation` boolean default true'); +} catch (Exception $e) {} +?> \ No newline at end of file diff --git a/cosmogramme/tests/bootstrap.php b/cosmogramme/tests/bootstrap.php index 0edd1446415f7a93dd62ee56cae6fc9e2b0e4cda..2394fc2af1c3634d693ae452860a6cc8a1df8c6a 100644 --- a/cosmogramme/tests/bootstrap.php +++ b/cosmogramme/tests/bootstrap.php @@ -27,7 +27,4 @@ $_SESSION['passe'] = 'admin_systeme'; define("BASE_URL", "/opac"); include_once "_init.php"; -require_once("classe_communication.php"); - - -?> +require_once("classe_communication.php"); \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/ModelTestCase.php b/cosmogramme/tests/php/classes/ModelTestCase.php index 7fb5bc9125af5e6ed34913db3e77d8a8892db62c..a20794e25a7b7bc404e8cf5dd42add4aa1fe975a 100644 --- a/cosmogramme/tests/php/classes/ModelTestCase.php +++ b/cosmogramme/tests/php/classes/ModelTestCase.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 */ abstract class TestFixtures { @@ -39,6 +39,8 @@ abstract class TestFixtures { abstract class ModelTestCase extends PHPUnit_Framework_TestCase { use Storm_Test_THelpers; + protected $_storm_default_to_volatile = false; + protected function _buildTableMock($model, $methods) { $table = $this->getMock('Storm_Model_Table'.$model,$methods); $loader = call_user_func(array($model, 'getLoader')); @@ -61,11 +63,22 @@ abstract class ModelTestCase extends PHPUnit_Framework_TestCase { ->will($this->returnValue($mock_results)); } - protected function tearDown() { + + public function setUp() { + Storm_Model_Abstract::unsetLoaders(); + if ($this->_storm_default_to_volatile) + Storm_Model_Loader::defaultToVolatile(); + } + + + protected function tearDown() { + if($this->_storm_default_to_volatile) + Storm_Model_Loader::defaultToDb(); Storm_Model_Abstract::unsetLoaders(); } - protected function _setFindAllExpectation($model, $fixtures) { + + protected function _setFindAllExpectation($model, $fixtures) { if (!is_array($fixtures)) { $finst = new $fixtures; $fixtures = $finst->all(); @@ -81,11 +94,10 @@ abstract class ModelTestCase extends PHPUnit_Framework_TestCase { return $tbl_newsletters; } - protected function _generateLoaderFor($model, $methods) { + + protected function _generateLoaderFor($model, $methods) { $loader = $this->getMock('Mock'.$model, $methods); Storm_Model_Abstract::setLoaderFor($model, $loader); return $loader; } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index 718568f4b601b7439d02da9ca39a7fccd3bc8456..0436e3e78fa5ecf417e1a428027f0d8c1596fdb8 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -46,8 +46,7 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { $req_profils = 'select * from profil_donnees where id_profil='.$this->_profil_donnees['id_profil']; - $this->fixture('Class_IntProfilDonnees', - $this->_profil_donnees); + $this->fixture('Class_IntProfilDonnees', $this->_profil_donnees); $this->_mock_sql ->whenCalled('fetchEnreg') @@ -64,7 +63,7 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { parent::setUp(); global $sql; - $sql = $this->_mock_sql = Storm_Test_ObjectWrapper::mock(); + $sql = $this->_mock_sql = $this->mock(); profil_donnees::clearCache(); $this->_mock_sql @@ -87,16 +86,16 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { VariableCache::getInstance() ->setValeurCache(['filtrer_fulltext' => 1, - 'mode_doublon'=> 1, - 'tracer_accents_iso'=>1, - 'non_exportable'=> 'electre;decitre;gam;zebris', - 'controle_codes_barres'=> 0, - 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, - 'champs_sup' => '', - 'ean_345' => '']) + 'mode_doublon'=> 1, + 'tracer_accents_iso'=>1, + 'non_exportable'=> 'electre;decitre;gam;zebris', + 'controle_codes_barres'=> 0, + 'unimarc_zone_titre' => '200$a;461$t', + 'unicite_code_barres' => 0, + 'champs_sup' => '', + 'ean_345' => '']) ->setListeCache(['nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image", - 'types_docs' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]); + 'types_docs' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]); Class_Notice::beVolatile(); Class_Exemplaire::beVolatile(); @@ -129,17 +128,19 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { public function loadNotice($filename) { - $this->loadNoticeFromString(file_get_contents(dirname(__FILE__)."/".$filename.".txt")); + $this->loadNoticeFromString(file_get_contents(__DIR__ . '/' . $filename . '.txt')); } public function loadNoticeFromString($unimarc) { - Codif_langue::getInstance()->setCodif(['fre' => ['id_langue' => 'fre', - 'libelle' => 'français']]); - $this->notice_integration = new notice_integration(); $this->notice_integration->setParamsIntegration(1, 0, isset($this->_profil_donnees['id_profil']) ? $this->_profil_donnees['id_profil'] : 1); + $this->_service_runner = $this->mock() + ->whenCalled('run') + ->answers(['statut' => 'KO']); + $this->notice_integration->setServiceRunner($this->_service_runner); + $this->notice_integration->traiteNotice($unimarc); $this->notice_integration->traiteFacettes(); $this->notice_data = $this->notice_integration->getNotice(); @@ -173,7 +174,8 @@ class NoticeIntegrationLollipopGeneratedNoticeRecordTest extends NoticeIntegrati /** @test */ public function codeAlphaShouldBeLollipop() { - $this->assertEquals('LOLLIPOP--NOSTLINGERC--ECOLEDESLOISIRS-1987-1', $this->notice_data['clef_alpha']); + $this->assertEquals('LOLLIPOP--NOSTLINGERC--ECOLEDESLOISIRS-1987-1', + $this->notice_data['clef_alpha']); } @@ -209,16 +211,19 @@ class NoticeIntegrationLollipopGeneratedNoticeRecordTest extends NoticeIntegrati abstract class NoticeIntegrationMarc21ToUnimarcTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); + $this->notice_marc21 = new notice_marc21(); $this->notice_marc21->ouvrirNotice(file_get_contents(dirname(__FILE__)."/marc21_etalon.txt"), 0); $this->notice_sgbd->ouvrirNotice($this->notice_marc21->getFullRecord()); } + /** @test */ public function zone461TInUnimarcShouldContainsTitres() { $this->assertEquals(['Titre général ;', 'titre general ;'], $this->notice_sgbd->get_subfield('461', 't')); } + /** @test */ public function zone461TInMarc21ShouldContainsTitres() { $this->assertEquals(['Titre général ;', 'titre general ;'], $this->notice_marc21->get_subfield('461', 't')); @@ -227,7 +232,8 @@ abstract class NoticeIntegrationMarc21ToUnimarcTest extends NoticeIntegrationTes abstract class NoticeIntegrationMarc21DynixTestCase extends NoticeIntegrationTestCase { - protected $_profil_donnees = ['id_profil' => 150, + protected $_profil_donnees = ['id' => 150, + 'id_profil' => 150, 'libelle' => 'MARC21 Dynix', 'accents' => '4', 'rejet_periodiques' => '1', @@ -237,23 +243,29 @@ abstract class NoticeIntegrationMarc21DynixTestCase extends NoticeIntegrationTes 'attributs' => 'a:7:{i:0;a:8:{s:8:"type_doc";a:12:{i:0;a:3:{s:4:"code";s:1:"0";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:1;a:3:{s:4:"code";s:1:"1";s:5:"label";s:5:"am;na";s:8:"zone_995";s:22:"LIV;MS;LDV;LVI;LV;LIVC";}i:2;a:3:{s:4:"code";s:1:"2";s:5:"label";s:2:"as";s:8:"zone_995";s:12:"PER;REVC;REV";}i:3;a:3:{s:4:"code";s:1:"3";s:5:"label";s:3:"i;j";s:8:"zone_995";s:17:"CD;LIVCD;LIVK7;K7";}i:4;a:3:{s:4:"code";s:1:"4";s:5:"label";s:1:"g";s:8:"zone_995";s:25:"DIAPO;DVD;VHS;VHD;VD;DVDJ";}i:5;a:3:{s:4:"code";s:1:"5";s:5:"label";s:3:"l;m";s:8:"zone_995";s:3:"CDR";}i:6;a:3:{s:4:"code";s:1:"7";s:5:"label";s:0:"";s:8:"zone_995";s:7:"LCA;LCD";}i:7;a:3:{s:4:"code";s:1:"8";s:5:"label";s:0:"";s:8:"zone_995";s:3:"DOS";}i:8;a:3:{s:4:"code";s:1:"9";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:9;a:3:{s:4:"code";s:2:"10";s:5:"label";s:0:"";s:8:"zone_995";s:6:"WEB;MF";}i:10;a:3:{s:4:"code";s:2:"11";s:5:"label";s:0:"";s:8:"zone_995";s:2:"JV";}i:11;a:3:{s:4:"code";s:3:"100";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}}s:17:"champ_code_barres";s:3:"999";s:10:"champ_cote";s:1:"k";s:14:"champ_type_doc";s:1:"r";s:11:"champ_genre";s:0:"";s:13:"champ_section";s:1:"z";s:17:"champ_emplacement";s:1:"u";s:12:"champ_annexe";s:1:"b";}i:1;a:1:{s:6:"champs";s:0:"";}i:2;a:1:{s:6:"champs";s:0:"";}i:3;a:1:{s:6:"champs";s:0:"";}i:5;a:3:{s:6:"champs";s:0:"";s:17:"xml_balise_abonne";s:0:"";s:17:"xml_champs_abonne";a:11:{s:6:"IDABON";s:0:"";s:9:"ORDREABON";s:0:"";s:3:"NOM";s:0:"";s:6:"PRENOM";s:0:"";s:9:"NAISSANCE";s:0:"";s:8:"PASSWORD";s:0:"";s:4:"MAIL";s:0:"";s:10:"DATE_DEBUT";s:0:"";s:8:"DATE_FIN";s:0:"";s:7:"ID_SIGB";s:0:"";s:9:"NUM_CARTE";s:0:"";}}i:4;a:5:{s:4:"zone";s:3:"995";s:5:"champ";s:1:"v";s:6:"format";s:1:"3";s:5:"jours";s:0:"";s:7:"valeurs";s:1:"n";}i:6;a:2:{s:4:"zone";s:3:"901";s:5:"champ";s:1:"a";}}']; } -class NoticeIntegrationMarc21CoupCavalierToUnimarcTest extends NoticeIntegrationMarc21DynixTestCase { + + + +class NoticeIntegrationMarc21CoupCavalierToUnimarcTest + extends NoticeIntegrationMarc21DynixTestCase { + public function setUp() { parent::setUp(); $this->fixture('Class_CodifSection', - ['id' => 2, - 'regles' => '996$z=ADU']); + ['id' => 2, 'regles' => '996$z=ADU']); $this->notice_marc21 = new notice_marc21(); - $this->notice_marc21->ouvrirNotice(file_get_contents(dirname(__FILE__)."/marc21_coup_cavalier.txt"), $this->_profil_donnees['id_profil']); + $this->notice_marc21->ouvrirNotice(file_get_contents(dirname(__FILE__)."/marc21_coup_cavalier.txt"), + $this->_profil_donnees['id_profil']); $this->notice_data = $this->notice_marc21->getNoticeIntegration(); } /** @test */ public function zone200AShouldBeLeCoupDuCavalier() { - $this->assertEquals('Le coup du cavalier', $this->notice_marc21->get_subfield('200', 'a')[0]); + $this->assertEquals('Le coup du cavalier', + $this->notice_marc21->get_subfield('200', 'a')[0]); } @@ -271,7 +283,7 @@ class NoticeIntegrationMarc21CoupCavalierToUnimarcTest extends NoticeIntegration /** @test */ public function sectionShouldHaveId2() { - $this->assertEquals(2, $this->notice_data['exemplaires'][0]['section']); + $this->assertEquals(2, $this->notice_data['exemplaires'][0]['section']); } @@ -639,7 +651,7 @@ class NoticeIntegrationBearsBeerMicrobibTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); - $this->loadNotice("unimarc_bears_beer"); + $this->loadNotice('unimarc_bears_beer'); } @@ -1710,7 +1722,4 @@ class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeInt public function noArticleShouldHaveBeenSaved() { $this->assertCount(0, Class_Notice_SerialArticles::findAll()); } -} - - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 5a27ae44c0da1ec6d83fffecf7144de072d604d4..c406e8229fede6c5e631e80083692e3193d4b6de 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -153,6 +153,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'FACETTE_TAG_LIBELLE' => Class_AdminVar_Meta::newDefault('Libellé de la facette tag'), 'UNLEASHED_FACETS' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des codes des facettes qui ne sont pas limitées à l\'affichage dans le résultat de recherche<br/>Exemple : T => Type de doc, Y => Annexe, B => Bibliothèque, ... (Voir <a href="' . BOKEH_REMOTE_FILES . 'blob/' . BOKEH_VERSION . '/library/Class/Codification.php#L24">la liste complète</a>)')), 'AFFICHER_DISPONIBILITE_SUR_RECHERCHE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la disponibilite dans le resultat de recherche.')), + 'SEARCH_ALSO_IN' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des sites de recherche élargie (la chaine \'%s\' dans l\'url sera remplacée par le terme de recherche)'), + [ 'options' => ['fields' => [['name' => 'site_label', 'label' => $this->_('Nom du site')], + ['name' => 'site_url', 'label' => $this->_('Url de recherche')] ]]]), 'NOM_DOMAINE' => Class_AdminVar_Meta::newDefault($this->_('Nom de domaine principal de l\'OPAC, ex: monopac.macommune.fr')), 'DATE_LAST_FULL_INTEGRATION_USERS' => Class_AdminVar_Meta::newDefault($this->_('Date du dernier import total des abonnés (modifié par cosmogramme)')), 'BOITE_PANIER_AUTO' => Class_AdminVar_Meta::newOnOff($this->_('Ajouter automatiquement une boîte panier dans la division flottante')), @@ -243,6 +246,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'DILICOM_PNB_MAX_LOAN_DURATION' => Class_AdminVar_Meta::newDefault($this->_('Durée maximale (en jours) d\'un prêt PNB Dilicom')), 'DILICOM_PNB_LOAN_COUNT_LIMIT' => Class_AdminVar_Meta::newDefault($this->_('Nombre de prêts simultanés maximum pour un livre PNB Dilicom')), 'DILICOM_PNB_MAX_LOAN_PER_USER' => Class_AdminVar_Meta::newDefault($this->_('Nombre de prêts simultanés maximum pour un abonné PNB Dilicom (par défaut 3)'), ['value' => 3]), + 'DILICOM_PNB_LOAN_WARNING_MESSAGE' => Class_AdminVar_Meta::newEditor($this->_('Message d\'avertissement affiché sur la popup d\'emprunt'), + ['value' => $this->_('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.')]), 'MYCOW_EID' => Class_AdminVar_Meta::newDefault($this->_('Clé d\'identification MyCOW.EU pour le portail. Cette clé doit être fournie par MyCOW.EU. Elle active la ressource numérique dans le portail.'))->bePrivate(), 'ONEDTOUCH_URL' => Class_AdminVar_Meta::newDefault($this->_('Adresse du serveur OAI 1D touch'))->bePrivate(), diff --git a/library/Class/AdminVar/Meta.php b/library/Class/AdminVar/Meta.php index f2de0637915017f98b5c725753a87d8dc3f0dc8c..48e17d3ea73e010382dbd2c8811fa4c9eee86fc7 100644 --- a/library/Class/AdminVar/Meta.php +++ b/library/Class/AdminVar/Meta.php @@ -27,7 +27,8 @@ class Class_AdminVar_Meta { TYPE_ON_OFF = 'on-off', TYPE_MULTI_INPUT = 'multi-input', TYPE_COMBO = 'combo', - TYPE_RAW_TEXT = 'raw-text'; + TYPE_RAW_TEXT = 'raw-text', + TYPE_EDITOR = 'editor'; protected @@ -41,7 +42,8 @@ class Class_AdminVar_Meta { 'OnOff' => self::TYPE_ON_OFF, 'MultiInput' => self::TYPE_MULTI_INPUT, 'Combo' => self::TYPE_COMBO, - 'RawText' => self::TYPE_RAW_TEXT]; + 'RawText' => self::TYPE_RAW_TEXT, + 'Editor' => self::TYPE_EDITOR]; $type_name = substr($name, 3); @@ -83,6 +85,11 @@ class Class_AdminVar_Meta { } + public function isEditor() { + return self::TYPE_EDITOR == $this->_type; + } + + public function isMultiInput() { return self::TYPE_MULTI_INPUT == $this->_type; } diff --git a/library/Class/Article.php b/library/Class/Article.php index 34ac7a8b6a80eaf147959a8d055709ab5d5ce08e..9ff6d9fb6cdf5d477d857950e0b6d60bd9c91052 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -783,6 +783,17 @@ class Class_Article extends Storm_Model_Abstract { } + public function getPubDate() { + if ($this->hasEventsDebut()) + return $this->getEventsDebut(); + + if ($this->hasDebut()) + return $this->getDebut(); + + return $this->getDateMaj(); + } + + public function beforeSave() { if ($this->isNew() && !$this->getDateCreation()) $this->setDateCreation($this->getDateMaj()); diff --git a/library/Class/Avis.php b/library/Class/Avis.php index 98b3157976343aad6a86c6f034e17849cdb05bac..7ada26071f2525136baffdeabfdac098968d719b 100644 --- a/library/Class/Avis.php +++ b/library/Class/Avis.php @@ -37,11 +37,10 @@ class Class_Avis extends Storm_Model_Abstract { protected $_default_attribute_values = ['entete' => '', 'avis' => '', + 'flags' => 0, 'note' => 0 ]; - - /** Ecrire 1 avis (update si existe déjà ) */ public static function ecrireCmsAvis($id_user, $role_level, $id_news, $note, $entete, $content) { $modo_avis_abo = getVar('MODO_AVIS'); // 0 apres / 1 avant de publier sur le site @@ -120,6 +119,10 @@ class Class_Avis extends Storm_Model_Abstract { $rank->save(); } + + public function getFlags() { + return -1; + } } ?> \ No newline at end of file diff --git a/library/Class/AvisNotice.php b/library/Class/AvisNotice.php index c4a97f61d2ed9b981d61abe856b36eb1eae89aa6..c33fd68292d22315edd3bc98df9fb45eafb84231 100644 --- a/library/Class/AvisNotice.php +++ b/library/Class/AvisNotice.php @@ -42,6 +42,76 @@ class AvisNoticeLoader extends Storm_Model_Loader { return $this; } + public function findOrphanReviews($status, $limitPage=null) { + $req = ['flags' => Class_AvisNotice::ORPHAN_FLAG, + 'order' => 'date_avis desc', + 'statut' => $status]; + if ($limitPage) + $req['limitPage'] = $limitPage; + return Class_AvisNotice::findAllBy($req); + } + + public function findBiblioReviews($status, $limitPage=null) { + $req = ['flags' => Class_AvisNotice::NO_FLAG, + 'abon_ou_bib' => Trait_Avis::$AVIS_BIBLIO, + 'order' => 'date_avis desc', + 'statut' => $status]; + if ($limitPage) + $req['limitPage'] = $limitPage; + return Class_AvisNotice::findAllBy($req); + } + + public function countBiblioReviews($status) { + $req = ['flags' => Class_AvisNotice::NO_FLAG, + 'abon_ou_bib' => Trait_Avis::$AVIS_BIBLIO, + 'statut' => $status]; + return Class_AvisNotice::countBy($req); + } + + public function countAboReviews($status) { + $req = ['flags' => Class_AvisNotice::NO_FLAG, + 'abon_ou_bib' => Trait_Avis::$AVIS_ABONNE, + 'statut' => $status]; + return Class_AvisNotice::countBy($req); + } + + + public function findAboReviews($status, $limitPage=null) { + $req = ['flags' => Class_AvisNotice::NO_FLAG, + 'abon_ou_bib' => Trait_Avis::$AVIS_ABONNE, + 'order' => 'date_avis desc', + 'statut' => $status]; + if ($limitPage) + $req['limitPage'] = $limitPage; + return Class_AvisNotice::findAllBy($req); + } + + + public function countOrphanReviews($status) { + $req = ['flags' => Class_AvisNotice::ORPHAN_FLAG, + 'order' => 'date_avis desc', + 'statut' => $status]; + + return Class_AvisNotice::countBy($req); + } + + public function countArchivedReviews($status) { + $req = ['flags' => Class_AvisNotice::ARCHIVED_FLAG, + 'order' => 'date_avis desc', + 'statut' => $status]; + + return Class_AvisNotice::countBy($req); + } + + public function findArchivedReviews($status,$limitPage=null) { + $req = ['flags' => Class_AvisNotice::ARCHIVED_FLAG, + 'order' => 'date_avis desc', + 'statut' => $status]; + if ($limitPage) + $req['limitPage'] = $limitPage; + + return Class_AvisNotice::findAllBy($req); + } protected function _addStatutAbonBibWhereClause($abon_ou_bib, &$params) { $modo_avis_abo = Class_AdminVar::get('MODO_AVIS'); // 0 apres / 1 avant de publier sur le site @@ -73,12 +143,15 @@ class AvisNoticeLoader extends Storm_Model_Loader { - id_panier: le panier de notices dont on veut récupérer les avis On prends les avis soit du catalogue, soit du panier, soit les dernier avis */ - public function getAvisFromPreferences($preferences, $limit_page=null) { + public function getAvisFromPreferences($preferences, $limit_page=null, $include_orphan = false) { $params = ['order' => 'DATE_AVIS DESC']; + if (!$include_orphan) + $params['flags'] = Class_AvisNotice::NO_FLAG; $preferences = array_merge(['id_panier' => 0, 'id_catalogue' => 0, - 'abon_ou_bib' => 'all'], + 'abon_ou_bib' => 'all', + ], $preferences); $id_panier = $preferences['id_panier']; @@ -94,7 +167,7 @@ class AvisNoticeLoader extends Storm_Model_Loader { if ($limit_page) $params['limitPage'] = $limit_page; - return Class_AvisNotice::getLoader()->findAllBy($params); + return Class_AvisNotice::findAllBy($params); } @@ -109,6 +182,9 @@ class AvisNoticeLoader extends Storm_Model_Loader { class Class_AvisNotice extends Storm_Model_Abstract { use Trait_Avis, Trait_Translator; + const NO_FLAG=0; + const ORPHAN_FLAG=1; + const ARCHIVED_FLAG=2; protected $_loader_class = 'AvisNoticeLoader'; protected $_table_name = 'notices_avis'; @@ -117,7 +193,12 @@ class Class_AvisNotice extends Storm_Model_Abstract { protected $_belongs_to = ['user' => ['model' => 'Class_Users', 'referenced_in' => 'id_user']]; - protected $_default_attribute_values = ['statut' => 0]; + protected $_default_attribute_values = ['statut' => 0, + 'flags' => self::NO_FLAG, + 'clef_oeuvre' => '', + 'date_avis' => null, + 'id_notice' => 0, + 'note' => 0]; protected $_notices; protected $_import_mode = false; @@ -144,6 +225,16 @@ class Class_AvisNotice extends Storm_Model_Abstract { } + public static function filterByOrphan($avis_list) { + return self::filterByMethod($avis_list, 'isOrphan'); + } + + + public static function filterByArchived($avis_list) { + return self::filterByMethod($avis_list, 'isArchived'); + } + + public static function filterByBibliothecaire($avis_list) { return self::filterByMethod($avis_list, 'isWrittenByBibliothecaire'); } @@ -154,11 +245,6 @@ class Class_AvisNotice extends Storm_Model_Abstract { } - public function getNote() { - return !$this->_attributes['note'] ? - 0 : $this->_attributes['note']; - } - public static function getNoteAverage($avis_list) { if (!$avis_list or count($avis_list) == 0) @@ -174,7 +260,7 @@ class Class_AvisNotice extends Storm_Model_Abstract { public function getNotices() { if (!isset($this->_notices)) - $this->_notices = $this->_findNoticesByClefOeuvre(); + $this->_notices = $this->findNoticesByClefOeuvre(); return $this->_notices; } @@ -183,25 +269,20 @@ class Class_AvisNotice extends Storm_Model_Abstract { * Recherche les notices liées à cet avis. Si non trouvé (par exemple l'auteur de la clé * oeuvre à été mis à jour dans le SIGB, essaye de retrouver la notice et réaffecte l'avis */ - protected function _findNoticesByClefOeuvre() { - if ($notices = Class_Notice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre()])) - return $notices; + public function findNoticesByClefOeuvre() { + if ($this->_notices = Class_Notice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre()])) + return $this->_notices; if (!$notices = Class_Notice::findAllBy(['where' => 'clef_oeuvre like "'.$this->getTitreClefOeuvre().'-%"'])) - return []; + return $this->_notices = []; $clef_oeuvre = $notices[0]->getClefOeuvre(); foreach($notices as $notice) { //on assume que les notices ont été retrouvées si elles ont toutes la même clé oeuvre if ($clef_oeuvre !== $notice->getClefOeuvre()) - return []; - - $this - ->setClefOeuvre($clef_oeuvre) - ->setModerationNOK() - ->save(); + return $this->_notices = []; } - + $this->_notices=$notices; return $notices; } @@ -215,8 +296,19 @@ class Class_AvisNotice extends Storm_Model_Abstract { return $this->setNotices(array($notice)); } + public function updateNoticeAndSave() { + $this->setIdNotice(0); + $this->findNoticesByClefOeuvre(); + if ($notice = $this->getFirstNotice()) { + return ($this->setIdNotice($notice->getId())->updateFlags()->save()); + } + return false; + } + public function getFirstNotice() { + if ($this->getIdNotice()>0) + return Class_Notice::find($this->getIdNotice()); $notices = $this->getNotices(); if (count($notices) == 0) return null; @@ -271,6 +363,24 @@ class Class_AvisNotice extends Storm_Model_Abstract { } + public function updateFlags() { + if ($this->getIdNotice()>0 && $this->getFlags() == Class_AvisNotice::ORPHAN_FLAG) + $this->setFlags(Class_AvisNotice::NO_FLAG); + if ($this->getIdNotice()<1 && $this->getFlags() == Class_AvisNotice::NO_FLAG) + $this->setFlags(Class_AvisNotice::ORPHAN_FLAG); + return $this; + } + + public function forceUpdateWithNotice($notice) { + if (!$notice) + return $this; + $this->setClefOeuvre($notice->getClefOeuvre()); + $this->setIdNotice($notice->getId()); + $this->updateFlags(); + return $this; + } + + public function beforeSave() { if ($this->isImportMode()) return; diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 6bc92f997127682e0fca314bbcb56a348bf8b1a5..ae39a4505d240782406e0974be45817a7b47500a 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -663,6 +663,16 @@ class Class_Bib extends Storm_Model_Abstract { } + public function getRecursiveArticleCategories() { + $categories=[]; + foreach($this->getArticleCategories() as $cat) { + $categories[]=$cat; + $categories= array_merge($categories,$cat->getRecursiveSousCategories()); + } + return $categories; + } + + public function getArticleCategoriesToJson() { return $this->articlesToJSON(false); } diff --git a/library/Class/CodifAuteur.php b/library/Class/CodifAuteur.php index 59e71f1c17a29ff3568a8e77b665539d47d2bf3f..61a804dc17de3014eacc033fe8f8fbc3265fa6ad 100644 --- a/library/Class/CodifAuteur.php +++ b/library/Class/CodifAuteur.php @@ -21,8 +21,8 @@ class CodifAuteurLoader extends Storm_Model_Loader { - public function findOrCreate($code_alpha,$auteur) { - $existing = Class_CodifAuteur::getLoader()->findByCodeAlpha($code_alpha); + public function findOrCreate($code_alpha, $auteur) { + $existing = Class_CodifAuteur::findByCodeAlpha($code_alpha); if(!$existing) { $nom_prenom = (-1 < $pos = strscan($auteur, "|", 0)) @@ -38,7 +38,7 @@ class CodifAuteurLoader extends Storm_Model_Loader { public function findByCodeAlpha($code_alpha) { - return Class_CodifAuteur::getLoader()->findFirstBy( + return Class_CodifAuteur::findFirstBy( ['where' => "MATCH(formes) AGAINST('" . $code_alpha . "' IN BOOLEAN MODE)"]); } @@ -78,10 +78,13 @@ class CodifAuteurLoader extends Storm_Model_Loader { class Class_CodifAuteur extends Storm_Model_Abstract { - const CODE_FACETTE='A'; + const CODE_FACETTE = 'A'; + protected $_table_name = 'codif_auteur'; protected $_table_primary = 'id_auteur'; protected $_loader_class = 'CodifAuteurLoader'; -} -?> \ No newline at end of file + protected $_default_attribute_values = ['mots_renvois' => '', + 'id_bnf' => '', + 'date_creation' => '']; +} \ No newline at end of file diff --git a/library/Class/CodifMatiere.php b/library/Class/CodifMatiere.php index ca0e6a0a6cc1f5127bf01b57518d0825ea2a5a1c..ddc10c8176691ddb8a5cb67db5e98bb8d80207ed 100644 --- a/library/Class/CodifMatiere.php +++ b/library/Class/CodifMatiere.php @@ -16,12 +16,32 @@ * * 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_CodifMatiereLoader extends Storm_Model_Loader { + public function findOrCreate($code, $label) { + if ($model = Class_CodifMatiere::findFirstBy(['code_alpha' => $code])) + return $model; + + $model = Class_CodifMatiere::newInstance(['libelle' => $label, + 'code_alpha' => $code]); + $model->save(); + + return $model; + } +} + + + class Class_CodifMatiere extends Storm_Model_Abstract { - const CODE_FACETTE='M'; + const CODE_FACETTE = 'M'; + protected $_table_name = 'codif_matiere'; protected $_table_primary = 'id_matiere'; + protected $_loader_class = 'Class_CodifMatiereLoader'; + + protected $_default_attribute_values = ['mots_renvois' => '', + 'id_bnf' => '', + 'date_creation' => '']; } -?> diff --git a/library/Class/Cosmogramme/Chronometre.php b/library/Class/Cosmogramme/Chronometre.php index 99c579fa4f30fb305ff499e24510befece0fd2a9..101cf571c2bf99b1d563848cc1646b57619e2844 100644 --- a/library/Class/Cosmogramme/Chronometre.php +++ b/library/Class/Cosmogramme/Chronometre.php @@ -95,5 +95,18 @@ class Class_Cosmogramme_Chronometre { return number_format($mean, 0, ',', ' ') . ' ' . $label . ' par minute'; } + + + public function average($number, $label) { + $time = $this->getTimeSource()->time() - $this->_start; + + if ($time == 0) + $time = 1; + + $average = $number / ($time / 60); + $text = number_format($average, 0, ',' , '.'); + $text .= ' '.$label.' par minute'; + return $text; + } } ?> \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/Chronometre.php b/library/Class/Cosmogramme/Integration/Chronometre.php index 48f503a92c4ccb6ae76f1516b94a0b597955e5f2..485131f7085fcaef99ca93bb963131314d7ecdb1 100644 --- a/library/Class/Cosmogramme/Integration/Chronometre.php +++ b/library/Class/Cosmogramme/Integration/Chronometre.php @@ -99,6 +99,11 @@ class Class_Cosmogramme_Integration_Chronometre { } + public function endMain() { + return $this->_main->end(); + } + + public function meanOnFile($total, $label) { return $this->_on_file->mean($total, $label); } @@ -107,5 +112,10 @@ class Class_Cosmogramme_Integration_Chronometre { public function elapsedOnRecords() { return $this->_on_records->elapsed(); } + + + public function mainAverage($number, $label) { + return $this->_main->average($number, $label); + } } ?> \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/CodifProvider.php b/library/Class/Cosmogramme/Integration/CodifProvider.php new file mode 100644 index 0000000000000000000000000000000000000000..2057fedd9c49d677755230757589af96499ea86a --- /dev/null +++ b/library/Class/Cosmogramme/Integration/CodifProvider.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright (c) 2012-2015, 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 Class_Cosmogramme_Integration_CodifProvider { + use Trait_TimeSource; + + protected $_indexation; + + + public function setIndexation($indexation) { + $this->_indexation = $indexation; + return $this; + } + + + public function getAuthor($label) { + return $this->_getFrom($label, + str_replace(' ', 'x', $this->_indexation->alphaMaj($label)), + 'Class_CodifAuteur'); + } + + + public function getTopic($label) { + // limit to the maximum size of code_alpha column in db to avoid duplicates + $code = substr($this->_indexation->alphaMaj($label), 0, 255); + return $this->_getFrom($label, $code, 'Class_CodifMatiere'); + } + + + protected function _getFrom($value, $code, $model_class) { + if (!$code) + return; + + $model = call_user_func_array([$model_class, 'findOrCreate'], + [$code, $value]); + + return $model; + } +} \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhaseAbstract.php b/library/Class/Cosmogramme/Integration/PhaseAbstract.php index 559cae022514d619a35491e2013198372ecbb4eb..844f79c062c5e22f9e436632ccb4ed82fcd54e28 100644 --- a/library/Class/Cosmogramme/Integration/PhaseAbstract.php +++ b/library/Class/Cosmogramme/Integration/PhaseAbstract.php @@ -21,7 +21,7 @@ abstract class Class_Cosmogramme_Integration_PhaseAbstract { - use Trait_TimeSource, Trait_StaticFileSystem, Trait_Translator; + use Trait_TimeSource, Trait_StaticFileSystem, Trait_Translator, Trait_MemoryCleaner; protected $_label = ''; protected $_phase, $_log, $_printer, $_chrono, $_is_time_out; @@ -129,6 +129,8 @@ abstract class Class_Cosmogramme_Integration_PhaseAbstract { public function isTimeOut() { + if (!$this->_chrono) + return false; return !$this->_phase->isCron() && $this->_chrono->mainElapsed() > $this->_chrono->timeout(); } diff --git a/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItem.php b/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItem.php new file mode 100644 index 0000000000000000000000000000000000000000..e37cf361e0ca9828554999806edefd55e73758f5 --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItem.php @@ -0,0 +1,71 @@ +<?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 + */ +require_once('cosmogramme/php/classes/classe_notice_integration.php'); + +class Class_Cosmogramme_Integration_PhaseDeleteRecordWithoutItem extends Class_Cosmogramme_Integration_PhaseAbstract { + const MY_ID = 2; + + protected $_label = 'Suppression des notices sans exemplaire'; + + public function _execute() { + if ($this->isTimeOut()) + return $this->_phase; + + $this->_chrono->start(); + $page_size = 1000; + $page = 1; + + while ($notices = Class_Notice::findAllBy(['order' => 'id_notice', + 'limitPage' => [$page, $page_size]])) { + foreach ($notices as $notice) { + $this->_runOne($notice); + } + + $this->_cleanMemory(); + $page++; + } + + if (0 == $this->_getData('deleted')) + $this->_log->ecrire('Aucune notice sans exemplaire'); + + if (0 < $this->_getData('deleted')) + $this->_log->ecrire($this->_getData('deleted').' notices sans exemplaire supprimées'); + $this->_log->ecrire('Temps de traitement: '.$this->_chrono->endMain().' ('.$this->_chrono->mainAverage($this->_getData('nombre'), 'notices').')' ); + } + + + protected function _runOne($notice) { + $this->_incrementData('nombre'); + + if ($notice->hasExemplaires()) + return; + + $notice->delete(); + $this->_incrementData('deleted'); + } + + protected function _init($phase) { + $phase + ->resetDatas() + ->setData('nombre', 0) + ->setData('deleted', 0); + } +} diff --git a/library/Class/Cosmogramme/Integration/PhaseNotice.php b/library/Class/Cosmogramme/Integration/PhaseNotice.php index bb2799ae99f8d8d841f7d2c833067cca155a0631..0be2dac0a66dac676b6b87a0094c145cf6425c21 100644 --- a/library/Class/Cosmogramme/Integration/PhaseNotice.php +++ b/library/Class/Cosmogramme/Integration/PhaseNotice.php @@ -21,9 +21,13 @@ require_once('cosmogramme/php/classes/classe_notice_integration.php'); -class Class_Cosmogramme_Integration_PhaseNotice extends Class_Cosmogramme_Integration_PhaseOnDataSource { +class Class_Cosmogramme_Integration_PhaseNotice + extends Class_Cosmogramme_Integration_PhaseOnDataSource { + const MY_ID = 0; + protected static $_service_runner; + protected function _init($phase) {} @@ -37,12 +41,14 @@ class Class_Cosmogramme_Integration_PhaseNotice extends Class_Cosmogramme_Integr public function importRecord($data, $integration) { - $notice = new notice_integration(); - $notice->setParamsIntegration($integration->getIdBib(), - $integration->getTypeOperation(), - $integration->getProfil(), - $integration->getTypeDoc()); - $notice->traiteNotice($data); + $integrator = new notice_integration(); + $integrator->setParamsIntegration($integration->getIdBib(), + $integration->getTypeOperation(), + $integration->getProfil(), + $integration->getTypeDoc()); + $integrator->setServiceRunner(static::$_service_runner); + $integrator->traiteNotice($data); + $this->_incrementCount($integrator->getStatut()); } @@ -104,5 +110,10 @@ class Class_Cosmogramme_Integration_PhaseNotice extends Class_Cosmogramme_Integr $this->_log->ecrire($trace) : $this->_getPrinter()->nextPutAll($trace . '<br>'); } -} -?> \ No newline at end of file + + + /** @category testing */ + public static function setServiceRunner($runner) { + static::$_service_runner = $runner; + } +} \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhaseOnDataSource.php b/library/Class/Cosmogramme/Integration/PhaseOnDataSource.php index a8049cee7af57c667c10b6f113676d65c8f42f82..927252d54e6f1723ddd31dc27fc3c7c4f0713684 100644 --- a/library/Class/Cosmogramme/Integration/PhaseOnDataSource.php +++ b/library/Class/Cosmogramme/Integration/PhaseOnDataSource.php @@ -88,7 +88,15 @@ abstract class Class_Cosmogramme_Integration_PhaseOnDataSource extends Class_Cos ->resetDatas() ->setData('nb_erreurs', 0) ->setData('nb_warnings', 0) - ->setData('nombre', 0); + ->setData('nombre', 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_REJECT, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_INSERT, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_DELETE, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_FULLUPDATE, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_UPDATE, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_RENEW, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_UPGRADE, 0) + ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_SUCCINCT, 0); $this->_chrono ->startOnFile() diff --git a/library/Class/Cosmogramme/Integration/PhaseReviews.php b/library/Class/Cosmogramme/Integration/PhaseReviews.php new file mode 100644 index 0000000000000000000000000000000000000000..0492474e46662dceb6f5928e19f1eea3a112affd --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseReviews.php @@ -0,0 +1,119 @@ +<?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 Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integration_PhaseAbstract { + const MY_ID=7.5; + + protected $_label = 'Reviews attachments'; + protected $_db_reset=true; + + public function __construct($phase, $log, $chrono) { + parent::__construct($phase, $log, $chrono); + + } + + public static function getPhaseWithoutContext() { + $phase=(new Class_Cosmogramme_Integration_Phase(self::MY_ID)); + $phase->resetDatas() + ->setData('nombre', 0); + return (new Class_Cosmogramme_Integration_PhaseReviews($phase,null,null)); + } + + protected function _init($new_phase) { + $new_phase + ->resetDatas() + ->setData('nombre', 0); + + $this->_chrono + ->startOnFile() + ->startOnRecords(); + return $this; + } + + + public function _execute() { + $page = 1; + while ($records = Class_AvisNotice::findAllBy(['order' => 'id', + 'limitPage' => [$page, 500]])) { + + if ($this->_log && (0 == ($this->_getData('nombre') % 100))) + $this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' avis mis à jour </span>'); + + $this->runUpdateForRecords($records); + + $this->_resetDbConnection(); + + $page++; + } + + if ($this->_log) { + $this->_log->ecrire('<span class="vert">'. + 'Tous les avis ont été mis à jour :' . + '<br>' . $this->_getData('nombre') . ' avis traités.</span>'); + + $msg = '<span class="vert">Temps de traitement : ' + . $this->_chrono->endFile() + . ' (' . $this->_chrono->meanOnFile($this->_getData('nombre'), + 'notices') . ')</span>'; + + $this->_log->ecrire($msg); + } + + } + + + protected function runUpdateForRecords($records) { + foreach ($records as $record) { + if ($this->isTimeOut()) + return $this->_resetDbConnection() + ->_phase; + $this->_runOne($record); + + } + } + + + protected function _runOne($record) { + if (!$record->updateNoticeAndSave()) + $record->updateFlags()->saveWithoutValidation(); + $this->_incrementData('nombre'); + + } + + /** @category testing */ + public function noDbReset() { + $this->_db_reset = false; + return $this; + } + + protected function _resetDbConnection() { + if (!$this->_db_reset) + return $this; + + Storm_Model_Abstract::unsetLoaders(); + Zend_Db_Table::getDefaultAdapter()->closeConnection(); + setupDatabase(loadConfig()); + gc_collect_cycles(); + return $this; + } + + +} \ No newline at end of file diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 97a8fa307c2bd1aeeb6a82e10fa04ffeeea327d9..91db2e27e98885fc8a8005f11cf9d1c1f7e03db7 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -547,6 +547,11 @@ class Class_CriteresRecherche { } + public function hasExpressionRecherche() { + return !in_array($this->getExpressionRecherche(), ['', '*']); + } + + public function getUrlRetourRechercheInitiale(){ $action = 'avancee'; if (array_key_exists('expressionRecherche',$this->_params) || array_key_exists('id_panier',$this->_params) || array_key_exists('id_catalogue',$this->_params)) diff --git a/library/Class/Indexation.php b/library/Class/Indexation.php index 40dd5297d561e200dccea14a48c961b4aa98ecc0..dc6a5e674c7f5578949b2181c1f1329d514edc64 100644 --- a/library/Class/Indexation.php +++ b/library/Class/Indexation.php @@ -44,7 +44,7 @@ class Class_Indexation { public static function getInstance() { if(!static::$_instance) - static::$_instance = new Class_Indexation(); + static::$_instance = new static(); return static::$_instance; } @@ -107,486 +107,513 @@ class Class_Indexation { ['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=array(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'); - } - // Indexation d'un titre - public function codeAlphaTitre($titre) - { - $titre=$this->alphaMaj($titre); - foreach($this->articles as $article) - { - $lg=strlen($article); - if(strLeft($titre, $lg)==$article) {$titre=strMid($titre,$lg,256); break;} - } - $titre=$this->alphaMaj($titre); - return $titre; - } + // 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']; + } - // Rend une suite de mots complete pour les formes plurielles - public function getExpressionRecherche($mot) { - if (!$mot=trim($mot)) - return false; - // Pluriel - $etoile = ''; - if(strRight($mot,1) == '*') { - $etoile='*'; - $mot=strLeft($mot, strlen($mot)-1); + // Indexation d'un titre + public function codeAlphaTitre($titre) + { + $titre=$this->alphaMaj($titre); + foreach($this->articles as $article) + { + $lg=strlen($article); + if(strLeft($titre, $lg)==$article) {$titre=strMid($titre,$lg,256); break;} } + $titre=$this->alphaMaj($titre); + return $titre; + } + + // Rend une suite de mots complete pour les formes plurielles + public function getExpressionRecherche($mot) { + if (!$mot=trim($mot)) + return false; - $m = $this->getPluriel($mot); - $m[2] = $this->phonetix($m[0]); - return trim('('.$m[0].$etoile.' '.$m[1].' '.$m[2].')'); + // Pluriel + $etoile = ''; + if(strRight($mot,1) == '*') { + $etoile='*'; + $mot=strLeft($mot, strlen($mot)-1); } + $m = $this->getPluriel($mot); + $m[2] = $this->phonetix($m[0]); + return trim('('.$m[0].$etoile.' '.$m[1].' '.$m[2].')'); + } - public function alphaMaj( $chaine ) { - 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, - utf8_decode($chaine))); - } + public function alphaMaj( $chaine ) { + 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, + utf8_decode($chaine))); + } - public function getClefAlpha($type_doc,$titre,$complement_titre,$auteur,$tome,$editeur,$annee) - { - $clef=$this->getClefOeuvre($titre,$complement_titre,$auteur,$tome).'-'; - $clef.=substr($this->alphaMaj(str_replace(' ','',$editeur)),0,80).'-'; - $clef.=$annee.'-'; - $clef.=$type_doc; - $clef=str_replace(' ','',$clef); - return $clef; - } + + public function getClefAlpha($type_doc,$titre,$complement_titre,$auteur,$tome,$editeur,$annee) + { + $clef=$this->getClefOeuvre($titre,$complement_titre,$auteur,$tome).'-'; + $clef.=substr($this->alphaMaj(str_replace(' ','',$editeur)),0,80).'-'; + $clef.=$annee.'-'; + $clef.=$type_doc; + $clef=str_replace(' ','',$clef); + return $clef; + } // Rend une clef alpha pour les oeuvres - public function getClefOeuvre($titre,$complement_titre,$auteur,$tome) - { - $clef = substr($this->codeAlphaTitre(strtoupper(str_replace(' ','',$titre))),0,80).'-'; - $clef.=substr($this->codeAlphaTitre(strtoupper(str_replace(' ','',$complement_titre))),0,20).'-'; - $clef.=substr($this->alphaMaj(str_replace(' ','',$auteur)),0,80).'-'; - $clef.=$this->alphaMaj($tome); - $clef=str_replace(' ','',$clef); - return $clef; - } + public function getClefOeuvre($titre,$complement_titre,$auteur,$tome) + { + $clef = substr($this->codeAlphaTitre(strtoupper(str_replace(' ','',$titre))),0,80).'-'; + $clef.=substr($this->codeAlphaTitre(strtoupper(str_replace(' ','',$complement_titre))),0,20).'-'; + $clef.=substr($this->alphaMaj(str_replace(' ','',$auteur)),0,80).'-'; + $clef.=$this->alphaMaj($tome); + $clef=str_replace(' ','',$clef); + return $clef; + } // Decoupe une expression en mots en tenant compte des exclusions / inclusions - public function getMots( $chaine ) { - $new = []; - $chaine = str_replace( '.', '', $chaine); - $chaine = trim($this->alphaMaj($chaine)); - $words = explode(' ', $chaine); - - foreach($words as $word) { - if(strlen($word) < 3 && intVal($word) == false) { - if(false == in_array($word, $this->inclu)) - continue; - - if( 1 == strlen($word)) - $word .= '00'; - } - - if(true == in_array($word, $this->exclu)) + public function getMots( $chaine ) { + $new = []; + $chaine = str_replace( '.', '', $chaine); + $chaine = trim($this->alphaMaj($chaine)); + $words = explode(' ', $chaine); + + foreach($words as $word) { + if(strlen($word) < 3 && intVal($word) == false) { + if(false == in_array($word, $this->inclu)) continue; - $new[] = $word; + if( 1 == strlen($word)) + $word .= '00'; } - return $new; + if(true == in_array($word, $this->exclu)) + continue; + + $new[] = $word; } + return $new; + } + // Rend une chaine de mots dedoublonnes et filtres - public function getFulltext($data) { - if (gettype($data) != 'array') - $data=array($data); - - $new=' '; - foreach($data as $chaine) - { - $mots=$this->getMots($chaine); - foreach($mots as $mot) - { - $mot=' '.$mot.' '; - if(strpos($new,$mot) === false ) - { - $new.=trim($mot).' '; - $phonem=' '.$this->phonetix(trim($mot)).' '; - if($phonem and strpos($new,$phonem) === false ) $new.=trim($phonem).' '; - } - } - } - return trim($new); - } + public function getFulltext($data) { + if (gettype($data) != 'array') + $data=array($data); + + $new=' '; + foreach($data as $chaine) + { + $mots=$this->getMots($chaine); + foreach($mots as $mot) + { + $mot=' '.$mot.' '; + if(strpos($new,$mot) === false ) + { + $new.=trim($mot).' '; + $phonem=' '.$this->phonetix(trim($mot)).' '; + if($phonem and strpos($new,$phonem) === false ) $new.=trim($phonem).' '; + } + } + } + return trim($new); + } // Rend le mot au singulier et au pluriel - public function getPluriel( $mot ) - { - if( strToUpper($mot) != $mot ) $mot=$this->alphaMaj($mot); - if(!trim($mot)) return false; - foreach($this->pluriel as $regle) - { - if(strLeft($regle[0],1) != '*') - { - if($mot==$regle[0] or $mot==$regle[1]) return $regle; - else continue; - } - $regle[0]=str_replace('*','',$regle[0]); - $regle[1]=str_replace('*','',$regle[1]); - $pattern_singulier = '('.$regle[0].'$)'; - $pattern_pluriel='('.$regle[1].'$)'; - - $pluriel=ereg_replace($pattern_singulier, $regle[1], $mot); - $singulier=ereg_replace($pattern_pluriel, $regle[0], $mot); - if($singulier != $mot or $pluriel != $mot) break; - } - // Si inchangé on ajoute le S - if($singulier == $pluriel) - { - if(strRight($mot,1)=='S') {$pluriel=$singulier; $singulier=strLeft($singulier,strlen($singulier)-1);} - else $pluriel=$singulier.'S'; - } - return array($singulier,$pluriel); - } + public function getPluriel( $mot ) + { + if( strToUpper($mot) != $mot ) $mot=$this->alphaMaj($mot); + if(!trim($mot)) return false; + foreach($this->pluriel as $regle) + { + if(strLeft($regle[0],1) != '*') + { + if($mot==$regle[0] or $mot==$regle[1]) return $regle; + else continue; + } + $regle[0]=str_replace('*','',$regle[0]); + $regle[1]=str_replace('*','',$regle[1]); + $pattern_singulier = '('.$regle[0].'$)'; + $pattern_pluriel='('.$regle[1].'$)'; + + $pluriel=ereg_replace($pattern_singulier, $regle[1], $mot); + $singulier=ereg_replace($pattern_pluriel, $regle[0], $mot); + if($singulier != $mot or $pluriel != $mot) break; + } + // Si inchangé on ajoute le S + if($singulier == $pluriel) + { + if(strRight($mot,1)=='S') {$pluriel=$singulier; $singulier=strLeft($singulier,strlen($singulier)-1);} + else $pluriel=$singulier.'S'; + } + return array($singulier,$pluriel); + } // --------------------------------------------------- // Rend true si mot inclu // --------------------------------------------------- - public function isMotInclu($mot) - { - return in_array($mot, $this->inclu); - } + public function isMotInclu($mot) + { + return in_array($mot, $this->inclu); + } // --------------------------------------------------- // Othographe approchante // --------------------------------------------------- - function phonetix($sIn) { - if (strlen($sIn)<4 || is_numeric($sIn)) - return false; - return $this->phonetixCompute($sIn); - } + function phonetix($sIn) { + if (strlen($sIn)<4 || is_numeric($sIn)) + return false; + return $this->phonetixCompute($sIn); + } - 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 = strtoupper( $sIn ); // on passe tout le reste en majuscules - $sIn = preg_replace( '`[^A-Z]`', '', $sIn ); // on garde uniquement les lettres de A à Z - - $sBack=$sIn; // on sauve le code (utilisé pour les mots très courts) - - $sIn = preg_replace( '`O[O]+`', 'OU', $sIn ); // pré traitement OO... -> OU - $sIn = str_replace( 'SAOU', 'SOU', $sIn ); // pré traitement SAOU -> SOU - $sIn = str_replace( 'OES', 'OS', $sIn ); // pré traitement OES -> OS - $sIn = str_replace( 'CCH', 'K', $sIn ); // pré traitement CCH -> K - $sIn = preg_replace( '`CC([IYE])`', 'KS$1', $sIn ); // CCI CCY CCE - $sIn = preg_replace( '`(.)\1`', '$1', $sIn ); // supression des répétitions - - // quelques cas particuliers - if ($sIn=='CD') return($sIn); - if ($sIn=='BD') return($sIn); - if ($sIn=='BV') return($sIn); - if ($sIn=='TABAC') return('TABA'); - if ($sIn=='FEU') return('FE'); - if ($sIn=='FE') return($sIn); - if ($sIn=='FER') return($sIn); - if ($sIn=='FIEF') return($sIn); - if ($sIn=='FJORD') return($sIn); - if ($sIn=='GOAL') return('GOL'); - if ($sIn=='FLEAU') return('FLEO'); - if ($sIn=='HIER') return('IER'); - if ($sIn=='HEU') return('E'); - if ($sIn=='HE') return('E'); - if ($sIn=='OS') return($sIn); - if ($sIn=='RIZ') return('RI'); - if ($sIn=='RAZ') return('RA'); - - // pré-traitements - $sIn = preg_replace( '`OIN[GT]$`', 'OIN', $sIn ); // terminaisons OING -> OIN - $sIn = preg_replace( '`E[RS]$`', 'E', $sIn ); // supression des terminaisons infinitifs et participes pluriels - $sIn = preg_replace( '`(C|CH)OEU`', 'KE', $sIn ); // pré traitement OEU -> EU - $sIn = str_replace( 'MOEU', 'ME', $sIn ); // pré traitement OEU -> EU - $sIn = preg_replace( '`OE([UI]+)([BCDFGHJKLMNPQRSTVWXZ])`', 'E$1$2', $sIn ); // pré traitement OEU OEI -> E - $sIn = preg_replace( '`^GEN[TS]$`', 'JAN', $sIn ); // pré traitement GEN -> JAN - $sIn = str_replace( 'CUEI', 'KEI', $sIn ); // pré traitement accueil - $sIn = preg_replace( '`([^AEIOUYC])AE([BCDFGHJKLMNPQRSTVWXZ])`', '$1E$2', $sIn ); // pré traitement AE -> E - $sIn = preg_replace( '`AE([QS])`', 'E$1', $sIn ); // pré traitement AE -> E - $sIn = preg_replace( '`AIE([BCDFGJKLMNPQRSTVWXZ])`', 'AI$1', $sIn ); // pré-traitement AIE(consonne) -> AI - $sIn = str_replace( 'ANIEM', 'ANIM', $sIn ); // pré traitement NIEM -> NIM - $sIn = preg_replace( '`(DRA|TRO|IRO)P$`', '$1', $sIn ); // P terminal muet - $sIn = preg_replace( '`(LOM)B$`', '$1', $sIn ); // B terminal muet - $sIn = preg_replace( '`(RON|POR)C$`', '$1', $sIn ); // C terminal muet - $sIn = preg_replace( '`PECT$`', 'PET', $sIn ); // C terminal muet - $sIn = preg_replace( '`ECUL$`', 'CU', $sIn ); // L terminal muet - $sIn = preg_replace( '`(CHA|CA|E)M(P|PS)$`', '$1N', $sIn ); // P ou PS terminal muet - $sIn = preg_replace( '`(TAN|RAN)G$`', '$1', $sIn ); // G terminal muet - - - // sons YEUX - $sIn = preg_replace( '`([^VO])ILAG`', '$1IAJ', $sIn ); - $sIn = preg_replace( '`([^TRH])UIL(AR|E)(.+)`', '$1UI$2$3', $sIn ); - $sIn = preg_replace( '`([G])UIL([AEO])`', '$1UI$2', $sIn ); - $sIn = preg_replace( '`([NSPM])AIL([AEO])`', '$1AI$2', $sIn ); - $convMIn = array('DILAI','DILON','DILER','DILEM','RILON','TAILE','GAILET','AILAI','AILAR', - 'OUILA','EILAI','EILAR','EILER','EILEM','REILET','EILET','AILOL' ); - $convMOut = array( 'DIAI', 'DION','DIER', 'DIEM', 'RION', 'TAIE', 'GAIET', 'AIAI', 'AIAR', - 'OUIA', 'AIAI', 'AIAR', 'AIER', 'AIEM', 'RAIET', 'EIET', 'AIOL' ); - $sIn = str_replace( $convMIn, $convMOut, $sIn ); - $sIn = preg_replace( '`([^AEIOUY])(SC|S)IEM([EA])`', '$1$2IAM$3', $sIn ); // IEM -> IAM - $sIn = preg_replace( '`^(SC|S)IEM([EA])`', '$1IAM$2', $sIn ); // IEM -> IAM - - // MP MB -> NP NB - $convMIn = array( 'OMB', 'AMB', 'OMP', 'AMP', 'IMB', 'EMP','GEMB','EMB', 'UMBL','CIEN'); - $convMOut = array( 'ONB', 'ANB', 'ONP', 'ANP', 'INB', 'ANP','JANB','ANB', 'INBL','SIAN'); - $sIn = str_replace( $convMIn, $convMOut, $sIn ); - - // Sons en K - $sIn = preg_replace( '`^ECHO$`', 'EKO', $sIn ); // cas particulier écho - $sIn = preg_replace( '`^ECEUR`', 'EKEUR', $sIn ); // cas particulier écÅ“uré - // Choléra ChÅ“ur mais pas chocolat! - $sIn = preg_replace( '`^CH(OG+|OL+|OR+|EU+|ARIS|M+|IRO|ONDR)`', 'K$1', $sIn ); //En début de mot - $sIn = preg_replace( '`(YN|RI)CH(OG+|OL+|OC+|OP+|OM+|ARIS|M+|IRO|ONDR)`', '$1K$2', $sIn ); //Ou devant une consonne - $sIn = preg_replace( '`CHS`', 'CH', $sIn ); - $sIn = preg_replace( '`CH(AIQ)`', 'K$1', $sIn ); - $sIn = preg_replace( '`^ECHO([^UIPY])`', 'EKO$1', $sIn ); - $sIn = preg_replace( '`ISCH(I|E)`', 'ISK$1', $sIn ); - $sIn = preg_replace( '`^ICHT`', 'IKT', $sIn ); - $sIn = preg_replace( '`ORCHID`', 'ORKID', $sIn ); - $sIn = preg_replace( '`ONCHIO`', 'ONKIO', $sIn ); - $sIn = preg_replace( '`ACHIA`', 'AKIA', $sIn ); // retouche ACHIA -> AKIA - $sIn = preg_replace( '`([^C])ANICH`', '$1ANIK', $sIn ); // ANICH -> ANIK 1/2 - $sIn = preg_replace( '`OMANIK`', 'OMANICH', $sIn ); // cas particulier 2/2 - $sIn = preg_replace( '`ACHY([^D])`', 'AKI$1', $sIn ); - $sIn = preg_replace( '`([AEIOU])C([BDFGJKLMNPQRTVWXZ])`', '$1K$2', $sIn ); // voyelle, C, consonne sauf H - $convPrIn = array('EUCHA','YCHIA','YCHA','YCHO','YCHED','ACHEO','RCHEO','RCHES', - 'ECHN','OCHTO','CHORA','CHONDR','CHORE','MACHM','BRONCHO','LICHOS','LICHOC'); - $convPrOut = array('EKA', 'IKIA', 'IKA', 'IKO', 'IKED','AKEO','RKEO', 'RKES', - 'EKN', 'OKTO', 'KORA', 'KONDR' ,'KORE' ,'MAKM', 'BRONKO', 'LIKOS', 'LIKOC'); - $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); - - // Weuh (perfectible) - $convPrIn = array( 'WA','WO', 'WI','WHI','WHY','WHA','WHO'); - $convPrOut = array( 'OI', 'O','OUI','OUI','OUI','OUA', 'OU'); - $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); - - // Gueu, Gneu, Jeu et quelques autres - $convPrIn = array( 'GNES','GNET','GNER','GNE', 'GI', 'GNI','GNA','GNOU','GNUR','GY','OUGAIN', - 'AGEOL', 'AGEOT','GEOLO','GEOM','GEOP','GEOG','GEOS','GEORG','GEOR','NGEOT','UGEOT','GEOT','GEOD','GEOC','GEO','GEA','GE', - 'QU', 'Q', 'CY', 'CI', 'CN','ICM','CEAT','CE', - 'CR', 'CO', 'CUEI','CU', 'VENCA','CA', 'CS','CLEN','CL', 'CZ', 'CTIQ', - 'CTIF','CTIC','CTIS','CTIL','CTIO','CTI', 'CTU', 'CTE','CTO','CTR','CT', 'PH', 'TH', - 'OW', 'LH', 'RDL', 'CHLO', 'CHR', 'PTIA'); - $convPrOut = array( 'NIES','NIET','NIER', 'NE', 'JI', 'NI','NIA','NIOU','NIUR','JI','OUGIN', - 'AJOL', 'AJOT','JEOLO','JEOM','JEOP','JEOG','JEOS','JORJ','JEOR','NJOT','UJOT','JEOT','JEOD','JEOC', 'JO','JA' ,'JE', - 'K', 'K', 'SI', 'SI', 'KN','IKM', 'SAT','SE', - 'KR', 'KO', 'KEI','KU', 'VANSA','KA', 'KS','KLAN','KL', 'KZ', 'KTIK', - 'KTIF','KTIS','KTIS','KTIL','KSIO','KTI', 'KTU', 'KTE','KTO','KTR','KT', 'F', 'T', - 'OU', 'L', 'RL', 'KLO', 'KR', 'PSIA'); - $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); - - $sIn = preg_replace( '`GU([^RLMBSTPZN])`', 'G$1', $sIn ); // Gueu ! - $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // GNO ! Tout sauf S pour gnos - $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // bis -> gnognotte! Si quelqu'un sait le faire en une seule regexp... - - - // TI -> SI v2.0 - $convPrIn = array( 'BUTIE','BUTIA','BATIA','ANTIEL','RETION','ENTIEL','ENTIAL','ENTIO','ENTIAI','UJETION','ATIEM','PETIEN', - 'CETIE','OFETIE','IPETI','LBUTION','BLUTION','LETION','LATION','SATIET'); - $convPrOut = array( 'BUSIE','BUSIA','BASIA','ANSIEL','RESION','ENSIEL','ENSIAL','ENSIO','ENSIAI','UJESION','ASIAM','PESIEN', - 'CESIE','OFESIE','IPESI','LBUSION','BLUSION','LESION','LASION','SASIET'); - $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); - $sIn = preg_replace( '`(.+)ANTI(AL|O)`', '$1ANSI$2', $sIn ); // sauf antialcoolique, antialbumine, antialarmer, ... - $sIn = preg_replace( '`(.+)INUTI([^V])`', '$1INUSI$2', $sIn ); // sauf inutilité, inutilement, diminutive, ... - $sIn = preg_replace( '`([^O])UTIEN`', '$1USIEN', $sIn ); // sauf soutien, ... - $sIn = preg_replace( '`([^DE])RATI[E]$`', '$1RASI$2', $sIn ); // sauf xxxxxcratique, ... - // TIEN TION -> SIEN SION v3.1 - $sIn = preg_replace( '`([^SNEU]|KU|KO|RU|LU|BU|TU|AU)T(IEN|ION)`', '$1S$2', $sIn ); - - - // H muet - $sIn = preg_replace( '`([^CS])H`', '$1', $sIn ); // H muet - $sIn = str_replace( 'ESH', 'ES', $sIn ); // H muet - $sIn = str_replace( 'NSH', 'NS', $sIn ); // H muet - $sIn = str_replace( 'SH', 'CH', $sIn ); // ou pas! - - // NASALES - $convNasIn = array( 'OMT','IMB', 'IMP','UMD','TIENT','RIENT','DIENT','IEN', - 'YMU','YMO','YMA','YME', 'YMI','YMN','YM', 'AHO','FAIM','DAIM','SAIM','EIN','AINS'); - $convNasOut = array( 'ONT','INB', 'INP','OND','TIANT','RIANT','DIANT', 'IN', - 'IMU','IMO','IMA','IME', 'IMI','IMN','IN', 'AO', 'FIN','DIN', 'SIN','AIN','INS'); - $sIn = str_replace( $convNasIn, $convNasOut, $sIn ); - // AIN -> IN v2.0 - $sIn = preg_replace( '`AIN$`', 'IN', $sIn ); - $sIn = preg_replace( '`AIN([BTDK])`', 'IN$1', $sIn ); - // UN -> IN - $sIn = preg_replace( '`([^O])UND`', '$1IND', $sIn ); // aucun mot français ne commence par UND! - $sIn = preg_replace( '`([JTVLFMRPSBD])UN([^IAE])`', '$1IN$2', $sIn ); - $sIn = preg_replace( '`([JTVLFMRPSBD])UN$`', '$1IN', $sIn ); - $sIn = preg_replace( '`RFUM$`', 'RFIN', $sIn ); - $sIn = str_replace( 'LUMB', 'LINB', $sIn ); - // EN -> AN - $sIn = preg_replace( '`([^BCDFGHJKLMNPQRSTVWXZ])EN`', '$1AN', $sIn ); - $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // deux fois pour les motifs recouvrants malentendu, pendentif, ... - $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // si quelqu'un sait faire avec une seule regexp! - $sIn = preg_replace( '`^EN([BCDFGHJKLNPQRSTVXZ]|CH|IV|ORG|OB|UI|UA|UY)`', 'AN$1', $sIn ); - $sIn = preg_replace( '`(^[JRVTH])EN([DRTFGSVJMP])`', '$1AN$2', $sIn ); - $sIn = preg_replace( '`SEN([ST])`', 'SAN$1', $sIn ); - $sIn = preg_replace( '`^DESENIV`', 'DESANIV', $sIn ); - $sIn = preg_replace( '`([^M])EN(UI)`', '$1AN$2', $sIn ); - $sIn = preg_replace( '`(.+[JTVLFMRPSBD])EN([JLFDSTG])`', '$1AN$2', $sIn ); - // EI -> AI - $sIn = preg_replace( '`([VSBSTNRLPM])E[IY]([ACDFRJLGZ])`', '$1AI$2', $sIn ); - - // Histoire d'Ô - $convNasIn = array( 'EAU', 'EU', 'Y', 'EOI', 'JEA','OIEM','OUANJ','OUA','OUENJ'); - $convNasOut = array( 'O', 'E', 'I', 'OI', 'JA' ,'OIM' ,'OUENJ', 'OI','OUANJ'); - $sIn = str_replace( $convNasIn, $convNasOut, $sIn ); - $sIn = preg_replace( '`AU([^E])`', 'O$1', $sIn ); // AU sans E qui suit - - // Les retouches! - $sIn = preg_replace( '`^BENJ`', 'BINJ', $sIn ); // retouche BENJ -> BINJ - $sIn = str_replace( 'RTIEL', 'RSIEL', $sIn ); // retouche RTIEL -> RSIEL - $sIn = str_replace( 'PINK', 'PONK', $sIn ); // retouche PINK -> PONK - $sIn = str_replace( 'KIND', 'KOND', $sIn ); // retouche KIND -> KOND - $sIn = preg_replace( '`KUM(N|P)`', 'KON$1', $sIn ); // retouche KUMN KUMP - $sIn = str_replace( 'LKOU', 'LKO', $sIn ); // retouche LKOU -> LKO - $sIn = str_replace( 'EDBE', 'EBE', $sIn ); // retouche EDBE pied-bÅ“uf - $sIn = str_replace( 'ARCM', 'ARKM', $sIn ); // retouche SCH -> CH - $sIn = str_replace( 'SCH', 'CH', $sIn ); // retouche SCH -> CH - $sIn = preg_replace( '`^OINI`', 'ONI', $sIn ); // retouche début OINI -> ONI - $sIn = preg_replace( '`([^NDCGRHKO])APT`', '$1AT', $sIn ); // retouche APT -> AT - $sIn = preg_replace( '`([L]|KON)PT`', '$1T', $sIn ); // retouche LPT -> LT - $sIn = str_replace( 'OTB', 'OB', $sIn ); // retouche OTB -> OB (hautbois) - $sIn = str_replace( 'IXA', 'ISA', $sIn ); // retouche IXA -> ISA - $sIn = str_replace( 'TG', 'G', $sIn ); // retouche TG -> G - $sIn = preg_replace( '`^TZ`', 'TS', $sIn ); // retouche début TZ -> TS - $sIn = str_replace( 'PTIE', 'TIE', $sIn ); // retouche PTIE -> TIE - $sIn = str_replace( 'GT', 'T', $sIn ); // retouche GT -> T - $sIn = str_replace( 'ANKIEM', 'ANKILEM', $sIn ); // retouche tranquillement - $sIn = preg_replace( '`(LO|RE)KEMAN`', '$1KAMAN', $sIn ); // KEMAN -> KAMAN - $sIn = preg_replace( '`NT(B|M)`', 'N$1', $sIn ); // retouche TB -> B TM -> M - $sIn = str_replace( 'GSU', 'SU', $sIn ); // retouche GS -> SU - $sIn = str_replace( 'ESD', 'ED', $sIn ); // retouche ESD -> ED - $sIn = str_replace( 'LESKEL', 'LEKEL', $sIn ); // retouche LESQUEL -> LEKEL - $sIn = str_replace( 'CK', 'K', $sIn ); // retouche CK -> K - - // Terminaisons - $sIn = preg_replace( '`USIL$`', 'USI', $sIn ); // terminaisons USIL -> USI - $sIn = preg_replace( '`X$|[TD]S$|[DS]$`', '', $sIn ); // terminaisons TS DS LS X T D S... v2.0 - $sIn = preg_replace( '`([^KL]+)T$`', '$1', $sIn ); // sauf KT LT terminal - $sIn = preg_replace( '`^[H]`', '', $sIn ); // H pseudo muet en début de mot, je sais, ce n'est pas une terminaison - $sBack2=$sIn; // on sauve le code (utilisé pour les mots très courts) - - $convPartIn = [ - '`TIL$`', // terminaisons TIL -> TI - '`LC$`', // terminaisons LC -> LK - '`L[E]?[S]?$`', // terminaisons LE LES -> L - '`(.+)N[E]?[S]?$`', // terminaisons NE NES -> N - '`EZ$`', // terminaisons EZ -> E - '`OIG$`', // terminaisons OIG -> OI - '`OUP$`', // terminaisons OUP -> OU - '`([^R])OM$`', // terminaisons OM -> ON sauf ROM - '`LOP$`', // terminaisons LOP -> LO - '`NTANP$`', // terminaisons NTANP -> NTAN - '`TUN$`', // terminaisons TUN -> TIN - '`AU$`', // terminaisons AU -> O - '`EI$`', // terminaisons EI -> AI - '`R[DG]$`', // terminaisons RD RG -> R - '`ANC$`', // terminaisons ANC -> AN - '`KROC$`', // terminaisons C muet de CROC, ESCROC - '`HOUC$`', // terminaisons C muet de CAOUTCHOUC - '`OMAC$`', // terminaisons C muet de ESTOMAC (mais pas HAMAC) - '`([J])O([NU])[CG]$`',// terminaisons C et G muet de OUC ONC OUG - '`([^GTR])([AO])NG$`',// terminaisons G muet ANG ONG sauf GANG GONG TANG TONG - '`UC$`', // terminaisons UC -> UK - '`AING$`', // terminaisons AING -> IN - '`([EISOARN])C$`', // terminaisons C -> K - '`([ABD-MO-Z]+)[EH]+$`', // terminaisons E ou H sauf pour C et N - '`EN$`', // terminaisons EN -> AN (difficile à faire avant sans avoir des soucis) Et encore, - '`(NJ)EN$`',// terminaisons EN -> AN - '`^PAIEM`', // PAIE -> PAI - '`([^NTB])EF$`', // F muet en fin de mot - '`(.)\1`' // supression des répétitions (suite à certains remplacements) - ]; - - $convPartOut = [ - 'TI', // terminaisons TIL -> TI - 'LK', // terminaisons LC -> LK - 'L', // terminaisons LE LES -> L - '$1N', // terminaisons NE NES -> N - 'E', // terminaisons EZ -> E - 'OI', // terminaisons OIG -> OI - 'OU', // terminaisons OUP -> OU - '$1ON', // terminaisons OM -> ON sauf ROM - 'LO', // terminaisons LOP -> LO - 'NTAN', // terminaisons NTANP -> NTAN - 'TIN', // terminaisons TUN -> TIN - 'O', // terminaisons AU -> O - 'AI', // terminaisons EI -> AI - 'R', // terminaisons RD RG -> R - 'AN', // terminaisons ANC -> AN - 'KRO', // terminaisons C muet de CROC, ESCROC - 'HOU', // terminaisons C muet de CAOUTCHOUC - 'OMA', // terminaisons C muet de ESTOMAC (mais pas HAMAC) - '$1O$2',// terminaisons C et G muet de OUC ONC OUG - '$1$2N',// terminaisons G muet ANG ONG sauf GANG GONG TANG TONG - 'UK', // terminaisons UC -> UK - 'IN', // terminaisons AING -> IN - '$1K', // terminaisons C -> K - '$1', // terminaisons E ou H sauf pour C et N - 'AN', // terminaisons EN -> AN (difficile à faire avant sans avoir des soucis) Et encore, c'est pas top! - '$1AN', // terminaisons EN -> AN - 'PAIM', // PAIE -> PAI - '\1', // F muet en fin de mot - '$1' // supression des répétitions (suite à certains remplacements) - ]; - - $sIn = preg_replace( $convPartIn, $convPartOut, $sIn ); - - // cas particuliers, bah au final, je n'en ai qu'un ici - $convPartIn = array( 'FUEL'); - $convPartOut = array( 'FIOUL'); - $sIn = str_replace( $convPartIn, $convPartOut, $sIn ); - - // Ce sera le seul code retourné à une seule lettre! - if ($sIn=='O') return($sIn); - - // seconde chance sur les mots courts qui ont souffert de la simplification - if (strlen($sIn)<2) - { - // Sigles ou abréviations - if (preg_match('`[BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ]*`',$sBack)) - return($sBack); - - if (preg_match('`[RFMLVSPJDF][AEIOU]`',$sBack)) - { - if (strlen($sBack)==3) - return(substr($sBack,0,2));// mots de trois lettres supposés simples - if (strlen($sBack)==4) - return(substr($sBack,0,3));// mots de quatre lettres supposés simples - } - - if (strlen($sBack2)>1) return $sBack2; - } - if (strlen($sIn)>1) - { - return substr($sIn,0,16); // Je limite à 16 caractères mais vous faites comme vous voulez! - } - else return ''; - } + 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 = strtoupper( $sIn ); // on passe tout le reste en majuscules + $sIn = preg_replace( '`[^A-Z]`', '', $sIn ); // on garde uniquement les lettres de A à Z + + $sBack=$sIn; // on sauve le code (utilisé pour les mots très courts) + + $sIn = preg_replace( '`O[O]+`', 'OU', $sIn ); // pré traitement OO... -> OU + $sIn = str_replace( 'SAOU', 'SOU', $sIn ); // pré traitement SAOU -> SOU + $sIn = str_replace( 'OES', 'OS', $sIn ); // pré traitement OES -> OS + $sIn = str_replace( 'CCH', 'K', $sIn ); // pré traitement CCH -> K + $sIn = preg_replace( '`CC([IYE])`', 'KS$1', $sIn ); // CCI CCY CCE + $sIn = preg_replace( '`(.)\1`', '$1', $sIn ); // supression des répétitions + + // quelques cas particuliers + if ($sIn=='CD') return($sIn); + if ($sIn=='BD') return($sIn); + if ($sIn=='BV') return($sIn); + if ($sIn=='TABAC') return('TABA'); + if ($sIn=='FEU') return('FE'); + if ($sIn=='FE') return($sIn); + if ($sIn=='FER') return($sIn); + if ($sIn=='FIEF') return($sIn); + if ($sIn=='FJORD') return($sIn); + if ($sIn=='GOAL') return('GOL'); + if ($sIn=='FLEAU') return('FLEO'); + if ($sIn=='HIER') return('IER'); + if ($sIn=='HEU') return('E'); + if ($sIn=='HE') return('E'); + if ($sIn=='OS') return($sIn); + if ($sIn=='RIZ') return('RI'); + if ($sIn=='RAZ') return('RA'); + + // pré-traitements + $sIn = preg_replace( '`OIN[GT]$`', 'OIN', $sIn ); // terminaisons OING -> OIN + $sIn = preg_replace( '`E[RS]$`', 'E', $sIn ); // supression des terminaisons infinitifs et participes pluriels + $sIn = preg_replace( '`(C|CH)OEU`', 'KE', $sIn ); // pré traitement OEU -> EU + $sIn = str_replace( 'MOEU', 'ME', $sIn ); // pré traitement OEU -> EU + $sIn = preg_replace( '`OE([UI]+)([BCDFGHJKLMNPQRSTVWXZ])`', 'E$1$2', $sIn ); // pré traitement OEU OEI -> E + $sIn = preg_replace( '`^GEN[TS]$`', 'JAN', $sIn ); // pré traitement GEN -> JAN + $sIn = str_replace( 'CUEI', 'KEI', $sIn ); // pré traitement accueil + $sIn = preg_replace( '`([^AEIOUYC])AE([BCDFGHJKLMNPQRSTVWXZ])`', '$1E$2', $sIn ); // pré traitement AE -> E + $sIn = preg_replace( '`AE([QS])`', 'E$1', $sIn ); // pré traitement AE -> E + $sIn = preg_replace( '`AIE([BCDFGJKLMNPQRSTVWXZ])`', 'AI$1', $sIn ); // pré-traitement AIE(consonne) -> AI + $sIn = str_replace( 'ANIEM', 'ANIM', $sIn ); // pré traitement NIEM -> NIM + $sIn = preg_replace( '`(DRA|TRO|IRO)P$`', '$1', $sIn ); // P terminal muet + $sIn = preg_replace( '`(LOM)B$`', '$1', $sIn ); // B terminal muet + $sIn = preg_replace( '`(RON|POR)C$`', '$1', $sIn ); // C terminal muet + $sIn = preg_replace( '`PECT$`', 'PET', $sIn ); // C terminal muet + $sIn = preg_replace( '`ECUL$`', 'CU', $sIn ); // L terminal muet + $sIn = preg_replace( '`(CHA|CA|E)M(P|PS)$`', '$1N', $sIn ); // P ou PS terminal muet + $sIn = preg_replace( '`(TAN|RAN)G$`', '$1', $sIn ); // G terminal muet + + + // sons YEUX + $sIn = preg_replace( '`([^VO])ILAG`', '$1IAJ', $sIn ); + $sIn = preg_replace( '`([^TRH])UIL(AR|E)(.+)`', '$1UI$2$3', $sIn ); + $sIn = preg_replace( '`([G])UIL([AEO])`', '$1UI$2', $sIn ); + $sIn = preg_replace( '`([NSPM])AIL([AEO])`', '$1AI$2', $sIn ); + $convMIn = array('DILAI','DILON','DILER','DILEM','RILON','TAILE','GAILET','AILAI','AILAR', + 'OUILA','EILAI','EILAR','EILER','EILEM','REILET','EILET','AILOL' ); + $convMOut = array( 'DIAI', 'DION','DIER', 'DIEM', 'RION', 'TAIE', 'GAIET', 'AIAI', 'AIAR', + 'OUIA', 'AIAI', 'AIAR', 'AIER', 'AIEM', 'RAIET', 'EIET', 'AIOL' ); + $sIn = str_replace( $convMIn, $convMOut, $sIn ); + $sIn = preg_replace( '`([^AEIOUY])(SC|S)IEM([EA])`', '$1$2IAM$3', $sIn ); // IEM -> IAM + $sIn = preg_replace( '`^(SC|S)IEM([EA])`', '$1IAM$2', $sIn ); // IEM -> IAM + + // MP MB -> NP NB + $convMIn = array( 'OMB', 'AMB', 'OMP', 'AMP', 'IMB', 'EMP','GEMB','EMB', 'UMBL','CIEN'); + $convMOut = array( 'ONB', 'ANB', 'ONP', 'ANP', 'INB', 'ANP','JANB','ANB', 'INBL','SIAN'); + $sIn = str_replace( $convMIn, $convMOut, $sIn ); + + // Sons en K + $sIn = preg_replace( '`^ECHO$`', 'EKO', $sIn ); // cas particulier écho + $sIn = preg_replace( '`^ECEUR`', 'EKEUR', $sIn ); // cas particulier écÅ“uré + // Choléra ChÅ“ur mais pas chocolat! + $sIn = preg_replace( '`^CH(OG+|OL+|OR+|EU+|ARIS|M+|IRO|ONDR)`', 'K$1', $sIn ); //En début de mot + $sIn = preg_replace( '`(YN|RI)CH(OG+|OL+|OC+|OP+|OM+|ARIS|M+|IRO|ONDR)`', '$1K$2', $sIn ); //Ou devant une consonne + $sIn = preg_replace( '`CHS`', 'CH', $sIn ); + $sIn = preg_replace( '`CH(AIQ)`', 'K$1', $sIn ); + $sIn = preg_replace( '`^ECHO([^UIPY])`', 'EKO$1', $sIn ); + $sIn = preg_replace( '`ISCH(I|E)`', 'ISK$1', $sIn ); + $sIn = preg_replace( '`^ICHT`', 'IKT', $sIn ); + $sIn = preg_replace( '`ORCHID`', 'ORKID', $sIn ); + $sIn = preg_replace( '`ONCHIO`', 'ONKIO', $sIn ); + $sIn = preg_replace( '`ACHIA`', 'AKIA', $sIn ); // retouche ACHIA -> AKIA + $sIn = preg_replace( '`([^C])ANICH`', '$1ANIK', $sIn ); // ANICH -> ANIK 1/2 + $sIn = preg_replace( '`OMANIK`', 'OMANICH', $sIn ); // cas particulier 2/2 + $sIn = preg_replace( '`ACHY([^D])`', 'AKI$1', $sIn ); + $sIn = preg_replace( '`([AEIOU])C([BDFGJKLMNPQRTVWXZ])`', '$1K$2', $sIn ); // voyelle, C, consonne sauf H + $convPrIn = array('EUCHA','YCHIA','YCHA','YCHO','YCHED','ACHEO','RCHEO','RCHES', + 'ECHN','OCHTO','CHORA','CHONDR','CHORE','MACHM','BRONCHO','LICHOS','LICHOC'); + $convPrOut = array('EKA', 'IKIA', 'IKA', 'IKO', 'IKED','AKEO','RKEO', 'RKES', + 'EKN', 'OKTO', 'KORA', 'KONDR' ,'KORE' ,'MAKM', 'BRONKO', 'LIKOS', 'LIKOC'); + $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); + + // Weuh (perfectible) + $convPrIn = array( 'WA','WO', 'WI','WHI','WHY','WHA','WHO'); + $convPrOut = array( 'OI', 'O','OUI','OUI','OUI','OUA', 'OU'); + $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); + + // Gueu, Gneu, Jeu et quelques autres + $convPrIn = array( 'GNES','GNET','GNER','GNE', 'GI', 'GNI','GNA','GNOU','GNUR','GY','OUGAIN', + 'AGEOL', 'AGEOT','GEOLO','GEOM','GEOP','GEOG','GEOS','GEORG','GEOR','NGEOT','UGEOT','GEOT','GEOD','GEOC','GEO','GEA','GE', + 'QU', 'Q', 'CY', 'CI', 'CN','ICM','CEAT','CE', + 'CR', 'CO', 'CUEI','CU', 'VENCA','CA', 'CS','CLEN','CL', 'CZ', 'CTIQ', + 'CTIF','CTIC','CTIS','CTIL','CTIO','CTI', 'CTU', 'CTE','CTO','CTR','CT', 'PH', 'TH', + 'OW', 'LH', 'RDL', 'CHLO', 'CHR', 'PTIA'); + $convPrOut = array( 'NIES','NIET','NIER', 'NE', 'JI', 'NI','NIA','NIOU','NIUR','JI','OUGIN', + 'AJOL', 'AJOT','JEOLO','JEOM','JEOP','JEOG','JEOS','JORJ','JEOR','NJOT','UJOT','JEOT','JEOD','JEOC', 'JO','JA' ,'JE', + 'K', 'K', 'SI', 'SI', 'KN','IKM', 'SAT','SE', + 'KR', 'KO', 'KEI','KU', 'VANSA','KA', 'KS','KLAN','KL', 'KZ', 'KTIK', + 'KTIF','KTIS','KTIS','KTIL','KSIO','KTI', 'KTU', 'KTE','KTO','KTR','KT', 'F', 'T', + 'OU', 'L', 'RL', 'KLO', 'KR', 'PSIA'); + $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); + + $sIn = preg_replace( '`GU([^RLMBSTPZN])`', 'G$1', $sIn ); // Gueu ! + $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // GNO ! Tout sauf S pour gnos + $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // bis -> gnognotte! Si quelqu'un sait le faire en une seule regexp... + + + // TI -> SI v2.0 + $convPrIn = array( 'BUTIE','BUTIA','BATIA','ANTIEL','RETION','ENTIEL','ENTIAL','ENTIO','ENTIAI','UJETION','ATIEM','PETIEN', + 'CETIE','OFETIE','IPETI','LBUTION','BLUTION','LETION','LATION','SATIET'); + $convPrOut = array( 'BUSIE','BUSIA','BASIA','ANSIEL','RESION','ENSIEL','ENSIAL','ENSIO','ENSIAI','UJESION','ASIAM','PESIEN', + 'CESIE','OFESIE','IPESI','LBUSION','BLUSION','LESION','LASION','SASIET'); + $sIn = str_replace( $convPrIn, $convPrOut, $sIn ); + $sIn = preg_replace( '`(.+)ANTI(AL|O)`', '$1ANSI$2', $sIn ); // sauf antialcoolique, antialbumine, antialarmer, ... + $sIn = preg_replace( '`(.+)INUTI([^V])`', '$1INUSI$2', $sIn ); // sauf inutilité, inutilement, diminutive, ... + $sIn = preg_replace( '`([^O])UTIEN`', '$1USIEN', $sIn ); // sauf soutien, ... + $sIn = preg_replace( '`([^DE])RATI[E]$`', '$1RASI$2', $sIn ); // sauf xxxxxcratique, ... + // TIEN TION -> SIEN SION v3.1 + $sIn = preg_replace( '`([^SNEU]|KU|KO|RU|LU|BU|TU|AU)T(IEN|ION)`', '$1S$2', $sIn ); + + + // H muet + $sIn = preg_replace( '`([^CS])H`', '$1', $sIn ); // H muet + $sIn = str_replace( 'ESH', 'ES', $sIn ); // H muet + $sIn = str_replace( 'NSH', 'NS', $sIn ); // H muet + $sIn = str_replace( 'SH', 'CH', $sIn ); // ou pas! + + // NASALES + $convNasIn = array( 'OMT','IMB', 'IMP','UMD','TIENT','RIENT','DIENT','IEN', + 'YMU','YMO','YMA','YME', 'YMI','YMN','YM', 'AHO','FAIM','DAIM','SAIM','EIN','AINS'); + $convNasOut = array( 'ONT','INB', 'INP','OND','TIANT','RIANT','DIANT', 'IN', + 'IMU','IMO','IMA','IME', 'IMI','IMN','IN', 'AO', 'FIN','DIN', 'SIN','AIN','INS'); + $sIn = str_replace( $convNasIn, $convNasOut, $sIn ); + // AIN -> IN v2.0 + $sIn = preg_replace( '`AIN$`', 'IN', $sIn ); + $sIn = preg_replace( '`AIN([BTDK])`', 'IN$1', $sIn ); + // UN -> IN + $sIn = preg_replace( '`([^O])UND`', '$1IND', $sIn ); // aucun mot français ne commence par UND! + $sIn = preg_replace( '`([JTVLFMRPSBD])UN([^IAE])`', '$1IN$2', $sIn ); + $sIn = preg_replace( '`([JTVLFMRPSBD])UN$`', '$1IN', $sIn ); + $sIn = preg_replace( '`RFUM$`', 'RFIN', $sIn ); + $sIn = str_replace( 'LUMB', 'LINB', $sIn ); + // EN -> AN + $sIn = preg_replace( '`([^BCDFGHJKLMNPQRSTVWXZ])EN`', '$1AN', $sIn ); + $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // deux fois pour les motifs recouvrants malentendu, pendentif, ... + $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // si quelqu'un sait faire avec une seule regexp! + $sIn = preg_replace( '`^EN([BCDFGHJKLNPQRSTVXZ]|CH|IV|ORG|OB|UI|UA|UY)`', 'AN$1', $sIn ); + $sIn = preg_replace( '`(^[JRVTH])EN([DRTFGSVJMP])`', '$1AN$2', $sIn ); + $sIn = preg_replace( '`SEN([ST])`', 'SAN$1', $sIn ); + $sIn = preg_replace( '`^DESENIV`', 'DESANIV', $sIn ); + $sIn = preg_replace( '`([^M])EN(UI)`', '$1AN$2', $sIn ); + $sIn = preg_replace( '`(.+[JTVLFMRPSBD])EN([JLFDSTG])`', '$1AN$2', $sIn ); + // EI -> AI + $sIn = preg_replace( '`([VSBSTNRLPM])E[IY]([ACDFRJLGZ])`', '$1AI$2', $sIn ); + + // Histoire d'Ô + $convNasIn = array( 'EAU', 'EU', 'Y', 'EOI', 'JEA','OIEM','OUANJ','OUA','OUENJ'); + $convNasOut = array( 'O', 'E', 'I', 'OI', 'JA' ,'OIM' ,'OUENJ', 'OI','OUANJ'); + $sIn = str_replace( $convNasIn, $convNasOut, $sIn ); + $sIn = preg_replace( '`AU([^E])`', 'O$1', $sIn ); // AU sans E qui suit + + // Les retouches! + $sIn = preg_replace( '`^BENJ`', 'BINJ', $sIn ); // retouche BENJ -> BINJ + $sIn = str_replace( 'RTIEL', 'RSIEL', $sIn ); // retouche RTIEL -> RSIEL + $sIn = str_replace( 'PINK', 'PONK', $sIn ); // retouche PINK -> PONK + $sIn = str_replace( 'KIND', 'KOND', $sIn ); // retouche KIND -> KOND + $sIn = preg_replace( '`KUM(N|P)`', 'KON$1', $sIn ); // retouche KUMN KUMP + $sIn = str_replace( 'LKOU', 'LKO', $sIn ); // retouche LKOU -> LKO + $sIn = str_replace( 'EDBE', 'EBE', $sIn ); // retouche EDBE pied-bÅ“uf + $sIn = str_replace( 'ARCM', 'ARKM', $sIn ); // retouche SCH -> CH + $sIn = str_replace( 'SCH', 'CH', $sIn ); // retouche SCH -> CH + $sIn = preg_replace( '`^OINI`', 'ONI', $sIn ); // retouche début OINI -> ONI + $sIn = preg_replace( '`([^NDCGRHKO])APT`', '$1AT', $sIn ); // retouche APT -> AT + $sIn = preg_replace( '`([L]|KON)PT`', '$1T', $sIn ); // retouche LPT -> LT + $sIn = str_replace( 'OTB', 'OB', $sIn ); // retouche OTB -> OB (hautbois) + $sIn = str_replace( 'IXA', 'ISA', $sIn ); // retouche IXA -> ISA + $sIn = str_replace( 'TG', 'G', $sIn ); // retouche TG -> G + $sIn = preg_replace( '`^TZ`', 'TS', $sIn ); // retouche début TZ -> TS + $sIn = str_replace( 'PTIE', 'TIE', $sIn ); // retouche PTIE -> TIE + $sIn = str_replace( 'GT', 'T', $sIn ); // retouche GT -> T + $sIn = str_replace( 'ANKIEM', 'ANKILEM', $sIn ); // retouche tranquillement + $sIn = preg_replace( '`(LO|RE)KEMAN`', '$1KAMAN', $sIn ); // KEMAN -> KAMAN + $sIn = preg_replace( '`NT(B|M)`', 'N$1', $sIn ); // retouche TB -> B TM -> M + $sIn = str_replace( 'GSU', 'SU', $sIn ); // retouche GS -> SU + $sIn = str_replace( 'ESD', 'ED', $sIn ); // retouche ESD -> ED + $sIn = str_replace( 'LESKEL', 'LEKEL', $sIn ); // retouche LESQUEL -> LEKEL + $sIn = str_replace( 'CK', 'K', $sIn ); // retouche CK -> K + + // Terminaisons + $sIn = preg_replace( '`USIL$`', 'USI', $sIn ); // terminaisons USIL -> USI + $sIn = preg_replace( '`X$|[TD]S$|[DS]$`', '', $sIn ); // terminaisons TS DS LS X T D S... v2.0 + $sIn = preg_replace( '`([^KL]+)T$`', '$1', $sIn ); // sauf KT LT terminal + $sIn = preg_replace( '`^[H]`', '', $sIn ); // H pseudo muet en début de mot, je sais, ce n'est pas une terminaison + $sBack2=$sIn; // on sauve le code (utilisé pour les mots très courts) + + $convPartIn = [ + '`TIL$`', // terminaisons TIL -> TI + '`LC$`', // terminaisons LC -> LK + '`L[E]?[S]?$`', // terminaisons LE LES -> L + '`(.+)N[E]?[S]?$`', // terminaisons NE NES -> N + '`EZ$`', // terminaisons EZ -> E + '`OIG$`', // terminaisons OIG -> OI + '`OUP$`', // terminaisons OUP -> OU + '`([^R])OM$`', // terminaisons OM -> ON sauf ROM + '`LOP$`', // terminaisons LOP -> LO + '`NTANP$`', // terminaisons NTANP -> NTAN + '`TUN$`', // terminaisons TUN -> TIN + '`AU$`', // terminaisons AU -> O + '`EI$`', // terminaisons EI -> AI + '`R[DG]$`', // terminaisons RD RG -> R + '`ANC$`', // terminaisons ANC -> AN + '`KROC$`', // terminaisons C muet de CROC, ESCROC + '`HOUC$`', // terminaisons C muet de CAOUTCHOUC + '`OMAC$`', // terminaisons C muet de ESTOMAC (mais pas HAMAC) + '`([J])O([NU])[CG]$`',// terminaisons C et G muet de OUC ONC OUG + '`([^GTR])([AO])NG$`',// terminaisons G muet ANG ONG sauf GANG GONG TANG TONG + '`UC$`', // terminaisons UC -> UK + '`AING$`', // terminaisons AING -> IN + '`([EISOARN])C$`', // terminaisons C -> K + '`([ABD-MO-Z]+)[EH]+$`', // terminaisons E ou H sauf pour C et N + '`EN$`', // terminaisons EN -> AN (difficile à faire avant sans avoir des soucis) Et encore, + '`(NJ)EN$`',// terminaisons EN -> AN + '`^PAIEM`', // PAIE -> PAI + '`([^NTB])EF$`', // F muet en fin de mot + '`(.)\1`' // supression des répétitions (suite à certains remplacements) + ]; + + $convPartOut = [ + 'TI', // terminaisons TIL -> TI + 'LK', // terminaisons LC -> LK + 'L', // terminaisons LE LES -> L + '$1N', // terminaisons NE NES -> N + 'E', // terminaisons EZ -> E + 'OI', // terminaisons OIG -> OI + 'OU', // terminaisons OUP -> OU + '$1ON', // terminaisons OM -> ON sauf ROM + 'LO', // terminaisons LOP -> LO + 'NTAN', // terminaisons NTANP -> NTAN + 'TIN', // terminaisons TUN -> TIN + 'O', // terminaisons AU -> O + 'AI', // terminaisons EI -> AI + 'R', // terminaisons RD RG -> R + 'AN', // terminaisons ANC -> AN + 'KRO', // terminaisons C muet de CROC, ESCROC + 'HOU', // terminaisons C muet de CAOUTCHOUC + 'OMA', // terminaisons C muet de ESTOMAC (mais pas HAMAC) + '$1O$2',// terminaisons C et G muet de OUC ONC OUG + '$1$2N',// terminaisons G muet ANG ONG sauf GANG GONG TANG TONG + 'UK', // terminaisons UC -> UK + 'IN', // terminaisons AING -> IN + '$1K', // terminaisons C -> K + '$1', // terminaisons E ou H sauf pour C et N + 'AN', // terminaisons EN -> AN (difficile à faire avant sans avoir des soucis) Et encore, c'est pas top! + '$1AN', // terminaisons EN -> AN + 'PAIM', // PAIE -> PAI + '\1', // F muet en fin de mot + '$1' // supression des répétitions (suite à certains remplacements) + ]; + + $sIn = preg_replace( $convPartIn, $convPartOut, $sIn ); + + // cas particuliers, bah au final, je n'en ai qu'un ici + $convPartIn = array( 'FUEL'); + $convPartOut = array( 'FIOUL'); + $sIn = str_replace( $convPartIn, $convPartOut, $sIn ); + + // Ce sera le seul code retourné à une seule lettre! + if ($sIn=='O') return($sIn); + + // seconde chance sur les mots courts qui ont souffert de la simplification + if (strlen($sIn)<2) + { + // Sigles ou abréviations + if (preg_match('`[BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ]*`',$sBack)) + return($sBack); + + if (preg_match('`[RFMLVSPJDF][AEIOU]`',$sBack)) + { + if (strlen($sBack)==3) + return(substr($sBack,0,2));// mots de trois lettres supposés simples + if (strlen($sBack)==4) + return(substr($sBack,0,3));// mots de quatre lettres supposés simples + } + + if (strlen($sBack2)>1) return $sBack2; + } + if (strlen($sIn)>1) + { + return substr($sIn,0,16); // Je limite à 16 caractères mais vous faites comme vous voulez! + } + else return ''; } +} ?> \ No newline at end of file diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 7718d0a942539b9f45b4d4854c766ba68b1312e4..2a4775d075120254b6d0155742fc9a83ac1c5405 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -484,6 +484,13 @@ class Class_Indexation_PseudoNotice_Cms extends Class_Indexation_PseudoNotice{ protected $_id = 'id_article'; protected $_label='m1'; + public function save() { + parent::save(); + + if($record = $this->_model->getNotice()) + (new Class_WebService_Vignette())->updateUrlsFromCacheServer($record); + } + protected function _prepare() { parent::_prepare(); $this->_datas['description'] = strip_tags($this->_datas['contenu']); diff --git a/library/Class/Migration/Patchs.php b/library/Class/Migration/Patchs.php index ccf4eb1033e1f5a0cf1c76e24862efc053c6d7ab..5bd2b688801f134246a8b68a43ee30b7292209c4 100644 --- a/library/Class/Migration/Patchs.php +++ b/library/Class/Migration/Patchs.php @@ -23,7 +23,9 @@ class Class_Migration_Patchs { use Trait_StaticFileSystem; - public $force = false; + public + $_last_patch_number, + $force = false; public function extensionForFile($file) { @@ -42,7 +44,16 @@ class Class_Migration_Patchs { } + public function setLastPatchNumber($number) { + $this->_last_patch_number = $number; + return $this; + } + + public function getLastPatchNumber() { + if (isset($this->_last_patch_number)) + return $this->_last_patch_number; + $ids=[]; foreach (self::getFileSystem()->glob(PATCH_PATH."patch_*") as $filename) { $ids[]=$this->versionForFile($filename); @@ -50,14 +61,15 @@ class Class_Migration_Patchs { if (empty($ids)) return 0; rsort($ids); - return $ids[0]; + return $this->_last_patch_number = (int)$ids[0]; } public function getMatchingPatchFiles($patch_level) { + $to_patch_level = $this->getLastPatchNumber(); return $this->getPatchesFilteredBy( - function($version) use ($patch_level) { - return $version > (int)$patch_level; + function($version) use ($patch_level, $to_patch_level) { + return ($version > (int)$patch_level) && ($version <= $to_patch_level); }); } @@ -80,7 +92,7 @@ class Class_Migration_Patchs { $basePath = dirname(realpath(__FILE__)); $patch_level = Class_CosmoVar::find("patch_level"); - $visitor->visitHeader($patch_level,$this->getLastPatchNumber()); + $visitor->visitHeader($patch_level, $this->getLastPatchNumber()); $ok = true; foreach($this->getMatchingPatchFiles($patch_level->getValeur()) as $script) { diff --git a/library/Class/Migration/ScriptPatchs.php b/library/Class/Migration/ScriptPatchs.php index 336bd83741c021a5629b0a992adfa12169e801cb..bd2ddb1bfb2bb3b6bc85cab535f3fd8f413af9e6 100644 --- a/library/Class/Migration/ScriptPatchs.php +++ b/library/Class/Migration/ScriptPatchs.php @@ -33,6 +33,12 @@ class Class_Migration_ScriptPatchs { } + public function runTo($patch_level) { + $this->migration = (new Class_Migration_Patchs()); + $this->migration->setLastPatchNumber($patch_level)->acceptVisitor($this); + } + + public function visitPhpError($exception) { $this->echoError("Code : ".$exception->getCode()."\n"); $this->echoError("Erreur :".$exception->getMessage()); diff --git a/library/Class/ModeleFusion.php b/library/Class/ModeleFusion.php index 508e0338662e6121129897c119e0998ae6afab2b..b5d7728f6e9a7ae1752ab7a1bd7562d533033271 100644 --- a/library/Class/ModeleFusion.php +++ b/library/Class/ModeleFusion.php @@ -144,8 +144,7 @@ class Class_ModeleFusion extends Storm_Model_Abstract { foreach ($matches as $match) { $tag = array_shift($match); - if (!$tag_value = $this->getTagValueForString($match)) - continue; + $tag_value = $this->getTagValueForString($match); $content = str_replace($tag, $tag_value, $content); } diff --git a/library/Class/Sitotheque.php b/library/Class/Sitotheque.php index 0e8e136a24126fd339da2954af305f5fc181956a..43afaf9e770b8768545f90b244d63885f24d2616 100644 --- a/library/Class/Sitotheque.php +++ b/library/Class/Sitotheque.php @@ -41,7 +41,7 @@ class SitothequeLoader extends Storm_Model_Loader { * @param array $id_categories * @return array */ - public function getSitesFromIdsAndCategories($id_sites, $id_categories) { + public function getSitesFromIdsAndCategories($id_sites, $id_categories, $sorted = false) { $sites = []; $feeds = []; @@ -64,10 +64,29 @@ class SitothequeLoader extends Storm_Model_Loader { $feeds = array_merge($feeds, $categorie->getSitotheques()); } + if ($feeds && $sorted == true) { + usort($feeds, function($a, $b) { + if ($a->getDateMaj() == $b->getDateMaj()) return 0; + return ($a->getDateMaj() < $b->getDateMaj() ? 1 : -1); + }); + } return $this->_filterOnId(array_filter($feeds)); } + public function getLastSitos($id_category, $id_items, $limit) { + if ($id_category) { + $sitos = Class_Sitotheque::getSitesFromIdsAndCategories( + explode('-', $id_items), + explode('-', $id_category), + true); + return $sitos; + } + $sitos = Class_Sitotheque::findAllBy(['order' => 'date_maj desc', + 'limit' => $limit]); + return $sitos; + } + /** * @param array $items * @return array diff --git a/library/Class/Systeme/ModulesAccueil/Sitotheque.php b/library/Class/Systeme/ModulesAccueil/Sitotheque.php index c0592951f2bc1adad2cf5a9f96bc083766202d96..26fb68344d5451c4f72f8d286e5fc34f277f65c8 100644 --- a/library/Class/Systeme/ModulesAccueil/Sitotheque.php +++ b/library/Class/Systeme/ModulesAccueil/Sitotheque.php @@ -38,14 +38,15 @@ class Class_Systeme_ModulesAccueil_Sitotheque extends Class_Systeme_ModulesAccue protected $_isPhone = false; /** @var array */ - protected $_defaultValues = array( - 'titre' => 'Sitothèque', // Titre de la boite - 'type_aff' => 1, // Type a afficher : 1=sélection libre, 2=les + récents - 'id_categorie' => '', // Liste d'id_categorie séparés par des tirets - 'id_items' => '', // Liste d'id_site séparés par des tirets - 'nb_aff' => '2', // Nombre à afficher - 'group_by_categorie' => false, //grouper les sites par categorie sous forme de menu, - 'display_order' => 'Random' //ordre d'affichage: Random ou Selection - ); + protected $_defaultValues = [ + 'titre' => 'Sitothèque', // Titre de la boite + 'type_aff' => 1, // Type a afficher : 1=sélection libre, 2=les + récents + 'id_categorie' => '', // Liste d'id_categorie séparés par des tirets + 'id_items' => '', // Liste d'id_site séparés par des tirets + 'nb_aff' => '2', // Nombre à afficher + 'rss' => '0', + 'group_by_categorie' => false, //grouper les sites par categorie sous forme de menu, + 'display_order' => 'Random' //ordre d'affichage: Random ou Selection + ]; } ?> \ No newline at end of file diff --git a/library/Class/TimeSource.php b/library/Class/TimeSource.php index 3872031f727f69bd2e91c6f51c85f268ca27d12b..5045e4662fdc87322aa59bcd1cd805ea88a90a5d 100644 --- a/library/Class/TimeSource.php +++ b/library/Class/TimeSource.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 */ /** @@ -29,7 +29,7 @@ class Class_TimeSource { return time(); } - + public function dateYmd() { return date('Y-m-d', $this->time()); } @@ -53,20 +53,20 @@ class Class_TimeSource { public function nextDate() { $time = $this->time(); - return $this->midnightTime(date('n', $time), - date('j', $time) + 1, + return $this->midnightTime(date('n', $time), + date('j', $time) + 1, date('Y', $time)); } public function nextMonths($number_of_months=1) { $time = $this->time(); - return $this->midnightTime(date('n', $time) + $number_of_months, - date('j', $time), + return $this->midnightTime(date('n', $time) + $number_of_months, + date('j', $time), date('Y', $time)); } - + public function getMonth($month) { $time = $this->time(); $year = date('m', $time) > $month ? date('Y', $time) + 1 : date('Y', $time); @@ -77,5 +77,11 @@ class Class_TimeSource { protected function midnightTime($month, $day, $year) { return mktime(0, 0, 0, $month, $day, $year); } + + + public function lastYear() { + $time = $this->time(); + return date('Y', $time) - 1 . date('-m-d', $time); + } } ?> \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index e615379574d5175bfd711ca5f2b22fe7d640e243..28495ad3955b536ce5ef4ba39e1572b2dbd6b57f 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -294,7 +294,6 @@ class Class_Users extends Storm_Model_Abstract { ]; - protected $_belongs_to = ['bib' => ['model' => 'Class_Bib', 'referenced_in' => 'id_site'], @@ -367,9 +366,26 @@ class Class_Users extends Storm_Model_Abstract { public function getLibelleBib() { - if (!$bib = $this->getBib()) + return ($library = $this->getLibrary()) ? $library->getLibelle() : ''; + } + + + public function getLibraryId() { + return ($library = $this->getLibrary()) ? $library->getId() : ''; + } + + + public function getLibrary() { + if ($library = $this->getBib()) + return $library; + + if(!$int_library = $this->getIntBib()) return ''; - return $bib->getLibelle(); + + if(!$library_int_library = $int_library->getBib()) + return ''; + + return $library_int_library; } @@ -635,6 +651,7 @@ class Class_Users extends Storm_Model_Abstract { public function getLastAvis() { return Class_AvisNotice::findAllBy(['id_user' => $this->getId(), 'order' => 'date_avis desc', + 'flags' => Class_AvisNotice::NO_FLAG, 'limit' => 10]); } diff --git a/library/Class/WebService/OAI/Request/ListIdentifiers.php b/library/Class/WebService/OAI/Request/ListIdentifiers.php index a8f6cc9b271c2c4b10ecd250ae2326e950578783..2283020063824a4d41b26afe0314b81dc0394d87 100644 --- a/library/Class/WebService/OAI/Request/ListIdentifiers.php +++ b/library/Class/WebService/OAI/Request/ListIdentifiers.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 Class_WebService_OAI_Request_ListIdentifiers { const IDENTIFIERS_BY_PAGE = 100; @@ -32,7 +32,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { protected $_notices; protected $_token; - + public function __construct($params, $baseUrl) { $this->_baseUrl = $baseUrl; $this->_params = array_merge(array('metadataPrefix' => null, @@ -49,15 +49,15 @@ class Class_WebService_OAI_Request_ListIdentifiers { $this->_resumptionToken = $this->_params['resumptionToken']; - if ($this->_resumptionToken + if ($this->_resumptionToken && ($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken))) { $this->_set = $token->getParam('set'); $this->_from = $token->getParam('from'); $this->_until = $token->getParam('until'); - + if ($this->_metadataPrefix) $this->_metadataPrefix=null; - else + else $this->_metadataPrefix=$token->getParam('metadataPrefix'); } @@ -81,7 +81,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { if (null == $this->_metadataPrefix) $answer.=$builder->error(array('code' => 'badArgument'), 'Metadata prefix is not found'); - if ('oai_dc' != $this->_metadataPrefix) + if ('oai_dc' != $this->_metadataPrefix) $answer.= $builder->error(array('code' => 'cannotDisseminateFormat')); @@ -97,23 +97,23 @@ class Class_WebService_OAI_Request_ListIdentifiers { if ($this->_until && $this->_from) { if (strlen($this->_until) != strlen($this->_from)) return $builder->error(array('code' => 'badArgument'), 'from granularity != until granularity'); - + if (strtotime($this->_from)>(strtotime($this->_until))) return $builder->error(array('code' => 'noRecordsMatch')); } $token = null; - if ($this->_resumptionToken + if ($this->_resumptionToken && !($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken))) return $builder->error(array('code' => 'badResumptionToken')); - if ($answer) + if ($answer) return $answer; - if ($this->_from) + if ($this->_from) $this->_catalogue->setFrom(substr($this->_from, 0, 10)); - if ($this->_until) + if ($this->_until) $this->_catalogue->setUntil(substr($this->_until, 0, 10)); if (0 == ($count = $this->_catalogue->getNoticesCount())) @@ -147,11 +147,11 @@ class Class_WebService_OAI_Request_ListIdentifiers { $requestOptions['set'] = $this->_set; if (null !== $this->_from) $requestOptions['from'] = $this->_from; - if (null !== $this->_until) + if (null !== $this->_until) $requestOptions['until'] = $this->_until; if (null !== $this->_resumptionToken) $requestOptions['resumptionToken'] = $this->_resumptionToken; - if (null !== $this->_metadataPrefix) + if (null !== $this->_metadataPrefix) $requestOptions['metadataPrefix'] = $this->_metadataPrefix; return $builder->request($requestOptions, $this->_baseUrl); @@ -159,7 +159,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { public function getCatalogueFromSetSpec($setSpec) { - if (null == $setSpec) + if (null == $setSpec) return Class_Catalogue::newCatalogueForAll(); return current(Class_Catalogue::getLoader()->findAllBy(array('oai_spec' => $setSpec))); } diff --git a/library/Class/WebService/SIGB/Emprunteur.php b/library/Class/WebService/SIGB/Emprunteur.php index b4a0182054cd554aae7d9f1000e8e4ffffe4dd19..f33aebe27698160a77fe186f0152e676131e7c20 100644 --- a/library/Class/WebService/SIGB/Emprunteur.php +++ b/library/Class/WebService/SIGB/Emprunteur.php @@ -616,7 +616,6 @@ class Class_WebService_SIGB_Emprunteur { } - /** * @return string */ diff --git a/library/Class/WebService/SIGB/Nanook.php b/library/Class/WebService/SIGB/Nanook.php index 9dcb7d5d1a61e846d6cbcd80f8b8731be4c24016..4e71a26a73f7614d116b9e7249efc1ebdde4973b 100644 --- a/library/Class/WebService/SIGB/Nanook.php +++ b/library/Class/WebService/SIGB/Nanook.php @@ -16,7 +16,24 @@ * * 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_SIGB_Nanook extends Class_WebService_SIGB_Abstract {} +class Class_WebService_SIGB_Nanook extends Class_WebService_SIGB_Abstract { + + public static function getService($params){ + if (!isset($params['provide_suggest'])) + $params = array_merge(['provide_suggest' => ''], + $params); + + if (!isset(static::$service)) { + $instance = new static(); + $classname = get_called_class().'_Service'; + static::$service = $classname::getService($params['url_serveur'], + $params['provide_suggest'] === '1'); + } + + return static::$service; + } + +} ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/BuySuggestForm.php b/library/Class/WebService/SIGB/Nanook/BuySuggestForm.php new file mode 100644 index 0000000000000000000000000000000000000000..5dc73e84220111c9705139985b5c94a60a0663cb --- /dev/null +++ b/library/Class/WebService/SIGB/Nanook/BuySuggestForm.php @@ -0,0 +1,78 @@ +<?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 Class_WebService_SIGB_Nanook_BuySuggestForm extends ZendAfi_Form_SuggestionAchat_Abstract { + + public function newBuySuggest($post) { + return (new Class_WebService_SIGB_Suggestion()) + ->updateAttributes($post) + ->setUser($this->_user); + } + + + public function init() { + parent::init(); + $this + + ->addElement('text', 'Title', ['label' => $this->_('Titre').' *', + 'placeholder' => $this->_('ex: Harry Potter à l\'école des sorciers'), + 'size' => 80, + 'required' => true, + 'allowEmpty' => false]) + + ->addElement('text', 'Author', ['label' => $this->_('Auteur').' *', + 'placeholder' => 'ex: Joanne Kathleen Rowling', + 'size' => 80, + 'required' => true, + 'allowEmpty' => false]) + + ->addElement('text', 'Isbn', ['label' => $this->_('Code-barres / ISBN'), + 'placeholder' => 'ex: 2-07-054127-4', + 'size' => 17]) + + ->addElement('url', 'Url', ['label' => $this->_('URL'), + 'placeholder' => 'http://www...', + 'size' => 80]) + + ->addElement('textarea', 'Comment', ['label' => '', + 'cols' => 70, + 'rows' => 10]) + + ->addElement('text', 'Library', ['label' => $this->_('Site'), + 'value' => Class_Users::getIdentity()->getLibelleBib(), + 'disabled' => true]) + + ->addDisplayGroup(['Title', + 'Author', + 'Isbn', + 'Library'], + 'suggestion', + ['legend' => $this->_('Informations sur le document')]) + + ->addDisplayGroup(['Url', + 'Comment'], + 'notes_group', + ['legend' => $this->_('Notes')]) + + ->addElement('submit', 'submit', ['label' => $this->_('Envoyer')]); + } +} +?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php index 57d9203bcaa3a9264ea0a1d6e615a6d729833168..06e0aab3fde30d9e648a71a751e826dd32a8829a 100644 --- a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php @@ -16,9 +16,13 @@ * * 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_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIGB_AbstractILSDIPatronInfoReader{ + protected + $_suggests = [], + $_current_suggest; + /** * @return Class_WebService_SIGB_Nanook_PatronInfoReader */ @@ -52,62 +56,62 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIG } - /** - * @param string $data + /** + * @param string $data */ public function endBarcode($data) { $this->_emprunteur->setCodeBarres($data); } - /** - * @param string $data + /** + * @param string $data */ public function endAddress($data) { $this->_emprunteur->setAdresse($data); } - /** - * @param string $data + /** + * @param string $data */ public function endTown($data) { $this->_emprunteur->setVille($data); } - /** - * @param string $data + /** + * @param string $data */ public function endZipCode($data) { $this->_emprunteur->setCodePostal($data); } - /** - * @param string $data + /** + * @param string $data */ public function endPhoneNumber($data) { $this->_emprunteur->setTelephone($data); } - /** - * @param string $data + /** + * @param string $data */ public function endDisplayOrder($data) { $this->_emprunteur->setOrdre($data); } - /** - * @param string $data + /** + * @param string $data */ public function endBirthDate($data) { $this->_emprunteur->setDateNaissance($data); } - + /** * @param string $data */ @@ -143,8 +147,8 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIG } - /** - * @param string $data + /** + * @param string $data */ public function endAvailable($data) { if (1 == (int)$data) { @@ -161,5 +165,64 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIG if ('' != $data) $this->_currentHold->setEtat('Pas disponible avant le ' . $data); } + + + public function startSuggest() { + $this->_current_suggest = new Class_WebService_SIGB_Nanook_Suggestion(); + } + + + public function endSuggest() { + $this->_suggests[] = $this->_current_suggest; + } + + + public function endSite($data) { + $library = Class_Bib::find($data); + $this->_current_suggest->setLibrary($library ? $library->getLibelle() : $data); + } + + + public function endStatus($data) { + $this->_current_suggest->setStatus($data); + } + + + public function endTitle($data) { + parent::endTitle($data); + + if($this->_current_suggest) + $this->_current_suggest->setTitle($data); + } + + + public function endAuthor($data) { + parent::endAuthor($data); + + if($this->_current_suggest) + $this->_current_suggest->setAuthor($data); + } + + + public function endIsbnean($data) { + $this->_current_suggest->setIsbn($data); + } + + + public function endDesclink($data) { + if($this->_current_suggest) + $this->_current_suggest->setUrl($data); + } + + + public function endComment($data) { + if($this->_current_suggest) + $this->_current_suggest->setNote($data); + } + + + public function getSuggestions() { + return $this->_suggests; + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index b15b4d2d4f30e7b64145962a60e366086de34f1e..ecf9d8c8e0553692bcafa5b3629250d349c2fcb5 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -19,6 +19,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_AbstractRESTService { + protected $_provide_suggest = false; + + + public static function getService($server_root, $provide_suggest = false) { + return self::newInstance() + ->setServerRoot($server_root) + ->setProvideSuggest($provide_suggest); + } + + /** * @param string $server_root * @return Class_WebService_SIGB_AbstractRESTService @@ -70,6 +80,24 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac } + // This method is call in Class_Suggestion->save(); + // Class_Suggestion->save() always return true without considering webservice answers. + // Looks like an user experience choice ? So no return statement is needed ... + public function suggest($suggestion) { + $url = $this->buildQueryURL(['service' => 'CreateSuggest', + 'patronId' => $suggestion->getUser()->getIdSigb()]); + + $post_data = ['site' => (($user = Class_Users::getIdentity()) ? $user->getLibraryId() : 0), + 'title' => $suggestion->getTitle(), + 'author' => $suggestion->getAuthor(), + 'isbnean' => $suggestion->getIsbn(), + 'desclink' => $suggestion->getUrl(), + 'comment' => $suggestion->getComment()]; + + $xml = $this->getWebClient()->postData($url, $post_data); + } + + /** * @param Class_Users $user * @param int $notice_id @@ -160,5 +188,53 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac return $this->getServerRoot() . implode('/', $parts); } + + + public function setProvideSuggest($provide_suggest) { + $this->_provide_suggest = $provide_suggest; + return $this; + } + + + public function providesSuggestions() { + return $this->_provide_suggest; + } + + + public function suggestionsOf($user) { + if (!$this->ilsdiAuthenticatePatron($user)) + return $this->_error($this->_('Échec de l\'authentification par le webservice')); + + return $this->getSuggestionsFromilsdiPatronInfo(['patronId' => $user->getIdSigb()], + Class_WebService_SIGB_Nanook_PatronInfoReader::newInstance()); + + } + + + protected function getSuggestionsFromilsdiPatronInfo($params, $reader, $error_tag='error') { + $emprunteur = Class_WebService_SIGB_Emprunteur::newInstance()->setService($this); + $params = array_merge(['service' => 'GetPatronInfo'], + $params); + + $xml = $this->httpGet($params); + + if (0 === strpos($xml, '<html>')) + return []; + + if ($this->_getTagData($xml, $error_tag)) + return []; + + return $reader + ->setEmprunteur($emprunteur) + ->parseXML($xml) + ->getSuggestions(); + } + + + public function newBuySuggestForm() { + return $this->providesSuggestions() + ? new Class_WebService_SIGB_Nanook_BuySuggestForm() + : parent::newBuySuggestForm(); + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/Suggestion.php b/library/Class/WebService/SIGB/Nanook/Suggestion.php new file mode 100644 index 0000000000000000000000000000000000000000..46429303a8e81433c253897f7f1856c8d7f6fe90 --- /dev/null +++ b/library/Class/WebService/SIGB/Nanook/Suggestion.php @@ -0,0 +1,43 @@ +<?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 Class_WebService_SIGB_Nanook_Suggestion extends Class_WebService_SIGB_Suggestion { + use Trait_Translator; + + public function __construct() { + parent::__construct(); + $this->_attribs = array_merge($this->_attribs, ['url' => '']); + } + + public function acceptVisitor($visitor) { + $visitor + ->visitField($this->_('Isbn/Ean'), $this->getIsbn()) + ->visitField($this->_('Titre'), $this->getTitle()) + ->visitField($this->_('Auteur'), $this->getAuthor()) + ->visitField($this->_('Bibliothèque'), $this->getLibrary()) + ->visitField($this->_('Url'), $this->getUrl()) + ->visitField($this->_('Note'), $this->getNote()) + ->visitField($this->_('Statut'), $this->getStatus()); + + return $this; + } +} \ No newline at end of file diff --git a/library/Trait/Avis.php b/library/Trait/Avis.php index 2c4a9c88d4e69f827226abf86169e864556ec52c..9cce4a6f6a7cbadd79d12a4672f3579c59a8aaae 100644 --- a/library/Trait/Avis.php +++ b/library/Trait/Avis.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 */ trait Trait_Avis { @@ -79,6 +79,13 @@ trait Trait_Avis { return $this->getAbonOuBib() == self::$AVIS_ABONNE; } + public function isOrphan() { + return $this->getFlags() == self::ORPHAN_FLAG ; + } + + public function isArchived() { + return $this->getFlags() == self::ARCHIVED_FLAG ; + } public function beWrittenByAbonne() { return $this->setAbonOuBib(self::$AVIS_ABONNE); diff --git a/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php index 1c8a613469e9d26d07ad6c05676f8d2902768a7e..4324c4d0a5d66c9a5f28060b408df994c88dbe1b 100644 --- a/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php +++ b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php @@ -58,14 +58,30 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr return 'id_cat'; } + protected function getAllParentCatIds($id_cat) { + return array_merge([$id_cat], + array_map(function($model) { return $model->getId();}, + Class_ArticleCategorie::find($id_cat)->getRecursiveSousCategories())); + } + + public function getRecursiveCategoriesForUser() { + $categories = (!$id_cat = $this->getParam('id_cat')) + ? $this->getBib()->getRecursiveArticleCategories() + : Class_ArticleCategorie::findAllBy(['id_cat_mere' => $this->getAllParentCatIds($id_cat), + 'order' => 'libelle']); + + return $this->getFilteredCategories($categories); + } + public function getCategories() { + $categories = (!$id_cat = $this->getParam('id_cat')) ? $this->getBib()->getArticleCategories() : Class_ArticleCategorie::findAllBy(['id_cat_mere' => $id_cat, 'order' => 'libelle']); - return $this->getFiltredCategories($categories); + return $this->getFilteredCategories($categories); } @@ -80,7 +96,7 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr } - protected function getFiltredCategories($categories) { + protected function getFilteredCategories($categories) { $cms_permissions = Class_Permission::getCmsPermissions(); $categories_filter = function($category) use ($cms_permissions) { @@ -105,7 +121,9 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr protected function getSearchParams() { - return parent::getSearchParams() + ['id_cat' => $this->getFilteredCategoriesIds()]; + if (count($filtered_ids=$this->getFilteredCategoriesIds())>0) + return array_merge(parent::getSearchParams(),['id_cat' => $filtered_ids]); + return parent::getSearchParams(); } @@ -113,7 +131,7 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr if ($this->_filtred_categories_ids) return $this->_filtred_categories_ids; - $categories = $this->getFiltredCategories($this->getCategoriesForUser()); + $categories = $this->getFilteredCategories($this->getRecursiveCategoriesForUser()); $this->_filtred_categories_ids = array_map(function($model) { return $model->getId(); }, $categories); diff --git a/library/ZendAfi/Controller/Action/Helper/RenderRss.php b/library/ZendAfi/Controller/Action/Helper/RenderRss.php new file mode 100644 index 0000000000000000000000000000000000000000..2411ac338054bd92e83220942236168cffb454ef --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/RenderRss.php @@ -0,0 +1,197 @@ +<?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_Controller_Action_Helper_RenderRss extends Zend_Controller_Action_Helper_Abstract { + + protected function _newStrategy($named) { + $class_name = 'ZendAfi_Controller_Action_Helper_RenderRss' . ucfirst($named); + return new $class_name(); + } + + + public function direct($id_profil, $id_module, $view, $type) { + $this->_newStrategy($type)->render($id_profil,$id_module,$view,$this->getActionController()); + } +} + + + +abstract class ZendAfi_Controller_Action_Helper_RenderRssAbstract { + protected $action, $_view; + + public function render($id_profil, $id_module, $view,$action) { + $this->_view = $view; + $this->action=$action; + $datas = []; + $data_rss = + [ + 'title' => 'Flux indisponible', + 'link' => ($this->action->getRequest()->getScheme() . '://' + . $this->action->getRequest()->getServer('HTTP_HOST')), + 'charset' => 'utf-8', + 'description' => '', + 'lastUpdate' => time() + ]; + + $profil = Class_Profil::find($id_profil); + if ($profil != null) { + $preferences = $profil->getModuleAccueilPreferences($id_module, $this->getType()); + $datas = $this->_getObjectDatas($id_module, $profil, $preferences); + $data_rss = array_merge( + $data_rss, + [ + 'title' => (trim($preferences['titre']) ? trim($preferences['titre']) : $profil->getLibelle()), + 'link' => $this->_getLink($profil, $id_module), + 'description' => $this->_getDescription() . $preferences['titre'] + ] + ); + } + $this->_renderRssFeed($datas, $data_rss); + } + + + protected function getDescriptionForElement($data) { + return html_entity_decode(Class_CmsUrlTransformer::imgUrlRelativeToAbsolute($this->_view->tagArticleEvent($data) + . $data->getFullContent())); + } + + + protected function getUrlLink($data) { + return $this->action->getRequest()->getScheme() . '://' + . $this->action->getRequest()->getServer('HTTP_HOST') + . $this->_view->url($data->getUrl()); + } + + + protected function lastUpdate($data) { + return strtotime($data->getPubDate()); + } + + + protected function _renderRssFeed($datas, $rss_array) { + $entries = []; + foreach ($datas as $data) { + $entries[] = + [ + 'title' => html_entity_decode($data->getTitre()), + 'link' => $this->getUrlLink($data), + 'lastUpdate' => $this->lastUpdate($data), + + 'description' => $this->getDescriptionForElement($data) + ]; + } + $rss_array['entries'] = $entries; + $feed = Zend_Feed::importArray($rss_array, 'rss'); + + $this->action->getHelper('ViewRenderer')->setNoRender(); + $this->action->getResponse()->setHeader('Content-Type', 'application/rss+xml;charset=utf-8') ; + $this->action->getResponse()->setBody($feed->saveXML()); + } + + + abstract protected function _getObjectDatas($id_module, $profil, $preferences); + + + protected function _getDescription() { + return ''; + } + + + protected function _getLink($profil, $id_module) { + return ''; + } + + + protected function getType() { + return 'NEWS'; + } +} + + + +class ZendAfi_Controller_Action_Helper_RenderRssSito extends ZendAfi_Controller_Action_Helper_RenderRssAbstract { + + protected function getType() { + return 'SITO'; + } + + + protected function getDescriptionForElement($data) { + return html_entity_decode($data->getDescription()); + } + + + protected function lastUpdate($data) { + return strtotime($data->getDateMaj()); + } + + + protected function getUrlLink($data) { + return $data->getUrl(); + } + + + protected function _getObjectDatas($id_module, $profil, $preferences) { + return Class_Sitotheque::getSitesFromIdsAndCategories( + explode('-', $preferences['id_items']), + explode('-', $preferences['id_categorie'])); + } +} + + + +class ZendAfi_Controller_Action_Helper_RenderRssNews extends ZendAfi_Controller_Action_Helper_RenderRssAbstract { + + protected function _getObjectDatas($id_module, $profil, $preferences) { + return Class_Calendar::getAllnextEvents($id_module, $profil); + } + + + protected function _getDescription() { + return 'Agenda: '; + } + + + protected function _getLink($profil, $id_module) { + return $profil->urlForModule('cms', 'articleviewbydate', $id_module); + } +} + + + +class ZendAfi_Controller_Action_Helper_RenderRssArticle extends ZendAfi_Controller_Action_Helper_RenderRssAbstract { + + protected function _getObjectDatas($id_module, $profil, $preferences) { + $articles = Class_Article::getArticlesByPreferences($preferences); + return Class_Article::filterByLocaleAndWorkflow($articles); + } + + + protected function _getDescription() { + return 'Articles: '; + } + + + protected function _getLink($profil, $id_module) { + return $profil->urlForModule('cms', 'viewselection', $id_module); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/AdminVar.php b/library/ZendAfi/Form/Admin/AdminVar.php index 6f49b0fca91adf1b5ef7ce7fca663e3884c7946a..5f03d037f3d2638363363c1adbb4a0e2b1038bc5 100644 --- a/library/ZendAfi/Form/Admin/AdminVar.php +++ b/library/ZendAfi/Form/Admin/AdminVar.php @@ -20,23 +20,9 @@ */ class ZendAfi_Form_Admin_AdminVar extends ZendAfi_Form { - protected static $_FORM_CLASSES = - [ - Class_AdminVar_Meta::TYPE_ON_OFF => 'ZendAfi_Form_Admin_AdminVar_Checkbox', - Class_AdminVar_Meta::TYPE_MULTI_INPUT => 'ZendAfi_Form_Admin_AdminVar_MultiInput', - Class_AdminVar_Meta::TYPE_DEFAULT => 'ZendAfi_Form_Admin_AdminVar', - Class_AdminVar_Meta::TYPE_ENCODED_DATA => 'ZendAfi_Form_Admin_AdminVar_EncodedData', - Class_AdminVar_Meta::TYPE_RAW_TEXT => 'ZendAfi_Form_Admin_AdminVar_RawText', - Class_AdminVar_Meta::TYPE_COMBO => 'ZendAfi_Form_Admin_AdminVar_Combo' - ]; - - public static function newWithAdminVar($admin_var, $options=[]) { - $form_class = static::$_FORM_CLASSES[$admin_var->getType()]; - - $form = (new $form_class($options)); - $form->setValue($admin_var->getValeur()); - return $form; + return (new ZendAfi_Form_Admin_AdminVarFactory) + ->newWithAdminVar($admin_var, $options); } diff --git a/library/ZendAfi/Form/Admin/AdminVar/Editor.php b/library/ZendAfi/Form/Admin/AdminVar/Editor.php new file mode 100644 index 0000000000000000000000000000000000000000..f812541e5010ffe31e62296e16cc4d4935c0493c --- /dev/null +++ b/library/ZendAfi/Form/Admin/AdminVar/Editor.php @@ -0,0 +1,40 @@ +<?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_Admin_AdminVar_Editor extends ZendAfi_Form_Admin_AdminVar { + protected $_select_options = []; + + + public function addVariableEditElement() { + $this->addElement('ckeditor', + 'valeur', + ['label' => $this->_('Valeur')]); + + } + + + public function getAdminVarValue() { + return trim($this->getValues()['valeur']); + } + + +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/AdminVar/MultiInput.php b/library/ZendAfi/Form/Admin/AdminVar/MultiInput.php index 3d6ae52a37209f94a091bc83cfab06578978f0db..6318a64c4085cd1e29e9373365574c19e4992021 100644 --- a/library/ZendAfi/Form/Admin/AdminVar/MultiInput.php +++ b/library/ZendAfi/Form/Admin/AdminVar/MultiInput.php @@ -21,25 +21,61 @@ class ZendAfi_Form_Admin_AdminVar_MultiInput extends ZendAfi_Form_Admin_AdminVar { + protected $_fields = []; + + + public function setFields($fields) { + $this->_fields = $fields; + return $this; + } + + public function addVariableEditElement() { $this->addElement('multiInput', 'valeur', ['label' => $this->_('Liste de valeurs'), - 'fields' => [ - ['name' => 'values', 'label' => $this->_('Valeur')] - ] - ]); + 'fields' => $this->_fields]); } public function setValue($value) { - $this->getElement('valeur')->setValues(['values' => explode(';', $value)]); + $this->getElement('valeur') + ->setValues($this->_detectValues($value)); } public function getAdminVarValue() { $values = $this->getValues(); - return implode(';', $values['valeur']['values']); + return $this->_shouldSerialize() + ? json_encode($values['valeur']) + : implode(';', $values['valeur']['values']); + } + + + protected function _detectValues($value) { + if (!$this->_shouldSerialize()) + return ['values' => explode(';', $value)]; + + return $this->_getSerializedValues($value); + } + + + protected function _shouldSerialize() { + return $this->_fields + && (count($this->_fields) > 1 || $this->_fields[0]['name'] != 'values'); + } + + + protected function _getSerializedValues($value) { + if ($arvalues = json_decode($value, true)) + return $arvalues; + + $arvalues = []; + $collector = function($item) use (&$arvalues) { + $arvalues[$item['name']] = ['']; + }; + + array_walk($this->_fields, $collector); + return $arvalues; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/AdminVarFactory.php b/library/ZendAfi/Form/Admin/AdminVarFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..60faeae3124e217e761a539cb96db2f65fe979a1 --- /dev/null +++ b/library/ZendAfi/Form/Admin/AdminVarFactory.php @@ -0,0 +1,67 @@ +<?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_Admin_AdminVarFactory { + use Trait_Translator; + + protected $_var, $_options; + + protected $_FORM_CLASSES = + [ + Class_AdminVar_Meta::TYPE_ON_OFF => 'ZendAfi_Form_Admin_AdminVar_Checkbox', + Class_AdminVar_Meta::TYPE_MULTI_INPUT => 'ZendAfi_Form_Admin_AdminVar_MultiInput', + Class_AdminVar_Meta::TYPE_DEFAULT => 'ZendAfi_Form_Admin_AdminVar', + Class_AdminVar_Meta::TYPE_ENCODED_DATA => 'ZendAfi_Form_Admin_AdminVar_EncodedData', + Class_AdminVar_Meta::TYPE_RAW_TEXT => 'ZendAfi_Form_Admin_AdminVar_RawText', + Class_AdminVar_Meta::TYPE_COMBO => 'ZendAfi_Form_Admin_AdminVar_Combo', + Class_AdminVar_Meta::TYPE_EDITOR => 'ZendAfi_Form_Admin_AdminVar_Editor' + ]; + + + public function newWithAdminVar($admin_var, $options=[]) { + $this->_admin_var = $admin_var; + $this->_options = $options; + + if ($admin_var->isMultiInput()) + return $this->_buildMultiInput(); + + return $this->_buildForm(); + } + + + protected function _buildMultiInput() { + $this->_options['fields'] = isset($this->_options['fields']) + ? $this->_options['fields'] + : [ ['name' => 'values', 'label' => $this->_('Valeur')] ]; + + return $this->_buildForm(); + } + + + protected function _buildForm() { + $form_class = $this->_FORM_CLASSES[$this->_admin_var->getType()]; + $form = (new $form_class($this->_options)); + $form->setValue($this->_admin_var->getValeur()); + + return $form; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/News.php b/library/ZendAfi/Form/Admin/News.php index 4ebe5318d05398b699057faec87e0b775c5471de..b09da25e79c6c20c9748c138b4e437f1098dc242 100644 --- a/library/ZendAfi/Form/Admin/News.php +++ b/library/ZendAfi/Form/Admin/News.php @@ -65,7 +65,7 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form { 'start' => ['name' => 'debut', 'allowEmpty' => false], 'end' => ['name' => 'fin'], - 'order' => 7]) + 'order' => 8]) ->addElement('dateRangePicker', 'event_range', @@ -77,7 +77,7 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form { 'end' => ['name' => 'events_fin', 'dateOnly' => false, 'toggleAllDay' => 'all_day'], - 'order' => 8]) + 'order' => 9]) ->addElement('checkbox', 'all_day', ['label' => $this->_("L'évenement dure toute la journée"), @@ -153,7 +153,7 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form { $this->addElement('email', 'destination_email', ['label' => $this->_('Email du modérateur'), 'value' => $email, - 'order' => 4]); + 'order' => 5]); $this->updateDisplayGroup('publication', ['destination_email']); } return $this; @@ -169,11 +169,11 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form { 'separator' => ' ', 'multiOptions' => Class_Article::getKnownStatus(), 'value' => (int) $status, - 'order' => 5]); + 'order' => 6]); $this->addElement('textarea', 'refus_message', - ['order' => 6, + ['order' => 7, 'cols' => 45, 'rows' => 5, 'style' => 'display:none', diff --git a/library/ZendAfi/View/Helper/Accueil/Sito.php b/library/ZendAfi/View/Helper/Accueil/Sito.php index f440aab07c94404fe7c9c2805071eba6abe44563..b86146b6c8bbd456f93c9f29dcaaa8623323c1db 100644 --- a/library/ZendAfi/View/Helper/Accueil/Sito.php +++ b/library/ZendAfi/View/Helper/Accueil/Sito.php @@ -47,6 +47,9 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base $contenu = ''; $nb_aff = $this->getPreference('nb_aff'); + if ($this->preferences['rss']) + $this->rss_interne = $this->_getRSSurl('sito', 'sito-rss'); + $box_title = $this->getPreference('titre') ? $this->getPreference('titre') : $this->_('Derniers sites ajoutés'); @@ -78,16 +81,16 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base } if ($this->isTypeAffichagePlusRecents() && $nb_aff > 0) { - $sites = Class_Sitotheque::findAllBy(['order' => 'date_maj desc', - 'limit' => 50]); - if (static::ORDER_RANDOM == $this->getPreference('display_order')) - shuffle($sites); + $sites = Class_Sitotheque::getLastSitos($this->getPreference('id_categorie'), + $this->getPreference('id_items'), + $nb_aff); $this->titre = $this->renderTitleLink($box_title, $this->_('Liste des derniers sites ajoutés'), $this->view->url(['controller' => 'sito', 'action' => 'viewrecent', + 'id_cat' => $this->getPreference('id_categorie'), 'nb' => 50], null,true)); } diff --git a/library/ZendAfi/View/Helper/Admin/ListViewMode.php b/library/ZendAfi/View/Helper/Admin/ListViewMode.php index b50bf7a39c50fe9e6e90c853b9f66849d9ac9162..1f87d676171b60e03f19b14b6c813921ca43089e 100644 --- a/library/ZendAfi/View/Helper/Admin/ListViewMode.php +++ b/library/ZendAfi/View/Helper/Admin/ListViewMode.php @@ -57,6 +57,7 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel 'action' => $this->view->url(array_filter($this->_list->getSearchUrl()), null, true), + 'method' => 'POST', 'id' => 'list_search_form']); } diff --git a/library/ZendAfi/View/Helper/Avis.php b/library/ZendAfi/View/Helper/Avis.php index 73f097c7bb1ad7ee259b1952b5bfcb388e780322..e13c8854fdf018a2ef04e5025d1e5d3cb8452ddf 100644 --- a/library/ZendAfi/View/Helper/Avis.php +++ b/library/ZendAfi/View/Helper/Avis.php @@ -63,7 +63,7 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { $this->setLimitNbWord($limit_nb_word); return ($avis->isAvisNotice()) ? - $this->avisNotice($avis, $limit_nb_word, $vignette_link_to_avis) : + $this->avisNotice($avis) : $this->avisCms($avis); } @@ -86,9 +86,10 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { } - protected function avisNotice($avis, $vignette_link_to_avis) { + protected function avisNotice($avis) { $url_vignette = URL_ADMIN_IMG . 'supports/vignette_vide.gif'; $title = $this->_('Oeuvre non trouvée'); + $type_doc_id = 0; $type_doc_label = $this->_('Inconnu'); @@ -103,7 +104,6 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { $url_vignette = $notice->fetchUrlVignette(); } - $content = $this->contenu_avis($avis); return $this-> diff --git a/library/ZendAfi/View/Helper/AvisBloc.php b/library/ZendAfi/View/Helper/AvisBloc.php index a94796d343af099b55175467f60095791dcbef36..db6fa4fb26ec24fb0cd39f614ec2de720ab97a97 100644 --- a/library/ZendAfi/View/Helper/AvisBloc.php +++ b/library/ZendAfi/View/Helper/AvisBloc.php @@ -16,18 +16,18 @@ * * 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_AvisBloc extends Zend_View_Helper_HtmlElement { - public function avisBloc($libelle_bloc, $avis_list) { + public function avisBloc($libelle_bloc, $avis_list,$page=0,$nb_elements=0) { $libelle_bloc = $this->view->_($libelle_bloc); - return $this->renderHtmlAvisBloc($libelle_bloc, $avis_list); - } + return $this->renderHtmlAvisBloc($libelle_bloc, $avis_list,$page,$nb_elements); + } - public function renderHtmlAvisBloc($libelle, $list) { + public function renderHtmlAvisBloc($libelle, $list,$page=0 ,$nb_elements=0) { $html = '<h2>'.$libelle.'</h2>'; $html.= '<div>'; @@ -35,15 +35,18 @@ class ZendAfi_View_Helper_AvisBloc extends Zend_View_Helper_HtmlElement { $empty = $this->view->_('Aucun avis ' . ($libelle ? $libelle . ' ' : '') . 'à modérer.'); $html.='<p align="center" class="error">'.$empty.'</p>'; } else { - $this->view->getHelper('avis')->setActions(['validate', 'edit', 'del']); - $html.= $this->view->partialCycle('modo/_avis_partial.phtml', + + $html.= $this->view->partialCycle('modo/_avis_partial.phtml', 'avis', $list, ['first', - 'second']); + 'second']); + if ($page>0) + $html.= $this->view->Pager($nb_elements,10,$page,$this->view->url(['page' => null],null,false)); } + + return $html.='</div>'; } } - diff --git a/library/ZendAfi/View/Helper/BoutonIco.php b/library/ZendAfi/View/Helper/BoutonIco.php index 7ec4993d55362d1254c1a69756f11cc6df7c4430..6abedb0e2bbce0055b8ed4d3058d522816cbdd00 100644 --- a/library/ZendAfi/View/Helper/BoutonIco.php +++ b/library/ZendAfi/View/Helper/BoutonIco.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_BoutonIco extends ZendAfi_View_Helper_BaseHelper { @@ -43,7 +43,7 @@ class ZendAfi_View_Helper_BoutonIco extends ZendAfi_View_Helper_BaseHelper { $options = [ - 'src' => $this->picto, + 'src' => $this->picto, 'class' => 'ico']; if ($this->bulle) { @@ -51,7 +51,7 @@ class ZendAfi_View_Helper_BoutonIco extends ZendAfi_View_Helper_BaseHelper { $options['title'] = $this->bulle; } - if ('DEL' == strtoupper($this->type)) + if ('DEL' == strtoupper($this->type)) $options['onclick'] = 'javascript:return confirm(\'' . $this->traduire('Êtes vous sûr de vouloir supprimer cet élément ?') . '\');'; $html = $this->view->tag('img', null, $options); @@ -64,14 +64,16 @@ class ZendAfi_View_Helper_BoutonIco extends ZendAfi_View_Helper_BaseHelper { protected function predefined($type) { $mapping = [ - 'ADD' => ['add.gif', $this->traduire('Ajouter')], - 'EDIT'=> ['edit.gif', $this->traduire('Modifier')], - 'DEL' => ['del.gif', $this->traduire('Supprimer')], - 'CONFIRM'=> ['coche_verte.gif', $this->traduire('Confirmer')], - 'VALIDATE' => ['coche_verte.gif', $this->traduire('Valider')], - 'TEST' => ['tester.gif', $this->traduire('Tester')], - 'SHOW' => ['show.gif', $this->traduire('Visualiser')], - 'MAIL' => ['mail.png', $this->traduire('Envoyer par mail')] + 'ADD' => ['add.gif', $this->traduire('Ajouter')], + 'EDIT'=> ['edit.gif', $this->traduire('Modifier')], + 'DEL' => ['del.gif', $this->traduire('Supprimer')], + 'CONFIRM'=> ['coche_verte.gif', $this->traduire('Confirmer')], + 'VALIDATE' => ['coche_verte.gif', $this->traduire('Valider')], + 'TEST' => ['tester.gif', $this->traduire('Tester')], + 'SHOW' => ['show.gif', $this->traduire('Visualiser')], + 'MAIL' => ['mail.png', $this->traduire('Envoyer par mail')], + 'VISIBLE' => ['hide.gif', $this->traduire('Rendre visible')], + 'INVISIBLE' => ['show.gif', $this->traduire('Archiver')] ]; $type = strtoupper($type); diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php b/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php index 8feffbd3713e3cb4698407b622b300e84b541bde..bdb451ed09c386f2a345f662d6c07bb82d86fa22 100644 --- a/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php +++ b/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php @@ -36,14 +36,13 @@ class ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories extends ZendAfi_V ->hasParentPermissionOn(Class_Permission::createArticleCategory(), $model); }; - - $actions[] = ['url' => $this->_getUrlForAction('edit'), + $actions[] = ['url' => $this->_getUrlForAction('edit', true), 'icon' => 'ico/edit.gif', 'label' => 'Modifier', 'condition' => $parent_permission]; $actions[] = [ - 'url' => $this->_getUrlForAction('delete'), + 'url' => $this->_getUrlForAction('delete', true), 'icon' => 'ico/del.gif', 'label' => 'Supprimer', 'condition' => function($model) use ($parent_permission) { diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index 2aa8116f95578e92a465b34f4d62723bc4a5ee0b..0ea70e2326b5113bcef18e8290e8c52e785ab907 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -53,7 +53,7 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement 'action' => 'consult-book-ajax', 'id' => $this->_album->getId()], $this->view->_('Consulter le livre en ligne'), - [ 'target'=> '_blank' ]); + ['data-popup' => 'true']); } @@ -61,8 +61,8 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement return $this->getDilicomAnchor(['controller' => 'bib-numerique', 'action' => 'loan-book-ajax', 'id' => $this->_album->getId()], - $this->view->_('Emprunter le livre au format EPUB') - ); + $this->view->_('Emprunter le livre au format EPUB'), + ['data-popup' => 'true']); } diff --git a/library/ZendAfi/View/Helper/TagSearchExtension.php b/library/ZendAfi/View/Helper/TagSearchExtension.php new file mode 100644 index 0000000000000000000000000000000000000000..5dbd86ac584f7217aec1b0f52348af34d24a523c --- /dev/null +++ b/library/ZendAfi/View/Helper/TagSearchExtension.php @@ -0,0 +1,72 @@ +<?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_TagSearchExtension extends ZendAfi_View_Helper_BaseHelper { + protected $_criteres, $_config; + + public function tagSearchExtension($criteres) { + $this->_config = json_decode(Class_AdminVar::get('SEARCH_ALSO_IN'), true); + $this->_criteres = $criteres; + + if (!$this->_shouldDisplay()) + return ''; + + $this->_criteres = $criteres; + $links = $this->_renderLinks(); + + return $links ? + $this->_tag('div', + $this->_('Rechercher aussi sur ') . implode('', $links), + ['class' => 'search_extensions']) + : ''; + } + + + protected function _shouldDisplay() { + return $this->_config && $this->_criteres->hasExpressionRecherche(); + } + + + protected function _renderLinks() { + $links = []; + foreach ($this->_config['site_label'] as $k => $site_label) + $links[] = $this->_renderLink($k, $site_label); + + return array_filter($links); + } + + + protected function _renderLink($k, $site_label) { + $site_url = $this->_config['site_url'][$k]; + if (!$site_url || !$site_label) + return null; + + return $this->_tag('span', + $this->view->tagAnchor($this->_injectSearchTerm($site_url), + $site_label)); + } + + + protected function _injectSearchTerm($url) { + return sprintf($url, $this->_criteres->getExpressionRecherche()); + } +} \ No newline at end of file diff --git a/library/startup.php b/library/startup.php index e69f68ab531a881f13a9890a296bdfee324ad5a8..eb6a6c96dc593c0629d2455f64cd2265e31dacab 100644 --- a/library/startup.php +++ b/library/startup.php @@ -64,7 +64,7 @@ function defineConstant($name, $value) { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.3'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.18'); + 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 90b5177c9fa1d3f553f6abe858baba74f8dca8d6..f94951c8badd39a799bafc6cdcffc5b714511b91 160000 --- a/library/storm +++ b/library/storm @@ -1 +1 @@ -Subproject commit 90b5177c9fa1d3f553f6abe858baba74f8dca8d6 +Subproject commit f94951c8badd39a799bafc6cdcffc5b714511b91 diff --git a/public/admin/css/global.css b/public/admin/css/global.css index 9f9f905d05456f767906560f0a6632a41f226707..2b1c243e8b064a5e0c35705f279ac95e37a6947c 100644 --- a/public/admin/css/global.css +++ b/public/admin/css/global.css @@ -599,6 +599,20 @@ table.subscribers td { width: 100%; } + +.critique .vignette_notice { + position: relative; +} + + +.critique .vignette_notice .icone_support { + position: absolute; + margin: 2px; + width: auto; + right: 0px; +} + + .critique h2 { margin-top:0px; } diff --git a/public/admin/css/subModal.css b/public/admin/css/subModal.css index 05e84f39d64e3a2ddb68cce855b8734dfea5834f..a81dc1102c9ad24e3dc28ac770f85595e5313e99 100644 --- a/public/admin/css/subModal.css +++ b/public/admin/css/subModal.css @@ -64,6 +64,8 @@ a[data-popup="true"].image-loading-status { background:url(../images/patience.gif) no-repeat center; width: 16px; height: 16px; + overflow: hidden; + font-size: 0; } diff --git a/public/admin/js/onload_utils.js b/public/admin/js/onload_utils.js index f66137c3f2eb91773611003955b700c616a5a1f7..4637978cc0e3d562e587e36d725e8544beda91d5 100644 --- a/public/admin/js/onload_utils.js +++ b/public/admin/js/onload_utils.js @@ -52,6 +52,7 @@ var setupAnchorsTarget = function() { $('a[href^="http"]').each(function() { if (!internalLink.test($(this).attr('href')) && (undefined == this.onclick) + && (undefined == $._data(this, 'events') || undefined == $._data(this, 'events').click) && (undefined == $(this).data('events') || undefined == $(this).data('events').click)) { if ($.browser.msie || !!navigator.userAgent.match(/Trident/)) { // Otherwise IE doesn't send HTTP Referer diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 083bc9714d181e8ba0b0f20879bb79ee49709777..74e29d018fa3b96b306b36f85c0676b0aaa67aae 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1415,21 +1415,24 @@ body.abonne_multimedia-hold-view .actions a { } -.recherche_actions { +.recherche_actions, .search_extensions { margin-top: 10px; clear: both; } -.recherche_actions span { +.recherche_actions span, .search_extensions span { padding-right: 10px; } -.recherche_actions a:before { +.recherche_actions a:before, .search_extensions a:before { content: "» "; } +.search_extensions { + text-align:right; +} #menu_horizontal { position: relative; @@ -3101,4 +3104,50 @@ a.loan-export { .boite.library p.closed { background: url(../images/buttons/ledred.png) no-repeat left center; +} + + +#opac-dialog a.button { + display: inline-block; + text-align: center; + padding: 2px 5px; + border-radius: 5px; + line-height: 2em; + margin: 5px; + font-size: 1.2em; + font-weight: bold; + min-width: 60px; + text-transform: uppercase; + text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.25); + cursor: pointer; + color: #FFF; + white-space: nowrap; +} + +#opac-dialog a.button.blue { + background: #008CFF; +} + + +#opac-dialog a.button.red { + background: #DF1B1B; +} + + +#opac-dialog a.button.blue:hover { + background: #004F8F; +} + + +#opac-dialog a.button.red:hover { + background: #8F1111; +} + +#opac-dialog div.popup-content { + padding: 5px; +} + +#opac-dialog div.popup-content, +#opac-dialog div.popup-content * { + vertical-align: middle; } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 4e8692448cdb0d56297ff27b51ceafc4d3f44b2d..1478e833a80312147f614646c9e73aaa58b00d03 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -311,10 +311,17 @@ class AccueilControllerConfigSitothequeDefaultsTest extends Admin_AbstractContro $this->assertXPath('//input[@type="radio"][@name="display_order"][@value="Random"]'); } + /** @test */ public function displayOrderSelectionShouldBePresent() { $this->assertXPath('//input[@type="radio"][@name="display_order"][@value="Selection"]'); } + + +/** @test */ + public function rssFlowPreferenceShouldBePresent() { + $this->assertXPath('//input[@type="checkbox"][@name="rss"]', $this->_response->getBody()); + } } diff --git a/tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php b/tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php index 2f9324112698c367aac768888c8e5b30a2f3ca2e..0c761711256fa6767758be78deaf5376e4fc3ec1 100644 --- a/tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminAvisModerationControllerTest.php @@ -127,6 +127,7 @@ class AdminAvisModerationControllerAvisToModerateTest extends AdminAvisModeratio class AdminAvisModerationControllerAvisDelTest extends AdminAvisModerationControllerTestCase { public function setUp() { parent::setUp(); + $_SERVER['HTTP_REFERER']='/admin/modo/avisnotice'; $this->dispatch('/admin/modo/delavisnotice/id/38'); } @@ -189,6 +190,7 @@ class AdminAvisModerationControllerAvisEditPostTest extends AdminAvisModerationC 'clef_alpha' => 'GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1', 'titre_principal' => 'La garçonnière' ]); + Class_AvisNotice::find(38)->setFlags(1)->save(); new ZendAfi_Controller_Action_Helper_FlashMessenger(); $this->postDispatch('/admin/modo/editavisnotice/id/38', ['url' => 'http://localhost/recherche/viewnotice/expressionRecherche/la+garconniere/tri/%2A/facette/T1/clef/GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1/id/1190178', @@ -202,6 +204,19 @@ class AdminAvisModerationControllerAvisEditPostTest extends AdminAvisModerationC Class_AvisNotice::find(38)->getClefOeuvre()); } + + public function testIdNoticeShouldBeUpdated() { + $this->assertEquals(1190178, + Class_AvisNotice::find(38)->getIdNotice()); + } + + + public function testReviewShouldBeNotFlaggedAnymore() { + $this->assertEquals(0, + Class_AvisNotice::find(38)->getFlags()); + } + + public function testRecordShouldBeUpdated() { $this->assertEquals('after', Class_AvisNotice::find(38)->getAvis()); diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index ab47be28548f8efccd24d16726537ae000e86684..abe9116d9b6eb7485cd7900a503f50378c02de3f 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -284,6 +284,46 @@ class AdminIndexControllerAdminVarEditActionTest extends Admin_AbstractControlle } } +class AdminIndexControllerAdminVarEditCKEditorActionTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile=true; + public function setUp() { + parent::setUp(); + } + + /** @test */ + public function defaultValueShouldBeSet() { + $this->assertEquals('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.',Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE')); + } + + /** @test */ + public function editPageShouldContainsTitlePNBLoanMessage() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => '']); + + $this->dispatch('/admin/index/adminvaredit/cle/DILICOM_PNB_LOAN_WARNING_MESSAGE'); + $this->assertQueryContentContains('h1', + 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + $this->_response->getBody()); + } + + /** @test */ + public function postEnrichTextShouldNotRemoveTags() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => '']); + $this + ->getRequest() + ->setMethod('POST') + ->setPost(['cle' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => "<b>don't use this, drm are dangerous!</b>"]); + $this->dispatch('/admin/index/adminvaredit/cle/DILICOM_PNB_LOAN_WARNING_MESSAGE'); + $this->assertEquals('<b>don\'t use this, drm are dangerous!</b>', Class_AdminVar::get('DILICOM_PNB_LOAN_WARNING_MESSAGE')); + } + + +} + abstract class AdminIndexControllerAdminVarEditWithWorkflowTestCase extends Admin_AbstractControllerTestCase { public function setUp() { @@ -709,3 +749,94 @@ class AdminIndexControllerDisplayModifierNomDomaineTest extends AbstractControll $this->assertNotXpathContentContains('//div[@class="modules"]//a', 'Modifier'); } } + + + +abstract class AdminIndexControllerAdminVarEditSearchAlsoInTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_AdminVar', + ['id' => 'SEARCH_ALSO_IN', + 'valeur' => json_encode(['site_label' => ['Jumel'], + 'site_url' => ['http://testing.fr?q=%s']])]); + + + } +} + + + +class AdminIndexControllerAdminVarEditSearchAlsoInTest + extends AdminIndexControllerAdminVarEditSearchAlsoInTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/index/adminvaredit/cle/SEARCH_ALSO_IN', true); + } + + + /** @test */ + public function shouldDisplayLabel() { + $this->assertXpathContentContains('//p', 'Liste des sites de recherche élargie', $this->_response->getBody()); + } + + + /** @test */ + public function shouldDisplayId() { + $this->assertXpathContentContains('//h1', 'SEARCH_ALSO_IN', $this->_response->getBody()); + } + + + /** @test */ + public function scriptShouldContainsSiteLabel() { + $this->assertXpathContentContains('//script', 'Nom du site'); + } + + + /** @test */ + public function scriptShouldContainsSiteUrlLabel() { + $this->assertXpathContentContains('//script', 'Url de recherche'); + } + + + /** @test */ + public function scriptShouldcontainsSiteLabelValue() { + $this->assertXpathContentContains('//script', 'Jumel', $this->_response->getBody()); + } + + + /** @test */ + public function scriptShouldcontainsSiteUrlValue() { + $this->assertXpathContentContains('//script', 'http:\\/\\/testing.fr?q=%s', + $this->_response->getBody()); + } +} + + + +class AdminIndexControllerAdminVarEditSearchAlsoInPostTest + extends AdminIndexControllerAdminVarEditSearchAlsoInTestCase { + + public function setUp() { + parent::setUp(); + $this->postDispatch('/admin/index/adminvaredit/cle/SEARCH_ALSO_IN', + ['site_label' => ['Jumelles'], + 'site_url' => ['http://jumelles.fr/?q=%s']]); + } + + + /** @test */ + public function varShouldContainsJumelles() { + $this->assertContains('Jumelles', Class_AdminVar::find('SEARCH_ALSO_IN')->getValeur()); + } + + + /** @test */ + public function varShouldContainsUrl() { + $this->assertContains('http://jumelles.fr/?q=%s', + Class_AdminVar::find('SEARCH_ALSO_IN')->getValeur()); + } +} diff --git a/tests/application/modules/admin/controllers/CmsControllerListModeTest.php b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php index 72043ba947ab5ebed5f3669de1c8e2ba2d2a5b28..85cb9a1d2bc7649be678010b1153135aaebcf3c4 100644 --- a/tests/application/modules/admin/controllers/CmsControllerListModeTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php @@ -149,6 +149,37 @@ class CmsControllerListModeAdminBibRootWithoutPermissionsTest +class CmsControllerListModeAdminSubCategoryTest extends CmsControllerListModeTestCase { + public function setUp() { + parent::setUp(); + + $other_cat = $this->fixture('Class_ArticleCategorie', + ['id' => 452, + 'libelle' => 'Monkey', + 'parent_categorie' => $this->root_category, + ]); + + $group = Class_UserGroup::find(22); + Class_Permission::createArticleCategory()->permitTo($group, $this->root_category); + + $this->dispatch('/admin/cms/index/id_cat/1', true); + } + + + /** @test */ + public function categoryMonkeyEditLinkShouldBeCmsCategoryEditId23() { + $this->assertXPath('//td//a[contains(@href, "cms-category/edit/id/452")]'); + } + + + /** @test */ + public function categoryMonkeyDeleteLinkShouldBeCmsCategoryDeleteId23() { + $this->assertXPath('//td//a[contains(@href, "cms-category/delete/id/452")]'); + } +} + + + class CmsControllerListModeAdminBibSubCategoryTest extends CmsControllerListModeTestCase { public function setUp() { @@ -160,14 +191,16 @@ class CmsControllerListModeAdminBibSubCategoryTest 'titre' => 'Wtf', 'contenu' => 'Welcome', 'id_cat' => 1]); + $other_cat = $this->fixture('Class_ArticleCategorie', ['id' => 2, 'libelle' => 'Lyrics', 'parent_categorie' => $this->root_category, - ]); - $other_cat->setBib($this->annecy); + ]); + + $other_cat->setBib($this->annecy); $group = Class_UserGroup::find(22); - Class_ArticleCategorie::find(23)->setLibelle('Modes')->save(); + Class_ArticleCategorie::find(23)->setLibelle('Modes')->save(); Class_Permission::createArticle()->permitTo($group, $other_cat); Class_Permission::createArticleCategory()->permitTo($group, $other_cat); @@ -191,7 +224,7 @@ class CmsControllerListModeAdminBibSubCategoryTest /** @test */ public function shouldDisplayModesCategory() { $this->assertXPathContentContains('//tr[2]//td/a[1][contains(@href, "cms/index/id_cat/23")]', - 'Modes'); + 'Modes',$this->_response->getBody()); } @@ -211,9 +244,76 @@ class CmsControllerListModeAdminBibSubCategoryTest -class CmsControllerListModeAdminBibSearchTest +class CmsControllerListModeSearchTest extends CmsControllerListModeTestCase { public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->logUser($this->_bernard); + + $this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'News from bib', + 'contenu' => 'Welcome', + 'categorie' => Class_ArticleCategorie::find(1)]); + + $this->fixture('Class_Article', + ['id' => 2, + 'titre' => 'News from portail', + 'contenu' => 'Welcome', + 'categorie' => Class_ArticleCategorie::find(23)]); + $this->fixture('Class_ArticleCategorie', + ['id' => 3400, + 'libelle' => 'Racine CRan', + 'parent_categorie' => Class_ArticleCategorie::find(340), + 'sous_categories' => []]); + + $this->fixture('Class_ArticleCategorie', + ['id' => 340, + 'libelle' => 'first level', + 'parent_categorie' => Class_ArticleCategorie::find(3400), + 'sous_categories' => []]); + + $this->fixture('Class_ArticleCategorie', + ['id' => 44, + 'libelle' => 'second level', + 'parent_categorie' => Class_ArticleCategorie::find(340), + 'sous_categories' => []]); + + $this->annecy->setArticleCategories([Class_ArticleCategorie::find(3400)])->save(); + + $this->fixture('Class_Article', + ['id' => 3, + 'titre' => 'News evenement', + 'contenu' => 'Welcome', + 'categorie' => Class_ArticleCategorie::find(44)]); + + + $this->fixture('Class_Article', + ['id' => 4, + 'titre' => 'Top cat evenement', + 'contenu' => 'Welcome', + 'categorie' => Class_ArticleCategorie::find(3400)]); + + + + $this->dispatch('/admin/cms/index/title_search/news', true); + } + + + /** @test */ + public function newsEvenementShouldBePresent() { + $this->assertXPathContentContains('//td', 'News evenement', $this->_response->getBody()); + } + + + /** @test */ + public function newsFromPortailShouldNotBePresent() { + $this->assertNotXPathContentContains('//td', 'News from portail', $this->_response->getBody()); + } +} + +class CmsControllerListModeAdminBibSearchTest extends CmsControllerListModeTestCase { + public function setUp() { parent::setUp(); ZendAfi_Auth::getInstance()->logUser($this->_admin_bib); @@ -229,17 +329,17 @@ class CmsControllerListModeAdminBibSearchTest 'contenu' => 'Welcome', 'categorie' => Class_ArticleCategorie::find(23)]); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('findAllBy') ->with(['where' => 'titre like \'%news%\'', - 'id_cat' => [1], + 'id_cat' => [1,23,34], 'order' => 'titre', 'limitPage' => [0, 25]]) ->answers([Class_Article::find(1)]) - ->whenCalled('countBy') ->with(['where' => 'titre like \'%news%\'', - 'id_cat' => [1], + 'id_cat' => [1,23,34], 'order' => 'titre']) ->answers(2) @@ -249,13 +349,13 @@ class CmsControllerListModeAdminBibSearchTest } + /** @test */ public function newsFromPortailShouldNotBePresent() { $this->assertNotXPathContentContains('//td', 'News from portail', $this->_response->getBody()); } -} - +} class CmsControllerListModeEditWithPaginationTest extends CmsControllerListModeTestCase { diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index 0ebeb7cbc1b9364be48d0540d9cd0244a80612b2..588f5824cd45f06192c2a4c7fd4c00e35d5a0a62 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -302,7 +302,6 @@ class CmsControllerArticleConcertAsAdminPortailEditActionTest extends CmsControl $this->assertXPathContentContains('//td','Tom et Jerry'); } - /** @test */ public function contentHeadShouldContainsLastEditOn26December() { $this->assertXPathContentContains('//div[@class="content_edit_head"]//dl/dd[preceding-sibling::dt[contains(text(), "Modifié le")]]', @@ -435,6 +434,7 @@ class CmsControllerArticleConcertAsReferentEditActionTest extends CmsControllerA $this->dispatch('/admin/cms/edit/id/4', true); } + } @@ -1955,9 +1955,22 @@ class CmsControllerArticleEditActionWithFormTest extends CmsControllerWithPermis /** @test */ public function emailShouldBePresentOnFourthPosition() { - $this->assertXPath("//table//tr[4]//input[@name='destination_email'][@type='email']", + $this->assertXPath("//table//tr[5]//input[@name='destination_email'][@type='email']", $this->_response->getBody()); } + + + /** @test */ + public function articleShouldContainsCategorySelector() { + $this->assertXPath('//table/tr[4]//select[@name="id_cat"]',$this->_response->getBody()); + } + + + /** @test */ + public function articleShouldContainsPublication() { + $this->assertXPath('//table/tr[6]//input[@name="debut"]',$this->_response->getBody()); + } + } diff --git a/tests/application/modules/admin/controllers/ModoControllerTest.php b/tests/application/modules/admin/controllers/ModoControllerTest.php index 4b042f15cc6a998d7c0ba9db5f9709e7f6499cfb..9ec78abf35d6de487a2cc02b69642d406c575d9f 100644 --- a/tests/application/modules/admin/controllers/ModoControllerTest.php +++ b/tests/application/modules/admin/controllers/ModoControllerTest.php @@ -53,9 +53,25 @@ class ModoControllerIndexActionTest extends Admin_AbstractControllerTestCase { $this->fixture('Class_AvisNotice', ['id' => 1, 'id_notice' => 1002, 'entete' => 'Mon avis', + 'note'=> 2, + 'id_user' => null, 'avis' => 'Ce livre est vraiment bien !', 'statut' => 0]); + $this->fixture('Class_Notice', ['id' => 1032, + 'titre_principal' => 'B comme bière : la bière expliquée aux (grands) enfants']); + + $this->fixture('Class_AvisNotice', ['id' => 223, + 'id_notice' => 1002, + 'entete' => 'Bulles', + 'note'=> 2, + 'id_user' => null, + 'flags' => 0, + 'avis' => ' Pour faire aimer la biere aux enfants!', + 'id_notice' => 1032, + 'statut' => 1]); + + $this->fixture('Class_SuggestionAchat', ['id' => 92, 'titre' => 'Kikolol', 'auteur' => 'Moi', @@ -602,13 +618,103 @@ class ModoControllerAvisnoticeActionTest extends Admin_AbstractControllerTestCas /** @test **/ public function avisnoticeShouldContainsListAvisBibliothecaires() { - $this->assertXpathContentContains('//div//h2', 'Bibliothécaires', $this->_response->getBody()); + $this->assertXpathContentContains('//div//h2', 'bibliothécaires', $this->_response->getBody()); } /** @test **/ public function avisnoticeShouldContainsListAvisAbonnes() { - $this->assertXpathContentContains('//div//h2', 'Abonnés', $this->_response->getBody()); + $this->assertXpathContentContains('//div//h2', 'abonnés', $this->_response->getBody()); + } + + + /** @test **/ + public function avisnoticeShouldContainsOrphanFlag() { + $this->assertXpathContentContains('//div//h2', 'Avis orphelins', $this->_response->getBody()); + } + + + /** @test */ + public function LinkToAllModeratedReviewsShouldBeDisplayed() { + $this->assertXPathContentContains('//a', 'Afficher tous les avis modérés', $this->_response->getBody()); + } +} + + + + + +class ModoControllerAllReviewsActionTest extends ModoControllerIndexActionTest { + + public function setup() { + parent::setup(); + $this->dispatch('admin/modo/allreviews', true); + } + + + /** @test **/ + public function moderatedReviewsShouldBeDisplayed() { + $this->assertXpathContentContains('//div//h2', 'B comme bière : la bière expliquée aux (grands) enfants', $this->_response->getBody()); + } + + + /** @test **/ + public function unmoderatedReviewsShouldNotBeDisplayed() { + $this->assertNotXpathContentContains('//div//h2', 'Para Ana', $this->_response->getBody()); + } + +} + + + + + +class ModoControllerAllReviewsPageActionTest extends ModoControllerIndexActionTest { + + public function setup() { + parent::setup(); + $this->dispatch('admin/modo/allreviews/page/10', true); + } + + + /** @test **/ + public function moderatedReviewsShouldBeDisplayedEvenIfPageIsOutOfBound() { + $this->assertXpathContentContains('//div//h2', 'B comme bière : la bière expliquée aux (grands) enfants', $this->_response->getBody()); + } + + + /** @test */ + public function LinkToNonModeratedReviewsShouldBeDisplayed() { + $this->assertXPathContentContains('//a', 'Afficher les avis non modérés', $this->_response->getBody()); + } +} + + + +class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionTest { + + public function setup() { + parent::setup(); + } + + /** @test **/ + public function moderatedReviewsShouldBeArchived() { + $this->dispatch('admin/modo/invisibleavisnotice/id/223', true); + $this->assertEquals(2,Class_AvisNotice::find(223)->getFlags()); + } + + /** @test **/ + public function moderatedReviewsShouldBeVisible() { + $avis=(Class_AvisNotice::find(223)); + $avis->setFlags(2); + $avis->save(); + $this->dispatch('admin/modo/visibleavisnotice/id/223', true); + $this->assertEquals(0,Class_AvisNotice::find(223)->getFlags()); + } + } + + + ?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/OpdsControllerTest.php b/tests/application/modules/admin/controllers/OpdsControllerTest.php index 5a52e832673072c82f8d5af8b7429c970cb6356d..91a91791a82802888a4b41a89d47eda964a1f30b 100644 --- a/tests/application/modules/admin/controllers/OpdsControllerTest.php +++ b/tests/application/modules/admin/controllers/OpdsControllerTest.php @@ -380,6 +380,8 @@ class Admin_OpdsControllerActionsWithUnknowCatalogTest extends Admin_OpdsControl } } + + abstract class Admin_OpdsControllerBrowseAtramentaTestCase extends Admin_OpdsControllerTestCase { public function setUp() { parent::setUp(); @@ -393,18 +395,22 @@ abstract class Admin_OpdsControllerBrowseAtramentaTestCase extends Admin_OpdsCon } } + + class Admin_OpdsControllerBrowseAtramentaActionTest extends Admin_OpdsControllerBrowseAtramentaTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/admin/opds/browse/id/3'); + $this->dispatch('/admin/opds/browse/id/3', true); } + /** @test */ public function titleShouldBeParcoursDuCatalogueAtramenta() { - $this->assertXPathContentContains('//h1', 'Parcours du catalogue "Atramenta"', $this->_response->getBody()); + $this->assertXPathContentContains('//h1', 'Parcours du catalogue "Atramenta"'); } + /** @test */ public function searchFieldShouldNotBePresent() { $this->assertNotXPath('//div[@class="panel"]//input[@name="search"]'); diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index 0c892f060deb7f8358e8c62f6fcde8ab0309d38c..ddd36a72a8ee23eb7f3a08c82dbc33ef1dcf9359 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -115,7 +115,6 @@ class UsersControllerEditMarcusTest extends UsersControllerWithMarcusTestCase { $this->dispatch('/admin/users/edit/id/10', true); } - /** @test **/ public function roleLevelShouldBeSIGBSubscriber() { $this->assertXpathContentContains('//tr/td','abonné identifié SIGB'); @@ -164,6 +163,13 @@ class UsersControllerEditMarcusTest extends UsersControllerWithMarcusTestCase { } + + /** @test **/ + public function testHiddenInputForRole() { + $this->assertXPath("//input[@name='role'][@value=2][@type='hidden']",$this->_response->getBody()); + } + + /** @test **/ public function testSelectedBibIsIdOne() { $this->assertXPath("//input[@name='bib'][@value='1']", $this->_response->getBody()); @@ -239,7 +245,21 @@ class UsersControllerEditMarcusTest extends UsersControllerWithMarcusTestCase { } -class rsControllerEditMarcusAsAdminPortailTest extends UsersControllerWithMarcusTestCase { +class UsersControllerEditMarcusAsAbonPortailTest extends UsersControllerWithMarcusTestCase { + public function setUp() { + parent::setUp(); + } + + + /** @test */ + function comboBibShouldNotBeVisible() { + $this->dispatch('/admin/users/edit/id/10'); + $this->assertNotXPath('//select[@name="bib"]'); + } +} + + +class UsersControllerEditMarcusAsAdminPortailTest extends UsersControllerWithMarcusTestCase { public function setUp() { parent::setUp(); $this->marcus->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL); @@ -262,8 +282,6 @@ class rsControllerEditMarcusAsAdminPortailTest extends UsersControllerWithMarcus } - - class UsersControllerDeleteMarcusTest extends UsersControllerWithMarcusTestCase { public function setUp() { parent::setUp(); @@ -471,6 +489,17 @@ class UsersControllerPostValidDataWithCommOpsysTest extends UsersControllerWithM ->answers(true); } + + /** @test */ + public function idAbonShouldNotBeModified() { + $this->assertEquals('00123',Class_Users::find(10)->getIdabon()); + } + + /** @test */ + public function roleShouldNotBeModified() { + $this->assertEquals(ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,Class_Users::find(10)->getRoleLevel()); + } + protected function _postData() { $this->_postEditData(array('username' => 'mdavis', 'password' => 'tutu', diff --git a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php index b678eae6443f6a10e55afc965d81ee337b751a38..f081f6303ee1b17b740e4a7ba1b5a936a22d037a 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php @@ -21,6 +21,8 @@ require_once 'AbstractControllerTestCase.php'; abstract class AbonneFlorenceIsLoggedControllerTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + protected function _initProfilHook($profil) { $profil ->setBrowser('opac') @@ -30,19 +32,23 @@ abstract class AbonneFlorenceIsLoggedControllerTestCase extends AbstractControll public function setUp() { parent::setUp(); - Class_Users::beVolatile(); - Class_AvisNotice::beVolatile(); - Class_Notice::beVolatile(); - $this->florence = Class_Users::newInstanceWithId(123456) - ->setPseudo('FloFlo') - ->setRoleLevel(2) - ->setRole('abonne_sigb') - ->setLogin('florence') - ->setPassword('caramel') - ->setIdSite(1) - ->setIdabon('00123') - ->setFicheSIGB(['type_com' => 0]); - $this->florence->save(); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MIN_SAISIE', + 'valeur' => 0]); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MAX_SAISIE', + 'valeur' => 1000]); + + $this->florence = $this->fixture('Class_Users', + ['id' => 123456, + 'pseudo' => 'FloFlo', + 'role_level' => 2, + 'role' => 'abonne_sigb', + 'login' => 'florence', + 'password' => 'caramel', + 'id_site' => 1, + 'idabon' => '00123', + 'fiche_sigb' => ['type_com' => 0]]); ZendAfi_Auth::getInstance()->logUser($this->florence); @@ -207,12 +213,12 @@ class AbonneControllerAvisNoticeWithAvisTest extends AbonneControllerAvisTestCas public function setUp() { parent::setUp(); - $avis = Class_AvisNotice::newInstanceWithId(12, ['Avis' => 'Excellent livre', - 'Entete' => 'Le sorcier super mimi', - 'note' => 4, - 'clef_oeuvre' => 'POTTER', - 'user' => $this->florence]); - $avis->save(); + $avis = $this->fixture('Class_AvisNotice', ['id' => 12, + 'Avis' => 'Excellent livre', + 'Entete' => 'Le sorcier super mimi', + 'note' => 4, + 'clef_oeuvre' => 'POTTER', + 'user' => $this->florence]); $this->dispatch('/opac/abonne/avis/id_notice/53'); $this->_xpath = new Storm_Test_XPath(); $this->_json = json_decode($this->_response->getBody()); @@ -250,105 +256,128 @@ abstract class AvisControllersFixturesTestCase extends AbonneFlorenceIsLoggedCon public function setUp() { parent::setUp(); - $this->modo_avis = new Class_AdminVar(); - $this->modo_avis - ->setId('MODO_AVIS') - ->setValeur(0); - $this->modo_avis_biblio = new Class_AdminVar(); - $this->modo_avis_biblio - ->setId('MODO_AVIS_BIBLIO') - ->setValeur(0); + $this->fixture('Class_AdminVar', + ['id' => 'MODO_AVIS', + 'valeur' => 0]); - $this->readspeaker = new Class_AdminVar(); - $this->readspeaker - ->setId('ID_READ_SPEAKER') - ->setValeur('54QCJRHZ31IPBV7GW3DKBPUYYP579A14'); + $this->fixture('Class_AdminVar', + ['id' => 'MODO_AVIS_BIBLIO', + 'valeur' => 0]); + $this->fixture('Class_AdminVar', + ['id' => 'ID_READ_SPEAKER', + 'valeur' => '54QCJRHZ31IPBV7GW3DKBPUYYP579A14']); - Class_AdminVar::getLoader() - ->cacheInstance($this->modo_avis) - ->cacheInstance($this->modo_avis_biblio) - ->cacheInstance($this->readspeaker); - $this->millenium = Class_Notice::newInstanceWithId(816, ['titre_principal' => 'Millenium', - 'clef_alpha' => 'MILLENIUM', - 'auteur_principal' => 'Stieg Larsson', - 'url_vignette' => '', - 'url_image' => '' - ] + $this->millenium = $this->fixture('Class_Notice', ['id' => 816, + 'titre_principal' => 'Millenium', + 'clef_alpha' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => '', + 'url_image' => '' + ] ); - $this->millenium->save(); - $this->millenium_with_vignette = Class_Notice::newInstanceWithId(817, ['titre_principal' => 'Millenium', - 'clef_alpha' => 'MILLENIUM', - 'auteur_principal' => 'Stieg Larsson', - 'url_vignette' => 'http://amazon.com/vignette_millenium.png' - ] + + + + + $this->millenium_with_vignette = $this->fixture('Class_Notice', ['id' => 817, + 'titre_principal' => 'Millenium', + 'clef_alpha' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => 'http://amazon.com/vignette_millenium.png' + ] ); - $this->millenium_with_vignette->save(); + $this->avis_millenium = $this->fixture('Class_AvisNotice', ['id' => 13, 'entete' => "J'adore", - 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', - 'note' => 5, - 'date_avis' => '2011-03-18 13:00:00', - 'user' => $this->florence, - 'statut' => 0, - 'abon_ou_bib'=>1 , - 'notices' => [$this->millenium, - $this->millenium_with_vignette] ]); - - $this->avis_millenium->save(); - $this->potter = Class_Notice::newInstance(); - $this->potter - ->setTitrePrincipal('Potter et la chambre des secrets') - ->setAuteurPrincipal('') - ->setUrlVignette('http://amazon.com/vignette_potter.png'); - $this->potter->save(); - $this->avis_potter = Class_AvisNotice::newInstanceWithId(25, - ['entete' => 'Prenant', - 'avis' => "Mais un peu trop naïf", - 'note'=>4, - 'date_avis' => '2010-10-12 10:00:00', - 'user'=>$this->florence, - 'statut' => 1, - 'abon_out_bib' => 1, - 'notices' => [$this->potter]]); - - $this->avis_potter->save(); - - $this->avis_lost = Class_AvisNotice::newInstanceWithId(67, - ['entete' =>"C'est perdu", - 'avis' =>"Plus de notice, ni d'utilisateur", - 'note' => 4, - 'date_avis' => '2008-10-12 10:00:00', - 'user'=>null, - 'statut' => 1, - 'abon_out_bib' => 1, - 'notices' => []]); - $this->avis_lost->save(); - - - $this->florence->setAvis([$this->avis_millenium, $this->avis_potter]); - $this->florence->save(); - $dupont = Class_Users::newInstanceWithId(56, ['nom'=>'Dupont']); - - $avis_millenium_dupont = Class_AvisNotice::newInstanceWithId(156) - ->setEntete("Cool") - ->setAvis("effrayant") - ->setNote(5) - ->setDateAvis('2011-03-18 13:00:00') - ->setAuteur($dupont) - ->setUser($dupont) - ->setStatut(0) - ->setAbonOuBib(1) - ->setNotices([$this->millenium]); - $dupont->setAvis([$avis_millenium_dupont]); - $dupont->save(); - $avis_millenium_dupont->save(); + 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', + 'note' => 5, + 'date_avis' => '2011-03-18 13:00:00', + 'user' => $this->florence, + 'statut' => 0, + 'abon_ou_bib'=>1 , + 'notices' => [$this->millenium, + $this->millenium_with_vignette] ]); + + $this->potter = $this->fixture('Class_Notice', + ['id'=> 22, + 'titre_principal' => 'Potter et la chambre des secrets', + 'auteur_principal' => '', + 'url_vignette' => 'http://amazon.com/vignette_potter.png']); + + $this->avis_potter = $this->fixture('Class_AvisNotice', + ['id' => 25, + 'entete' => 'Prenant', + 'avis' => "Mais un peu trop naïf", + 'note'=>4, + 'date_avis' => '2010-10-12 10:00:00', + 'user'=>$this->florence, + 'statut' => 1, + 'abon_out_bib' => 1, + 'notices' => [$this->potter]]); + + $lost=$this->fixture('Class_AvisNotice', ['id' => 178, + 'entete' => "Lost highway", + 'clef_oeuvre' => 'LOST-LOST', + 'avis' => 'Oh po po !', + 'note' => 5, + 'date_avis' => '2015-03-18 13:00:00', + 'user' => $this->florence, + 'statut' => 1, + 'flags' => Class_AvisNotice::ORPHAN_FLAG, + 'abon_ou_bib'=>1, + 'id_notice' => 30]); + + + $this->avis_lost = $this->fixture('Class_AvisNotice', + ['id' => 67, + 'entete' =>"C'est perdu", + 'avis' =>"Plus de notice, ni d'utilisateur", + 'note' => 4, + 'date_avis' => '2008-10-12 10:00:00', + 'user'=>null, + 'statut' => 1, + 'abon_out_bib' => 1, + 'flags' => 1, + 'notices' => []]); + + + + $dupont = $this->fixture('Class_Users', ['id' => 56 , + 'login' => 'Dupont', + 'nom'=>'Dupont', + 'password' => 'pwd', + 'id_abon' => 435]); + + + $avis_millenium_dupont = $this->fixture('Class_AvisNotice', + ['id' => 156, + 'entete' => "Cool", + 'avis' => "effrayant", + 'note' => 5, + 'setDateAvis' => '2011-03-18 13:00:00', + 'auteur' => $dupont, + 'user' => $dupont, + 'statut' => 0, + 'abon_out_bib' => 1, + 'notices' =>[$this->millenium] + ]); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') + ->whenCalled('findAllBy') + ->with(['where' => 'clef_oeuvre like "LOST-%"']) + ->answers(null) + ->whenCalled('findAllBy') + ->with(['where' => 'clef_oeuvre like "MILLENIUM-%"']) + ->answers([$this->millenium,$this->millenium_with_vignette]) + ; + + } } @@ -381,9 +410,9 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT } /** @test */ - public function pageShouldDisplayVousAvezRedigeDeuxAvis() { + public function pageShouldDisplayVousAvezRedigeTroiAvis() { $this->assertXPathContentContains('//a', - 'Vous avez rédigé 2 avis', + 'Vous avez rédigé 3 avis', $this->_response->getBody()); } @@ -392,6 +421,8 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT public function linkAvisShouldGoToAbonneViewAvis() { $this->assertXPath('//a[contains(@href, "/abonne/viewavis/id/123456")]'); } + + } @@ -400,26 +431,36 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT class AbonneControllerAvisBlogControllerViewAuteurActionTest extends AvisControllersFixturesTestCase { public function setUp() { parent::setUp(); + + $this->dispatch('/opac/blog/viewauteur/id/123456'); } + + /** @test */ + public function AvisWithoutNoticeShouldBeDisplayedForAuthor() { + $this->assertXPathContentContains("//div[@class='critique'][1]//a", 'Lost highway'); + } + + public function testPageIsRendered() { $this->assertController('blog'); $this->assertAction('viewauteur'); } public function testMilleniumIsHere() { - $this->assertXPathContentContains("//div[@class='critique'][1]//h2", 'Millenium (Stieg Larsson)'); + $this->assertXPathContentContains("//div[@class='critique'][2]//h2", 'Millenium (Stieg Larsson)'); } + /** @test */ public function milleniumShouldLinkToNoticeMilleniumWithRetourAbonneViewAvis() { - $this->assertXPath('//a[contains(@href, "/recherche/viewnotice/id/817/clef/MILLENIUM/retour_abonne/viewavis")]',$this->_response->getBody()); + $this->assertXPath('//a[contains(@href, "/recherche/viewnotice/id/817/clef/MILLENIUM/retour_abonne/viewavis")]'); } public function testPotterIsHere() { - $this->assertXPathContentContains("//div[@class='critique'][2]//h2", 'Potter et la chambre des secrets'); + $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Potter et la chambre des secrets'); } public function testDeleteMilleniumButtonPresent() { @@ -504,7 +545,7 @@ class AbonneControllerAvisRssControllerViewAvisUserTest extends AvisControllersF /** @test */ function firstItemTitleShouldBeJAdore() { - $this->assertXPathContentContains('//channel/item/title', "J'adore"); + $this->assertXPathContentContains('//channel/item/title', "J'adore",$this->_response->getBody()); } @@ -601,8 +642,8 @@ class AbonneControllerAvisBlogControllerLastCritiquesTest extends AvisController /** @test */ - public function lostRratingShouldBeAtThirdPlace() { - $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Oeuvre non trouvée'); + public function lostRratingShouldNotBeDIsplayed() { + $this->assertNotXPathContentContains("//div[@class='critique'][3]//h2", 'Oeuvre non trouvée'); } } @@ -612,21 +653,16 @@ abstract class ModuleSelectionCritiquesTestCase extends AvisControllersFixturesT public function setUp() { parent::setUp(); - $preferences = array('modules' => array(3 => array('division' => 2, - 'type_module' => 'CRITIQUES', - 'preferences' => array('titre' => 'Coups de coeur' - )))); - $profil = Class_Profil::getLoader() - ->find(2) - ->setCfgModules( ['blog' => ['viewcritiques' => ['nb_display' => 2]]]) - ->setCfgAccueil($preferences); + $preferences = ['modules' => [3 => ['division' => 2, + 'type_module' => 'CRITIQUES', + 'preferences' => ['titre' => 'Coups de coeur' + ] + ]]]; + $profil = $this->fixture('Class_Profil', + ['id'=>2, + 'cfg_modules' => ['blog' => ['viewcritiques' => ['nb_display' => 2]]], + 'cfg_accueil' => $preferences]); - $this->_generateLoaderFor('Class_AvisNotice', ['getAvisFromPreferences']) -// ->expects($this->once()) - ->method('getAvisFromPreferences') - ->will($this->returnValue([$this->avis_millenium, - $this->avis_potter, - $this->avis_lost])); } } @@ -665,11 +701,11 @@ class AbonneControllerAvisBlogControllerViewCritiquesTest extends ModuleSelectio } public function testMilleniumIsHere() { - $this->assertQueryContentContains('h2', 'Millenium'); + $this->assertQueryContentContains('h2', 'Millenium',$this->_response->getBody()); } public function testPotterIsHere() { - $this->assertQueryContentContains('h2', 'Potter'); + $this->assertQueryContentContains('h2', 'Potter',$this->_response->getBody()); } /** @test */ @@ -781,9 +817,9 @@ class AbonneControllerAvisBlogControllerViewReadAvisTest extends AbonneFlorence class AbonneControllerEditAvisNoticeNotFoundActionTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - Class_AvisNotice::beVolatile(); $this->dispatch('/opac/abonne/editavisnotice/id/54', true); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php new file mode 100644 index 0000000000000000000000000000000000000000..aa37724d749aa94d77909f2d7c3f343105ecda36 --- /dev/null +++ b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php @@ -0,0 +1,262 @@ +<?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 + */ + +require_once 'tests/fixtures/NanookFixtures.php'; + +abstract class AbstractAbonneControllerSuggestionAchatNanookTestCase extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_francis; + + public function setUp() { + parent::setUp(); + + $logger = $this->mock() + ->whenCalled('log')->answers(true) + + ->whenCalled('logError') + ->willDo( + function($url, $message) { + throw new RuntimeException($url . ' :: ' . $message); + }); + + Class_WebService_SIGB_AbstractService::setLogger($logger); + + + $sigb_conf = $this->fixture('Class_IntBib', + ['id' => 3, + 'comm_params' => ['url_serveur' => 'nanookService', + 'provide_suggest' => '1'], + 'comm_sigb' => Class_IntBib::COM_NANOOK]); + + $tatim = $this->fixture('Class_Bib', ['id' => 12, + 'libelle' => 'Tatim bib', + 'int_bib' => $sigb_conf]); + + $sigb_conf->setIdBib(12); + + $this->_francis = $this->fixture('Class_Users', ['id' => 3, + 'id_sigb' => '187', + 'login' => 'francis', + 'password' => 'test', + 'int_bib' => $sigb_conf]); + + ZendAfi_Auth::getInstance()->logUser($this->_francis); + + $this->mock_web_client = $this->mock(); + $this->mock_web_client + ->whenCalled('open_url') + ->with('http://nanookService/service/AuthenticatePatron/username/francis/password/test') + ->answers(NanookFixtures::albatorAuthenticatePatronResponse()) + + ->whenCalled('open_url') + ->with('http://nanookService/service/GetPatronInfo/patronId/187') + ->answers(NanookFixtures::albatorPatronInfoResponse()) + + ->whenCalled('postData') + ->with('http://nanookService/service/CreateSuggest/patronId/187', + ['site' => '12', + 'title' => 'fu', + 'author' => 'mf', + 'isbnean' => '2-07-0541 27_4', + 'desclink' => '', + 'comment' => 'no']) + ->answers(NanookFixtures::createSuggestFuSucces()) + + ->whenCalled('postData') + ->with('http://nanookService/service/CreateSuggest/patronId/187', + ['site' => '12', + 'title' => 'fu', + 'author' => 'Ye', + 'isbnean' => '2-07-0541 27_4', + 'desclink' => '', + 'comment' => 'no']) + ->answers(NanookFixtures::createSuggestFuError()) + + ->beStrict(); + + $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); + $sigb_comm->setWebClient($this->mock_web_client); + } + + + public function tearDown() { + Class_IntBib::find(3)->getSIGBComm()->setWebClient(null); + parent::tearDown(); + } +} + + + +class AbonneControllerSuggestionAchatNanookListTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/suggestion-achat', true); + } + + + /** @test */ + public function pageShouldContainsSuggestionFromNanook() { + $this->assertXPathContentContains('//table//tr[1]//td[2]', 'Purple for the win'); + } + + + /** @test */ + public function albatorShouldBePresent() { + $this->assertXPathContentContains('//table//tr[1]//td[3]', 'albator'); + } + + + /** @test */ + public function bibLalbelShouldBeTatimBib() { + $this->assertXPathContentContains('//table//tr[1]/td[4]', 'Tatim bib'); + } + + + /** @test */ + public function noteSuggestFromBokehShouldBePresent() { + $this->assertXPathContentContains('//table//tr[1]/td[6]', 'Suggest from Bokeh'); + } + + + /** @test */ + public function isbnShouldBePresent() { + $this->assertXPathContentContains('//table//tr[1]/td[1]', '123456789'); + } + + + /** @test */ + public function urlShouldBePresent() { + $this->assertXPathContentContains('//table//tr[1]/td[5]', 'http://www.Suggest.url'); + } +} + + + +class AbonneControllerSuggestionAchatNanookAddTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/suggestion-achat-add', true); + } + + + /** @test */ + public function formShouldContainsTextAreaForComment() { + $this->assertXPath('//form//textarea[@name="Comment"]'); + } + + + /** @test */ + public function formShouldContainsInputForTitle() { + $this->assertXPath('//form//input[@name="Title"][@placeholder="ex: Harry Potter à l\'école des sorciers"]'); + } + + + /** @test */ + public function formShouldContainsInputForAuthor() { + $this->assertXPath('//form//input[@name="Author"][@placeholder="ex: Joanne Kathleen Rowling"]'); + } + + + /** @test */ + public function formShouldContainsInputForIsbn() { + $this->assertXPath('//form//input[@name="Isbn"][@placeholder="ex: 2-07-054127-4"]'); + } + + + /** @test */ + public function formShouldContainsInputForUrl() { + $this->assertXPath('//form//input[@name="Url"][@placeholder="http://www..."]'); + } + + + /** @test */ + public function formShouldContainsSite() { + $this->assertXPath('//form//input[@name="Library"][@value="Tatim bib"][@disabled="1"]'); + } +} + + + +class AbonneControllerSuggestionAchatNanookAddPostTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $mock_transport = new MockMailTransport(); + Zend_Mail::setDefaultTransport($mock_transport); + + $this->postDispatch('/opac/abonne/suggestion-achat-add', ['Site' => '12', + 'Title' => 'fu', + 'Author' => 'mf', + 'Isbn' => '2-07-0541 27_4', + 'Url' => '', + 'Comment' => 'no']); + } + + + /** @test */ + public function suggestionShouldHaveBeenSend() { + $this->assertFlashMessengerContains(['notification' => ['message' => 'Suggestion d\'achat enregistrée']]); + } + + + /** @test */ + public function shouldRedirect() { + $this->assertRedirect(); + } +} + + + +class AbonneControllerSuggestionAchatNanookAddPostErrorsTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $mock_transport = new MockMailTransport(); + Zend_Mail::setDefaultTransport($mock_transport); + + $this->postDispatch('/opac/abonne/suggestion-achat-add', ['Site' => '12', + 'Title' => 'fu', + 'Author' => 'Ye', + 'Isbn' => '2-07-0541 27_4', + 'Url' => '', + 'Comment' => 'no']); + } + + + /** @test */ + public function suggestionShouldHaveBeenSend() { + $this->assertFlashMessengerContains(['notification' => ['message' => 'Suggestion d\'achat enregistrée']]); + } + + + /** @test */ + public function shouldRedirect() { + $this->assertRedirect(); + } +} diff --git a/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatTest.php b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatTest.php index 0aa6c7df4d680329fa21fa9c3ca66db8060c97b7..3f97398757e5e0e65e93f29376645608e0ed6cd9 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatTest.php @@ -215,7 +215,6 @@ abstract class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase public function setUp() { parent::setUp(); - $sigb_plage = $this->fixture('Class_IntBib', [ 'id' => 3, @@ -263,26 +262,22 @@ abstract class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase } - public function tearDown() { Class_IntBib::find(3)->getSIGBComm()->setWebClient(null); parent::tearDown(); } - } - class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulTest extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase { + public function setUp() { parent::setup(); - $this->dispatch('/opac/abonne/suggestion-achat-add', true); } - /** @test */ public function formShouldContainsTextAreaForPatronReason() { $this->assertXPath('//form//textarea[@name="PatronReason"]'); @@ -325,11 +320,17 @@ class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulTest exten class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulPostTest extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase { public function setUp() { parent::setUp(); + $this->mock_web_client ->whenCalled('open_url') ->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=azerty&id_type=cardnumber') - ->answers('<xml><id>234</id></xml>'); + ->answers('<xml><id>234</id></xml>') + + ->whenCalled('postData') + ->answers(true); + $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); + $sigb_comm->setWebClient($this->mock_web_client); $this->postDispatch('/opac/abonne/suggestion-achat-add', ['Title' => 'Harry Potter', diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php index 0ff81c36619bbd4621ae78475828023fe108d293..a0aa0de6477255cf8400944a1bcd5601f70f8eed 100644 --- a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php +++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php @@ -106,18 +106,121 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe -class BibNumeriqueContollerDilicomAjaxRedirectBookActionTest extends BibNumeriqueContollerDilicomTestCase { +class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueContollerDilicomTestCase { + protected $_storm_default_to_volatile = true; + /** @test */ - public function redirectShouldBeConsultBook() { + public function popupConsultBookShouldContainsLinkToOpenAjax() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/consultBook?glnContractor=123456789&orderLineId=x321&accessMedium=STREAMING&localization=IN_SITU&consultEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&ipAddress=127.0.0.1&glnColl=afi-bib&loanerColl=2345889&loanId=n4y4nq63') + ->answers(DilicomFixtures::loanBookResponse()) + ->beStrict(); + $this->dispatch('/bib-numerique/consult-book-ajax/id/3', true); - $this->assertRedirectTo('/bib-numerique/consult-book/id/3', $this->getResponseLocation()); + $this->assertContains('<div class="popup-content"><p>Êtes vous sûr de vouloir consulter ce document ?</p><a href="/bib-numerique/consult-book-open-ajax/id/3" data-popup="true" class="button blue">oui</a><a href="" onclick="opacDialogClose();return false" class="button red">non</a></div>', + json_decode($this->_response->getBody())->content); + } + + + /** @test */ + public function popupConsultBookOpenShouldContainsLinkToOpenPnbUrl() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/consultBook?glnContractor=123456789&orderLineId=x321&accessMedium=STREAMING&localization=IN_SITU&consultEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&ipAddress=127.0.0.1&glnColl=afi-bib&loanerColl=2345889&loanId=n4y4nq63') + ->answers(DilicomFixtures::loanBookResponse()) + ->beStrict(); + + $this->dispatch('/bib-numerique/consult-book-open-ajax/id/3', true); + $this->assertContains('<div class=\"popup-content\"><a href=\"https:\/\/pnb-dilicom.centprod.com\/v2\/\/link\/3025594195810\/LOAN\/WIKI001\/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do\" target=\"_blank\" class=\"button blue\" onclick=\"opacDialogClose();\">Lire en ligne<\/a><\/div>"', + $this->_response->getBody()); + } + + + /** @test */ + public function popupLoanBookOpenAjaxWithPnbErrorShouldContainsScriptToReloadPage() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/consultBook?glnContractor=123456789&orderLineId=x321&accessMedium=STREAMING&localization=IN_SITU&consultEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&ipAddress=127.0.0.1&glnColl=afi-bib&loanerColl=2345889&loanId=n4y4nq63') + ->answers(DilicomFixtures::loanBookErrorResponse()) + ->beStrict(); + + $this->dispatch('/bib-numerique/consult-book-open-ajax/id/3', true); + $this->assertContains('<script>window.open(\"\/recherche\/viewnotice\/id\/3\/render\/false\")<\/script>', $this->_response->getBody()); } /** @test */ - public function redirectShouldBeLoanBook() { + public function loanBookPopupShouldContainsQuestion() { $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); - $this->assertRedirectTo('/bib-numerique/loan-book/id/3', $this->getResponseLocation()); + $this->assertContains('<p>Êtes vous sûr de vouloir emprunter ce document ?</p>', + json_decode($this->_response->getBody())->content); + } + + + /** @test */ + public function loanBookPopupShouldContainsLinkToDownload() { + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('<a href=\"\/bib-numerique\/download-loan-book-ajax\/id\/3\" data-popup=\"true\" class=\"button blue\">oui<\/a>', $this->_response->getBody()); + } + + + /** @test */ + public function loanBookPopupShouldContainsAnswerYes() { + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('<a href=\"\/bib-numerique\/download-loan-book-ajax\/id\/3\" data-popup=\"true\" class=\"button blue\">oui<\/a>', $this->_response->getBody()); + } + + + /** @test */ + public function loanBookPopupShouldContainDefaultMessage() { + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.', json_decode($this->_response->getBody())->content); + } + + + /** @test */ + public function loanBookPopupShouldContainDefinedMessage() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => 'Don\'t use this !' + ]); + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('Don\'t use this !', json_decode($this->_response->getBody())->content); + } + + + /** @test */ + public function downloadLinkShouldAnswersDilicomLink() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&glnColl=afi-bib&loanerColl=2345889&localization=EX_SITU&loanEndDate=2014-08-10T14%3A14%3A14%2B0200&ean13=435465&loanId=1') + ->answers(DilicomFixtures::loanBookResponse()) + ->beStrict(); + + $this->dispatch('bib-numerique/download-loan-book-ajax/id/3', true); + $this->assertContains('"<div class=\"popup-content\"><a href=\"https:\/\/pnb-dilicom.centprod.com\/v2\/\/link\/3025594195810\/LOAN\/WIKI001\/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do\" class=\"button blue\" onclick=\"opacDialogClose();\">T\u00e9l\u00e9charger<\/a><\/div>"', $this->_response->getBody()); + } + + + /** @test */ + public function downloadLinkWithPnbErrorShouldConstainsScriptToReloadPage() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&glnColl=afi-bib&loanerColl=2345889&localization=EX_SITU&loanEndDate=2014-08-10T14%3A14%3A14%2B0200&ean13=435465&loanId=1') + ->answers(DilicomFixtures::loanBookErrorResponse()) + ->beStrict(); + + $this->dispatch('bib-numerique/download-loan-book-ajax/id/3', true); + $this->assertContains('<script>window.open(\"\/recherche\/viewnotice\/id\/3\/render\/false\")<\/script>', $this->_response->getBody()); + } + + + /** @test */ + public function downloadLinkWithNoConnectedUserShouldRenderLoginPopup() { + ZendAfi_Auth::getInstance()->clearIdentity(); + $this->dispatch('bib-numerique/download-loan-book-ajax/id/3', true); + $this->assertContains('"title":"Authentification"', $this->_response->getBody()); } } diff --git a/tests/application/modules/opac/controllers/BlogControllerTest.php b/tests/application/modules/opac/controllers/BlogControllerTest.php index 8ccc8b87621b11a5442ee55904e17d671b5003b5..c01c62513941be41e1a273e92b26b1c476e153ab 100644 --- a/tests/application/modules/opac/controllers/BlogControllerTest.php +++ b/tests/application/modules/opac/controllers/BlogControllerTest.php @@ -68,8 +68,10 @@ class BlogControllerHierarchicalTest extends AbstractControllerTestCase { $this->fixture('Class_AvisNotice', ['id' => 1, + 'id_notice' => 233134, 'note' => 5, 'entete' => 'Incroyable', + 'id_notice' => $this->ksp->getId(), 'avis' => 'What a wonderful game', 'statut' => 1, 'date_avis' => '2015-05-18 00:00:00', @@ -143,7 +145,7 @@ class BlogControllerHierarchicalTest extends AbstractControllerTestCase { /** @test */ public function kspShouldBePresent() { - $this->assertXPathContentContains('//h2', 'Kerbal Space Program'); + $this->assertXPathContentContains('//h2', 'Kerbal Space Program',$this->_response->getBody()); } diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index b87bdc6d4b43d25eb881292c8d96b92e06f22434..1663c1f936ec04d60c37bfae3b280fc3823e3d34 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -48,7 +48,6 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC 'clef_oeuvre' => 'HPELPA', 'clef_alpha' => 'POTTER', 'exemplaires' => []])]); - $this->setUpProfilAdulte(); $this->setUpProfilJeunesse(); } @@ -1181,7 +1180,10 @@ class ProfilOptionsControllerProfilBreadcrumbTest extends ProfilOptionsControlle } - + /** @test */ + public function sitothequesShouldNotContainsLinkToRss() { + $this->assertNotXpath('//div[@class="rss"]/a[contains(@href, "/sito/sito-rss")]'); + } } @@ -1302,8 +1304,6 @@ class ProfilOptionsControllerProfilJeunesseViewPageJeuxTest extends ProfilOption class ProfilOptionsControllerPagesJeuxWithSitotheque extends ProfilOptionsControllerProfilJeunesseWithPagesJeuxMusiqueTestCase { - - public function setUp() { parent::setUp(); @@ -1311,7 +1311,8 @@ class ProfilOptionsControllerPagesJeuxWithSitotheque extends ProfilOptionsContro '10' => ['division' => '2', 'type_module' => 'SITO', - 'preferences' => ['id_categorie' => '2', + 'preferences' => ['rss' => 1, + 'id_categorie' => '2', 'group_by_categorie' => true]]], 'options' => []]); @@ -1350,6 +1351,12 @@ class ProfilOptionsControllerPagesJeuxWithSitotheque extends ProfilOptionsContro } + /** @test */ + public function sitothequesShouldContainsLinkToRss() { + $this->assertXpath('//div[@class="rss"]/a[contains(@href, "/sito/sito-rss")]'); + } + + /** @test */ public function categoryMySitesShouldBeInUlSitotheque() { $this->assertXPathContentContains('//ul[@class="sitotheque"]/li/h2/a', @@ -2516,4 +2523,88 @@ class ProfilOptionControllerWithHeritedPagesTest extends ProfilOptionControllerH public function profilShouldIncrementCfgIdsAndDeleteOldIdAndKeepPosition() { $this->assertEquals([11,10], array_keys(Class_Profil::find(2)->getCfgAccueilAsArray()['modules'])); } +} + + + +class ProfilOptionsControllerRecentSitoTest extends ProfilOptionsControllerProfilJeunesseWithPagesJeuxMusiqueTestCase { + + + public function setUp() { + parent::setUp(); + + $this->page_jeux->setCfgAccueil(['modules' => [ + '10' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '2', + 'type_aff' => '2']]], + 'options' => []]); + + $this->fixture('Class_SitothequeCategorie', + ['id' => 2, + 'libelle' => 'Jeunesse', + 'sitotheques' => [ + $this->fixture('Class_Sitotheque', + ['id' => 34, + 'titre' => 'Thot cursus', + 'url' => 'http://cursus.edu/', + 'description' => 'Top notch site', + 'tags' => 'VOD']) + ]]); + + $this->fixture('Class_SitothequeCategorie', + ['id' => 3, + 'libelle' => 'Informatique', + 'sitotheques' => [ + $this->fixture('Class_Sitotheque', + ['id' => 35, + 'titre' => 'Pharo', + 'url' => 'http://pharo.org/', + 'description' => 'Cool programming language', + 'tags' => 'Smalltalk'])] + ]); + + } + + /** @test */ + public function sitothequeShouldContainsLinkToCursus() { + $this->dispatch('/opac/index/index/clef/zork?id_profil=12', true); + $this->assertXPathContentContains('//a[@href="http://cursus.edu/"]', 'Thot cursus'); + } + + + /** @test */ + public function sitothequeShouldNotContainsLinkToPharo() { + $this->dispatch('/opac/index/index/clef/zork?id_profil=12', true); + $this->assertNotXPathContentContains('//a[@href="http://pharo.org/"]', 'Pharo'); + } + + + /** @test */ + public function withoutCategoryShouldDisplay2Sitos() { + $this->page_jeux->setCfgAccueil(['modules' => [ + '10' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '', + 'type_aff' => '2']]], + 'options' => []]); + + $this->dispatch('/opac/index/index/clef/zork?id_profil=12', true); + $this->assertXPathCount('//div[@class="sitotheque"]', 2); + } + + + /** @test */ + public function with1CategoryAnd1ItemShouldDisplay2Sitos() { + $this->page_jeux->setCfgAccueil(['modules' => [ + '10' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '2', + 'id_items' => '35', + 'type_aff' => '2']]], + 'options' => []]); + + $this->dispatch('/opac/index/index/clef/zork?id_profil=12', true); + $this->assertXPathCount('//div[@class="sitotheque"]', 2); + } } \ 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 8fe479988c796c7737df0f53b4d812e5b33ea559..a79c352713387dbd46a0b91806fffd713a5c7a65 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -67,7 +67,7 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe $this->fixture('Class_ModeleFusion', ['id' => 1, 'nom' => 'recherche', - 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> + '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, @@ -118,7 +118,10 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe } - + /** @test */ + public function displayShouldNotPrintTagResume() { + $this->assertNotXPathContentContains("//div", '{resume}'); + } } @@ -134,6 +137,7 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo $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']); @@ -189,4 +193,10 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo public function avisShouldBeDisplayed() { $this->assertXPathContentContains('//div//p', "Lies are news and truth is obsolete.",$this->_response->getBody()); } + + + /** @test */ + public function displayShouldNotPrintNoticeDotResume() { + $this->assertNotXPathContentContains("//div", '{notice.resume}'); + } } diff --git a/tests/application/modules/opac/controllers/RechercheControllerSearchExtensionTest.php b/tests/application/modules/opac/controllers/RechercheControllerSearchExtensionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..73425ea2d2352fa88789eadfc75f2b4bf117849c --- /dev/null +++ b/tests/application/modules/opac/controllers/RechercheControllerSearchExtensionTest.php @@ -0,0 +1,173 @@ +<?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 RechercheControllerSearchExtensionTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Zend_Registry::set('sql', + $this->mock() + ->whenCalled('fetchAll') + ->answers([])); + + $this->_prepareFixtures(); + $this->dispatch('/opac/recherche/simple?expressionRecherche=sport', true); + } + + + protected function _prepareFixtures() { + $this->fixture('Class_AdminVar', + ['id' => 'SEARCH_ALSO_IN', + 'valeur' => json_encode($this->_extensionSites())]); + } + + + protected function _extensionSites() { + return ['site_label' => [''], 'site_url' => ['']]; + } +} + + + +class RechercheControllerSearchExtensionDisabledTest + extends RechercheControllerSearchExtensionTestCase { + + protected function _prepareFixtures() {} + + /** @test */ + public function shouldNotContainsExtensionLinks() { + $this->assertNotXPathContentContains('//div', 'Rechercher aussi sur'); + } +} + + + +class RechercheControllerSearchExtensionEnabledWithEmptySiteAndUrlTest + extends RechercheControllerSearchExtensionTestCase { + + /** @test */ + public function shouldNotContainsExtensionLinks() { + $this->assertNotXPathContentContains('//div', 'Rechercher aussi sur'); + } +} + + + +class RechercheControllerSearchExtensionEnabledWithSiteAndNoUrlTest + extends RechercheControllerSearchExtensionTestCase { + + protected function _extensionSites() { + return ['site_label' => ['Jumel'], 'site_url' => ['']]; + } + + + /** @test */ + public function shouldNotContainsExtensionLinks() { + $this->assertNotXPathContentContains('//div', 'Rechercher aussi sur'); + } +} + + + +class RechercheControllerSearchExtensionEnabledWithUrlAndNoSiteTest + extends RechercheControllerSearchExtensionTestCase { + + protected function _extensionSites() { + return ['site_label' => [''], 'site_url' => ['http://jumel.org?q=%s']]; + } + + + /** @test */ + public function shouldNotContainsExtensionLinks() { + $this->assertNotXPathContentContains('//div', 'Rechercher aussi sur'); + } +} + + + +class RechercheControllerSearchExtensionEnabledTest + extends RechercheControllerSearchExtensionTestCase { + + protected function _extensionSites() { + return ['site_label' => ['Jumel', + 'Incomplete', + 'Trouvons.org',], + 'site_url' => ['http://www.jumel39.fr/rechercher?search_api_views_fulltext=%s', + '', + 'http://trouvons.org/#q=%s']]; + } + + + /** @test */ + public function shouldContainsExtensionLinks() { + $this->assertXPathContentContains('//div', 'Rechercher aussi sur'); + } + + + /** @test */ + public function shouldContainsJumelLink() { + $this->assertXPathContentContains('//a[contains(@href, "rechercher?search_api_views_fulltext=sport")]', + 'Jumel'); + } + + + /** @test */ + public function shouldNotDisplayIncompletLink() { + $this->assertNotXPathContentContains('//a', 'Incomplete'); + } + + + /** @test */ + public function shouldContainsTrouvonsLink() { + $this->assertXPathContentContains('//a[contains(@href, "#q=sport")]', + 'Trouvons.org'); + } +} + + + +class RechercheControllerSearchExtensionWithoutTermsTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Zend_Registry::set('sql', + $this->mock() + ->whenCalled('fetchAll') + ->answers([])); + + $this->fixture('Class_AdminVar', + ['id' => 'SEARCH_ALSO_IN', + 'valeur' => json_encode(['site_label' => ['Jumel'], + 'site_url' => ['http://www.jumel39.fr/rechercher?search_api_views_fulltext=%s']])]); + + $this->dispatch('/opac/recherche/simple?type_doc=&tri=*&expressionRecherche=', true); + } + + + /** @test */ + public function shouldNotContainsExtensionLinks() { + $this->assertNotXPathContentContains('//div', 'Rechercher aussi sur'); + } +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index e6be26938dca4ff18c57ebfcad735760827e4001..8cc5b3fccb112a61df25f53911d66dc52a901f2d 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -49,7 +49,8 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { 'division' => '2', 'type_module' => 'SITO', 'preferences' => ['id_categorie' => '3', - 'id_items' => '25-28'] + 'id_items' => '25-28', + 'rss_status' => 1] ] ], 'options' => []]); @@ -58,9 +59,7 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { } - - -abstract class SitoControllerViewCategoyTestCase extends SitoControllerTestCase { +abstract class SitoControllerViewCategoryAndRecentTestCase extends SitoControllerTestCase { public function setUp() { parent::setUp(); $collectif = $this->fixture('Class_SitothequeCategorie', @@ -78,12 +77,13 @@ abstract class SitoControllerViewCategoyTestCase extends SitoControllerTestCase 'parent_categorie' => $associations, 'libelle' => 'Libre' ]); - $this->fixture('Class_Sitotheque', + $quadrature = $this->fixture('Class_Sitotheque', ['id' => 280, 'categorie' => $libre, 'titre' => 'La quadrature du net', 'description' => 'Internet et libertés', 'url' => 'http://laquadrature.net']); + $quadrature->setDateMaj('1970-01-01 00:00:00'); $this->fixture('Class_Sitotheque', ['id' => 282, @@ -92,27 +92,35 @@ abstract class SitoControllerViewCategoyTestCase extends SitoControllerTestCase 'description' => 'Promouvoir le logiciel libre', 'url' => 'http://april.org']); - $this->fixture('Class_Sitotheque', + $framasoft = $this->fixture('Class_Sitotheque', ['id' => 281, 'categorie' => $collectif, 'titre' => 'Framasoft', 'description' => 'Degooglisons internet', 'url' => 'http://framasoft.org']); + $framasoft->setDateMaj('9999-12-12 00:00:00'); + } +} + +abstract class SitoControllerViewCategoryTestCase extends SitoControllerViewCategoryAndRecentTestCase { + public function setUp() { + parent::setUp(); Class_Profil::getCurrentProfil() ->setCfgAccueil(['modules' => ['1' => ['division' => '2', 'type_module' => 'SITO', 'preferences' => ['id_categorie' => '12', 'type_aff' => '3', - 'id_items' => '280-281']]], + 'id_items' => '280-281', + 'rss' => 1]]], 'options' => []]); + } } - -class SitoControllerViewCategoyTest extends SitoControllerViewCategoyTestCase { +class SitoControllerViewCategoryTest extends SitoControllerViewCategoryTestCase { public function setUp() { parent::setUp(); $this->dispatch('/sito/viewcategory/id_cat/12/start_cat/12', true); @@ -148,8 +156,6 @@ class SitoControllerViewCategoyTest extends SitoControllerViewCategoyTestCase { } - - class SitoControllerViewRecentTest extends SitoControllerTestCase { public function setUp() { parent::setUp(); @@ -163,12 +169,60 @@ class SitoControllerViewRecentTest extends SitoControllerTestCase { $this->assertXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', $this->_response->getBody()); } + +} + + +abstract class SitoControllerViewRecentTestCase extends SitoControllerViewCategoryAndRecentTestCase { + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil() + ->setCfgAccueil(['modules' => ['1' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '12', + 'type_aff' => '2', + 'id_items' => '280-281']]], + 'options' => []]); + } } +class SitoControllerViewRecentWithCategoryTest extends SitoControllerViewRecentTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/sito/viewrecent/nb/10/id_cat/12', true); + } + + /** @test */ + public function linuxFrShouldNotBeShown() { + $this->assertNotXPath('//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', + $this->_response->getBody()); + } + + /** @test */ + public function framasoftShouldBeShownFirst() { + $this->assertXPath('(//div[@class="sitotheque"])[1]//a[@href="http://framasoft.org"]', + $this->_response->getBody()); + } + + /** @test */ + public function aprilShouldBeShownSecond() { + $this->assertXPath('(//div[@class="sitotheque"])[2]//a[@href="http://april.org"]', + $this->_response->getBody()); + } + + /** @test */ + public function quadratureShouldBeShownLast() { + $this->assertXPath('(//div[@class="sitotheque"])[3]//a[@href="http://laquadrature.net"]', + $this->_response->getBody()); + } +} + + -class SitoControllerViewCategorySearchTest extends SitoControllerViewCategoyTestCase { +class SitoControllerViewCategorySearchTest extends SitoControllerViewCategoryTestCase { public function setUp() { parent::setUp(); @@ -286,7 +340,6 @@ class SitoControllerSitoViewIdTest extends SitoControllerTestCase { } - class SitoControllerSitoWebThumbnailUrl extends SitoControllerTestCase { public function setup() { parent::setUp(); @@ -321,4 +374,67 @@ class SitoControllerSitoWebThumbnailUrl extends SitoControllerTestCase { $this->getResponseLocation()); } } + + + +class SitoControllerRssWithProfileTest extends SitoControllerViewCategoryTestCase { + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil() + ->setCfgAccueil(['modules' => ['1' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '19', + 'type_aff' => '3', + 'id_items' => '281', + 'rss' => 1]]], + 'options' => []]); + + $this->dispatch('sito/sito-rss?id_module=1&id_profil=2'); + } + + +/** @test */ + public function rssShouldOnlyContainsTwoSitos() { + $this->assertXPathCount('//item', 2,$this->_response->getBody()); + } + + + /** @test */ + public function linuxFrShouldNotBeShown() { + $this->assertNotXPathContentContains('link', 'http://april.org'); + } + + + /** @test */ + public function framasoftShouldBeShown() { + $this->assertXPathContentContains('//link', 'http://framasoft.org'); + } + + + /** @test */ + public function laquadratureShouldBeShown() { + $this->assertXPathContentContains('//link', 'http://laquadrature.net'); + } +} + + + +class SitoControllerRssWithoutProfileTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Profil') + ->whenCalled('find') + ->answers(null); + + $this->dispatch('sito/sito-rss'); + } + + + /** @test */ + public function titleShouldBeFluxIndisponible() { + $this->assertXPathContentContains('//channel/title', 'Flux indisponible', $this->_response->getBody()); + } +} ?> diff --git a/tests/application/modules/opac/controllers/ead.xsd b/tests/application/modules/opac/controllers/ead.xsd index 9595a769ba255ed597fa520aedb80e17898ce0a5..e8008b6167c437d810fe269e132d8ea0a5bebf72 100644 --- a/tests/application/modules/opac/controllers/ead.xsd +++ b/tests/application/modules/opac/controllers/ead.xsd @@ -69,7 +69,7 @@ xmlns="urn:isbn:1-931666-22-9" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import namespace="http://www.w3.org/1999/xlink" - schemaLocation="http://www.loc.gov/standards/xlink/xlink.xsd"/> + schemaLocation="xlink.xsd"/> <xs:attributeGroup name="am.date.normal"> <xs:attribute name="normal"> <xs:simpleType> diff --git a/tests/application/modules/opac/controllers/xlink.xsd b/tests/application/modules/opac/controllers/xlink.xsd new file mode 100644 index 0000000000000000000000000000000000000000..4691efcf3978fb15ebb9ff3a2d8e2bbef73fe2a0 --- /dev/null +++ b/tests/application/modules/opac/controllers/xlink.xsd @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- METS XLink Schema, v. 2, Nov. 15, 2004 --> +<schema targetNamespace="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" elementFormDefault="qualified"> + <!-- global attributes --> + <attribute name="href" type="anyURI"/> + <attribute name="role" type="string"/> + <attribute name="arcrole" type="string"/> + <attribute name="title" type="string"/> + <attribute name="show"> + <simpleType> + <restriction base="string"> + <enumeration value="new"/> + <enumeration value="replace"/> + <enumeration value="embed"/> + <enumeration value="other"/> + <enumeration value="none"/> + </restriction> + </simpleType> + </attribute> + <attribute name="actuate"> + <simpleType> + <restriction base="string"> + <enumeration value="onLoad"/> + <enumeration value="onRequest"/> + <enumeration value="other"/> + <enumeration value="none"/> + </restriction> + </simpleType> + </attribute> + <attribute name="label" type="string"/> + <attribute name="from" type="string"/> + <attribute name="to" type="string"/> + <attributeGroup name="simpleLink"> + <attribute name="type" type="string" fixed="simple" form="qualified"/> + <attribute ref="xlink:href" use="optional"/> + <attribute ref="xlink:role" use="optional"/> + <attribute ref="xlink:arcrole" use="optional"/> + <attribute ref="xlink:title" use="optional"/> + <attribute ref="xlink:show" use="optional"/> + <attribute ref="xlink:actuate" use="optional"/> + </attributeGroup> + <attributeGroup name="extendedLink"> + <attribute name="type" type="string" fixed="extended" form="qualified"/> + <attribute ref="xlink:role" use="optional"/> + <attribute ref="xlink:title" use="optional"/> + </attributeGroup> + <attributeGroup name="locatorLink"> + <attribute name="type" type="string" fixed="locator" form="qualified"/> + <attribute ref="xlink:href" use="required"/> + <attribute ref="xlink:role" use="optional"/> + <attribute ref="xlink:title" use="optional"/> + <attribute ref="xlink:label" use="optional"/> + </attributeGroup> + <attributeGroup name="arcLink"> + <attribute name="type" type="string" fixed="arc" form="qualified"/> + <attribute ref="xlink:arcrole" use="optional"/> + <attribute ref="xlink:title" use="optional"/> + <attribute ref="xlink:show" use="optional"/> + <attribute ref="xlink:actuate" use="optional"/> + <attribute ref="xlink:from" use="optional"/> + <attribute ref="xlink:to" use="optional"/> + </attributeGroup> + <attributeGroup name="resourceLink"> + <attribute name="type" type="string" fixed="resource" form="qualified"/> + <attribute ref="xlink:role" use="optional"/> + <attribute ref="xlink:title" use="optional"/> + <attribute ref="xlink:label" use="optional"/> + </attributeGroup> + <attributeGroup name="titleLink"> + <attribute name="type" type="string" fixed="title" form="qualified"/> + </attributeGroup> + <attributeGroup name="emptyLink"> + <attribute name="type" type="string" fixed="none" form="qualified"/> + </attributeGroup> +</schema> \ No newline at end of file diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php new file mode 100644 index 0000000000000000000000000000000000000000..77195bf2d0dd0415b32b4f4e9c845ebfb3799c14 --- /dev/null +++ b/tests/db/UpgradeDBTest.php @@ -0,0 +1,143 @@ +<?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 + */ + +abstract class UpgradeDBTestCase extends PHPUnit_Framework_TestCase { + const BACK_PATCH_LEVEL = 262; + + protected static $_upgrade_done=false; + + abstract public function prepare(); + + public function setUp() { + if (!self::$_upgrade_done) { + + $this->_movePatchLevelTo(self::BACK_PATCH_LEVEL); + $this->_runAllPrepares(); + self::$_upgrade_done = true; + } + + (new Class_Migration_ScriptPatchs())->runTo($this->_getPatchLevel()); + } + + + public function query($query) { + return Zend_Db_Table::getDefaultAdapter()->query($query); + } + + + public function _movePatchLevelTo($patch_level) { + $this->query('update variables set valeur=' . $patch_level . ' where clef="patch_level"'); + $this->query('delete from patch_hash'); + } + + + public function _runAllPrepares() { + foreach($this->_getSubclasses() as $subclass) { + (new $subclass())->prepare(); + } + } + + + protected function _getPatchLevel() { + preg_match('/UpgradeDB_([0-9]+)_Test/', + get_class($this), + $matches); + return $matches[1]; + } + + + protected function _getSubclasses() { + $result = array(); + foreach (get_declared_classes() as $class) { + if (is_subclass_of($class, __CLASS__)) + $result[] = $class; + } + + return $result; + } +} + + + + +class UpgradeDB_263_Test extends UpgradeDBTestCase { + public function prepare() { + $this->query('delete from permission where code="CATEGORY"'); + } + + + /** @test */ + public function permissionCATEGORYShouldBeCreated() { + $data = $this->query('select * from permission where code="category" limit 1;')->fetch(); + $this->assertArraySubset(['code' => 'CATEGORY', + 'module' => 'ARTICLE', + 'type' => 'Droits', + 'sorting' => 1, + 'description' => 'Créer des sous-catégories et des articles'], + $data); + } +} + + + + +class UpgradeDB_274_Test extends UpgradeDBTestCase { + public function prepare() { + $this->query('delete from bib_admin_var where clef="CNIL_CONSENT_ENABLE"'); + } + + + /** @test */ + public function varCNIL_CONSENT_ENABLE_ShouldEqualsOne() { + $data = $this->query('select valeur from bib_admin_var where clef="CNIL_CONSENT_ENABLE"')->fetch(); + $this->assertEquals('1', + $data['valeur']); + } +} + + + + +class UpgradeDB_268_Test extends UpgradeDBTestCase { + protected static $user_backup; + + public function prepare() { + static::$user_backup = $this->query('select id_user, pseudo from bib_admin_users order by id_user limit 1')->fetch(); + } + + + public function tearDown() { + $this->query('update bib_admin_users set pseudo="' . static::$user_backup['pseudo'] . '" where id_user=' . static::$user_backup['id_user']); + } + + + /** @test */ + public function userPseudoCanBeHundredCharsLong() { + $hundred_chars_pseudo = str_pad('pseudo', 100, 'o', STR_PAD_BOTH); + + $this->query('update bib_admin_users set pseudo="' . $hundred_chars_pseudo . '" where id_user=' . static::$user_backup['id_user']); + + $this->assertEquals($hundred_chars_pseudo, + $this->query('select pseudo from bib_admin_users where id_user=' . static::$user_backup['id_user'])->fetch()['pseudo']); + } +} + +?> \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/GetPatronInfoFrancoisMorel.xml b/tests/fixtures/GetPatronInfoFrancoisMorel.xml similarity index 100% rename from tests/library/Class/WebService/SIGB/GetPatronInfoFrancoisMorel.xml rename to tests/fixtures/GetPatronInfoFrancoisMorel.xml diff --git a/tests/library/Class/WebService/SIGB/NanookFixtures.php b/tests/fixtures/NanookFixtures.php similarity index 79% rename from tests/library/Class/WebService/SIGB/NanookFixtures.php rename to tests/fixtures/NanookFixtures.php index 17a5b80ee8cefa24f383739d44800b8b0c3a0a95..fb71aa13db6f8dd1000173d567e8a9646b7b2154 100644 --- a/tests/library/Class/WebService/SIGB/NanookFixtures.php +++ b/tests/fixtures/NanookFixtures.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -16,8 +16,9 @@ * * 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 NanookFixtures { /** @return string */ public static function xmlCancelHoldError() { @@ -84,7 +85,7 @@ class NanookFixtures { } - /** @return string **/ + /** @return string **/ public static function xmlUpdatePatronError() { return '<?xml version="1.0" encoding="UTF-8"?> <UpdatePatronInfo> @@ -359,7 +360,7 @@ class NanookFixtures { <mail>null</mail> </GetPatronInfo>'; } - + /** * @return string */ @@ -403,4 +404,141 @@ class NanookFixtures { <patronId>555</patronId> </AuthenticatePatron>'; } + + + public static function albatorPatronInfoResponse() { + return ' + <getpatroninfo> + <patronid> + 3358 + </patronid> + <barcode> + 01 + </barcode> + <lastname> + ALBATOR + </lastname> + <firstname> + Lucien + </firstname> + <displayorder> + 1 + </displayorder> + <birthdate> + 1950-01-01 + </birthdate> + <phonenumber></phonenumber> + <town></town> + <zipcode></zipcode> + <address></address> + <enddate> + 2020-10-05 + </enddate> + <mail></mail> + <loans></loans> + <holds></holds> + <suggests> + <suggest> + <site> + 12 + </site> + <status> + En attente + </status> + <title> + Purple for the win + </title> + <author> + albator + </author> + <isbnean>123456789</isbnean> + <desclink>http://www.Suggest.url</desclink> + <comment>Suggest from Bokeh</comment> + </suggest> + </suggests> + </getpatroninfo> +'; + } + + + public static function albatorAuthenticatePatronResponse() { + return '<AuthenticatePatron><patronId>187</patronId></AuthenticatePatron>'; + } + + + public static function createSuggestFuSucces() { + return ' <getpatroninfo> + <patronid> + 3358 + </patronid> + <barcode> + 01 + </barcode> + <lastname> + ALBATOR + </lastname> + <firstname> + Lucien + </firstname> + <displayorder> + 1 + </displayorder> + <birthdate> + 1950-01-01 + </birthdate> + <phonenumber></phonenumber> + <town></town> + <zipcode></zipcode> + <address></address> + <enddate> + 2020-10-05 + </enddate> + <mail></mail> + <loans></loans> + <holds></holds> + <suggests> + <suggest> + <site> + 12 + </site> + <status> + En attente + </status> + <title> + Purple for the win + </title> + <author> + albator + </author> + <isbnean>123456789</isbnean> + <desclink>Suggest URL</desclink> + <comment>Suggest from Bokeh</comment> + </suggest> + <suggest> + <site> + 12 + </site> + <status> + En attente + </status> + <title> + fu + </title> + <author> + albator + </author> + <isbnean></isbnean> + <desclink></desclink> + <comment></comment> + </suggest> + </suggests> + </getpatroninfo> +'; + } + + + public static function createSuggestFuError() { + return '<CreateSuggest><error>CreateSuggestError</error></CreateSuggest>'; + } } +?> \ No newline at end of file diff --git a/tests/library/Class/ArticleTest.php b/tests/library/Class/ArticleTest.php index 6415c3bd2f748401ad68efd45e16fde3a6d91b74..dfa55991f66f689a0f126058a8c0482612683a20 100644 --- a/tests/library/Class/ArticleTest.php +++ b/tests/library/Class/ArticleTest.php @@ -1081,6 +1081,45 @@ class ArticleIndexAllTest extends ModelTestCase { public function setUp() { parent::setUp(); + $_SERVER['SCRIPT_NAME'] = '/tom'; + + $filesystem = new Storm_FileSystem_Volatile(); + $thumbnail_paths = PATH_TEMP .'vignettes_titre/'; + $filesystem + ->mkdir($thumbnail_paths) + ->cd($thumbnail_paths); + + Class_Article::setFileWriter($this->mock() + ->whenCalled('fileExists') + ->with('/tom/images/bonlieu.jpg') + ->answers(false) + + ->whenCalled('fileExists') + ->with('./images/bonlieu.jpg') + ->answers(true) + + ->beStrict()); + + Class_WebService_Vignette::setFileSystem($filesystem); + + $image = $this->mock() + ->whenCalled('thumbnailImage') + ->with(160, 220, true, true) + ->answers(null) + + ->whenCalled('writeImage') + ->with(PATH_TEMP . 'vignettes_titre/MYCMSFIRSTSTEP-1-TOM----8.jpg') + ->answers(null) + + ->beStrict(); + + $image_factory = $this->mock() + ->whenCalled('newImage') + ->with('./images/bonlieu.jpg') + ->answers($image); + + Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($image_factory); + $user = $this->fixture('Class_Users', ['id' => 1, 'login' => 'Tom', @@ -1098,7 +1137,7 @@ class ArticleIndexAllTest extends ModelTestCase { $this->fixture('Class_Article', ['id' => 1, 'titre' => 'My Cms First Step', - 'contenu' => 'My Cms First Step', + 'contenu' => 'My Cms First Step. <img src="../../images/bonlieu.jpg" />', 'auteur' => $user, 'indexation' => 1, 'status' => Class_Article::STATUS_VALIDATED]); @@ -1164,6 +1203,20 @@ class ArticleIndexAllTest extends ModelTestCase { public function article4ShouldNotHaveANotice() { $this->assertNull(Class_Article::find(4)->getNotice()); } + + + /** @test */ + public function articleOneRecordThumbnailShouldBeSet() { + $this->assertContains('temp/vignettes_titre/MYCMSFIRSTSTEP-1-TOM----8.jpg', Class_Article::find(1)->getNotice()->getUrlVignette()); + } + + + /** @test */ + public function deleteArticleTwoShouldDeleteNoticeTwo() { + Class_Article::find(2)->delete(); + Class_Notice::clearCache(); + $this->assertEmpty(Class_Notice::find(2)); + } } diff --git a/tests/library/Class/AvisNoticeTest.php b/tests/library/Class/AvisNoticeTest.php index 3a39385cacf05c9aae66d4076c55fba38398f0e9..30fd7af1c0d4d9af29219ff752fe52f7e9d23754 100644 --- a/tests/library/Class/AvisNoticeTest.php +++ b/tests/library/Class/AvisNoticeTest.php @@ -367,72 +367,63 @@ class AvisTestFindAllByUserAndClefOeuvreTestCase extends AvisTestFindAllTestCase class NoticeTestHasManyAvisTest extends Storm_Test_ModelTestCase { public function setUp() { - $this->millenium = Class_Notice::newInstanceWithId(34, ['clef_oeuvre' => 'MILLENIUM--LARSSON']); + $this->millenium = $this->fixture('Class_Notice', ['id' => 34, + 'clef_oeuvre' => 'MILLENIUM--LARSSON']); $this->steve = Class_Users::newInstanceWithId(5, ['prenom' => 'Steve']); - $this->avis_millenium_steve = Class_AvisNotice::newInstanceWithId(12, - ['user' => $this->steve, - 'entete' => 'ça fait peur', - 'avis' => "c'est glauque", - 'clef_oeuvre' => 'MILLENIUM--LARSSON', - 'note' => 2]); - - $this->bryan = Class_Users::newInstanceWithId(6, ['prenom' => 'Bryan']); - $this->avis_millenium_lost_bryan = Class_AvisNotice::newInstanceWithId(15, - ['user' => $this->bryan, - 'entete' => 'perdu', - 'avis' => "perdu sniff sniff", - 'clef_oeuvre' => 'MILLENIUM--SLARSSON', - 'note' => 5]); - - - $this->avis_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice'); - $this->avis_loader->whenCalled('save')->answers(true); + $this->avis_millenium_steve = $this->fixture('Class_AvisNotice', ['id' => 12, + 'user' => $this->steve, + 'entete' => 'ça fait peur', + 'avis' => "c'est glauque", + 'clef_oeuvre' => 'MILLENIUM--LARSSON', + 'note' => 2]); + + $this->bryan = $this->fixture('Class_Users' , ['id' =>6, 'login' => 'bryan', 'password' => 'toto', 'prenom' => 'Bryan']); + $this->avis_millenium_lost_bryan = $this->fixture('Class_AvisNotice', ['id' =>15, + 'user' => $this->bryan, + 'entete' => 'perdu', + 'avis' => "perdu sniff sniff", + 'clef_oeuvre' => 'MILLENIUM--SLARSSON', + 'note' => 5]); + + $this->notice_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice'); + } /** @test */ public function noticeMilleniumGetAvisForUserSteveShouldReturnAvisSteve() { - $this->avis_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON', - 'id_user' => 5]) - ->answers([$this->avis_millenium_steve]); - $found_avis = $this->millenium->getAvisByUser($this->steve); $this->assertEquals([$this->avis_millenium_steve], $found_avis); } + + /** @test */ - public function noticeMilleniumGetAvisShouldReturnAllAvisOnClefOeuvre() { - $avis_millenium_robert = new Class_AvisNotice(); + public function milleniumAvisFirstNoticesShouldNoticeMillenium() { + $this->assertEquals($this->millenium, + $this->avis_millenium_steve->getFirstNotice()); + } - $this->avis_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON']) - ->answers([$this->avis_millenium_steve, - $avis_millenium_robert]); + + /** @test */ + public function noticeMilleniumGetAvisShouldReturnAllAvisOnClefOeuvre() { $found_avis = $this->millenium->getAvis(); - $this->assertEquals([$this->avis_millenium_steve, - $avis_millenium_robert], + $this->assertEquals([$this->avis_millenium_steve + ], $found_avis); } + /** @test */ public function avisMilleniumSteveGetNoticesShouldReturnNoticeMillenium() { - $this->notice_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON']) - ->answers([$this->millenium]); - - $notices_found = $this->avis_millenium_steve->getNotices(); - $this->assertEquals(array($this->millenium), - $notices_found); + $notices_found = $this->avis_millenium_steve->findNoticesByClefOeuvre(); + $this->assertEquals(array($this->millenium), $notices_found); } @@ -447,29 +438,39 @@ class NoticeTestHasManyAvisTest extends Storm_Test_ModelTestCase { ->with(['where' => 'clef_oeuvre like "MILLENIUM-%"']) ->answers([$this->millenium]) ->beStrict(); + $this->avis_millenium_lost_bryan->setStatut(1); - + $this->avis_millenium_lost_bryan->updateNoticeAndSave(); $this->assertEquals([$this->millenium], $this->avis_millenium_lost_bryan->getNotices()); - return $this->avis_loader->getFirstAttributeForLastCallOn('save'); + return $this->avis_millenium_lost_bryan; + } + + /** + * @test + * @depends lostAvisMilleniumGetNoticesShouldSearchNoticeOnTitleClefOeuvre + */ + public function ModerationShouldNotBeReset($saved_avis) { + $this->assertEquals(1, $saved_avis->getStatut()); } + /** * @test * @depends lostAvisMilleniumGetNoticesShouldSearchNoticeOnTitleClefOeuvre */ public function avisLostShouldBeSaved($saved_avis) { - $this->assertEquals('MILLENIUM--LARSSON', $saved_avis->getClefOeuvre()); + $this->assertEquals('34', $saved_avis->getIdNotice()); } - /** * @test * @depends lostAvisMilleniumGetNoticesShouldSearchNoticeOnTitleClefOeuvre */ - public function avisLostShouldGoThroughModeration($saved_avis) { - $this->assertEquals(0, $saved_avis->getStatut()); + public function clefoeuvreShouldNotChanged($saved_avis) { + $this->assertEquals('MILLENIUM--SLARSSON', $saved_avis->getClefOeuvre()); } + } @@ -602,14 +603,14 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { public function testDefaultSQLQuery() { $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "ORDER BY `DATE_AVIS` DESC"); + "WHERE (flags=0) ORDER BY `DATE_AVIS` DESC"); } public function testWithAllAndModoAPosteriori() { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "ORDER BY `DATE_AVIS` DESC"); + "WHERE (flags=0) ORDER BY `DATE_AVIS` DESC"); } @@ -618,7 +619,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=1)) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=1)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -628,7 +629,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=0)) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -641,7 +642,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=1) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=1) ". "AND (STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -651,7 +652,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '0'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='0') ". + "WHERE (flags=0) AND (ABON_OU_BIB='0') ". "ORDER BY `DATE_AVIS` DESC"); } @@ -662,7 +663,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '0'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='0') ". + "WHERE (flags=0) AND (ABON_OU_BIB='0') ". "AND ((STATUT=1 OR ABON_OU_BIB=1)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -672,7 +673,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '1'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='1') ". + "WHERE (flags=0) AND (ABON_OU_BIB='1') ". "ORDER BY `DATE_AVIS` DESC"); } @@ -682,7 +683,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '1'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='1') ". + "WHERE (flags=0) AND (ABON_OU_BIB='1') ". "AND ((STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -811,7 +812,6 @@ class AvisVisibilityTest extends ModelTestCase { } - class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { public function setUp() { parent::setUp(); @@ -864,9 +864,11 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => '0', 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated]); + $this->assertEquals([$this->_avis_bib_moderated, $this->_avis_abon_moderated], Class_AvisNotice::getAvisFromPreferences(['id_panier' => 1])); } @@ -879,6 +881,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 0, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_abon_moderated]); @@ -894,6 +897,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 1, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated]); @@ -911,6 +915,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 0, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); @@ -928,6 +933,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); @@ -947,6 +953,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1)']) ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); @@ -970,6 +977,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice') ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', + 'flags' => 0, 'id_notice' => -1]) ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItemTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItemTest.php new file mode 100644 index 0000000000000000000000000000000000000000..28c71ca79d33fb203b69d357671a7ba1771de8ea --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhaseDeleteRecordWithoutItemTest.php @@ -0,0 +1,104 @@ +<?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 PhaseDeleteRecordWithoutItemTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + protected $_phase; + + public function setUp() { + parent::setUp(); + + $this->_phase = $this->_buildPhase('DeleteRecordWithoutItem') + ->setMemoryCleaner(function() {}) + ->run(); + Class_Notice::clearCache(); + Class_Exemplaire::clearCache(); + } + + + protected function _prepareFixtures() { + $exemplaire1 = $this->fixture('Class_Exemplaire', ['id' => 234, + 'code_barres' => '000456132']); + + $exemplaire2 = $this->fixture('Class_Exemplaire', ['id' => 235, + 'code_barres' => '000456133']); + + $exemplaire3 = $this->fixture('Class_Exemplaire', ['id' => 236, + 'code_barres' => '000456134']); + + + $this->fixture('Class_Notice', ['id' => 31, + 'exemplaires' => [$exemplaire1]]); + + $this->fixture('Class_Notice', ['id' => 32, + 'exemplaires' => [$exemplaire2]]); + + $this->fixture('Class_Notice', ['id' => 33, + 'exemplaires' => [$exemplaire3]]); + } + + + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(1)) + ->beCron(); + } +} + + + + +class PhaseDeleteRecordWithoutItemSimpleTest extends PhaseDeleteRecordWithoutItemTestCase { + + protected function _prepareFixtures() { + parent::_prepareFixtures(); + $this->fixture('Class_Notice', ['id' => 34]); + $this->fixture('Class_Notice', ['id' => 35]); + } + + + /** @test */ + public function totalNumberOfRecordsShouldBe3() { + $this->assertEquals(3, Class_Notice::countBy([])); + } + + + /** @test */ + public function logShouldContain2NoticesSansExemplaireSupprimees() { + $this->assertLogContains('2 notices sans exemplaire supprimées'); + } +} + + + + +class PhaseDeleteRecordWithoutItemNothingToDeleteTest extends PhaseDeleteRecordWithoutItemTestCase { + + /** @test */ + public function totalNumberOfRecordsShouldBe3() { + $this->assertEquals(3, Class_Notice::countBy([])); + } + + + /** @test */ + public function logShouldContainAucuneNoticeSansExemplaire() { + $this->assertLogContains('Aucune notice sans exemplaire'); + } +} diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php index 57d486e32ef6905a6c0fc1b91797368d741d663a..5eba2a3792ac8fd535a3b1e0fd37bf049816f30f 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php @@ -22,7 +22,8 @@ require_once 'cosmogramme/php/fonctions/variables.php'; require_once __DIR__ . '/PhaseNoticeTestCase.php'; -class PhaseNoticeImportTest extends PhaseNoticeTestCase { + +abstract class PhaseNoticeImportTestCase extends PhaseNoticeTestCase { protected function _prepareFixtures() { parent::_prepareFixtures(); @@ -41,22 +42,65 @@ class PhaseNoticeImportTest extends PhaseNoticeTestCase { 'code' => null, 'rules' => null]); - Class_CodifThesaurus::addFacetForSigb('Public' , '993$a',Class_IntBib::COM_NANOOK); + Class_CodifThesaurus::addFacetForSigb('Public', '993$a', Class_IntBib::COM_NANOOK); $this->fixture('Class_Exemplaire', ['id' => 889039, 'id_int_bib' => 2]); - $time_source = $this->mock()->whenCalled('dateYmd')->answers('2015-06-26'); + $oscar = $this->fixture('Class_CodifAuteur', + ['id' => 42, + 'libelle' => 'WILDE oscar', + 'formes' => 'WILDExOSCAR', + 'mots_renvois' => 'HARLOCK;ARCADIA', + 'date_creation' => '2014-01-01']); + + $edmond = $this->fixture('Class_CodifAuteur', + ['id' => 43, + 'libelle' => 'JALOUX edmond', + 'formes' => 'JALOUXxEDMOND', + 'mots_renvois' => '', + 'date_creation' => '2015-01-01']); + + $this->onLoaderOfModel('Class_CodifAuteur') + ->whenCalled('findByCodeAlpha') + ->with('WILDExOSCAR') + ->answers($oscar) + + ->whenCalled('findByCodeAlpha') + ->with('JALOUXxEDMOND') + ->answers($edmond) + + ->whenCalled('findByCodeAlpha') + ->answers(null); + + $this->fixture('Class_CodifMatiere', + ['id' => 43, + 'libelle' => 'Renaissance', + 'code_alpha' => 'RENAISSANCE', + 'mots_renvois' => 'LUMIERE', + 'date_creation' => '2015-01-01']); + + $time_source = (new TimeSourceForTest('2015-10-19'))->atCoffeeTime(); Class_Cosmogramme_Integration_PhaseNotice::setTimeSource($time_source); + Class_Cosmogramme_Integration_CodifProvider::setTimeSource($time_source); } +} + +class PhaseNoticeImportFullTest extends PhaseNoticeImportTestCase { /** @test */ public function totalNumberOfRecordsShouldBe109() { $this->assertEquals(109, Class_Notice::countBy([])); } + /** @test */ + public function totalNumberOfSerialArticlesShouldBe1() { + $this->assertEquals(1, Class_Notice_SerialArticles::countBy([])); + } + + /** @test */ public function totalNumberOfItemsShouldBe109() { $this->assertEquals(109, Class_Exemplaire::countBy([])); @@ -101,7 +145,40 @@ class PhaseNoticeImportTest extends PhaseNoticeTestCase { * @see http://forge.afi-sa.fr/issues/26261 */ public function libraryLastImportDateShouldBeSet() { - $this->assertEquals('2015-06-26', Class_IntBib::find(2)->getDernierAjout()); + $this->assertEquals('2015-10-19', Class_IntBib::find(2)->getDernierAjout()); + } + + + /** @test */ + public function firstRecordAuthorsShouldContainsSeeAlso() { + $this->assertContains('HARLOCK', Class_Notice::find(1)->getAuteurs()); + } + + + /** @test */ + public function recordTopicsShouldContainsSeeAlso() { + $record = Class_Notice::findFirstBy(['isbn' => '2-215-06225-8']); + $this->assertContains('LUMIERE', + $record->getRawAttributes()['matieres'], + $record->getTitrePrincipal()); + } + + + /** @test */ + public function shouldNotHarvestSeeAlsos() { + $this->assertFalse($this->_service_runner->methodHasBeenCalled('run')); + } + + + /** @test */ + public function phaseCounterShouldContain110RecordsInserted() { + $this->assertEquals(110, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_INSERT)); + } + + + /** @test */ + public function phaseCounterShouldContain17RecordsRejected() { + $this->assertEquals(17, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_REJECT)); } } @@ -125,4 +202,66 @@ class PhaseNoticeImportWithResumptionPointerTest extends PhaseNoticeTestCase { public function totalNumberOfRecordsShouldBe107() { $this->assertEquals(107, Class_Notice::countBy([])); } +} + + + + +class PhaseNoticeDeletingTest extends PhaseNoticeTestCase { + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + $this->fixture('Class_CosmoVar', + ['id' => 'mode_doublon', + 'valeur' => Class_CosmoVar::DOUBLE_SEARCH_IDS]); + + $this->fixture('Class_Cosmogramme_Integration', + ['id' => 1000, + 'bib' => Class_IntBib::find(2), + 'profil_donnees' => Class_IntProfilDonnees::find(102), + 'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_ITEM_DELETE, + 'traite' => 'non', + 'fichier' => 'records_to_delete.txt', + 'pointeur_reprise' => 0]); + } + + + /** @test */ + public function phaseCounterShouldContain2RecordsDeleted() { + $this->assertEquals(2, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_DELETE)); + } +} + + + + +class PhaseNoticeUpdatingTest extends PhaseNoticeTestCase { + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + $this->fixture('Class_CosmoVar', + ['id' => 'mode_doublon', + 'valeur' => Class_CosmoVar::DOUBLE_SEARCH_IDS]); + + $this->fixture('Class_Cosmogramme_Integration', + ['id' => 1001, + 'bib' => Class_IntBib::find(2), + 'profil_donnees' => Class_IntProfilDonnees::find(102), + 'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_INCREMENT, + 'traite' => 'non', + 'fichier' => 'records_to_update.txt', + 'pointeur_reprise' => 0]); + } + + + /** @test */ + public function phaseCounterShouldContain3RecordsRejected() { + $this->assertEquals(3, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_REJECT)); + } + + + /** @test */ + public function phaseCounterShouldContain7RecordsRenewed() { + $this->assertEquals(7, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_RENEW)); + } } \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTestCase.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTestCase.php index ad5aef2189b81e74495020ac6d67be7a333c3c9b..7095a3c7a522e35e6ca13893fe7b320e97a33da1 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTestCase.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTestCase.php @@ -21,10 +21,12 @@ class PhaseNoticeTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { - protected $_phase; + protected $_phase, $_service_runner; public function setUp() { parent::setUp(); + $this->fixture('Class_CosmoVar', + ['id' => 'unimarc_zone_matiere', 'valeur' => '610a']); $this->_phase = $this->_buildPhase('Notice')->run(); Class_Notice::clearCache(); @@ -89,6 +91,11 @@ class PhaseNoticeTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { 'traite' => 'non', 'fichier' => 'records.txt', 'pointeur_reprise' => 0]); + + $this->_service_runner = $this->mock() + ->whenCalled('run') + ->answers(['statut' => 'KO']); + Class_Cosmogramme_Integration_PhaseNotice::setServiceRunner($this->_service_runner); } diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a5f97cd83d4407c8b0a289b39011b2eb744a03b2 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php @@ -0,0 +1,130 @@ +<?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 PhaseReviewsTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + public function setUp() { + parent::setUp(); + + $this->_phase = $this->_buildPhase('Reviews') + ->noDbReset() + ->run(); + } +} + + + +class PhaseReviewsBadPreviousPhaseTest extends PhaseReviewsTestCase { + protected function _getPreviousPhase() { + return new Class_Cosmogramme_Integration_Phase(6); + } + + + /** @test */ + public function shouldNotChangePhase() { + $this->assertTrue($this->_phase->isId(6)); + } +} + + + +class PhaseReviewsExpectedPreviousPhaseTest extends PhaseReviewsTestCase { + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(7.5)) + ->beCron(); + } + + + protected function _prepareFixtures() { + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MIN_SAISIE', + 'valeur' => 10]); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MAX_SAISIE', + 'valeur' => 1000]); + + $this->millenium = $this->fixture('Class_Notice', ['id' => 816, + 'titre_principal' => 'Millenium', + 'clef_oeuvre' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => '', + 'url_image' => '']); + + + $this->avis_millenium = $this->fixture('Class_AvisNotice', ['id' => 13, + 'entete' => "J'adore", + 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', + 'note' => 5, + 'date_avis' => '2011-03-18 13:00:00', + + 'statut' => 0, + 'clef_oeuvre' => 'MILLENIUM', + 'abon_ou_bib'=>1 , + 'notices' => [] ]); + + $this->avis_tout_seul = $this->fixture('Class_AvisNotice', ['id' => 14, + 'entete' => "I'm an orphan", + 'avis' => '<div><ul><li>Suspense Intense !</li><li>plop !</li></ul></div>', + 'id_notice' => 20, + 'note' => 5, + 'date_avis' => '2011-03-18 13:00:00', + + 'statut' => 0, + 'clef_oeuvre' => 'HUNT', + 'abon_ou_bib'=>1 , + 'notices' => [] ]); + $this + ->onLoaderOfModel('Class_Notice') + ->whenCalled('findAllBy') + ->with(['where' => 'clef_oeuvre like "HUNT-%"']) + ->answers([]); + } + + + /** @test */ + public function shouldChangePhase() { + $this->assertTrue($this->_phase->isId(7.5)); + } + + + /** @test */ + public function logShouldContainsPhaseLabel() { + $this->assertLogContains('Tous les avis ont été mis à jour'); + } + + + /** @test */ + public function logShouldContainsProcessedRecordCount() { + $this->assertLogContains('2 avis traités'); + } + + + /** @test */ + public function noticeMilleniumShouldBeAttached() { + $this->assertEquals(816, Class_AvisNotice::find(13)->getIdNotice()); + } + + + /** @test */ + public function review14ShouldNotBeAttached() { + $this->assertEquals(0, Class_AvisNotice::find(14)->getIdNotice()); + } +} diff --git a/tests/library/Class/Cosmogramme/Integration/records_to_delete.txt b/tests/library/Class/Cosmogramme/Integration/records_to_delete.txt new file mode 100644 index 0000000000000000000000000000000000000000..79aef13faf187df3dcd3f8025c607a134413515b --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/records_to_delete.txt @@ -0,0 +1 @@ +01321nam0 22003011 450 00100090000001000250000910000260003410100130006010500650007320001220013821000270026021500140028721500450030122500170034667600060036368600110036970000170038070100460039770200440044380100510048783000210053883500060055993000250056593200160059093200160060693200110062299503860063300012445 a2-07-050157-4d10,06 a19991209 e 1frea01 ba0 afrecfre 1[1999-12-09-00.00.00.000000][2006-08-25-00.00.00.000000][][]1 aLe Portrait de Dorian GrayfOscar WILDEgTrad. de l'anglais par Edmond JALOUXgTrad. de l'anglais par Félix FRAPEREAU aPariscGallimardd1981 a1 vol.11 a253 p.3253ccouv. ill. en coul.d21 cm. 2a1000 Soleils 10 aRO WIL10aWILDEbOscar10aFRAPEREAUbFélixgTrad. de l'anglais5TRG10aJALOUXbEdmondgTrad. de l'anglais5TRG aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1ADO2adolescents aR aRoman adolescent4RO aPhilosophie aFantastique aVanité aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0113177*81gL-h011317kRO WILm20141104opqeram1[ALP][Librairie ALPHABET][ORLEANS][45000][14, Rue de la République][FABRICE, ISABELLE, MARYLE][38.54.17.59][0,00][][][][][][][][][][][][][][][][][]2[ARE][Roman Adolescent][0][1][Livre disponible - Romans Fonds Adolescent][0][0][0][0]310,0691993-05-27-00.00.00.0000005113176BIB01068nam0 22002531 450 00100090000001000180000910000260002710100130005310500650006620000780013121000240020921500070023321500580024022500170029830300190031567600060033470000290034070200380036980100510040783000230045883500060048193000130048799503140050000016448 a2-218-24667-8 a19991209 b 1frea01 ba0 afrecfre 1[1999-12-09-00.00.00.000000][2007-02-07-00.00.00.000000][][]1 aLes Trésors des cheminsfCatherine DOLTO-TOLITCHgIll. par Joëlle BOUCHER aPariscHatierd1989 4np anon paginécill. en coul. couv. ill. en coul.d19 cm. 2aMine de rien alivre cartonné 1010aDOLTO-TOLITCHbCatherine10aBOUCHERbJoëllegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0149777*81gL-h014977m20141104opqbram1[DON][Don][][45][][][][0,00][][][][][][][][][mobilier bibliothèque][][][][][][][][]2[AJM][Album "Jardin des mots"][0][1][Livre disponible : Fonds "Jardin des Mots"][0][0][0][0]91995-11-29-00.00.00.0000005149776BIB diff --git a/tests/library/Class/Cosmogramme/Integration/records_to_update.txt b/tests/library/Class/Cosmogramme/Integration/records_to_update.txt new file mode 100644 index 0000000000000000000000000000000000000000..c31040389ea0bf4f7eea89bc29f1b6eccd98ae84 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/records_to_update.txt @@ -0,0 +1 @@ +01321nam0 22003011 450 00100090000001000250000910000260003410100130006010500650007320001220013821000270026021500140028721500450030122500170034667600060036368600110036970000170038070100460039770200440044380100510048783000210053883500060055993000250056593200160059093200160060693200110062299503860063300012445 a2-07-050157-4d10,06 a19991209 e 1frea01 ba0 afrecfre 1[1999-12-09-00.00.00.000000][2006-08-25-00.00.00.000000][][]1 aLe Portrait de Dorian GrayfOscar WILDEgTrad. de l'anglais par Edmond JALOUXgTrad. de l'anglais par Félix FRAPEREAU aPariscGallimardd1981 a1 vol.11 a253 p.3253ccouv. ill. en coul.d21 cm. 2a1000 Soleils 10 aRO WIL10aWILDEbOscar10aFRAPEREAUbFélixgTrad. de l'anglais5TRG10aJALOUXbEdmondgTrad. de l'anglais5TRG aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1ADO2adolescents aR aRoman adolescent4RO aPhilosophie aFantastique aVanité aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0113177*81gL-h011317kRO WILm20141104opqeram1[ALP][Librairie ALPHABET][ORLEANS][45000][14, Rue de la République][FABRICE, ISABELLE, MARYLE][38.54.17.59][0,00][][][][][][][][][][][][][][][][][]2[ARE][Roman Adolescent][0][1][Livre disponible - Romans Fonds Adolescent][0][0][0][0]310,0691993-05-27-00.00.00.0000005113176BIB01068nam0 22002531 450 00100090000001000180000910000260002710100130005310500650006620000780013121000240020921500070023321500580024022500170029830300190031567600060033470000290034070200380036980100510040783000230045883500060048193000130048799503140050000016448 a2-218-24667-8 a19991209 b 1frea01 ba0 afrecfre 1[1999-12-09-00.00.00.000000][2007-02-07-00.00.00.000000][][]1 aLes Trésors des cheminsfCatherine DOLTO-TOLITCHgIll. par Joëlle BOUCHER aPariscHatierd1989 4np anon paginécill. en coul. couv. ill. en coul.d19 cm. 2aMine de rien alivre cartonné 1010aDOLTO-TOLITCHbCatherine10aBOUCHERbJoëllegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0149777*81gL-h014977m20141104opqbram1[DON][Don][][45][][][][0,00][][][][][][][][][mobilier bibliothèque][][][][][][][][]2[AJM][Album "Jardin des mots"][0][1][Livre disponible : Fonds "Jardin des Mots"][0][0][0][0]91995-11-29-00.00.00.0000005149776BIB01674nam0 22003611 450 00100090000001000250000910000260003410100130006010500650007320001630013821000180030121500590031961000160037861000140039461000140040861000160042261000280043861000250046661000170049161000130050867600470052168600140056870000380058270200380062070200380065870200400069670200400073680100510077683000230082783500060085093000300085699504260088600022315 a2-215-06225-8d10,51 a19991209 b 1frea01 ba0 afrecfre 1[1999-12-09-00.00.00.000000][2007-05-11-00.00.00.000000][][]1 aL'Imagerie de l'histoirefConcept. Emilie BEAUMONTgTexte de Marie-Renée PIMONTgIll. par Isabella MISSOgIll. par Sophie TOUSSAINTgIll. par Isabelle ROGNONI cFleurusd1999 a125 p.3125cIll. en coul. couv. ill. en coul.d23 cm. aPréhistoire aAntiquité aMoyen Age aRenaissance aHenri IV, roi de France aRévolution française aXXème siècle aHistoire a909tHistoire universelle. Civilisation11 a909 BEA B10aBEAUMONTbEmiliegConception5CON10aPIMONTbMarie-RenéegTexte de5TX10aMISSObIsabellagIllustré par5IL10aTOUSSAINTbSophiegIllustré par5IL10aROGNONIbIsabellegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aD aDocumentaire jeunesse4DJ aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0207167*81gL-h020716k909 BEA Bm20141104opqbram1[LOD][Librairie LODDE][ORLEANS][45000][Rue Jeanne d'Arc][MARYLENE, ISABELLE][02.38.65.43.43][15,00][][][][][][][][][fournitures mat. audio][][][][][][][][]2[ADJM][Documentaire "Jardin des Mots"][0][1][Livre disponible : Fonds documentaire Au Jardin des Mots][0][0][0][0]310,5191999-11-19-00.00.00.0000005207166BIB01277oam2 22003011 450 00100090000001000250000902100070003410000260004110100080006710500650007520001160014021000130025621500070026921500580027646100190033467600060035368600060035970000180036570200430038370200410042680100510046783000230051883500060054193000130054793200100056093200090057099503960057900022329 a3-314-21211-9d12,04 aFR a19991209 b 1frea01 ba0 afre 1[1999-12-09-00.00.00.000000][2006-08-10-00.00.00.000000][][]1 aPlume et le chien de traîneaufHans de BEERgTrad. par Anne-Marie CHAPOUTONgTrad. par Géraldine ELSCHNERv232 cNord-Sud 4np anon paginécIll. en coul. couv. ill. en coul.d30 cm. tPlumev239031 10 aB10aBEERbHans de10aCHAPOUTONbAnne-MariegTraduit par5TR10aELSCHNERbGéraldinegTraduit par5TR aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aChien aOurs aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0207937*81gL-h020793kBm20141104opqbram1[LOD][Librairie LODDE][ORLEANS][45000][Rue Jeanne d'Arc][MARYLENE, ISABELLE][02.38.65.43.43][15,00][][][][][][][][][fournitures mat. audio][][][][][][][][]2[AJM][Album "Jardin des mots"][0][1][Livre disponible : Fonds "Jardin des Mots"][0][0][0][0]313,5691999-11-19-00.00.00.0000005207936BIB00771nam1 22002651 450 00100090000001000100000902100070001910000260002610100080005210500650006020000860012521000130021121500070022421500580023167600060028968600060029570000180030170200430031970200410036280100510040383000230045483500060047793000130048393200090049600009031 d12,04 aFR a19991209 b 1frea01 ba0 afre 1[1999-12-09-00.00.00.000000][1999-12-09-00.00.00.000000][][]1 aPlumefHans de BEERgTrad. par Anne-Marie CHAPOUTONgTrad. par Géraldine ELSCHNER cNord-Sud 4np anon paginécill. en coul. couv. ill. en coul.d30 cm. 10 aB10aBEERbHans de10aCHAPOUTONbAnne-MariegTraduit par5TR10aELSCHNERbGéraldinegTraduit par5TR aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aOurs01874nje0 22004331 450 00100090000001000240000907100270003310000240006010500650008420000710014921000190022021500390023922500170027830100130029546400420030846400260035046400430037646400400041946400350045946400270049446400410052146400280056246400380059046400250062846400240065346400250067746400300070246400310073246400250076346400310078867600060081968600130082571000490083880100510088783500060093893000140094493400780095899504040103600301892 a5030073020921d7,6200a302092bHallmark2HALL a19991209 1frea01 ba 1[1999-12-09-00.00.00.000000][2009-06-09-00.00.00.000000][][]1 aTangofOrchestre THE BALLROOM DANCE ORCHESTRAbDC : Disque Compact cHallmarkd1995 a1 DC11c, (43.54)5[43.54]d13/14 2aCome dancing aS-0016221 aSanta MonicabTraditionneld(4.58)v11 aBlue tangod(2.48)v11 aLa PassionarabTraditionneld(2.28)v11 aLa Cumparsitad(2.30)v1fRODRIGUEZ1 aHernando's Hideawayd(2.26)v11 aA Media luzd(2.14)v11 aEl ToreadorbTraditionneld(2.20)v11 aTango veranod(1.43)v11 aEl PoetabTraditionneld(3.35)v11 aLa Palomad(3.14)v11 aJealousyd(3.06)v11 aOle Guapad(3.11)v11 aTango Op.165/2d(2.09)v11 aTango del Amord(2.015)v11 aEl Choclod(2.06)v11 aAdios Muchachosd(2.05)v1 10 a5.63 TAN10aTHE BALLROOM DANCE ORCHESTRAgOrchestre5ORC aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN aC aTango4TA a<5><63><><"Danse de salon" (tango, valse, charleston, etc...)><TAN>< >< > aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfS-0016227*81gS-h001622k5.63 TANm20141104opqsrje1[CDD][CDD/Digital Concept][CARRY-LE-ROUET][13620][7 Allée des Tilleuls][MR BEGOND PATRICK][02.38.55.66.51][0,00][][][][][][][][][mobilier bibliothèque][][][][][][][][]2[ACD][Disque Compact Adulte][0][1][CD disponible : Fonds Sonore Adulte][0][0][0][0]37,6291998-02-17-00.00.00.000000516226BIB01237oam2 22002771 450 00100090000001000240000902100070003310000260004010100080006610501170007420000890019121000330028021500460031322500270035930300190038646100420040567600060044770000200045370200360047380100510050983000230056083500060058393000130058993200090060299503480061100401796 a2-227-70496-9d3,33 aFR a20000619 b 1frea01 ba0 afre 1[2000-06-19-00.00.00.000000][2006-09-26-00.00.00.000000][2000-06-19-00.00.00.000000][1997-09-01-00.00.00.000000]1 aLes Animaux préférés de Petit Ours BrunfMarie AUBINAISgIll. par Danièle BOURv131 aPariscBayard Editionsd1997 cill. en coul. couv. ill. en coul.d15 cm. 2aLes petits répertoires alivre cartonné tPetit Ours Brun (cartonné)v13401795 1010aAUBINAISbMarie10aBOURbDanièlegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aOurs aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0334757*81gL-h033475m20141104opqbram1[DON][Don][][45][][][][0,00][][][][][][][][][mobilier bibliothèque][][][][][][][][]2[AJM][Album "Jardin des mots"][0][1][Livre disponible : Fonds "Jardin des Mots"][0][0][0][0]33,3392009-04-10-00.00.00.00000042000-06-19-00.00.00.0000005334756BIB00679nam1 22002291 450 00100090000001000090000910000260001810100080004410500650005220000700011721000330018721500070022021500580022767600060028570000200029170200360031180100510034783000230039883500060042193000130042793200090044000401795 d3,33 a20000619 b 0frea01 ba0 afre 1[2000-06-19-00.00.00.000000][][2000-06-19-00.00.00.000000][]1 aPetit Ours Brun (cartonné)fMarie AUBINAISgIll. par Danièle BOUR aPariscBayard Editionsd1997 4np anon paginécill. en coul. couv. ill. en coul.d15 cm. 1010aAUBINAISbMarie10aBOURbDanièlegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1B2blanc (0-5 ans) aF aAlbum4A aOurs01506oam2 22003251 450 00100090000001000240000902100070003310000260004010100130006610501170007920001220019621000470031821500140036521500570037922500270043646100200046367600060048368600130048970000260050270200500052870200390057880100510061783000230066883500060069193000230069793200080072093200130072893200210074199504180076200404959 a2-01-200238-2d4,26 aFR a20010514 c 1frea01 ba1 afrecger 1[2001-05-14-00.00.00.000000][2007-08-16-00.00.00.000000][2001-05-14-00.00.00.000000][2001-02-01-00.00.00.000000]1 aMini au bord de merfChristine NOSTLINGERgTrad. de l'allemand par Marie-Claude AUGERgIll. par Claire LE GRANDv534 aParisb43 Quai de GrenellecHachette Livre a1 vol.11 a93 p.393cill. en coul. couv. ill. en coul.d18 cm. 2aBibliothèque Rosev518 tMiniv53404561 10 aJR NOS J10aNOSTLINGERbChristine10aAUGERbMarie-ClaudegTrad. de l'allemand5TRD10aLE GRANDbClairegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1J2jaune (5-8 ans) aR aRoman jeunesse4JR aMer aVacances aRoman d'aventure aBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMINfL-0233347*81gL-h023334kJR NOS Jm20141104opqjram1[LOD][Librairie LODDE][ORLEANS][45000][Rue Jeanne d'Arc][MARYLENE, ISABELLE][02.38.65.43.43][15,00][][][][][][][][][fournitures mat. audio][][][][][][][][]2[ARJ][Roman Jeunesse][0][1][Livre disponible : Fonds Roman Jeunesse][0][0][0][0]33,6292001-05-14-00.00.00.00000042001-05-14-00.00.00.0000005233346BIB00906nam1 22002651 450 00100090000001000090000902100070001810000260002510100130005110500910006420001010015521000470025621500570030322500220036067600060038268600130038870000260040170200500042770200390047780100510051683000230056783500060059093000230059693200210061900404561 d4,26 aFR a20010404 c 1frea01 ba1 afrecger 1[2001-04-04-00.00.00.000000][2007-08-16-00.00.00.000000][2001-04-04-00.00.00.000000][]1 aMinifChristine NOSTLINGERgTrad. de l'allemand par Marie-Claude AUGERgIll. par Claire LE GRAND aParisb43 Quai de GrenellecHachette Livre a90 p.390cill. en coul. couv. ill. en coul.d18 cm. 2aBibliothèque Rose 10 aJR NOS J10aNOSTLINGERbChristine10aAUGERbMarie-ClaudegTrad. de l'allemand5TRD10aLE GRANDbClairegIllustré par5IL aFRbBIBLIOTHEQUE MUNICIPALE ST-PRYVE ST-MESMIN 1J2jaune (5-8 ans) aR aRoman jeunesse4JR aRoman d'aventure diff --git a/tests/library/Class/SitothequeTest.php b/tests/library/Class/SitothequeTest.php index 5d8250a6f4b8ecc132c3bf2d193cc4f84b7437cf..06d267be0648cc4aba8a5a601598c486c34f3845 100644 --- a/tests/library/Class/SitothequeTest.php +++ b/tests/library/Class/SitothequeTest.php @@ -40,7 +40,10 @@ class SitothequeSitesFromIdsAndCategoriesTest extends Storm_Test_ModelTestCase { -class SitothequeIndexAllTest extends Storm_Test_ModelTestCase { +class SitothequeIndexAllTest extends ModelTestCase { + protected + $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); Class_Notice::beVolatile(); @@ -104,6 +107,15 @@ class SitothequeIndexAllTest extends Storm_Test_ModelTestCase { Class_Sitotheque::indexAll(); $this->assertNotContains('1', Class_Sitotheque::find(2)->getDomaineIdsAsArray()); } + + + + /** @test */ + public function deleteSiteOneShouldDeleteNoticeOne() { + Class_Sitotheque::find(1)->delete(); + Class_Notice::clearCache(); + $this->assertEmpty(Class_Notice::find(1)); + } } diff --git a/tests/library/Class/TimeSourceForTest.php b/tests/library/Class/TimeSourceForTest.php index 9ed1bf6a49dc3faa17246be13537a015ce23b81d..192f1897c64dd7c9f8fbe2c4f7ff57f2898cd9f9 100644 --- a/tests/library/Class/TimeSourceForTest.php +++ b/tests/library/Class/TimeSourceForTest.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 TimeSourceForTest extends Class_TimeSource { @@ -41,6 +41,10 @@ class TimeSourceForTest extends Class_TimeSource { public function time() { return $this->_time; } -} -?> \ No newline at end of file + + public function atCoffeeTime() { + $this->_time = strtotime(date('Y-m-d', $this->_time) . ' 16:00:00'); + return $this; + } +} \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index d612ff2f45028bf2209c0b85ab24a8dfa49a466d..b957ded7b7f2338e2d63db62b83ac5af3defa27e 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -include_once 'NanookFixtures.php'; +include_once 'tests/fixtures/NanookFixtures.php'; class NanookGetServiceTest extends Storm_Test_ModelTestCase { public function setUp() { diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index 02201180a2974e6a6b8b6724a0a03eb26afa831c..8106c8bd27ea650862f35690c78f53055353e1b7 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -205,12 +205,12 @@ class SitoViewHelperLastTest extends SitoViewHelperTestCase { /** @test */ - public function itemsShouldBeShuffled() { + public function itemsShouldNotBeShuffled() { $htmls = []; for ($i=0; $i<10; $i++) $htmls[] = $this->_helper->getBoite(); - $this->assertTrue(1 < count(array_unique($htmls))); + $this->assertCount(1, array_unique($htmls)); } } diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 8656f02449b8e9d4375db91e76b7560e92039efc..689b573449c14528b7e5c458cb241041b81123f6 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -7,6 +7,9 @@ stopOnError="false" > <testsuites> + <testsuite name="DBTestSuite"> + <directory>./db/</directory> + </testsuite> <testsuite name="ApplicationTestSuite"> <directory>./application/</directory> <directory>./library/</directory>