diff --git a/INSTALL.en.md b/INSTALL.en.md index 9cfdb1b6a3f1edd030bbe0368cb535ea4d7fe457..c040accb5ce8c3f219d4bc9fbfab1249295a5d15 100644 --- a/INSTALL.en.md +++ b/INSTALL.en.md @@ -3,24 +3,19 @@ This procedure is meant for Ubuntu et Debian GNU/Linux # Necessary packages : -## Ubuntu -Requirements: Bokeh needs PHP 5.4 which is not present by default in ubuntu. Repository must be declared below with the last version of php: - +## Ubuntu Trusty ``` -apt-get install python-software-properties -add-apt-repository ppa:ondrej/php5 -apt-get update -apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 subversion php5-mcrypt +apt-get install python-software-properties php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz ``` -## Debian +## Debian Wheezy ``` -apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 subversion php5-mcrypt +apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz ``` ## ArchLinux ``` -yaourt -S php php-gd php-imagick xdebug php-pear apache mysql php-apache php-xhprof graphviz subversion +yaourt -S php php-gd php-imagick xdebug php-pear apache mysql php-apache php-xhprof graphviz git ``` ## CentOS @@ -86,8 +81,10 @@ upload_max_filesize = 10M error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED ``` -Activate the following extensions: calendar, curl, gd, gettext, iconv, mcrypt, mysql, pdo_mysql, openssl, soap, imagick - +Activate the following extensions if they are not already actived (they should be): +``` +php5enmod calendar curl gd gettext iconv mcrypt mysql pdo_mysql openssl soap imagick +``` ## Configure Apache @@ -121,7 +118,7 @@ chmod -R 777 opacce/temp # MySQL config -Modifier /etc/mysql/my.cnf et ajouter dans la section et forcer l'indexation fulltext à partir de 1 lettre dans la section [mysqld] +Edit /etc/mysql/my.cnf and add to the [mysqld] section the following line (in order to force fulltext indexation from the first letter) ``` ft_min_word_len = 1 @@ -136,7 +133,7 @@ skip-character-set-client-handshake character-set-server=utf8 ``` -Connect to mysql and import the db schema +Connect to mysql and import the database schema ``` mysql -uroot -ppass @@ -167,13 +164,13 @@ cp config.ref.php config.php connnect with the account admin/achanger and click on the patch update link -# connect to the opac +# Connect to the opac Use the account compte admin/achanger go to http://localhost/opacce/admin -# TO run the tests: +# To run the tests: ``` cd opacce/tests/ phpunit -``` \ No newline at end of file +``` diff --git a/INSTALL.fr.md b/INSTALL.fr.md index 3c2e8b8f8ed6fd39d475720efeced64f5863fe50..320f5f10b0e5a48f9c59c8bc48d17037c51afd01 100644 --- a/INSTALL.fr.md +++ b/INSTALL.fr.md @@ -3,24 +3,19 @@ Sauf indiqué, cette procédure prends en compte par défaut les distributions G # Paquets nécessaires: -## Ubuntu -Prérequis: l'OPAC nécessite PHP 5.4 qui n'est pas encore par défaut dans Ubuntu. Il est nécessaire de déclarer le dépôt qui suit la dernière version de PHP comme ceci: - +## Ubuntu Trusty ``` -apt-get install python-software-properties -add-apt-repository ppa:ondrej/php5 -apt-get update -apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 subversion php5-mcrypt +apt-get install python-software-properties php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz ``` -## Debian +## Debian Wheezy ``` -apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 subversion php5-mcrypt +apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysql graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz ``` ## ArchLinux ``` -yaourt -S php php-gd php-imagick xdebug php-pear apache mysql php-apache php-xhprof graphviz subversion +yaourt -S php php-gd php-imagick xdebug php-pear apache mysql php-apache php-xhprof graphviz git ``` ## CentOS @@ -86,8 +81,10 @@ upload_max_filesize = 10M error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED ``` -Activez les extensions suivantes: calendar, curl, gd, gettext, iconv, mcrypt, mysql, pdo_mysql, openssl, soap, imagick - +Activez les extensions suivantes si elles ne le sont pas déjà (elles devraient l'être) : +``` +php5enmod calendar curl gd gettext iconv mcrypt mysql pdo_mysql openssl soap imagick +``` ## Configurer Apache @@ -176,4 +173,4 @@ cp config.ref.php config.php ``` cd opacce/tests/ phpunit -``` \ No newline at end of file +``` diff --git a/INSTALL.windows.md b/INSTALL.windows.md new file mode 100644 index 0000000000000000000000000000000000000000..61e3da04eaabae6df602fc29b77ab958bb632c48 --- /dev/null +++ b/INSTALL.windows.md @@ -0,0 +1,85 @@ +# Préparation de Windows + +Téléchargez et installez le paquet [Microsoft Visual C++ 2008 Redistributable](http://www.microsoft.com/en-us/download/details.aspx?id=5582) + +Cela nécessite le redémarrage de windows. + + +# Installation de la pile Apache + MySQL + PHP + +Télécharger [XAMPP portable pour Windows](http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/5.6.3/xampp-portable-win32-5.6.3-0-VC11.zip/download) + +Décompressez l'archive et déplacez le répertoire **xamp** à la racine d'un disque (ex: D:\xampp\) + +Lancer le programme **D:\xampp\xampp-control** puis démarrez les services MySQL et Apache. Depuis un navigateur web, allez sur la page http://localhost. Vous devriez arriver sur une page avec le logo XAMPP. + + +# Configuration d'Apache + +Modifiez le fichier D:\xampp\apache\conf\http.conf et décommentez la ligne suivante (ligne 108 et 115) +``` +LoadModule deflate_module modules/mod_deflate.so + +LoadModule filter_module modules/mod_filter.so +``` + +Note si vous utilez une version d'Apache différente de celle abordée ici: assurez-vous de l'activation des modules ''headers'' et ''rewrite''. + + +# Récupération des sources + +Téléchargez et installez [SourceTree pour l'accès GIT](http://www.sourcetreeapp.com/) + +Ceci fait, dans le menu **Fichier** sélectionnez **Cloner / nouveau** et remplisser le formulaire comme suit: +* Source / URL: **http://git.afi-sa.fr/afi/opacce.git** +* Destination: **D:\xampp\htdocs\opacce** + +et cliquez sur **Cloner**. + + +# Création de la base de données + +Pointez votre navigateur web sur http://localhost/phpmyadmin pour accéder à l'outil d'administration MySQL. + +Dans l'onglet **Bases de données** créez la base **opacce** puis sélectionnez la dans l'arborescence de gauche. + +Dans l'onglet **Plus** sélectionnez **Importez**, puis importez le ficher **D:\xampp\htdocs\opacce\scripts\opac2.sql**. + + + +# Configuration de Bokeh + +Depuis le répertoire D:\xampp\htdocs\opacce, copiez le fichier **config.ini.default** en **config.ini** et modifiez les lignes suivantes: +``` +sgbd.config.username = root +sgbd.config.password = +sgbd.config.dbname = opacce +``` + +Depuis le répertoire D:\xampp\htdocs\opacce\cosmogramme, copiez le fichier **config.ref.php** en **config.php** et modifiez les lignes suivantes: +``` +integration_user=root +integration_pwd= +integration_base=opacce +pwd_master=opacce +``` + +Créez un fichier vide **D:\xampp\htdocs\opacce\local.php** (celui-ci sert à surcharger des configurations globales au site). + + +# Mise à jour de la base de données + +Pointez votre navigateur sur http://localhost/opacce/cosmogramme/ et connectez vous avec le compte admin / achanger. + +De là , cliquez sur le lien **Vous devez exécuter une mise à niveau de la base de données**. + + +# Terminé ! + +Vous pouvez maintenant administrer Bokeh à l'adresse http://localhost/opacce/admin avec le compte admin / achanger. + +Les URLs sont: +- interface publique: http://localhost/opacce +- interface d'administration: http://localhost/opacce/admin +- interface de configuration des intégrations SIGB: http://localhost/opacce/cosmogramme + diff --git a/VERSIONS b/VERSIONS index 9633c7e28e247c3e23ac2caaa84a4ba12756b7ee..421e59787848e8bf05b6335927c54c5cf491ffac 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,153 @@ +26/05/2015 - v7.1.34 + + - ticket #25066 : Bibliothèque numérique, ajout du connecteur Jamendo + + - ticket #19572 : Possibilité d'import des vignettes des sites web depuis typo3 vers bokeh. + + - ticket #25334 : Protocole CAS 1.0: ajout du mail et de la date de naissance dans la réponse "validate" pour les besoins du SSO 1DTouch + + - ticket #21425 : Boîte critiques : nouveau mode d'affichage en navigation hiérarchique par domaine + + - ticket #19571 : Cosmogramme peut importer des paniers exportés par le SIGB dans un fichier CSV + + - ticket #23767 : Correction de l'ordre de creation des contantes dans cosmogramme. BASE_URL n'était pas définit pendant les intégrations. + + + +22/05/2015 - v7.1.33 + + - ticket #24826 : Ajout d'une hauteur minimale dans le contenu des boîtes pour qu'on puisse toujours accéder à la molette de configuration. + + - ticket #25250 : Suppression des containtes SQL 'not null' sur les champs de la table notices_articles + + - ticket #25054 : Correction du filtrage du calendrier lorsque la date n'était pas sélectionnée. + + + +19/05/2015 v7.1.32 + + - dev#15606: Nanook: possibilité de définir le site de l'abonné comme site de retrait par défaut pour les réservations. + La préférence Cosmogramme 'site_retrait_resa' permet désormais ce comportement, positionnée sur 'site de l'abonné'. + + - ticket #24993 : Amélioration du paramétrage de la boîte de navigation par domaine. Seulement un domaine est sélectionnable. Les domaines sélectionnables sont ceux qui on des sous-domaines. + + - ticket #23837 : Augmentation de la taille de tous les VARCHAR de la table exemplaires + + - ticket #18547 : possibilité de définir le site de l'abonné comme site de retrait par défaut pour les réservations Pergame. + + - ticket #22532 : les ressources numériques pouvaient ne pas s'afficher après sauvegarde d'un album + + - ticket #24656 : l'export CSV des formulaires n'est plus dépendant du système de fichiers, ce qui corrige l'impossibilité d'exporter si il existe un fichier "formulaires.csv" avec les mauvais droits d'accès + + - ticket #22632 : corrige l'intégration des articles de périodiques pour Nanook lorsque le numéro de tome est supérieur à 10 caractères + + - ticket #24816 : La position des boîtes est gardée après réattribution d'un identifiant. + + + +12/05/2015 - v7.1.31 + + - ticket #24903 : les urls de génération des vignettes utilisent le format ZF, ce qui corrige un problème de chargement selon l'infrastructure d'installation + + +12/05/2015 v7.0.18 + + - ticket #24569 : Cosmogramme: correction de la sélection du format de fichier de profil de données sur certaines installations + - ticket #24206 : Correction de l'impossibilité d'ajouter de nouvelles boîtes (si utilisation de boîtes dans la bannière). + - ticket #18668 : Evolution du rendu des biographies en provenance de l'API de wikipedia. + +11/05/2015 - v7.1.30 + + - ticket #23802 : Ajout d'un mode de visualisation par arborescence paginée dans la boite sitothèque + - ticket #24664 : correction de l'accès aux articles en tant qu'administrateur bibliothèque dans le mode "liste" + + + +04/05/2015 - v7.1.29 + +- ticket #23459 : lorsqu'on modifie un article en mode liste, le bouton retour ramène à la catégorie de l'article modifié +- ticket #23734 : correction du parcours des réponses web services suite à mise à jour du SIGB Orphée +- ticket #24503 : fixe les thesaurus dont le titre contient des caractères autre que [a-zA-Z0-9] +- ticket #23721 : correction de l'indexation en temps réel des pseudos notices d'articles, sitothèques et paniers +- ticket #23756 : correction des liens de différents bouttons qui posaient problèmes pour les Bokeh installé en mode racine. +- tickets #24489 et #24486 : correction des patchs SQL 233 et 235 qui posaient problèmes lors d'une migration d'une base stable vers master. +- ticket #24497 : correction d'une erreur d'indexation des domaines (Cosmogramme) + + + +27/04/2015 - v7.1.28 + + - ticket #18297: Mise en conformité RGAA de la liste des résultats de recherche et de la vue notice + - ticket #21436: Possibilité de définir des facettes à partir de champs unimarc arbitraires + - ticket #21758 : Ajout de la possibilité d'avoir un résultat de recherche au format JSON + - ticket #23904 : Le filtrage du contenu dans ckeditor est désactivé pour les administrateurs + - Premier écran d'installation / configuration de Bokeh, merci à Gaël VINOT pour cette contribution + + + +23/04/2015 - v7.1.27 + - ticket #23391 : Correction d'une régression dans le mode de dédoublonnage par identifiant. + - ticket #19079 : Correction de la modification des vignettes pour les périodiques. + - hotline#22305 : Respect des sauts de ligne dans les avis notice des bibliothécaires. + + + +17/04/2015 - v7.0.15 - v7.1.25 v7.1.26 + - ticket #18020 : Mise à jour de la gestion des réservations des postes multimédia. + + - ticket #24018 : Correction d'un bug qui ajoutait des boîtes avec le même identifiant entre les profils partagés. + + + +14/04/2015 - v7.1.23 - v7.1.24 + + - ticket #23322 : Correction d'un bug qui empéchait la création de sous-catégories d'articles dans la nouvelle interface de gestion + + + + +14/04/2015 - v7.0.14 + + - ticket #23080 : Correction d'un bug qui duplicait le résumé d'un album en note de la notice à l'indexation. + + - ticket #23465 : Correction du lien pour accéder aux bibliothèques depuis le mode territoire + + + +30/032015 - v 7.1.22 + + - ticket #18283 : RGAA + + - Amélioration de la conformité RGAA dans la banniere, les images, les permaliens, la boite de recherche, la boite de connexion, + la boite calendrier avec le tableau des jours, la boite kiosque de notice. + + - Pour faciliter la mise en place de charte graphique, les tailles du site paramétrées dans les profils peuvent être exprimées en pourcentage. + + + +30/03/2015 - v7.0.13 + + - ticket #21695: Bibliothèque numérique : ajout d'un mode de visualisation en listes paginées. + Ceci permet d'améliorer grandement la vitesse d'affichage + et de navigation dans les albums pour les grands volumes d'albums. + + - ticket #21953: Correction de la création de domaines via le droit de création. + + - ticket #22194: Suppression du message "Le service Babelio est gratuit pour une durée de 90 jours..." + + - ticket #23216: Ajout d'une exception pour 'robots.txt' dans le fichier .htaccess + + + +26/03/2015 - v7.1.20 + - ticket #22172: Améliore l'ergonomie des liens FRBR + + - ticket #22519: Supprime les caractères de non-tri lors de l'homogénéisation des notices. + + - ticket #23151: Optimisation des requêtes faites lors de la visualisation des notices. + + + 19/03/2015 - v7.1.19 - ticket #22829: Correction d'une régression dans l'import des fichiers d'abonnés diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index 547bb2c5d789635d43d4bb9fa4fe4b7999f690d2..b4b8830e12b0598918ccab9a06b6f54488ee4fac 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -104,7 +104,17 @@ class Admin_AccueilController extends Zend_Controller_Action { } + public function preprocessSitoCategories() { + if ((int)$this->_getParam('type_aff',0)!=3) + return; + + if ($categories=explode('-',$this->_getParam('id_categorie'))) + $this->_request->setPost('id_categorie',$categories[0]); + + } public function sitothequeAction() { + $this->preprocessSitoCategories(); + $this->_request->setPost('group_by_categorie','0'); $this->_simpleAction('SITO'); } diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 3999e6c1ebe1670dead484ef5067e4ecf78ca2b4..81636cabfe13bccc444210cb543fcf23e24c5a8d 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -34,19 +34,22 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { public function indexAction() { - $categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0, 'order' => 'libelle']); + if (Class_AdminVar::get('ALBUMS_LIST_MODE')) + return $this->_renderList(); + + $categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0, + 'order' => 'libelle']); $categories []= Class_AlbumCategorie::defaultCategory() ->setAlbums(Class_Album::findAllBy(['cat_id' => 0])); - $this->view->categories = [ [ 'bib' => Class_Bib::getPortail(), - 'containers' => $categories]]; + $this->view->categories = [ ['bib' => Class_Bib::getPortail(), + 'containers' => $categories]]; $this->view->containersActions = $this->_getTreeViewContainerActions(); $this->view->itemsActions = $this->_getTreeViewItemActions(); $this->view->headScript()->appendScript('var treeViewSelectedCategory = ' - . (int)$this->_getParam('cat_id') . ';' - . 'var treeViewAjaxBaseUrl = "' . $this->view->url(['action' => 'items-of']) . '"'); + . (int)$this->_getParam('cat_id') . ';' + . 'var treeViewAjaxBaseUrl = "' . $this->view->url(['action' => 'items-of']) . '"'); $this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js'); - } @@ -124,7 +127,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } - protected function _formImportDilicom() { return $this->view ->newForm(['id' => 'import_dilicom', 'class' => 'form']) @@ -136,7 +138,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } - protected function _formImportEAD() { return $this->view ->newForm(['id' => 'import_ead', 'class' => 'form']) @@ -194,8 +195,8 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } $this->_renderCategoryForm( - $categorie, - 'Modification de la '. ((!$categorie->hasParentCategorie()) ? 'collection' : 'catégorie') . ' "' . $categorie->getLibelle() . '"'); + $categorie, + 'Modification de la '. ((!$categorie->hasParentCategorie()) ? 'collection' : 'catégorie') . ' "' . $categorie->getLibelle() . '"'); } @@ -219,7 +220,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $title .= ' dans la collection "' . $categorie->getLibelle() . '"'; $this->_renderAlbumForm( - Class_Album::newInstance()->setCategorie($categorie), $title); + Class_Album::newInstance()->setCategorie($categorie), $title); } @@ -312,7 +313,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { public function editressourceAction() { if (null === ($ressource = Class_AlbumRessource::getLoader() - ->find($this->_getParam('id')))) { + ->find($this->_getParam('id')))) { $this->_redirect('admin/album'); return; } @@ -325,9 +326,9 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->view->errors = $ressource->getErrors(); $this->view->form->getElement('fichier') - ->setValue($ressource->getFichier()); + ->setValue($ressource->getFichier()); $this->view->form->getElement('poster') - ->setValue($ressource->getPoster()); + ->setValue($ressource->getPoster()); $this->view->ressource = $ressource; } @@ -379,7 +380,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { public function massRessourceDeleteAction() { $this->_helper->getHelper('viewRenderer')->setNoRender(true); if ((!$ids = $this->_getParam('ids')) - || (!$id = $this->_getParam('id'))) { + || (!$id = $this->_getParam('id'))) { $this->_helper->notify('Paramètres manquants dans la requête de suppression'); return; } @@ -466,19 +467,19 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { */ protected function _categorieForm($categorie) { $cat_id = $categorie->isNew() ? $categorie->getParentId(): $categorie->getId(); - $form = new Zend_Form(['id' => 'categorie', - 'data-backurl' => $this->view->url(['action' => 'index', - 'cat_id' => $cat_id])]); + $form = new ZendAfi_Form(['id' => 'categorie', + 'data-backurl' => $this->view->url(['action' => 'index', + 'cat_id' => $cat_id])]); $form->addElement(new Zend_Form_Element_Text('libelle', ['label' => 'Libellé *', 'size' => 30, 'required' => true, 'allowEmpty' => false])) - ->addDisplayGroup(['libelle'], 'categorie', - ['legend' => (($categorie->hasParentCategorie()) ? - 'Catégorie' - : 'Collection')]) - ->populate($categorie->toArray()); + ->addDisplayGroup(['libelle'], 'categorie', + ['legend' => (($categorie->hasParentCategorie()) ? + 'Catégorie' + : 'Collection')]) + ->populate($categorie->toArray()); return $form; } @@ -519,8 +520,10 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { */ protected function _albumForm($album) { $form = ZendAfi_Form_Album::newWithAlbum($album); - $form->addAttribs(['data-backurl' => $this->view->url(['action' => 'index', - 'cat_id' => $album->getCatId()])]); + $bib_id_param = []; + if(!$this->_getParam('title_search')) + $bib_id_param = ['cat_id' => $album->getCatId()]; + $form->addAttribs(['data-backurl' => $this->view->url(array_filter(array_merge(['action' => 'index'], $bib_id_param)))]); return $form; } @@ -533,7 +536,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { return ZendAfi_Form_Album_Ressource::newWith($ressource); } - /** + /** * @param Class_Album $album * @return null */ @@ -542,8 +545,8 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->view->form = $form; if ( - !$this->_request->isPost() - or !$form->isValid($this->_request->getPost()) + !$this->_request->isPost() + or !$form->isValid($this->_request->getPost()) ) return; @@ -605,7 +608,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { (new Storm_Cache())->clean(); $this->_helper->notify('Album sauvegardé'); - $this->_redirectClose('admin/album/edit_album/id/' . $album->getId()); return true; } return false; @@ -630,15 +632,15 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { */ protected function _renderAlbumForm($album, $titre) { if ($this->_validateAndSaveAlbum($album)) - return; + return $this->_redirectToEdit($album);; $this->view->titre = $titre; $this->view->errors = $album->getErrors(); $this->view->album = $album; $this->view->form->getElement('fichier') - ->setValue($album->getFichier()); + ->setValue($album->getFichier()); $this->view->form->getElement('pdf') - ->setValue($album->getPdf()); + ->setValue($album->getPdf()); if ($this->isPopupRequest()) $this->_prepareAlbumAjaxFrom(); @@ -646,20 +648,29 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->getHelper('ViewRenderer')->setScriptAction('album_form'); } + + protected function _getEditUrl($model) { + return Class_Url::absolute(['action' => 'edit_album', + 'id' => $model->getId(), + 'page' => $this->_getParam('page'), + 'title_search' => $this->_getParam('title_search')]); + } + + protected function _prepareAlbumAjaxFrom() { $id_notice = $this->_getParam('id_notice') ? $this->_getParam('id_notice') : ''; $this->view->form->beSimple() - ->setAction($this->view->url(['action' => 'link_album_to', - 'id_notice' => $id_notice])) - ->setEnctype('application/x-www-form-urlencoded'); + ->setAction($this->view->url(['action' => 'link_album_to', + 'id_notice' => $id_notice])) + ->setEnctype('application/x-www-form-urlencoded'); if (!$this->_request->isPost()) { $notice = Class_Notice::find($id_notice); $this->view->form->populateFrbrUrl( - $this->view->absoluteUrl($this->view->urlNotice($notice, [], null, true), null, true)); + $this->view->absoluteUrl($this->view->urlNotice($notice, [], null, true), null, true)); $this->view->form->getElement('titre')->setValue($notice->getTitrePrincipal()); } @@ -667,48 +678,28 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { protected function _getTreeViewContainerActions() { - $actions = Class_AdminVar::isBibNumEnabled() - ? [['url' => $this->_getUrlForAction('add_categorie_to'), - 'icon' => 'ico/add_cat.gif', - 'label' => 'Ajouter une sous-catégorie'], + return (new ZendAfi_View_Helper_ModelActionsTable_AlbumCategories($this->view, 'album'))->getActions(); + } - ['url' => $this->_getUrlForAction('add_album_to'), - 'icon' => 'ico/add_news.gif', - 'label' => 'Ajouter un album']] - : []; + protected function _getTreeViewItemActions() { + return (new ZendAfi_View_Helper_ModelActionsTable_Album($this->view, 'album'))->getActions(); + } - return array_merge($actions, - [['url' => $this->_getUrlForAction('edit_categorie'), - 'icon' => 'ico/edit.gif', - 'label' => 'Modifier la catégorie'], - ['url' => $this->_getUrlForAction('delete_categorie'), - 'icon' => 'ico/del.gif', - 'label' => 'Supprimer la catégorie', - 'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]]); - } + protected function _renderList() { + $cat_id = $this->_getParam('cat_id', ''); + $category = Class_AlbumCategorie::find($cat_id); + if ('0' === $cat_id) + $category = Class_AlbumCategorie::defaultCategory(); - protected function _getTreeViewItemActions() { - return [['url' => $this->_getUrlForAction('edit_album'), - 'icon' => 'ico/edit.gif', - 'label' => "Modifier l'album"], - ['url' => $this->_getUrlForAction('edit_images'), - 'icon' => 'ico/album_images.png', - 'label' => "Gérer les médias", - 'caption' => 'formatedCount'], - ['url' => $this->_getUrlForAction('preview_album'), - 'icon' => function($model) {return $model->isVisible() ? 'ico/show.gif' : 'ico/hide.gif';}, - 'label' => "Visualisation de l'album"], - ['url' => $this->_getUrlForAction('delete_album'), - 'icon' => 'ico/del.gif', - 'label' => "Supprimer l'album", - 'anchorOptions' => ['onclick' => "return confirm('Êtes-vous sûr de vouloir supprimer cet album');"]]]; - } - - - protected function _getUrlForAction($action) { - return $this->view->url($this->_baseUrlOptions + ['action' => $action], null, true) . '/id/%s'; - } -} \ No newline at end of file + $this->view->list = $this->_helper + ->albumListViewMode(['model' => $category, + 'page' => $this->_getParam('page', 0), + 'search_value' => $this->_getParam('title_search', '')]); + + return $this->renderScript('admin/listViewMode.phtml'); + } +} +?> \ No newline at end of file diff --git a/application/modules/admin/controllers/CatalogueController.php b/application/modules/admin/controllers/CatalogueController.php index a02187daa499c15ebe94f2f26beb8cadae728f7e..d4b6e8327d7708d48ae2b0bdfe60d3b918f3085e 100644 --- a/application/modules/admin/controllers/CatalogueController.php +++ b/application/modules/admin/controllers/CatalogueController.php @@ -18,15 +18,13 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Controleur CATALOGUES DYNAMIQUES -////////////////////////////////////////////////////////////////////////////////////////// + class Admin_CatalogueController extends ZendAfi_Controller_Action { use Trait_Translator; protected $_user; - function preDispatch() { + public function preDispatch() { parent::preDispatch(); $this->_user = Class_Users::getIdentity(); @@ -38,20 +36,18 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } - - function indexAction() { + public function indexAction() { if (!$this->view->catalogues = Class_Catalogue::findTopCatalogues()) $this->view->message = $this->_('Aucun domaine n\'a été trouvé'); - $this->view->titre = $this->_('Définition des domaines'); } - function testerAction() { - if(!$id_catalogue=(int)$this->_getParam("id_catalogue")) + public function testerAction() { + if (!$id_catalogue = (int)$this->_getParam("id_catalogue")) $this->_redirect("admin/catalogue/index"); - if(!$catalogue = Class_Catalogue::find($id_catalogue)) + if (!$catalogue = Class_Catalogue::find($id_catalogue)) $this->_redirect("admin/catalogue/index"); $ret = ['requete' => '', @@ -69,7 +65,7 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } } } - // Variables de vue + $this->view->requete = $ret["requete"]; $this->view->temps_execution = $ret["temps_execution"] . " secs."; $this->view->nb_notices = $ret["nb_notices"]; @@ -80,20 +76,15 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } - function addAction() { - $catalogue = Class_Catalogue::getLoader() - ->newInstance() - ->setLibelle("** nouveau domaine **") - ->setParentId($this->_getParam('id_catalogue', null)) - ->setUser(Class_Users::getIdentity()); - + public function addAction() { + $catalogue = $this->_newCatalogue(); if ($this->isSaved($catalogue)) { - if($id_module = $this->_getParam('id_module')) - $this->updateConfigKiosque($id_module,$catalogue); + if ($id_module = $this->_getParam('id_module')) + $this->updateConfigKiosque($id_module, $catalogue); $this->_helper->notify($this->_('Domaine %s ajouté', $catalogue->getLibelle())); - $this->_redirectClose('admin/catalogue/edit/id_catalogue/'.$catalogue->getId()); + $this->_redirectClose('admin/catalogue/edit/id_catalogue/' . $catalogue->getId()); return; } @@ -114,57 +105,58 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } - //---------------------------------------------------------------------------------- - // modification d'un catalogue - //---------------------------------------------------------------------------------- - function editAction() { - $id_catalogue=(int)$this->_getParam("id_catalogue"); - if (!$catalogue = Class_Catalogue::getLoader()->find($id_catalogue)) { - $this->_redirect("admin/catalogue/index"); + public function editAction() { + if ((!$catalogue = Class_Catalogue::find((int)$this->_getParam('id_catalogue'))) + || (!$catalogue->canBeDeletedOrModifyByUser($this->_user))) { + $this->_redirect('admin/catalogue/index'); return; } + if ($this->isSaved($catalogue)) { $this->_helper->notify($this->_('Domaine %s sauvegardé', $catalogue->getLibelle())); - $this->_redirectClose("admin/catalogue/edit/id_catalogue/".$catalogue->getId()); + $this->_redirectClose('admin/catalogue/edit/id_catalogue/' . $catalogue->getId()); return; } $this->view->titre = $this->_('Modification du domaine: %s', $catalogue->getLibelle()); $this->view->catalogue=$catalogue; - $this->getHelper('ViewRenderer')->renderScript('catalogue/form.phtml'); } - function duplicateAction() { - $id_catalogue=(int)$this->_getParam("id_catalogue"); - if (!$catalogue = Class_Catalogue::getLoader()->find($id_catalogue)) { + public function duplicateAction() { + if (!$catalogue = Class_Catalogue::find((int)$this->_getParam("id_catalogue"))) { $this->_redirect("admin/catalogue/index"); return; } - $new_catalogue = Class_Catalogue::getLoader() - ->newInstance() - ->setLibelle("** nouveau domaine **") - ->setParentId($this->_getParam('id_catalogue', null)) - ->setUser(Class_Users::getIdentity()); + $new_catalogue = $this->_newCatalogue(); if ($this->isSaved($new_catalogue)) { $this->_helper->notify($this->_('Domaine %s sauvegardé', $catalogue->getLibelle())); $this->_redirect("admin/catalogue/index"); return; } - $new_catalogue=$catalogue->copy(); + + $new_catalogue = $catalogue->copy(); $this->view->titre = $this->_('Duplication du domaine: %s', $catalogue->getLibelle()); - $this->view->catalogue=$new_catalogue; + $this->view->catalogue = $new_catalogue; $this->getHelper('ViewRenderer')->renderScript('catalogue/form.phtml'); } + protected function _newCatalogue() { + return Class_Catalogue::newInstance(['libelle' => '** nouveau domaine **', + 'parent_id' => $this->_getParam('id_catalogue', null), + 'user' => $this->_user]); + } + + public function isSaved($catalogue) { if (!$this->_request->isPost()) return false; + return $catalogue ->updatePostAttributes($this->_request->getPost()) ->save(); @@ -182,57 +174,59 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } - //---------------------------------------------------------------------------------- - // Suppression d'un catalogue - //---------------------------------------------------------------------------------- - function deleteAction() { - $id_catalogue=(int)$this->_getParam("id_catalogue"); - $user = Class_Users::getIdentity(); - if ($catalogue = Class_Catalogue::find($id_catalogue)) { + public function browsableDomainsAction() { + $this->_helper->viewRenderer->setNoRender(); + $data = []; + $data[] = (new Class_Catalogue())->getBrowsableDomainsJson(); + $JSON = json_encode($data); + + $this->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8'); + $this->getResponse()->setBody($JSON); + } + + + + public function deleteAction() { + if (($catalogue = Class_Catalogue::find((int)$this->_getParam('id_catalogue'))) + && $catalogue->canBeDeletedOrModifyByUser($this->_user)) { Class_NoticeDomain::deleteByDomain($catalogue); - $catalogue->deleteWithUser($user); + $catalogue->deleteWithUser($this->_user); } $this->_redirect("admin/catalogue/index"); } public function paniersAction() { - $id_catalogue=(int)$this->_getParam("id_catalogue"); - if(!$catalogue = Class_Catalogue::find($id_catalogue)) + if (!$catalogue = Class_Catalogue::find((int)$this->_getParam("id_catalogue"))) return $this->_redirect("admin/catalogue/index"); if ($this->_request->isPost()) { $panier = Class_PanierNotice::find($this->_request->getPost('id_panier')); - $catalogue - ->addPanierNotice($panier) - ->save(); + $catalogue->addPanierNotice($panier)->save(); $panier->addCatalogue($catalogue)->save(); $panier->index(); $this->_helper->notify($this->_('Panier "%s" ajouté', $panier->getLibelle())); - $this->_redirect('admin/catalogue/paniers/id_catalogue/'.$id_catalogue); + $this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId()); return; } if ($id_panier_to_remove = (int)$this->_getParam('remove')) { $panier = Class_PanierNotice::find($id_panier_to_remove); - $catalogue - ->removePanierNotice($panier) - ->save(); + $catalogue->removePanierNotice($panier)->save(); $panier->removeCatalogue($catalogue)->save(); $this->_helper->notify($this->_('Panier "%s" retiré', $panier->getLibelle())); - $this->_redirect('admin/catalogue/paniers/id_catalogue/'.$id_catalogue); + $this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId()); return; } - $this->view->form_paniers = $this->formAjoutPanier($catalogue); $this->view->catalogue = $catalogue; $this->view->titre = $this->_('Paniers du domaine: %s', $catalogue->getLibelle()); } - public function formAjoutPanier($catalogue) { + protected function formAjoutPanier($catalogue) { $options = []; $paniers = Class_PanierNotice::findAllBelongsToAdmin(); foreach($paniers as $panier) @@ -247,11 +241,11 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } - function domainesPaniersJsonAction() { + public function domainesPaniersJsonAction() { $this->_helper->viewRenderer->setNoRender(); $data = []; - $data[] = Class_Users::getIdentity()->getPaniersJson(); + $data[] = $this->_user->getPaniersJson(); $data[] = (new Class_Catalogue())->getDomainesJson(); $data[] = (new Class_PanierNotice())->getPaniersAdminsNotInCatalogueJson(); $JSON = json_encode($data); diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index c9af8887c1157b0528f578ce40f46eacbab19a66..4dd0ffdc261b059725b80a7c527c4a408f0a8901 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -64,108 +64,42 @@ class Admin_CmsController extends ZendAfi_Controller_Action { protected function _renderList() { - $this->view->titre = $this->view->_('Mise à jour des articles'); - $bibs = $this->_getBibs(); - $ids = array_map(function($model) {return $model->getId();}, $bibs); - - $url_params = ['module' => 'admin', - 'controller' => 'cms', - 'action' => 'index']; - - $root_label = $this->identity->isRoleLibraryLimited() ? - $this->_bib->getLibelle() : $this->_('Racine'); - $breadcrumb = [$this->view->tag('a', $root_label, - ['href' => $this->view->url($url_params, - null, true)])]; - - $this->view->bibActions = $this->_getBibActions(); - $this->view->categorieActions = $this->_getTreeViewContainerActions(); - $this->view->articleActions = $this->_getTreeViewItemActions(); - - $cms_permissions = Class_Permission::getCmsPermissions(); - $categories_filter = function($category) use ($cms_permissions){ - return $this->identity->hasAnyPermissionUnder($category, $cms_permissions) - || $this->identity->hasAnyPermissionOn($category, $cms_permissions); - }; - - if (($id_cat = $this->_getParam('id_cat')) - && ($category = Class_ArticleCategorie::find($id_cat)) - && ($current_bib = $category->getBib() ? - $category->getBib() : Class_Bib::getPortail()) - && in_array($current_bib->getId(), $ids)) { - $this->view->categories = array_filter($category->getChildren(), - $categories_filter); - - if (!$this->identity->isRoleLibraryLimited()) - $breadcrumb[] = $this->view->tag('a', $current_bib->getLibelle(), - ['href' => $this->view->url(array_merge($url_params, ['id_bib' => $current_bib->getId()]), - null, true)]); - - $render_cats = function ($model) use (&$breadcrumb, $url_params, $category) { - $options = ['href' => $this->view->url(array_merge($url_params, ['id_cat' => $model->getId()]), - null, true)]; - if ($model->getId() == $category->getId()) - $options['style'] = 'font-weight:bolder'; - - $breadcrumb[] = $this->view->tag('a', $model->getLibelle(), $options); - }; - - $parents_and_self = $category->getParentsAndSelf(); - array_walk($parents_and_self, $render_cats); - $this->view->breadcrumb = implode(' > ', $breadcrumb) - . ' ' . $this->view->modelActions($category, $this->view->categorieActions, true); - - $items_by_page = 25; - $page = $this->_getParam('page', 0); - $this->view->art_paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null(Class_Article::countBy(['id_cat' => $category->getId()]))); - $this->view->art_paginator->setItemCountPerPage($items_by_page); - $this->view->art_paginator->setCurrentPageNumber($page); - $this->view->art_paginator->setView($this->view); - - $this->view->articles = Class_Article::findAllBy(['id_cat' => $category->getId(), - 'order' => 'titre', - 'limitPage' => [$page, $items_by_page]]); - - return; + $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() + : null); + $id_cat = $this->_getParam('id_cat', 0); + + $params = ['page' => $this->_getParam('page', 0), + 'search_value' => $search, + 'bib' => $this->_bib, + 'id_bib' => $id_bib, + 'id_cat' => $id_cat]; + + if (($id_bib && in_array($id_bib, $ids)) || $id_cat || ($id_bib == '0') || ($search)) { + $params['model'] = Class_ArticleCategorie::find($id_cat); + $this->view->list = $this->_helper->articleListViewMode($params); + + return $this->renderScript('admin/listViewMode.phtml'); } - if (null !== ($id_bib = $this->_getParam('id_bib')) - && in_array($id_bib, $ids)) { - $current_bib = Class_Bib::find($id_bib); + $params['model'] = null; + $params['bibs'] = $bibs; + $this->view->list = $this->_helper->bibListViewMode($params); - $breadcrumb[] = $this->view->tag('a', $current_bib->getLibelle(), - ['href' => $this->view->url(array_merge($url_params, ['id_bib' => $current_bib->getId()]), - null, true)]); - - $this->view->categories = array_filter($current_bib->getArticleCategories(), - $categories_filter); - $this->view->breadcrumb = implode(' > ', $breadcrumb) - . ' ' . $this->view->modelActions($current_bib, $this->view->bibActions, true); - return; - } - - if (1 < count($bibs)) { - $this->view->bibs = $bibs; - return; - } - - if (0 == count($bibs)) - return; - - $this->view->categories = array_filter($bibs[0]->getArticleCategories(), - $categories_filter); - $this->view->breadcrumb = implode(' > ', $breadcrumb) - . ' ' . $this->view->modelActions($bibs[0], $this->view->bibActions, true) ; + return $this->renderScript('admin/listViewMode.phtml'); } public function indexAction() { - if (Class_AdminVar::isArticlesListMode()) { - $this->_renderList(); - $this->getHelper('ViewRenderer')->setScriptAction('list'); - return; - } + $this->view->titre = $this->view->_('Articles'); + + if (Class_AdminVar::isArticlesListMode()) + return $this->_renderList(); $bibs = $this->_getBibs(); @@ -544,147 +478,18 @@ class Admin_CmsController extends ZendAfi_Controller_Action { } - /** - * @return array - */ private function _getTreeViewContainerActions() { - $parent_permission = function($model) { - return $this->identity - ->hasParentPermissionOn(Class_Permission::createArticleCategory(), - $model); - }; - - $actions[] = ['url' => $this->_getUrlForCategoryActionAndIdName('edit'), - 'icon' => 'ico/edit.gif', - 'label' => 'Modifier', - 'condition' => $parent_permission]; - - $actions[] = [ - 'url' => $this->_getUrlForCategoryActionAndIdName('delete'), - 'icon' => 'ico/del.gif', - 'label' => 'Supprimer', - 'condition' => function($model) use ($parent_permission) { - return $parent_permission($model) && $model->hasNoChild(); - }, - 'anchorOptions' => [ - 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]; - - - $actions[] = [ - 'url' => $this->_getUrlForActionAndIdName('add', 'id_cat'), - 'icon' => 'ico/add_news.gif', - 'label' => 'Ajouter un article', - 'condition' => function($model) { - return $this->identity - ->hasAnyPermissionOn($model, - [Class_Permission::createArticle(), - Class_Permission::createArticleCategory()]); - }]; - - $actions[] = [ - 'url' => $this->_getUrlForCategoryActionAndIdName('add'), - 'icon' => 'ico/add_cat.gif', - 'label' => 'Ajouter une sous-catégorie', - 'condition' => function($model) { - return $this->identity - ->hasPermissionOn(Class_Permission::createArticleCategory(), - $model); - }]; - return $actions; + return (new ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories($this->view, 'article'))->getActions(); } private function _getTreeViewItemActions() { - $permission_closure = function($model) { - return $this->identity - ->hasAnyPermissionOn($model->getCategorie(), - [Class_Permission::createArticle(), - Class_Permission::createArticleCategory()]); - }; - - $actions[] = [ - 'url' => $this->_getUrlForActionAndIdName('makeinvisible'), - 'icon' => 'ico/show.gif', - 'label' => 'Rendre cet article invisible', - 'condition' => function($model) use ($permission_closure) { - return $permission_closure($model) && $model->isVisible(); - }]; - - $actions[] = [ - 'url' => $this->_getUrlForActionAndIdName('makevisible'), - 'icon' => 'ico/hide.gif', - 'label' => 'Rendre cet article visible', - 'condition' => function($model) use ($permission_closure) { - return $permission_closure($model) && $model->isNotVisible(); - }]; - - $actions[] = ['url' => $this->_getUrlForActionAndIdName('edit'), - 'icon' => 'ico/edit.gif', - 'label' => 'Modifier', - 'condition' => $permission_closure]; - - $actions[] = ['url' => $this->_getUrlForActionAndIdName('newsduplicate'), - 'icon' => 'ico/copier.gif', - 'label' => 'Dupliquer', - 'condition' => $permission_closure]; - - $actions[] = ['url' => $this->_getUrlForActionAndIdName('delete'), - 'icon' => 'ico/del.gif', - 'label' => 'Supprimer', - 'condition' => $permission_closure]; - - return $actions; + return (new ZendAfi_View_Helper_ModelActionsTable_Article($this->view, 'article'))->getActions(); } private function _getBibActions() { - $actions = []; - $actions[] = [ - 'url' => $this->_getUrlForCategoryActionAndIdName('add', 'id_bib'), - 'icon' => 'ico/add_cat.gif', - 'label' => $this->_('Ajouter une catégorie'), - 'condition' => function($model) { - return $this->identity->isRoleMoreThanModoPortail() - || $this->identity->hasPermissionOn(Class_Permission::createArticleCategory(), - $model); - }]; - - $permissions_link = $this->view->url(['module' => 'admin', - 'controller' => 'bib', - 'action' => 'permissions'], - null, true) - . ($page = $this->_getParam('page') ? '/page/' . $page : '') - . '/id/%s'; - - $actions[] = [ - 'url' => $permissions_link, - 'icon' => 'picto/groupes_16.png', - 'label' => $this->_('Permissions par défaut'), - 'condition' => function($model) { - return $this->identity->isRoleMoreThanModoPortail(); - }]; - - return $actions; - } - - - protected function _getUrlForActionAndIdName($action, $idName = 'id') { - return $this->view->url(['module' => 'admin', - 'controller'=> 'cms', - 'action' => $action], - null, true) - . (($page = $this->_getParam('page')) ? '/page/' . $page : '') - . '/' . $idName . '/%s'; - } - - - protected function _getUrlForCategoryActionAndIdName($action, $idName = 'id') { - return $this->view->url(['module' => 'admin', - 'controller'=> 'cms-category', - 'action' => $action], - null, true) - . (($page = $this->_getParam('page')) ? '/page/' . $page : '') - . '/' . $idName . '/%s'; + return (new ZendAfi_View_Helper_ModelActionsTable_Bib($this->view, 'bib'))->getActions(); } @@ -739,9 +544,9 @@ class Admin_CmsController extends ZendAfi_Controller_Action { if (!Class_AdminVar::isArticlesListMode()) return 'admin/cms/index' . (!$model->isNew() ? '/id/' . $model->getId() : ''); - return sprintf('admin/cms/index/id_cat/%d%s', - ($cat = $model->getCategorie()) ? $cat->getId() : 0, - ($page = $this->_getParam('page')) ? '/page/'.$page : ''); + return $this->view->absoluteUrl(['module' => 'admin', + 'controller' => 'cms', + 'action' => 'index']); } @@ -781,8 +586,13 @@ class Admin_CmsController extends ZendAfi_Controller_Action { protected function _getEditUrl($model) { - return parent::_getEditUrl($model) - . (($page = $this->_getParam('page')) ? '/page/'.$page : ''); + $this->getRequest()->setParamSources(['_GET']); + $url = parent::_getEditUrl($model) + . (($page = $this->_getParam('page')) ? '/page/'.$page : '') + . (($id_cat = $this->_getParam('id_cat')) ? '/id_cat/'.$id_cat : '') + . (($title_search = $this->_getParam('title_search')) ? '/title_search/' . $title_search : ''); + $this->getRequest()->setParamSources(['_GET', '_POST']); + return $url; } } diff --git a/application/modules/admin/controllers/HarvestController.php b/application/modules/admin/controllers/HarvestController.php index 7273444348f369fc439c960eb554f1ea7409de5c..6ac70c7c0dd61558506f708b75705f4f06b24a64 100644 --- a/application/modules/admin/controllers/HarvestController.php +++ b/application/modules/admin/controllers/HarvestController.php @@ -24,7 +24,12 @@ class Admin_HarvestController extends Zend_Controller_Action { public function preDispatch() { $action = $this->_request->getActionName(); - if (in_array($action, ['arte-vod-browse', 'arte-vod-ajax', 'orphea-browse', 'orphea-ajax'])) + if (in_array($action, ['arte-vod-browse', + 'arte-vod-ajax', + 'jamendo-browse', + 'jamendo-ajax', + 'orphea-browse', + 'orphea-ajax'])) return; $services = $this->getServices(); @@ -63,7 +68,8 @@ class Admin_HarvestController extends Zend_Controller_Action { 'numilog' => new Class_WebService_BibNumerique_Numilog(), 'cyberlibris' => new Class_WebService_BibNumerique_Cyberlibris(), 'numerique-premium' => new Class_WebService_BibNumerique_NumeriquePremium(), - 'orphea' => new Class_WebService_BibNumerique_Orphea()]; + 'orphea' => new Class_WebService_BibNumerique_Orphea(), + 'jamendo' => new Class_WebService_BibNumerique_Jamendo()]; } @@ -88,6 +94,7 @@ class Admin_HarvestController extends Zend_Controller_Action { */ public function arteVodBrowseAction() { $this->view->titre = $this->view->_('Moissonnage ArteVOD'); + $this->view->harvest_url = $this->view->url(['action' => 'arte-vod-ajax']); } @@ -107,6 +114,52 @@ class Admin_HarvestController extends Zend_Controller_Action { } $this->view->titre = $this->view->_('Moissonnage Orphea'); + $this->view->harvest_url = $this->view->url(['action' => 'orphea-ajax']); + } + + + public function jamendoBrowseAction() { + $jamendo = new Class_WebService_BibNumerique_Jamendo(); + if (!$jamendo->isEnabled()) { + $this->_redirect('/admin/index'); + } + + + $import_form = $this->view + ->newForm(['id' => 'import', 'class' => 'form']) + ->setMethod('post') + ->addElement('url', 'url', ['label' => $this->view->_('URL de la page Jamendo'), + 'required' => true, + 'allowEmpty' => false]) + ->addDisplayGroup(['url'], 'album', ['legend' => $this->view->_('Album')]) + ->addElement('submit', 'submit', ['label' => $this->view->_('Importer')]); + + if ($this->getRequest()->isPost() && $import_form->isValid($this->getRequest()->getPost())) { + if ($album = $jamendo->importFromUrl($this->getRequest()->getPost('url'))) { + $this->_helper->notify($this->view->_('Album "%s" importé de Jamendo', + $album->getTitre())); + $this->_redirect('/admin/album/edit_album/id/'.$album->getId()); + return; + } + + $import_form->getElement('url') + ->addDecorator('Errors') + ->addError('URL invalide'); + } + + $this->view->titre = $this->view->_('Moissonnage Jamendo'); + $this->view->harvest_url = $this->view->url(['action' => 'jamendo-ajax']); + $this->view->import_form = $import_form; + } + + + public function jamendoAjaxAction() { + $this->_helper->viewRenderer->setNoRender(); + if (!Class_AdminVar::isJamendoEnabled()) + return; + + $service = new Class_WebService_BibNumerique_Jamendo(); + echo json_encode($service->harvestPage($this->_getParam('page', 1))); } diff --git a/application/modules/admin/controllers/I18nController.php b/application/modules/admin/controllers/I18nController.php index 08c4c4b58f17f4e80953ebc4e0215ffb55750996..13619ff4c66db717000e048ae7fc6d8c46be2238 100644 --- a/application/modules/admin/controllers/I18nController.php +++ b/application/modules/admin/controllers/I18nController.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 Admin_I18nController extends Zend_Controller_Action { /** @@ -45,7 +45,7 @@ class Admin_I18nController extends Zend_Controller_Action { asort($master, SORT_STRING); // et les traduction pour chaque langue configurée - $translated = array(); + $translated = []; foreach(Class_AdminVar::getLanguesWithoutDefault() as $langue) { $translated[$langue] = $this->_i18n->read($langue); @@ -79,7 +79,7 @@ class Admin_I18nController extends Zend_Controller_Action { (string)$this->_getParam('field'), (string)$this->_getParam('value')); - $this->_helper->json(array('succes' => true)); + $this->_helper->json(['succes' => true]); } @@ -87,10 +87,8 @@ class Admin_I18nController extends Zend_Controller_Action { * @return Zend_Form */ private function _getForm(array $master, array $languages) { - $form = new Zend_Form(array( - 'id' => 'i18nForm', - 'method' => Zend_Form::METHOD_POST - )); + $form = new ZendAfi_Form(['id' => 'i18nForm', + 'method' => Zend_Form::METHOD_POST]); foreach ($languages as $langue => $v) { // séparation en 2 sections pour classement diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php index 9b28602567a65d30c15d7ffb41506dd4ec463a51..eef41d8fd3694b9dcd5fc1f106b49272c667f421 100644 --- a/application/modules/admin/controllers/IndexController.php +++ b/application/modules/admin/controllers/IndexController.php @@ -39,12 +39,6 @@ class Admin_IndexController extends ZendAfi_Controller_Action { $this->view->href_site="true"; } - $status_babelio = Class_WebService_Babelio::getActivationStatus(); - $this->view->status_babelio = $status_babelio['enabled'] ? 'Activé' : 'Désactivé'; - if (null !== $expiration_date = $status_babelio['expire_at']) - $this->view->status_babelio .= ', expiration le '.$expiration_date->toString("d MMMM yyyy"); - $this->view->show_babelio_info = !$status_babelio['enabled'] || $expiration_date !== null; - $this->view->user = Class_Users::getLoader()->getIdentity(); } diff --git a/application/modules/admin/controllers/ModulesController.php b/application/modules/admin/controllers/ModulesController.php index 716f2b6077d814f1d6b47f87a6159bc53184c00b..2fea3532a77070e4b5844fd995462007b3443c67 100644 --- a/application/modules/admin/controllers/ModulesController.php +++ b/application/modules/admin/controllers/ModulesController.php @@ -128,18 +128,6 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { return $this->_simpleAction('formulaire_contact'); } - public function catalogueAction() { - $this->view->titre = 'Domaines'; - if ($this->_request->isPost()) { - $ret = $this->getPostListe(); - if ('ok' == $ret) - return $this->updateEtRetour($this->_request->getPost()); - $this->retourErreur($ret); - } - - $this->render->renderScript('modules/recherche_resultat.phtml'); - } - public function rechercheAction() { if ('resultat' == $this->_getParam('action1')) @@ -220,33 +208,6 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { } - protected function getPostListe() { - $liste_nb_par_page = (int)$liste_nb_par_page; - $facettes_nombre = (int)$facettes_nombre; - $tags_nombre = (int)$tags_nombre; - - if ($liste_nb_par_page < 3 or $liste_nb_par_page > 50) - return "Le nombre de notices par page doit être compris entre 3 et 50"; - - if(!trim($liste_codes)) - return "Indiquez au moins 1 champ à afficher pour la liste"; - - if($facettes_actif == 1 and $facettes_nombre < 2 or $facettes_nombre > 10) - return "Le nombre de facettes doit être compris entre 2 et 10"; - - if($facettes_actif == 1 and !trim($facettes_codes)) - return "Indiquez au moins 1 facette à afficher"; - - if($tags_actif == 1 and $tags_nombre < 5 or $tags_nombre > 1000) - return "Le nombre de tags doit être compris entre 5 et 1000"; - - if($tags_actif == 1 and !trim($tags_codes)) - return "Indiquez au moins 1 type de tag à afficher"; - - return 'ok'; - } - - public function noticeajaxAction() { $this->view->type_doc = $this->action2; $this->noticeConsolidationOnglets(); diff --git a/application/modules/admin/controllers/MultimediaController.php b/application/modules/admin/controllers/MultimediaController.php index 3767d71b141a2ab5293d1ac21bd5885983c3a0c2..9f1760669a09edf952bd3efda8bfa3aa7c31d13e 100644 --- a/application/modules/admin/controllers/MultimediaController.php +++ b/application/modules/admin/controllers/MultimediaController.php @@ -39,10 +39,7 @@ class Admin_MultimediaController extends ZendAfi_Controller_Action { 'elements' => $this->getConfigFields()], 'config_auto' => ['legend' => 'Réservation automatique', - 'elements' => $this->getConfigAutoFields()], - - 'config_auto_closing_days' => ['legend' => 'Réservation les jours de fermetures', - 'elements' => $this->getConfigClosingDaysFields()] + 'elements' => $this->getConfigAutoFields()] ] ]; } @@ -131,29 +128,6 @@ disponible', } - public function getConfigClosingDaysFields() { - $hours_select = Class_Multimedia_Location::getPossibleHours(30); - - - $fields['autohold_for_closing_days'] = ['element' => 'checkbox', - 'options' => ['label' => 'Autoriser les réservations automatique pour les jours de fermeture -disponible', - 'title' => 'Permet de définir des jours d\'utilisation des postes sans possibilités de réservation de bokeh', - 'required' => true, - 'allowEmpty' => false]]; - - - $field_labels = ['open_hour' => $this->view->_('Heure d\'ouverture'), - 'close_hour' => $this->view->_('Heure de fermeture')]; - - foreach ($field_labels as $field => $label) - $fields[$field] = ['element' => 'select', 'options' => ['label' => $label, - 'multiOptions' => $hours_select]]; - - return $fields; - } - - public function browseAction() { if (!$location = Class_Multimedia_Location::find((int)$this->_getParam('id'))) { $this->_redirect('/admin/multimedia'); diff --git a/application/modules/admin/controllers/OuverturesController.php b/application/modules/admin/controllers/OuverturesController.php index 4f222939aadda5ecbbbc8abbe4dd8e081041a31d..304f30ae668f0b78fe9b3f774856203c92b35638 100644 --- a/application/modules/admin/controllers/OuverturesController.php +++ b/application/modules/admin/controllers/OuverturesController.php @@ -81,7 +81,7 @@ class Admin_OuverturesController extends ZendAfi_Controller_Action { } parent::indexAction(); - $this->formatTitreWithLibelleBib('%s: plages d\'ouverture'); + $this->formatTitreWithLibelleBib('%s: plages ouvertes à la réservation des postes multimédia'); } diff --git a/application/modules/admin/controllers/ZoneController.php b/application/modules/admin/controllers/ZoneController.php index cba055c472eac28e2ca15897a9fd2f2b52d4dc0d..d2c88d13a6dbbbbf7050cdb9576cbfe4c3000c10 100644 --- a/application/modules/admin/controllers/ZoneController.php +++ b/application/modules/admin/controllers/ZoneController.php @@ -16,9 +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 Admin_ZoneController extends Zend_Controller_Action +class Admin_ZoneController extends ZendAfi_Controller_Action { //--------------------------------------------------------------------- @@ -33,11 +33,11 @@ class Admin_ZoneController extends Zend_Controller_Action protected function _checkPost($zone) { $this->view->zone = $zone; - if (!$this->_request->isPost()) + if (!$this->_request->isPost()) return; if ($zone->updateAttributes($_POST)->save()) - $this->_redirect('admin/zone/index'); + $this->_redirect('admin/zone/index'); } //--------------------------------------------------------------------- @@ -78,47 +78,35 @@ class Admin_ZoneController extends Zend_Controller_Action //--------------------------------------------------------------------- // placer les bibliotheques sur la carte //--------------------------------------------------------------------- - function placerbibsAction() - { - $this->view->titre = 'Placement des bibliothèques sur la carte'; - $id_zone=$this->_request->getParam("id_zone"); + function placerbibsAction() { + $this->view->titre = $this->view->_('Placement des bibliothèques sur la carte'); + + if(!$zone = Class_Zone::find($this->_request->getParam('id_zone'))) + return $this->_redirect('admin/zone/index'); + + if(!$bibs = $zone->getVisibleBibs()) + return $this->_redirect('admin/zone/index'); - $bibs = fetchAll("select * from bib_c_site where ID_ZONE=$id_zone and VISIBILITE > 0"); - // Validation - if ($this->_request->isPost()) - { - $i = 0; - foreach($bibs as $bib) - { - // Positions des bibs - $id_bib=$bib['ID_SITE']; - $data = array(); - $data["libelle"]=$_POST["libelle_".$i]; - $data["posX"]=$_POST["posX_".$i]; - $data["posY"]=$_POST["posY_".$i]; - $data["posPoint"]=$_POST["posPoint_".$i]; - $data["profilID"]=$_POST["profilID_".$i]; - $props=addslashes(ZendAfi_Filters_Serialize::serialize($data)); - sqlExecute("update bib_c_site set AFF_ZONE='$props' where ID_SITE=$id_bib"); - - // Proprietes du label - $couleur_texte=$_POST["couleur_texte"]; - $couleur_ombre=$_POST["couleur_ombre"]; - $taille_fonte=$_POST["taille_fonte"]; - sqlExecute("update bib_c_zone set COULEUR_TEXTE='$couleur_texte', COULEUR_OMBRE='$couleur_ombre', TAILLE_FONTE='$taille_fonte' where ID_ZONE=$id_zone"); - $i++; + if ($this->_request->isPost()) { + foreach($bibs as $bib) { + $bib_id = $bib->getId(); + $data = ['posX' => $this->_request->getParam('posX_' . $bib_id, 0), + 'posY' => $this->_request->getParam('posY_' . $bib_id, 0), + 'posPoint' => $this->_request->getParam('posPoint_' . $bib_id), + 'profilID' => $this->_request->getParam('profilID_' . $bib_id, 0)]; + + $aff_zone = ZendAfi_Filters_Serialize::serialize($data); + $bib->setAffZone($aff_zone)->save(); } - $this->_redirect('admin/zone/index'); + + $zone->setCouleurTexte($this->_request->getParam('couleur_texte')) + ->setCouleurOmbre($this->_request->getParam('couleur_ombre')) + ->setTailleFonte($this->_request->getParam('taille_fonte')) + ->save(); } - // Entree formulaire - $this->view->zone= Class_Zone::getLoader()->find($id_zone); - if(!$this->view->zone->COULEUR_TEXTE) $this->view->zone->COULEUR_TEXTE="#ffffff"; - if(!$this->view->zone->COULEUR_OMBRE) $this->view->zone->COULEUR_OMBRE="#000000"; - if(!$this->view->zone->TAILLE_FONTE) $this->view->zone->TAILLE_FONTE="12"; - - // Caracteristiques de l'image - $this->view->image=$this->view->zone->getImageZone($this->view->zone->IMAGE,true); - $this->view->bibs=$bibs; + $this->view->zone = $zone; + $this->view->image= $this->view->zone->getImageZone($zone->getImage(), true); + $this->view->bibs = $bibs; } } \ No newline at end of file diff --git a/application/modules/admin/views/scripts/accueil/critiques.phtml b/application/modules/admin/views/scripts/accueil/critiques.phtml index d4b3afb519f04455c09f11db5abb076a14115b30..589027200b9f1a67e59e92cd1cff7f5caeb1c544 100644 --- a/application/modules/admin/views/scripts/accueil/critiques.phtml +++ b/application/modules/admin/views/scripts/accueil/critiques.phtml @@ -1,74 +1,109 @@ +<?php +Class_ScriptLoader::getInstance() +->addJQueryReady(' +function toggleHierarchical() { + if ($("#hierarchical").is(":checked")) { + $(".non-hierarchical").hide(); + $("#only_img").parents("tr").hide(); + $("#id_panier").parents("tr").hide(); + return; + } + + $(".non-hierarchical").show(); + $("#only_img").parents("tr").show(); + $("#id_panier").parents("tr").show(); +} + + +$("#hierarchical").change(toggleHierarchical); +toggleHierarchical(); +'); +?> <center> - <h1>Propriétés du module : Dernières critiques</h1><br> + <h1>Propriétés du module : Critiques</h1><br> <div class="formTable"> - <form method="post" action="<?php echo $this->url ?>"> - + <form method="post" action="<?php echo $this->url; ?>"> + <fieldset> - <legend>Affichage</legend> - <table cellspacing="2"> - <tr> - <td class="droite">Titre du bloc </td> - <td class="gauche"><input type="text" name="titre" size="50" maxlength="60" value="<?php print($this->preferences["titre"]); ?>"></td> - </tr> - - <tr> - <td class="droite">Style de boite </td> - <td class="gauche"><?php echo $this->combo_templates ?></td> - </tr> - - </table> + <legend>Affichage</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Titre du bloc </td> + <td class="gauche"><input type="text" name="titre" size="50" maxlength="60" value="<?php print($this->preferences['titre']); ?>"></td> + </tr> + + <tr> + <td class="droite">Style de boite </td> + <td class="gauche"><?php echo $this->combo_templates; ?></td> + </tr> + <tr> + <td class="droite">Proposer un fil Rss </td> + <td class="gauche"> + <?php echo $this->formCheckbox('rss_avis', + $this->preferences['rss_avis'], + null, + ['1', '0']); ?> + </td> + </tr> + </table> </fieldset> <br> - + <fieldset> - <legend>Critiques</legend> - <table cellspacing="2"> - <tr> - <td class="droite">Origine des critiques </td> - <td class="gauche"> - <?php echo $this->formSelect("abon_ou_bib",$this->preferences["abon_ou_bib"],"",array("1" => "Bibliothécaire","0"=>"Abonné ou utilisateur du site","all" => "Tout le monde")) ?> - </td> - </tr> - <tr> - <td class="droite">Nombre à afficher </td> - <td class="gauche"><input type="text" name="nb_aff_avis" size="2" maxlength="2" value="<?php print($this->preferences["nb_aff_avis"]); ?>"></td> - </tr> - <tr> - <td class="droite">Ordre d'affichage </td> - <td class="gauche"> - <?php - echo $this->formRadioButtons("display_order", - $this->preferences["display_order"], - array( - "CreationDesc" => "Par date de création (plus récent en premier)", - "Random" => "Aléatoire")); - ?> - </td> - </tr> + <legend>Critiques</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Origine des critiques </td> + <td class="gauche"> + <?php echo $this->formSelect('abon_ou_bib', + $this->preferences['abon_ou_bib'], + '', + ['1' => 'Bibliothécaire', + '0' => 'Abonné ou utilisateur du site', + 'all' => 'Tout le monde']); ?> + </td> + </tr> - <tr> - <td class="droite">Couper les critiques à </td> - <td class="gauche"><input type="text" name="nb_words" size="3" maxlength="3" value="<?php print($this->preferences["nb_words"]); ?>">mots</td> - </tr> - <tr> - <td class="droite">Proposer un fil Rss </td> - <td class="gauche"> - <?php echo $this->formCheckbox('rss_avis', - $this->preferences['rss_avis'], - null, - array('1', '0')) ?> - </td> - </tr> - </table> + <tr> + <td class="droite">Navigation hiérarchique </td> + <td class="gauche"> + <?php echo $this->formCheckbox('hierarchical', + $this->preferences['hierarchical'], + null, + ['1', '0']); ?> + </td> + </tr> + + <tr class="non-hierarchical"> + <td class="droite">Nombre à afficher </td> + <td class="gauche"><input type="text" name="nb_aff_avis" size="2" maxlength="2" value="<?php print($this->preferences['nb_aff_avis']); ?>"></td> + </tr> + <tr class="non-hierarchical"> + <td class="droite">Ordre d'affichage </td> + <td class="gauche"> + <?php + echo $this->formRadioButtons('display_order', + $this->preferences['display_order'], + ['CreationDesc' => 'Par date de création (plus récent en premier)', + 'Random' => 'Aléatoire']); + ?> + </td> + </tr> + <tr> + <td class="droite">Couper les critiques à </td> + <td class="gauche"><input type="text" name="nb_words" size="3" maxlength="3" value="<?php print($this->preferences['nb_words']); ?>">mots</td> + </tr> + </table> </fieldset> - <?php - echo $this->partial("accueil/_options_catalogue_panier.phtml", - array('preferences' => $this->preferences, - 'catalogues' => $this->catalogues, - 'paniers' => $this->paniers)); + <?php + echo $this->partial('accueil/_options_catalogue_panier.phtml', + ['preferences' => $this->preferences, + 'catalogues' => $this->catalogues, + 'paniers' => $this->paniers]); ?> - - <?php echo $this->formSubmit("Valider","Valider",array("class" => "bouton")) ?> - </form> - </div> + + <?php echo $this->formSubmit('Valider', 'Valider', ['class' => 'bouton']); ?> + </form> + </div> +</center> diff --git a/application/modules/admin/views/scripts/accueil/rechsimple.phtml b/application/modules/admin/views/scripts/accueil/rechsimple.phtml index 41d379eae41026b300b3dfb537e079849aebde13..ec10c982c0c63cbf1eccde2d3028e91a27752417 100644 --- a/application/modules/admin/views/scripts/accueil/rechsimple.phtml +++ b/application/modules/admin/views/scripts/accueil/rechsimple.phtml @@ -2,11 +2,11 @@ <h1>Propriétés de la boîte de recherche simple</h1><br> <div class="formTable"> <form method="post" action="<?php echo $this->url ?>"> - + <fieldset> <legend>Affichage</legend> <table cellspacing="2"> - + <tr> <td class="droite">Style de boite </td> <td class="gauche"><?php echo $this->combo_templates ?></td> @@ -16,20 +16,20 @@ <td class="droite">Largeur du champ de saisie </td> <td class="gauche"><?php echo $this->tagSlider("largeur",$this->preferences["largeur"],100,300,1) ?></td> </tr> - + </table> </fieldset> <br> - + <fieldset> <legend>Généralités</legend> <table cellspacing="2"> - + <tr> <td class="droite">Titre </td> <td class="gauche"><input type="text" name="titre" size="55" value="<?php print($this->preferences["titre"]); ?>"></td> </tr> - + <tr> <td class="droite">Proposer la sélection de bibliothèques </td> <td class="gauche"><?php echo $this->formSelect("select_bib",$this->preferences["select_bib"],"",array("1" => "oui","0"=>"non")) ?></td> @@ -50,11 +50,16 @@ <td class="gauche"><?php echo $this->formSelect("select_doc",$this->preferences["select_doc"],"",array("1" => "oui","0"=>"non")) ?></td> </tr> + <tr> + <td class="droite">Message du bouton pour rechercher </td> + <td class="gauche"><input type="text" name="search_button" size="55" value="<?php print($this->preferences["search_button"]); ?>"></td> + </tr> + <tr> <td class="droite">Message au-dessus du champ de saisie </td> <td class="gauche"><input type="text" name="message" size="55" value="<?php print($this->preferences["message"]); ?>"></td> </tr> - + <tr> <td class="droite">Message d'exemple dans le champ de saisie </td> <td class="gauche"><input type="text" name="placeholder" size="55" value="<?php print($this->preferences["placeholder"]); ?>"></td> @@ -75,14 +80,14 @@ array('on', 'off')); ?> </td> </tr> - + <tr> <td class="droite">Tri du résultat de recherche </td> <td class="gauche"> - <?php echo $this->formSelect('tri', - $this->preferences['tri'], - '', + <?php echo $this->formSelect('tri', + $this->preferences['tri'], + '', (new Class_CriteresRecherche())->getListeTris()); ?> </td> </tr> @@ -91,7 +96,7 @@ <tr> <td class="droite">Basculer automatiquement sur le profil: </td> <td class="gauche"> - <?php + <?php echo $this->ComboProfils('ALL', 'ALL', $this->preferences['profil_redirect']); ?> </td> @@ -111,7 +116,7 @@ </table> </fieldset> - + <?php echo $this->formSubmit("Valider","Valider",array("class" => "bouton")) ?> </form> </div> diff --git a/application/modules/admin/views/scripts/accueil/sitotheque.phtml b/application/modules/admin/views/scripts/accueil/sitotheque.phtml index 6f3e6e4b36ce42286b67e6be95d80d2b42fa3771..d4a711ec1d21e3728fffd7cba0a6f41dca7bd29b 100644 --- a/application/modules/admin/views/scripts/accueil/sitotheque.phtml +++ b/application/modules/admin/views/scripts/accueil/sitotheque.phtml @@ -1,102 +1,111 @@ -<center> -<h1>Propriétés du module sitothèque</h1><br> -<div class="formTable"> - <form method="post" action="<?php echo $this->url ?>"> - - <fieldset> - <legend>Affichage</legend> - <table cellspacing="2"> - - <tr> - <td class="droite">Style de boite </td> - <td class="gauche"><?php echo $this->combo_templates ?></td> - </tr> - - </table> - </fieldset> - <br> - - <fieldset> - <legend>Généralités</legend> - <table cellspacing="2"> - <tr> - <td class="droite">Titre </td> - <td class="gauche"><input type="text" name="titre" size="50" value="<?php print($this->preferences["titre"]); ?>"></td> - </tr> - </table> - </fieldset> - <br> - - <fieldset> - <legend>Sites à afficher</legend> - <table cellspacing="2" width="100%"> - <tr> - <td class="droite" width="90px">Type </td> - <td class="gauche"> - <?php - $onchange="$('.treeselect').treeselect('toggleVisibility', (this.value == '1'));"; - echo $this->formSelect("type_aff", - $this->preferences["type_aff"], - array("onchange" => $onchange), - array("1" => "Une sélection de catégories ou de sites", - "2" => "Les sites les plus récents")) - ?> - </td> - </tr> - </table> - - <div id="table_selection"> - <?php - echo $this->treeSelect( - $this->preferences["id_items"], - $this->preferences["id_categorie"], - ($this->preferences["type_aff"] == "1"), - BASE_URL.'/admin/bib/allitems?id_bib='.$this->id_bib.'&type=sito', - "form"); - ?> - </div> - - <table cellspacing="2" width="100%"> - - - <tr id='option_display_order'> - <td class="droite" width="90px">Ordre d'affichage </td> - <td class="gauche"> - <?php - echo $this->formRadio("display_order", - $this->preferences["display_order"], - [], - ['Random' => $this->_('Par ordre aléatoire'), - 'Selection' => $this->_('Par ordre de sélection')]); - ?> - </td> - </tr> - - - <tr id='option_nb_aff'> - <td class="droite" width="90px">Nbre à afficher </td> - <td class="gauche"><input type="text" name="nb_aff" size="3" maxlength="3" value="<?php print($this->preferences["nb_aff"]); ?>"></td> - </tr> - - <tr> - <td class="droite" width="90px">Grouper par catégorie </td> - <td class="gauche"> - <?php - echo $this->formCheckbox('group_by_categorie', - null, - array('checked' => $this->preferences["group_by_categorie"])); - ?> - </td> - </tr> - </table> - - </fieldset> - <br /> - - <?php echo $this->formSubmit("Valider","Valider",array("class" => "bouton")) ?> - </form> - - <script type="text/javascript"> - formSelectToggleVisibilityForElement("input[name=display_order]", "#option_nb_aff", "Random"); - </script> - </div> +<?php +Class_ScriptLoader::getInstance() +->addJQueryReady(' +function toggleDisplayTypeDependents() { + var dependents = $(".group_cat, #option_display_order, #option_nb_aff"); + ("3" == $("#type_aff").val()) ? dependents.hide() : dependents.show(); +} + +$("#type_aff").change(function () { + toggleDisplayTypeDependents(); + var value = $("#type_aff").val(); + $(".treeselect").treeselect("toggleVisibility", (value == "1" || value == "3")); +}); + +toggleDisplayTypeDependents(); +formSelectToggleVisibilityForElement("input[name=display_order]", "#option_nb_aff", "Random"); +'); +?> +<center> + <h1>Propriétés du module sitothèque</h1><br> + <div class="formTable"> + <form method="post" action="<?php echo $this->url; ?>"> + + <fieldset> + <legend>Affichage</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Style de boite </td> + <td class="gauche"><?php echo $this->combo_templates; ?></td> + </tr> + </table> + </fieldset> + <br> + + <fieldset> + <legend>Généralités</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Titre </td> + <td class="gauche"><input type="text" name="titre" size="50" value="<?php print($this->preferences['titre']); ?>"></td> + </tr> + </table> + </fieldset> + <br> + + <fieldset> + <legend>Sites à afficher</legend> + <table cellspacing="2" width="100%"> + <tr> + <td class="droite" width="90px">Type </td> + <td class="gauche"> + <?php + echo $this->formSelect('type_aff', + $this->preferences['type_aff'], + [], + ['1' => 'Une sélection de catégories ou de sites', + '2' => 'Les sites les plus récents', + '3' => 'Affichage hiérarchique par catégorie']) + ?> + </td> + </tr> + </table> + + <div id="table_selection"> + <?php + echo $this->treeSelect($this->preferences['id_items'], + $this->preferences['id_categorie'], + ($this->preferences['type_aff'] != '2'), + BASE_URL . '/admin/bib/allitems?id_bib=' . $this->id_bib . '&type=sito', + "form"); + ?> + </div> + + <table cellspacing="2" width="100%"> + <tr id='option_display_order'> + <td class="droite" width="90px">Ordre d'affichage </td> + <td class="gauche"> + <?php + echo $this->formRadio('display_order', + $this->preferences['display_order'], + [], + ['Random' => $this->_('Par ordre aléatoire'), + 'Selection' => $this->_('Par ordre de sélection')]); + ?> + </td> + </tr> + + <tr id='option_nb_aff'> + <td class="droite" width="90px">Nbre à afficher </td> + <td class="gauche"><input type="text" name="nb_aff" size="3" maxlength="3" value="<?php print($this->preferences['nb_aff']); ?>"></td> + </tr> + + <tr class="group_cat"> + <td class="droite" width="90px">Grouper par catégorie </td> + <td class="gauche"> + <?php + echo $this->formCheckbox('group_by_categorie', + null, + ['checked' => $this->preferences['group_by_categorie']]); + ?> + </td> + </tr> + </table> + + </fieldset> + <br /> + + <?php echo $this->formSubmit('Valider', 'Valider', ['class' => 'bouton']); ?> + </form> + </div> +</center> diff --git a/application/modules/admin/views/scripts/admin/listViewMode.phtml b/application/modules/admin/views/scripts/admin/listViewMode.phtml new file mode 100644 index 0000000000000000000000000000000000000000..57fa33f3c0f222cfd6208af52c2011e5c1d84a3d --- /dev/null +++ b/application/modules/admin/views/scripts/admin/listViewMode.phtml @@ -0,0 +1,3 @@ +<?php +echo $this->admin_ListViewMode($this->list); +?> diff --git a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml index 2d569ecd6ad53f78c483148ea744b38174aed7fc..5a4ba6d8060b8fe4f909dbee28a9be780538bf93 100644 --- a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml +++ b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml @@ -1,52 +1,54 @@ -<li class="<?php echo $this->item_class ?>"> - - <div><?php echo $this->catalogue->getLibelle() ?></div> +<?php +$catalog = $this->catalogue; +$user = Class_Users::getIdentity(); +$editable = $catalog->canBeDeletedOrModifyByUser($user); +?> +<li class="<?php echo $this->item_class; ?>"> + <div><?php echo $this->escape($catalog->getLibelle()); ?></div> <div class="commentaire"></div> <div class="actions"> - <?php - - $actions = [ ['action' => 'tester', 'icon' => 'ico/tester.gif', 'help' => 'Tester'] ]; - - if (Class_Users::getIdentity()->isRoleMoreThanModoBib()) { - $actions = array_merge($actions, [ - ['action' => 'edit', 'icon' => 'ico/edit.gif', 'help' => 'Editer'], - ['action' => 'duplicate', 'icon' => 'ico/copier.gif', 'help' => 'Dupliquer'], - ['action' => 'add', 'icon' => 'ico/add_news.gif', 'help' => 'Ajouter un sous-domaine'], - ['action' => 'paniers', 'icon' => 'picto/paniers_16.png', 'help' => 'Paniers']]); - } + <?php + $actions = [ + ['action' => 'tester', 'icon' => 'ico/tester.gif', 'help' => 'Tester'], + ['action' => 'edit', 'icon' => 'ico/edit.gif', 'help' => 'Editer', 'display' => $editable], + ['action' => 'duplicate', 'icon' => 'ico/copier.gif', 'help' => 'Dupliquer'], + ['action' => 'add', 'icon' => 'ico/add_news.gif', 'help' => 'Ajouter un sous-domaine', 'display' => $editable], + ['action' => 'paniers', 'icon' => 'picto/paniers_16.png', 'help' => 'Paniers', 'display' => $editable] + ]; foreach ($actions as $action) { - echo $this->tagAnchor($this->url(array('action' => $action['action'], - 'id_catalogue' => $this->catalogue->getId())), - '<img src="'.URL_ADMIN_IMG.$action['icon'].'" alt="'.$action['help'].'" title="'.$action['help'].'" />'); + if (isset($action['display']) && !$action['display']) + continue; + + echo $this->tagAnchor($this->url(['action' => $action['action'], + 'id_catalogue' => $catalog->getId()]), + $this->tag('img', null, + ['src' => URL_ADMIN_IMG . $action['icon'], + 'alt' => $action['help'], + 'title' => $action['help']])); } - if ($this->catalogue->canBeDeletedOrModifyByUser(Class_Users::getIdentity())) { - echo '<a href="'.BASE_URL.'/admin/catalogue/delete/id_catalogue/'.$this->catalogue->getId(). '">'. - $this->boutonIco("type=del"). - '</a>'; - } + if ($editable) + echo $this->tag('a', $this->boutonIco('type=del'), + ['href' => BASE_URL . '/admin/catalogue/delete/id_catalogue/'.$catalog->getId()]); - $catalogue_url = $this->absoluteUrl(['module' => 'opac', + $catalogue_url = $this->absoluteUrl(['module' => 'opac', 'controller' => 'recherche', 'action' => 'simple', - 'id_catalogue' => $this->catalogue->getId()], - null, - true); - echo $this->tagPreview($catalogue_url, 'Visualisation du catalogue: '.$this->catalogue->getLibelle()); - echo $this->permalink($catalogue_url); + 'id_catalogue' => $catalog->getId()], + null, true); + + echo $this->tagPreview($catalogue_url, 'Visualisation du catalogue: '.$catalog->getLibelle()); + echo $this->permalink($catalogue_url); ?> </div> - - - <ul> - <?php - echo $this->partialCycle('catalogue/_catalogue_row.phtml', + <?php + echo $this->partialCycle('catalogue/_catalogue_row.phtml', 'catalogue', - $this->catalogue->getSousDomaines(), - array('first', 'second')); + $catalog->getSousDomaines(), + ['first', 'second']); ?> </ul> </li> diff --git a/application/modules/admin/views/scripts/catalogue/form.phtml b/application/modules/admin/views/scripts/catalogue/form.phtml index da0085dba05a29f55cadc699c5ec4187d50427df..716de21dddeb344ce124de44ff40366260d7ec95 100644 --- a/application/modules/admin/views/scripts/catalogue/form.phtml +++ b/application/modules/admin/views/scripts/catalogue/form.phtml @@ -1,7 +1,4 @@ - <?php Class_ScriptLoader::getInstance()->addAdminScript('controle_maj'); ?> - - <center> <div class="form" align="center" > <form name="form" method="post" action="<?php echo $this->url(); ?>"> @@ -23,7 +20,7 @@ <tr> <td align="right"><?php echo $this->traduire('Image'); ?></td> <td class="gauche" style="padding-left:5px"> - <?php + <?php echo $this->coreFiveFileInput('url_img', $this->catalogue->getUrlImg(), 'image'); ?> </td> @@ -31,7 +28,12 @@ <tr> <td class="droite" style="width:150px;"><?php echo $this->traduire('Domaine parent'); ?></td> - <td class="gauche"><?php echo $this->comboCatalogue($this->catalogue) ?></td> + <td class="gauche"> + <?php + $display_closure = function($catalog) { + return $catalog->canBeDeletedOrModifyByUser(Class_Users::getIdentity()); + }; + echo $this->comboCatalogue($this->catalogue, $display_closure); ?></td> </tr> <tr> @@ -45,7 +47,6 @@ (int)$this->catalogue->getIndexer(), null, [1, 0]); ?></td> - </tr> </table> </fieldset> @@ -58,34 +59,34 @@ <td class="droite" style="width:150px;"><?php echo $this->traduire('OAI spec'); ?></td> <td class="gauche"><input type="text" name="oai_spec" value="<?php echo $this->catalogue->getOaiSpec()?>" maxlength="50" size="50" onchange="setFlagMaj(true)"></td> </tr> - </table> + </table> </fieldset> <?php } ?> <fieldset> <legend><?php echo $this->traduire('Critères généraux'); ?> </legend> <table border="0" cellpadding="5" cellspacing="0"> - + <tr> <td class="droite" valign="top" style="width:180px;"><?php echo $this->traduire('Types de documents'); ?></td> <td class="gauche"><?php echo $this->TagListeCoches("type_doc","type_doc",$this->catalogue->getTypeDoc()); ?></td> </tr> - + <tr> <td class="droite" valign="top"><?php echo $this->traduire('Genres'); ?></td> <td class="gauche"><?php echo $this->TagListeCoches("genre","genre",$this->catalogue->getGenre()); ?></td> </tr> - + <tr> <td class="droite" valign="top"><?php echo $this->traduire('Langues'); ?></td> <td class="gauche"><?php echo $this->TagListeCoches("langue","langue",$this->catalogue->getLangue()); ?></td> </tr> - + <tr> <td class="droite"><?php echo $this->traduire('Année de parution - depuis'); ?></td> <td class="gauche"><input type="text" name="annee_debut" size="4" maxlength="4" value="<?php echo $this->catalogue->getAnneeDebut()?>"> (sur 4 chiffres)</td> </tr> - + <tr> <td class="droite"><?php echo $this->traduire('jusqu\'à '); ?></td> <td class="gauche"><input type="text" name="annee_fin" size="4" maxlength="4" value="<?php echo $this->catalogue->getAnneeFin()?>"> (sur 4 chiffres)</td> @@ -107,7 +108,7 @@ null, array(1, 0)); ?></td> </tr> - + </table> </fieldset> @@ -154,18 +155,18 @@ <td class="droite" valign="top" style="width:130px"><?php echo $this->traduire('Matières / sujets'); ?></td> <td class="gauche"><?php echo $this->TagListeSuggestion("matiere","matiere",$this->catalogue->getMatiere()); ?></td> </tr> - + <tr> <td class="droite" valign="top"><?php echo $this->traduire('Indices Dewey'); ?></td> <td class="gauche"><?php echo $this->TagListeSuggestion("dewey","dewey",$this->catalogue->getDewey()); ?></td> </tr> - + <tr> <td class="droite" valign="top"><?php echo $this->traduire('Pcdm4'); ?></td> <td class="gauche"><?php echo $this->TagListeSuggestion("pcdm4","pcdm4",$this->catalogue->getPcdm4()); ?></td> </tr> - <?php + <?php $thesauri = Class_CodifThesaurus::getIndices('root'); foreach ($thesauri as $thesaurus) { ?> <tr> @@ -178,25 +179,25 @@ <td class="droite" valign="top"><?php echo $this->traduire("Centres d'intérêt"); ?></td> <td class="gauche"><?php echo $this->TagListeSuggestion("interet","interet",$this->catalogue->getInteret()); ?></td> </tr> - + <tr> <td class="droite" valign="top"><?php echo $this->traduire('Tags utilisateur'); ?></td> <td class="gauche"><?php echo $this->TagListeSuggestion("tag","tags",$this->catalogue->getTags()); ?></td> </tr> - + </table> </fieldset> - + <table> <tr> <td align="right" style="padding-right:5px;"> <?php if ($this->catalogue->canBeDeletedOrModifyByUser(Class_Users::getIdentity())) { - echo $this->bouton('type=V',"javascript=;setFlagMaj(false);"); + echo $this->bouton('type=V',"javascript=;setFlagMaj(false);"); } ?> </td> - <td align="left" style="padding-left:5px;"> - <?php + <td align="left" style="padding-left:5px;"> + <?php echo $this->boutonRetour(['module' => 'admin', 'controller' => 'catalogue']) ?> diff --git a/application/modules/admin/views/scripts/catalogue/index.phtml b/application/modules/admin/views/scripts/catalogue/index.phtml index 0b8e861dbdaf3bb90f27debb6c6d18260eb12ebe..62566a8aae9c57de4afa1eced30a02277b9d2ca0 100644 --- a/application/modules/admin/views/scripts/catalogue/index.phtml +++ b/application/modules/admin/views/scripts/catalogue/index.phtml @@ -1,28 +1,32 @@ -<?php -if (Class_Users::getIdentity()->isAdmin()) - echo ('<center><div align="center"><br>'.$this->bouton('id=c_19','picto=add.gif','texte='.$this->traduire('Ajouter un domaine').'','url='.BASE_URL.'/admin/catalogue/add','largeur=220px').'</div></center>'); -?> - -<div class="catalogues"> - - <ul class="tree"> - - <?php - echo $this->partialCycle('catalogue/_catalogue_row.phtml', - 'catalogue', - $this->catalogues, - array('first', 'second')); - ?> - </ul> - <div class="clear"></div> -</div> - -<p align="center" class="error"><?php echo $this->message ?></p> - -<?php -if (Class_AdminVar::isOaiServerEnabled()) { - echo '<h3>'.$this->_('Serveur OAI').'</h3>'; - echo sprintf('<div>Base URL: <input class="permalink" value="%s" readonly="true" size="100"/></div>', - Class_WebService_OAI::baseURL()); -} -?> +<?php if (Class_Users::getIdentity()->hasRightAccessDomaines()) { ?> + <center> + <div align="center"><br> + <?php echo $this->bouton('id=c_19', + 'picto=add.gif', + 'texte=' . $this->_('Ajouter un domaine'), + 'url=' . BASE_URL . '/admin/catalogue/add', + 'largeur=220px');?> + </div> + </center> +<?php } ?> + +<div class="catalogues"> + <ul class="tree"> + <?php + echo $this->partialCycle('catalogue/_catalogue_row.phtml', + 'catalogue', + $this->catalogues, + ['first', 'second']);?> + </ul> + <div class="clear"></div> +</div> + +<p align="center" class="error"><?php echo $this->message; ?></p> + +<?php if (Class_AdminVar::isOaiServerEnabled()) { ?> + <h3><?php echo $this->_('Serveur OAI');?></h3> + <div>Base URL: <input class="permalink" + value="<?php echo Class_WebService_OAI::baseURL(); ?>" + readonly="true" + size="100" /></div> +<?php } ?> diff --git a/application/modules/admin/views/scripts/cms/list.phtml b/application/modules/admin/views/scripts/cms/list.phtml deleted file mode 100644 index edd38afb5960fa175b200385d33b8f109cb5aa31..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/cms/list.phtml +++ /dev/null @@ -1,78 +0,0 @@ -<?php -echo $this->tag('div', $this->breadcrumb, - ['style' => 'font-size:140%;']); - -if ($this->bibs) { - $label = function($model, $attrib) { - return $this->tag('a', - $this->tagImg(URL_ADMIN_IMG . 'ico/cat.gif') - . $model->$attrib, - ['href' => $this->url(['module' => 'admin', - 'controller' => 'cms', - 'action' => 'index', - 'id_bib' => $model->getId()], - null, true)]); - }; - - echo $this->tagModelTable( - $this->bibs, - [$this->_('Localisation')], - ['libelle'], - [function($model) { - return $this->modelActions($model, $this->bibActions); - }], - 'cms-categories', - null, - ['libelle' => $label]); - - return; -} - - -$label = function($model, $attrib) { - $sub_categories = $model->getRecursiveSousCategories(); - $ids = array_map(function($item) {return $item->getId();}, $sub_categories); - $ids[] = $model->getId(); - - return $this->tag('a', - $this->tagImg(URL_ADMIN_IMG . 'ico/cat.gif') - . $model->$attrib - . ' (' . Class_Article::countBy(['id_cat' => $ids]) . ')', - ['href' => $this->url(['module' => 'admin', - 'controller' => 'cms', - 'action' => 'index', - 'id_cat' => $model->getId()], - null, true)]); -}; - - -echo $this->tagModelTable( - $this->categories, - [$this->_('Catégories')], - ['libelle'], - [function($model) { - return $this->modelActions($model, $this->categorieActions); - }], - 'cms-categories', - null, - ['libelle' => $label]); - - - -$label = function($model, $attrib) { - return $this->tagImg(URL_ADMIN_IMG . 'picto/article.png') . ' ' . $model->getTitre(); -}; - -if ($this->articles) { - echo $this->tagModelTable( - $this->articles, - [$this->_('Articles')], - ['libelle'], - [function($model) { - return $this->modelActions($model, $this->articleActions); - }], - 'cms-articles', - null, - ['libelle' => $label]); - echo $this->paginationControl($this->art_paginator); -} diff --git a/application/modules/admin/views/scripts/harvest/_harvest_progress.phtml b/application/modules/admin/views/scripts/harvest/_harvest_progress.phtml new file mode 100644 index 0000000000000000000000000000000000000000..313cac6d59d3104344467b60f3a9855b56f22f38 --- /dev/null +++ b/application/modules/admin/views/scripts/harvest/_harvest_progress.phtml @@ -0,0 +1,48 @@ +<form id="source_harvest"> + <input type="submit" value="<?php echo $this->_('Lancer le moissonnage');?>"> +</form> + +<div id="harvest_progress" style="display:none"> + <div id="progress_message"><?php echo $this->_('Moissonnage en cours');?></div> + <div id="progress_bar"></div> +</div> + +<script type="text/javascript"> +var source_harvest = function(page_number) { + var harvest_url = '<?php echo $this->harvest_url; ?>'; + var params = {page: page_number}; + $.getJSON(harvest_url, params, function(data) { + if (data == null) { + $('#progress_message').text('Aucune donnée retournée'); + $('#progress_bar').progressbar({value:100}); + return; + } + + if (data['error'] != null) { + $('#progress_message').text('Erreur : ' + data['error']); + $('#progress_bar').progressbar({value:100}); + return; + } + + if (!data['has_next']) { + $('#progress_message').text('Catalogue importé'); + $('#progress_bar').progressbar({value:100}); + return; + } + + $('#progress_message').text(data['total_count'] + ' notices au total. Page ' + + data['current_page'] + '/' + data['page_count']); + $('#progress_bar').progressbar({value:(data['current_page'] * 100) / data['page_count']}); + source_harvest(page_number+1); + }); +} + + +$(document).ready(function(){ + $('#source_harvest').submit(function() { + $('#harvest_progress').children().andSelf().show(); + source_harvest(1); + return false; + }); +}); +</script> diff --git a/application/modules/admin/views/scripts/harvest/arte-vod-browse.phtml b/application/modules/admin/views/scripts/harvest/arte-vod-browse.phtml index 97c964cd945fac531308b3ac580d4c3d5c1069f0..71a7cf371dd3f5183dce427ec611451f9ed2e3cc 100644 --- a/application/modules/admin/views/scripts/harvest/arte-vod-browse.phtml +++ b/application/modules/admin/views/scripts/harvest/arte-vod-browse.phtml @@ -1,48 +1,4 @@ -<form id="artevod_harvest"> - <input type="submit" value="<?php echo $this->_('Lancer le moissonnage');?>"> -</form> - -<div id="harvest_progress" style="display:none"> - <div id="progress_message"><?php echo $this->_('Moissonnage en cours');?></div> - <div id="progress_bar"></div> -</div> - -<script type="text/javascript"> -var artevod_harvest = function(page_number) { - var harvest_url = '<?php echo BASE_URL . '/admin/harvest/arte-vod-ajax'; ?>'; - var params = {page: page_number}; - $.getJSON(harvest_url, params, function(data) { - if (data == null) { - $('#progress_message').text('Aucune donnée retournée'); - $('#progress_bar').progressbar({value:100}); - return; - } - - if (data['error'] != null) { - $('#progress_message').text('Erreur : ' + data['error']); - $('#progress_bar').progressbar({value:100}); - return; - } - - if (!data['has_next']) { - $('#progress_message').text('Catalogue importé'); - $('#progress_bar').progressbar({value:100}); - return; - } - - $('#progress_message').text(data['total_count'] + ' notices au total. Page ' - + data['current_page'] + '/' + data['page_count']); - $('#progress_bar').progressbar({value:(data['current_page'] * 100) / data['page_count']}); - artevod_harvest(page_number+1); - }); -} - - -$(document).ready(function(){ - $('#artevod_harvest').submit(function() { - $('#harvest_progress').children().andSelf().show(); - artevod_harvest(1); - return false; - }); -}); -</script> +<?php +echo $this->partial('harvest/_harvest_progress.phtml', + ['harvest_url' => $this->harvest_url]); +?> diff --git a/application/modules/admin/views/scripts/harvest/jamendo-browse.phtml b/application/modules/admin/views/scripts/harvest/jamendo-browse.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ee035c78cc205d0327a11bddb1a5f56d7b674dfb --- /dev/null +++ b/application/modules/admin/views/scripts/harvest/jamendo-browse.phtml @@ -0,0 +1,6 @@ +<?php echo $this->partial('harvest/_harvest_progress.phtml', + ['harvest_url' => $this->harvest_url]); ?> + +<h2><?php echo $this->_('Importer un album depuis la page Jamendo'); ?></h2> + +<?php echo $this->renderForm($this->import_form); ?> diff --git a/application/modules/admin/views/scripts/harvest/orphea-browse.phtml b/application/modules/admin/views/scripts/harvest/orphea-browse.phtml index 4e3aa377093e9c15c6c0bc1c89333cb0fa20071c..d42e853cdbc6154883cb577fb8ea2f5c61945664 100644 --- a/application/modules/admin/views/scripts/harvest/orphea-browse.phtml +++ b/application/modules/admin/views/scripts/harvest/orphea-browse.phtml @@ -1,4 +1,4 @@ -<form id="artevod_harvest"> +<form id="source_harvest"> <input type="submit" value="<?php echo $this->_('Lancer le moissonnage');?>"> </form> @@ -30,7 +30,7 @@ var orphea_harvest = function(unid = null, page_number = 1, total_pages = null) return; } - $('#progress_message').text(data['total_count'] + ' notices au total. Page ' + $('#progress_message').text(data['total_count'] + ' notices au total. Page ' + data['current_page']); $('#progress_bar').progressbar({value:(data['current_page'] * 100) / data['total_pages']}); orphea_harvest(data['unid'], page_number+1, data['total_pages']); @@ -39,7 +39,7 @@ var orphea_harvest = function(unid = null, page_number = 1, total_pages = null) $(document).ready(function(){ - $('#artevod_harvest').submit(function() { + $('#source_harvest').submit(function() { $('#harvest_progress').children().andSelf().show(); orphea_harvest(null, 1); return false; diff --git a/application/modules/admin/views/scripts/index/index.phtml b/application/modules/admin/views/scripts/index/index.phtml index c58f16c81d4357da55b72f08de6478071531ee3c..54dce4c6ee2326122eadd5827c6e7e90f27ab7e4 100644 --- a/application/modules/admin/views/scripts/index/index.phtml +++ b/application/modules/admin/views/scripts/index/index.phtml @@ -18,13 +18,9 @@ if ($this->user->isAdmin()) { echo $this->ligneInfos("Etat du site", $this->etat_site . $lien) . $this->ligneInfos("Profil", $profil->getLibelle() . $lien_edit_site) - . $this->ligneInfos("Thème", $profil->getSkin()) - . $this->ligneInfos("Avis Babelio", $this->status_babelio); + . $this->ligneInfos("Thème", $profil->getSkin()); -if ($this->show_babelio_info) { ?> - <div class='ligne_info'>Le service <a href='http://www.babelio.com/'>Babelio</a> est gratuit pour une durée de -90 jours à compter de l'ouverture du portail. Veuillez contacter AFI pour souscrire à un abonnement.</div> -<?php } ?> +?> <h2><?php echo $this->traduire('Accès');?> :</h2> <?php diff --git a/application/modules/admin/views/scripts/modo/index.phtml b/application/modules/admin/views/scripts/modo/index.phtml index 7e2aa1378c20b779999c506d575193beab0e89f7..a6aa72151ffe0f3b981efd7de143e2656fcb4114 100644 --- a/application/modules/admin/views/scripts/modo/index.phtml +++ b/application/modules/admin/views/scripts/modo/index.phtml @@ -18,14 +18,14 @@ $menus = [["icon" => "article.png", "label" => "Suggestions d'achat", "url" => $this->url(['action' => 'suggestion-achat']), "count" => $modstats['suggestions_achat']['count']] - + ]; if (isset($modstats['formulaires'])) { - $menus[] = + $menus[] = ["icon" => "formulaires_16.png", "label" => "Formulaires", - "url" => $this->url(['action' => 'formulaires']), + "url" => $this->url(['action' => 'formulaires', 'id_article' => null]), "count" => $modstats['formulaires']['count']] ;} ?> @@ -34,4 +34,3 @@ if (isset($modstats['formulaires'])) { <?php if ($this->subview) { ?> <div class="subview"><?php echo $this->subview;?><div class="clear"></div></div> <?php } ?> - diff --git a/application/modules/admin/views/scripts/modules/auth_form.phtml b/application/modules/admin/views/scripts/modules/auth_form.phtml index 409e5a6fcdf99b59af1104c0304c14633149de5d..07f600227fed530176af9cacf880a188f6c1a0a6 100644 --- a/application/modules/admin/views/scripts/modules/auth_form.phtml +++ b/application/modules/admin/views/scripts/modules/auth_form.phtml @@ -37,10 +37,10 @@ <tr> <td class="droite">Désactiver l'auto-complétion </td> <td class="gauche"> - <?php - echo $this->formCheckbox('autocomplete_off', + <?php + echo $this->formCheckbox('autocomplete_off', (int)$this->preferences["autocomplete_off"], - null, + null, [1, 0]); ?> </td> @@ -72,9 +72,9 @@ </tr> <tr> - <td class="droite">Basculer automatiquement sur le profil: </td> + <td class="droite"><label>Basculer automatiquement sur le profil: </label></td> <td class="gauche"> - <?php + <?php $this->getHelper('ComboProfils') ->setTagId('profil_redirect') ->setTagName('profil_redirect') diff --git a/application/modules/admin/views/scripts/profil/_formProfil.phtml b/application/modules/admin/views/scripts/profil/_formProfil.phtml index 662c4a84522a164c076b5823b68cf78948a371fb..21bb1db1c57f930bc8e6d2cd54d5e06bc0237eac 100644 --- a/application/modules/admin/views/scripts/profil/_formProfil.phtml +++ b/application/modules/admin/views/scripts/profil/_formProfil.phtml @@ -240,7 +240,13 @@ echo $this->partial('profil/_profil_panel.phtml', <td align="right" style="width:25%"><?php echo $this->traduire('Largeur totale du site'); ?></td> <td> <input type="text" name="largeur_site" size="4" maxlength="4" value="<?php print($this->profil->getLargeurSite()) ?>" style="width:40px"> - <span class="info" style="color:#575757"> pixels</span> + <span class="info" style="color:#575757"> + <select name="size_site_scale"> + <option value="px" <?php if ($this->profil->getSizeSiteScale() == "px") echo 'selected="selected"'; ?>>pixels</option> + <option value="percent" <?php if ($this->profil->getSizeSiteScale() == "percent") echo 'selected="selected"'; ?>>%</option> + </select> + + </span> </td> </tr> <tr class="only_browser"> @@ -279,21 +285,41 @@ echo $this->partial('profil/_profil_panel.phtml', </tr> <tr> <td align="right">Divison 1</td> - <td width="10px"><input type="text" class="normal" name="largeur_division1" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision1()?>"></td><td class="normal" width="10px">pixels </td> + <td width="10px"><input type="text" class="normal" name="largeur_division1" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision1()?>"></td><td class="normal" width="10px"> + <select name="width_division1_scale"> + <option value="px" <?php if ($this->profil->getWidthDivision1Scale() == "px") echo 'selected="selected"'; ?>>pixels</option> + <option value="percent" <?php if ($this->profil->getWidthDivision1Scale() == "percent") echo 'selected="selected"'; ?>>%</option> + </select> + </td> <td width="10px"><input type="text" class="normal" name="marge_division1" size="2" maxlength="2" value="<?php echo $this->profil->getMargeDivision1()?>"></td><td class="normal">pixels</td> <td> </td> </tr> <tr> <td align="right">Divison 2</td> - <td width="10px"><input type="text" class="normal" name="largeur_division2" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision2()?>"></td><td class="normal" width="10px">pixels </td> - <td width="10px"><input type="text" class="normal" name="marge_division2" size="2" maxlength="2" value="<?php echo $this->profil->getMargeDivision2()?>"></td><td class="normal">pixels</td> + <td width="10px"><input type="text" class="normal" name="largeur_division2" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision2()?>"></td><td class="normal" width="10px"> + + <select name="width_division2_scale"> + <option value="px" <?php if ($this->profil->getWidthDivision2Scale() == "px") echo 'selected="selected"'; ?>>pixels</option> + <option value="percent" <?php if ($this->profil->getWidthDivision2Scale() == "percent") echo 'selected="selected"'; ?>>%</option> + </select> + +</td> + <td width="10px"><input type="text" class="normal" name="marge_division2" size="2" maxlength="2" value="<?php echo $this->profil->getMargeDivision2()?>"></td><td class="normal"> +pixels </td> <td> </td> </tr> <tr> <td align="right">Divison 3</td> - <td width="10px"><input type="text" class="normal" name="largeur_division3" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision3()?>"></td><td class="normal" width="10px">pixels </td> + <td width="10px"><input type="text" class="normal" name="largeur_division3" size="4" maxlength="4" value="<?php echo $this->profil->getLargeurDivision3()?>"></td><td class="normal" width="10px"> + + <select name="width_division3_scale"> + <option value="px" <?php if ($this->profil->getWidthDivision3Scale() == "px") echo 'selected="selected"'; ?>>pixels</option> + <option value="percent" <?php if ($this->profil->getWidthDivision3Scale() == "percent") echo 'selected="selected"'; ?>>%</option> + </select> + +</td> <td width="10px"><input type="text" class="normal" name="marge_division3" size="2" maxlength="2" value="<?php echo $this->profil->getMargeDivision3()?>"></td><td class="normal">pixels</td> <td style="white-space:nowrap"> <?php echo $this->formCheckbox('division_three_always_visible', diff --git a/application/modules/admin/views/scripts/zone/placerbibs.phtml b/application/modules/admin/views/scripts/zone/placerbibs.phtml index d2b9ff513bbce6b60b192e660d40fb6b57db39ae..d9cd208a6da3ea52379a92f4ffd2e32948188a4f 100644 --- a/application/modules/admin/views/scripts/zone/placerbibs.phtml +++ b/application/modules/admin/views/scripts/zone/placerbibs.phtml @@ -4,114 +4,124 @@ <script type="text/javascript" src="<?php echo URL_ADMIN_JS?>color_picker/jquery.vreboton.ColorPicker.js"> </script> <script type="text/javascript"> -var current_index=0; -// Color picker - jQuery(function($) - { - $("#couleur_texte").attachColorPicker(); - $("#couleur_texte").change(function() { $('span').css('color',$('#couleur_texte').val()) }); - $("#couleur_ombre").attachColorPicker(); - $("#couleur_ombre").change(function() { $('span').css('text-shadow','1px 0px 5px ' + $('#couleur_ombre').val()) }); - }); - -// Change valeur proprietes - $(function() - { - $('#posPoint_aff').change(function() - { - $('#posPoint_'+current_index).attr('value',$(this).val()); - memoPos(current_index,parseInt($('#bib'+current_index).css('left')),parseInt($('#bib'+current_index).css('top'))); - }); - - $('#select_clef_profil').change(function() - { - $('#profilID_'+current_index).attr('value',$(this).val()); - }); - - $('#libelle_aff').keyup(function() - { - $('#libelle_'+current_index).attr('value',$(this).val()); - $('#bib'+current_index).text($(this).val()); - memoPos(current_index,parseInt($('#bib'+current_index).css('left')),parseInt($('#bib'+current_index).css('top'))); - }); - }); - -// Memo coordonnees - function memoPos(index,nX,nY) - { - // Memo des coordonnées - var posContainer=$('#image_container').offset(); - $('#posX_'+index).attr('value',parseInt(nX-posContainer.left)); - $('#posY_'+index).attr('value',parseInt(nY-posContainer.top)); - - // Positionnement du point - var oPoint=$('#point_'+index); - var hauteur_point=oPoint.outerHeight(true); - var largeur_point=oPoint.outerWidth(true); - var hauteur=$('#bib'+index).outerHeight(true); - var largeur=$('#bib'+index).outerWidth(true); - var position=$('#posPoint_'+index).val(); - - // if(position=="dessus") par défaut - pointY=nY-hauteur_point; - pointX=nX+(largeur/2)-(largeur_point/2); - - if(position=="dessous") - { - pointY=nY+hauteur; - pointX=nX+(largeur/2)-(largeur_point/2); - } - if(position=="droite") - { - pointY=nY+(hauteur/2)-(hauteur_point/2); - pointX=nX+largeur+2; - } - if(position=="gauche") - { - pointY=nY+(hauteur/2)-(hauteur_point/2); - pointX=nX-largeur_point-2; - } - oPoint.css('left',parseInt(pointX)+'px'); - oPoint.css('top',parseInt(pointY)+'px'); - } - - // Changement de la fonte - function changeFonte() - { - $('span').css('font-size',$('#taille_fonte').val()+'px'); - $('span').each(function (i) - { - memoPos(i,parseInt(this.style.left),parseInt(this.style.top)); - }); - } + var current_index=0; + // Color picker + jQuery(function($) + { + $("#couleur_texte").attachColorPicker(); + $("#couleur_texte").change(function() { $('span').css('color',$('#couleur_texte').val()) }); + $("#couleur_ombre").attachColorPicker(); + $("#couleur_ombre").change(function() { $('span').css('text-shadow','1px 0px 5px ' + $('#couleur_ombre').val()) }); + }); + + // Change valeur proprietes + $(function() + { + $('#posPoint_aff').change(function() + { + $('#posPoint_'+current_index).attr('value',$(this).val()); + memoPos(current_index,parseInt($('#bib'+current_index).css('left')),parseInt($('#bib'+current_index).css('top'))); + }); + + $('#select_clef_profil').change(function() + { + $('#profilID_'+current_index).attr('value',$(this).val()); + }); + + $('#libelle_aff').keyup(function() + { + $('#libelle_'+current_index).attr('value',$(this).val()); + $('#bib'+current_index).text($(this).val()); + memoPos(current_index,parseInt($('#bib'+current_index).css('left')),parseInt($('#bib'+current_index).css('top'))); + }); + }); + + // Memo coordonnees + function memoPos(index,nX,nY) + { + // Memo des coordonnées + var posContainer=$('#image_container').offset(); + $('#posX_'+index).attr('value',parseInt(nX-posContainer.left)); + $('#posY_'+index).attr('value',parseInt(nY-posContainer.top)); + + // Positionnement du point + var oPoint=$('#point_'+index); + var hauteur_point=oPoint.outerHeight(true); + var largeur_point=oPoint.outerWidth(true); + var hauteur=$('#bib'+index).outerHeight(true); + var largeur=$('#bib'+index).outerWidth(true); + var position=$('#posPoint_'+index).val(); + + // if(position=="dessus") par défaut + pointY=nY-hauteur_point; + pointX=nX+(largeur/2)-(largeur_point/2); + + if(position=="dessous") + { + pointY=nY+hauteur; + pointX=nX+(largeur/2)-(largeur_point/2); + } + if(position=="droite") + { + pointY=nY+(hauteur/2)-(hauteur_point/2); + pointX=nX+largeur+2; + } + if(position=="gauche") + { + pointY=nY+(hauteur/2)-(hauteur_point/2); + pointX=nX-largeur_point-2; + } + oPoint.css('left',parseInt(pointX)+'px'); + oPoint.css('top',parseInt(pointY)+'px'); + } + + // Changement de la fonte + function changeFonte() + { + $('span').css('font-size',$('#taille_fonte').val()+'px'); + $('span').each(function (i) + { + memoPos(i,parseInt(this.style.left),parseInt(this.style.top)); + }); + } </script> -<?php -echo '<h3>Territoire : '.$this->zone->LIBELLE.'</h3>'; +<?php +echo '<h3>Territoire : '.$this->zone->getLibelle.'</h3>'; echo '<div class="form" align="center">'; echo '<div id="image_container" style="width:'.$this->image[0].'px;height:'.$this->image[1].'px;background-image:url(\''.$this->image["url"].'\');" align="left">'; -if($this->bibs) -{ - $index=0; +if($this->bibs) { $hidden=''; - foreach($this->bibs as $bib) - { - // Proprietes - $props=ZendAfi_Filters_Serialize::unserialize($bib["AFF_ZONE"]); - if (!$libelle = $props["libelle"]) $libelle=$bib["VILLE"]; - if (!$posX = $props["posX"]) $posX=0; - if (!$posY = $props["posY"]) $posY=12*$index; - if (!$posPoint = $props["posPoint"]) $posPoint="gauche"; - if (!$profilID = $props["profilID"]) $profilID = 1; - if($index==0){$libelle_aff=$libelle; $posPoint_aff=$posPoint;$nomBib_aff=$bib["LIBELLE"];} + $default_position = 0; + foreach($this->bibs as $bib) { + $index = $bib->getId(); + + $props = ['libelle' => $bib->getVille(), + 'posX' => 0, + 'posY' => 0, + 'posPoint' => 'gauche', + 'profilID' => 0]; + + $unserialize = ($unserialize = ZendAfi_Filters_Serialize::unserialize($bib->getAffZone())) ? $unserialize : []; + + $props = array_merge($props, $unserialize); + + if (0 == $props["posY"]) + $posY = $default_position = 12 + $default_position; + + $libelle = $props['libelle']; + $posX = $props['posX']; + $posY = $props['posY']; + $posPoint = $props['posPoint']; + $profilID = $props['profilID']; // Champ draggable - echo'<span id="bib'.$index.'" style="position:absolute;cursor:pointer;font-family:Verdana;font-size:'.$this->zone->TAILLE_FONTE.'px;font-weight:bold;color:'.$this->zone->COULEUR_TEXTE.';white-space:nowrap;text-shadow: 1px 0px 5px '.$this->zone->COULEUR_OMBRE.'">'.$libelle.'</span>'; + echo'<span id="bib'.$index.'" style="position:absolute;cursor:pointer;font-family:Verdana;font-size:'.$this->zone->getTailleFonte().'px;font-weight:bold;color:'.$this->zone->getCouleurTexte().';white-space:nowrap;text-shadow: 1px 0px 5px '.$this->zone->getCouleurOmbre().'">'.$libelle.'</span>'; // Champs du post - $hidden.='<input id="idbib_'.$index.'" name="idbib_'.$index.'" type="hidden" value="'.$bib["ID_SITE"].'">'; - $hidden.='<input id="nomBib_'.$index.'" type="hidden" value="'.$bib["LIBELLE"].'">'; + $hidden.='<input id="idbib_'.$index.'" name="idbib_'.$index.'" type="hidden" value="'.$bib->getId().'">'; + $hidden.='<input id="nomBib_'.$index.'" type="hidden" value="'.$bib->getLibelle().'">'; $hidden.='<input id="posX_'.$index.'" name="posX_'.$index.'" type="hidden" value="'.$posX.'">'; $hidden.='<input id="posY_'.$index.'" name="posY_'.$index.'" type="hidden" value="'.$posY.'">'; $hidden.='<input id="libelle_'.$index.'" name="libelle_'.$index.'" type="hidden" value="'.$libelle.'">'; @@ -120,108 +130,112 @@ if($this->bibs) $hidden.='<img id="point_'.$index.'" src="'.URL_ADMIN_IMG.'picto/point_map.png" style="position:absolute;">'; // Javascript d'initialisation - ?> - <script> - $(function() - { - posContainer=$('#image_container').offset(); - posX=parseInt(<?php echo $posX ?>+posContainer.left); - posY=parseInt(<?php echo $posY ?>+posContainer.top); - memoPos(<?php echo $index ?>,posX,posY) - oObj=$('#bib<?php echo $index ?>'); - oObj.draggable - ({ - containment: 'parent', - drag: function(event, ui) - { memoPos(<?php echo $index ?>,ui.position.left,ui.position.top)} - }) - .css('left',posX+'px') - .css('top',posY+'px') - .mousedown(function() - { - $('#nomBib_aff').attr('value',$('#nomBib_<?php echo $index ?>').val()); - $('#libelle_aff').attr('value',$('#libelle_<?php echo $index ?>').val()); - - var valeur=$('#posPoint_<?php echo $index ?>').val(); - $('#posPoint_aff > option').attr('selected',''); - $('#posPoint_aff option[value='+valeur+']').attr('selected','selected'); - - var profil_id=$('#profilID_<?php echo $index ?>').val(); - $('#select_clef_profil option').attr('selected', ''); - $('#select_clef_profil option[value='+profil_id+']').attr('selected','selected'); - - current_index=<?php echo $index ?>; - }); - }); - - </script> - <?php - $index++; +?> + <script> + $(function() + { + posContainer=$('#image_container').offset(); + posX=parseInt(<?php echo $posX ?>+posContainer.left); + posY=parseInt(<?php echo $posY ?>+posContainer.top); + memoPos(<?php echo $index ?>,posX,posY) + oObj=$('#bib<?php echo $index ?>'); + oObj.draggable + ({ + containment: 'parent', + drag: function(event, ui) + { memoPos(<?php echo $index ?>,ui.position.left,ui.position.top)} + }) + .css('left',posX+'px') + .css('top',posY+'px') + .mousedown(function() + { + $('#nomBib_aff').attr('value',$('#nomBib_<?php echo $index ?>').val()); + $('#libelle_aff').attr('value',$('#libelle_<?php echo $index ?>').val()); + + var valeur=$('#posPoint_<?php echo $index ?>').val(); + $('#posPoint_aff > option').attr('selected',''); + $('#posPoint_aff option[value='+valeur+']').attr('selected','selected'); + + var profil_id=$('#profilID_<?php echo $index ?>').val(); + $('#select_clef_profil option').attr('selected', ''); + $('#select_clef_profil option[value='+profil_id+']').attr('selected','selected'); + + current_index=<?php echo $index ?>; + }); + }); + + </script> + <?php + $index++; } echo '</div>'; + + $nomBib_aff = ''; + $libelle_aff = ''; + $posPoint_aff = ''; ?> -<br /> -<form name="form" action="<?php echo BASE_URL ?>/admin/zone/placerbibs/id_zone/<?php echo $this->zone->ID_ZONE; ?>" method="post"> -<fieldset> - <legend>Propriétés</legend> - <table> - <tr> - <td class="droite" style="width:150px">Bibliothèque</td> - <td class="gauche"><input type="text" id="nomBib_aff" size="40" value="<?php echo $nomBib_aff ?>" readonly="readonly"></td> - </tr> - <tr> - <td class="droite">Libellé à afficher</td> - <td class="gauche"><input type="text" id="libelle_aff" size="40" value="<?php echo $libelle_aff ?>"></td> - </tr> - <tr> - <td class="droite">Position du point</td> - <td class="gauche"><?php echo $this->formSelect("posPoint_aff",$posPoint_aff,"",array("dessus" => "au dessus","gauche"=>"à gauche","droite"=>"à droite","dessous"=>"en dessous"))?></td> - </tr> - <tr> - <td class="droite">Lien vers la page</td> - <td class="gauche"><?php echo $this->comboProfils(); ?></td> - </tr> - - <tr> - <td colspan="2"><h3>Etiquettes</h3></td> - </tr> - - <tr> - <td class="droite">Taille de la police</td> - <td class="gauche"><?php echo $this->tagSlider("taille_fonte",$this->zone->TAILLE_FONTE,5,40,1,"changeFonte();") ?></td> - </tr> - - <tr> - <td class="droite">Couleur du texte</td> - <td class="gauche"><input type="text" id="couleur_texte" name="couleur_texte" size="8" value="<?php echo $this->zone->COULEUR_TEXTE;?>" /></td> - </tr> - - <tr> - <td class="droite">Couleur de l'ombre</td> - <td class="gauche"><input type="text" id="couleur_ombre" name="couleur_ombre" size="8" value="<?php echo $this->zone->COULEUR_OMBRE;?>" /></td> - </tr> - - </table> -</fieldset> - - <?php echo $hidden; ?> + <br /> + <form name="form" action="<?php echo BASE_URL ?>/admin/zone/placerbibs/id_zone/<?php echo $this->zone->getId(); ?>" method="post"> + <fieldset> + <legend>Propriétés</legend> + <table> + <tr> + <td class="droite" style="width:150px">Bibliothèque</td> + <td class="gauche"><input type="text" id="nomBib_aff" size="40" value="<?php echo $nomBib_aff ?>" readonly="readonly"></td> + </tr> + <tr> + <td class="droite">Libellé à afficher</td> + <td class="gauche"><input type="text" id="libelle_aff" size="40" value="<?php echo $libelle_aff ?>"></td> + </tr> + <tr> + <td class="droite">Position du point</td> + <td class="gauche"><?php echo $this->formSelect("posPoint_aff",$posPoint_aff,"",array("dessus" => "au dessus","gauche"=>"à gauche","droite"=>"à droite","dessous"=>"en dessous"))?></td> + </tr> + <tr> + <td class="droite">Lien vers la page</td> + <td class="gauche"><?php echo $this->comboProfils('ALL', 'ALL', 0, false, true); ?></td> + </tr> + + <tr> + <td colspan="2"><h3>Etiquettes</h3></td> + </tr> + + <tr> + <td class="droite">Taille de la police</td> + <td class="gauche"><?php echo $this->tagSlider("taille_fonte",$this->zone->TAILLE_FONTE,5,40,1,"changeFonte();") ?></td> + </tr> + + <tr> + <td class="droite">Couleur du texte</td> + <td class="gauche"><input type="text" id="couleur_texte" name="couleur_texte" size="8" value="<?php echo $this->zone->getCouleurTexte();?>" /></td> + </tr> + + <tr> + <td class="droite">Couleur de l'ombre</td> + <td class="gauche"><input type="text" id="couleur_ombre" name="couleur_ombre" size="8" value="<?php echo $this->zone->getCouleurOmbre();?>" /></td> + </tr> + + </table> + </fieldset> + + <?php echo $hidden; ?> <table> <tr> <td align="right" style="padding-right:5px;"><?php echo $this->bouton('type=V'); ?> </td> - <td align="left" style="padding-left:5px;"> <?php echo $this->bouton('id=29','picto=del.gif','texte=Annuler','url='.BASE_URL.'/admin/zone','largeur=120px'); ?></td> + <td align="left" style="padding-left:5px;"> <?php echo $this->bouton('id=29','picto=back.gif','texte=Retour','url='.BASE_URL.'/admin/zone','largeur=120px'); ?></td> </tr> </table> </form> <?php -} -else -{ + } + else + { + echo '</div>'; + echo BR.BR.'<p class="error">Il n\'y a aucune bibliothèque visible dans ce territoire.</p>'; + echo BR.'<div align="center">'.$this->bouton('id=29','picto=retour.gif','texte=Retour','url='.BASE_URL.'/admin/zone','largeur=120px').'</div>'.BR; + } echo '</div>'; - echo BR.BR.'<p class="error">Il n\'y a aucune bibliothèque visible dans ce territoire.</p>'; - echo BR.'<div align="center">'.$this->bouton('id=29','picto=retour.gif','texte=Retour','url='.BASE_URL.'/admin/zone','largeur=120px').'</div>'.BR; -} -echo '</div>'; -?> + ?> diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 1860dfdd57f9e27b3522571ed1da2a7115d010c5..9bb51f1571c8b555fd83f9022aef796e0364fa84 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -573,7 +573,6 @@ class AbonneController extends ZendAfi_Controller_Action { $response = new StdClass(); $response->auth = 0; - $response->until = ''; $request = Class_Multimedia_AuthenticateRequest::newWithRequest($this->_request); if ($user = $request->getUser()) { @@ -591,9 +590,13 @@ class AbonneController extends ZendAfi_Controller_Action { } $response->auth = 1; - $response->until = date('c', $request->getCurrentHoldEnd()); + $response->holding = $request->canHoldingForToDay(); + $response->holded = $request->isSuccessHolding(); + $response->until = ''; + if($response->holded) $response->until = date('c', $request->getCurrentHoldEnd()); $this->_response->setBody(json_encode($response)); + } @@ -618,6 +621,7 @@ class AbonneController extends ZendAfi_Controller_Action { /* Vérification du quota sur le jour choisi */ $day = $this->_getParam('day'); + $this->view->location = $bean->getLocation()->getLibelleBib(); $quotaErrorType = null; if (null != $day) { $quotaErrorType = $this->_user->getMultimediaQuotaErrorForDay($day); @@ -686,6 +690,7 @@ class AbonneController extends ZendAfi_Controller_Action { return result;'; $this->view->beforeShowDay = $beforeShowDay; + $this->view->location = $bean->getLocation()->getLibelleBib(); $this->view->timelineActions = $this->_getTimelineActions('day'); } @@ -719,6 +724,7 @@ class AbonneController extends ZendAfi_Controller_Action { $this->view->timelineActions = $this->_getTimelineActions('hours'); $this->view->form = $this->multimediaHoldHoursForm($bean, $location); + $this->view->day = strftime('%d %B %Y', strtotime($bean->day)); } @@ -741,6 +747,10 @@ class AbonneController extends ZendAfi_Controller_Action { $this->view->groups = $bean->getGroups(); $this->view->timelineActions = $this->_getTimelineActions('group'); + $this->view->location = $bean->getLocation()->getLibelleBib(); + $this->view->day = strftime('%d %B %Y', strtotime($bean->day)); + $this->view->time = str_replace(':', 'h', $bean->time); + $this->view->duration = $bean->duration . 'mn'; } @@ -752,6 +762,11 @@ class AbonneController extends ZendAfi_Controller_Action { $this->view->devices = $bean->getGroup()->getHoldableDevicesForDateTimeAndDuration($bean->day, $bean->time, $bean->duration); + $this->view->location = $bean->getLocation()->getLibelleBib(); + $this->view->day = strftime('%d %B %Y', strtotime($bean->day)); + $this->view->time = str_replace(':', 'h', $bean->time); + $this->view->duration = $bean->duration . 'mn'; + $this->view->group = $bean->getGroup()->getLibelle(); } @@ -913,7 +928,8 @@ class AbonneController extends ZendAfi_Controller_Action { $this->_helper->viewRenderer->setNoRender(); $datas = []; - foreach($this->_user->getEmprunts() as $emprunt) { + $emprunts = $this->_user->getLoansWithoutPNB(); + foreach($emprunts as $emprunt) { if (!$exemplaire = $emprunt->getExemplaireOPAC()) continue; @@ -928,5 +944,10 @@ class AbonneController extends ZendAfi_Controller_Action { $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"', true); $response->setBody(implode('', $datas)); } + + + public function endLoanBookAction() { + $this->_forward('end-loan-book', 'bib-numerique'); + } } ?> \ No newline at end of file diff --git a/application/modules/opac/controllers/BibNumeriqueController.php b/application/modules/opac/controllers/BibNumeriqueController.php index cc7e611071753fa6e31d4f1a8fccef485520912d..3b90ccbfaaee198464684bb08fc886a1a53e0a73 100644 --- a/application/modules/opac/controllers/BibNumeriqueController.php +++ b/application/modules/opac/controllers/BibNumeriqueController.php @@ -271,6 +271,38 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { $this->_redirect($content->link->url); } + + + public function loanBookAction() { + if(!$album = Class_Album::find($this->_getParam('id'))) + return $this->_redirectToReferer(); + + $content = (new Class_WebService_BibNumerique_Dilicom_Hub())->loanBook($album); + + if ($content->returnMessage) { + $this->_helper->notify(implode(',', $content->returnMessage)); + return $this->_redirectToReferer(); + } + + return $this->_redirect($content->link->url); + } + + + public function endLoanBookAction() { + if ($loan = Class_Loan_Pnb::find($this->_getParam('id'))) + $loan->endLoanDo([$this, 'notifyEndLoanBook']); + + $this->_redirectToReferer(); + } + + + public function notifyEndLoanBook($errors) { + $message = $errors + ? implode(',', $errors) + : $this->view->_('Votre retour a bien été enregistré'); + + $this->_helper->notify($message);; + } } ?> \ No newline at end of file diff --git a/application/modules/opac/controllers/BlogController.php b/application/modules/opac/controllers/BlogController.php index 5788de638ef22b102ac4d1630ec58307808e9748..c086a431a9412d2d312c5a3827829ae30770b5b9 100644 --- a/application/modules/opac/controllers/BlogController.php +++ b/application/modules/opac/controllers/BlogController.php @@ -18,39 +18,30 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3: Blog -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + class BlogController extends ZendAfi_Controller_Action { use Trait_Translator; - private $_user = null; // Le user connecté - var $modo_blog; - var $_today; - - function init() - { - //Verify that the user has successfully authenticated. If not, we redirect to the login. - $user = ZendAfi_Auth::getInstance(); - if (!$user->hasIdentity())$this->_user=null; - else $this->_user = ZendAfi_Auth::getInstance()->getIdentity(); - $this->modo_blog = getVar('MODO_BLOG'); - $class_date = new Class_Date(); - $this->_today = $class_date->DateTimeDuJour(); + private $_user = null; // Le user connecté + private $modo_blog; + private $_today; + + public function init() { + $this->_user = Class_Users::getIdentity(); + $this->modo_blog = Class_AdminVar::get('MODO_BLOG'); + $this->_today = (new Class_Date())->DateTimeDuJour(); } - function indexAction() - { + + public function indexAction() { $this->_redirect('opac/blog/lastcritique/nb/10'); } - //------------------------------------------------------------------------------------------------------ - // Donner son avis - //------------------------------------------------------------------------------------------------------ - function viewauteurAction() { - $id_user = (int)$this->_request->getParam('id', $this->_user->ID_USER); - if ($auteur = Class_Users::getLoader()->find($id_user)) { + + public function viewauteurAction() { + $id_user = (int)$this->_getParam('id', $this->_user->ID_USER); + if ($auteur = Class_Users::find($id_user)) { $this->view->liste_avis = Class_AvisNotice::filterVisibleForUser($this->_user, $auteur->getAvis()); $this->view->name = $auteur->getNomAff(); } else { @@ -58,24 +49,26 @@ class BlogController extends ZendAfi_Controller_Action { $this->view->name = 'Auteur introuvable'; } - $this->view->title = "Avis"; + $this->view->title = 'Avis'; $this->view->id_user = $id_user; $avis_helper = $this->view->getHelper('Avis'); $avis_helper->addUrlContext(['retour_abonne' => 'viewavis']); if (($id_user == $this->_user->ID_USER) || Class_Users::isCurrentUserAdmin()) - $avis_helper->setActions(array('del')); + $avis_helper->setActions(['del']); } - function delavisnoticeAction() { + public function delavisnoticeAction() { $id = $this->_getParam('id'); - $avis = Class_AvisNotice::getLoader()->find($id); - if (($avis->getUser() == Class_Users::getIdentity()) || Class_Users::isCurrentUserAdmin()) { + $avis = Class_AvisNotice::find($id); + if (($avis->getUser() == Class_Users::getIdentity()) + || Class_Users::isCurrentUserAdmin()) { $avis->delete(); $this->_helper->notify($this->_("Avis supprimé")); } - if(!$this->_getParam('js_redirect') === true){ + + if (!$this->_getParam('js_redirect') === true){ $redirect = $this->_getParam('redirect', 'blog/viewauteur/id/'.$avis->getIdUser()); $this->_redirect($redirect); return; @@ -85,14 +78,15 @@ class BlogController extends ZendAfi_Controller_Action { } - function lastcritiqueAction() { - $nb_avis = (int)$this->_request->getParam('nb', 20); - $liste_avis = Class_AvisNotice::getLoader()->findAllBy(array('order' => 'date_avis desc', - 'limit' => $nb_avis)); + public function lastcritiqueAction() { + $nb_avis = (int)$this->_getParam('nb', 20); + $liste_avis = Class_AvisNotice::findAllBy(['order' => 'date_avis desc', + 'limit' => $nb_avis]); $this->view->nb_aff = $nb_avis; - $this->view->liste_avis = Class_AvisNotice::filterVisibleForUser($this->_user, $liste_avis); - $this->view->title = $this->view->_("Dernières critiques"); + $this->view->liste_avis = Class_AvisNotice::filterVisibleForUser($this->_user, + $liste_avis); + $this->view->title = $this->view->_('Dernières critiques'); $this->renderScript('blog/viewcritiques.phtml'); } @@ -111,36 +105,44 @@ class BlogController extends ZendAfi_Controller_Action { } - /* + /** * Affiche l'avis avec l'id donné pour pouvoir être lu par Read Speaker. */ - function readavisAction() { + public function readavisAction() { $this ->getHelper('ViewRenderer') ->setLayoutScript('readspeaker.phtml'); - $id_avis = $this->_request->getParam('id'); - $this->view->avis = Class_AvisNotice::getLoader()->find($id_avis); + $this->view->avis = Class_AvisNotice::find($this->_getParam('id')); } - function viewavisAction() { - $id_avis = $this->_request->getParam('id'); - $avis = Class_AvisNotice::getLoader()->find($id_avis); + public function viewavisAction() { + $id_avis = $this->_getParam('id'); + $avis = Class_AvisNotice::find($id_avis); $this->view->avis = $avis; - $this->view->commentaires = array(); + $this->view->commentaires = []; $this->view->modo_blog = $this->modo_blog; $this->view->user_co = ($this->_user->ID_USER != ''); $this->view->user = $this->_user; } - function alertAction() { + public function alertAction() { $class_blog = new Class_Blog(); - $type = $this->_request->getParam('type'); - $id = $this->_request->getParam('id_avis'); - $class_blog->alertThis($id,$type); + $type = $this->_getParam('type'); + $id = $this->_getParam('id_avis'); + $class_blog->alertThis($id, $type); $this->_redirect($_SERVER['HTTP_REFERER']); } + + + public function hierarchicalAction() { + $this->view->list = $this->_helper + ->reviewListViewMode(['model' => Class_Catalogue::find($this->_getParam('id', 0)), + 'id' => $this->_getParam('id'), + 'page' => $this->_getParam('page', 1), + 'truncate_at' => $this->_getParam('truncate_at')]); + } } \ No newline at end of file diff --git a/application/modules/opac/controllers/CasServerV10Controller.php b/application/modules/opac/controllers/CasServerV10Controller.php index 7510de7afb3b0552e3f7123aabdb0d1d020763b6..8edab7c8fcb3de647ecd2a67903f3a703452df11 100644 --- a/application/modules/opac/controllers/CasServerV10Controller.php +++ b/application/modules/opac/controllers/CasServerV10Controller.php @@ -16,14 +16,19 @@ * * 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 CasServerV10Controller extends CasServerController { // see http://www.jasig.org/cas/protocol#validate-cas-1.0 public function returnValidTicketResponse($user, $ticket) { - $this->getResponse()->setBody( - 'yes'.chr(10).$user->getNomAff().'|'.$user->getLogin().chr(10) - ); + $this->getResponse() + ->setBody( + 'yes'.chr(10). + implode('|', + [$user->getNomAff(), + $user->getLogin(), + $user->getMail(), + $user->getDateNaissanceIso8601()]).chr(10)); } diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index 0ba670f5d86109554695e3e2d0c3691aee969c39..c7e2a9ee8da2efa36cf885c8b21c3eb5c972f12c 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -258,8 +258,9 @@ class CmsController extends ZendAfi_Controller_Action { $preferences = array_merge($module_calendrier->getDefaultValues(), $this->_modulesPreferences($id_module)); + if (!preg_match('/[0-9]{4}-[0-9]{2}/', $date)) { - $date = date('Y-m-d'); + $date = null; } // param pour l'affichage du calendar @@ -267,6 +268,7 @@ class CmsController extends ZendAfi_Controller_Action { if ($month = $this->_getParam('month')) { $param['DATE'] = date('Y') . '-' . sprintf("%02d", $month); } + $param['URL']=''; $param['ID_BIB']=Class_Profil::getCurrentProfil()->getIdSite(); $param['AFFICH_MOIS']=1; diff --git a/application/modules/opac/controllers/DomainsController.php b/application/modules/opac/controllers/DomainsController.php index 89623455126484128b5756bf8a5ff4025ee3f070..cdc9eb5374f4821ee287e7e86b7e94b1776e956e 100644 --- a/application/modules/opac/controllers/DomainsController.php +++ b/application/modules/opac/controllers/DomainsController.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 DomainsController extends ZendAfi_Controller_Action { @@ -41,7 +41,6 @@ class DomainsController extends ZendAfi_Controller_Action { $this->view->current_domain = $catalog; $this->view->id_module = $id_module; - $this->view->current_breadcrumb = $this->_getParam('parents'); } } ?> \ No newline at end of file diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php index 54262af62eee6e507bd1b683527ac421c23dd2b7..9ec04d325eee9c12693585098a72d1641b73dc5c 100644 --- a/application/modules/opac/controllers/ModulesController.php +++ b/application/modules/opac/controllers/ModulesController.php @@ -79,8 +79,8 @@ class ModulesController extends Zend_Controller_Action { public function mycowAction() { $mycow = new Class_Systeme_ModulesMenu_MyCow(); $mycow->afterLoginRedirectTo($this->_request->getServer('HTTP_REFERER')); - $this->checkNotifyMessage($mycow, $mycow->getDynamiqueUrl()); - } + $this->checkNotifyMessage($mycow, $mycow->getDynamiqueUrl()); + } public function mycowSsoAction() { diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 8e6bcd822bab850386fe2693c1b4e3660147a3c9..b007c9eed73a7ff8e25172dd4bbff596245a6b36 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -25,16 +25,16 @@ class RechercheController extends ZendAfi_Controller_Action { private $preferences; - public function init() { - $this->moteur=Class_MoteurRecherche::getInstance(); - $this->view->resultat=array(); + public function init() { + $this->moteur = Class_MoteurRecherche::getInstance(); + $this->view->resultat = []; - $this->view->statut = $this->_getParam("statut"); + $this->view->statut = $this->_getParam('statut'); - if($this->view->statut == "reset") - $this->view->statut ="saisie"; + if ($this->view->statut == 'reset') + $this->view->statut = 'saisie'; - $this->view->url_retour = BASE_URL."/opac/recherche/simple/"; + $this->view->url_retour = BASE_URL . '/opac/recherche/simple/'; $this->view->url_facette = $this->view->url_retour; $this->preferences = $this->_getParam('current_module')['preferences']; @@ -83,6 +83,11 @@ class RechercheController extends ZendAfi_Controller_Action { $criteres_recherche = new Class_CriteresRecherche(); $criteres_recherche->setParams($params); + if ('json' == $this->_getParam('format', '')) { + $this->_renderJsonResult($criteres_recherche); + return; + } + $this->getFrontController()->getRouter()->getCurrentRoute() ->match(str_replace(BASE_URL, '', @@ -90,8 +95,9 @@ class RechercheController extends ZendAfi_Controller_Action { $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); - if ($this->view->statut == "guidee") + if ($this->view->statut == 'guidee') $criteres_recherche->updateRubrique('guidee'); + $this->view->current_domain = $criteres_recherche->getCatalogue(); $this->showDomainBreadcrumbOnDomainBrowsing(); @@ -100,6 +106,34 @@ class RechercheController extends ZendAfi_Controller_Action { } + protected function _renderJsonResult($criteres_recherche) { + $datas = ['url' => Class_Url::absolute(), + 'total' => 0, + 'page_size' => $this->preferences['liste_nb_par_page'], + 'page' => $this->_getParam('page', 1), + 'records' => []]; + + $ret = $this->moteur->lancerRecherche($criteres_recherche); + if (isset($ret['statut']) && $ret['statut'] == 'erreur') { + $this->_helper->json($datas); + return; + } + + $datas['total'] = $ret['nombre']; + $records = []; + (new Storm_Model_Collection($this->_getListNotices($ret['req_liste']))) + ->eachDo( + function($record) use (&$records) { + $json = new Class_Notice_JsonVisitor(); + $record->acceptVisitor($json); + $records[] = $json->data(); + }); + + $datas['records'] = $records; + $this->_helper->json($datas); + } + + protected function showDomainBreadcrumbOnDomainBrowsing() { $id_module = $this->_getParam('id_module'); if (($config = Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig($id_module)) @@ -128,7 +162,7 @@ class RechercheController extends ZendAfi_Controller_Action { if($title = $this->getTitleForPage($criteres_recherche)) return $title; - return $this->view->_("Résultat de la recherche"); + return $this->view->_('Résultat de la recherche'); } @@ -146,7 +180,7 @@ class RechercheController extends ZendAfi_Controller_Action { return $titre_from_module; if ($this->_request->getParam('rubrique')) - return $this->view->_("Recherche guidée"); + return $this->view->_('Recherche guidée'); if ($catalogue = $criteres_recherche->getCatalogue()) return $catalogue->getLibelle(); @@ -248,7 +282,7 @@ class RechercheController extends ZendAfi_Controller_Action { $notices); if (!in_array($id_notice, $ids)) - $id_notice = $notices[0]->getId(); + $id_notice = array_pop($notices)->getId(); } if (!$notice = Class_Notice::find($id_notice)) { @@ -545,7 +579,11 @@ class RechercheController extends ZendAfi_Controller_Action { $id_origine = $this->_getParam('id_origine'); $code_annexe = $this->_getParam('code_annexe'); + if (Class_CosmoVar::isSiteRetraitResaPatronLibrary()) + $code_annexe = $user->getUserIdSite(); + $comm = new Class_CommSigb(); + $ret = $comm->reserverExemplaire($id_bib, $id_origine, $code_annexe); $this->renderPopupResult($this->view->_('Réservation'), @@ -599,7 +637,7 @@ class RechercheController extends ZendAfi_Controller_Action { } - if (!Class_CosmoVar::isSiteRetraitResaEnabled() + if (!Class_CosmoVar::isSiteRetraitResaChoiceEnabled() && !$this->arePickupLocationsProvidedByComm()) { $this->_forward('reservationajax'); return; diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 6700be3445c74b537831b58e3cb73316cc7be1c8..5011efef12cf73a5ca230af195c564961500541f 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -20,31 +20,20 @@ */ class SitoController extends Zend_Controller_Action { - private $_session; - private $_idProfil; - - function init() - { - $this->_session = Zend_Registry::get('session'); - $this->_idProfil = $this->_session->idProfil; - } - - function indexAction() - { + public function indexAction() { $this->_redirect('opac/'); } - // Lire une url - function sitoviewAction() { + + public function sitoviewAction() { $ids = $this->_getParam('id', $this->_getParam('id_items')); $sitos = Class_Sitotheque::getSitesFromIdsAndCategories( explode('-', $ids), - explode("-",$this->_request->getParam('id_categorie'))); + explode('-', $this->_getParam('id_categorie'))); $this->view->sitos = $sitos; - $this->view->title = $this->view->_("Sélection de sites"); + $this->view->title = $this->view->_('Sélection de sites'); $this->renderScript('sito/viewsitos.phtml'); - } @@ -56,11 +45,22 @@ class SitoController extends Zend_Controller_Action { $sites = Class_Sitotheque::findAllBy(['order' => 'date_maj desc', 'limit' => $limit]); $this->view->sitos = $sites; - $this->view->title = $this->view->_("Derniers Sites"); + $this->view->title = $this->view->_('Derniers Sites'); $this->renderScript('sito/viewsitos.phtml'); } + public function viewcategoryAction() { + $id_category = $this->_getParam('id_cat'); + $search = $this->_getParam('title_search', ''); + $this->view->list = $this->_helper + ->sitothequeListViewMode(['model' => Class_SitothequeCategorie::find($id_category), + 'search_value' => $search, + 'id_cat' => $id_category, + 'page' => $this->_getParam('page', 1)]); + } + + public function viewselectionAction() { $id_module = $this->_getParam('id_module'); @@ -70,6 +70,7 @@ class SitoController extends Zend_Controller_Action { $sites = Class_Sitotheque::getSitesFromIdsAndCategories( explode('-', $preferences['id_items']), explode('-', $preferences['id_categorie'])); + $this->view->sites = $sites; $this->view->title = $this->view->_("Sélection de sites"); } @@ -85,7 +86,4 @@ class SitoController extends Zend_Controller_Action { $webThumbnail = new Class_WebService_WebSiteThumbnail(); $this->_redirect($webThumbnail->fetchFullUrl($url)); } - -} - -?> +} \ No newline at end of file diff --git a/application/modules/opac/views/scripts/abonne/multimedia-hold-day.phtml b/application/modules/opac/views/scripts/abonne/multimedia-hold-day.phtml index ce55ca1fcc4277c560a74abb01e4198ae2c230d5..0696b91d9dbdbbf01a913aed588debf7157ab640 100644 --- a/application/modules/opac/views/scripts/abonne/multimedia-hold-day.phtml +++ b/application/modules/opac/views/scripts/abonne/multimedia-hold-day.phtml @@ -2,6 +2,11 @@ <?php echo $this->timeline($this->timelineActions);?> <div class="workflow_step"> + <div> + <ul> + <li><?php echo sprintf('%s : %s', $this->_('Lieu'), $this->escape($this->location));?></li> + </ul> + </div> <h2><?php echo $this->_('Pour quel jour ?');?></h2> <?php if ($this->quotaError) { ?> <div class="error"><?php echo $this->quotaError;?></div> @@ -21,4 +26,4 @@ <div id="hold-day" class="calendar"></div> </div> -<?php $this->closeBoite();?> \ No newline at end of file +<?php $this->closeBoite();?> diff --git a/application/modules/opac/views/scripts/abonne/multimedia-hold-device.phtml b/application/modules/opac/views/scripts/abonne/multimedia-hold-device.phtml index bc9c175ea357f9a001901c4f1a258d2ff89a3500..33c51db1dc7ab5248fb6c765d446273a664af537 100644 --- a/application/modules/opac/views/scripts/abonne/multimedia-hold-device.phtml +++ b/application/modules/opac/views/scripts/abonne/multimedia-hold-device.phtml @@ -3,6 +3,16 @@ <div class="workflow_step"> + <div> + <ul> + <li><?php echo sprintf('%s : %s', $this->_('Lieu'), $this->escape($this->location));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Jour'), $this->escape($this->day));?></li> + <li><?php echo sprintf('%s : %s', $this->_('À partir de'), $this->escape($this->time));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Durée'), $this->escape($this->duration));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Secteur'), $this->escape($this->group));?></li> + </ul> + </div> + <h2><?php echo $this->_('Quel poste ?') ?></h2> <ul> <?php @@ -12,4 +22,4 @@ </ul> </div> -<?php $this->closeBoite();?> \ No newline at end of file +<?php $this->closeBoite();?> diff --git a/application/modules/opac/views/scripts/abonne/multimedia-hold-group.phtml b/application/modules/opac/views/scripts/abonne/multimedia-hold-group.phtml index 6bde170da33e1a124586956209818f97986ddd4c..60bf6d4f8aa00f4989246667309721a154801f11 100644 --- a/application/modules/opac/views/scripts/abonne/multimedia-hold-group.phtml +++ b/application/modules/opac/views/scripts/abonne/multimedia-hold-group.phtml @@ -2,6 +2,15 @@ <?php echo $this->timeline($this->timelineActions);?> <div class="workflow_step"> + <div> + <ul> + <li><?php echo sprintf('%s : %s', $this->_('Lieu'), $this->escape($this->location));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Jour'), $this->escape($this->day));?></li> + <li><?php echo sprintf('%s : %s', $this->_('À partir de'), $this->escape($this->time));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Durée'), $this->escape($this->duration));?></li> + </ul> + </div> + <h2><?php echo $this->_('Quel secteur ?') ?></h2> <ul> <?php @@ -13,4 +22,4 @@ </ul> </div> -<?php $this->closeBoite();?> \ No newline at end of file +<?php $this->closeBoite();?> diff --git a/application/modules/opac/views/scripts/abonne/multimedia-hold-hours.phtml b/application/modules/opac/views/scripts/abonne/multimedia-hold-hours.phtml index c8bf5d8907ddcb06a3559d943f4c6bb14064dbde..faf53fb3e9991def3273ea30c526ff8e6e481ab7 100644 --- a/application/modules/opac/views/scripts/abonne/multimedia-hold-hours.phtml +++ b/application/modules/opac/views/scripts/abonne/multimedia-hold-hours.phtml @@ -2,6 +2,13 @@ <?php echo $this->timeline($this->timelineActions);?> <div class="workflow_step"> + <div> + <ul> + <li><?php echo sprintf('%s : %s', $this->_('Lieu'), $this->escape($this->location));?></li> + <li><?php echo sprintf('%s : %s', $this->_('Jour'), $this->escape($this->day));?></li> + </ul> + </div> + <h2><?php echo $this->_('Quand ?') ?></h2> <?php if ($this->error) { ?> <div class="error"> @@ -12,4 +19,4 @@ <?php echo $this->renderForm($this->form) ?> </div> -<?php $this->closeBoite();?> \ No newline at end of file +<?php $this->closeBoite();?> diff --git a/application/modules/opac/views/scripts/abonne/prets.phtml b/application/modules/opac/views/scripts/abonne/prets.phtml index 80cb8ad610ea692746955d5582e84a4afcb04a31..17ac6d4655fe1e12bf332ce79d5b4a44ae99674a 100644 --- a/application/modules/opac/views/scripts/abonne/prets.phtml +++ b/application/modules/opac/views/scripts/abonne/prets.phtml @@ -7,11 +7,10 @@ foreach (['message', 'error'] as $type) echo '<p class="error">' . $this->fiche[$type] . '</p>'; ?> -<?php if (isset($this->fiche['fiche']) - && ($emprunts = $this->fiche['fiche']->getEmprunts()) - && !empty($emprunts)) { - echo $this->abonne_LoanExport(); - } +<?php +if ($emprunts = $this->user->getEmprunts()) { + echo $this->abonne_LoanExport(); +} ?> <table width="100%" class="tablesorter"> @@ -28,9 +27,56 @@ foreach (['message', 'error'] as $type) <tbody> <?php $num = 1; - if (isset($this->fiche['fiche'])) { - foreach ($this->fiche["fiche"]->getEmprunts() as $emprunt) { - $class_retard = $emprunt->enRetard() ? 'class="pret_en_retard"' : '';?> + foreach ($this->user->getLoansWithOutPNB() as $emprunt) { + $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> + <tr <?php echo $class_retard;?>> + <td width="15px" align="center"><b><?php echo $num++;?></b></td> + <td> + <?php + echo $this->tagAnchor( + $this->url(['controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $emprunt->getNoticeOPACId(), + 'retour_abonne' => 'prets'], + null, true), + $emprunt->getTitre()); + ?></td> + <td><?php echo $emprunt->getAuteur();?></td> + <td><?php echo $emprunt->getBibliotheque();?></td> + <td class="date_retour"> + <?php + echo $emprunt->getDateRetour() . ' '; + echo $this->abonne_LoanAction($emprunt); + ?> + </td> + <td><?php echo $emprunt->getType();?></td> + </tr> + <?php } ?> + </tbody> +</table> +<br/> +<br/> + +<?php +if($this->user->hasPNB()) { +?> +<h2><?php echo $this->_('Prêts numériques en cours'); ?></h2> +<table width="100%" class="tablesorter"> + <thead> + <tr> + <th style="text-align:left; white-space:nowrap"><?php echo $this->_('n°'); ?></th> + <th style="text-align:left"><?php echo $this->_('Titre'); ?></th> + <th style="text-align:left"><?php echo $this->_('Auteur'); ?></th> + <th style="text-align:left"><?php echo $this->_('Bibliothèque'); ?></th> + <th style="text-align:center"><?php echo $this->_('Retour prévu'); ?></th> + <th style="text-align:center"><?php echo $this->_('Informations'); ?></th> + </tr> + </thead> + <tbody> + <?php + $num = 1; + foreach ($this->user->getPNBLoans() as $emprunt) { + $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> <tr <?php echo $class_retard;?>> <td width="15px" align="center"><b><?php echo $num++;?></b></td> <td> @@ -46,26 +92,19 @@ foreach (['message', 'error'] as $type) <td><?php echo $emprunt->getAuteur();?></td> <td><?php echo $emprunt->getBibliotheque();?></td> <td class="date_retour"> - <?php echo $emprunt->getDateRetour() . ' ';?> <?php - if ($emprunt->isRenewable()) - $url = $this->url([ - 'action' => 'prolongerPret', - 'id_pret' => $emprunt->getId() - ]); - $attrs = [ - 'data-popup' => 'true', - 'data-popup-refresh' => 'true', - ]; - echo $this->tagAnchor($url, $this->_('Prolonger'), $attrs); + echo $emprunt->getDateRetour() . ' '; + echo $this->abonne_LoanAction($emprunt); ?> </td> <td><?php echo $emprunt->getType();?></td> </tr> - <?php } - } ?> + <?php } ?> </tbody> </table> +<?php +} +?> <?php $this->closeBoite(); ?> <?php echo $this->abonne_RetourFiche(); ?> diff --git a/application/modules/opac/views/scripts/abonne/reservations.phtml b/application/modules/opac/views/scripts/abonne/reservations.phtml index 4d5427ccb582deae8156e363db5eb871c046d0d9..cd657ef8956ef2d5fc9753969ca51e866dc39722 100644 --- a/application/modules/opac/views/scripts/abonne/reservations.phtml +++ b/application/modules/opac/views/scripts/abonne/reservations.phtml @@ -1,6 +1,8 @@ <?php $this->openBoite($this->_('Réservations en cours'));?> -<div class="abonneTitre"><?php echo $this->escape($this->fiche["nom_aff"]);?></div> +<div class="abonneTitre"> + <?php echo $this->escape($this->user->getNomAff());?> +</div> <table width="100%" class="tablesorter"> <thead> @@ -26,8 +28,7 @@ </tr> <?php } ?> <?php - if ($this->fiche["fiche"]) { - $resas = $this->fiche["fiche"]->getReservations(); + $resas = $this->user->getReservations(); $num=1; foreach($resas as $resa) { ?> <tr> @@ -54,7 +55,7 @@ ?> </td> </tr> - <?php }} ?> + <?php } ?> </tbody> </table> diff --git a/application/modules/opac/views/scripts/accueil.phtml b/application/modules/opac/views/scripts/accueil.phtml index f9f4cb40efebe2bf98cd4f933ca1e38d55550416..f37328240ce88017b9f215b07383573afeddcc93 100644 --- a/application/modules/opac/views/scripts/accueil.phtml +++ b/application/modules/opac/views/scripts/accueil.phtml @@ -1,7 +1,7 @@ -<div id="site_web_wrapper" style="width:<?php echo $this->profil->getLargeurSite(); ?>px; margin-left:auto; margin-right:auto"> +<div id="site_web_wrapper" style="width:<?php echo $this->profil->getWidthSite(); ?>; margin-left:auto; margin-right:auto"> <div class="siteWeb portail_background_img"> <div id="site_web_content"> - <?php echo $this->partial("banniere.phtml", array("profil" => $this->profil)); ?> + <?php echo $this->partial("banniere.phtml", array("profil" => $this->profil)); ?> <div id="col_wrapper"> <?php switch ($this->profil->getNbDivisions()) { @@ -10,16 +10,16 @@ break; case 2: - echo $this->divisionMap($this->profil, - $this->profil->isDivisionsFromRightToLeft() + echo $this->divisionMap($this->profil, + $this->profil->isDivisionsFromRightToLeft() ? [2 => 'colContenu', 1 => 'colDroite'] : [1 => 'colGauche', 2 => 'colContenu']); break; case 3: echo '<div id="right_col_color">'; - echo $this->divisionMap($this->profil, - $this->profil->isDivisionsFromRightToLeft() + echo $this->divisionMap($this->profil, + $this->profil->isDivisionsFromRightToLeft() ? [3 => 'colGauche', 2 => 'colMilieu', 1 => 'colDroite'] : [1 => 'colGauche', 2 => 'colMilieu', 3 => 'colDroite']); echo '</div>'; @@ -27,9 +27,9 @@ } echo $this->division($this->profil, 5, 'colFlottant'); - + ?> - + <div class="clear"></div> </div> <!-- col_wrapper --> </div> <!-- site_web_content --> diff --git a/application/modules/opac/views/scripts/auth/boite-login.phtml b/application/modules/opac/views/scripts/auth/boite-login.phtml index 8ad6900cf7ce1b3bc770a2a3360e26d32e3bdac0..a27e94a06ba3e86751ba53dab54646a4ac9ec9e9 100644 --- a/application/modules/opac/views/scripts/auth/boite-login.phtml +++ b/application/modules/opac/views/scripts/auth/boite-login.phtml @@ -1,32 +1,50 @@ -<div class="form"> - <?php - if($user = Class_Users::getIdentity()) { - echo sprintf("<div class='welcome'>%s %s </div>", $this->preferences['message_connecte'], $this->abonne_NamesOrLogin($user)); - - if ($user->hasIdabon()){ - if(!$user->isAbonnementValid()) - echo $this->tag('p', - _('Abonnement expiré - Merci de contacter la médiathèque'), - ['class' => 'expired']); - } - - echo sprintf('<a href="%s" target="_parent" class="account-link">%s</a>', $this->url(['controller'=>'abonne', - 'action'=>'fiche', - 'id_profil'=>$this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()],null,true), $this->_($this->preferences['lien_compte'])); - if ($user->hasIdabon()) - echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations()); - echo sprintf('<a href="%s" target="_parent" class="account-disconnect">%s</a>', $this->url(['controller'=>'auth', - 'action'=>'logout'],null,true), $this->_($this->preferences['lien_deconnection'])); - } else { - $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge($this->preferences, - ['redirect_url' => $this->redirect, - 'service' => $this->service, - 'id_notice' => $this->id_notice]), - - 'action' => $this->url(['controller' => 'auth', - 'action' => ($this->form_action ? $this->form_action : 'boite-login'), - 'id_module' => $this->id_module])]); - echo $this->renderForm($form); - } - ?> -</div> +<?php + +if (!$user = Class_Users::getIdentity()) { + $form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge($this->preferences, + ['redirect_url' => $this->redirect, + 'service' => $this->service, + 'id_notice' => $this->id_notice]), + + 'action' => $this->url(['controller' => 'auth', + 'action' => ($this->form_action ? $this->form_action : 'boite-login'), + 'id_module' => $this->id_module])]); + echo $this->tag('div', $this->renderForm($form), + ['class' => 'form']); + + return; +} + +$html = $this->tag('div', + $this->preferences['message_connecte'] . ' ' . $this->abonne_NamesOrLogin($user), + ['class' => 'welcome']); + +if ($user->hasIdabon() && !$user->isAbonnementValid()) + $html .= $this->tag('p', + $this->_('Abonnement expiré - Merci de contacter la médiathèque'), + ['class' => 'expired']); + +$user_url = $this->url(['controller' => 'abonne', + 'action' => 'fiche', + 'id_profil' => $this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()], + null, true); + +$html .= $this->tag('a', $this->_($this->preferences['lien_compte']), + ['href' => $user_url, + 'class' => 'account-link', + 'target' => '_parent']); + +if ($user->hasIdabon()) + $html .= $this->ficheAbonneLinks($user->getNbEmprunts(), + $user->getNbEmpruntsRetard(), + $user->getNbReservations()); + +$html .= $this->tag('a', $this->_($this->preferences['lien_deconnection']), + ['href' => $this->url(['controller'=>'auth', + 'action'=>'logout'], + null, true), + 'class' => 'account-disconnect', + 'target' => '_parent']); + +echo $this->tag('div', $html, ['class' => 'form']); +?> diff --git a/application/modules/opac/views/scripts/blog/hierarchical.phtml b/application/modules/opac/views/scripts/blog/hierarchical.phtml new file mode 100644 index 0000000000000000000000000000000000000000..1bb14e4e81e2a949fc33a67380f7cd3ce3568c49 --- /dev/null +++ b/application/modules/opac/views/scripts/blog/hierarchical.phtml @@ -0,0 +1,8 @@ +<?php +echo $this->publicListViewMode( + $this->list, + function($item) { + return $this->getHelper('avis') + ->addUrlContext($this->list->getReviewUrlContext()) + ->avis($item, $this->list->getParam('truncate_at', 0)); + }); diff --git a/application/modules/opac/views/scripts/contenu.phtml b/application/modules/opac/views/scripts/contenu.phtml index 5deaa52216b560eaa74fb3b0aebec40179423f5b..f02810f7ca1f005f766e1d813cf40d65e26499fd 100644 --- a/application/modules/opac/views/scripts/contenu.phtml +++ b/application/modules/opac/views/scripts/contenu.phtml @@ -1,7 +1,7 @@ -<div id="site_web_wrapper" style="width:<?php echo $this->profil->getLargeurSite(); ?>px; margin-left:auto; margin-right:auto"> +<div id="site_web_wrapper" style="width:<?php echo $this->profil->getWidthSite(); ?>; margin-left:auto; margin-right:auto"> <div class="siteWeb module_background_img module"> <div id="site_web_content"> - + <?php echo $this->partial("banniere.phtml", array("profil" => $this->profil)); ?> <div id="col_wrapper"> @@ -15,19 +15,19 @@ if ($this->profil->getDivisionThreeAlwaysVisible()) { echo $this->division($this->profil, 3, 'colGauche'); echo $this->division($this->profil, 2, 'colMilieu', $this->actionContent); - + } else { echo $this->division($this->profil, 2, 'colContenu', $this->actionContent); - - - + + + } echo $this->division($this->profil, 1, 'colDroite'); } else { echo $this->division($this->profil, 1, 'colGauche'); - + if ($this->profil->getDivisionThreeAlwaysVisible()) { echo $this->division($this->profil, 2, 'colMilieu', $this->actionContent); echo $this->division($this->profil, 3, 'colDroite'); diff --git a/application/modules/opac/views/scripts/head.phtml b/application/modules/opac/views/scripts/head.phtml index c0bbb9b972608c9db3ac1f761bd97a021b69176b..04832a80ae62f75689ff9957e98f39ca4023e882 100644 --- a/application/modules/opac/views/scripts/head.phtml +++ b/application/modules/opac/views/scripts/head.phtml @@ -13,7 +13,7 @@ Class_ScriptLoader::getInstance()->loadMeta(); echo $current_profil->getStyleCss(); - if ($current_profil->hasFavicon()) + if ($current_profil->hasFavicon()) echo sprintf('<link rel="shortcut icon" href="%s"/>', $current_profil->getFavicon()); $head_scripts = Class_ScriptLoader::newInstance() @@ -32,7 +32,6 @@ 'division-five', 'reload_module']) ->addJQueryReady(' $("input").placeholder(); - setupAnchorsTarget(); autoHideShowConfigurationModule(); initializeNoticeMurAnimation(); initializeImgHover(); @@ -102,6 +101,7 @@ $script_loader->addSkinStyleSheet('ie' . $ie, ['ie_version' => $ie]) ->addUserFilesStylSheet($current_profil->getHeaderCssIE($ie), ['ie_version' => $ie]); + $script_loader->addJQueryReady('setupAnchorsTarget();'); $head_scripts->renderStyleSheets(); $script_loader->renderStyleSheets(); diff --git a/application/modules/opac/views/scripts/pagination.phtml b/application/modules/opac/views/scripts/pagination.phtml new file mode 100644 index 0000000000000000000000000000000000000000..aa60d29e84bb94ec33efdc50d615f44afade7f5b --- /dev/null +++ b/application/modules/opac/views/scripts/pagination.phtml @@ -0,0 +1,27 @@ +<?php if (1 >= $this->pageCount) return;?> +<?php if ($this->pageCount): ?> +<div class="paginationControl"> +<!-- Previous page link --> +<?php if (isset($this->previous)): ?> + <a href="<?php echo $this->url(['page' => $this->previous]); ?>">< <?php echo $this->_('Précédent'); ?></a> | +<?php else: ?> + <span class="disabled">< <?php echo $this->_('Précédent'); ?></span> | +<?php endif; ?> + +<!-- Numbered page links --> +<?php foreach ($this->pagesInRange as $page): ?> + <?php if ($page != $this->current): ?> + <a href="<?php echo $this->url(['page' => $page]); ?>"><?php echo $page; ?></a> | + <?php else: ?> + <?= $page; ?> | + <?php endif; ?> +<?php endforeach; ?> + +<!-- Next page link --> +<?php if (isset($this->next)): ?> + <a href="<?php echo $this->url(array('page' => $this->next)); ?>"><?php echo $this->_('Suivant'); ?> ></a> +<?php else: ?> + <span class="disabled"><?php echo $this->_('Suivant'); ?> ></span> +<?php endif; ?> +</div> +<?php endif; ?> diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index 48fd740d8ad7696a0386536c3fbdd2b110000ec6..83c3650763e512ec979767d97f0f2fd6ef8c6656 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -2,8 +2,8 @@ $this->openBoite($this->title); $script_loader = Class_ScriptLoader::getInstance() - ->addStyleSheet(URL_ADMIN_JS.'slimbox/slimbox2') - ->addAdminScript('slimbox/slimbox2.min.js') + ->loadButterflyLightbox() + ->addAdminScript('multi_inputs/multi_inputs.js') ->addStyleSheet(URL_ADMIN_JS.'rating/jquery.rating') @@ -13,19 +13,19 @@ $script_loader = Class_ScriptLoader::getInstance() ->addOpacScripts(['subModal', 'recherche', 'liste_notices_mur']) + ->addJQueryReady(sprintf('$("#reseaux-sociaux").load("%s")', - $this->url(array('controller' => 'recherche', - 'action' => 'reseau', - 'id_notice' => $this->notice->getId(), - 'type_doc' => $this->notice->getTypeDoc())))); + $this->url(['controller' => 'recherche', + 'action' => 'reseau', + 'id_notice' => $this->notice->getId(), + 'type_doc' => $this->notice->getTypeDoc()]))); ?> <div class="navigation"> - <a class="retour" href="<?php echo $this->url($this->criteres_recherche->getUrlRetourListe(), null, true).'#'.$this->notice->getId(); ?>"> + <a class="retour" href="<?php echo $this->url($this->criteres_recherche->getUrlRetourListe(), null, true).'#'.$this->notice->getId(); ?>"> <?php echo $this->_('Retour à la liste') ?> </a> - <?php echo $this->tagAnchor($this->url_panier, $this->_('Ajouter au Panier'), ['class'=>'panier'. @@ -36,39 +36,37 @@ $script_loader = Class_ScriptLoader::getInstance() 'data-action' => $this->url_panier, 'title' => $this->notice->getPaniersLibelles()]); ?> - <?php - echo $this->Notice_LienReserver($this->notice); - if ($this->notice_navigation) - echo $this->Notice_Navigation($this->notice_navigation); - ?> + <?php + echo $this->Notice_LienReserver($this->notice); + if ($this->notice_navigation) + echo $this->Notice_Navigation($this->notice_navigation); + ?> <div class="clear"></div> </div> <div class="notice_vignette"> - <?php - if ($this->notice->hasVignette()) { - printf('<a id="vignette" href="%s" title="%s">', - $this->notice->getUrlImage(), - htmlentities($this->notice->getTitrePrincipal())); - - printf('<img src="%s" width="100" border="0" alt="%s" />', - $this->notice->getUrlVignette(), - $this->_('Vignette')); - - echo '</a>'; - echo '<script type="text/javascript">$("a[id=\'vignette\']").slimbox({}, null, null)</script>'; + <?php + if ($this->notice->hasVignette()) { + echo $this->tag('a', + $this->tagImg($this->notice->getUrlVignette(), + ['style' => 'width:100px;', + 'alt' => $this->_('Vignette')]), + ['id' => 'vignette', + 'href' => $this->notice->getUrlImage(), + 'title' => htmlentities($this->notice->getTitrePrincipal())]); + $script_loader->addJQueryReady('$("a#vignette").butterfly({closeButton:false});'); } else - echo $this->notice_Vignette($this->notice); + echo $this->notice_Vignette($this->notice); if ($this->display_modifier_vignette_link) - echo sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>', - $this->url(['module' => 'admin', - 'controller' => 'upload', - 'action' => 'vignette-notice', - ]), - $this->_('Modifier la vignette')); + echo sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>', + $this->url(['module' => 'admin', + 'controller' => 'upload', + 'action' => 'vignette-notice', + ]), + $this->_('Modifier la vignette')); ?> <div id="reseaux-sociaux"></div> diff --git a/application/modules/opac/views/scripts/sansMenuGauche.phtml b/application/modules/opac/views/scripts/sansMenuGauche.phtml index 62e81d0556a77debc5a271f729b015e7e06a679b..1faee5fbd789442a78fe2dd26fc799b31cbdecad 100644 --- a/application/modules/opac/views/scripts/sansMenuGauche.phtml +++ b/application/modules/opac/views/scripts/sansMenuGauche.phtml @@ -3,10 +3,10 @@ ob_start(); echo '<body '.$this->bodyParam.'>'; ?> -<div id="site_web_wrapper" style="width:<?php echo $this->profil->getLargeurSite(); ?>px; margin-left:auto; margin-right:auto"> +<div id="site_web_wrapper" style="width:<?php echo $this->profil->getWidthSite(); ?>; margin-left:auto; margin-right:auto"> <div class="siteWeb portail_background_img"> <div id="site_web_content"> - <?php echo $this->partial("banniere.phtml", array("profil" => $this->profil)); ?> + <?php echo $this->partial("banniere.phtml", array("profil" => $this->profil)); ?> <div id="col_wrapper" style="overflow:hidden;width:<?php echo $this->profil->getLargeurSite(); ?>px"> <div class="colContenu"> @@ -16,15 +16,15 @@ echo '<body '.$this->bodyParam.'>'; </div> </div> -<?php -echo $this->partial('footer.phtml', +<?php +echo $this->partial('footer.phtml', array('portail_cfg_site' => $this->profil->getCfgSiteAsArray())); $html = ob_get_contents(); ob_end_clean(); -echo $this->partial('head.phtml', - array_merge($this->profil->getCfgSiteAsArray(), +echo $this->partial('head.phtml', + array_merge($this->profil->getCfgSiteAsArray(), array('titre' => $this->getTitre()))); echo $html; ?> diff --git a/application/modules/opac/views/scripts/sito/viewcategory.phtml b/application/modules/opac/views/scripts/sito/viewcategory.phtml new file mode 100644 index 0000000000000000000000000000000000000000..95955c14e0d5fa1f2fa261e2edcdaf51d1abfe5f --- /dev/null +++ b/application/modules/opac/views/scripts/sito/viewcategory.phtml @@ -0,0 +1,3 @@ +<?php +echo $this->publicListViewMode($this->list); +?> diff --git a/application/modules/push/controllers/MultimediaController.php b/application/modules/push/controllers/MultimediaController.php index 469deccfcd405358cbb63d284fc4548758da720b..3b498dddae2efccf8f85aef5776107e038d3d8d6 100644 --- a/application/modules/push/controllers/MultimediaController.php +++ b/application/modules/push/controllers/MultimediaController.php @@ -95,11 +95,33 @@ class Push_MultimediaController extends Zend_Controller_Action { public function createBorrowerAction() { + + if($infoUser = $this->checkInfoForAbonneAfim('Create borrower multimedia start')) + $this->_response->setBody(Class_Multimedia_Users::getInstance()->createUser($infoUser)); + + } + + public function modifyBorrowerAction() { + + if($infoUser = $this->checkInfoForAbonneAfim('Modify borrower multimedia start')) + $this->_response->setBody(Class_Multimedia_Users::getInstance()->modifyUser($infoUser)); + + } + + public function deleteBorrowerAction() { + + if($infoUser = $this->checkInfoForAbonneAfim('Delete borrower multimedia start')) + $this->_response->setBody(Class_Multimedia_Users::getInstance()->deleteUser($infoUser)); + } + + + private function checkInfoForAbonneAfim($info){ + $this->_helper->getHelper('viewRenderer')->setNoRender(); + $multimedia = Class_Multimedia::getInstance(); $log = $multimedia->getLog(); - $log->info('Create borrower multimedia start'); + $log->info($info); - $this->_helper->getHelper('viewRenderer')->setNoRender(); if (null == ($json = $this->_getParam('json'))) { $log->err('Missing json parameter'); @@ -121,7 +143,9 @@ class Push_MultimediaController extends Zend_Controller_Action { return; } - $this->_response->setBody(Class_Multimedia_Users::getInstance()->createUser($infoUser)); + return $infoUser; + } + } ?> \ No newline at end of file diff --git a/application/modules/telephone/controllers/AbonneController.php b/application/modules/telephone/controllers/AbonneController.php index d96639cb8b901cef2c7d8650408f51a9eec97ca0..c5489af89f5aaeda7536d3ededae1ed549287ac0 100644 --- a/application/modules/telephone/controllers/AbonneController.php +++ b/application/modules/telephone/controllers/AbonneController.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once ROOT_PATH.'application/modules/opac/controllers/AbonneController.php'; @@ -46,9 +46,9 @@ class Telephone_AbonneController extends AbonneController { return; } - $this->_detectReservation($fiche_sigb['fiche']->getReservations()); + $this->_detectReservation($this->_user->getReservations()); - if ($this->view->resa + if ($this->view->resa && $this->_getParam('confirmed')) { $sigb = new Class_CommSigb(); $sigb->supprimerReservation($this->_user, $this->view->resa->getId()); diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index 075e1a42ad4c17d4560f0c0434b25b7e52a02a9d..b6078adc8a752c875bc90d969b1311ea97ba3597 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once ROOT_PATH.'application/modules/opac/controllers/RechercheController.php'; @@ -100,7 +100,7 @@ class Telephone_RechercheController extends RechercheController { $this->_loadReservationParamsFromSession(); - if (Class_CosmoVar::isSiteRetraitResaEnabled() + if (Class_CosmoVar::isSiteRetraitResaChoiceEnabled() && !$this->_getParam('pickup')) { $this->_redirect(sprintf('/recherche/pickup-location/b/%s/e/%s/a/%s', urlencode($this->_getParam('b')), @@ -110,8 +110,8 @@ class Telephone_RechercheController extends RechercheController { } $ret = Class_CommSigb::getInstance() - ->reserverExemplaire($this->_getParam('b'), - $this->_getParam('e'), + ->reserverExemplaire($this->_getParam('b'), + $this->_getParam('e'), ($this->_getParam('pickup')) ? $this->_getParam('pickup') : $this->_getParam('a')); if (isset($ret["erreur"]) && '' != $ret['erreur']) { @@ -181,7 +181,7 @@ class Telephone_RechercheController extends RechercheController { public function frbrAction() { - $this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id')); + $this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id')); } @@ -221,4 +221,3 @@ class Telephone_RechercheController extends RechercheController { ->setParam('e', $params['e']) ->setParam('a', $params['a']); }} - diff --git a/application/modules/telephone/views/scripts/abonne/fiche.phtml b/application/modules/telephone/views/scripts/abonne/fiche.phtml index 2a5e9f6ca4858d2e19935f29659ef80c39e527f2..edeb871e1d2402cf4f19c94d93fc062a8e92278a 100644 --- a/application/modules/telephone/views/scripts/abonne/fiche.phtml +++ b/application/modules/telephone/views/scripts/abonne/fiche.phtml @@ -2,106 +2,104 @@ <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <?php if ($this->messages) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <?php foreach($this->messages as $message) { ?> - <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($message);?></a></li> - <?php } ?> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <?php foreach($this->messages as $message) { ?> + <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($message);?></a></li> + <?php } ?> + </ul> + </div> <?php } ?> -<?php +<?php if ($this->user->isAbonne()) { $date_fin = formatDate($this->user->getDateFin(), '1'); $message = ($this->user->isAbonnementValid()) ? - "Votre abonnement est valide jusqu'au %s." : - "Votre abonnement est terminé depuis le %s."; + "Votre abonnement est valide jusqu'au %s." : + "Votre abonnement est terminé depuis le %s."; ?> -<ul data-role="listview"> - <li data-role="list-divider"><?php echo $this->_('Abonnement');?></li> - <li><?php echo $this->_($message, $date_fin);?></li> -</ul> + <ul data-role="listview"> + <li data-role="list-divider"><?php echo $this->_('Abonnement');?></li> + <li><?php echo $this->_($message, $date_fin);?></li> + </ul> <?php } ?> -<?php +<?php $fiche_sigb = $this->user->getFicheSigb(); if (array_key_exists("erreur", $fiche_sigb)) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <li><a href="#" data-icon="alert" data-theme="a"><?php echo $this->escape($fiche_sigb["erreur"]);?></a></li> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <li><a href="#" data-icon="alert" data-theme="a"><?php echo $this->escape($fiche_sigb["erreur"]);?></a></li> + </ul> + </div> <?php } ?> <?php if (array_key_exists("message", $fiche_sigb)) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($fiche_sigb["message"]);?></a></li> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($fiche_sigb["message"]);?></a></li> + </ul> + </div> <?php } ?> -<?php -if (array_key_exists("fiche", $fiche_sigb)) { - $nb_retards = $fiche_sigb["fiche"]->getNbPretsEnRetard(); - $nb_prets = $fiche_sigb["fiche"]->getNbEmprunts(); - $nb_resas = $fiche_sigb["fiche"]->getNbReservations(); +<?php +$nb_retards = $this->user->getNbEmpruntsRetard(); +$nb_prets = $this->user->getNbEmprunts(); +$nb_resas = $this->user->getNbReservations(); ?> <ul data-role="listview" data-split-icon="forward"> <li data-role="list-divider"><?php echo $this->_('Prêts');?> - <span class="ui-li-count"><?php echo $nb_prets;?></span></li> -<?php if (0 < $nb_prets) { ?> - <?php foreach($fiche_sigb['fiche']->getEmprunts() as $emprunt) { - $class_retard = $emprunt->enRetard() ? 'pret_en_retard"' : '';?> - <li data-icon="false"> - <a <?php echo $emprunt->enRetard() ? 'style="color:red;"' : '';?> - href="<?php echo $this->url(array('controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $emprunt->getNoticeOPACId()));?>"> - <h3><?php echo $emprunt->getTitre();?></h3> - <p><strong><?php echo $this->escape($emprunt->getAuteur());?></strong></p> - <p><strong><?php echo $this->escape($emprunt->getBibliotheque());?></strong></p> - <p><strong><?php echo $this->_('Retour prévu');?> <?php echo $emprunt->getDateRetour();?></strong></p> - </a> - <?php if ($emprunt->isRenewable()) { ?> - <a href="<?php echo $this->url(array('action' => 'prolongerpret', - 'id_pret' => $emprunt->getId()));?>" - data-theme="c"><?php echo $this->_('Prolonger');?></a> + <span class="ui-li-count"><?php echo $nb_prets;?></span></li> + <?php if (0 < $nb_prets) { ?> + <?php foreach($this->user->getEmprunts() as $emprunt) { + $class_retard = $emprunt->enRetard() ? 'pret_en_retard"' : '';?> + <li data-icon="false"> + <a <?php echo $emprunt->enRetard() ? 'style="color:red;"' : '';?> + href="<?php echo $this->url(array('controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $emprunt->getNoticeOPACId()));?>"> + <h3><?php echo $emprunt->getTitre();?></h3> + <p><strong><?php echo $this->escape($emprunt->getAuteur());?></strong></p> + <p><strong><?php echo $this->escape($emprunt->getBibliotheque());?></strong></p> + <p><strong><?php echo $this->_('Retour prévu');?> <?php echo $emprunt->getDateRetour();?></strong></p> + </a> + <?php if ($emprunt->isRenewable()) { ?> + <a href="<?php echo $this->url(array('action' => 'prolongerpret', + 'id_pret' => $emprunt->getId()));?>" + data-theme="c"><?php echo $this->_('Prolonger');?></a> + <?php } ?> + </li> <?php } ?> - </li> + <?php } else { ?> + <li><?php echo $this->_('Vous n\'avez aucun prêt en cours');?></li> <?php } ?> -<?php } else { ?> - <li><?php echo $this->_('Vous n\'avez aucun prêt en cours');?></li> -<?php } ?> </ul> <ul data-role="listview" data-split-icon="delete"> <li data-role="list-divider"><?php echo $this->_('Réservations');?> - <span class="ui-li-count"><?php echo $nb_resas;?></span></li> -<?php if (0 < $nb_resas) { ?> - <?php foreach($fiche_sigb['fiche']->getReservations() as $reservation) { ?> - <li data-icon="false"> - <a href="<?php echo $this->url(array('controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $reservation->getNoticeOPACId()));?>"> - <h3><?php echo $reservation->getTitre();?></h3> - <p><strong><?php echo $this->escape($reservation->getAuteur());?></strong></p> - <p><strong><?php echo $this->escape($reservation->getBibliotheque());?></strong></p> - <p><?php echo $this->_('Etat') . ' : ' . $this->escape($reservation->getEtat());?>, - <?php echo $this->_('Rang') . ' : ' . $this->escape($reservation->getRang());?></p> - </a> - <a href="<?php echo $this->url(array('action' => 'cancel-hold', - 'id' => $reservation->getId()));?>" - data-rel="dialog" data-theme="c" data-position="notext"> - <?php echo $this->_('Supprimer cette réservation');?></a> - </li> + <span class="ui-li-count"><?php echo $nb_resas;?></span></li> + <?php if (0 < $nb_resas) { ?> + <?php foreach($this->user->getReservations() as $reservation) { ?> + <li data-icon="false"> + <a href="<?php echo $this->url(array('controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $reservation->getNoticeOPACId()));?>"> + <h3><?php echo $reservation->getTitre();?></h3> + <p><strong><?php echo $this->escape($reservation->getAuteur());?></strong></p> + <p><strong><?php echo $this->escape($reservation->getBibliotheque());?></strong></p> + <p><?php echo $this->_('Etat') . ' : ' . $this->escape($reservation->getEtat());?>, + <?php echo $this->_('Rang') . ' : ' . $this->escape($reservation->getRang());?></p> + </a> + <a href="<?php echo $this->url(array('action' => 'cancel-hold', + 'id' => $reservation->getId()));?>" + data-rel="dialog" data-theme="c" data-position="notext"> + <?php echo $this->_('Supprimer cette réservation');?></a> + </li> + <?php } ?> + <?php } else { ?> + <li><?php echo $this->_('Vous n\'avez aucune réservation en cours');?></li> <?php } ?> -<?php } else { ?> - <li><?php echo $this->_('Vous n\'avez aucune réservation en cours');?></li> -<?php } ?> </ul> -<?php } ?> \ No newline at end of file diff --git a/application/modules/telephone/views/scripts/abonne/prets.phtml b/application/modules/telephone/views/scripts/abonne/prets.phtml index c7677ee8b24a0b70c1a13965939e4f7ded2816d3..439bdfefb3c861ce310761aee01fda5de4f7eb7e 100644 --- a/application/modules/telephone/views/scripts/abonne/prets.phtml +++ b/application/modules/telephone/views/scripts/abonne/prets.phtml @@ -1,11 +1,11 @@ <?php echo $this->toolbar($this->_('Prêts'));?> <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <ul data-role="listview" data-inset="true"> -<?php -foreach ($this->fiche["fiche"]->getEmprunts() as $emprunt) { +<?php +foreach ($this->user->getEmprunts() as $emprunt) { echo sprintf('<li>%s</li>', $emprunt->getTitre()); } ?> -</ul> \ No newline at end of file +</ul> diff --git a/application/modules/telephone/views/scripts/abonne/reservations.phtml b/application/modules/telephone/views/scripts/abonne/reservations.phtml index 15535d55891158fa8876f2056d60cbb2e752e846..98b3b37ec092da3c0a11ae49071d8f40aaf3c2af 100644 --- a/application/modules/telephone/views/scripts/abonne/reservations.phtml +++ b/application/modules/telephone/views/scripts/abonne/reservations.phtml @@ -1,10 +1,10 @@ <?php echo $this->toolbar($this->_('Réservations'));?> <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <ul data-role="listview" data-inset="true"> -<?php -foreach ($this->fiche["fiche"]->getReservations() as $reservation) { +<?php +foreach ($this->user->getReservations() as $reservation) { echo sprintf('<li>%s</li>', $reservation->getTitre()); } ?> -</ul> \ No newline at end of file +</ul> diff --git a/build.sh b/build.sh index 069c28656b7eeacd5fcf4386a722e8e106bef6d3..0b5d611865ce06f89cf7a5ddba1836a66302c31e 100755 --- a/build.sh +++ b/build.sh @@ -6,4 +6,12 @@ sed -i "s/sgbd.config.password =/sgbd.config.password = opac/g" config.ini sed -i "s/sgbd.config.dbname =/sgbd.config.dbname = opac/g" config.ini touch local.php php scripts/upgrade_db.php -phpunit -c tests/phpunit.xml --exclude-group no-ci + +cd cosmogramme +cp config.ref.php config.php +sed -i "s/integration_user=root/integration_user=opac/g" config.php +sed -i "s/integration_pwd=root/integration_pwd=opac/g" config.php +sed -i "s/integration_base=opac3/integration_base=opac/g" config.php +cd .. + +phpunit -c tests/phpunit.xml --exclude-group no-ci && cd cosmogramme/tests && phpunit --exclude-group no-ci diff --git a/ckeditor/config.js b/ckeditor/config.js index 8d5398e3c8056597f4c6438728f9bfef76bc472f..4f7f5fbad57c18bfdebfc07109205b95a61c44bf 100644 --- a/ckeditor/config.js +++ b/ckeditor/config.js @@ -47,7 +47,6 @@ CKEDITOR.editorConfig = function( config ) config.templates_replaceContent = false; config.bodyClass = 'boiteMilieu ckeditor_content'; - // Toolbar par défaut: // config.toolbar_Full = //[ diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php new file mode 100644 index 0000000000000000000000000000000000000000..5ad208a1136953d84050d0f3d6ddcded430669e6 --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php @@ -0,0 +1,106 @@ +<?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 Cosmo_FacetsController extends Zend_Controller_Action { + use Trait_Translator; + public function preDispatch() { + $this->cosmoPath = $this->view->cosmoPath = new CosmoPaths(); + } + + + public function indexAction() { + $this->view->models = Class_CodifThesaurus::findAllBy(['rules not' => null, + 'order' => 'libelle']); + $this->view->currentId = $this->_getParam('id'); + } + + + public function addAction() { + $this->view->model = Class_CodifThesaurus::newInstance([ + 'libelle_facette' => '** nouvelle facette **', + 'rules' => json_encode(['label' => $this->_getParam('rules')])]); + } + + + public function validateAction() { + if (!$this->_request->isPost()) { + $this->_gotoIndex(); + return; + } + + if (!$model = Class_CodifThesaurus::find($this->_getParam('id'))) + $model = Class_CodifThesaurus::newInstance(); + + $model + ->setLibelle($this->_getParam('libelle_facette')) + ->setLibelleFacette($this->_getParam('libelle_facette')) + ->setRules(json_encode(['label' => $this->_getParam('rules')])); + + if (!$model->isValid()) { + $this->view->model = $model; + $this->view->errors = $model->getErrors(); + $this->render('add'); + return; + } + + if (!$model->getIdThesaurus()) { + $libelle = preg_replace('/[^a-zA-Z0-9]/', '', $this->_getParam('libelle_facette')); + $libelle = substr($libelle, 0, 4); + $id_thesaurus = $this->generateNewIdThesaurusForLabel($libelle); + $model->setIdThesaurus($id_thesaurus); + $model->setCode($libelle); + } + + $model->save(); + $this->_gotoIndex($model->getId()); + } + + + protected function generateNewIdThesaurusForLabel($label) { + $suffixes = array_merge(range(0, 9), range('a', 'z')); + while(!empty($suffixes)) { + $suffix = strtoupper(array_shift($suffixes));; + $id = sprintf("%'".$suffix."-4s", strtoupper($label)); + if (!Class_CodifThesaurus::findFirstBy(['id_thesaurus' => $id])) + return $id; + } + } + + + public function deleteAction() { + if ($model = Class_CodifThesaurus::find($this->_getParam('id'))) + $model->delete(); + $this->_gotoIndex(); + } + + + protected function _gotoIndex($id=null) { + $this->_redirect($this->view->url([ + 'module' => 'cosmo', + 'controller' => 'facets', + 'action' => 'index', + 'id' => $id + ], null, true), + ['prependBase' => false]); + } +} +?> diff --git a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/add.phtml b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/add.phtml new file mode 100644 index 0000000000000000000000000000000000000000..d5705fe1380d93f8f930ca3d4d23b75a66c9214b --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/add.phtml @@ -0,0 +1,19 @@ +<?php $model = $this->model; ?> +<h1>Codification des facettes dynamiques</h1> +<div class="liste"> + <?php if ($this->errors) { ?> + <ul style="color:red;font-weight:bolder;"> + <?php foreach ($this->errors as $error) { ?> + <li><?php echo $this->escape($error);?></li> + <?php } ?> + </ul> + <?php } ?> + <?php echo $this->cosmoFacets($this->model, true); ?> +</div> +<br/><br/> + +<?php +echo $this->cosmoButton('Retour', + $this->url(['module' => 'cosmo', 'controller' => 'facets'], + null, true)); +?> diff --git a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/index.phtml b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/index.phtml new file mode 100644 index 0000000000000000000000000000000000000000..0023585f7d9481754ae3206e69fb5d5ba9f8eaf4 --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/facets/index.phtml @@ -0,0 +1,29 @@ +<h1>Facettes dynamiques</h1> +<div class="liste"> + <?php + foreach($this->models as $model) { + $img = 'plus.gif'; + $display = false; + if ($model->getId() == $this->currentId) { + $img = 'moins.gif'; + $display = true; + } + ?> + <div class="liste_img"> + <?php echo $this->tagImg($this->cosmoPath->getCosmoBaseUrl() . 'images/'.$img, + ['id' => 'Ifacet' . $model->getId(), + 'style' => 'cursor:pointer', + 'onclick' => 'contracter_bloc(\'facet'.$model->getId().'\')']);?> + </div> + <div class="liste_titre"><?php echo $model->getLibelleFacette();?></div> + <?php echo $this->cosmoFacets($model, $display); ?> + <?php } ?> +</div> + +<br/><br/> +<?php +echo $this->cosmoButton('Ajouter une facette dynamique', + $this->url(['module' => 'cosmo', + 'controller' => 'facets', + 'action' => 'add'], null, true)); +?> diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3bc761728f3eb7e16fd896a662cc8ce38f0d8043 --- /dev/null +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php @@ -0,0 +1,235 @@ +<?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 Cosmo_DynamicFacetsControllerTestCase extends CosmoControllerTestCase { + public function setUp() { + parent::setUp(); + $docu = $this->fixture('Class_CodifThesaurus', + ['id' => 3, + 'libelle' => 'Document', + 'libelle_facette' => 'Document', + 'id_thesaurus' => 'DOCU', + 'id_origine' => null, + 'code' => null, + 'rules' => '{"label":" 99$t "}']); + + } +} + + + + +class Cosmo_DynamicFacetsControllerIndexTest extends Cosmo_DynamicFacetsControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/cosmo/facets/index', true); + + } + + + /** @test */ + public function titleShouldBeDynamicFacets() { + $this->assertXpathContentContains('//h1' , 'Facettes dynamiques'); + + } + + + /** @test */ + public function addButtonShouldBePresent() { + $this->assertXpath('//input[contains(@onclick, "/cosmo/facets/add")]'); + } + + + /** @test */ + public function facetDocumentShouldBeDisplayed() { + $this->assertXpath('//form[contains(@action, "/cosmo/facets/validate/id/3")]'); + } + + + /** @test */ + public function facetsRulesShouldBePresent() { + $this->assertXpathContentContains('//textarea[@name="rules"]', '99$t',$this->_response->getBody()); + } + + + /** @test */ + public function facetDeleteButtonShouldBePresent() { + $this->assertXpath('//input[contains(@onclick, "/cosmo/facets/delete/id/3")]'); + } +} + + + +class Cosmo_DynamicFacetsControllerValidateAddPostTest extends Cosmo_DynamicFacetsControllerTestCase { + public function setUp() { + parent::setUp(); + $this->postDispatch( + '/cosmo/facets/validate/id/3', + [ + 'libelle_facette' => 'New facet name', + 'rules' => '88$a'] + ); + + $this->model = Class_CodifThesaurus::find(3); + } + + + /** @test */ + public function labelShouldBeNewFaceName() { + $this->assertEquals('New facet name', $this->model->getLibelle()); + } + + + /** @test */ + public function idThesaurusShouldNotBeModifiedIfAlreadyExist() { + $this->assertEquals('DOCU', $this->model->getIdThesaurus()); + } + + /** @test */ + public function rulesShouldBeDollarXEqualsZeroSeven() { + $this->assertEquals('88$a', $this->model->getRulesLabel()); + } + +} + + + + +class Cosmo_DynamicFacetsControllerValidatePostWithErrorsTest extends Cosmo_DynamicFacetsControllerTestCase { + public function setUp() { + parent::setUp(); + $this->postDispatch( + '/cosmo/facets/validate/id/3', + [ + 'libelle_facette' => '', + 'rules' => '33']); + + $this->model = Class_CodifThesaurus::find(3); + } + + + public function errorsProvider() { + return [ + ['Vous devez définir le libellé'], + ['La règle n\'est pas de la forme 686$a']]; + } + + + /** + * @test + * @dataProvider errorsProvider + */ + public function errorShouldBePresent($message) { + $this->assertXpathContentContains('//li', $message, $this->_response->getBody()); + } + + + /** @test */ + public function labelShouldNotBeSaved() { + $this->assertTrue($this->model->hasChangedAttribute('libelle')); + } + + + /** @test */ + public function rulesShouldNotBeSaved() { + $this->assertTrue($this->model->hasChangedAttribute('rules')); + } +} + + + + +class Cosmo_DynamicFacetsControllerValidateTest extends Cosmo_DynamicFacetsControllerTestCase { + /** @test */ + public function idThesaurusShouldBeDOC0() { + $this->postDispatch( + '/cosmo/facets/validate', + ['libelle_facette' => 'doc', + 'rules' => '33$2']); + + $this->assertEquals('DOC0', + Class_CodifThesaurus::findFirstBy(['libelle'=>'doc'])->getIdThesaurus()); + } + + + /** @test */ + public function withExistingIdThesaurusDOCXNewIdThesaurusShouldBeDOC1() { + $this->fixture('Class_CodifThesaurus', + ['libelle' => 'doc that i love', + 'id_thesaurus' => 'DOC0', + 'rules' => '{"label":" 345$t "}']); + + $this->postDispatch( + '/cosmo/facets/validate', + ['libelle_facette' => 'doc', + 'rules' => '33$2']); + + $this->assertEquals('DOC1', + Class_CodifThesaurus::findFirstBy(['libelle'=>'doc'])->getIdThesaurus()); + + } + + + /** @test */ + public function withSpecialCharsNewIdThesaurusShouldBeFourLetters() { + $this->postDispatch( + '/cosmo/facets/validate', + ['libelle_facette' => 'Année top 5', + 'rules' => '66$6']); + + + $this->assertEquals('ANNE', + Class_CodifThesaurus::findFirstBy(['libelle'=>'Année top 5'])->getIdThesaurus()); + } +} + + + + +class Cosmo_DynamicFacetsControllerAddTest extends Cosmo_DynamicFacetsControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/cosmo/facets/add', true); + } + + + /** @test */ + public function titleShouldBePresent() { + $this->assertXpathContentContains('//h1', 'Codification des facettes dynamiques'); + } + + + /** @test */ + public function formActionShouldGoToValidate() { + $this->assertXpath('//form[contains(@action, "/cosmo/facets/validate")]'); + } + + + /** @test */ + public function labelShouldDefaultToNouvelleFacette() { + $this->assertXpath('//input[@name="libelle_facette"][@value="** nouvelle facette **"]'); + } +} + + + +?> \ No newline at end of file diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php index 07b8972cdb9f3681966dfd771367ae788e00ff97..bfa86a10728f6bd5dfb31eb129735faaa898fd22 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php @@ -36,7 +36,7 @@ abstract class Cosmo_IntegrationControllerControlActionTestCase extends CosmoCon parent::setUp(); Class_IntBib::beVolatile(); Class_Cosmogramme_Integration::beVolatile(); - Class_Cosmogramme_ProfilDonnees::beVolatile(); + Class_IntProfilDonnees::beVolatile(); $this->file_system = $this->mock(); Class_Cosmogramme_Integration::setFileSystem($this->file_system); @@ -80,7 +80,7 @@ class Cosmo_IntegrationControllerControlActionWithBibTest extends Cosmo_Integrat ->whenCalled('filesize')->answers(1024) ; - $profil = $this->fixture('Class_Cosmogramme_ProfilDonnees', + $profil = $this->fixture('Class_IntProfilDonnees', ['id' => 1, 'type_fichier' => 1]); diff --git a/cosmogramme/php/_identification.php b/cosmogramme/php/_identification.php index c60e3776711dccef7f8760f2e3204db28e42d5c9..eadc16ccd1218232eb6ec350e0369ee63f76df04 100644 --- a/cosmogramme/php/_identification.php +++ b/cosmogramme/php/_identification.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 */ if(isset($_REQUEST["admin_login"])) diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 6fd16e323e0bc358b67aa55c9ef1f3b000b19706..ca9c0b6f1e3cd0387aa84d3dbfef5fb982cbceda 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -1,8 +1,7 @@ <?php -// Constantes error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","241"); +define("PATCH_LEVEL","256"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); @@ -33,25 +32,22 @@ date_default_timezone_set('Europe/Paris'); require_once 'classe_cosmopaths.php'; $cosmo_path = new CosmoPaths(); -$site = '/' . $cosmo_path->getSite() . '/'; $cfgfile = $cosmo_path->getConfigPath(); -define('BASE_URL', $cosmo_path->getBaseUrl()); -define('USERFILESPATH', $cosmo_path->getUserfilesPath()); - - -define("URL_BASE", $site . APPLI . "/"); -define("URL_IMG", URL_BASE . "images/"); - - require_once("fonctions/fonctions_base.php"); require_once("fonctions/string.php"); require_once("fonctions/erreur.php"); require_once("fonctions/date_heure.php"); require_once("fonctions/variables.php"); +define('BASE_URL', $cosmo_path->getBaseUrl()); +define('USERFILESPATH', $cosmo_path->getUserfilesPath()); + require_once($basePath.'/../storm_init.php'); +define("URL_BASE", $cosmo_path->getCosmoBaseUrl()); +define("URL_IMG", URL_BASE . "images/"); + require_once("classe_sql.php"); require_once("fonctions/sql.php"); diff --git a/cosmogramme/php/_menu.php b/cosmogramme/php/_menu.php index 139beef52dad21733ce067f8dbc179ff4cfb0655..d5897758d77f8bf342647929cb9ff424b7db90bc 100644 --- a/cosmogramme/php/_menu.php +++ b/cosmogramme/php/_menu.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 */ ////////////////////////////////////////////////////////////////////////////////////////// // MENU GAUCHE @@ -107,6 +107,7 @@ else ligneMenu("Matières","codif_matiere.php"); ligneMenu("Indices Dewey","codif_dewey.php"); ligneMenu("Indices PCDM4","codif_pcdm4.php"); + ligneMenu("Facettes dynamiques","../cosmozend/cosmo/facets/index"); ?> <div class="menu_section">Statistiques</div> <?php diff --git a/cosmogramme/php/classes/classe_cosmopaths.php b/cosmogramme/php/classes/classe_cosmopaths.php index 1b601c610fb0d9a4d1f4ca0ac12e1b1d2a699975..7c39f13342e47a38641a545914394fd3c5ea4cc8 100644 --- a/cosmogramme/php/classes/classe_cosmopaths.php +++ b/cosmogramme/php/classes/classe_cosmopaths.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 CosmoPaths { @@ -45,7 +45,7 @@ class CosmoPaths { public function getFilesystem() { require_once(realpath(dirname(__FILE__)).'/../../../library/Class/Testing/FileSystem.php'); - return null == $this->_filesystem + return null == $this->_filesystem ? new Class_Testing_FileSystem() : $this->_filesystem; } @@ -62,7 +62,16 @@ class CosmoPaths { public function getBaseUrl() { - return '/' . $this->getSite() . '/'; + if (!isset($_SERVER['SCRIPT_NAME'])) + return '/' . $this->getSite() . '/'; + + $parts = array_filter(explode('/', $_SERVER['SCRIPT_NAME'])); + while ((count($parts)>0) && (end($parts) !== self::COSMO_DIR_NAME)) + array_pop($parts); + array_pop($parts); + return $parts + ? '/' . implode('/', $parts) . '/' + : '/'; } @@ -83,10 +92,10 @@ class CosmoPaths { protected function getFilePath() { - if (isset($_SERVER['SCRIPT_FILENAME']) + if (isset($_SERVER['SCRIPT_FILENAME']) && false !== strpos($_SERVER['SCRIPT_FILENAME'], self::COSMO_DIR_NAME)) return $_SERVER['SCRIPT_FILENAME']; - + $current_path = $this->getFileSystem()->getcwd(); if (false !== strpos($current_path, self::COSMO_DIR_NAME)) return $current_path; diff --git a/cosmogramme/php/classes/classe_log.php b/cosmogramme/php/classes/classe_log.php index 64fbf93d2d82e7b3bf5350e1ecd258e4b06ddd7a..253b7503a1181b5e06ae389a930dc94301378495 100644 --- a/cosmogramme/php/classes/classe_log.php +++ b/cosmogramme/php/classes/classe_log.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 */ //////////////////////////////////////////////////////////////////////// // LOGS @@ -251,6 +251,11 @@ class Class_log { fclose($this->fic); } + + + public function addError($message) { + $this->ecrire('<br><span class="rouge">'.$message.'</span><br>'); + } } ?> \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 16d52290440b283878afbc9c3afc7867b1d47dc7..50732bc61215987984ca032d30ba52a8552a3cda 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -30,6 +30,10 @@ class notice_integration { const RECORD_RENEW = 5; const RECORD_UPDATE = 4; + const STATUS_NOTFOUND = 'non trouvée'; + + const SEARCH_MODE_ALPHAKEY = 1; + private $id_profil; // Id du profil de données initialisé private $format; // Format de fichier 0=unimarc private $id_article_periodique; // Mode d'indentification des articles de periodiques @@ -236,6 +240,7 @@ class notice_integration { public function traiteHomogene($id_notice, $isbn, $ean, $id_commerciale, $no_request) { global $sql; + // Appel du service $args["isbn"]=$isbn; $args["ean"]= $ean; @@ -247,13 +252,20 @@ class notice_integration { $ret["timeout"]=10; // Statut not found : Mise a jour nombre de retries - if($ret["statut_z3950"] == "1") $sql->execute("Update notices set z3950_retry = z3950_retry +1 Where id_notice=$id_notice"); + if ($ret["statut_z3950"] == '1') { + $notice = Class_Notice::find($id_notice); + $retry = $notice->getZ3950Retry() + 1; + $notice->setZ3950Retry($retry)->save(); + } // Statut ok : on remplace la notice if(!$this->analyseur) $this->analyseur=new notice_unimarc(); if($ret["statut_z3950"] > "1") { - $this->analyseur->ouvrirNotice($ret["unimarc"],1); + $this->analyseur->ouvrirNotice($ret["unimarc"], + $args['isbn'] + ? profil_donnees::HOMOGENIZATION_ISBN + : profil_donnees::HOMOGENIZATION_EAN); $this->notice=$this->analyseur->getNoticeIntegration(); $qualite=getVariable("homogene_code_qualite"); $this->updateNotice($id_notice,$qualite); @@ -421,81 +433,71 @@ class notice_integration { private function chercheNotice() { - global $sql; - $id_bib = $this->id_bib; + $attributes = []; + if(!$this->mode_doublon) + $attributes = [['isbn', $this->notice['isbn13']], + ['isbn', $this->notice['isbn10']], + ['ean', $this->notice['ean']], + ['id_commerciale', $this->notice['id_commerciale']]]; - if(!$this->mode_doublon) { - $isbn10=$this->notice["isbn10"]; - $isbn13=$this->notice["isbn13"]; - $ean=$this->notice["ean"]; - $id_commerciale=$this->notice["id_commerciale"]; - } - $clef_alpha=$this->notice["clef_alpha"]; + if ($this->mode_doublon == static::SEARCH_MODE_ALPHAKEY) + $attributes = [['clef_alpha', $this->notice['clef_alpha']]]; - $this->identification=array("statut"=>"non trouvée"); - if($this->notice["statut_exemplaires"]["nb_ex"]>0) - { - $unicite_codes_barres=getVariable("unicite_code_barres"); - if($unicite_codes_barres=="1") $condition=""; - else $condition='id_int_bib='.$this->id_int_bib.' and '; - foreach($this->notice["exemplaires"] as $ex) - { - $code_barres=$ex["code_barres"]; - if($code_barres >"")$id_notice=$sql->fetchOne("select id_notice from exemplaires where ".$condition." code_barres='$code_barres'"); - if($id_notice) - { - $this->identification["statut"]="code_barres"; - $this->identification["code_barres"]=$id_notice; - break; - } - } - } - if($isbn10) - { - $this->identification["isbn"]=$sql->fetchOne("select id_notice from notices where isbn='$isbn10'"); - if(!$id_notice and $this->identification["isbn"]) - { - $this->identification["statut"]="isbn"; - $id_notice=$this->identification["isbn"]; - } - } - if($isbn13 and !$this->identification["isbn"]) - { - $this->identification["isbn"]=$sql->fetchOne("select id_notice from notices where isbn='$isbn13'"); - if(!$id_notice and $this->identification["isbn"]) - { - $this->identification["statut"]="isbn"; - $id_notice=$this->identification["isbn"]; - } - } - if($ean) - { - $this->identification["ean"]=$sql->fetchOne("select id_notice from notices where ean='$ean'"); - if(!$id_notice and $this->identification["ean"]) - { - $this->identification["statut"]="ean"; - $id_notice=$this->identification["ean"]; - } + $this->identification = ['statut' => static::STATUS_NOTFOUND]; + + if ($id_notice = $this->searchRecordByItemsBarcodes()) { + $this->identification['statut'] = 'code_barres'; + $this->identification['code_barres'] = $id_notice; + + return $id_notice; } - if($id_commerciale and !$ean) - { - $this->identification["id_commerciale"]=$sql->fetchOne("select id_notice from notices where id_commerciale='$id_commerciale'"); - if(!$id_notice and $this->identification["id_commerciale"]) - { - $this->identification["statut"]="id_commerciale"; - $id_notice=$this->identification["id_commerciale"]; + + foreach ($attributes as $attr) { + list($key, $value) = $attr; + + if ($id_notice = $this->searchRecordBy($key, $value)) { + $this->identification['statut'] = $key; + $this->identification[$key] = $id_notice; + + return $id_notice; } } - if($this->mode_doublon==1) - { - if (!$id_notice && $matching_notice = Class_Notice::findFirstBy(['clef_alpha' => $clef_alpha])) { - $this->identification["clef_alpha"] = $id_notice = $matching_notice->getId(); - $this->identification["statut"]="clef_alpha"; - } + + return ''; + } + + + private function searchRecordByItemsBarcodes() { + if ($this->notice['statut_exemplaires']['nb_ex'] <= 0) + return ''; + + $unicite_codes_barres = getVariable('unicite_code_barres'); + $condition = []; + + if ($unicite_codes_barres == '1') + $condition['id_int_bib'] = $this->id_int_bib; + + foreach ($this->notice['exemplaires'] as $ex) { + if (!$ex['code_barres'] > '') + continue; + + $condition['code_barres'] = $ex['code_barres']; + if ($exemplaire = Class_Exemplaire::findFirstBy($condition)) + return $exemplaire->getIdNotice(); } - if(!$id_notice)$this->identification["statut"]="non trouvée"; - return $id_notice; + return ''; + } + + + private function searchRecordBy($key, $value) { + if (!$value) + return ''; + + if (!$notice = Class_Notice::findFirstBy([$key => $value])) + return ''; + + return $notice->getId(); } @@ -926,8 +928,10 @@ class notice_integration { if($this->notice["statut"]==1) { $this->statut=2; - if($clef_unimarc) $controle=$sql->execute("delete from notices_articles where clef_unimarc='$clef_unimarc'"); - else $controle=$sql->execute("delete from notices_articles where clef_chapeau='$clef_chapeau' and clef_numero='$clef_numero' and clef_article='$clef_article'" ); + if($clef_unimarc) + $controle=$sql->execute("delete from notices_articles where clef_unimarc='$clef_unimarc'"); + else + $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; @@ -968,7 +972,8 @@ class notice_integration { } else { - $sql->insert("notices_articles",$enreg); + Class_Notice_SerialArticles::newInstance($enreg)->save(); + Class_Notice_SerialArticles::clearCache(); $this->statut=1; } } diff --git a/cosmogramme/php/classes/classe_profil_donnees.php b/cosmogramme/php/classes/classe_profil_donnees.php index 9301ff5a8371a01428f7e8ae40224c49ee72c029..73d07c562279eda7a333e3e965df31aa4be4e735 100644 --- a/cosmogramme/php/classes/classe_profil_donnees.php +++ b/cosmogramme/php/classes/classe_profil_donnees.php @@ -20,6 +20,10 @@ */ class profil_donnees { + const + HOMOGENIZATION_ISBN = -1, + HOMOGENIZATION_EAN = -2; + private $id_profil; // Id sgbd private $libelle; // Libellé du profil private $rejet_periodiques; // Rejet des periodiques dans les imports @@ -134,7 +138,7 @@ class profil_donnees { $this->id_article_periodique=0; $this->type_fichier=0; $this->format=1; - if($id_profil == -1) { + if($id_profil == self::HOMOGENIZATION_ISBN) { $this->libelle="Homogénéisation d'isbn"; $this->attributs[1]["champs"]="isbn"; } else { diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index 9b3190d688708b8c6cfc09eb1f27250dd10c1629..f8ccc45faedc9a2f07df68de4c38d6705680c0b2 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -126,7 +126,7 @@ class notice_unimarc extends iso2709_record { $notice["clef_oeuvre"] = $this->getClefAlpha(true); $notice["clef_chapeau"] = $this->getClefChapeau(); $notice["titre_princ"] = $this->getTitrePrincipal(); - $notice["tome_alpha"] = $this->getTome(); + $notice["tome_alpha"] = $this->indexation->alphaMaj($this->getTome()); $notice["alpha_titre"] = $this->indexation->codeAlphaTitre($notice["titre_princ"]." ".$notice["tome_alpha"]); $notice["id_commerciale"] = $this->getIdCommerciale($notice["alpha_titre"]); $notice["titres"] = $this->getTitres(); @@ -147,11 +147,9 @@ class notice_unimarc extends iso2709_record { $notice["dewey"] = $this->getDewey(); - if (defined('DEVELOPMENT')) { - $notice = $this->getThesauriAndPcdm4($notice); - } else { - $notice["pcdm4"] = $this->getPcdm4(); - } + $notice["thesauri"] = $this->getThesauri($notice); + $notice["pcdm4"] = $this->getPcdm4(); + $notice["cote"] = $this->getCote(); $notice["langues"] = $this->getLangues(); $notice["champs_forces"] = $this->getChampsForces(); @@ -203,7 +201,7 @@ class notice_unimarc extends iso2709_record { { // type de doc $notice["type_doc"] = 100; - $notice["infos_type_doc"] = array("code"=>100,libelle=>"article de périodique"); + $notice["infos_type_doc"] = ["code"=>100, 'libelle'=>"article de périodique"]; // statut $notice["statut"] = $this->getStatut(); @@ -1044,10 +1042,41 @@ class notice_unimarc extends iso2709_record { } - public function getThesauriAndPcdm4($notice) { + public function getThesauri($notice) { + return array_merge($this->_findThesauriIn686(), + $this->_findOtherThesauri()); + + } + + protected function _createThesauriFromLabels($labels,$thesaurus) { + $thesauri=[]; + foreach($labels as $label) { + $thesauri[] = $thesaurus->getOrCreateChild(strtoupper($label), + $label); + } + return $thesauri; + } + + + protected function _findOtherThesauri() { + $thesauri = []; + + $thesauri_definitions = Class_CodifThesaurus::findAllBy(['rules not' => null]); + foreach($thesauri_definitions as $thesaurus) { + $labels = $thesaurus->withLabelRulesDo( + function($field, $subfield) { + return $this->get_subfield($field, $subfield); + }); + $thesauri=array_merge($thesauri,$this->_createThesauriFromLabels($labels,$thesaurus)); + } + return $thesauri; + } + + + protected function _findThesauriIn686() { $thesaurus = []; $data = $this->get_subfield('686'); - $pcdm4 = null; + foreach($data as $items) { $sous_champs = $this->decoupe_bloc_champ($items); $code_thesaurus = null; @@ -1057,21 +1086,14 @@ class notice_unimarc extends iso2709_record { $id_origine = $item['valeur']; if ($item["code"] == "2") $code_thesaurus = trim($item['valeur']); + if ($code_thesaurus && $id_origine ) { - if ($code_thesaurus == "PCDM") { - $indice=pcdm4::filtreIndice($id_origine); - $pcdm4=$indice; - continue; - } - $thesaurus[] = Class_CodifThesaurus::findByIdOrigineAndCode($id_origine,$code_thesaurus); + $thesaurus[] = Class_CodifThesaurus::findByIdOrigineAndCode($id_origine, + $code_thesaurus); } } } - - $notice['thesauri'] = $thesaurus; - if ($pcdm4) - $notice['pcdm4'] = $pcdm4; - return $notice; + return $thesaurus; } diff --git a/cosmogramme/php/config_profil_donnees.php b/cosmogramme/php/config_profil_donnees.php index 20031a315d03f14c255e3598baaea0650b2009a6..77bd9a13337aaa4d4b3d86efda25d8af85649577 100644 --- a/cosmogramme/php/config_profil_donnees.php +++ b/cosmogramme/php/config_profil_donnees.php @@ -245,18 +245,21 @@ function paveAscii($profil) print('<div style="margin-right:5px;float:left">Sélectionnez un champ</div>'); // Combos de champs - if($profil["type_fichier"]<"1") $display="block"; else $display="none"; + if($profil["type_fichier"]<=Class_IntProfilDonnees::FT_RECORDS) $display="block"; else $display="none"; print('<div id="combo_type_0" style="float:left;display:'.$display.'">'.getComboCodif("","champs_ascii",0,$event)).'</div>'; - if($profil["type_fichier"]=="1" and $format !=4) $display="block"; else $display="none"; + if($profil["type_fichier"]==Class_IntProfilDonnees::FT_PATRONS and $format !=Class_IntProfilDonnees::FORMAT_XML) $display="block"; else $display="none"; print('<div id="combo_type_1" style="float:left;display:'.$display.'">'.getComboCodif("","champs_abonne",0,$event)).'</div>'; - if($profil["type_fichier"]=="2" and $format !=4) $display="block"; else $display="none"; + if($profil["type_fichier"]==Class_IntProfilDonnees::FT_LOANS and $format !=Class_IntProfilDonnees::FORMAT_XML) $display="block"; else $display="none"; print('<div id="combo_type_2" style="float:left;display:'.$display.'">'.getComboCodif("","champs_pret",0,$event)).'</div>'; - if($profil["type_fichier"]=="3" and $format !=4) $display="block"; else $display="none"; + if($profil["type_fichier"]==Class_IntProfilDonnees::FT_HOLDS and $format !=Class_IntProfilDonnees::FORMAT_XML) $display="block"; else $display="none"; print('<div id="combo_type_3" style="float:left;display:'.$display.'">'.getComboCodif("","champs_reservation",0,$event)).'</div>'; + if($profil["type_fichier"]==Class_IntProfilDonnees::FT_BASKETS and $format !=Class_IntProfilDonnees::FORMAT_XML) $display="block"; else $display="none"; + print('<div id="combo_type_4" style="float:left;display:'.$display.'">'.getComboCodif("","champs_panier",0,$event)).'</div>'; + print(' <input type="button" class="bouton" value="Effacer" onclick="selectChamp(\''.$id_champ.'\',\'\')">'); print('</td></tr>'); print('<tr>'); diff --git a/cosmogramme/php/integration/domaines.php b/cosmogramme/php/integration/domaines.php index 55924a8f0b5a86092d5c77083cbb5c430ad500c0..8363110a2deaa6dcdc6d36451514c257ff300091 100644 --- a/cosmogramme/php/integration/domaines.php +++ b/cosmogramme/php/integration/domaines.php @@ -23,7 +23,7 @@ ///////////////////////////////////////////////////////////////////////// require_once("classe_transaction.php"); setVariable("traitement_phase","Indexation des domaines"); -if ($phase==14) { +if ($phase==16) { $log->ecrire("<h4>Indexation des domaines</h4>"); unset($phase_data); $reprise=false; @@ -33,10 +33,10 @@ if ($phase==14) { $phase_data["pointeur"]=0; $phase_data["domaine"]=0; - $phase=15; + $phase=17; } -if ($phase==15) { +if ($phase==17) { $position_domaine=$phase_data["domaine"]; // Indexation des catalogues dynamiques $catalogues = array_slice(Class_Catalogue::findAllCataloguesAIndexer(),$position_domaine); diff --git a/cosmogramme/php/integration/facettes.php b/cosmogramme/php/integration/facettes.php deleted file mode 100644 index 08d5a8ca2a7f040a9d7fe617bc1c2192b08b8c8c..0000000000000000000000000000000000000000 --- a/cosmogramme/php/integration/facettes.php +++ /dev/null @@ -1,91 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -///////////////////////////////////////////////////////////////////////// -// CALCUL DES FACETTES -///////////////////////////////////////////////////////////////////////// - -setVariable("traitement_phase", "Mise à jour des facettes exemplaires"); -if ($phase == 7) { - $log->ecrire("<h4>Mise à jour des facettes exemplaires</h4>"); - unset($phase_data); - $phase_data["nombre"] = 0; - $phase_data["timeStart"] = time(); - $phase_data["pointeur_notice"]=0; - $phase_data["pointeur"]=getVariable('date_maj_facettes'); - if(!$phase_data["pointeur"]) $phase_data["pointeur"]='0000-00-00 00:00:00'; - $chrono100notices->start(); - $phase = 7.1; -} - -// Lancer requete -if ($phase == 7.1) { - if(!$mode_cron and $phase_data["pointeur_notice"] > 0) - print("<h4>Mise à jour des facettes exemplaires</h4>"); - - while(true) { - Storm_Model_Abstract::unsetLoaders(); - Zend_Db_Table::getDefaultAdapter()->closeConnection(); - setupDatabase(loadConfig()); - gc_collect_cycles(); - - $notices = Class_Notice::findAllBy([ - "where" => - "id_notice > ".$phase_data["pointeur_notice"] - ." and date_maj >='" . $phase_data["pointeur"]."'", - "order" => "id_notice", - "limit" => "1000"]); - if (!$notices) break; - - foreach ($notices as $notice) { - if (!$mode_cron and $chrono->tempsPasse() > $timeout) - sauveContexte(); - - $id_notice = $notice->getId(); - $last_date_maj = $notice->getDateMaj(); - - // si ressource num, les facettes sont déjà calculés dans pseudo notice - if (99 < $notice->getTypeDoc()) { - $phase_data["pointeur_notice"] = $id_notice; - $phase_data["nombre"]++; - if ($phase_data["nombre"] % 5000 == 0) { - print($phase_data["nombre"] . BR); - flush(); - } - continue; - } - - $notice - ->updateFacetsFromExemplaires() - ->save(); - - $phase_data["pointeur_notice"] = $id_notice; - $phase_data["nombre"]++; - if ($phase_data["nombre"] % 5000 == 0) { print($phase_data["nombre"] . BR); flush(); } - } - } - - setVariable('date_maj_facettes', $last_date_maj); - $log->ecrire('<span class="vert"> '.$phase_data['nombre'].' notices traitées.</span>').BR; - $log->ecrire('<span class="vert">Temps de traitement : ' . $chrono100notices->end() . " (" . $chrono100notices->moyenne($phase_data["nombre"], "notices") . ")</span>" . BR); - $phase = 8; -} -?> diff --git a/cosmogramme/php/integration/integration_phase.php b/cosmogramme/php/integration/integration_phase.php new file mode 100644 index 0000000000000000000000000000000000000000..0b1f6f6daae68c44d1099ac190cc7c3ace1ce4e2 --- /dev/null +++ b/cosmogramme/php/integration/integration_phase.php @@ -0,0 +1,53 @@ +<?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 + */ + +function startIntegrationPhase($name) { + global $chrono, $chrono_fichier, $chrono100notices, $phase, $phase_data, $mode_cron, $reprise, $log; + + $integration_class_name = 'Class_Cosmogramme_Integration_Phase'.ucfirst($name); + + // collect state from global scope + $current_chrono = Class_Cosmogramme_Integration_Chronometre::fromLegacyState($chrono, + $chrono_fichier, + $chrono100notices); + + $current_phase = Class_Cosmogramme_Integration_Phase::fromLegacyState($phase, + $phase_data, + $mode_cron, + $reprise); + + + $requested_phase = new $integration_class_name($current_phase, + $log, + $current_chrono); + + $new_phase = $requested_phase->run(); + +// reinject state into global scope + $current_chrono->backToLegacyState($chrono, $chrono_fichier, $chrono100notices); + $new_phase->backToLegacyState($phase, $phase_data, $mode_cron, $reprise); + + + if (!$mode_cron && $requested_phase->isTimeOut()) + sauveContexte(); +} + +?> \ No newline at end of file diff --git a/cosmogramme/php/integration/reservations.php b/cosmogramme/php/integration/reservations.php deleted file mode 100644 index c1c0b2f704285053d6ae5991506f5b7fec739440..0000000000000000000000000000000000000000 --- a/cosmogramme/php/integration/reservations.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// collect state from global scope -$current_chrono = Class_Cosmogramme_Integration_Chronometre::fromLegacyState($chrono, - $chrono_fichier, - $chrono100notices); -$current_phase = Class_Cosmogramme_Integration_Phase::fromLegacyState($phase, - $phase_data, - $mode_cron, - $reprise); - -// run phase -$phase_reservation = new Class_Cosmogramme_Integration_PhaseReservation($current_phase, - $log, - $current_chrono); -$new_phase = $phase_reservation->run(); - - -// reinject state into global scope -$current_chrono->backToLegacyState($chrono, $chrono_fichier, $chrono100notices); -$new_phase->backToLegacyState($phase, $phase_data, $mode_cron, $reprise); - - -if (!$mode_cron && $phase_reservation->isTimeOut()) - sauveContexte(); diff --git a/cosmogramme/php/integre_traite_main.php b/cosmogramme/php/integre_traite_main.php index 6d1d7ae1ec29472d43d061302f27feeaeafeff86..bd3f81fdf320534508c0d95e2d79373207357f0c 100644 --- a/cosmogramme/php/integre_traite_main.php +++ b/cosmogramme/php/integre_traite_main.php @@ -45,6 +45,7 @@ require_once 'classe_log.php'; require_once 'classe_notice_integration.php'; require_once 'classe_maj_auto.php'; require_once 'classe_bib.php'; +require_once 'integration/integration_phase.php'; // Instanciations $log = new Class_log('integration'); @@ -57,6 +58,9 @@ $parseur = new parseur(); $notice = new notice_integration(); $bib = new bibliotheque(); + + + // Initialisations $integration_path = getVariable('integration_path'); $debug_level = getVariable('debug_level'); @@ -404,7 +408,6 @@ if ($phase == 3) if ($homogene_actif == 0) { $log->ecrire('<span class="rouge">Le processus d\'homogénéisation des notices est désactivé</span>' . BR); - $phase = 7; } else { if ($ecart < $frequence) $log->ecrire('<span class="vert">Sera fait dans ' . ($frequence - $ecart) . ' jour(s)</span>'); @@ -479,7 +482,6 @@ if ($phase == 4) if ($homogene_actif == 0) { $log->ecrire('<span class="rouge">Le processus d\'homogénéisation des notices est désactivé</span>' . BR); - $phase = 7; } else { if ($ecart < $frequence) $log->ecrire('<span class="vert">Sera fait dans ' . ($frequence - $ecart) . ' jour(s)</span>'); @@ -545,7 +547,6 @@ if ($phase == 5) if ($homogene_actif == 0) { $log->ecrire('<span class="rouge">Le processus d\'homogénéisation des notices est désactivé</span>' . BR); - $phase = 7; } else { if ($ecart < $frequence) $log->ecrire('<span class="vert">Sera fait dans ' . ($frequence - $ecart) . ' jour(s)</span>'); @@ -593,15 +594,16 @@ if ($phase == 6 and $ecart >= $frequence and $homogene_actif == 1) } afficherRecapHomogene($phase_data, $chrono); setVariable("homogene_date", $date); - $phase = 7; -} -elseif ($phase == 6) $phase = 7; +}; // ---------------------------------------------------------------- // Recalcul des facettes bibliothèque (phases 7 et 7.1) // ---------------------------------------------------------------- -if (!$mode_cron and $chrono->tempsPasse() > 5) sauveContexte(); -if ($phase > 6 and $phase < 8) include("integration/facettes.php"); +if (!$mode_cron and $chrono->tempsPasse() > 5) + sauveContexte(); + +startIntegrationPhase('ItemFacets'); +$phase = 8; // ---------------------------------------------------------------- // Integration des abonnés @@ -622,11 +624,16 @@ if ($phase == 10 or $phase == 11) } if ($phase == 12 or $phase == 13) { - include("integration/reservations.php"); + startIntegrationPhase('Reservation'); $phase = 14; } if ($phase==14 or $phase==15) { + startIntegrationPhase('Panier'); + $phase = 16; +} + +if ($phase==16 or $phase==17) { include("integration/domaines.php"); $phase=20; } diff --git a/cosmogramme/sql/patch/patch_234.php b/cosmogramme/sql/patch/patch_234.php index 936e261818e8b7009188899ed77bb8e0c0fa844f..748565dc346c40807d2d767bf84738d2e8cec39c 100644 --- a/cosmogramme/sql/patch/patch_234.php +++ b/cosmogramme/sql/patch/patch_234.php @@ -7,7 +7,6 @@ $adapter->query('CREATE TABLE `patch_hash` ( ' . 'key (`value`)' . ') engine=MyISAM default charset=utf8'); - $migration = new Class_Migration_Patchs(); $patch_level = (int)Class_CosmoVar::get('patch_level'); $patches = $migration->getPatchesFilteredBy( @@ -16,3 +15,5 @@ $patches = $migration->getPatchesFilteredBy( }); foreach($patches as $script) $migration->hashScriptAndDo($script, function() { return true; }); + +?> diff --git a/cosmogramme/sql/patch/patch_235.php b/cosmogramme/sql/patch/patch_235.php index 3bd506bd755cfc6b7de46c7115f88717e578de4d..53e615e9a0b41a39a716a13b1154af5d7e5c8d15 100644 --- a/cosmogramme/sql/patch/patch_235.php +++ b/cosmogramme/sql/patch/patch_235.php @@ -1,4 +1,10 @@ <?php -$adapter = Zend_Db_Table::getDefaultAdapter(); -$adapter->query('alter table multimedia_location add column `autohold_for_closing_days` tinyint(3) unsigned DEFAULT "0"'); -?> +$adapter = Zend_Registry::get('sql'); +$default_adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $default_adapter->query("SELECT autohold_for_closing_days FROM multimedia_location LIMIT 1"); +} catch (Exception $e) { + $adapter->query("ALTER IGNORE TABLE `multimedia_location` ADD COLUMN `autohold_for_closing_days` tinyint(3) unsigned DEFAULT 0;"); +} +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_236.php b/cosmogramme/sql/patch/patch_236.php index 4d4aceb1c359bb091adca4d86496d9f8a896b53c..2755cc14d5ba1d7fff9e755ca5e4679b795ef5dd 100644 --- a/cosmogramme/sql/patch/patch_236.php +++ b/cosmogramme/sql/patch/patch_236.php @@ -1,8 +1,8 @@ <?php - $adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $adapter->query("ALTER TABLE album MODIFY genre varchar(100) NULL default ''"); $adapter->query("ALTER TABLE album MODIFY matiere varchar(100) NULL default ''"); $adapter->query("ALTER TABLE album MODIFY nature_doc varchar(50) NULL default ''"); $adapter->query("ALTER TABLE album MODIFY dewey varchar(100) NULL default ''"); $adapter->query("ALTER TABLE album MODIFY tags text NULL default ''"); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_242.php b/cosmogramme/sql/patch/patch_242.php new file mode 100644 index 0000000000000000000000000000000000000000..c4239c7dcc4542b40df8bf48b4cdaf0e49093f30 --- /dev/null +++ b/cosmogramme/sql/patch/patch_242.php @@ -0,0 +1,10 @@ +<?php +Zend_Registry::get('sql')->query('CREATE TABLE `album_item` ( ' + . 'id int(11) unsigned not null auto_increment,' + . 'album_id int(11) unsigned not null,' + . 'loan_count int(11) not null,' + . 'quantity int(11) not null,' + . 'primary key (id),' + . 'key (`album_id`)' + . ') engine=MyISAM default charset=utf8'); +?> diff --git a/cosmogramme/sql/patch/patch_243.php b/cosmogramme/sql/patch/patch_243.php new file mode 100644 index 0000000000000000000000000000000000000000..c53f43d24ad4208102f45aa54115d74b7c6a131c --- /dev/null +++ b/cosmogramme/sql/patch/patch_243.php @@ -0,0 +1,13 @@ +<?php +Zend_Registry::get('sql')->query('CREATE TABLE `loan_pnb` ( ' + . 'id int(11) unsigned not null auto_increment,' + . 'record_origin_id varchar(50) not null,' + . 'subscriber_id varchar(20) not null,' + . 'user_id int not null,' + . 'ongoing boolean not null,' + . 'expected_return_date datetime not null,' + . 'loan_date datetime not null,' + . 'loan_link text not null,' + . 'primary key (id)' + . ') engine=MyISAM default charset=utf8'); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_244.php b/cosmogramme/sql/patch/patch_244.php new file mode 100644 index 0000000000000000000000000000000000000000..a8a31f1565d374ba1d348e984a4b43288c114aac --- /dev/null +++ b/cosmogramme/sql/patch/patch_244.php @@ -0,0 +1,4 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); +$adapter->query('alter table bib_admin_profil modify TITRE_SITE varchar(100) not null'); +?> diff --git a/cosmogramme/sql/patch/patch_245.php b/cosmogramme/sql/patch/patch_245.php new file mode 100644 index 0000000000000000000000000000000000000000..f955190452f70fb0e823054a276d7bab07d9df62 --- /dev/null +++ b/cosmogramme/sql/patch/patch_245.php @@ -0,0 +1,4 @@ +<?php +Zend_Db_Table::getDefaultAdapter() + ->query('alter table codif_thesaurus add column rules varchar(250)'); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_246.php b/cosmogramme/sql/patch/patch_246.php new file mode 100644 index 0000000000000000000000000000000000000000..a581b111a7cf51a74aa3cd03174432c191a7d5be --- /dev/null +++ b/cosmogramme/sql/patch/patch_246.php @@ -0,0 +1,28 @@ +<?php +$adapter = Zend_Registry::get('sql'); + +$adapter->query("CREATE TABLE IF NOT EXISTS `permission` ( id INT(11) unsigned NOT NULL AUTO_INCREMENT, code varchar(255) NOT NULL, module varchar(255) NOT NULL, type varchar(255) NOT NULL, sorting int(11) NOT NULL, description text NULL, PRIMARY KEY (id), KEY (code), KEY (module), KEY (type), KEY (sorting)) ENGINE = MYISAM, character set=UTF8;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'CATEGORY', 'ARTICLE', 'Droits', 1, 'Créer des sous-catégories et des articles' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'CATEGORY') LIMIT 1;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'ARTICLE', 'ARTICLE', 'Droits', 2, 'Créer des articles' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'ARTICLE') LIMIT 1;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'PENDING', 'ARTICLE', 'Nouveaux statuts autorisés', 1, 'À valider' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'PENDING') LIMIT 1;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'VALIDATED', 'ARTICLE', 'Nouveaux statuts autorisés', 101, 'Validé' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'VALIDATED') LIMIT 1;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'REFUSED', 'ARTICLE', 'Nouveaux statuts autorisés', 102, 'Refusé' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'REFUSED') LIMIT 1;"); + +$adapter->query("insert into `permission` (code, module, type, sorting, description) SELECT 'ARCHIVED', 'ARTICLE', 'Nouveaux statuts autorisés', 103, 'Archivé' from `permission` WHERE NOT EXISTS (SELECT * FROM `permission` WHERE code = 'ARCHIVED') LIMIT 1;"); + +$adapter->query('CREATE TABLE IF NOT EXISTS `user_group_permission` ( id INT(11) unsigned NOT NULL AUTO_INCREMENT, id_group INT(11) unsigned NOT NULL, id_permission INT(11) unsigned NOT NULL, id_model INT(11) unsigned NOT NULL, model_class varchar(255) NOT NULL, PRIMARY KEY (id), KEY(id_group), KEY(id_permission), KEY(id_model), KEY(model_class)) ENGINE = MYISAM, character set=UTF8;'); + +$adapter->query("UPDATE `user_group_categorie` SET `libelle` = 'Général' WHERE `user_group_categorie`.`libelle` = 'Catégorie par défaut' LIMIT 1;"); + +try { + $default_adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + $default_adapter->query("SELECT id_bib from user_groups LIMIT 1"); +} catch (Exception $e) { + $adapter->query("ALTER TABLE `user_groups` add column `id_bib` INT(11) NOT NULL DEFAULT '0', add key `id_bib` (`id_bib`);"); +} +?> diff --git a/cosmogramme/sql/patch/patch_247.php b/cosmogramme/sql/patch/patch_247.php new file mode 100644 index 0000000000000000000000000000000000000000..2352b8e950f0a253445138f17e5c93208210918b --- /dev/null +++ b/cosmogramme/sql/patch/patch_247.php @@ -0,0 +1,6 @@ +<?php +$format_liste = "0:Unimarc\r\n1:Ascii tabulé\r\n2:Ascii séparé par des points-virgule\r\n3:Ascii séparé par des \"|\"\r\n4:Xml\r\n5:CSV\r\n6:Marc21\r\n"; + +$adapter = Zend_Db_Table::getDefaultAdapter(); +$adapter->query("UPDATE variables SET liste = '$format_liste' WHERE clef = 'import_format'"); +?> diff --git a/cosmogramme/sql/patch/patch_248.php b/cosmogramme/sql/patch/patch_248.php new file mode 100644 index 0000000000000000000000000000000000000000..154af7f1b6ff202c6f46393c7898488082ddc841 --- /dev/null +++ b/cosmogramme/sql/patch/patch_248.php @@ -0,0 +1,4 @@ +<?php +Zend_Db_Table::getDefaultAdapter() + ->query("UPDATE `variables` SET commentaire='Site de retrait à la réservation', liste='0:site de l\'exemplaire\r\n1:proposer le choix\r\n2:site de l\'abonné', verrou='' WHERE variables.clef='site_retrait_resa' LIMIT 1;"); +?> diff --git a/cosmogramme/sql/patch/patch_249.php b/cosmogramme/sql/patch/patch_249.php new file mode 100644 index 0000000000000000000000000000000000000000..77cc78f562baa33ca6faf4556a081b60a8d24a55 --- /dev/null +++ b/cosmogramme/sql/patch/patch_249.php @@ -0,0 +1,8 @@ +<?php +$adapter = Zend_Registry::get('sql'); +$adapter->query('ALTER TABLE exemplaires MODIFY code_barres VARCHAR(255)'); +$adapter->query('ALTER TABLE exemplaires MODIFY cote VARCHAR(255)'); +$adapter->query('ALTER TABLE exemplaires MODIFY id_origine VARCHAR(255)'); +$adapter->query('ALTER TABLE exemplaires MODIFY annexe VARCHAR(255)'); +$adapter->query('ALTER TABLE exemplaires MODIFY activite VARCHAR(255)'); +?> diff --git a/cosmogramme/sql/patch/patch_250.php b/cosmogramme/sql/patch/patch_250.php new file mode 100644 index 0000000000000000000000000000000000000000..67c94a5742572786e8c7c2ae67750c31231a4b64 --- /dev/null +++ b/cosmogramme/sql/patch/patch_250.php @@ -0,0 +1,2 @@ +<?php +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_251.php b/cosmogramme/sql/patch/patch_251.php new file mode 100644 index 0000000000000000000000000000000000000000..ac93016d2c12b4fb8f2e6d7add01612aaaf4a0d1 --- /dev/null +++ b/cosmogramme/sql/patch/patch_251.php @@ -0,0 +1,4 @@ +<?php +Zend_Db_Table::getDefaultAdapter() + ->query('alter table notices modify column tome_alpha varchar(20);'); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_252.php b/cosmogramme/sql/patch/patch_252.php new file mode 100644 index 0000000000000000000000000000000000000000..f45fa7bfef9f99564d8d59f0f6e0265926e079c5 --- /dev/null +++ b/cosmogramme/sql/patch/patch_252.php @@ -0,0 +1,4 @@ +<?php +$adapter = Zend_Registry::get('sql'); +$adapter->query("UPDATE `variables` SET commentaire='Site de retrait à la réservation', liste='0:site de l\'exemplaire\r\n1:proposer le choix\r\n2:site de l\'abonné', verrou='' WHERE variables.clef='site_retrait_resa' LIMIT 1;"); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_253.php b/cosmogramme/sql/patch/patch_253.php new file mode 100644 index 0000000000000000000000000000000000000000..277a8ec3432ab3b4aadf77fbd2a8e5b736d2a6cb --- /dev/null +++ b/cosmogramme/sql/patch/patch_253.php @@ -0,0 +1,5 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); +$format_liste = "0:Unimarc\r\n1:Ascii tabulé\r\n2:Ascii séparé par des points-virgule\r\n3:Ascii séparé par des \"|\"\r\n4:Xml\r\n5:CSV\r\n6:Marc21\r\n"; +$adapter->query("UPDATE variables SET liste = '$format_liste' WHERE clef = 'import_format'"); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_254.php b/cosmogramme/sql/patch/patch_254.php new file mode 100644 index 0000000000000000000000000000000000000000..66bd425df7f5cc5442f41a53cbfe9ed2aee825bf --- /dev/null +++ b/cosmogramme/sql/patch/patch_254.php @@ -0,0 +1,10 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); +$adapter->query('alter table notices_articles modify clef_chapeau varchar(100) NULL'); +$adapter->query('alter table notices_articles modify clef_numero varchar(20) NULL'); +$adapter->query('alter table notices_articles modify clef_article varchar(20) NULL'); +$adapter->query('alter table notices_articles modify clef_unimarc varchar(15) NULL'); +$adapter->query('alter table notices_articles modify unimarc text NULL'); +$adapter->query('alter table notices_articles modify date_maj varchar(20) NULL'); +$adapter->query('alter table notices_articles modify qualite tinyint(4) NULL'); +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_255.php b/cosmogramme/sql/patch/patch_255.php new file mode 100644 index 0000000000000000000000000000000000000000..1b03a6c1524bd316c6efe4528bfae93da03bd5a3 --- /dev/null +++ b/cosmogramme/sql/patch/patch_255.php @@ -0,0 +1,37 @@ +<?php +$liste_panier = "'ID_SIGB:id du panier dans le SIGB\r\nLIBELLE:nom du panier\r\nIDABON:numéro de carte du propriétaire\r\nMAIL:courriel du propriétaire\r\nROLE:admin (1) ou abonné (0)\r\nID_NOTICE_SIGB:identifiant de notice du SIGB'"; + +$adapter = Zend_Db_Table::getDefaultAdapter(); +$adapter + ->query("UPDATE `variables` SET liste='0:notices\r\n1:abonnés\r\n2:prêts\r\n3:reservations\r\n4:paniers' WHERE variables.clef='type_fichier' LIMIT 1;"); + +$adapter + ->query( +"INSERT INTO `variables` (clef, valeur, commentaire, type_champ, liste, groupe, ordre, verrou, hidden) +VALUES ( + 'champs_panier', + NULL, + 'Champs pour l\'import des paniers', + 2, + $liste_panier, + 5, + 86, + 'checked', + 1 +) +ON DUPLICATE KEY UPDATE liste=$liste_panier;"); + +try { + $adapter->query('select id_sigb from notices_paniers limit 1'); +} catch (Exception $e) { + $adapter->query('alter table notices_paniers add column id_sigb int(11), add key id_sigb (id_sigb)'); +} + + +try { + $adapter->query('select id_int_bib from notices_paniers limit 1'); +} catch (Exception $e) { + $adapter->query('alter table notices_paniers add column id_int_bib int(11), add key id_int_bib (id_int_bib)'); +} + +?> \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_256.php b/cosmogramme/sql/patch/patch_256.php new file mode 100644 index 0000000000000000000000000000000000000000..da307dad8729967b769f571644a512bb3825a79d --- /dev/null +++ b/cosmogramme/sql/patch/patch_256.php @@ -0,0 +1,9 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try { + $adapter->query('select `license` from `album_ressources` limit 1'); +} catch (Exception $e) { + $adapter->query("ALTER TABLE `album_ressources` ADD COLUMN `license` VARCHAR(255) NULL DEFAULT NULL;"); +} +?> \ No newline at end of file diff --git a/cosmogramme/tests/bootstrap.php b/cosmogramme/tests/bootstrap.php index e979f71a61b2511ee27c9747cb6060a24b8b5477..0edd1446415f7a93dd62ee56cae6fc9e2b0e4cda 100644 --- a/cosmogramme/tests/bootstrap.php +++ b/cosmogramme/tests/bootstrap.php @@ -27,6 +27,7 @@ $_SESSION['passe'] = 'admin_systeme'; define("BASE_URL", "/opac"); include_once "_init.php"; +require_once("classe_communication.php"); ?> diff --git a/cosmogramme/tests/php/classes/CarthameIntegrationTest.php b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..37d242b815fd0813b19e31f96cdf60980edfed03 --- /dev/null +++ b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php @@ -0,0 +1,136 @@ +<?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 + */ + +require_once 'NoticeIntegrationTest.php'; + +abstract class CarthameIntegrationTestCase extends NoticeIntegrationTestCase { + public function setUp() { + parent::setUp(); + VariableCache::getInstance() + ->setValeurCache(['filtrer_fulltext' => 1, + 'homogene_code_qualite' => 10, + 'homogene' => 0, + 'mode_doublon'=> 0, + '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' => '']); + } + + + public function getProfilDonnees() { + return + ['id_profil' => 106, + 'libelle' => 'Carthame', + 'accents' => Class_IntProfilDonnees::ENCODING_ISO2709, + 'rejet_periodiques' => '1', + 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE, + 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, + 'format' => Class_IntProfilDonnees::FORMAT_UNIMARC, + 'attributs' => serialize( + [ [ + 'type_doc' => [ + [ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'au;ku' ], + [ 'code' => '2', 'label' => '', 'zone_995' => ''], + [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'je;jd'], + [ 'code' => '4', 'label' => 'g','zone_995' => 'g'], + [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'le'], + [ 'code' => '6', 'label' => 'f;k', 'zone_995' => 'f;k'], + [ 'code' => '10', 'label' => '', 'zone_995' => 'uu'], + ], + 'champ_code_barres' => 'f', + 'champ_cote' => 'k', + 'champ_type_doc' => '', + 'champ_genre' => '', + 'champ_section' => '', + 'champ_emplacement' => '', + 'champ_annexe' => '' + ], + + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => ''], + [ 'zone' => '995', 'champ' => '', 'format' => '', 'jours' => '', 'valeurs' => ''] + ])]; + } +} + + + +class TangoMangoCarthameIntegrationTest extends CarthameIntegrationTestCase { + protected $_notice; + + public function setUp() { + parent::setUp(); + $this->fixture('Class_Notice', ['id' => 7939934, + 'type_doc' => 1, + 'facettes' => 'Lfre G3 T1 B7 B2 V2 2015-09', + 'isbn' => '978-2-359-10416-5', + 'clef_alpha' => '------1', + 'clef_oeuvre' => '---', + 'qualite' => 10, + 'exportable' => 1, + 'date_creation' => '2015-09-08 00:00:00', + 'date_maj' => '2015-03-13 02:00:12', + 'unimarc' => '01041cam0 2200289 450 001002100000003004700021010003900068020001700107021002700124073001800151100004100169101000800210102000700218105001800225106000600243200000500249210000100254215000100255225000100256300000100257330048800258461000100746686000100747700000100748801000100749930000100750FRBNF437016350000001http://catalogue.bnf.fr/ark:/12148/cb43701635n a978-2-35910-416-5brel.d12,90 EUR aFRb01364260 aFRbDLE-20131029-62048 0a9782359104165 a20131029d2013 m y0frey50 ba0 afre aFR a||||t 00|a| ar1 aaaAn 982, alors qu\' Elaine et Encre Noire continuent de réparer leur bateau, un évènement inattendu bouleverse les Eaux Tièdes : le retour de la Gazette du Pirate !aLa Gazette du pirate annonce le retour du grand tournoi, le rendez-vous incontournable des écumeurs des mers. Encre Noire et Elaine décident de voler des trésors et d\'amasser de l\'argent pour acheter un nouveau gouvernail afin de mettre toutes les chances de leur côté pour remporter l\'épreuve. ÂElectre 2015']); + } + + + /** @test */ + public function importFromFileShouldNotCreateAnOtherRecord() { + $this->loadNotice('unimarc_tangomango'); + $notice = Class_Notice::find(7939934); + $this->assertCount(1, Class_Notice::findAll()); + return $notice; + } + + + /** + * @depends importFromFileShouldNotCreateAnOtherRecord + * @test + * */ + public function importFromFileShouldUpdateNotice($notice) { + $this->assertEquals('TangoMango n° 2<br /> La Gazette du pirate', $notice->getTitrePrincipal()); + } + + + /** @test */ + public function homogenizeShouldUpdateNotice() { + $notice = Class_Notice::find(7939934); + $notice_integration = new notice_integration(); + $notice_integration->traiteHomogene($notice->getId(), + $notice->getIsbn(), + '', + '', + 3); + + Class_Notice::clearCache(); + $notice = Class_Notice::find(7939934); + $this->assertEquals('Tangomango n° 2<br /> La gazette du pirate', $notice->getTitrePrincipal()); + } + + +} diff --git a/cosmogramme/tests/php/classes/CosmoPathsTest.php b/cosmogramme/tests/php/classes/CosmoPathsTest.php index 0f0cd4bd4bf8a924424013e638a3b9050999fd84..9fb8b34b9b0a573a1268d1e3637863775703f51a 100644 --- a/cosmogramme/tests/php/classes/CosmoPathsTest.php +++ b/cosmogramme/tests/php/classes/CosmoPathsTest.php @@ -16,13 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'classe_cosmopaths.php'; abstract class CosmoPathsTestCase extends PHPUnit_Framework_TestCase { - /** @test */ public function basePathShouldEndWithDomainBokehDotFr() { $this->assertEquals('bokeh.fr/', substr($this->_cosmo_paths->getBasePath(), -9)); @@ -67,7 +66,8 @@ class CosmoPathsFromHttpRequestTest extends CosmoPathsTestCase { public function setUp() { parent::setUp(); - $_SERVER = ['SCRIPT_FILENAME' => '/var/www/htdocs/bokeh.fr/cosmogramme/index.php', + $_SERVER = ['SCRIPT_NAME' => '/bokeh.fr/cosmogramme/index.php', + 'SCRIPT_FILENAME' => '/var/www/htdocs/bokeh.fr/cosmogramme/index.php', 'DOCUMENT_ROOT' => '/var/www/htdocs']; $this->_cosmo_paths = new CosmoPaths(); } @@ -81,6 +81,121 @@ class CosmoPathsFromHttpRequestTest extends CosmoPathsTestCase { +class CosmoPathsFromHttpRequestInASubdirTest extends PHPUnit_Framework_TestCase { + protected $_cosmo_paths; + + public function setUp() { + parent::setUp(); + $_SERVER = [ + 'SCRIPT_NAME' => '/projects/bokeh/cosmogramme/index.php', + 'SCRIPT_FILENAME' => '/var/www/projects/bokeh/cosmogramme/index.php', + 'DOCUMENT_ROOT' => '/var/www']; + $this->_cosmo_paths = new CosmoPaths(); + } + + /** @test */ + public function basePathShouldEndWithDomainBokehDotFr() { + $this->assertEquals('bokeh/', substr($this->_cosmo_paths->getBasePath(), -6)); + } + + + /** @test */ + public function configPathShouldEndWithBokehDotFrCosmogrammeConfigDotPhp() { + $this->assertEquals('bokeh/cosmogramme/config.php', substr($this->_cosmo_paths->getConfigPath(), -28)); + } + + + /** @test */ + public function bokehConfigPathShouldEndWithBokehSlashConfigDotIni() { + $this->assertEquals('bokeh/config.ini', substr($this->_cosmo_paths->getBokehConfigPath(), -16)); + } + + + /** @test */ + public function baseUrlShouldBeProjectsBokeh() { + $this->assertEquals('/projects/bokeh/', $this->_cosmo_paths->getBaseUrl()); + } + + + /** @test */ + public function siteShouldBeBokeh() { + $this->assertEquals('bokeh', $this->_cosmo_paths->getSite()); + } + + + /** @test */ + public function userFilesPathShouldEndWithBokehDotFrSlashUserfiles() { + $this->assertEquals('bokeh/userfiles', substr($this->_cosmo_paths->getUserfilesPath(), -15)); + } + + + public function tearDown() { + unset($_SERVER['SCRIPT_NAME']); + unset($_SERVER['SCRIPT_FILENAME']); + unset($_SERVER['DOCUMENT_ROOT']); + } +} + + + + +class CosmoPathsFromHttpRequestAtRootTest extends PHPUnit_Framework_TestCase { + protected $_cosmo_paths; + + public function setUp() { + parent::setUp(); + $_SERVER = [ + 'SCRIPT_NAME' => '/cosmogramme/index.php', + 'SCRIPT_FILENAME' => '/var/www/projects/bokeh/cosmogramme/index.php', + 'DOCUMENT_ROOT' => '/var/www/projects/bokeh']; + $this->_cosmo_paths = new CosmoPaths(); + } + + /** @test */ + public function basePathShouldEndWithDomainBokehDotFr() { + $this->assertEquals('bokeh/', substr($this->_cosmo_paths->getBasePath(), -6)); + } + + + /** @test */ + public function configPathShouldEndWithBokehDotFrCosmogrammeConfigDotPhp() { + $this->assertEquals('bokeh/cosmogramme/config.php', substr($this->_cosmo_paths->getConfigPath(), -28)); + } + + + /** @test */ + public function bokehConfigPathShouldEndWithBokehSlashConfigDotIni() { + $this->assertEquals('bokeh/config.ini', substr($this->_cosmo_paths->getBokehConfigPath(), -16)); + } + + + /** @test */ + public function baseUrlShouldBeEmpty() { + $this->assertEquals('/', $this->_cosmo_paths->getBaseUrl()); + } + + + /** @test */ + public function siteShouldBeBokeh() { + $this->assertEquals('bokeh', $this->_cosmo_paths->getSite()); + } + + + /** @test */ + public function userFilesPathShouldEndWithBokehDotFrSlashUserfiles() { + $this->assertEquals('bokeh/userfiles', substr($this->_cosmo_paths->getUserfilesPath(), -15)); + } + + + public function tearDown() { + unset($_SERVER['SCRIPT_NAME']); + unset($_SERVER['SCRIPT_FILENAME']); + unset($_SERVER['DOCUMENT_ROOT']); + } +} + + + class CosmoPathsFromCommandLineTest extends CosmoPathsTestCase { protected $_cosmo_paths; diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1f925fc2e84ea0b06583eaa3516ed18c6200a7c1 --- /dev/null +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -0,0 +1,237 @@ +<?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 + */ + + +require_once('NoticeIntegrationTest.php'); + +abstract class KohaRecordIntegrationTestCase extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forKoha()->getRawAttributes(); + } +} + + + +class KohaRecordIntegrationBadUnimarcTest extends KohaRecordIntegrationTestCase { + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_bad_pagaille'); + } + + /** @test */ + public function titleShouldBePagaille() { + $this->assertEquals('La Pagaille', $this->notice_data['titres'][0]); + } +} + + + + +class KohaRecordIntegrationBdMilleniumTest extends KohaRecordIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forKoha()->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_bd_millenium'); + $this->millenium = Class_Notice::find(1); + } + + /** @test */ + public function titreShouldBeHommesQuiNaimaientPasLesFemmes() { + $this->assertEquals('Les hommes qui n\'aimaient pas les femmes', $this->millenium->getTitrePrincipal()); + } + + + /** @test */ + public function collectionShouldContainsMillenium() { + $this->assertContains('Millenium', $this->millenium->getCollections()); + } + + /** @test */ + public function collectionMilleniumShouldBeIndexed() { + $this->assertEquals('MILLENIUM MILENIUM', $this->millenium->getRawAttributes()['collection']); + } +} + + + + +class KohaRecordIntegrationUnimarcWithoutLabelBlocTest extends KohaRecordIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forKoha()->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_no_bloc_label_koha'); + } + + + /** @test */ + public function typeDocShouldBeZero() { + $this->assertSame(0, + $this->notice_integration->noticeToDBEnreg($this->notice_data)['type_doc']); + } + +} + + + + +class KohaRecordIntegrationFacetPresseTest extends KohaRecordIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forKoha() + ->setIdProfil(111) + ->setTypeDocRecognition(2, 'as', 'PRESSE') + ->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_koha_okapi'); + } + + + /** @test */ + public function clefAlphaShouldBeAsExpected() { + $this->assertEquals('OKAPI---955-BAYARD--2', Class_Notice::find(1)->getClefAlpha()); + } + + + /** @test */ + public function facettesShouldContainsT2() { + $this->assertEquals('Lfre T2 B1 YMEDSTMAR', + Class_Notice::find(1) + ->updateFacetsFromExemplaires() + ->getFacettes()); + } + + + /** @test */ + public function okapi983ShouldHaveT2Facette() { + $okapi_983 = Class_Notice::findFirstBy(['tome_alpha' => '983']); + $this->assertContains('T2', $okapi_983->getFacettes()); + } + + + /** @test */ + public function loadSameUnimarcShouldNotDuplicateOkapi983() { + $this->loadNotice('unimarc_koha_okapi'); + $okapi_983 = Class_Notice::findAllBy(['tome_alpha' => '983']); + $this->assertCount(1, $okapi_983); + } +} + + + + +class KohaRecordIntegrationVagabondWithThesaurusOn702DollarATest extends KohaRecordIntegrationTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CodifThesaurus', + ['id' => 1, + 'libelle' => 'Author', + 'id_thesaurus' => 'AUTH', + 'id_origine' => null, + 'code' => 'authors', + 'rules' => '{"label":"702$a"}']); + + + $marcel = $this->fixture('Class_CodifThesaurus', + ['id' => 2, + 'libelle' => 'Marcel', + 'id_thesaurus' => 'AUTH0001', + 'id_origine' => 'MARCEL', + 'code' => 'authors', + 'rules' => null]); + + + $docu = $this->fixture('Class_CodifThesaurus', + ['id' => 3, + 'libelle' => 'Document', + 'id_thesaurus' => 'DOCU', + 'id_origine' => null, + 'code' => 'document', + 'rules' => '{"label":" 99$t "}']); + + + $loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifThesaurus'); + $loader + ->whenCalled('findFirstBy') + ->with(['code' => 'authors', + 'where' => 'id_thesaurus like "AUTH%"', + 'order' => 'id_thesaurus desc']) + ->answers($marcel) + + ->whenCalled('findFirstBy') + ->with(['code' => 'document', + 'where' => 'id_thesaurus like "DOCU%"', + 'order' => 'id_thesaurus desc']) + ->answers($docu); + + + $this->loadNotice('unimarc_vagabond'); + $this->_notice = Class_Notice::find(1); + } + + + /** @test */ + public function titleShouldBeVagabond() { + $this->assertEquals('Vagabond n° 4', $this->_notice->getTitrePrincipal()); + } + + + /** @test */ + public function facetsShouldContainsHAUTH0001() { + $this->assertContains('HAUTH0001', $this->_notice->getFacetCodes()); + } + + + /** @test */ + public function facetsShouldContainsHAUTH0002() { + $this->assertContains('HAUTH0002', $this->_notice->getFacetCodes(), $this->_notice->getFacettes()); + } + + + /** @test */ + public function facetsShouldContainsHDOCU0001() { + $this->assertContains('HDOCU0001', + $this->_notice->getFacetCodes(), + $this->_notice->getFacettes()); + } + + /** @test */ + public function entryForYoshikawaShouldBeCreated() { + $entry = Class_CodifThesaurus::findFirstBy(['id_thesaurus' => 'AUTH0002']); + $this->assertNotNull($entry); + $this->assertEquals('Yoshikawa', + $entry->getLibelle()); + } + +} + +?> \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e0274469b744326392ff8c3ff9c61f8378176ef6 --- /dev/null +++ b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php @@ -0,0 +1,76 @@ +<?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 + */ + +require_once 'NoticeIntegrationTest.php'; + +/** @see http://forge.afi-sa.fr/issues/17196 */ +class NoticeIntegrationDedupWithoutIsbnTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES()->setIdProfil(113) + ->getRawAttributes(); + } + public function setUp() { + parent::setUp(); + $this->fixture('Class_Notice', ['id' => 15824768, + 'type_doc' => 2, + 'alpha_titre' => 'ANIME LAND 203', + 'alpha_auteur' => 'ANIMARTE', + 'titres' => 'ANIME ANIM LAND LAN MAGAZINE MAGAZIN FRANCAIS FRANKAI L00 ANIMATION ANIMASION 203', + 'auteurs' => 'ANIMARTE ANIMART', + 'editeur' => 'Animarte', + 'dewey' => 'ARTS AR LOISIRS LOISIR', + 'facettes' => 'D7948083 A204019 Lfre G4 G9 G37 G18 G12 G10 G33 G11 G45 G17 G5 G14 G2 G13 G8 G7 G30 G19 G24 G21 G20 G43 G3 G16 G51 G47 G27 G29 G36 G25 G34 G31 G56 G53 G1 G28 G26 G44 G32 G23 G6 G58 G50 T2 B105 S6 YVIGNEULLES B4 S1 S10 B3 YLIGNY S7 B18 YAUBREVILLE B81 YPIERREFITT B40 YDUGNY B53 YLACROIXSME B39 YDOULCON B20 YBELLEVILLE B58 YISLETTES B7 YSTM B94 YSPINCOURT B130 YTRIAUCOURT B26 YBRAS B96 YTREMONT B35 YDAMVILLERS B80 YPAGNY B8 YDIEUE B33 YCOUSANCE B73 YMONTMEDY B126 YCDOS B29 YCLERMONTAR B42 YFRESNES B57 YLEROUVILLE B124 YSOUILLY B41 YETAIN B11 YLAMORVILLE B1 YBDM B101 YVAUBECOURT', + 'cote' => '741.5 ANI', + 'id_commerciale' => '', + 'id_bnf' => '', + 'ean' => null, + 'clef_alpha' => 'ANIMELAND-LEMAGAZINEFRANCAISDE-ANIMARTE-203-ANIMARTE-1991-2', + 'clef_oeuvre' => 'ANIMELAND-LEMAGAZINEFRANCAISDE-ANIMARTE-203', + 'clef_chapeau' => 'ANIME LAND', + 'tome_alpha' => 203, + 'annee' => 1991, + 'qualite' => 5, + 'exportable' => 1, + 'date_creation' => '2015-08-13 00:00:00', + 'date_maj' => '2015-04-19 03:56:21', + 'unimarc' => "01281cas0 2200373 450 0010007000000110027000070200013000340900011000471000041000581010008000991020007001071060006001141100016001202000114001362070023002502100056002732100045003292100070003742150010004443000072004543120037005263260011005634610015005744610008005894610023005974880055006205170014006755300015006896760018007046860070007227100060007928010048008528020007009001588661 a1148-0807dle n° 20 F b19104668 a158866 a19910613a1991 m y0frey50 ba0 afre aFR ar aah z z 1 aAnime landbTexte impriméele magazine français de l'animationf[Animarte]g[dir. publ. Yvan West Laurence] 0aN° 1 (1991, avr.) aVanvesb71 rue Jean-Jaurès, 92170cAnimarted1991-0 aParisb7 rue Elie Faure, 75012cAnimarte1 aParisb14 rue Soleillet, 75971 Cedex 20cAnime manga pressd1996- d30 cm aCertains numéros sont accompagnés d'un DVD-ROM ou d'un DVD vidéo aAutre forme de titre : Animeland aBimest11tAnime land11v20311o- Avril / Mai 2015 1036140168tAnime land. Hors-sériex1283-6338d19971 aAnimeland0 aAnime land a794.808 3v22 a0002Cadre de classement de la Bibliographie nationale française 312883488aAnimartecVanves, Hauts-de-Seine40709161742 0aFRbFR-751131015c19910613gAFNOR2intermrc a07", + ]); + + VariableCache::getInstance() + ->setValeurCache(['filtrer_fulltext' => 1, + 'mode_doublon'=> 0, + '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' => '']); + + $this->loadNotice('unimarc_dernier_des_hommes'); + } + + + /** @test */ + public function thereShouldHave2Records() { + $this->assertEquals(2, Class_Notice::count()); + } +} diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index dce95e10e9601cf629e4911a5b51f6053d80d814..f96ce961e6965fed6424da2b657fcb959feb33fa 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -106,6 +106,22 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { Class_CodifDewey::beVolatile(); Class_CodifPcdm4::beVolatile(); + Class_Notice_SerialArticles::beVolatile(); + + $this->fixture('Class_IntBib', + ['id' => 1, + 'nom' => 'My wonderful library', + 'nom_court' => 'MWL', + 'mail' => '', + 'qualite' => 10, + 'dernier_ajout' => '2015-01-01', + 'ecart_ajouts' => '0', + 'date_mail' => '', + 'sigb' => 1, + 'planif_mode' => 'r', + 'comm_sigb' => 0, + 'comm_params' => 'N']); + $this->notice_sgbd=new notice_unimarc(); $this->setupProfilDonnees(); } @@ -137,19 +153,22 @@ class NoticeIntegrationLivreNumTest extends NoticeIntegrationTestCase { parent::setUp(); $notice_integration = new notice_integration(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifThesaurus') - ->whenCalled('findThesaurusForCatalogue') - ->with(5) - ->answers(Class_CodifThesaurus::newInstanceWithId(25, - ['id_thesaurus' => 25])) + $this->fixture('Class_CodifThesaurus', ['id' =>25, + 'id_origine' => 5, + 'id_thesaurus' => 25, + 'code' => Class_CodifThesaurus::CODE_CATALOGUE, + 'libelle' => 'thesaurus']); + + $this->fixture('Class_CodifThesaurus', ['id' =>29, + 'id_origine' => 6, + 'id_thesaurus' => 29, + 'code' => Class_CodifThesaurus::CODE_CATALOGUE, + 'libelle' => 'thesaurus']); - ->whenCalled('findThesaurusForCatalogue') - ->with(6) - ->answers(Class_CodifThesaurus::newInstanceWithId(29, - ['id_thesaurus' => 29])); $this->fixture('Class_CodifAuteur', ['id' => '234']); - $this->fixture('Class_Album', ['id' => 100]); + $this->fixture('Class_Album', ['id' => 100, + 'status' => Class_Album::STATUS_VALIDATED]); $this->ret = $notice_integration ->traitePseudoNotice(100, @@ -189,12 +208,6 @@ class NoticeIntegrationLivreNumTest extends NoticeIntegrationTestCase { $this->assertEquals(['Collection', 'Dataset'], $this->notice_sgbd->get_subfield('200', 'b')); } - - /** @test */ - public function thesaurusShouldHaveBeenFetched() { - $this->assertTrue(Class_CodifThesaurus::methodHasBeenCalledWithParams('findThesaurusForCatalogue', [5])); - $this->assertTrue(Class_CodifThesaurus::methodHasBeenCalledWithParams('findThesaurusForCatalogue', [6])); - } } @@ -228,6 +241,7 @@ abstract class NoticeIntegrationSacramentariumTestCase extends NoticeIntegration 'id_origine'=>'D09030160', 'cfg_thumbnails'=>'', 'a:9:{s:15:"thumbnail_width";s:3:"400";s:28:"thumbnail_left_page_crop_top";s:1:"0";s:30:"thumbnail_left_page_crop_right";s:2:"35";s:31:"thumbnail_left_page_crop_bottom";s:1:"0";s:29:"thumbnail_left_page_crop_left";s:1:"0";s:29:"thumbnail_right_page_crop_top";s:1:"0";s:31:"thumbnail_right_page_crop_right";s:1:"0";s:32:"thumbnail_right_page_crop_bottom";s:1:"0";s:30:"thumbnail_right_page_crop_left";s:2:"35";}', + 'status' => Class_Album::STATUS_VALIDATED, 'pdf'=>'', 'sous_titre'=>'Sacramentaire de Souvigny', 'cote'=>'MS 14', @@ -240,12 +254,14 @@ abstract class NoticeIntegrationSacramentariumTestCase extends NoticeIntegration 'id_bib' => 1, 'bibliotheques' => '7;87', 'annexes' => '6;55', - 'sections' => '12;23']); + 'sections' => '12;23', + 'status' => Class_Album::STATUS_VALIDATED]); $this->notice_integration = new notice_integration(); - $this->pseudo_notice = $this->notice_integration->traitePseudoNotice(100, - $this->sacramentarium->rawToArray()); + $this->pseudo_notice = $this->notice_integration + ->traitePseudoNotice(100, + $this->sacramentarium->rawToArray()); $this->notice_sgbd->ouvrirNotice($this->pseudo_notice['unimarc'], 0); } @@ -479,6 +495,8 @@ class NoticeIntegrationMarc21CoupCavalierToUnimarcTest extends NoticeIntegration } + + class NoticeIntegrationMarc21BorisToUnimarcTest extends NoticeIntegrationMarc21DynixTestCase { public function setUp() { parent::setUp(); @@ -500,29 +518,21 @@ class NoticeIntegrationBourdieuWithElectreGeneratedNoticeRecordTest extends Noti ->setCodif(['fre' => ['id_langue' => 'fre', 'libelle' => 'français']]); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifThesaurus') - ->whenCalled('findByIdOrigineAndCode') - ->with('T380500', 'thèmeelectre') - ->answers($this->fixture('Class_CodifThesaurus', - ['id' => '2222', - 'id_thesaurus'=>'AAAA0001222', - 'code' => 'themeelectre', - 'libelle' => 'Modes de vie et comportements selon les pays'])) - - ->whenCalled('findByIdOrigineAndCode') - ->with('GDOC005', 'genreelectre') - ->answers(null) - - ->whenCalled('findByIdOrigineAndCode') - ->with('PS0100', 'publicelectre') - ->answers($this->fixture('Class_CodifThesaurus', - ['id' => '88', - 'id_thesaurus' => 'AAAA88', - 'code' => 'publicelectre', - 'libelle' => 'Public motivé'])) - ->beStrict(); - - + $this->fixture('Class_CodifThesaurus', + ['id' => 2222, + 'id_origine' => 'T380500', + 'id_thesaurus' => 'AAAA0001222', + 'code' => 'thèmeelectre', + 'libelle' => 'Modes de vie et comportements selon les pays', + 'rules' => null]); + + $this->fixture('Class_CodifThesaurus', + ['id' => 88, + 'id_origine' => 'PS0100', + 'id_thesaurus' => 'AAAA88', + 'code' => 'publicelectre', + 'libelle' => 'Public motivé', + 'rules' => null]); $this->notice_integration = new notice_integration(); $this->notice_integration->setParamsIntegration(1, 0, 1); @@ -1151,81 +1161,6 @@ class NoticeIntegrationItemsIn852Test extends NoticeIntegrationTestCase { -class NoticeIntegrationKohaBadUnimarcTest extends NoticeIntegrationTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forKoha()->getRawAttributes(); - } - - - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_bad_pagaille'); - } - - /** @test */ - public function titleShouldBePagaille() { - $this->assertEquals('La Pagaille', $this->notice_data['titres'][0]); - } -} - - - - -class NoticeIntegrationKohaBdMilleniumTest extends NoticeIntegrationTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forKoha()->getRawAttributes(); - } - - - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_bd_millenium'); - $this->millenium = Class_Notice::find(1); - } - - /** @test */ - public function titreShouldBeHommesQuiNaimaientPasLesFemmes() { - $this->assertEquals('Les hommes qui n\'aimaient pas les femmes', $this->millenium->getTitrePrincipal()); - } - - - /** @test */ - public function collectionShouldContainsMillenium() { - $this->assertContains('Millenium', $this->millenium->getCollections()); - } - - /** @test */ - public function collectionMilleniumShouldBeIndexed() { - $this->assertEquals('MILLENIUM MILENIUM', $this->millenium->getRawAttributes()['collection']); - } -} - - - - -class NoticeIntegrationKohaUnimarcWithoutLabelBlocTest extends NoticeIntegrationTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forKoha()->getRawAttributes(); - } - - - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_no_bloc_label_koha'); - } - - - /** @test */ - public function typeDocShouldBeZero() { - $this->assertSame(0, - $this->notice_integration->noticeToDBEnreg($this->notice_data)['type_doc']); - } - -} - - - - class NoticeIntegrationBiblioArcheoAnimauxTest extends NoticeIntegrationTestCase { protected $_profil_donnees = [ 'id_profil' => 111, @@ -1760,52 +1695,6 @@ class NoticeIntegrationSymphonieTest extends NoticeIntegrationTestCase { -class NoticeIntegrationUnimarcKohaFacetteTest extends NoticeIntegrationTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forKoha() - ->setIdProfil(111) - ->setTypeDocRecognition(2, 'as', 'PRESSE') - ->getRawAttributes(); - } - - - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_koha_okapi'); - } - - - /** @test */ - public function clefAlphaShouldBeAsExpected() { - $this->assertEquals('OKAPI---955-BAYARD--2', Class_Notice::find(1)->getClefAlpha()); - } - - - /** @test */ - public function facettesShouldContainsT2() { - $this->assertEquals('Lfre T2 B1 YMEDSTMAR', - Class_Notice::find(1) - ->updateFacetsFromExemplaires() - ->getFacettes()); - } - - - /** @test */ - public function okapi983ShouldHaveT2Facette() { - $okapi_983 = Class_Notice::findFirstBy(['tome_alpha' => '983']); - $this->assertContains('T2', $okapi_983->getFacettes()); - } - - - /** @test */ - public function loadSameUnimarcShouldNotDuplicateOkapi983() { - $this->loadNotice('unimarc_koha_okapi'); - $okapi_983 = Class_Notice::findAllBy(['tome_alpha' => '983']); - $this->assertCount(1, $okapi_983); - } -} - - /** @see http://forge.afi-sa.fr/issues/16628 */ class NoticeIntegrationInterestEsperluetteTest extends NoticeIntegrationTestCase { @@ -2335,4 +2224,75 @@ class NoticeIntegrationNoNoticeTest extends NoticeIntegrationTestCase { public function writeItemShouldNotCrash() { $this->assertNull($this->_notice_integration->ecrireExemplaires(1)); } -} \ No newline at end of file +} + + + + +class NoticeIntegrationSerialTopSanteTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + $profil = Class_IntProfilDonnees::forNanook()->setIdProfil(110); + return $profil->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $contents = file_get_contents(dirname(__FILE__)."/unimarc_top_sante.txt"); + + array_map([$this, 'loadNoticeFromString'], + preg_split('/'.chr(30).chr(29).'/', $contents)); + + $this->notice = Class_Notice::find(1); + } + + + /** @test */ + public function mainTitleShouldBeTopSante() { + $this->assertContains('Top Santé n° 295 - Avril 2015', $this->notice->getTitrePrincipal()); + } + + + /** @test */ + public function noticeShouldHaveFiveArticles() { + $this->assertCount(5, $this->notice->getArticlesPeriodique()); + } +} + + + +class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES() + ->setIdProfil(111) + ->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $contents = file_get_contents(dirname(__FILE__)."/unimarc_petit_doucet.txt"); + + array_map([$this, 'loadNoticeFromString'], + preg_split('/'.chr(30).chr(29).'/', $contents)); + + $this->notice = Class_Notice::find(1); + } + + + /** @test */ + public function mainTitleShouldBeBellesHistoires() { + $this->assertEquals('Belles histoires (Les)', $this->notice->getTitrePrincipal()); + } + + + /** @test */ + public function noArticleShouldHaveBeenSaved() { + $this->assertCount(0, Class_Notice_SerialArticles::findAll()); + } +} + + +?> \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_dernier_des_hommes.txt b/cosmogramme/tests/php/classes/unimarc_dernier_des_hommes.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ca4e572879b1d2774166daee9a197ef552ca010 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_dernier_des_hommes.txt @@ -0,0 +1 @@ +01683ngm0 2200361 450 0010008000000200017000080710022000251000041000471010028000881020007001161150025001232000164001482100050003122150086003623000203004483000131006513040042007823060016008243300071008403450027009116860008009387020046009467020032009927020024010247020025010487020021010738010039010948010025011339010047011589020020012059030008012259950088012330476549 aFRb70502749|1bMK2 Âed.a9714900 a20050119d2005 y0frey0103 ba1 amulcgerjengjfrejspa aFR ac baiz|||||||bz||c1 aDernier des hommes (Le)bImages animÂeesfFriedrich Wilhelm Murnau, rÂeal.gCarl Mayer, scÂenariogEmil Jannings, Maly Delscharft, Max Hiller... [et al.], act. a[Paris]cMK2 Âed. [Âed., distrib.]d[DL 2005] a1 DVD vidÂeo monoface double couche zone 2 (2 h 10 min)c4/3, n. et b. (PAL), mu. aContient aussi : rÂealisation du "Dernier des hommes" par Luciano Berriatua (40 min), crÂeateurs du film, gÂenÂerique, le film est prÂesentÂe avec sa double fin, la deuxiÁeme Âetant la fin originale aFilm muet avec intertitres en allemand et sous-titrage optionnel en anglais, franÐcais et espagnol avec accompagnement musical aNotice rÂedigÂee d'aprÁes la jaquette aCop. : 1924 a"L'histoire de la decheance du portier d'un grand hotel de Berlin" b3700224303952d56,00 € a207 |aMurnaubFriedrich Wilhelmf1888-19314300 |aMayerbCarlf1894-19444690 |aJanningsbEmil4005 |aDelschaftbMaly4005 |aHillerbMax4005 0aFRbBNFc20050119gAFNOR2intermrc 0aFRbBM BLDc20070929 aCinÂema -- Allemagne [Europe] -- 1895-1928 aFilm dramatique aP14 30476707aMÂediathÁeque Jean JEUKENSf10086587kF MUR DVDm20140712n20140823qargd \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt b/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt new file mode 100644 index 0000000000000000000000000000000000000000..bc11399aa4c080cf51861de2891951d1f1529767 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_petit_doucet.txt @@ -0,0 +1 @@ +00369nas0 2200097 450 0010008000001000041000082000044000494610036000934620093001299950049002220690665 a20150429a|||| uu y0frey0103 ba| aBelles histoires (Les)h509i01/05/2015 |30627457tBelles histoires (Les) 30690669tLe petit Doucet et les 7 filles de l'ogrefHistoire Âecrite par Arnaud AlmÂeras 30690666aBDYbYf16431346045kA ALM bqJruu00638naa0 2200181 450 0010008000001000041000081010008000491020007000572000113000642150010001773300159001876760006003467000037003527020023003898010028004129020010004409030006004500690669 a20150429a|||| u y0frey0103 ba| afre aFR| aLe petit Doucet et les 7 filles de l'ogrefHistoire Âecrite par Arnaud AlmÂerasgillustrÂee par Sara Ogilvie a42 p. aIl Âetait une fois un petit garÐcon et trÁes gentil... Un jour, ses six frÁeres trÁes moqueurs et trÁes mÂechants dÂecident de le perdre dans la forÃet... aA 1aAlmÂerasbArnaudf1967-....4070 1aOgilviebSara4440 1aFRbBDP YONNEc20150429 aAlbum ab \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_tangomango.txt b/cosmogramme/tests/php/classes/unimarc_tangomango.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe45493120f78ad20cb5560c767bf7cf624045d6 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_tangomango.txt @@ -0,0 +1 @@ +01765nam 2200421 4500001001200000005001700012010004000029073001800069100004100087101000800128102000700136105001000143106000600153200005800159210003300217211001300250215005700263219001100320225001800331225001700349330031300366345001800679410002500697461002600722676001500748679000600763686001200769700004300781801003700824830003000861903004000891947001000931969002800941991001400969995012000983995012001103995012001223DOC0023868420150312153734.1 a978-2-35910-416-5bcart.d12,90 EUR a9782359104165 a20140908d2013 a |0fre|0101||||ba afre aFR a0||y| ar aLa Gazette du piratebLivrefAdrian Fernandez Delgado aRoubaix (Nord)cAnkamad2013 a20130919 a1 vol. (47 p.)cillustrations en couleurd30 x 21 cm cGAZPIR aTangoMangov2 aWakfu heroes aLa Gazette du pirate annonce le retour du grand tournoi, le rendez-vous incontournable des écumeurs des mers. Encre Noire et Elaine décident de voler des trésors et d'amasser de l'argent pour acheter un nouveau gouvernail afin de mettre toutes les chances de leur côté pour remporter l'épreuve. Electre 2015 b9782359104165 tWakfu heroes6314784 tTangoMangov26313313 a741.56v22 cM 2electre aFernandez DelgadobAdrian32165644070 aFRbMD68-Colmarc20140908gAFNOR aELECTRED202015_1 20150209 aBandes dessinées - Bandes dessinées c12.90 a3h3iD202015_1_2233959 aD202015_1 aMD68-ColmarbMD68-ColmareBandes Dessineesf00100009189000oUNraztFC5D2GNH15000736I20150312J11,74K20150908 aMD68-ColmarbMD68-ColmareBandes Dessineesf00100009188986oUNraztFC5D2GNH15003216I20150312J11,74K20150908 aMD68-ColmarbMD68-ColmareBandes Dessineesf00100009188994oUNraztFC5D2GNH15003217I20150312J11,74K20150908 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_top_sante.txt b/cosmogramme/tests/php/classes/unimarc_top_sante.txt new file mode 100644 index 0000000000000000000000000000000000000000..fc4815a30ef7551b9da45f1fe3b1385743a57eb0 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_top_sante.txt @@ -0,0 +1 @@ +00756nas2 2200133 450 001000700000073001800007100001300025122004500038200010200083461008600185801001700271992018400288995015000472353014 a3781591102904 a20140620 a 20150430 1 aExclusif ! Avec la méthode "très bien merci !" Objectif tour de taille ! -3 kilos, c'est sûr ! nTop SantéoAbonnementtTop Santév295 - Avril 2015wNormal41x1152-7137016492 2aFrc20150428 uhttp://websvc.pergame.net/afi_opac_services/images/periodiques/numeros/156/thumbs/295.jpegvhttp://websvc.pergame.net/afi_opac_services/images/periodiques/numeros/156/big/295.jpeg aMédiathèque Jim-Dandurandf121049kPem20150428qarpzppocv12[DERN][Dernier numéro][0][0][A consulter sur place][0][0][1][0]644724829900253naa2 2200061 450 0010007000002000140000074610044001473702921 aDossier médecine : Alergies respiratoires, dermato, alimentaires... On peut toutes les guérir ! Les meilleurs conseils et traitements tTop Santév295 - Avril 2015wNormal4100222naa2 2200061 450 0010007000002000109000074610044001163702931 aLes nouvelles techniques anti-stress : Sophrologie, méditation, hypnose + les exos à faire soi-même ! tTop Santév295 - Avril 2015wNormal4100166naa2 2200061 450 0010007000002000053000074610044000603702941 aCellulite : Les crèmes 2015 testées pour vous tTop Santév295 - Avril 2015wNormal4100214naa2 2200061 450 0010007000002000101000074610044001083702951 aHalus valgus : Tous les progrès de la chirurgie du pied + le classement des meilleurs hôpitaux tTop Santév295 - Avril 2015wNormal4100180naa2 2200061 450 0010007000002000067000074610044000743702961 aProgrès : Les dernières innovations en chirurgie esthétique tTop Santév295 - Avril 2015wNormal41 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_vagabond.txt b/cosmogramme/tests/php/classes/unimarc_vagabond.txt new file mode 100644 index 0000000000000000000000000000000000000000..81f86fc23598109c8f4881b6b773ede21f8325c6 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_vagabond.txt @@ -0,0 +1 @@ +01469nam 2200349 4500001000400000003004700004010004700051020001700098021002000115039001900135090000800154091001900162099001300181100004100194101000800235102000700243105001800250106000600268200017600274210005600450215009700506461003300603610001000636676001000646700007200656702005000728702006100778702004000839801007000879930002900949995014100978869http://catalogue.bnf.fr/ark:/12148/cb37710769n a2-84580-144-0bbr.dPrix : 59 F : 8,99 EUR aFRb00201411 aFRbDL 01-54100 oOPLa027037083 a869 b20140822c1a2 eUZELtBD a20020103d2001 m y0frey50 ba1 afre aFR aa t 00|a| ar1 aVagabondbTexte impriméh4fTakehiko Inouégd'après l'oeuvre d'Eiji Yoshikawa, "Miyamoto Musashi"g[trad. du japonais par Jacques Lalloz]g[adapté par Philippe Marcel] aPariscÉd. Tonkamd2001e35-RennesgImpr. Oberthur aNon paginé [ca 206] p.cill. en noir et en coul., couv. ill., jaquette ill. en coul.d19 cm 0tVagabondv4aTakehiko Inoué aManga a741.5 313527612935oISNI0000000121039965aInouebTakehikof1967-....4070 311929525936aYoshikawabEijif1892-19624100 312040286937oISNI0000000108815456aLallozbJacques4730 312320807938aMarcelbPhilippe4010 0aFRbFR-751131015c20020103gAFNORhFRBNF3771076900000002intermrc 5FR-751131010:2003-196584 fSTJ000095w2014-06-2630009117cMTRSTJ20kBD VAG 452012-09-07o0efiction adulte bande dessineesddcrBDm2014-06-19bMTRSTJ6MTRSTJ \ No newline at end of file diff --git a/doc/extern_libs.org b/doc/extern_libs.org index 35f6c37ab6950ef06abad34ecc0c9499b45438e9..281e10e8f8a2af49804ed38a19aa3e7c4f7ba50c 100644 --- a/doc/extern_libs.org +++ b/doc/extern_libs.org @@ -39,6 +39,7 @@ | DateTimepicker | MIT License | | Choix de la date et de l'heure dans les articles | X ajout du support des dates courante sans partie d'heures | https://github.com/mugifly/jquery-simple-datetimepicker/ | | DataTables | MIT Licence | | Ecran des variables | | http://www.datatables.net/ | | CodeMirror | MIT Licence | | Edition code source javascript | | http://codemirror.net | -| | | | | | | +| Butterfly Lighbox | GPL | - | Accessible lightbox plugin | | http://irama.org/web/dhtml/butterfly/ | + diff --git a/includes.php b/includes.php index 12dbbf146c838418b938987da9909570efb216db..6f619f1a16252dd94e068f9a6f61ee4079322f0c 100644 --- a/includes.php +++ b/includes.php @@ -24,25 +24,7 @@ set_include_path($base_path . '/library' . PATH_SEPARATOR . $base_path . '/library/storm/zf/library' . PATH_SEPARATOR . get_include_path()); -// Includes de base include_once "local.php"; -$site= substr($_SERVER['SCRIPT_NAME'], 1, strpos($_SERVER['SCRIPT_NAME'], "index.php") -2); -$parts=explode('/', $site); -if(!file_exists("../" . end($parts))) { - echo "Erreur de vhost !" ; - exit ; -} - -define("BASE_URL", "/" . $site) ; - -function rootUrl() { - return (isset($_SERVER['HTTPS']) && !in_array($_SERVER['HTTPS'], ['', 'off']) ? 'https://' : 'http://') - . $_SERVER['SERVER_NAME'] - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']); -} -define('ROOT_URL', rootUrl()); - include_once "fonctions/fonctions.php"; -require_once "Zend/Loader.php"; require_once "library/startup.php"; ?> \ No newline at end of file diff --git a/index.php b/index.php index 92222100a805f5fe82dfe97230d0ce3153d51525..b5e532024536e8039a8abcb1ba3a02918a382c54 100644 --- a/index.php +++ b/index.php @@ -18,7 +18,11 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +//vérification du paramétrage Bokeh +if ((!file_exists('local.php') || !file_exists('config.ini') || !file_exists('cosmogramme/config.php')) //test existence fichiers de paramétrage + && file_exists('scripts/install-bokeh.php')) { //contrôle présence script de paramétrage + include('scripts/install-bokeh.php'); +} require('includes.php'); try { diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index d1ffe31dec3a3482196ece42f459bd7beb90eb1e..b01bcbfac769c99a16a964d3a653a8219da7de81 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -136,6 +136,14 @@ class Class_AdminVar extends Storm_Model_Abstract { } + /** + * @return bool + */ + public static function isJamendoEnabled() { + return ('' != trim(Class_AdminVar::get('JAMENDO_CLIENT_ID'))); + } + + /** * @return bool */ @@ -612,6 +620,14 @@ class Class_AdminVar extends Storm_Model_Abstract { 'description' => 'Le gestionnaire de contenu affiche les articles sous forme de liste paginée au lieu de d\'une arborescence. Cet affichage est adapté lorsque le nombre d\'article devient trop important', 'type' => self::TYPE_ON_OFF, ], + 'ALBUMS_LIST_MODE' => [ + 'description' => 'Le gestionnaire de contenu affiche les albums sous forme de liste paginée au lieu de d\'une arborescence. Cet affichage est adapté lorsque le nombre d\'albums devient trop important', + 'type' => self::TYPE_ON_OFF, + ], + 'DILICOM_PNB' => [ + 'description' => 'Activation du PNB Dilicom', + 'type' => self::TYPE_ON_OFF, + ], 'DILICOM_PNB_GLN_COLLECTIVITE' => [ 'description' => 'Gln de la collectivité, il est fourni par Dilicom.', ], @@ -661,7 +677,10 @@ class Class_AdminVar extends Storm_Model_Abstract { 'description' => 'Login du portail fourni par Kidilangues.', ], 'KIDILANGUES_PWD' => [ - 'description' => 'Paswword du portail fourni par Kidilangues.', + 'description' => 'Password du portail fourni par Kidilangues.', + ], + 'JAMENDO_CLIENT_ID' => [ + 'description' => 'ID client Jamendo', ], ]; diff --git a/library/Class/Album.php b/library/Class/Album.php index ef39a702a913c098482b4914dee9ae4d64bb1f54..0f65ffc44e02ed10948c71b130ef09ce18549e86 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -111,7 +111,11 @@ class Class_Album extends Storm_Model_Abstract { 'usage_constraints' => ['model' => 'Class_Album_UsageConstraint', 'role' => 'album', 'instance_of' => 'Class_Album_UsageConstraints', - 'dependents' => 'delete']]; + 'dependents' => 'delete'], + + 'items' => ['model' => 'Class_Album_Item', + 'role' => 'album', + 'dependents' => 'delete']]; protected $_default_attribute_values = ['titre' => '', 'sous_titre' => '', @@ -500,6 +504,7 @@ class Class_Album extends Storm_Model_Abstract { public function isAudioRecord() { return ($this->getTypeDocId() == Class_TypeDoc::ONEDTOUCH || + $this->getTypeDocId() == Class_TypeDoc::JAMENDO || $this->getTypeDocId() == Class_TypeDoc::AUDIO_RECORD); } @@ -519,6 +524,11 @@ class Class_Album extends Storm_Model_Abstract { } + public function isJamendo() { + return $this->getTypeDocId() == Class_TypeDoc::JAMENDO; + } + + public function isNumeriquePremium() { return $this->getTypeDocId() == Class_TypeDoc::NUMERIQUEPREMIUM; } diff --git a/library/Class/Album/Item.php b/library/Class/Album/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..c612997831e0ff7f19d1bc6fc30e1157b73edaa8 --- /dev/null +++ b/library/Class/Album/Item.php @@ -0,0 +1,28 @@ +<?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_Album_Item extends Storm_Model_Abstract { + protected + $_table_name = 'album_item', + $_belongs_to = ['album' => ['model' => 'Class_Album']], + $_default_attribute_values = ['loan_count' => 0]; +} +?> \ No newline at end of file diff --git a/library/Class/Album/UsageConstraint.php b/library/Class/Album/UsageConstraint.php index 4fb22d5a3ea376a22260b05898c2e47102cd6573..903fec42acc839d4cd985d7323624f2fdfad3875 100644 --- a/library/Class/Album/UsageConstraint.php +++ b/library/Class/Album/UsageConstraint.php @@ -20,23 +20,33 @@ */ +class Class_Album_UsageConstraintLoader extends Storm_Model_Loader { + public function loanConstraint($album) { + return $album->getUsageConstraints()->getLoanConstraint(); + } +} + + class Class_Album_UsageConstraint extends Storm_Model_Abstract { + use Trait_TimeSource; + const DEVICE_SHARE_CONSTRAINT = '04', LOAN_CONSTRAINT = '06', AVAILABILITY_CONSTRAINT = '07', + ORDER_LINE_ID = 'order_line_id', DURATION = 'duration', QUANTITY = 'quantity', - ORDER_LINE_ID = 'order_line_id', - MAX_NB_OF_USERS = 'max_number_of_users'; + MAX_NB_OF_USERS = 'max_number_of_users', + END_DATE = 'end_date'; protected $_table_name = 'album_usage_constraints', + $_loader_class = 'Class_Album_UsageConstraintLoader', $_belongs_to = ['album' => ['model' => 'Class_Album']], $_default_attribute_values = ['serialized_datas' => ''], $_datas; - public function beforeSave() { $this->setSerializedDatas($this->getDatas()->serialized()); } @@ -68,11 +78,13 @@ class Class_Album_UsageConstraint extends Storm_Model_Abstract { return $this->getDatas()->get(self::ORDER_LINE_ID); } + public function setOrderLineId($id) { $this->getDatas()->set(self::ORDER_LINE_ID, $id); return $this; } + public function setDuration($value) { $this->getDatas()->set(self::DURATION, $value); return $this; @@ -101,6 +113,92 @@ class Class_Album_UsageConstraint extends Storm_Model_Abstract { } + public function isLoanedBy($user) { + return $this->getLoanedBy($user) + ? true : false; + } + + + public function getLoanedBy($user) { + return Class_Pret::findFirstBy(['id_notice_origine' => $this->getAlbum()->getIdOrigine(), + 'idabon' => $user->getIdabon(), + 'en_cours' => 1]); + } + + + public function isLoanable() { + return + $this->getAlbum()->getUsageConstraints()->isAValidOffer() + && $this->hasSimultaneousLoanRemaining() + && $this->hasAvailableQuantity(); + } + + + public function hasSimultaneousLoanRemaining() { + return $this->numberOfSimultaneousLoansRemaning() <= $this->getMaxNumberOfUsers(); + } + + + public function numberOfSimultaneousLoansRemaning() { + return $this->findItemDoIfNone( + function($item) { + return $this->getMaxNumberOfUsers() - $item->getLoanCount(); + }, + false ); + } + + + public function updateLoanUsers($count) { + return $this->findItemDoIfNone( + function($item) { + return $item->setLoanCount($count); + }, + false ); + } + + + public function hasAvailableQuantity() { + return $this->findItemDoIfNone( + function($item) { + return $item->getQuantity() < $this->getQuantity(); + }, + false ); + } + + + public function quantityOfLoansRemaining() { + return $this->findItemDoIfNone( + function($item) { + return $this->getQuantity() - $item->getQuantity(); + }, + 0 ); + } + + + protected function findItemDoIfNone($closure, $return_value) { + if(!$item = Class_Album_Item::findFirstBy(['album_id' => $this->getAlbum()->getId()])) + return $return_value; + + return $closure($item); + } + + + public function isAValidOffer() { + return $this->getEndDate() > date(DATE_ISO8601, $this->getCurrentTime()); + } + + + public function getEndDate() { + return $this->getDatas()->get(self::END_DATE); + } + + + public function setEndDate() { + $this->getDatas()->set(self::END_DATE, date(DATE_ISO8601, ($this->getCurrentTime() + ($this->getDuration() * 24 * 3600)))); + return $this; + } + + public function acceptVisitor($visitor) { $visitor->visitUsageType($this->getUsageType()); $this->getDatas() diff --git a/library/Class/Album/UsageConstraints.php b/library/Class/Album/UsageConstraints.php index a8b591ac1a85aa7b14e7eb101d12226b147fb695..b4c7097cfe971b96b4483a3c6538652b9b1b37c0 100644 --- a/library/Class/Album/UsageConstraints.php +++ b/library/Class/Album/UsageConstraints.php @@ -22,7 +22,16 @@ class Class_Album_UsageConstraints extends Storm_Model_Collection_Abstract { public function getLoanConstraint() { - return $this->detect(function($c) {return $c->isLoanConstraint();}); + return ($constraint = $this->detect(function($c) {return $c->isLoanConstraint();})) + ? $constraint + : new Class_Album_UsageConstraint(); + } + + + public function getAvailabilityConstraint() { + return ($constraint = $this->detect(function($c) {return $c->isAvailabilityConstraint();})) + ? $constraint + : new Class_Album_UsageConstraint(); } @@ -46,8 +55,58 @@ class Class_Album_UsageConstraints extends Storm_Model_Collection_Abstract { } + public function quantityOfLoansRemaining() { + return $this->getLoanConstraint()->quantityOfLoansRemaining(); + } + + public function getAvailabilityDuration() { - return $this->detect(function($c) {return $c->isAvailabilityConstraint();})->getDuration(); + return $this->getAvailabilityConstraint()->getDuration(); + } + + + public function getAvailabilityEndDate() { + return $this->getAvailabilityConstraint()->getEndDate(); + } + + + public function isAValidOffer() { + return $this->getAvailabilityConstraint()->isAValidOffer(); + } + + + public function isLoanedBy($user) { + return $this->getLoanConstraint()->isLoanedBy($user); + } + + + public function getLoanedBy($user) { + return $this->getLoanConstraint()->getLoanedBy($user); + } + + + public function isLoanable() { + return $this->getLoanConstraint()->isLoanable(); + } + + + public function hasSimultaneousLoanRemaining() { + return 0 < (int)$this->getLoanConstraint()->numberOfSimultaneousLoansRemaning(); + } + + + public function numberOfSimultaneousLoansRemaning() { + return $this->getLoanConstraint()->numberOfSimultaneousLoansRemaning(); + } + + + public function updateLoanUsers($count) { + return $this->getLoanConstraint()->updateLoanUsers($count); + } + + + public function hasAvailableQuantity() { + return $this->getLoanConstraint()->hasAvailableQuantity(); } diff --git a/library/Class/AlbumCategorie.php b/library/Class/AlbumCategorie.php index 6baacc7eff8b332828ec2558f9ee69653d21e176..1439eb83fe6aa49dd9e7d028196891597dd8ea67 100644 --- a/library/Class/AlbumCategorie.php +++ b/library/Class/AlbumCategorie.php @@ -63,33 +63,31 @@ class AlbumCategorieLoader extends Storm_Model_Loader { class Class_AlbumCategorie extends Storm_Model_Abstract { + use Trait_TreeNode; + protected $_loader_class = 'AlbumCategorieLoader'; protected $_table_name = 'album_categorie'; protected $_table_primary = 'id'; - protected $_belongs_to = array('parent_categorie' => array('model' => 'Class_AlbumCategorie', - 'referenced_in' => 'parent_id')); + protected $_belongs_to = ['parent_categorie' => ['model' => 'Class_AlbumCategorie', + 'referenced_in' => 'parent_id']]; - protected $_has_many = array('sous_categories' => array('model' => 'Class_AlbumCategorie', - 'role' => 'parent', - 'dependents' => 'delete'), + protected $_has_many = ['sous_categories' => ['model' => 'Class_AlbumCategorie', + 'role' => 'parent', + 'dependents' => 'delete'], - 'albums' => array('model' => 'Class_Album', - 'role' => 'categorie', - 'order' => 'titre', - 'dependents' => 'delete'), + 'albums' => ['model' => 'Class_Album', + 'role' => 'categorie', + 'order' => 'titre', + 'dependents' => 'delete'], - 'validated_albums' => array('model' => 'Class_Album', + 'validated_albums' => ['model' => 'Class_Album', 'role' => 'categorie', 'order' => 'titre', 'dependents' => 'delete', - 'scope' => ['status' => Class_Album::STATUS_VALIDATED])); - - protected $_default_attribute_values = array('parent_id' => 0); + 'scope' => ['status' => Class_Album::STATUS_VALIDATED]]]; + protected $_default_attribute_values = ['parent_id' => 0]; - public static function getLoader() { - return self::getLoaderFor(__CLASS__); - } public function hasChildren() { @@ -111,10 +109,12 @@ class Class_AlbumCategorie extends Storm_Model_Abstract { return !$this->hasChildren(); } + public function getItems() { return Class_Album::getLoader()->getItemsOf($this->getId()); } + public function isNew() { return parent::isNew() || 0 == $this->getId(); } @@ -158,7 +158,7 @@ class Class_AlbumCategorie extends Storm_Model_Abstract { * @return array() */ public function getHierarchy() { - $hierarchy = array(); + $hierarchy = []; $this->_getParentHiearchyOn($hierarchy); return $hierarchy; } @@ -168,14 +168,24 @@ class Class_AlbumCategorie extends Storm_Model_Abstract { * @param array $hierarchy */ protected function _getParentHiearchyOn(array &$hierarchy) { - if (null !== ($parent = $this->getParentCategorie())) { + if (null !== ($parent = $this->getParentCategorie())) $parent->getHierarchyOn($hierarchy); - } } + public function getIdEad() { - return "C".$this->getId(); + return 'C' . $this->getId(); } -} -?> \ No newline at end of file + + /** @see Trait_TreeNode */ + public function getParent() { + return $this->getParentCategorie(); + } + + + /** @see Trait_TreeNode */ + public function getChildren() { + return $this->getAlbums(); + } +} \ No newline at end of file diff --git a/library/Class/AlbumRessource.php b/library/Class/AlbumRessource.php index 8eb6247f64437422fe32ac3ef979c083bb0c9f10..298f698cc90436c8cd2b051eb7f39dcc6963467b 100644 --- a/library/Class/AlbumRessource.php +++ b/library/Class/AlbumRessource.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 AlbumRessourceLoader extends Storm_Model_Loader { /** @@ -37,7 +37,7 @@ class AlbumRessourceLoader extends Storm_Model_Loader { class Class_AlbumRessource extends Storm_Model_Abstract { use Trait_Translator; - + const BASE_PATH = 'media/'; const TILES_DIR = 'tiles/'; @@ -68,14 +68,14 @@ class Class_AlbumRessource extends Storm_Model_Abstract { /** @var Imagick */ protected $_image; - + /** @var AlbumRessource_TilesGenerator */ protected $_tiles_generator; /** @var int used solely in validation */ protected $_media_type; - + protected $_table_name = 'album_ressources'; protected $_primary_key = 'id'; protected $_loader_class = 'AlbumRessourceLoader'; @@ -93,7 +93,8 @@ class Class_AlbumRessource extends Storm_Model_Abstract { 'matiere' => '', 'poster' => '', 'url' => '', - 'unimarc' => '' + 'unimarc' => '', + 'license' => '' ]; @@ -106,7 +107,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { return self::$_image_extensions; } - + public static function getAudioExtensions() { return self::$_audio_extensions; } @@ -179,7 +180,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { $permalink = $this->getAlbum()->getPermalink(); $permalink['folio'] = $this->getFolio(); return $permalink; - } + } /** @@ -224,7 +225,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { public function receivePoster() { $oldThumbnail = $this->getThumbnailPath(); - + // fichier non requis if (!$this->isFileUploadedForName('poster')) { if ($this->isImage()) { @@ -233,7 +234,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { return $this->createThumbnail(); } - + return true; } @@ -258,7 +259,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { return $this->createThumbnail(); } - + /** * @return bool */ @@ -266,7 +267,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { // fichier non requis if (!$this->isFileUploadedForName('fichier')) return true; - + $upload = $this->getUploadHandler('fichier'); if (!$upload->receive()) { @@ -337,7 +338,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { public function getImage() { if (isset($this->_image)) return $this->_image; - + try { $this->_image = new Imagick(($this->isImage()) ? $this->getOriginalPath() : @@ -558,14 +559,14 @@ class Class_AlbumRessource extends Storm_Model_Abstract { 'crop_top' => 0), $params); - $image->cropImage($image->getImageWidth() - $resize_params['crop_left'] - $resize_params['crop_right'], - $image->getImageHeight() - $resize_params['crop_top'] - $resize_params['crop_bottom'], - $resize_params['crop_left'], + $image->cropImage($image->getImageWidth() - $resize_params['crop_left'] - $resize_params['crop_right'], + $image->getImageHeight() - $resize_params['crop_top'] - $resize_params['crop_bottom'], + $resize_params['crop_left'], $resize_params['crop_top']); - $image->resizeImage($resize_params['width'], - $resize_params['height'], - Imagick::FILTER_LANCZOS, + $image->resizeImage($resize_params['width'], + $resize_params['height'], + Imagick::FILTER_LANCZOS, 1); $image->writeImage($filepath); @@ -709,7 +710,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { $this->deletePosterAndThumbnail(); $this->setPoster(''); } - + if ((self::MEDIA_TYPE_URL == $mediaType) && $this->hasFichier()) { $this->deleteFichierAndThumbnail(); $this->setFichier(''); @@ -760,7 +761,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { /** * @return bool - */ + */ public function isImage() { return $this->isFileExtensionIn($this->getImageExtensions()); } @@ -768,7 +769,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { /** * @return bool - */ + */ public function isFlash() { return $this->isFileExtensionIn(['swf']); } @@ -776,7 +777,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { /** * @return bool - */ + */ public function isVideo() { return $this->isFileExtensionIn(['mov']); } @@ -784,16 +785,19 @@ class Class_AlbumRessource extends Storm_Model_Abstract { /** * @return bool - */ + */ public function isFile() { return !($this->isImage() or $this->isVideo() or $this->isFlash()); } public function isAudio() { - return $this->isFileExtensionIn($this->getAudioExtensions()); + return + $this->getAlbum()->isJamendo() + || + $this->isFileExtensionIn($this->getAudioExtensions()); } - + /** * @return string @@ -807,7 +811,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { } - /** + /** * @param array $extensions * @return bool */ @@ -816,7 +820,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { } - /** + /** * @return string */ protected function humanizeFilename() { @@ -846,7 +850,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { return $folio; } - + public function setMediaType($type) { $this->_media_type = $type; return $this; @@ -856,13 +860,13 @@ class Class_AlbumRessource extends Storm_Model_Abstract { public function getMediaType() { return $this->_media_type; } - + public function validate() { $media_type = $this->getMediaType(); if (!$media_type) return; - + if (self::MEDIA_TYPE_URL == $media_type) { $this ->validateAttribute('url', 'Zend_Validate_NotEmpty', 'Url du média requise') @@ -940,12 +944,12 @@ class Class_AlbumRessource extends Storm_Model_Abstract { if (isset($unimarc[$field])) return $unimarc[$field]; return null; - + } public function setUnimarc($array_or_string) { - if (is_array($array_or_string)) + if (is_array($array_or_string)) parent::setUnimarc(serialize($array_or_string)); else parent::setUnimarc($array_or_string); @@ -973,7 +977,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { foreach($unimarcs as $k => $unimarc) if (is_array($unimarc) && $unimarc['field'] == $zone) $to_delete[] = $k; - + foreach($to_delete as $i) unset($unimarcs[$i]); @@ -1000,9 +1004,9 @@ class Class_AlbumRessource extends Storm_Model_Abstract { return array_filter( array_map( function($item) { - return (!is_array($item) || !isset($item['a'])) ? + return (!is_array($item) || !isset($item['a'])) ? null : $item['a']; - }, + }, $this->getAuthors())); } @@ -1016,9 +1020,9 @@ class Class_AlbumRessource extends Storm_Model_Abstract { array_map( function($item) { return (!is_array($item) || '701' !== $item['field'] - || !isset($item['data']) || !isset($item['data']['a'])) ? + || !isset($item['data']) || !isset($item['data']['a'])) ? null : $item['data']; - }, + }, $this->getUnimarcAsArray())); } @@ -1027,9 +1031,9 @@ class Class_AlbumRessource extends Storm_Model_Abstract { * add author in unimarc container if not present with the same function */ public function addAuthor($name, $function = null) { - if (!$name) + if (!$name) return $this; - + $datas = ['a' => $name]; if (null !== $function) $datas['4'] = $function; @@ -1037,7 +1041,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { if (!in_array((string)$name, $this->getAuthorsNames())) return $this->addMultipleUnimarc('701', $datas); - if (!$function) + if (!$function) return $this; $found = false; @@ -1045,7 +1049,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { if ($name == $author['a'] && $function == $author['4']) { $found = true; break; - } + } } return (!$found) ? $this->addMultipleUnimarc('701', $datas) : $this; @@ -1053,10 +1057,10 @@ class Class_AlbumRessource extends Storm_Model_Abstract { public function findTitle() { - return - $this->getTitre() - ? $this->getTitre() - : ($this->getFichier() + return + $this->getTitre() + ? $this->getTitre() + : ($this->getFichier() ? $this->humanizeFilename() : $this->getFolio()); } @@ -1064,8 +1068,8 @@ class Class_AlbumRessource extends Storm_Model_Abstract { public function acceptVisitor($visitor) { $view_helper = (new ZendAfi_Controller_Action_Helper_View()); - $visitor->visitRessourceDatas($this->findTitle(), - $this->getDuration(), + $visitor->visitRessourceDatas($this->findTitle(), + $this->getDuration(), $this->getAuthorsNames(), $view_helper->album_PlayRessourceUrl($this)); } diff --git a/library/Class/AvisNotice.php b/library/Class/AvisNotice.php index 0d68bf1713d90aec162302409ed3b95e759699d3..b533137fcbaf02f2cc9b5f4a0c85c43d4c28129e 100644 --- a/library/Class/AvisNotice.php +++ b/library/Class/AvisNotice.php @@ -26,7 +26,7 @@ class AvisNoticeLoader extends Storm_Model_Loader { $preferences["aleatoire"] = 0; // on veut toutes les notices $preferences["avec_avis"] = 1; //seulement les notices avec avis - $notices = Class_Catalogue::getLoader()->getNoticesByPreferences($preferences); + $notices = Class_Catalogue::getNoticesByPreferences($preferences); if (count($notices) == 0) { //on ne doit retourner aucun avis @@ -73,7 +73,7 @@ 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) { + public function getAvisFromPreferences($preferences, $limit_page=null) { $params = ['order' => 'DATE_AVIS DESC']; $preferences = array_merge(['id_panier' => 0, @@ -90,6 +90,10 @@ class AvisNoticeLoader extends Storm_Model_Loader { $this->_addCatalogueConditions($preferences, $params); $this->_addStatutAbonBibWhereClause($abon_ou_bib, $params); + + if ($limit_page) + $params['limitPage'] = $limit_page; + return Class_AvisNotice::getLoader()->findAllBy($params); } diff --git a/library/Class/Batch.php b/library/Class/Batch.php index 47085490b7a07778f8d2ba06bc7b1c56b1738a8a..85b5d2ecae0db2bd362c4684db9843d8c7191a80 100644 --- a/library/Class/Batch.php +++ b/library/Class/Batch.php @@ -43,6 +43,7 @@ class Class_BatchLoader extends Storm_Model_Loader{ 'MOISSONNAGE_TOUTAPPRENDRE' => new Class_Batch_ToutApprendre(), 'MOISSONNAGE_1DTOUCH' => new Class_Batch_OneDTouch(), 'MOISSONNAGE_ORPHEA' => new Class_Batch_Orphea(), + 'MOISSONNAGE_JAMENDO' => new Class_Batch_Jamendo(), ]; } diff --git a/library/Class/Batch/Jamendo.php b/library/Class/Batch/Jamendo.php new file mode 100644 index 0000000000000000000000000000000000000000..6f1f4a7e548c5b988f67939c015cd1befcc458d4 --- /dev/null +++ b/library/Class/Batch/Jamendo.php @@ -0,0 +1,28 @@ +<?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_Batch_Jamendo extends Class_Batch_RessourceNumerique{ + protected function _getService() { + return new Class_WebService_BibNumerique_Jamendo(); + } +} +?> diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 53f37020d44ceac39ad8bf2734c432871f640ed3..1a16adb404b32e7b6919d2eb3bed7cdb4d8bd302 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -252,7 +252,7 @@ class Class_Bib extends Storm_Model_Abstract { if (!$aff_zone = ZendAfi_Filters_Serialize::unserialize($this->getAffZone())) $aff_zone = []; - return array_merge(['profilID' => null, + return array_merge(['profilID' => '', 'libelle' => '', 'posX' => 0, 'posY' => 0, @@ -263,14 +263,49 @@ class Class_Bib extends Storm_Model_Abstract { public function getUrl() { $props = $this->getAffZoneAsArray(); - $profil = Class_Profil::find($props["profilID"]); - $parts = $profil ? $profil->getUrlParts() : ['controller' => 'bib', - 'action' => 'bibview', - 'id' => $this->getId()]; + + $parts = ['controller' => 'bib', + 'action' => 'bibview', + 'id' => $this->getId()]; + + if($profil = Class_Profil::find($props["profilID"])) + $parts = $profil->getUrlParts(); + return Class_Url::assemble($parts, null, true); } + public function getPosX() { + return $this->getAffZoneKey('posX'); + } + + + public function getPosY() { + return $this->getAffZoneKey('posY'); + } + + + public function getPosPoint() { + return $this->getAffZoneKey('posPoint'); + } + + + public function getProfilId() { + return $this->getAffZoneKey('profilID'); + } + + + public function getAffZoneKey($key) { + if (!$aff_zone = ZendAfi_Filters_Serialize::unserialize($this->getAffZone())) + return 0; + + if(!isset($aff_zone[$key])) + return 0; + + return $aff_zone[$key]; + } + + public function getBibsBySite($id_site=0) { $where = ''; if($id_site!=0) diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index 4c5197485946cfc198704bbed2874c70fbdbb16e..eddb18f7734d0fc6616df7d19c04b90e37c1530d 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -18,11 +18,9 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Catalogues de notices -//////////////////////////////////////////////////////////////////////////////// -class CatalogueLoader extends Storm_Model_Loader { + +class CatalogueLoader extends Storm_Model_Loader { const DEFAULT_ITEMS_BY_PAGE = 100; public function loadNoticesFor($catalogue, $itemsByPage = self::DEFAULT_ITEMS_BY_PAGE, $page = 1, $find_all_params = null) { @@ -44,33 +42,35 @@ class CatalogueLoader extends Storm_Model_Loader { public function findAllCataloguesAIndexer() { - $catalogues=Class_Catalogue::findAllBy(['indexer'=>true]); - return $catalogues; + return Class_Catalogue::findAllBy(['indexer'=>true]); } public function getDomainsForBreadcrumb($breadcrumb) { - $domains_ids=array_filter(explode(';',$breadcrumb)); - $domains=[]; - foreach ($domains_ids as $domain_id) { - $domains[]=Class_Catalogue::find($domain_id); - } + $domains_ids = array_filter(explode(';', $breadcrumb)); + $domains = []; + foreach ($domains_ids as $domain_id) + $domains[] = Class_Catalogue::find($domain_id); + return $domains; } - public function updateAllThesaurusForCatalogueChildren($catalogue_id,$thesaurus_id) { - $catalogues=Class_Catalogue::findAllBy(['parent_id'=>$catalogue_id]); + public function updateAllThesaurusForCatalogueChildren($catalogue_id, $thesaurus_id) { + $catalogues = Class_Catalogue::findAllBy(['parent_id' => $catalogue_id]); foreach ($catalogues as $catalogue) { - Class_CodifThesaurus::deleteAllWithIdOrigineAndCode($catalogue->getId(),'Catalogue'); - $new_thesaurus=$catalogue->getNewThesaurus(); - $new_thesaurus_id=Class_CodifThesaurus::findNextThesaurusChildId($thesaurus_id); + Class_CodifThesaurus::deleteAllWithIdOrigineAndCode($catalogue->getId(), + 'Catalogue'); + $new_thesaurus = $catalogue->getNewThesaurus(); + $new_thesaurus_id = Class_CodifThesaurus::findNextThesaurusChildId('catalogue', + $thesaurus_id); $new_thesaurus->setIdThesaurus($new_thesaurus_id); $new_thesaurus->save(); - Class_Catalogue::getLoader()->updateAllThesaurusForCatalogueChildren($catalogue->getId(),$new_thesaurus_id); - } + Class_Catalogue::getLoader() + ->updateAllThesaurusForCatalogueChildren($catalogue->getId(), $new_thesaurus_id); + } } @@ -81,19 +81,18 @@ class CatalogueLoader extends Storm_Model_Loader { if ('' == ($where = $this->clausesFor($catalogue))) return 0; - return Class_Notice::getLoader()->countBy(array('where' => $where)); + return Class_Notice::getLoader()->countBy(['where' => $where]); } public function clausesFor($catalogue) { - $conditions = array(); + $conditions = []; if ($fromUntil = $this->fromUntilClauseFor($catalogue)) $conditions[] = $fromUntil; if ($catalogue->isMatchingAllNotices()) return $fromUntil ? $fromUntil : '1=1'; - if ($facets = $this->facetsClauseFor($catalogue)) $conditions[] = $facets; @@ -109,7 +108,6 @@ class CatalogueLoader extends Storm_Model_Loader { if ($new = $this->nouveauteClauseFor($catalogue)) $conditions[] = $new; - if (0 == count($conditions)) return ''; @@ -118,7 +116,7 @@ class CatalogueLoader extends Storm_Model_Loader { public function noticesLinked($catalogue) { - if(!$catalogue) + if (!$catalogue) return ''; if (!Class_NoticeDomain::getClesNoticesForDomain($catalogue->getId())) @@ -134,27 +132,30 @@ class CatalogueLoader extends Storm_Model_Loader { */ public function facetsClauseFor($catalogue, $against = '') { $against_ou = ''; - $facets = array('B' => $catalogue->getBibliotheque(), - 'S' => $catalogue->getSection(), - 'G' => $catalogue->getGenre(), - 'L' => $catalogue->getLangue(), - 'Y' => $catalogue->getAnnexe(), - 'E' => $catalogue->getEmplacement()); + $facets = ['B' => $catalogue->getBibliotheque(), + 'S' => $catalogue->getSection(), + 'G' => $catalogue->getGenre(), + 'L' => $catalogue->getLangue(), + 'Y' => $catalogue->getAnnexe(), + 'E' => $catalogue->getEmplacement()]; foreach ($facets as $k => $v) $against .= Class_Catalogue::getSelectionFacette($k, $v); - $facets = array('A' => $catalogue->getAuteur(), - 'M' => $catalogue->getMatiere(), - 'D' => $catalogue->getDewey(), - 'P' => $catalogue->getPcdm4(), - 'H' => $catalogue->getThesaurus(), - 'Z' => $catalogue->getTags(), - 'F' => $catalogue->getInteret()); + $facets = ['A' => $catalogue->getAuteur(), + 'M' => $catalogue->getMatiere(), + 'D' => $catalogue->getDewey(), + 'P' => $catalogue->getPcdm4(), + 'H' => $catalogue->getThesaurus(), + 'Z' => $catalogue->getTags(), + 'F' => $catalogue->getInteret()]; foreach ($facets as $k => $v) - $against_ou .= Class_Catalogue::getSelectionFacette($k, $v, in_array($k, array('M', 'D', 'P','H')), false); - + $against_ou .= Class_Catalogue::getSelectionFacette($k, + $v, + in_array($k, + ['M', 'D', 'P','H']), + false); if ('' != $against_ou) $against .= ' +(' . $against_ou . ")"; @@ -171,15 +172,14 @@ class CatalogueLoader extends Storm_Model_Loader { return ''; $parts = array_filter(explode(';', $docType)); - if (1 == count($parts)) - return 'type_doc=' . $parts[0]; - - return 'type_doc IN (' . implode(', ', $parts) . ')'; + return (1 == count($parts)) ? + ('type_doc=' . $parts[0]) : + ('type_doc IN (' . implode(', ', $parts) . ')'); } public function yearClauseFor($catalogue) { - $clauses = array(); + $clauses = []; if ($start = $catalogue->getAnneeDebut()) $clauses[] = "annee >= '" . $start . "'"; @@ -194,7 +194,7 @@ class CatalogueLoader extends Storm_Model_Loader { public function coteClauseFor($catalogue) { - $clauses = array(); + $clauses = []; if ($start = $catalogue->getCoteDebut()) $clauses[] = "cote >= '" . strtoupper($start) . "'"; @@ -218,8 +218,7 @@ class CatalogueLoader extends Storm_Model_Loader { public function fromUntilClauseFor($catalogue) { - $clauses = array(); - + $clauses = []; if ($start = $catalogue->getFrom()) $clauses[] = "left(date_maj, 10) >= '" . $start . "'"; @@ -512,7 +511,9 @@ class CatalogueLoader extends Storm_Model_Loader { $thesaurus_parent = $parent->saveThesauriParents(); if (!$thesaurus_parent) return null; - $new_thesaurus_id=Class_CodifThesaurus::findNextThesaurusChildId($thesaurus_parent->getIdThesaurus()); + $new_thesaurus_id=Class_CodifThesaurus::findNextThesaurusChildId( + 'catalogue', + $thesaurus_parent->getIdThesaurus()); } else if (strlen($thesaurus->getIdThesaurus())>8) { $new_thesaurus_id=Class_CodifThesaurus::findNextRacineCatalogue();} @@ -640,19 +641,26 @@ class Class_Catalogue extends Storm_Model_Abstract { public function getAllNoticeIdsForDomaine($nb_par_page,$numero_page) { $preferences = $this->toArray(); - $req=$this->getLoader()->getRequetes($preferences, ['id_notice']); + $req = $this->getLoader()->getRequetes($preferences, ['id_notice']); - $start=$nb_par_page*$numero_page; - $requete_ids=str_replace('LIMIT 5000', - "limit ".$nb_par_page*$numero_page.','.$nb_par_page, - $req['req_liste']); + if(!isset($req['req_liste'])) + return []; - $sql = Zend_Registry::get('sql'); + $start= $nb_par_page * $numero_page; + + $requete_ids = str_replace('LIMIT 5000', + "limit ".$nb_par_page*$numero_page.','.$nb_par_page, + $req['req_liste']); + + if(!$requete_ids) + return []; + + $sql = Zend_Registry::get('sql'); + $ids_rows = $sql->fetchAll($requete_ids); - $ids_rows=$sql->fetchAll($requete_ids); - $ids=[]; + $ids = []; foreach($ids_rows as $row) { - $ids[]=$row['id_notice']; + $ids[] = $row['id_notice']; } return $ids; @@ -995,7 +1003,8 @@ class Class_Catalogue extends Storm_Model_Abstract { $thesaurus_parent = $catalogue_parent->saveThesauriParents(); if (!$thesaurus_parent) return null; - $new_thesaurus_id=Class_CodifThesaurus::findNextThesaurusChildId($thesaurus_parent->getIdThesaurus()); + $new_thesaurus_id=Class_CodifThesaurus::findNextThesaurusChildId('catalogue', + $thesaurus_parent->getIdThesaurus()); $thesaurus->setIdThesaurus($new_thesaurus_id); $thesaurus->setLibelle($this->getLibelle()); $thesaurus->save(); @@ -1110,6 +1119,35 @@ class Class_Catalogue extends Storm_Model_Abstract { } + public function getBrowsableDomainsJson($domains = [], $options = []) { + $domains = $domains ? $domains : Class_Catalogue::getLoader()->findTopCatalogues(); + $browsable_domains = array_filter($domains, function($domain) {return $domain->hasSousDomaines();}); + + $data_domaines=[]; + foreach($browsable_domains as $domaine) { + $data_domaines [] = $domaine->getBrowsableDomainsJson($domaine->getSousDomaines(), $options); + } + + $leaf_domains = array_diff($domains, $browsable_domains); + $data_leaf_domains = []; + foreach($leaf_domains as $domain) { + $data_leaf_domains [] = ['id' => $domain->getId(), + 'label' => $domain->getLibelle(), + 'options' => ['ico' => URL_ADMIN_IMG.'picto/domaines_16.png', + 'multipleSelection' => false]]; + } + + + return ['id' => $this->getId() ? $this->getId() : 'domaines', + 'label' => $this->getLibelle() ? $this->getLibelle() : $this->_('Domaines'), + 'categories' => $data_domaines, + 'items' => $data_leaf_domains, + 'options' => ['ico' => URL_ADMIN_IMG.'picto/domaines_16.png', + 'multipleSelection' => false]]; + + } + + public function hasNoSettings() { $attributs = $this->_attributes; unset($attributs['libelle']); @@ -1128,15 +1166,14 @@ class Class_Catalogue extends Storm_Model_Abstract { if (!$this->isAttributeEmpty($key)) return false; } + return true; } public function isEmpty() { - if($this->hasNoSettings() && !Class_NoticeDomain::getClesNoticesForDomain($this->getId())) - return true; - - return false; + return $this->hasNoSettings() + && !Class_NoticeDomain::getClesNoticesForDomain($this->getId()); } } diff --git a/library/Class/CmsUrlTransformer.php b/library/Class/CmsUrlTransformer.php index 4bff4588f530dadf497f033d4744a068e1189fca..8c1b4ff9dc2d24a59da8847664189bc0b66cb571 100644 --- a/library/Class/CmsUrlTransformer.php +++ b/library/Class/CmsUrlTransformer.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 */ /* @@ -56,6 +56,80 @@ class Class_CmsUrlTransformer { '$1'.BASE_URL.'/$2', $rel); } + + + public static function removeHostFromArray($hostname,$basedir, $contents, &$replace_count = null) { + if (is_array($contents)) { + foreach ($contents as $index => $content) { + $contents[$index] = static::removeHostFromArray($hostname,$basedir, $content, $replace_count); + + } + return $contents; + } + + return static::removeHost($hostname,$basedir, $contents, $replace_count); + } + + + public static function removeHost($hostname,$basedir, $content, &$replace_count = null) { + + $content = static::removeHostFromHtml($hostname,$basedir, $content, $count); + $replace_count = $count; + + $content = static::removeHostFromUrl($hostname,$basedir, $content, $count); + $replace_count += $count; + + return $content; + } + + public static function removeHostFromHtml($hostname,$basedir, $content, &$replace_count = null) { + $hosts = ['web.afi-sa.net', + 'opac3.pergame.net', + 'www.'.$basedir, + 'www.'.$hostname, + $hostname]; + + $regs = []; + foreach($hosts as $host) { + $regs []= '/(< *(a|img)[^>]*(href|src) *= *["\'])((http:\/\/)?' . $host. ')?(\/'.$basedir.')?(\/[^"\']*)/i'; + } + + + return preg_replace($regs, '$1$7', $content, -1, $replace_count); + } + + + public static function removeBaseDir($hostname,$basedir, $content, &$replace_count = null) { + + $regs = static::checkHostFromUrl($hostname,$basedir); + + $result = preg_replace($regs, '$1$4', $content, -1, $replace_count); + return $result; + + } + + public static function checkHostFromUrl($hostname,$basedir) { + $hosts = ['web.afi-sa.net', + 'opac3.pergame.net', + 'www.'.$basedir, + 'www.'.$hostname, + $hostname]; + + $regs = []; + foreach($hosts as $host) { + $regs []= '/^((http:\/\/)?' . $host. ')?(\/'.$basedir.')?([\/?][^"\']*)/i'; + } + return $regs; + } + + + public static function removeHostFromUrl($hostname,$basedir, $content, &$replace_count = null) { + $regs = static::checkHostFromUrl($hostname,$basedir); + $result = preg_replace($regs, '$4', $content, -1, $replace_count); + if (strpos($result,"?") === 0 ) + $result="/".$result; + return $result; + } } ?> \ No newline at end of file diff --git a/library/Class/CodifGenre.php b/library/Class/CodifGenre.php index f98c9c69992febcc72fdfa06d10d20d456b59436..b0906a135202c2f06298f3b9a926ccd0e9448ec9 100644 --- a/library/Class/CodifGenre.php +++ b/library/Class/CodifGenre.php @@ -16,11 +16,14 @@ * * 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_CodifGenre extends Storm_Model_Abstract { - const CODE_FACETTE='G'; + use Trait_Facetable; + + const CODE_FACETTE = 'G'; + protected $_table_name = 'codif_genre'; protected $_table_primary = 'id_genre'; diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index 30f7f1c295d29f6d461e8106d4178fbe75645577..2eb5a6baa2a609688490451a1e11a100dc47e44b 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -55,9 +55,11 @@ class Class_CodifThesaurusLoader extends Storm_Model_Loader { } - public function findNextThesaurusChildId($parentid_thesaurus) { + /** @return string */ + public function findNextThesaurusChildId($code, $parentid_thesaurus) { Class_CodifThesaurus::clearCache(); - $last_thesaurus = Class_CodifThesaurus::findFirstBy(['where' => 'code like "catalogue" and id_thesaurus like "'.$parentid_thesaurus.'%"', + $last_thesaurus = Class_CodifThesaurus::findFirstBy(['code' => $code, + 'where' => 'id_thesaurus like "'.$parentid_thesaurus.'%"', 'order' => 'id_thesaurus desc']); if (!$last_thesaurus) return $parentid_thesaurus.'0001'; @@ -88,7 +90,7 @@ class Class_CodifThesaurusLoader extends Storm_Model_Loader { public function deleteAllWithIdOrigineAndCode($id_origine,$code_thesaurus) { if ($thesauri = Class_CodifThesaurus::findAllBy(['id_origine' => $id_origine, - 'code' => $code_thesaurus ])) + 'code' => $code_thesaurus ])) foreach ($thesauri as $thesaurus) { if ($thesaurus->getIdThesaurus()!='') sqlExecute('delete from codif_thesaurus where id_thesaurus like "'.$thesaurus->getIdThesaurus().'%"'); @@ -101,9 +103,8 @@ class Class_CodifThesaurusLoader extends Storm_Model_Loader { * $return Class_CodifThesaurus */ public function findByIdOrigineAndCode($id_origine,$code_thesaurus) { - if ($thesaurus = Class_CodifThesaurus::findFirstBy(['id_origine' => $id_origine, - 'code' => $code_thesaurus ])) + 'code' => $code_thesaurus ])) return $thesaurus; return Class_CodifThesaurus::findFirstBy(['id_origine' => $id_origine]); } @@ -161,7 +162,9 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { protected $_loader_class = 'Class_CodifThesaurusLoader'; protected $_table_name = 'codif_thesaurus'; protected $_table_primary = 'id'; - protected $_default_attribute_values = ['libelle_facette' => '']; + protected $_default_attribute_values = ['libelle_facette' => '', + 'id_thesaurus' =>null, + 'rules' => null]; public function getListeSuggestion($recherche,$mode,$limite_resultat,$theme) { @@ -212,6 +215,54 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { public function getFacetteIndex() { return self::CODE_FACETTE.$this->getIdThesaurus(); } + + + public function newChildEntry() { + $loader = $this->getLoader(); + $code = $this->getCode(); + return $loader->newInstance(['code' => $code, + 'id_thesaurus' => $loader->findNextThesaurusChildId( + $code, + $this->getIdThesaurus())]); + } + + + public function getOrCreateChild($id_origine, $label) { + if (!$entry = $this->getLoader()->findFirstBy(['code' => $this->getCode(), + 'id_origine' => $id_origine])) { + $entry = $this + ->newChildEntry() + ->updateAttributes(['id_origine' => $id_origine, + 'libelle' => $label]); + $entry->save(); + } + return $entry; + } + + + public function withLabelRulesDo($closure) { + $rules = json_decode($this->getRules()); + list($field, $subfield) = explode('$',$rules->label); + return $closure(sprintf('%03d', trim($field)), + trim($subfield)); + } + + public function getRulesLabel() { + return json_decode($this->getRules())->label; + + } + + public function validate() { + $this->check('' != $this->getLibelle(), 'Vous devez définir le libellé'); + if (!$this->getRules()) + return true; + + $this->check('' != $this->getRules(), 'Vous devez définir au moins une règle'); + $regles = str_replace(' ', '', $this->getRulesLabel()); + $this->check(preg_match('/^[0-9]{1,3}\$[a-z0-9]$/', $regles), + 'La règle n\'est pas de la forme 686$a'); + + } } ?> \ No newline at end of file diff --git a/library/Class/CodifTypeDoc.php b/library/Class/CodifTypeDoc.php index 10354e547686d4e6ab483e9b486dda4d193e0795..a2090a183db12c97e4341158255a6dc759b21ba0 100644 --- a/library/Class/CodifTypeDoc.php +++ b/library/Class/CodifTypeDoc.php @@ -16,12 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_CodifTypeDoc extends Storm_Model_Abstract { use Trait_Translator; - + protected $_table_name = 'codif_type_doc'; protected $_table_primary = 'type_doc_id'; protected $_default_attribute_values = ['bibliotheques' => '', @@ -35,7 +35,7 @@ class Class_CodifTypeDoc extends Storm_Model_Abstract { const VIDEO = 4; const LOGICIEL = 5; - protected static $_libelles = [ + protected static $_libelles = [ self::INCONNU => 'Non identifié', self::LIVRE => 'Livre', self::PERIODIQUE => 'Périodique' , @@ -43,7 +43,7 @@ class Class_CodifTypeDoc extends Storm_Model_Abstract { self::VIDEO => 'Vidéo', self::LOGICIEL => 'Logiciel', ]; - + public function getLibelle() { return $this->_(static::$_libelles[$this->getFamilleId()]); @@ -53,7 +53,7 @@ class Class_CodifTypeDoc extends Storm_Model_Abstract { public function setFamilleId($id) { if (!isset(static::$_libelles[$id])) $id=0; - return parent::_set('famille_id',$id); + return parent::_set('famille_id',$id); } @@ -61,6 +61,7 @@ class Class_CodifTypeDoc extends Storm_Model_Abstract { return static::$_libelles; } + public function afterSave() { $this->setId($this->getTypeDocId()); } diff --git a/library/Class/Codification.php b/library/Class/Codification.php index d2863f31a4cd8090067e35841d8b90dd4bbe3571..6e5d786f7a97377e23cb95fa9230f0a87ae477b0 100644 --- a/library/Class/Codification.php +++ b/library/Class/Codification.php @@ -104,6 +104,7 @@ class Class_Codification { } + public function getCodesLibellesFacette($concatenated_facettes) { $codes_libelles=[]; for($i=0; $i<strlen($concatenated_facettes); $i++) { @@ -312,4 +313,18 @@ class Class_Codification { return $libelle . ' d\'' . $chapeau; return $libelle . ' de ' . $chapeau; } + + + + + public function cleanDeletedFacets($concat_facets) { + $facets=''; + foreach ($this->getCodesLibellesFacette($concat_facets) as $code => $libelle) { + if ($libelle=='') + continue; + $facets.=$code; + } + return $facets; + } + } \ No newline at end of file diff --git a/library/Class/CommSigb.php b/library/Class/CommSigb.php index ba4ce745ccb7ac1038099fd5df0155c847240631..be57530e68edb76bcfead87cbabcccbb2aa90594 100644 --- a/library/Class/CommSigb.php +++ b/library/Class/CommSigb.php @@ -146,6 +146,18 @@ class Class_CommSigb { return $this->withUserAndSIGBDo($std_user, $supprimer); } + /** + * @param Class_Users $user + * @return array + */ + public function getUserAnnexe($std_user) { + $annexe = function ($user, $sigb) { + return $sigb->getUserAnnexe($user); + }; + + return $this->withUserAndSIGBDo($std_user, $annexe); + } + /** * @param Class_Users $user diff --git a/library/Class/CosmoVar.php b/library/Class/CosmoVar.php index 6ff2276bc1e7b4796406faaf93937d18770e2836..22777f70efac310b7fcade369cacc1c77453e36f 100644 --- a/library/Class/CosmoVar.php +++ b/library/Class/CosmoVar.php @@ -32,16 +32,26 @@ class Class_CosmoVarLoader extends Storm_Model_Loader { } - public function isSiteRetraitResaEnabled() { + public function isSiteRetraitResaChoiceEnabled() { return (1 === (int)Class_CosmoVar::get('site_retrait_resa')); } + public function isSiteRetraitResaItemLibrary() { + return (0 === (int)Class_CosmoVar::get('site_retrait_resa')); + } + + public function isSiteRetraitResaPatronLibrary() { + return (2 === (int)Class_CosmoVar::get('site_retrait_resa')); + } + + public function getLabelInList($name, $value) { if (!$model = Class_CosmoVar::find($name)) return ''; - foreach (explode(chr(13).chr(10), $model->getListe()) as $line) { + $lines = array_filter(explode(chr(13).chr(10), $model->getListe())); + foreach ($lines as $line) { $parts = explode(':', $line); if ($value == $parts[0]) return $parts[1]; @@ -49,6 +59,8 @@ class Class_CosmoVarLoader extends Storm_Model_Loader { return ''; } + + public function updateLabelInList($value ,$label ,$list) { $new_list=[]; foreach (explode(chr(13).chr(10), $list) as $line) { diff --git a/library/Class/Cosmogramme/FileParser.php b/library/Class/Cosmogramme/FileParser.php index ccc264c8c2da994d22d61081d767e3ce1615bfa6..c6d359e74c9aca8a3198aeb1319d6e9100eb9757 100644 --- a/library/Class/Cosmogramme/FileParser.php +++ b/library/Class/Cosmogramme/FileParser.php @@ -158,8 +158,7 @@ abstract class Class_Cosmogramme_FileParser_Ascii extends Class_Cosmogramme_File protected function _next() { $fileSystem = $this->getFileSystem(); $data = trim($fileSystem->fgets($this->_file_handle)); - if ($this->_separator != chr(9)) - $data = str_replace($this->_separator, chr(9), $data); + $data = str_getcsv($data, $this->_separator); $this->_position = $fileSystem->ftell($this->_file_handle); $ret = new Class_Cosmogramme_FileParserRecord($data); @@ -245,18 +244,8 @@ class Class_Cosmogramme_FileParser_Xml extends Class_Cosmogramme_FileParser { -class Class_Cosmogramme_FileParser_Csv extends Class_Cosmogramme_FileParser { - protected function _next() { - $fileSystem = $this->getFileSystem(); - $data = trim($fileSystem->fgets($this->_file_handle)); - $data = str_replace('","', chr(9), $data); - $data = str_replace('"', '', $data); - - $this->_position = $fileSystem->ftell($this->_file_handle); - $ret = new Class_Cosmogramme_FileParserRecord($data); - $fileSystem->feof($this->_file_handle) ? $ret->beEnd() : $ret->beOk(); - return $ret; - } +class Class_Cosmogramme_FileParser_Csv extends Class_Cosmogramme_FileParser_Ascii { + protected $_separator = ','; } diff --git a/library/Class/Cosmogramme/Integration.php b/library/Class/Cosmogramme/Integration.php index 1be05660c303d996352eb944967d96b18925d555..30bf0a3a31ca1f38fb21b84848d47845d35c501e 100644 --- a/library/Class/Cosmogramme/Integration.php +++ b/library/Class/Cosmogramme/Integration.php @@ -34,7 +34,7 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract { 'role' => 'int_bib', 'referenced_in' => 'id_bib'], - 'profil_donnees' => ['model' => 'Class_Cosmogramme_ProfilDonnees', + 'profil_donnees' => ['model' => 'Class_IntProfilDonnees', 'role' => 'integration', 'referenced_in' => 'profil']]; @@ -44,11 +44,21 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract { } + public function beTotalImport() { + return $this->setTypeOperation(self::TYPE_OPERATION_TOTAL); + } + + public function isIncrement() { return self::TYPE_OPERATION_INCREMENT == $this->getTypeOperation(); } + public function beIncrementImport() { + return $this->setTypeOperation(self::TYPE_OPERATION_INCREMENT); + } + + public function getFileSize() { if (!$this->fileExists()) return 0; diff --git a/library/Class/Cosmogramme/Integration/Phase.php b/library/Class/Cosmogramme/Integration/Phase.php index 61d5a9b2af0d8911df914fda0176039694c4904d..c66355dd398db9ec95d3eb1f1b91b948198cb36e 100644 --- a/library/Class/Cosmogramme/Integration/Phase.php +++ b/library/Class/Cosmogramme/Integration/Phase.php @@ -68,6 +68,11 @@ class Class_Cosmogramme_Integration_Phase { } + public function isIdIn($ids) { + return in_array($this->_id, $ids); + } + + public function isCron() { return $this->_is_cron; } diff --git a/library/Class/Cosmogramme/Integration/PhaseAbstract.php b/library/Class/Cosmogramme/Integration/PhaseAbstract.php new file mode 100644 index 0000000000000000000000000000000000000000..65010509093b58975afc59f5dbdbb5cbeec4f7ee --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseAbstract.php @@ -0,0 +1,129 @@ +<?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 Class_Cosmogramme_Integration_PhaseAbstract { + use Trait_TimeSource; + + protected $_label = ''; + protected $_phase, $_log, $_printer, $_chrono, $_is_time_out; + + + public function __construct($phase, $log, $chrono) { + $this->_phase = $phase; + $this->_log = $log; + $this->_chrono = $chrono; + $this->_is_time_out = false; + } + + + protected abstract function _execute(); + protected abstract function _init($phase); + + + /** @return array **/ + protected function _previousPhaseIds() { + return [static::MY_ID - 1]; + } + + + protected function _prepareNewPhase() { + if (!$this->_phase->isIdIn($this->_previousPhaseIds())) + return $this->_phase; + + $new_phase = (new Class_Cosmogramme_Integration_Phase(static::MY_ID)) + ->beSameCronAs($this->_phase); + + $this->_log->ecrire('<h4>' . $this->_label . '</h4>'); + $this->_init($new_phase); + return $new_phase; + } + + + /** @return Class_Cosmogramme_Integration_Phase */ + public function run() { + Class_CosmoVar::setValueOf('traitement_phase', $this->_label); + $this->_phase = $this->_prepareNewPhase(); + + if (!$this->_isMyTurn()) + return $this->_phase; + + $this->_printLabel(); + + $this->_execute(); + + return $this->_phase; + } + + + protected function _isMyTurn() { + return $this->_phase->isId(static::MY_ID); + } + + + protected function _getData($name) { + return $this->_phase->getData($name); + } + + + protected function _setData($name, $value) { + $this->_phase->setData($name, $value); + return $this; + } + + + protected function _incrementData($name) { + $this->_phase->incrementData($name); + return $this; + } + + + protected function _printLabel() { + if (!$this->_phase->isCron() && $this->_wasRunning()) + $this->_getPrinter()->nextPutAll('<h4>' . $this->_label . '</h4>'); + } + + + protected function _wasRunning() { + return false; + } + + + /** @category testing */ + public function setPrinter($printer) { + $this->_printer = $printer; + return $this; + } + + + protected function _getPrinter() { + if (null !== $this->_printer) + return $this->_printer; + return new Class_Cosmogramme_Integration_PhasePrinter(); + } + + + public function isTimeOut() { + return $this->_is_time_out = $this->_is_time_out + || (!$this->_phase->isCron() + && $this->_chrono->mainElapsed() > $this->_chrono->timeout()); + } +} \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhaseItemFacets.php b/library/Class/Cosmogramme/Integration/PhaseItemFacets.php new file mode 100644 index 0000000000000000000000000000000000000000..056c084c4e4fa367cba212e16fd80a61d1d836ea --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseItemFacets.php @@ -0,0 +1,145 @@ +<?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_PhaseItemFacets + extends Class_Cosmogramme_Integration_PhaseAbstract { + const MY_ID = 7; + const MAX_ITEMS = 1000; + + protected $_previous_records, $_last_update_date; + protected $_db_reset = true; + protected $_label = 'Mise à jour des facettes exemplaires'; + + + public function __construct($phase, $log, $chrono) { + parent::__construct($phase, $log, $chrono); + $this->_previous_records = []; + } + + + public function _execute() { + while ($records = Class_Notice::findAllAfter($this->_getData('pointeur_notice'), + $this->_getData('pointeur'))) { + + if (0 == ($this->_getData('nombre') % 100)) + $this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' records updated </span>'); + + /* @see #23391 : whenever we fetched ths same record page, end loop */ + if ($this->_previous_records && (0 == count(array_filter(array_diff($this->_previous_records, $records))))) + break; + + $this->_previous_records = $records; + + $this->runUpdateForRecords($records); + + $this->_resetDbConnection(); + } + + Class_CosmoVar::setValueOf('date_maj_facettes', $this->_last_update_date); + + $this->_log->ecrire('<span class="vert">'. + 'Toutes les exemplaires ont été mis à jour :' . + ' pointeur notice : ' . $this->_getData('pointeur_notice') . + ' pointeur : ' . $this->_getData('pointeur') . + '<br>' . $this->_getData('nombre') . ' notices traitées.</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; + + if (static::MAX_ITEMS < Class_Exemplaire::countBy(['id_notice' => $record->getId()])) + return; + + $this->_runOne($record); + } + } + + + protected function _runOne($record) { + // types starting with 100 are indexed at another phase + if (100 > $record->getTypeDoc()) + $record->updateFacetsFromExemplaires() + ->save(); + + $this->_setData('pointeur_notice', $record->getId()); + $this->_incrementData('nombre'); + $this->_last_update_date = $record->getDateMaj(); + } + + + /** @return array **/ + protected function _previousPhaseIds() { + return [4, 5, 6]; + } + + + protected function _init($new_phase) { + $last_update_date = Class_CosmoVar::getValueOf('date_maj_facettes'); + $new_phase + ->resetDatas() + ->setData('nombre', 0) + ->setData('pointeur_notice', 0) + ->setData('pointeur', + $last_update_date ? $last_update_date : '0000-00-00 00:00:00'); + + $this->_chrono + ->startOnFile() + ->startOnRecords(); + } + + + protected function _wasRunning() { + return $this->_getData('pointeur_notice') > 0; + } + + + /** @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/Cosmogramme/Integration/PhaseOnFile.php b/library/Class/Cosmogramme/Integration/PhaseOnFile.php new file mode 100644 index 0000000000000000000000000000000000000000..bd9df250511aa0281b41e97788872e51449dfca6 --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseOnFile.php @@ -0,0 +1,222 @@ +<?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 Class_Cosmogramme_Integration_PhaseOnFile extends Class_Cosmogramme_Integration_PhaseAbstract { + public function _execute() { + $integrations = Class_Cosmogramme_Integration::findAllBy(['traite' => 'non', + 'order' => 'id']); + foreach ($integrations as $integration) { + if ($this->isTimeOut()) + return $this->_phase; + + $this->_runOne($integration); + } + + $this->_setData('pointeur', 0); + $processed = $this->_getData('nb_fic'); + $msg = ($processed > 0) ? + $processed . ' fichier(s) traité(s).' : + 'aucun fichier traité'; + $this->_log->ecrire('<br><span class="violet">' . $msg . '</span><br>'); + } + + + protected function _runOne($integration) { + if (!($profil = $integration->getProfilDonnees()) || !$this->_validateProfil($profil)) + return; + + $this->_headerOf($integration); + + if ($integration->shouldClean()) + $this->_clean($integration); + + $this->_initOne(); + + $file_path = Class_CosmoVar::get('integration_path') . $integration->getFichier(); + $parser = Class_Cosmogramme_FileParser::openFor($file_path, + $integration->getPointeurReprise(), + $profil); + + if (!$parser->isValid()) { + Class_CosmoVar::increment('traitement_erreurs'); + $this->_log->ecrire('<span class="rouge">Impossible d\'ouvrir le fichier : ' + . $file_path + . '</span><br>'); + return; + } + + $this->_runFile($parser, $integration); + + if (!$this->isTimeOut()) { + $integration->setTraite($this->getTimeSource()->dateYmd()) + ->setPointeurReprise($this->_getData('nombre')) + ->save(); + $this->_phase->incrementData('nb_fic'); + } + } + + + protected function _initOne() { + if ($this->_phase->isCallBack()) { + $this->_phase->beNotCallBack(); + return; + } + + $this->_phase + ->resetDatas() + ->setData('nb_erreurs', 0) + ->setData('nb_warnings', 0) + ->setData('nombre', 0); + + $this->_chrono + ->startOnFile() + ->startOnRecords(); + } + + + + protected function _wasRunning() { + return $this->_getData('nombre') > 0; + } + + + protected function _runFile($parser, $integration) { + while(true) { + if ($this->isTimeOut()) + return; + + $line = $parser->next(); + if ($this->_lineError($line)) + return; + + if ($this->_lineAtEnd($line)) + return $this->_afterFileProcessed($integration); + + $this->_lineOk($line, $integration); + } + } + + + protected function _lineError($line) { + if (!$line->isError()) + return false; + + $line->withErrorDo( + function($error) { + $this->_log->ecrire('<span class="rouge">' . $error . '</span><br>'); + }); + + $processed = $this->_getData('nombre'); + $msg = ($processed > 0) ? + $processed . ' fiches ont pu être traitées.' : + 'aucune fiche n\'a pu être traitée.'; + $this->_log->ecrire('<span class="vert">' . $msg . '</span>'); + + return true; + } + + + protected function _lineAtEnd($line) { + if (!$line->isEnd()) + return false; + + $processed = $this->_getData('nombre'); + if ($processed == 0) { + $this->_log->ecrire('<br><span class="vert">Le fichier ne contenait aucune fiche</span><br>'); + return true; + } + + $this->_log->ecrire('<br><span class="vert">' . $processed . ' fiches ont été traitées.</span>'); + $msg = "temps de traitement " . $this->_chrono->endFile() + . ' (' . $this->_chrono->meanOnFile($processed, 'fiches') . ')'; + + $this->_log->ecrire('<br><span class="vert">' . $msg . '</span><br>'); + return true; + } + + + protected function _lineOk($line, $integration) { + if (!$line->isOk()) + return; + + if ($this->_shouldIgnoreLine($line, $integration)) + return; + + $this->_processLine($line, $integration); + + $this->_incrementData('nombre'); + + $processed = $this->_getData('nombre'); + if (0 == $processed % 1000) { + $this->_log->ecrire('fiche ' . $processed + . ' (' . $this->_chrono->elapsedOnRecords() + . ' secondes)<br>'); + $this->_chrono->startOnRecords(); + } + + $line->withNextPositionDo( + function($next) use ($integration) { + $this->_setData('pointeur', $next); + + $integration + ->setPointeurReprise($next) + ->save(); + }); + } + + + /** one line of file has been read and should be processed here */ + abstract protected function _processLine($line, $integration); + + /** in case of full import, implements what is needed to be done */ + abstract protected function _clean($integration); + + /** should return true if $line must not be processed */ + abstract protected function _shouldIgnoreLine($line, $integration); + + /** return true if given profil parameters are correct for this phase */ + abstract protected function _validateProfil($profil); + + /** hooked called after the file has been fully processed */ + abstract protected function _afterFileProcessed($integration); + + + + protected function _headerOf($integration) { + $profil = $integration->getProfilDonnees(); + $format = Class_CosmoVar::getLabelInList('import_format', $profil->getFormat()); + $nom_bib = $integration->getBib()->getNomCourt(); + + $operation = Class_CosmoVar::getLabelInList('import_type_operation', + $integration->getTypeOperation()); + $trace = '<b><span class="vert">'.$nom_bib." (" . $operation . ")</b></span><br>"; + $trace .= '<span class="bib">Fichier : '. $integration->getFichier() . "</span><br>"; + $trace .= '<span class="bib">Profil : ' . $profil->getLibelle() . '</span><br>'; + $trace .= '<span class="bib">Format : ' . $format .'</span><br>'; + + (!$integration->getPointeurReprise()) ? + $this->_log->ecrire($trace) : + $this->_getPrinter()->nextPutAll($trace . '<br>'); + } +} + +?> \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php new file mode 100644 index 0000000000000000000000000000000000000000..ce26db3ca23ceb3acfd27de365e45543e9b9d2c0 --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -0,0 +1,132 @@ +<?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_PhasePanier extends Class_Cosmogramme_Integration_PhaseOnFile { + const MY_ID = 15; + + protected $_label = 'Intégration des fichiers paniers'; + + protected function _init($new_phase) {} + + protected function _validateProfil($profil) { + $errors = []; + $fields = $this->getFields($profil); + + if (false === array_search('ID_SIGB',$fields)) + $errors []= 'Configuration: colonne ID_SIGB requise'; + + if (false === array_search('ID_ABON',$fields) && false === array_search('MAIL', $fields)) + $errors []= 'Configuration: colonne IDABON ou MAIL requise'; + + array_map( [$this->_log, 'addError'], $errors); + return empty($errors); + } + + protected function _processLine($line, $integration) { + $line->withDataDo( + function($data) use ($integration){ + $this->importBasketRecord($data, $integration); + }); + } + + + + protected function findPossibleOwnersOfBasketRecord($map) { + $possible_owners = new Storm_Model_Collection(); + if ($map['mail']) + $possible_owners->addAll(Class_Users::findAllBy(['mail' => $map['mail']])); + + if ($map['idabon']) + $possible_owners->addAll(Class_Users::findAllBy(['idabon' => $map['idabon']])); + + $possible_owners = $possible_owners->select((1 == (int)$map['role']) + ? 'isBibliothecaire' + : 'isAbonne'); + return $possible_owners; + } + + + protected function mapRecordColumns($integration, $datas) { + $fields=$this->getFields($integration->getProfilDonnees()); + $map = []; + foreach($fields as $k => $name) { + $map[strtolower($name)] = $datas[$k]; + } + return $map; + } + + protected function getFields($profil_donnees) { + $attribs = unserialize($profil_donnees->getAttributs()); + return explode(';', $attribs[3]['champs']); + + } + + + protected function importBasketRecord($datas, $integration) { + if (sizeof($datas) != sizeof($this->getFields($integration->getProfilDonnees()))) + return; + $map = $this->mapRecordColumns($integration, $datas); + $possible_owners = $this->findPossibleOwnersOfBasketRecord($map); + + if ($possible_owners->isEmpty()) + return $this->_log->addError('Panier orphelin: '.$map['libelle']); + + if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb']])) + return; + + $owner = $possible_owners->first(); + + $id_sigb = $map['id_sigb']; + xdebug_break(); + $basket = Class_PanierNotice::findFirstBy(['id_sigb' => $id_sigb]); + if ($id_sigb==null || !$basket) { + $basket = Class_PanierNotice::newInstance()->initializeForUser($owner); + } + + $basket + ->setLibelle($map['libelle']) + ->setIdSigb($map['id_sigb']) + ->setUser($owner) + ->setIdabon($owner->getIdabon()) + ->addNotice($exemplaire->getNotice()) + ->save(); + } + + + protected function _clean($integration) { + $baskets = Class_PanierNotice::findAllBy(['id_int_bib' => $integration->getId()]); + foreach($baskets as $basket) + $basket->setNotices('')->save(); + } + + + protected function _shouldIgnoreLine($line, $integration) { + return false; + } + + protected function _afterFileProcessed($integration) { + Class_PanierNotice::deleteBy(['id_int_bib' => $integration->getId(), + 'notices' => '']); + } +} + +?> \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhasePrinter.php b/library/Class/Cosmogramme/Integration/PhasePrinter.php new file mode 100644 index 0000000000000000000000000000000000000000..38c974d3ccc7014b80a71b03122654a970f5edab --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhasePrinter.php @@ -0,0 +1,27 @@ +<?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_PhasePrinter { + public function nextPutAll($value) { + print($value);flush(); + } +} diff --git a/library/Class/Cosmogramme/Integration/PhaseReservation.php b/library/Class/Cosmogramme/Integration/PhaseReservation.php index f9c452dd52531b72cb3b157fd95ea44a76816496..450e54335e8baf0bdd8494494ef5887a42981d8f 100644 --- a/library/Class/Cosmogramme/Integration/PhaseReservation.php +++ b/library/Class/Cosmogramme/Integration/PhaseReservation.php @@ -20,263 +20,40 @@ */ -class Class_Cosmogramme_Integration_PhaseReservation { - use Trait_TimeSource; - +class Class_Cosmogramme_Integration_PhaseReservation extends Class_Cosmogramme_Integration_PhaseOnFile { const MY_ID = 13; protected $_phase, $_log, $_printer, $_chrono, $_is_time_out; protected $_label = 'Intégration des fichiers de réservations'; - public function __construct($phase, $log, $chrono) { - $this->_phase = $phase; - $this->_log = $log; - $this->_chrono = $chrono; - $this->_is_time_out = false; - } - - - public function run() { - Class_CosmoVar::setValueOf('traitement_phase', $this->_label); - $this->_init(); - - if (!$this->_isMyTurn()) - return $this->_phase; - - $this->_printLabel(); - - $integrations = Class_Cosmogramme_Integration::findAllBy(['traite' => 'non', - 'order' => 'id']); - foreach ($integrations as $integration) { - if ($this->isTimeOut()) - return $this->_phase; - - $this->_runOne($integration); - } - - $this->_phase->setData('pointeur', 0); - $processed = $this->_phase->getData('nb_fic'); - $msg = ($processed > 0) ? - $processed . ' fichier(s) traité(s).' : - 'aucun fichier traité'; - $this->_log->ecrire('<br><span class="violet">' . $msg . '</span><br>'); - - return $this->_phase; - } - - - protected function _isMyTurn() { - return $this->_phase->isId(self::MY_ID); - } - - - protected function _printLabel() { - if (!$this->_phase->isCron() && $this->_phase->getData('nombre') > 0) - $this->_getPrinter()->nextPutAll('<h4>' . $this->_label . '</h4>'); - } - - - protected function _runOne($integration) { - if (!($profil = $integration->getProfilDonnees()) || !$profil->isHolds()) - return; - - $this->_headerOf($integration); - $this->_clean($integration); - $this->_initOne(); - - $file_path = Class_CosmoVar::get('integration_path') . $integration->getFichier(); - $parser = Class_Cosmogramme_FileParser::openFor($file_path, - $integration->getPointeurReprise(), - $profil); - - if (!$parser->isValid()) { - Class_CosmoVar::increment('traitement_erreurs'); - $this->_log->ecrire('<span class="rouge">Impossible d\'ouvrir le fichier : ' - . $file_path - . '</span><br>'); - return; - } - - $this->_runFile($parser, $integration); - - if (!$this->isTimeOut()) { - $integration->setTraite($this->getTimeSource()->dateYmd()) - ->setPointeurReprise($this->_phase->getData('nombre')) - ->save(); - $this->_phase->incrementData('nb_fic'); - } - } - - - protected function _initOne() { - if ($this->_phase->isCallBack()) { - $this->_phase->beNotCallBack(); - return; - } - - $this->_phase - ->resetDatas() - ->setData('nb_erreurs', 0) - ->setData('nb_warnings', 0) - ->setData('nombre', 0); - - $this->_chrono - ->startOnFile() - ->startOnRecords(); - } - - - protected function _runFile($parser, $integration) { - while(true) { - if ($this->isTimeOut()) - return; - - $line = $parser->next(); - if ($this->_lineError($line) || $this->_lineAtEnd($line)) - return; - - $this->_lineOk($line, $integration); - } - } - - - protected function _lineError($line) { - if (!$line->isError()) - return false; + protected function _init($new_phase) {} - $line->withErrorDo( - function($error) { - $this->_log->ecrire('<span class="rouge">' . $error . '</span><br>'); - }); + protected function _afterFileProcessed($integration) {} - $processed = $this->_phase->getData('nombre'); - $msg = ($processed > 0) ? - $processed . ' fiches ont pu être traitées.' : - 'aucune fiche n\'a pu être traitée.'; - $this->_log->ecrire('<span class="vert">' . $msg . '</span>'); - - return true; + protected function _validateProfil($profil) { + return $profil->isHolds(); } - - protected function _lineAtEnd($line) { - if (!$line->isEnd()) - return false; - - $processed = $this->_phase->getData('nombre'); - if ($processed == 0) { - $this->_log->ecrire('<br><span class="vert">Le fichier ne contenait aucune fiche</span><br>'); - return true; - } - - $this->_log->ecrire('<br><span class="vert">' . $processed . ' fiches ont été traitées.</span>'); - $msg = "temps de traitement " . $this->_chrono->endFile() - . ' (' . $this->_chrono->meanOnFile($processed, 'fiches') . ')'; - - $this->_log->ecrire('<br><span class="vert">' . $msg . '</span><br>'); - return true; - } - - - protected function _lineOk($line, $integration) { - if (!$line->isOk()) - return; - - $is_pergame_header = function($data) { - return substr($data, 0, 13) == 'BIB_T_RESERVE'; - }; - - if ($line->withDataDo($is_pergame_header)) - return; // Entete pergame - + protected function _processLine($line, $integration) { $transaction = new Class_Cosmogramme_Integration_Transaction($integration); - $line->withDataDo( - function($data) use ($transaction) { - $transaction->importHold($data); - }); - - $this->_phase->incrementData('nombre'); - - $processed = $this->_phase->getData('nombre'); - if (0 == $processed % 1000) { - $this->_log->ecrire('fiche ' . $processed - . ' (' . $this->_chrono->elapsedOnRecords() - . ' secondes)<br>'); - $this->_chrono->startOnRecords(); - } - - $line->withNextPositionDo( - function($next) use ($integration) { - $this->_phase - ->setData('pointeur', $next); - - $integration - ->setPointeurReprise($next) - ->save(); - }); - } - - - public function isTimeOut() { - return $this->_is_time_out = $this->_is_time_out - || (!$this->_phase->isCron() - && $this->_chrono->mainElapsed() > $this->_chrono->timeout()); + $line->withDataDo([$transaction, 'importHold']); } protected function _clean($integration) { - if ($integration->shouldClean()) - Class_Reservation::deleteBy(['id_site' => $integration->getBib()->getId()]); + Class_Reservation::deleteBy(['id_site' => $integration->getBib()->getId()]); } - protected function _headerOf($integration) { - $profil = $integration->getProfilDonnees(); - $format = Class_CosmoVar::getLabelInList('import_format', $profil->getFormat()); - $nom_bib = $integration->getBib()->getNomCourt(); - $operation = Class_CosmoVar::getLabelInList('import_type_operation', - $integration->getTypeOperation()); - $trace = '<b><span class="vert">'.$nom_bib." (" . $operation . ")</b></span><br>"; - $trace .= '<span class="bib">Fichier : '. $integration->getFichier() . "</span><br>"; - $trace .= '<span class="bib">Profil : ' . $profil->getLibelle() . '</span><br>'; - $trace .= '<span class="bib">Format : ' . $format .'</span><br>'; - - (!$integration->getPointeurReprise()) ? - $this->_log->ecrire($trace) : - $this->_getPrinter()->nextPutAll($trace . '<br>'); + protected function _shouldIgnoreLine($line, $integration) { + return $line->withDataDo([$this, 'isPergameHeader']); } - protected function _init() { - if (!$this->_phase->isId(12)) - return; - - $this->_phase = (new Class_Cosmogramme_Integration_Phase(13)) - ->beSameCronAs($this->_phase); - - $this->_log->ecrire('<h4>' . $this->_label . '</h4>'); - } - - - /** @category testing */ - public function setPrinter($printer) { - $this->_printer = $printer; - return $this; - } - - - protected function _getPrinter() { - if (null !== $this->_printer) - return $this->_printer; - return new Class_Cosmogramme_Integration_PhasePrinter(); + public function isPergameHeader($data) { + return false !== array_search( 'BIB_T_RESERVE', $data); } } - - -class Class_Cosmogramme_Integration_PhasePrinter { - public function nextPutAll($value) { - print($value); - } -} +?> \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/Transaction.php b/library/Class/Cosmogramme/Integration/Transaction.php index eae3636b8dac4a80d4257af5d2b926024953fa8e..74e662b71cf0f91e50cf70528be8c0a406fd041f 100644 --- a/library/Class/Cosmogramme/Integration/Transaction.php +++ b/library/Class/Cosmogramme/Integration/Transaction.php @@ -39,15 +39,14 @@ class Class_Cosmogramme_Integration_Transaction { public function importHold($data) { - $data = $this->_utfEncode($data); - $data = explode(chr(9), $data); - + $data = array_map([$this, '_utfEncode'], $data); $hold = $this->_is_pergame ? $this->_importPergameHold($data) : $this->_importOthersHold($data); $hold->setIdSite($this->_bib->getId()); if (1 > $hold->getOrdreabon()) $hold->setOrdreabon(1); + $hold->setDateResa($this->_date_format->format($hold->getDateResa())) ->save(); } diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 6461e446836c62aceda7b8fb4da987c348d2e797..ba6919e1e5ac7943677316c55ee23c223105f1f7 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -55,7 +55,9 @@ class Class_CriteresRecherche { 'section' => '', 'page' => 1, 'genre' => '', - 'liste_format' => '' + 'liste_format' => '', + 'digital_lib' => '', + 'no_extension' => '' ]; @@ -82,7 +84,7 @@ class Class_CriteresRecherche { public function getValidParameters() { - return array_merge(array_keys(self::$criteres), + return array_merge(array_keys(static::$criteres), ['filtres', 'id_user', 'id_module', @@ -399,13 +401,14 @@ class Class_CriteresRecherche { if ($type_doc = $this->getParam('type_doc')) $visitor->visitTypeDoc($type_doc); - if ($section = $this->getParam('section')) { + if ($section = $this->getParam('section')) $visitor->visitSection($section); - } if ($annexe = $this->getParam('annexe')) $visitor->visitAnnexe($annexe); + $visitor->visitDigitalLib($this->getParam('digital_lib')); + $annee_debut = $this->getAnneeDebut(); $annee_fin = $this->getAnneeFin(); @@ -426,6 +429,7 @@ class Class_CriteresRecherche { public function acceptVisitor($visitor) { + $visitor->visitNoExtension($this->getParam('no_extension')); $this->visitByRechercheType($visitor); $facettes = $this->getFacettes(); diff --git a/library/Class/FRBR/LinkType.php b/library/Class/FRBR/LinkType.php index 58a5871f72eab48326e305830037adac3374344a..89d30a3f030d55ed9d80ee689af0b20a9ea6ffcc 100644 --- a/library/Class/FRBR/LinkType.php +++ b/library/Class/FRBR/LinkType.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_FRBR_LinkTypeLoader extends Storm_Model_Loader { @@ -27,7 +27,7 @@ class Class_FRBR_LinkTypeLoader extends Storm_Model_Loader { $list = []; foreach ($this->findAllBy(['order' => 'libelle']) as $model) $list[$model->getId()] = $model->getLibelle(); - + return $list; } @@ -35,8 +35,11 @@ class Class_FRBR_LinkTypeLoader extends Storm_Model_Loader { public function getSourceTargetComboList() { $list = []; foreach ($this->findAllBy(['order' => 'libelle']) as $model) { - $list[$model->getId() . ':source'] = $model->getLibelle() . ' - ' . $model->getFromSource(); - $list[$model->getId() . ':target'] = $model->getLibelle() . ' - ' . $model->getFromTarget(); + $libelle = $model->getLibelle(); + $groupped = array($model->getId() . ':source' => $model->getFromSource(), + $model->getId() . ':target' => $model->getFromTarget() + ); + $list[$libelle] = $groupped; } return $list; } @@ -46,7 +49,7 @@ class Class_FRBR_LinkTypeLoader extends Storm_Model_Loader { class Class_FRBR_LinkType extends Storm_Model_Abstract { use Trait_Translator; - + protected $_table_name = 'frbr_linktype'; protected $_loader_class = 'Class_FRBR_LinkTypeLoader'; protected $_has_many = ['links' => ['model' => 'Class_FRBR_Link', @@ -60,7 +63,7 @@ class Class_FRBR_LinkType extends Storm_Model_Abstract { return ' ' . $this->getFromSource() . ' -><br><- ' . $this->getFromTarget(); } - + public function validate() { $this ->validateAttribute('libelle', 'Zend_Validate_NotEmpty', $this->_('Un libellé est requis')) diff --git a/library/Class/File/Info.php b/library/Class/File/Info.php index 221dbb7a5f96f0486cf7a971e93417cda0640918..5af5fb13f8193329d7b98b5f770574f42527843e 100644 --- a/library/Class/File/Info.php +++ b/library/Class/File/Info.php @@ -16,11 +16,11 @@ * * 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_File_Info { - protected + protected $_filepath, $_path_info; @@ -39,13 +39,13 @@ class Class_File_Info { public function humanizeFilename() { if (!$file = $this->fileNameWithoutExtension()) return ''; - + $parts = array_filter(preg_split('/[0-9_\*\-\s]+/', $file)); return ucfirst(implode(' ', array_map('trim',$parts))); } - /** + /** * @return string */ public function fileNameWithoutExtension() { @@ -65,7 +65,9 @@ class Class_File_Info { * @return string */ public function fileExtension() { - return $this->_path_info['extension']; + return isset($this->_path_info['extension']) + ? $this->_path_info['extension'] + : ''; } diff --git a/library/Class/Import/Typo3.php b/library/Class/Import/Typo3.php index 7bc2443ea6ebed5d3a629499bfd67211c74bad2e..3c36f32ad87001d1dd56a2576191adbc443c52c5 100644 --- a/library/Class/Import/Typo3.php +++ b/library/Class/Import/Typo3.php @@ -20,13 +20,14 @@ */ class Class_Import_Typo3 { use Trait_TimeSource; + use Trait_StaticFileWriter; const DEFAULT_CAT_ID = 30000; - const BOKEH_IMG_URL = "http://www.mediathequeouestprovence.fr/uploads/"; -// const BOKEH_IMG_URL="http://web.afi-sa.net/miop-test.net/userfiles/image/uploads/"; - const BOKEH_ATTACHMENT_URL = "http://www.mediathequeouestprovence.fr/fileadmin/fichiers/"; -// const BOKEH_ATTACHMENT_URL="http://web.afi-sa.net/miop-test.net/userfiles/file/"; + + const FOLDER_IMGS = "pics/"; //directory to get external images + const BOKEH_IMG_URL = "http://www.mediathequeouestprovence.fr/uploads/"; //url to get files + const BOKEH_ATTACHMENT_URL = "http://www.mediathequeouestprovence.fr/fileadmin/fichiers/"; // path to admin files (specific miop) const BOKEH_FILEADMIN_URL = "http://www.mediathequeouestprovence.fr/fileadmin/"; -// const BOKEH_FILEADMIN_URL= "http://web.afi-sa.net/miop_test.net/userfiles/image/"; + const UID_TYPO3_CF = 'uid_typo3'; @@ -121,6 +122,20 @@ class Class_Import_Typo3 { $logger->addLogRow("\n\n ******** Détection des dossiers documentaires"); $this->updateCategoriesForDossiersDocumentaires(); } + if ($what == 'sito_reimport') { + $logger->addLogRow("\n\n ******** Reimport des sitothèques"); + $this->importSites(); + $logger->addLogRow("\n\n ******** Récupération des images pour les sitothèques"); + $this->updateSites(); + $logger->addLogRow("\n\ Attention : Relancer une intégration cosmogramme pour que l'import soit pris en compte"); + } + + if ($what == 'sito') { + $logger->addLogRow("\n\n ******** Récupération des images pour les sitothèques"); + $this->updateSites(); + $logger->addLogRow("\n\ Attention : Relancer une intégration cosmogramme pour que l'import soit pris en compte"); + } + if ($what == 'advices') { $logger->addLogRow("\n\n ******** Attribution des avis de notices"); @@ -219,6 +234,13 @@ class Class_Import_Typo3 { public function importSites() { + Class_Sitotheque::deleteBy([]); + Class_SitothequeCategorie::deleteBy([]); + + $this->sites_categories_map = new SiteCategoriesMap('Non classé', $this->domaine_map); + $t3categories = $this->t3db->findAllNewsCat(); + $this->sites_categories_map->build($t3categories); + $t3news = $this->t3db->findAllSites(); foreach($t3news as $new) $element = $this->traceUnknownKohaUrls( @@ -229,10 +251,36 @@ class Class_Import_Typo3 { } + + public function updateSites() { + + $t3sites=$this->t3db->findAllExternalSites(); + foreach ($t3sites as $t3site) { + $link_array = explode(' ', $t3site['ext_url']); + $image=explode(',',$t3site['image']); + $this->createImageForExternalWebsite($link_array[0],$image[0]); + } + + } + + + + public function createImageForExternalWebsite($url,$image) { + if (!$image) + return; + $image_contents=$this->getFileWriter()->getContents(self::BOKEH_IMG_URL.self::FOLDER_IMGS.$image); + if (!$image_contents) + return; + $website_thumbnail= new Class_WebService_WebSiteThumbnail(); + $this->getFileWriter()->putContents($website_thumbnail->getFilePath($url), $image_contents); + } + + public function createSito($new) { $date_maj = date("Y-m-d H:i:s", $new['crdate']); $id_cat = $this->sites_categories_map->find($new['category'])->getId(); $url = $this->convertKohaToBokehUrl($this->format_url($new['ext_url'])); + $tags = str_replace(', ', ';', $new['tx_danpextendnews_tags']); $element = Class_Sitotheque::newInstance(['id_cat' => $id_cat, @@ -294,7 +342,7 @@ class Class_Import_Typo3 { protected function addImage($image) { if (!$image) return ''; - return '<img src="'.self::BOKEH_IMG_URL.'pics/'.$image.'" alt=""/>'; + return '<img src="'.self::BOKEH_IMG_URL.self::FOLDER_IMGS.$image.'" alt=""/>'; } @@ -1143,7 +1191,7 @@ class Typo3DB { 'mysqli', ['host' => 'localhost', 'username' => 'root', - 'password' => '', + 'password' => 'root', 'dbname' => 'miop_typo3'])); } @@ -1190,7 +1238,12 @@ class Typo3DB { public function findAllSites() { - return $this->t3db->fetchAll("select * from tt_news where deleted=0 and hidden=0 and ext_url>'' order by uid ASC"); + return $this->t3db->fetchAll("select * from tt_news where deleted=0 and t3ver_label not like 'DELETED!' and hidden=0 and ext_url not like '%koha.mediathequeouestprovence.fr%' and ext_url>'' order by uid ASC"); + } + + + public function findAllExternalSites() { + return $this->t3db->fetchAll("select * from tt_news where deleted=0 and t3ver_label not like 'DELETED!' and hidden=0 and image>'' and ext_url not like '%koha.mediathequeouestprovence.fr%' and ext_url>'' order by uid ASC"); } diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index e3966d286152dce012ab914a6b67ea317ab20b48..d0006f7482855092fc66c23f7687ad7fd3391395 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -152,6 +152,7 @@ class Class_Indexation_PseudoNotice { $authors = $this->getAuthorsNames(); $indexation = Class_Indexation::getInstance(); + $this->_notice ->setMatieres($this->extractFullTextFromCodif($data, 'matiere', @@ -159,9 +160,9 @@ class Class_Indexation_PseudoNotice { ->setAlphaTitre($indexation->codeAlphaTitre($this->_datas["titre"])) ->setClefAlpha($this->_model->getAlphaKey()) ->setClefOeuvre($indexation->getClefOeuvre($this->_datas["titre"], - '', - $this->_datas["auteur"], - '')) + '', + $this->_datas["auteur"], + '')) ->setTitres($indexation->getfullText($this->extractTitles())) ->setAuteurs($indexation->getfullText($authors)) ->setAlphaAuteur($indexation->alphaMaj(implode(' ', $this->extractAuthors()))) @@ -195,6 +196,7 @@ class Class_Indexation_PseudoNotice { } $cote = ''; + if ($this->dataExist('cote', $this->_datas)) $cote = $this->_datas['cote']; @@ -328,6 +330,7 @@ class Class_Indexation_PseudoNotice { return $visitor->getUnimarc(); } + protected function _getCodeBarres() { return str_repeat('0', (4 - strlen($this->_datas['id_bib']))) . $this->_datas['id_bib'] . '-' . $this->_notice->getId(); @@ -391,6 +394,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ } + public function extractEditors() { $editors = parent::extractEditors(); if(empty($editors)) @@ -435,11 +439,19 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ $visitor->visitRessource($ressource); } + public function isValid() { return null != $this->_model && $this->_model->isVisible() && $this->_model->isValidated(); } + + + protected function _getUnimarc() { + $visitor = new Class_Indexation_PseudoNotice_AlbumVisitor(); + $this->acceptVisitor($visitor); + return $visitor->getUnimarc(); + } } diff --git a/library/Class/Cosmogramme/ProfilDonnees.php b/library/Class/Indexation/PseudoNotice/AlbumVisitor.php similarity index 71% rename from library/Class/Cosmogramme/ProfilDonnees.php rename to library/Class/Indexation/PseudoNotice/AlbumVisitor.php index edd76a2a13672929d0e677f397bd2ee360b106c8..ef1c6d96a70baabfc520d686590d546ff53f1282 100644 --- a/library/Class/Cosmogramme/ProfilDonnees.php +++ b/library/Class/Indexation/PseudoNotice/AlbumVisitor.php @@ -20,17 +20,11 @@ */ -class Class_Cosmogramme_ProfilDonnees extends Storm_Model_Abstract { - const FILE_TYPE_RECORDS = 0; - const FILE_TYPE_USERS = 1; - const FILE_TYPE_LOANS = 2; - const FILE_TYPE_HOLDS = 3; +class Class_Indexation_PseudoNotice_AlbumVisitor extends Class_Indexation_PseudoNotice_UnimarcVisitor { - protected $_table_name = 'profil_donnees'; - protected $_table_primary = 'id_profil'; - public function isHolds() { - return self::FILE_TYPE_HOLDS == $this->getTypeFichier(); + public function visitDescription($description) { + return $this; } } ?> \ No newline at end of file diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 6b19355851ca8650260d474f7eb4ce55338aec40..64f23bd54b28822862aa384df02fd6b1bfd2528f 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -23,7 +23,9 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { const FT_RECORDS = 0, FT_PATRONS = 1, - FT_HOLDS = 2, + FT_LOANS = 2, + FT_HOLDS = 3, + FT_BASKETS = 4, ENCODING_UTF8 = 0, ENCODING_ISO2709 = 1, ENCODING_WINDOWS_ANSI = 2, @@ -55,7 +57,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { return self:: newInstance(['libelle' => 'Unimarc Nanok', 'accents' => self::ENCODING_UTF8, - 'rejet_periodiques' => '1', + 'rejet_periodiques' => 0, 'id_article_periodique' => self::SERIAL_FORMAT_PERGAME, 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, @@ -437,6 +439,21 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { $config[0]['champ_availability'] = $value; return $this->setAttributs($config); } + + + + public function isHolds() { + return self::FT_HOLDS == $this->getTypeFichier(); + } + + public function getSeparator() { + switch ($this->getFormat()) { + case self::FORMAT_SEMI_COLON_ASCII : return ';';break; + case self::FORMAT_CSV : return ',';break; + case self::FORMAT_PIPED_ASCII : return '|';break; + } + return ','; + } } ?> \ No newline at end of file diff --git a/library/Class/Loan/Pnb.php b/library/Class/Loan/Pnb.php new file mode 100644 index 0000000000000000000000000000000000000000..399556189f87ccf5561097ee1cc7d556d788f45c --- /dev/null +++ b/library/Class/Loan/Pnb.php @@ -0,0 +1,102 @@ +<?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_Loan_PnbLoader extends Storm_Model_Loader { + public function findOngoingByUserAndAlbum($user, $album) { + return $this->findFirstBy(['record_origin_id' => $album->getIdOrigine(), + 'user_id' => $user->getId(), + 'ongoing' => true]); + + } +} + + +class Class_Loan_Pnb extends Storm_Model_Abstract { + protected + $_table_name = 'loan_pnb', + $_loader_class = 'Class_Loan_PnbLoader'; + + public function getAlbum() { + return Class_Album::findFirstBy(['id_origine' => $this->getRecordOriginId()]); + } + + + public function setAlbum($album) { + return $this->setRecordOriginId($album->getIdOrigine()); + } + + + public function isLate() { + return false; + } + + + public function isPNB() { + return true; + } + + + public function getNoticeOPACId() { + return $this->getAlbum()->getNoticeId(); + } + + + public function getTitre() { + return $this->getAlbum()->getTitre(); + } + + + public function getAuteur() { + return $this->getAlbum()->getMainAuthorName(); + } + + + public function getBibliotheque() { + return ''; + } + + + public function getDateRetour() { + return $this->getExpectedReturnDate(); + } + + + public function isRenewable() { + return false; + } + + + public function getType() { + return ''; + } + + + public function getOrderLineId() { + return $this->getAlbum()->getUsageConstraints()->getLoanOrderLineId(); + } + + + public function endLoanDo($closure) { + $content = (new Class_WebService_BibNumerique_Dilicom_Hub())->endLoanBook($this); + $closure($content->returnMessage); + } +} +?> \ No newline at end of file diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index c4ae068c61c482c35f43f1dfd38d320f35c5607d..a22bae97cf473c0e7bb2f8ccf877ef4208c8b02d 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_MoteurRecherche { - use Trait_Singleton, Trait_Translator, Trait_TimeSource; + use Trait_Singleton, Trait_Translator, Trait_TimeSource, Trait_SearchCriteriaVisitor; private $ix; // Classe d'indexation private $limite_facettes = ' limit 15000'; // limite pour le calcul des facettes @@ -32,6 +32,9 @@ class Class_MoteurRecherche { $_or_conditions = '', $_filter_domain_conditions = ''; + protected $_extensible = true; + + public function __construct() { $this->ix = new Class_Indexation(); } @@ -73,6 +76,29 @@ class Class_MoteurRecherche { } + public function visitDigitalLib($flag) { + if ($flag) + $this->setCondition('type_doc >= ' . Class_TypeDoc::NUMERIC_START); + } + + + public function visitNoExtension($no_extension) { + if ($no_extension) + $this->beNotExtensible(); + } + + + public function beNotExtensible() { + $this->_extensible = false; + return $this; + } + + + public function isExtensible() { + return $this->_extensible; + } + + public function visitSerie($serie, $tri) { $this->setCondition('clef_chapeau="' . $serie . '" '); @@ -239,13 +265,6 @@ class Class_MoteurRecherche { } - public function visitPage($page) { - } - - public function visitTri($tri, $libelle) { - } - - public function visitTextInput($name, $operateur, $type_recherche, $valeur, $pertinence) { if (!$recherche = $this->_visitTextInputTermsIn($valeur, $type_recherche, $pertinence)) return; @@ -406,10 +425,10 @@ class Class_MoteurRecherche { // Lancer les requetes $nb = fetchOne($req_comptage); $ret['statut'] = ''; - if(!$nb && ($this->criteres_recherche->getPertinence() || $this->nb_mots <=1)) { - $ret["statut"] = 'erreur'; - $ret["erreur"] = $this->_('Aucun résultat trouvé'); - $ret['req_liste']=$req_notices; + if (!$nb && !$this->_shouldExtend()) { + $ret['statut'] = 'erreur'; + $ret['erreur'] = $this->_('Aucun résultat trouvé'); + $ret['req_liste'] = $req_notices; $this->addStatEchec(2, $criteres_recherche->getCriteres()); return $ret; } @@ -431,6 +450,13 @@ class Class_MoteurRecherche { } + protected function _shouldExtend() { + return $this->isExtensible() + && (!$this->criteres_recherche->getPertinence()) + && 1 < $this->nb_mots; + } + + public function visitRubrique($indice, $fil) { if ($indice=='guidee') { $rubriques_tmp=['X1','X2']; diff --git a/library/Class/Multimedia/AuthenticateRequest.php b/library/Class/Multimedia/AuthenticateRequest.php index d598029a8462d7ccc2f669346c3cd46d1d537419..6913997ce3d2869ace586c88a5f2bcfd6ae7e81c 100644 --- a/library/Class/Multimedia/AuthenticateRequest.php +++ b/library/Class/Multimedia/AuthenticateRequest.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_Multimedia_AuthenticateRequest { @@ -32,6 +32,11 @@ class Class_Multimedia_AuthenticateRequest { /** @var Class_Multimedia_Device */ protected $_device; + /** @var boolean */ + protected $_holdableDay = false; + + /** @var boolean */ + protected $_successHolding = false; /** * @param Zend_Controller_Request_Abstract @@ -54,9 +59,9 @@ class Class_Multimedia_AuthenticateRequest { || !($site = $request->getParam('site'))) return $this->_error('MissingParameter'); - $auth = ZendAfi_Auth::getInstance(); - if (!$auth->authenticateLoginPassword($login, - $password, + $auth = ZendAfi_Auth::getInstance(); + if (!$auth->authenticateLoginPassword($login, + $password, [$auth->newAuthSIGB(), $auth->newAuthDb()])) { if (Class_Users::findFirstBy(['login' => $login])) return $this->_error('PasswordIsWrong'); @@ -65,30 +70,60 @@ class Class_Multimedia_AuthenticateRequest { $user = Class_Users::getIdentity(); - if (!$user->isAbonnementValid()) + $group = Class_UserGroup::findGroupUserMultimedia(); + + if (!$user->isAbonneInviteInGroupMultimedia() && !$user->isAbonnementValid()) return $this->_error('SubscriptionExpired'); + $this->_user = $user; if ($location = Class_Multimedia_Location::getLoader()->findByIdOrigine($site)) $this->_device = Class_Multimedia_Device::getLoader()->findByIdOrigineAndLocation($poste, $location); - + if (!$this->_device) return $this->_error('DeviceNotFound'); - if (!$this->getCurrentHold()) - return $this->_error('DeviceNotHeldByUser'); + $mode = $request->getParam('mode'); + if(isset($mode) && $mode === 'holdable-day'){ + $this->_holdableDay = $this->_device->isHoldableDayToDay(); + } + + if (isset($mode) && $mode === 'hold'){ + $temps = $request->getParam('temps'); + if(!$this->getCurrentHold($temps)) + return $this->_error('DeviceNotHeldByUser'); + + $this->_successHolding = true; + } + + if(isset($mode) && $mode === 'modified-hold'){ + if(!$hold = $this->getCurrentHold()) + return $this->_error('DeviceNotHeldByUser'); + $start = $hold->getStart(); + $duration = floor(($location->getTimeSource()->time() - $start) / 60); + $hold->delete(); + $this->_device->createHoldWithStartTimeAndDuration($user, $start, $duration); + } return $this->beValid(); } + public function canHoldingForToDay(){ + return $this->_holdableDay; + } + + public function isSuccessHolding(){ + return $this->_successHolding; + } + /** * @return Class_Multimedia_DeviceHold */ - public function getCurrentHold() { + public function getCurrentHold($temps=null) { if (!isset($this->_current_hold) && isset($this->_device) && isset($this->_user)) - $this->_current_hold = $this->_device->getCurrentHoldForUser($this->_user); + $this->_current_hold = $this->_device->getCurrentHoldForUser($this->_user, $temps); return $this->_current_hold; } @@ -99,7 +134,7 @@ class Class_Multimedia_AuthenticateRequest { public function getCurrentHoldEnd() { return $this->getCurrentHold()->getEnd(); } - + /** @return boolean */ public function isValid() { @@ -126,7 +161,7 @@ class Class_Multimedia_AuthenticateRequest { } - /** + /** * @param string $code * @return Class_Multimedia_AuthenticateRequest */ diff --git a/library/Class/Multimedia/Device.php b/library/Class/Multimedia/Device.php index fbf6f267900cf10113fe447024f42066dd23c407..45cc607ffb1d0ecb2452620415322aa564947f2c 100644 --- a/library/Class/Multimedia/Device.php +++ b/library/Class/Multimedia/Device.php @@ -109,12 +109,12 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { * @param $user Class_Users * @return Class_Multimedia_DeviceHold */ - public function getCurrentHoldForUser($user) { + public function getCurrentHoldForUser($user, $temps=null) { if (null !== ($hold = $this->getCurrentHold()) and $user->getId() == $hold->getIdUser()) return $hold; - return $this->autoHoldByUser($user, $hold); + return $this->autoHoldByUser($user, $hold, $temps); } @@ -123,7 +123,7 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { * @param $current_hold Class_Multimedia_DeviceHold * @return Class_Multimedia_DeviceHold */ - public function autoHoldByUser($user, $current_hold) { + public function autoHoldByUser($user, $current_hold, $temps=null) { if (!$this->canCreateHoldGivenCurrentHoldAndUser($current_hold, $user)) return null; @@ -131,11 +131,15 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { if (null == ($start = $this->getPreviousStartTime())) return null; - $end = $this->findHoldEndForTodayFrom($start, 1); + return $this->createHoldWithStartTimeAndDuration($user, $start, $temps); + } + public function createHoldWithStartTimeAndDuration($user, $start, $duration){ + $end = $this->findHoldEndForTodayFrom($start, $duration ); if ($end <= $start) return null; + $hold = Class_Multimedia_DeviceHold::getLoader() ->newInstance() ->setDevice($this) @@ -143,10 +147,15 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { ->setStart($start) ->setEnd($end); $hold->save(); + return $hold; } + public function isHoldableDayToDay(){ + return $this->getGroup()->isHoldableDayToDay(); + } + /** * @param Class_Multimedia_DeviceHold $current_hold * @return boolean @@ -196,12 +205,16 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { * @param timestamp $starrt * @return timestamp */ - public function findHoldEndForTodayFrom($start, $autohold=null) { - // fin de créneau par défaut selon config - $end = $start + (60 * $this->getAutoholdSlotsMax() * $this->getSlotSize()); + public function findHoldEndForTodayFrom($start, $temps=null) { + + $nbSlotMax = (!isset($temps)) ? $this->getAutoholdSlotsMax() + : ceil($temps / $this->getSlotSize()); + + // fin de créneau par défaut selon config + $end = $start + (60 * $nbSlotMax * $this->getSlotSize()); // si on dépasse la fin de journée on se limite à la fin de journée - if ($end > ($next_closing = $this->getMaxTimeForToday($autohold))) + if ($end > ($next_closing = $this->getMaxTimeForToday())) $end = $next_closing; // si on dépasse la prochaine résa on se limite au début de la prochaine résa @@ -279,8 +292,8 @@ class Class_Multimedia_Device extends Storm_Model_Abstract { /** @return int */ - public function getMaxTimeForToday($autohold=null) { - return $this->getGroup()->getMaxTimeForToday($autohold); + public function getMaxTimeForToday() { + return $this->getGroup()->getMaxTimeForToday(); } diff --git a/library/Class/Multimedia/DeviceGroup.php b/library/Class/Multimedia/DeviceGroup.php index dfe9913fffbe55ec6f81cb3855644767eb53efae..e73612337dffb8b8181ec53a6a6e4dedffb7008a 100644 --- a/library/Class/Multimedia/DeviceGroup.php +++ b/library/Class/Multimedia/DeviceGroup.php @@ -91,8 +91,8 @@ class Class_Multimedia_DeviceGroup extends Storm_Model_Abstract { /** @return int */ - public function getMaxTimeForToday($autohold=null) { - return $this->getLocation()->getMaxTimeForToday($autohold); + public function getMaxTimeForToday() { + return $this->getLocation()->getMaxTimeForToday(); } @@ -120,4 +120,9 @@ class Class_Multimedia_DeviceGroup extends Storm_Model_Abstract { public function getLibelleBib() { return $this->getLocation()->getLibelleBib(); } + + /** @return bool */ + public function isHoldableDayToDay(){ + return $this->getLocation()->isHoldableDayToDay(); + } } \ No newline at end of file diff --git a/library/Class/Multimedia/Location.php b/library/Class/Multimedia/Location.php index 4be161568644097ce9e738388d7220d0f66ecb00..3168cc3f43bd71cb59ab3940a7e28ff94eead9ce 100644 --- a/library/Class/Multimedia/Location.php +++ b/library/Class/Multimedia/Location.php @@ -192,6 +192,7 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { $time_source->date(), $time_source->nextDate()); + if (0 == count($times)) return null; @@ -201,13 +202,10 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { return $previous; $previous = $time; } - return null; } - - - public function getOuvertureForDate($date, $autohold=null) { + public function getOuvertureForDate($date) { if (is_string($date)) $date = strtotime($date); @@ -223,8 +221,6 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { return $ouverture; } - return ($this->getAutoholdForClosingDays() && $autohold === 1) ? - $this->_autoOpening() : null; } @@ -262,8 +258,8 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { /** @return int */ - public function getMaxTimeForToday($autohold = null) { - if (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date(), $autohold)) + public function getMaxTimeForToday() { + if (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date())) return 0; return $ouverture->getNextCloseFrom($this->getCurrentTime()); } @@ -352,6 +348,9 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { })); } + public function isHoldableDayToDay(){ + return (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date())) ? false : true; + } public function beforeSave() { if (is_array($days = $this->getDays())) diff --git a/library/Class/Multimedia/Users.php b/library/Class/Multimedia/Users.php index e78ccafac682285b66633f3f917634b38cdc4eaa..0a560ef8b8092fbd349a695253aa95409d2feb14 100644 --- a/library/Class/Multimedia/Users.php +++ b/library/Class/Multimedia/Users.php @@ -51,14 +51,65 @@ class Class_Multimedia_Users { ->setOrdreabon(1) ->setDateDebut('') ->setDateFin($infoUser->datefin) - ->setIdSite($infoUser->site->id) - ->save(); + ->setIdSite($infoUser->site->id); + + if(!$user->save()) + return $user->getErrors()[0]; $usergroupShip = new Class_UserGroupMembership(); $usergroupShip->setUser($user) ->setUserGroup($group) ->save(); } + return 'ADD_NEW_USER_OK'; + + } + + + public function modifyUser($infoUser){ + + if(!$this->isValidInfo($infoUser)){ + return 'INVALID_INFO_USER'; + } + + $user = Class_Users::findFirstBy(['login'=>$infoUser->login]); + + if(!isset($user)) + return $this->createUser(array($infoUser)); + + if($user->isAbonneInviteInGroupMultimedia()){ + $user->setNom($infoUser->nom) + ->setPrenom($infoUser->prenom) + ->setNaissance($infoUser->naissance) + ->setPseudo('') + ->setMail('') + ->setRoleLevel(0) + ->setRole('') + ->setIdabon($infoUser->login) + ->setOrdreabon(1) + ->setDateDebut('') + ->setDateFin($infoUser->datefin) + ->setIdSite($infoUser->site->id); + if($infoUser->pwd !== md5($user->getPassword())) + $user->setPassword($infoUser->pwd); + $user->save(); + } + return 'MODIFICATION_USER_OK'; + + } + + + public function deleteUser($infoUser){ + if(!$this->isValidInfo($infoUser)){ + return 'INVALID_INFO_USER'; + } + + + $user = Class_Users::findFirstBy(['login'=>$infoUser->login]); + if(isset($user) && $user->isAbonneInviteInGroupMultimedia()){ + $user->delete(); + return 'SUCCESS_DELETING'; + } } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index f979ae3bd1472c032ab54715ba5b6cd08c108202..018426ac4cdf93d77cf27ced1a1f638009688972 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -120,6 +120,14 @@ class NoticeLoader extends Storm_Model_Loader { return $result[0]; } + + + public function findAllAfter($record_id, $update_date) { + $where = "id_notice > " . $record_id . " and date_maj >='" . $update_date . "'"; + return Class_Notice::findAllBy(['where' => $where, + 'order' => 'id_notice', + 'limit' => '100']); + } } @@ -577,30 +585,33 @@ class Class_Notice extends Storm_Model_Abstract { // ---------------------------------------------------------------- // Renvoie les articles d'un périodique // ---------------------------------------------------------------- - public function getArticlesPeriodique($id_notice) { + public function getArticlesPeriodique() { // lire dans la base - $notice = fetchEnreg("select clef_chapeau,tome_alpha from notices where id_notice=$id_notice"); - $data = fetchAll("select unimarc from notices_articles where clef_chapeau='" . $notice["clef_chapeau"] . "' and clef_numero='" . $notice["tome_alpha"] . "'"); - if (!$data) return false; - foreach ($data as $enreg) { - if (!$enreg["unimarc"]) continue; - $this->getNoticeUnimarc()->setNotice($enreg["unimarc"], 0); - $article["titre"] = $this->getTitrePrincipal(); - $complement = $this->getComplementTitre(); - if ($complement) - $article["titre"].=" : " . $complement; + $datas = Class_Notice_SerialArticles::findAllBy(['clef_chapeau' => $this->getClefChapeau(), + 'clef_numero' => $this->getTomeAlpha()]); + + $articles = []; + + foreach ($datas as $enreg) { + if (!$enreg->getUnimarc()) continue; + + $this->getNoticeUnimarc()->setNotice($enreg->getUnimarc(), 0); + + $article = ["titre" => $this->getTitrePrincipal()]; + if ($complement = $this->getComplementTitre()) + $article["titre"] .= " : " . $complement; + $auteurs = $this->getAuteursUnimarc(true); - $article["auteur"] = $auteurs[0]; + $article["auteur"] = isset($auteurs[0]) ? $auteurs[0] : ''; $article["pagination"] = $this->getCollation(); $note = $data = $this->get_subfield("300", "a"); - $article["note"] = trim($note[0]); - unset($this->_resume); + $article["note"] = isset($note[0]) ? trim($note[0]) : ''; $article["resume"] = $this->getResume(); $article["matieres"] = $this->getMatieres(); - $ret[] = $article; + $articles[] = $article; } - return $ret; + return $articles; } @@ -825,6 +836,12 @@ class Class_Notice extends Storm_Model_Abstract { } + public function getVolume() { + $data = $this->get_subfield('461','v'); + return isset($data[0]) ? $data[0] : null; + } + + public function setTitrePrincipal($titre) { $this->_notice_unimarc->set_subfield('200', 'a', $titre); return $this; @@ -896,7 +913,8 @@ class Class_Notice extends Storm_Model_Abstract { // ---------------------------------------------------------------- public function getComplementTitre() { - $titre = $this->get_subfield("200", "e"); + if (!$titre = $this->get_subfield("200", "e")) + return ''; $titre = $this->filtreTitre($titre[0]); return trim($titre); } @@ -1470,6 +1488,7 @@ class Class_Notice extends Storm_Model_Abstract { public function acceptVisitor($visitor) { $indexation = new Class_Indexation(); $visitor->visitClefAlpha($this->getClefAlpha()); + $visitor->visitSerialTitle($this->_getTitresDansZones(['461$t'])); $visitor->visitTitres($this->_getTitresDansZones(['200$a', '200$e'])); $visitor->visitAuteurs($this->_getAuteursDansZone('700', $indexation)); $visitor->visitContributeurs($this->_getAuteursDansZone('702', $indexation)); @@ -1492,6 +1511,11 @@ class Class_Notice extends Storm_Model_Abstract { $visitor->visitAlbum($this->getAlbum()); $visitor->visitSource(array_merge($this->get_subfield('801', 'b'), $this->get_subfield('852', 'k'))); + $permalink = new Class_Notice_Permalink(); + $visitor->visitPermalink($permalink->absoluteFor($this, null, true)); + $visitor->visitVolume($this->getVolume()); + $visitor->visitCollections($this->getCollections()); + $visitor->visitGenres($this->getGenres()); } diff --git a/library/Class/Notice/JsonVisitor.php b/library/Class/Notice/JsonVisitor.php new file mode 100644 index 0000000000000000000000000000000000000000..aed1d92987aadeab8664b289ab4874818ac73f3b --- /dev/null +++ b/library/Class/Notice/JsonVisitor.php @@ -0,0 +1,158 @@ +<?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_Notice_JsonVisitor { + use Trait_NoticeVisitor; + + const KIND_CODE = 'genre'; + + protected $_data; + + public function __construct() { + $this->_data = new StdClass(); + } + + + public function data() { + return $this->_data; + } + + + public function visitClefAlpha($clef) { + $this->_data->identifier = $clef; + } + + + public function visitPermalink($link) { + $this->_data->permalink = $link; + } + + + public function visitTypeDoc($id) { + $type = new StdClass(); + $type->code = $id; + $type->label = ($type_doc = Class_TypeDoc::find($id)) ? $type_doc->getLabel() : ''; + + $this->_data->type = $type; + } + + + public function visitVignette($url_vignette) { + if ($url_vignette) + $this->_data->thumbnail = Class_Url::absolute($url_vignette); + } + + + public function visitSerialTitle($title) { + $this->_ensureArray('titles'); + $this->_data->titles = array_merge($title, $this->_data->titles); + $this->_data->serial = array_shift($title); + } + + + public function visitTitres($titles) { + $this->_ensureArray('titles'); + $this->_data->titles = array_merge($this->_data->titles, $titles); + } + + + public function visitAuteurs($authors) { + $this->_data->creators = $authors; + } + + + public function visitEditeur($publisher) { + $this->_data->publishers = [$publisher]; + } + + + public function visitAnnee($year) { + $this->_data->date = $year; + } + + + public function visitVolume($volume) { + if ($volume) + $this->_data->volume = $volume; + } + + + public function visitLangues($languages) { + if ($language = array_shift($languages)) + $this->_data->language = $language; + } + + + public function visitCollections($collections) { + $this->_data->collections = $collections; + } + + + public function visitGenres($kinds) { + if (!$kinds) + return; + + $classification = $this->_ensureKindsClassification(); + foreach($kinds as $kind) { + $entry = new StdClass(); + $entry->code = $kind->asFacet(); + $entry->label= $kind->getLibelle(); + $classification->entries[] = $entry; + } + } + + + protected function _ensureKindsClassification() { + $this->_ensureArray('classifications'); + if ($classification = $this->_classificationByType(static::KIND_CODE)) + return $classification; + + $classification = $this->_classificationOf(static::KIND_CODE, 'Genre'); + $this->_data->classifications[] = $classification; + return $classification; + } + + + protected function _classificationOf($type, $label) { + $classification = new StdClass(); + $classification->type = $type; + $classification->label= $label; + $classification->entries = []; + return $classification; + } + + + protected function _classificationByType($type) { + $this->_ensureArray('classifications'); + return (new Storm_Collection($this->_data->classifications)) + ->detect(function($item) use ($type) { return $type == $item->type; }); + } + + + protected function _ensureArray($name) { + if (isset($this->_data->$name)) + return $this; + + $this->_data->$name = []; + return $this; + } +} \ No newline at end of file diff --git a/library/Class/Notice/Permalink.php b/library/Class/Notice/Permalink.php new file mode 100644 index 0000000000000000000000000000000000000000..0f902d8c4ef32b29f95eef3b129f77806b20c5bb --- /dev/null +++ b/library/Class/Notice/Permalink.php @@ -0,0 +1,77 @@ +<?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_Notice_Permalink { + protected $_special_types = [Class_TypeDoc::ARTICLE, + Class_TypeDoc::RSS, + Class_TypeDoc::SITE, + Class_TypeDoc::CVS]; + + public function absoluteFor($record, $name=null, $reset=false, $encode=true) { + return Class_Url::absolute($this->paramsFor($record), $name, $reset, $encode); + } + + + public function paramsFor($record) { + if (!$record) + return ['controller'=>'recherche', 'action' => 'simple']; + + if ($this->_isNormal($record)) + return ['controller' => 'recherche', + 'action' => 'viewnotice', + 'clef' => $record->getClefAlpha(), + 'id' => $record->getId()]; + + + switch($record->getTypeDoc()) { + case Class_TypeDoc::ARTICLE: + return ['controller' => 'cms', + 'action' => 'articleview', + 'id' => $record->getChamp856b()]; + + case Class_TypeDoc::RSS: + return ['controller' => 'rss', + 'action' => 'main', + 'id_flux' => $record->getChamp856b()]; + + case Class_TypeDoc::SITE: + return ['controller' => 'sito', + 'action' => 'sitoview', + 'id_items' => $record->getChamp856b()]; + + case Class_TypeDoc::CVS: + return ['controller' => 'modules', + 'action' => 'cvs', + 'docid' => $record->getId()]; + } + } + + + protected function _isNormal($record) { + return !$this->_isSpecial($record); + } + + + protected function _isSpecial($record) { + return in_array($record->getTypeDoc(), $this->_special_types); + } +} \ No newline at end of file diff --git a/library/Class/Notice/SerialArticles.php b/library/Class/Notice/SerialArticles.php new file mode 100644 index 0000000000000000000000000000000000000000..ebf55ba7833772c02b7950d7285b31a8fd70ac04 --- /dev/null +++ b/library/Class/Notice/SerialArticles.php @@ -0,0 +1,43 @@ +<?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_Notice_SerialArticles extends Storm_Model_Abstract { + protected + $_table_name = 'notices_articles', + $_table_primary = 'id_article'; + + + protected $_default_attribute_values = ['clef_chapeau' => '', + 'clef_numero' => '', + 'clef_article' => '', + 'unimarc' => '']; + + + public function validate() { + if (!$this->getClefChapeau()) + $this->addError('Clé chapeau requise'); + + if (!$this->getClefNumero()) + $this->addError('Clé numero requise'); + } +} + +?> \ No newline at end of file diff --git a/library/Class/NoticeDomain.php b/library/Class/NoticeDomain.php index 70514ddd1ad760cd4089048472b1f95a89d3f229..510a2ca8759ca9671927126e89ba2f575cc57d7e 100644 --- a/library/Class/NoticeDomain.php +++ b/library/Class/NoticeDomain.php @@ -103,7 +103,6 @@ class NoticeDomainLoader extends Storm_Model_Loader { $attributs)); foreach ($notices_domains as $notice_domain) { - //Class_NoticeDomain::deleteRecordsFacetteForCart($notice_domain->getDomainId(), $notice_domain->getPanierId()); $notice_domain->delete(); } } @@ -113,13 +112,13 @@ class NoticeDomainLoader extends Storm_Model_Loader { $notices_domains = Class_NoticeDomain::findAllBy(['domain_id' => $domain->getId()]); foreach ($notices_domains as $notice_domain) { - //Class_NoticeDomain::deleteRecordsFacetteForDomain($notice_domain->getDomainId()); $notice_domain->delete(); } } } + class Class_NoticeDomain extends Storm_Model_Abstract { protected $_table_name = 'notice_domain', diff --git a/library/Class/NoticeHtml.php b/library/Class/NoticeHtml.php index 91442e92cb7d1522351582bceddaaca21f7554fe..d9c21f79cd611fb9d974a79cf1e38ff2db558f67 100644 --- a/library/Class/NoticeHtml.php +++ b/library/Class/NoticeHtml.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_NoticeHtml { @@ -24,7 +24,7 @@ class Class_NoticeHtml { public $haut_onglet = ''; // Html ligne du haut avec image fermer pour les onglets public $preferences; // Préférences d'affichage pour les blocs et les onglets private $_translate; - + public function __construct($notice='') { $this->notice = $notice; @@ -36,17 +36,17 @@ class Class_NoticeHtml { /** Conteneur ajax pour une notice */ public function getConteneurNotice($id_notice) { - return - '<div class="notice" id="N' . $id_notice . '">' + return + '<div class="notice" id="N' . $id_notice . '">' . '<table class="notice" align="center"><tr>' . '<td class="notice_patience" style="text-align:right"><img src="'.URL_IMG.'patience.gif" alt="' . $this->_translate->_('Chargement en cours') . '" /></td>' . '<td class="notice_patience" width="80%">' . $this->_translate->_('Veuillez patienter : lecture en cours...') . '</td>' . '</tr></table></div>'; } - - + + public function getNonTrouve($msg='', $haut_onglet=false) { - if (!$msg) + if (!$msg) $msg = $this->_translate->_('Aucune information n\'a été trouvée'); if ($haut_onglet) $html = $this->haut_onglet; @@ -57,15 +57,15 @@ class Class_NoticeHtml { return $html; } - + public function getArticlesPeriodique($articles) { $html = ''; - if ($articles[0]["note"]) + if ($articles[0]["note"]) $html .= '<div style="margin-top:5px;margin-bottom:5px;font-weight:bold">'.$articles[0]["note"].'</div>'; $html .= '<table><tr><td class="notice_info_ligne_titre">'.$this->_translate->_('Articles').' :</td</tr></table>'; - if(!$articles) + if(!$articles) return $this->haut_onglet.$html . $this->_translate->_("Aucun article n'a été trouvé"); $style = ' style="text-align:right;padding-right:5px;padding-left:10px;vertical-align:top;"'; @@ -75,20 +75,20 @@ class Class_NoticeHtml { $html .= '<tr><td style="padding-top:7px" colspan="2" align="left"><b>'.$num." - ".$article["titre"].'</b></td></tr>'; $article_line = '<tr><td %s>%s :</td><td>%s</td></tr>'; - - if ($article['pagination']) - $html .= sprintf($article_line, - $style, - $this->_translate->_('Pagination'), + + if ($article['pagination']) + $html .= sprintf($article_line, + $style, + $this->_translate->_('Pagination'), str_replace("pp.","",$article["pagination"])); - if ($article['auteur']) + if ($article['auteur']) $html .= sprintf($article_line, $style, $this->_translate->_('Auteur'), $article["auteur"]); - if($article['resume']) + if($article['resume']) $html .= sprintf($article_line, $style, $this->_translate->_('Résumé'), @@ -145,7 +145,7 @@ class Class_NoticeHtml { return $this->getNonTrouve(); $premieres_notices = array_splice($notices, 0, 5); - + $codes_facettes = Class_Profil::getCurrentProfil()->getChampsNoticeResultatRecherche(); $html .= $view->ListeNotices_Vignettes($premieres_notices, ['liste_codes' => $codes_facettes]); @@ -157,7 +157,7 @@ class Class_NoticeHtml { //------------------------------------------------------------------------------------------------------ // Bande annonce -//------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------ public function getBandeAnnonce($source,$bo) { $html=$this->haut_onglet; @@ -175,7 +175,7 @@ class Class_NoticeHtml { public function getInterviews($source, $videos, $width, $height) { - if (!$videos) + if (!$videos) return $this->getNonTrouve($this->_translate->_("Aucune vidéo n'a été trouvée."),true); $html = $this->haut_onglet; @@ -206,7 +206,7 @@ class Class_NoticeHtml { $html .= '</table>'; return $html; } - + public function getPhotos($photos) { $html=$this->haut_onglet; @@ -235,7 +235,7 @@ class Class_NoticeHtml { $html .= '</tr></table>'; return $html; } - + public function getMorceaux($notice, $source) { $video_img = Class_Profil::getCurrentProfil()->getUrlImage('bouton/voir_video.png'); @@ -248,8 +248,8 @@ class Class_NoticeHtml { if($source) $html.=sprintf('<div class="notice_info_titre"><h3>%s : %s</h3></div>', $this->_translate->_('Source'), $source); - $volume=0; - + $volume=0; + foreach($notice["morceaux"] as $vol) { $volume++; if ($notice["nombre_volumes"]>1) @@ -289,13 +289,13 @@ class Class_NoticeHtml { "afficher_media('".$id_div."','close','')", $this->_translate->_("Replier"), $this->_translate->_("Replier")); - - if (isset($morceau["url_ecoute"])) + + if (isset($morceau["url_ecoute"])) $img_ecoute .= $audio_js_player->audioJsPlayer($morceau["url_ecoute"]); } // Html - if (!$img_ecoute) + if (!$img_ecoute) $img_ecoute = ' '; $html .= '<li><div>'.$img_video.$close.'</div><div class="notice_info_ligne">'.$plage.': '.$morceau["titre"].'</div>'.$img_ecoute; $html .= '<div id="'.$id_div.'" rel="video" style="display:none"></div>'; @@ -309,7 +309,7 @@ class Class_NoticeHtml { return $html; } - + public function getBibliographie($notices, $auteur) { $html=$this->haut_onglet; if(!$notices) return $html.$this->getNonTrouve(); @@ -348,7 +348,7 @@ class Class_NoticeHtml { public function getTags($tags, $id_notice, $view) { - $user = Zend_Auth::getInstance()->getIdentity(); + $user = Zend_Auth::getInstance()->getIdentity(); $html = $this->haut_onglet; $html .= $view->nuageTags($tags, ['calcul' => 3]); $url = "javascript:fonction_abonne('".$user->ID_USER."','/abonne/tagnotice?id_notice=".$id_notice."')"; diff --git a/library/Class/NoticeUnimarc/Writer.php b/library/Class/NoticeUnimarc/Writer.php index 926dc3f75f632062a361f20e9cc6f47403a89776..16fbdbde3860f867a210f17867eed364a9f9eaf9 100644 --- a/library/Class/NoticeUnimarc/Writer.php +++ b/library/Class/NoticeUnimarc/Writer.php @@ -396,6 +396,7 @@ class Class_NoticeUnimarc_Writer extends Class_NoticeUnimarc { public function _initISODecodeTable() { $this->_iso_decode_table = [ + chr(0x88) => '', chr(0x89) => '', chr(0x90) => '', chr(0xc1).chr(0x41) => 'À', diff --git a/library/Class/OpdsCatalog.php b/library/Class/OpdsCatalog.php index 3f483353c027f6bcc99785b812aff1ad3288ae19..de72698b586018bd1c2cafb4708e4b079e72c847 100644 --- a/library/Class/OpdsCatalog.php +++ b/library/Class/OpdsCatalog.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_OpdsCatalog extends Storm_Model_Abstract { @@ -55,9 +55,9 @@ class Class_OpdsCatalog extends Storm_Model_Abstract { public function newForEntry($url) { $url = $this->_normalizeUrl($url); return Class_OpdsCatalog::getLoader()->newInstance() - ->setLibelle($this->getLibelle()) - ->setWebClient($this->getWebClient()) - ->setUrl($url); + ->setLibelle($this->getLibelle()) + ->setWebClient($this->getWebClient()) + ->setUrl($url); } @@ -82,10 +82,10 @@ class Class_OpdsCatalog extends Storm_Model_Abstract { public function getSearchForm() { - $form = new Zend_Form(array('method' => 'post')); + $form = new ZendAfi_Form(['method' => 'post']); $form - ->addElement('text', 'search', array('required' => true, - 'allowEmpty' => false)) + ->addElement('text', 'search', ['required' => true, + 'allowEmpty' => false]) ->addElement('submit', 'Rechercher'); return $form; } @@ -97,15 +97,15 @@ class Class_OpdsCatalog extends Storm_Model_Abstract { protected function _normalizeUrl($url) { - if (!$this->getUrl()) + if (!$this->getUrl()) return $url; - if ('http' == substr($url, 0, 4)) + if ('http' == substr($url, 0, 4)) return $url; $urlInfos = parse_url($this->getUrl()); $normalized = $urlInfos['scheme'] . '://' . $urlInfos['host']; - if ('/' == substr($url, 0, 1)) + if ('/' == substr($url, 0, 1)) return $normalized . $url; return $normalized . dirname($urlInfos['path']) . $url; } diff --git a/library/Class/Pret.php b/library/Class/Pret.php index 55547cf96b4dc8564702e61fa491c82160ad4c24..e81e2dd44adbde4b03c1b5cafb419ff82ee8ca77 100644 --- a/library/Class/Pret.php +++ b/library/Class/Pret.php @@ -36,5 +36,4 @@ class Class_Pret extends Storm_Model_Abstract { 'code_barres' => $this->getCodeBarres()]);$item; } } - ?> \ No newline at end of file diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 6b651546e49da74a010fe206ea89bdf35dddbd71..576b3136dfe66e8c57fbc16dc4ab168f5bbaba64 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -165,6 +165,10 @@ class Class_Profil extends Storm_Model_Abstract { 'menu_haut_on', 'largeur_division1', 'largeur_site', + 'size_site_scale', + 'width_division1_scale', + 'width_division2_scale', + 'width_division3_scale', 'nb_divisions', 'ordre_divisions', 'hauteur_banniere', @@ -219,6 +223,11 @@ class Class_Profil extends Storm_Model_Abstract { 'mail_suggestion_achat' => '', 'skin' => 'original', 'largeur_site' => 1000, + 'size_site_scale' => 'px', + 'width_division1_scale' => 'px', + 'width_division2_scale' => 'px', + 'width_division3_scale' => 'px', + 'width_division5_scale' => 'px', 'nb_divisions' => 3, 'ordre_divisions' => 0, 'largeur_division1' => 250, @@ -574,10 +583,28 @@ class Class_Profil extends Storm_Model_Abstract { } + /** @return array */ + public function getBannerBoxes() { + $cfg_accueil = $this->getCfgAccueilAsArray(); + $banner_boxes = []; + foreach ($cfg_accueil['modules'] as $id => $module) { + if ($module['division'] == self::DIV_BANNIERE) + $banner_boxes[$id] = $module; + } + + return $banner_boxes; + } + + /** @return array */ public function getLocalModuleAccueilConfig($id_module) { $cfg_accueil = $this->getCfgAccueilAsArray(); - $modules_config = $cfg_accueil['modules']; + + $banner_boxes = []; + if ($this->hasParentProfil()) + $banner_boxes = $this->getParentProfil()->getBannerBoxes(); + + $modules_config = $cfg_accueil['modules'] + $banner_boxes; $module = ['type_module' => null, 'preferences' => []]; if (!array_key_exists($id_module, $modules_config)) @@ -1129,11 +1156,12 @@ class Class_Profil extends Storm_Model_Abstract { if ($this->getNbDivisions() < 3) $this->setLargeurDivision3(0); if ($this->getNbDivisions() < 2) $this->setLargeurDivision2(0); $this->check($this->getLibelle(), 'Le libellé est obligatoire.'); - $this->check($this->getLargeurSite() >= 800 and $this->getLargeurSite() <= 2000, - 'La largeur du site doit être comprise entre 800 et 2000 pixels.'); - $this->check($this->getLargeurDivision1() + + $this->check($this->getSizeSiteScale()!="px" or $this->getLargeurSite() >= 800 and $this->getLargeurSite() <= 2000, + 'La largeur du site doit être comprise entre 800 et 2000 pixels.'); + $this->check($this->getSizeSiteScale()!="px" or + ($this->getLargeurDivision1() + $this->getLargeurDivision2() + - $this->getLargeurDivision3() <= $this->getLargeurSite(), + $this->getLargeurDivision3() <= $this->getLargeurSite()), 'La somme des largeurs des divisions ne doit pas excéder la largeur du site.'); $this->check($this->getLargeurDivision1(), 'Il manque la largeur de la division 1.'); @@ -1153,12 +1181,6 @@ class Class_Profil extends Storm_Model_Abstract { $this->check($this->_isCSSColorValid($this->getCouleurLienBandeau()), 'La couleur des liens du bandeau doit être au format #001122'); - $url_validate = new ZendAfi_Validate_Url(); - $this->check(!$this->getLogoGaucheLink() or $url_validate->isValid($this->getLogoGaucheLink()), - 'Le lien pour le logo gauche n\'est pas valide'); - - $this->check(!$this->getLogoDroiteLink() or $url_validate->isValid($this->getLogoDroiteLink()), - 'Le lien pour le logo droite n\'est pas valide'); $validator = new ZendAfi_Validate_ProfilRewriteUrl(); $validator->isValid($this); @@ -1597,9 +1619,66 @@ class Class_Profil extends Storm_Model_Abstract { public function afterSave() { $this->_has_parent_profil = null; $this->_should_forward_attributes = []; + $this->syncModulesIds(); + } + + + + protected function syncModulesIds() { + $this->syncModulesIdsWithParentProfil(); + } + + + protected function syncModulesIdsWithParentProfil() { + if(!$this->hasParentProfil()) + return; + + if(!$parent_banner_modules = $this->getParentProfil()->getBoitesDivision(self::DIV_BANNIERE)) + return; + + if(!$ids_used_by_parent_profil = array_keys($parent_banner_modules)) + return; + + return $this->doNotUseIds($ids_used_by_parent_profil); } + protected function doNotUseIds($ids) { + $my_cfg = $this->getCfgAccueilAsArray(); + + if(!isset($my_cfg['modules'])) + return; + + if(!$my_modules_ids = array_keys($my_cfg['modules'])) + return; + + if(!$duplicate_ids = array_intersect($ids, $my_modules_ids)) + return; + + $last_used_id = max(array_unique(array_merge($ids, $my_modules_ids))); + + foreach($duplicate_ids as $id) { + $last_used_id++; + $this->changeIdModuleTo($id, $last_used_id); + } + } + + + protected function changeIdModuleTo($id, $new_id) { + $cfg_accueil = $this->getCfgAccueilAsArray(); + $modules = $cfg_accueil['modules']; + $keys = array_keys($modules); + $position = array_search($id, $keys); + + if ($position !== false) { + $keys[$position] = $new_id; + $cfg_accueil['modules'] = array_combine($keys, $modules); + } + + $this->setCfgAccueil($cfg_accueil)->save(); + return $this; + } + public function setCfgMenuHorizontal($cfg_menu_horizontal) { $menus = $this->getCfgMenusAsArray(); @@ -1692,7 +1771,7 @@ class Class_Profil extends Storm_Model_Abstract { $moved_module['division'] = $new_div; unset($cfg_accueil['modules'][$id]); - $new_modules = array(); + $new_modules = []; $i = 0; foreach($cfg_accueil['modules'] as $module_id => $module) { $in_new_div = $module['division'] == $new_div; @@ -1784,12 +1863,9 @@ class Class_Profil extends Storm_Model_Abstract { public function getCss($name) { - if (!$this->_get($name)) - return ''; - - if ($this->getFileWriter()->fileExists($this->getCssPath($name))) - return $this->_get($name); - return ''; + return ($css = $this->_get($name)) + ? $css + : ''; } @@ -1979,5 +2055,10 @@ class Class_Profil extends Storm_Model_Abstract { } return ''; } + + public function getWidthSite() { + return $this->getLargeurSite(). + ($this->getSizeSiteScale()=="percent"? "%":"px"); + } } ?> diff --git a/library/Class/ScriptLoader.php b/library/Class/ScriptLoader.php index 89b321678e384f9c8d622724d0690e0aee571838..c23c25708df137815316ff490bda5e98934d563c 100644 --- a/library/Class/ScriptLoader.php +++ b/library/Class/ScriptLoader.php @@ -256,6 +256,14 @@ class Class_ScriptLoader { } + /** + * @return ScriptLoader + */ + public function addOPACScriptStyleSheet($style_sheet, $attributes=null) { + return $this->addStyleSheet(BASE_URL."/public/opac/js/".$style_sheet, $attributes); + } + + /** * @return ScriptLoader */ @@ -733,6 +741,15 @@ class Class_ScriptLoader { } + public function loadButterflyLightbox() { + return $this->addOPACScript('butterfly/jquery.resize-events') + ->addOPACScript('butterfly/jquery.history') + ->addOPACScript('butterfly/jquery.butterfly.min') + ->addOPACScriptStyleSheet('butterfly/butterfly') + ->addOPACScriptStyleSheet('butterfly/butterfly-ie', ['ie_version' => 6]); + } + + public function addRecordMeta($record) { $this->_metas[] = '<meta property="og:title" content="' . htmlentities($record->getTitrePrincipal()) . ' - ' . $record->getAuteurPrincipal() . '" />'; $this->_metas[] = '<meta property="og:description" content="' . htmlentities($record->getResume()) . '" />'; diff --git a/library/Class/Sitotheque.php b/library/Class/Sitotheque.php index 2dae95d5f2915995671a52cb087cc470a8ea8f18..961852f8c51b08db78b23310fb96cd8b50f3f034 100644 --- a/library/Class/Sitotheque.php +++ b/library/Class/Sitotheque.php @@ -36,6 +36,7 @@ class Class_SitothequeModelSite extends BaseItem { class SitothequeLoader extends Storm_Model_Loader { + /** * @param array $id_sites * @param array $id_categories @@ -100,7 +101,8 @@ class SitothequeLoader extends Storm_Model_Loader { class Class_Sitotheque extends Storm_Model_Abstract { - use Trait_Translator, Trait_TreeViewableItem, Trait_HasManyDomaines, Trait_Indexable, Trait_CustomFields; + use Trait_Translator, Trait_TreeViewableItem, Trait_HasManyDomaines, Trait_Indexable, Trait_CustomFields, + Trait_TimeSource; protected $_loader_class = 'SitothequeLoader'; @@ -125,6 +127,7 @@ class Class_Sitotheque extends Storm_Model_Abstract { public function beforeSave() { + $this->setDateMaj($this->getCurrentDateTime()); $this->unindex(); } diff --git a/library/Class/SitothequeCategorie.php b/library/Class/SitothequeCategorie.php index 0fcf189d8fc6e969593f8f4ca69485bddfeeef75..fe11dbf037db8a563e9d5862822f16bf23ab2a52 100644 --- a/library/Class/SitothequeCategorie.php +++ b/library/Class/SitothequeCategorie.php @@ -32,9 +32,11 @@ class Class_SitothequeCategorie extends Storm_Model_Abstract { protected $_has_many = ['sous_categories' => ['model' => 'Class_SitothequeCategorie', 'role' => 'parent_categorie', + 'order' => 'libelle', 'dependents' => 'delete'], 'sitotheques' => ['model' => 'Class_Sitotheque', + 'order' => 'titre', 'role' => 'categorie', 'dependents' => 'delete']]; diff --git a/library/Class/StatsNotices.php b/library/Class/StatsNotices.php index 5b956cfa247d27d42a9d6432706ead2ca868bfb0..7b1a0695eb6e558ab16939b3f7c9629c2cc91185 100644 --- a/library/Class/StatsNotices.php +++ b/library/Class/StatsNotices.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_StatsNotices { @@ -41,23 +41,23 @@ class Class_StatsNotices { protected function _addStat($id_notice, $field) { $annee = date('Y'); $mois = date('m'); - sqlExecute(sprintf('update notices set %s = %s + 1 where id_notice=%s', + sqlExecute(sprintf('update notices set %s = %s + 1 where id_notice=%s', $field, $field, $id_notice)); - if (!fetchOne(sprintf('select count(*) from stats_notices where annee=%s and mois=%s', - $annee, $mois))) + if (!fetchOne(sprintf('select count(*) from stats_notices where annee=%s and mois=%s', + $annee, $mois))) sqlExecute(sprintf('insert into stats_notices (annee, mois) values (%s, %s)', $annee, $mois)); sqlExecute(sprintf('update stats_notices set %s = %s + 1 where annee=%s and mois=%s', $field, $field, $annee, $mois)); } - + public function getPeriode($annee=0, $mois=0) { $msg = ''; - if ($mois) + if ($mois) $msg = $this->lib_mois[$mois]; - if ($annee) + if ($annee) $msg .= ' ' . $annee; if ($msg) @@ -81,7 +81,7 @@ class Class_StatsNotices { $ret[$annee] = ['total' => $nombre, 'mois' => []]; } $ret["total"] = $total; - + $liste = fetchAll("Select annee, mois, nb_visu as cnt from stats_notices order by annee desc, mois desc"); foreach ($liste as $stat) { $mois = $this->lib_mois[$stat['mois']]; @@ -123,7 +123,7 @@ class Class_StatsNotices { } $ret["total"] = $total; $ret["graphes"]["annees"] = $this->getGraphe($ret["annees"],$total); - + // Par mois $liste = fetchAll("Select mois,sum(nb_resa) from stats_notices group by 1"); foreach($liste as $stat) { @@ -139,14 +139,14 @@ class Class_StatsNotices { public function getPalmaresReservation($type_doc) { if ($type_doc) $where = ' and type_doc=' . $type_doc; - + // Lancer la requete $req = "select id_notice,nb_resa from notices Where nb_resa > 0" . $where . " order by 2 desc LIMIT 0,50"; $liste = fetchAll($req); foreach ($liste as $item) { $id_notice = $item["id_notice"]; $nombre = $item["nb_resa"]; - $notice = ($model = Class_Notice::find($id_notice)) + $notice = ($model = Class_Notice::find($id_notice)) ? $model->getNotice('JA') : []; $lig["id_notice"] = $id_notice; $lig["nombre"] = $nombre; @@ -171,20 +171,23 @@ class Class_StatsNotices { protected function _isBlackListed() { + // @see http://forge.afi-sa.fr/issues/23151 + return true; + $robots = explode(';', getVar('BLACK_LIST_ROBOT')); $client = null; if (array_isset('REMOTE_HOST', $_SERVER)) $client = $_SERVER['REMOTE_HOST']; - if (!$client and array_isset('REMOTE_ADDR', $_SERVER)) + if (!$client and array_isset('REMOTE_ADDR', $_SERVER)) $client = str_replace('-', '.', $_SERVER['REMOTE_ADDR']); - if (!$client) + if (!$client) return true; - foreach($robots as $robot) - if (trim($robot) and striPos($client, $robot) !== false) + foreach($robots as $robot) + if (trim($robot) and striPos($client, $robot) !== false) return true; return false; } diff --git a/library/Class/Systeme/ModulesAccueil/Critiques.php b/library/Class/Systeme/ModulesAccueil/Critiques.php index 8c9d1a8909517814d0a07159594c804d61f2b746..fbb1f5a8a1d798e5b86e4d5d7dac200f18f6f5fe 100644 --- a/library/Class/Systeme/ModulesAccueil/Critiques.php +++ b/library/Class/Systeme/ModulesAccueil/Critiques.php @@ -16,12 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Systeme_ModulesAccueil_Critiques extends Class_Systeme_ModulesAccueil_Null{ /** @var string */ protected $_group = Class_Systeme_ModulesAccueil::GROUP_INFO; - + /** @var string */ protected $_libelle = 'Critiques'; @@ -38,17 +38,17 @@ class Class_Systeme_ModulesAccueil_Critiques extends Class_Systeme_ModulesAccuei protected $_isPhone = true; /** @var array */ - protected $_defaultValues = array( - 'titre' => "Dernières critiques", // Titre du bloc critiques - 'nb_aff_avis' => 2, // Nombre de critiques à afficher - 'nb_words' => 30, // Couper les critiques à X mots - 'display_order' => "Random", // Affichage par ordre aléatoire - 'rss_avis' => "1", // Proposer le flux RSS - 'only_img' => '1', - 'id_panier' => 0, - 'id_catalogue' => 0, - 'abon_ou_bib' => 0, - 'tri' => 0 //tri par titre - ); + protected $_defaultValues = ['titre' => "Dernières critiques", // Titre du bloc critiques + 'nb_aff_avis' => 2, // Nombre de critiques à afficher + 'nb_words' => 30, // Couper les critiques à X mots + 'display_order' => "Random", // Affichage par ordre aléatoire + 'rss_avis' => "1", // Proposer le flux RSS + 'only_img' => '1', + 'id_panier' => 0, + 'id_catalogue' => 0, + 'abon_ou_bib' => 0, + 'tri' => 0, //tri par titre + 'hierarchical' => 0, + ]; } ?> \ No newline at end of file diff --git a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php index 111b7916f0d207ff7876708ef4158a3adf08ada8..e5a60cd595e1cf7c796c8567f84468113b7ca42f 100644 --- a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php +++ b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php @@ -16,12 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Systeme_ModulesAccueil_RechercheSimple extends Class_Systeme_ModulesAccueil_Null{ /** @var string */ protected $_group = Class_Systeme_ModulesAccueil::GROUP_RECH; - + /** @var string */ protected $_libelle = 'Recherche simple'; @@ -38,19 +38,21 @@ class Class_Systeme_ModulesAccueil_RechercheSimple extends Class_Systeme_Modules protected $_isPhone = false; /** @var array */ - protected $_defaultValues = [ - 'titre' => 'Rechercher', // Titre de la boite - 'message' => '', // Message au-dessus du champ de saisie - 'exemple' => '', // Exemple sous le champ de saisie - 'select_bib' => 0, // Sélection des bib - 'select_doc' => 0, // Sélection des types de docs - 'select_annexe' => 0, // Sélection annexes - 'largeur' => 140, // du champ de saisie - 'recherche_avancee' => 1, //afficher le lien recherche avancée, - 'type_doc' => 0, // filtre du type de doc - 'tri' => '*', - 'profil_redirect' => 0, //type de profil vers lequel basculer lors d'une recherche - 'placeholder' => '' //message d'exemple dans le champ de recherche - ]; + protected $_defaultValues = + [ + 'titre' => 'Rechercher', // Titre de la boite + 'message' => '', // Message au-dessus du champ de saisie + 'exemple' => '', // Exemple sous le champ de saisie + 'select_bib' => 0, // Sélection des bib + 'select_doc' => 0, // Sélection des types de docs + 'select_annexe' => 0, // Sélection annexes + 'largeur' => 140, // du champ de saisie + 'recherche_avancee' => 1, //afficher le lien recherche avancée, + 'type_doc' => 0, // filtre du type de doc + 'tri' => '*', + 'profil_redirect' => 0, //type de profil vers lequel basculer lors d'une recherche + 'placeholder' => '', //message d'exemple dans le champ de recherche + 'search_button' => ''//search button text value + ]; } ?> \ No newline at end of file diff --git a/library/Class/Systeme/PergameService.php b/library/Class/Systeme/PergameService.php index 710f8c982bb27e6a508807ba49dca59daa02b27b..6ea5abb3e47f218e1203f72f9732f987e0d537c0 100644 --- a/library/Class/Systeme/PergameService.php +++ b/library/Class/Systeme/PergameService.php @@ -20,7 +20,7 @@ */ class Class_Systeme_PergameService { - use Trait_TimeSource; + use Trait_TimeSource, Trait_Translator; private $user; @@ -35,7 +35,7 @@ class Class_Systeme_PergameService { public function getNbPretsEnRetard() { - $date = date('Y-m-d'); + $date = $this->getTimeSource()->dateYmd(); $req = 'select count(*) from prets where IDABON=\'' . $this->user->IDABON . '\' and ORDREABON=' . $this->user->ORDREABON . ' and EN_COURS=1 and DATE_RETOUR < \'' . $date .'\''; $nb_retard = fetchOne($req); return $nb_retard; @@ -113,32 +113,46 @@ class Class_Systeme_PergameService { public function getReservations() { - $data=fetchAll("select * from reservations where IDABON='".$this->user->IDABON."' and ORDREABON=".$this->user->ORDREABON); - if(!$data) return array(); - foreach($data as $enreg) - { - $notice=$this->getNoticeFromTransaction($enreg["SUPPORT"],$enreg["ID_NOTICE_ORIGINE"]); + $data = Class_Reservation::findAllBy(['idabon' => $this->user->getIdabon(), + 'ordreabon' => $this->user->getOrdreabon()]); + if(!$data) + return []; + + foreach($data as $enreg) { + $notice = $this->getNoticeFromTransaction($enreg->getSupport(), + $enreg->getIdNoticeOrigine()); $resa["titre"]=$notice["J"]; - if($notice["A"]) $resa["titre"].=" / ".$notice["A"]; - // rang - $rang=fetchOne("select count(*) from reservations where ID_NOTICE_ORIGINE=".$enreg["ID_NOTICE_ORIGINE"]." and DATE_RESA<'".$enreg["DATE_RESA"]."'"); - $resa["rang"]=$rang+1; - $resa["id_suppr"]=$enreg["ID_RESA"]; + if($notice["A"]) + $resa["titre"].= " / ".$notice["A"]; + + $rang = Class_Reservation::countBy(['where' => "ID_NOTICE_ORIGINE = " . $enreg->getIdNoticeOrigine() . + " and DATE_RESA < '" . $enreg->getDateResa() . "'"]); - // Controle si en pret - $en_pret=fetchOne("select count(*) from prets where ID_NOTICE_ORIGINE=".$enreg["ID_NOTICE_ORIGINE"]." and EN_COURS=1"); - if($en_pret>0) $resa["etat"]="en prêt"; - elseif($resa["rang"]==1) $resa["etat"]="disponible"; - else $resa["etat"]="réservé"; + $resa["rang"] = $rang + 1; + $resa["id_suppr"] = $enreg->getIdResa(); - // empiler - $reservations[]=$resa; + $en_pret = Class_Pret::countBy(['id_notice_origine' => $enreg->getIdNoticeOrigine(), + 'en_cours' => 1]); + + $resa['etat'] = $this->getHoldStatus($en_pret, $resa['rang']); + $reservations[] = $resa; } return $reservations; } + protected function getHoldStatus($numbers_of_loans, $hold_rank) { + if($numbers_of_loans > 0) + return $this->_('en prêt'); + + if( 1 == $hold_rank) + return $this->_('disponible'); + + return $this->_('réservé'); + } + + private function getNoticeFromCodeBarres($id_bib, $code_barres) { $cls_notice = new Class_Notice(); $id_notice = fetchOne("select id_notice from exemplaires where code_barres='$code_barres' and id_bib=$id_bib"); @@ -175,25 +189,31 @@ class Class_Systeme_PergameService { public function reserverExemplairePergame($id_bib, $exemplaire, $code_annexe) { if (!$this->user || !$this->user->ID_USER) - return ['erreur' => 'Vous devez être connecté pour réserver un document']; + return ['erreur' => $this->_('Vous devez être connecté pour réserver un document')]; if(!$this->user->IDABON) - return ['erreur' => 'Vous devez être connecté en tant qu\'abonné pour réserver un document']; + return ['erreur' => $this->_('Vous devez être connecté en tant qu\'abonné pour réserver un document')]; if (!$exemplaire) - return ['erreur' => 'Une erreur s\'est produite lors de la lecture de la notice.']; + return ['erreur' => $this->_('Une erreur s\'est produite lors de la lecture de la notice.')]; + + if(!$id_bib) + $id_bib = 1; + + if(!$code_annexe) + $code_annexe = $id_bib; $notice = $exemplaire->getNotice(); $support = $notice->getFamilleId(); // Controle si deja réservé par l'abonné $ret = null; - $id_abon = $this->user->IDABON; - $ordre_abon = $this->user->ORDREABON; + $id_abon = $this->user->getIdabon(); + $ordre_abon = $this->user->getOrdreabon(); $id_origine = $exemplaire->getIdOrigine(); $resa = Class_Reservation::findFirstBy([ 'id_notice_origine' => $id_origine, - 'id_site' => $id_bib, + 'id_site' => $code_annexe, 'idabon' => $id_abon, 'ordreabon'=> $ordre_abon]); @@ -212,13 +232,10 @@ class Class_Systeme_PergameService { if ($nb >= $regles['Max_par_document']) return ['erreur' => 'La réservation est impossible car le nombre maximum de réservations pour ce document a été atteint (' . $regles["Max_par_document"] . ').']; - if (!$id_bib) - $id_bib = 1; - $time_source = self::getTimeSource(); Class_Reservation::newInstance([ - 'id_site' => $id_bib, + 'id_site' => $code_annexe, 'id_pergame' => 0, 'idabon' => $id_abon, 'ordreabon' => $ordre_abon, @@ -317,7 +334,10 @@ class Class_Systeme_PergameService { public function getReglesReservation($id_bib) { if (!$id_bib) return false; - $bib = Class_IntBib::find($id_bib); + + if(!$bib = Class_IntBib::find($id_bib)) + return false; + $data = $bib->getCommParamsAsArray(); if (!isset($data["Max_par_carte"])) $data["Max_par_carte"] = 3; diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php index 042f97ad354407f6a809305ac904b29275e54cf7..8b68c57d4849003217132af71cc344643e297056 100644 --- a/library/Class/TypeDoc.php +++ b/library/Class/TypeDoc.php @@ -179,6 +179,7 @@ class TypeDocLoader extends Storm_Model_Loader { class Class_TypeDoc extends Storm_Model_Abstract { const CODE_FACETTE = 'T'; + const NUMERIC_START = 100; protected $_loader_class = 'TypeDocLoader'; protected $_belongs_to = ['codif_type_doc' => @@ -207,6 +208,7 @@ class Class_TypeDoc extends Storm_Model_Abstract { const DILICOM = 112; const ORPHEA = 113; const ONEDTOUCH = 114; + const JAMENDO = 115; public static function getDefaultTypeDocs() { @@ -233,6 +235,7 @@ class Class_TypeDoc extends Storm_Model_Abstract { self::DILICOM => 'Livre numérique (PNB)', self::ONEDTOUCH => '1D touch', self::ORPHEA => 'Orphea', + self::JAMENDO => 'Jamendo', ]; } @@ -299,8 +302,10 @@ class Class_TypeDoc extends Storm_Model_Abstract { public function getCodifTypeDoc() { if ($codif=parent::_get('codif_type_doc')) return $codif; + $codif=Class_CodifTypeDoc::newInstance( ['type_doc_id' => $this->getId(), 'famille_id' => $this->getId()]); + $codif->save(); $codif->setId($this->getId()); $this->setCodifTypeDoc($codif); @@ -355,6 +360,7 @@ class Class_TypeDoc extends Storm_Model_Abstract { public function setFamilleId($id) { $this->getCodifTypeDoc()->setFamilleId($id); + return $this; } @@ -380,4 +386,4 @@ class Class_TypeDoc extends Storm_Model_Abstract { } } -?> +?> \ No newline at end of file diff --git a/library/Class/Url.php b/library/Class/Url.php index e078d20ad454450feaf74d0b038694220f7d0f0d..5a409a919a16d5f4afd7a6844515a908a8228a49 100644 --- a/library/Class/Url.php +++ b/library/Class/Url.php @@ -32,12 +32,18 @@ class Class_Url { } + public static function rootUrl() { + return (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS'] || $_SERVER['HTTPS'] == 'off' ? 'http://' : 'https://') + . $_SERVER['SERVER_NAME'] + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']); + } + + public static function doNotAddBaseUrl() { static::$_do_not_add_base_url = true; } - /** * Generates an url given the name of a route. * @@ -64,9 +70,11 @@ class Class_Url { if (preg_match('/http[s]?:\/\//', $url)) return $url; - if ((!static::$_do_not_add_base_url) && (0 !== strpos($url, BASE_URL))) + if ((!static::$_do_not_add_base_url) && BASE_URL && (0 !== strpos($url, BASE_URL))) $url = BASE_URL . ($url[0] == '/' ? $url : '/'.$url); + $url = ($url[0] == '/' ? $url : '/'.$url); + return 'http://' . $_SERVER['SERVER_NAME'] . $url; } diff --git a/library/Class/User/Loans.php b/library/Class/User/Loans.php new file mode 100644 index 0000000000000000000000000000000000000000..d20721ae4abc6f429c445a0744e5bb5870fe0d66 --- /dev/null +++ b/library/Class/User/Loans.php @@ -0,0 +1,37 @@ +<?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_User_Loans extends Storm_Model_Collection_Abstract { + public function selectLates() { + return $this->select(function($loan) {return $loan->isLate();}); + } + + + public function withoutPNB() { + return $this->reject(function($loan) {return $loan->isPNB();}); + } + + + public function selectPNB() { + return $this->select(function($loan) {return $loan->isPNB();}); + } +} +?> \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index 9ed4c5ea9c7dcce088a3fdf9e6ead3463b30a969..a1c1fd0bc80bf07d712eca1f54d1532ba2e45fb9 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -52,8 +52,8 @@ class UsersLoader extends Storm_Model_Loader { $sql_template .= 'where '; $sql_template .= - '(nom like \'%2$s\' or login like \'%2$s\') '. - 'order by nom, prenom, login limit '.$limit; + '(nom like \'%2$s\' or login like \'%2$s\') '. + 'order by nom, prenom, login limit '.$limit; $like = strtolower($search).'%'; @@ -216,16 +216,16 @@ class UsersLoader extends Storm_Model_Loader { public function findBlowfish($login) { return array_filter( - Class_Users::findAllBy(['login' => $login]), - function($user) { - return substr($user->getPassword(), 0, 4) === '$2a$'; - }); + Class_Users::findAllBy(['login' => $login]), + function($user) { + return substr($user->getPassword(), 0, 4) === '$2a$'; + }); } public function isEmailUnique($email) { $users = Class_Users::findFirstBy([ - 'where' => 'login = "'.$email.'" or mail = "'.$email.'"']); + 'where' => 'login = "'.$email.'" or mail = "'.$email.'"']); return $users ? false : true; } } @@ -247,49 +247,49 @@ class Class_Users extends Storm_Model_Abstract { protected $_table_primary = 'ID_USER'; protected $_loader_class = 'UsersLoader'; protected $_has_many = [ - 'subscriptions' => ['model' => 'Class_NewsletterSubscription', - 'role' => 'user', - 'dependents' => 'delete'], + 'subscriptions' => ['model' => 'Class_NewsletterSubscription', + 'role' => 'user', + 'dependents' => 'delete'], - 'newsletters' => ['through' => 'subscriptions'], + 'newsletters' => ['through' => 'subscriptions'], - 'avis' => ['model' => 'Class_AvisNotice', - 'role' => 'user', - 'order' => 'date_avis desc'], + 'avis' => ['model' => 'Class_AvisNotice', + 'role' => 'user', + 'order' => 'date_avis desc'], - 'avis_articles' => ['model' => 'Class_Avis', - 'role' => 'auteur', - 'order' => 'date_avis desc'], + 'avis_articles' => ['model' => 'Class_Avis', + 'role' => 'auteur', + 'order' => 'date_avis desc'], - 'paniers' => ['model' => 'Class_PanierNotice', - 'role' => 'user', - 'order' => 'date_maj desc'], + 'paniers' => ['model' => 'Class_PanierNotice', + 'role' => 'user', + 'order' => 'date_maj desc'], - 'suggestion_achat' => ['model' => 'Class_SuggestionAchat', - 'role' => 'user', - 'order' => 'date_creation desc'], + 'suggestion_achat' => ['model' => 'Class_SuggestionAchat', + 'role' => 'user', + 'order' => 'date_creation desc'], - 'session_formation_inscriptions' => ['model' => 'Class_SessionFormationInscription', - 'role' => 'stagiaire'], + 'session_formation_inscriptions' => ['model' => 'Class_SessionFormationInscription', + 'role' => 'stagiaire'], - 'session_formations' => ['through' => 'session_formation_inscriptions'], + 'session_formations' => ['through' => 'session_formation_inscriptions'], - 'formations' => ['through' => 'session_formation_inscriptions'], + 'formations' => ['through' => 'session_formation_inscriptions'], - 'session_formation_interventions' => ['model' => 'Class_SessionFormationIntervention', - 'role' => 'intervenant'], + 'session_formation_interventions' => ['model' => 'Class_SessionFormationIntervention', + 'role' => 'intervenant'], - 'session_interventions' => ['through' => 'session_formation_interventions'], + 'session_interventions' => ['through' => 'session_formation_interventions'], - 'user_group_memberships' => ['model' => 'Class_UserGroupMembership', - 'role' => 'user', - 'dependents' => 'delete'], + 'user_group_memberships' => ['model' => 'Class_UserGroupMembership', + 'role' => 'user', + 'dependents' => 'delete'], - 'user_groups' => ['through' => 'user_group_memberships'], + 'user_groups' => ['through' => 'user_group_memberships'], - 'formulaires' => ['model' => 'Class_Formulaire', - 'role' => 'user', - 'order' => 'date_creation desc'], + 'formulaires' => ['model' => 'Class_Formulaire', + 'role' => 'user', + 'order' => 'date_creation desc'], ]; @@ -329,7 +329,9 @@ class Class_Users extends Storm_Model_Abstract { 'is_contact_mail' => 0, 'ordreabon' => '', 'id_panier_courant' => 0]; - protected $_fiche_sigb; + protected + $_fiche_sigb, + $_loans; public static function currentUserId() { if (!$user = self::getLoader()->getIdentity()) @@ -348,6 +350,15 @@ class Class_Users extends Storm_Model_Abstract { return $this->getRoleLevel() == ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB; } + public function isAbonneInviteInGroupMultimedia(){ + + if(!$group = Class_UserGroup::findGroupUserMultimedia()) return false; + + if(!$memberShip = Class_UserGroupMembership::findFirstBy(['user_id'=> $this->getId(), 'user_group_id'=>$group->getId()])) return false; + + return $this->getRoleLevel() == ZendAfi_Acl_AdminControllerRoles::INVITE; + } + public function isBibliothecaire() { return $this->getRoleLevel() >= ZendAfi_Acl_AdminControllerRoles::MODO_BIB; @@ -360,27 +371,26 @@ class Class_Users extends Storm_Model_Abstract { return $bib->getLibelle(); } + public function getUserIdSite() { + $comm = new Class_CommSigb(); + return $comm->getUserAnnexe($this); +// return $this->id_site; + } + /** * @return bool */ public function isRedacteur() { return in_array( - $this->getRoleLevel(), - [ - ZendAfi_Acl_AdminControllerRoles::MODO_BIB, - ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL - ] + $this->getRoleLevel(), + [ + ZendAfi_Acl_AdminControllerRoles::MODO_BIB, + ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL + ] ); } - /** - * @return bool - */ - public function isReferent() { - return $this->getRoleLevel() >= ZendAfi_Acl_AdminControllerRoles::REFERENT; - } - /** * @return bool @@ -425,9 +435,9 @@ class Class_Users extends Storm_Model_Abstract { */ public function setModeContact($mode_contact) { switch ($mode_contact) { - case self::MODE_CONTACT_MAIL: $this->setIsContactMail(true)->setIsContactSms(false); break; - case self::MODE_CONTACT_SMS: $this->setIsContactMail(false)->setIsContactSms(true); break; - default: $this->setIsContactMail(false)->setIsContactSms(false); + case self::MODE_CONTACT_MAIL: $this->setIsContactMail(true)->setIsContactSms(false); break; + case self::MODE_CONTACT_SMS: $this->setIsContactMail(false)->setIsContactSms(true); break; + default: $this->setIsContactMail(false)->setIsContactSms(false); } return $this; } @@ -577,8 +587,8 @@ class Class_Users extends Storm_Model_Abstract { public function getUserGroupsIds() { $groups = $this->getUserGroups(); return array_map( - function($group) { return $group->getId();}, - $groups); + function($group) { return $group->getId();}, + $groups); } @@ -686,7 +696,9 @@ class Class_Users extends Storm_Model_Abstract { * @return bool */ public function hasRightAccessDomaines() { - return $this->isRoleMoreThanModoBib() || $this->hasRightToAccess(Class_UserGroup::RIGHT_USER_DOMAINES_SUPPRESSION_LIMIT) || $this->hasRightToAccess(Class_UserGroup::RIGHT_USER_DOMAINES_TOTAL_ACCESS); + return $this->isRoleMoreThanModoBib() + || $this->hasRightToAccess(Class_UserGroup::RIGHT_USER_DOMAINES_SUPPRESSION_LIMIT) + || $this->hasRightToAccess(Class_UserGroup::RIGHT_USER_DOMAINES_TOTAL_ACCESS); } @@ -794,25 +806,25 @@ class Class_Users extends Storm_Model_Abstract { public function getUsers($id_zone,$id_site,$role_level,$recherche,$page) { if($id_site and $id_site !="ALL") - { - if($id_site=="PORTAIL") $id_site=0; - $cond[]="id_site=$id_site"; - } + { + if($id_site=="PORTAIL") $id_site=0; + $cond[]="id_site=$id_site"; + } elseif($id_zone and $id_zone !="ALL") - { - if($id_zone=="PORTAIL") $cond[]="ID_SITE=0"; - else { - $bibs=fetchAll("select ID_SITE from bib_c_site where ID_ZONE=$id_zone"); - if(!$bibs) return false; - foreach($bibs as $bib) - { - if($inSql) $inSql.=","; - $inSql.=$bib["ID_SITE"]; - } - $cond[]="ID_SITE in($inSql)"; + if($id_zone=="PORTAIL") $cond[]="ID_SITE=0"; + else + { + $bibs=fetchAll("select ID_SITE from bib_c_site where ID_ZONE=$id_zone"); + if(!$bibs) return false; + foreach($bibs as $bib) + { + if($inSql) $inSql.=","; + $inSql.=$bib["ID_SITE"]; + } + $cond[]="ID_SITE in($inSql)"; + } } - } $recherche = array_merge(array('role' => '', 'login' => '', 'nom' => ''), $recherche); @@ -874,7 +886,7 @@ class Class_Users extends Storm_Model_Abstract { if ($this->getRoleLevel() > 1 and $this->getRoleLevel() < 5 and $this->getIdSite() == 0) { $cls_role= new ZendAfi_Acl_AdminControllerRoles(); $this->addError($this->_("La bibliothèque est obligatoire pour le rôle : %s", - $cls_role->getLibelleRole($this->getRoleLevel()))); + $cls_role->getLibelleRole($this->getRoleLevel()))); } if ($this->getRole()=="abonne_sigb" and !$this->getIdabon()) @@ -1023,7 +1035,28 @@ class Class_Users extends Storm_Model_Abstract { * @return array */ public function getEmprunts() { - return $this->getEmprunteur()->getEmprunts(); + if (!isset($this->_loans)) + $this->_loans = new Class_User_Loans(array_merge( + $this->getEmprunteur()->getEmprunts(), + Class_Loan_Pnb::findAllBy(['user_id' => $this->getId(), + 'ongoing' => true]))); + return $this->_loans; + } + + + public function hasPNB() { + return 0 < Class_Loan_Pnb::countBy(['user_id' => $this->getId(), + 'ongoing' => true]); + } + + + public function getLoansWithOutPNB() { + return $this->getEmprunts()->withoutPNB(); + } + + + public function getPNBLoans() { + return $this->getEmprunts()->selectPNB(); } @@ -1041,26 +1074,11 @@ class Class_Users extends Storm_Model_Abstract { } - /** - * Liste des Class_WebService_SIGB_Emprunt en retard - * @return array - */ - public function getEmpruntsRetard() { - $emprunts = $this->getEmprunts(); - $retards = array(); - foreach ($emprunts as $emprunt) { - if ($emprunt->enRetard()) - $retards[]=$emprunt; - } - return $retards; - } - - /** * @return int */ public function getNbEmprunts() { - return $this->getEmprunteur()->getNbEmprunts(); + return $this->getEmprunts()->count(); } @@ -1068,7 +1086,7 @@ class Class_Users extends Storm_Model_Abstract { * @return int */ public function getNbEmpruntsRetard() { - return $this->getEmprunteur()->getNbPretsEnRetard(); + return $this->getEmprunts()->selectLates()->count(); } @@ -1167,7 +1185,7 @@ class Class_Users extends Storm_Model_Abstract { public function beforeSave() { $this->setDateMaj(Class_Multimedia_Utils_DateTimeFormat::getInstance() - ->getCurrentDateFormatInYmdHMS()); + ->getCurrentDateFormatInYmdHMS()); if(!$this->isNew()) return $this; @@ -1221,7 +1239,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('+1 day', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } @@ -1234,7 +1252,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('next monday', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } @@ -1247,7 +1265,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('first day of next month', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } diff --git a/library/Class/WebService/AllServices.php b/library/Class/WebService/AllServices.php index a2d5babee2af2bc57abee7611844429c0a6b2304..b11bed6d6e249ef533f2500966c80095f562eab5 100644 --- a/library/Class/WebService/AllServices.php +++ b/library/Class/WebService/AllServices.php @@ -22,6 +22,8 @@ class Class_WebService_AllServices { const RETOUR_SERVICE_OK = 2; + const SVC_API = '2.0'; + private static $_http_client; private $services = [ @@ -151,6 +153,7 @@ class Class_WebService_AllServices { $args = array(); $args['src'] = self::createSecurityKey(); + $args['api'] = self::SVC_API; $args['action'] = $service; return json_decode(self::httpGet($url_service, $args), diff --git a/library/Class/WebService/BibNumerique/Abstract.php b/library/Class/WebService/BibNumerique/Abstract.php index 3561496df7c66b39a921c1aa2904081e30ed5669..2e2306b2ebb9d5f64e93123e4d33f05790a33374 100644 --- a/library/Class/WebService/BibNumerique/Abstract.php +++ b/library/Class/WebService/BibNumerique/Abstract.php @@ -20,21 +20,37 @@ */ abstract class Class_WebService_BibNumerique_Abstract extends Class_WebService_Abstract { + const SESSION_NAMESPACE = 'HARVEST'; - protected $_logger, - $web_client, + protected static $_harvested_ids_cache; + + protected + $_logger, + $_web_client, $_harvested_ids; + public static function setHarvestedIdsCache($cache) { + static::$_harvested_ids_cache = $cache; + } + + + public static function getHarvestedIdsCache() { + if (!isset(static::$_harvested_ids_cache)) + static::$_harvested_ids_cache = new Zend_Session_Namespace(md5(BASE_URL), self::SESSION_NAMESPACE); + return static::$_harvested_ids_cache; + } + + public function setWebClient($client) { - $this->web_client = $client; + $this->_web_client = $client; return $this; } public function getWebClient() { - if (!isset($this->web_client)) + if (!isset($this->_web_client)) $this->setWebClient(self::getHttpClient()); - return $this->web_client; + return $this->_web_client; } public function setLogger($logger) { @@ -50,6 +66,57 @@ abstract class Class_WebService_BibNumerique_Abstract extends Class_WebService_A } + public function harvestPage($page_number = 1) { + if (1 == $page_number) + $this->getHarvestedIdsCache()->harvestedIds = array(); + + if (!$harvested_ids = $this->getHarvestedIdsCache()->harvestedIds) + $harvested_ids = []; + + $response = array(); + if (null == ($reader = $this->loadPage($page_number))) { + $response['error'] = 'Erreur de communication'; + return $response; + } + + $response['total_count'] = $reader->getTotalCount(); + $response['current_page'] = $reader->getPageNumber(); + $response['page_count'] = $reader->getPageCount(); + $response['has_next'] = $reader->getPageNumber() < $reader->getPageCount(); + + $harvested_ids = array_merge($harvested_ids, $this->_importRessources($reader->getRessourcesNumeriques())); + $this->getHarvestedIdsCache()->harvested_ids = $harvested_ids; + + if (!$response['has_next']) + $this->setHarvestedIds($harvested_ids); + + $this->_deleteNonHarvested(); + + return $response; + } + + + /** + * @param $ressources array + * @return array of harvested ids + */ + protected function _importRessources($ressources) { + $harvestedIds = array(); + foreach ($ressources as $ressource) { + $harvestedIds[] = $ressource->getId(); + if ($ressource->isAlreadyHarvested()) + continue; + + $this->loadRessource($ressource); + $ressource->import(); + } + return $harvestedIds; + } + + + public function loadRessource($film) {} + + public function harvest() { $current_page = 1; $total_page = 0; @@ -67,7 +134,7 @@ abstract class Class_WebService_BibNumerique_Abstract extends Class_WebService_A $this->_harvested_ids = array_merge($this->_harvested_ids, $this->_importRessources($ress_numerique)); $current_page++; - } while ($current_page <= $total_page); + } while (($current_page <= $total_page) && !empty($ress_numerique)); $this->_deleteNonHarvested(); } @@ -83,21 +150,6 @@ abstract class Class_WebService_BibNumerique_Abstract extends Class_WebService_A } abstract protected function _deleteNonHarvested(); - - - protected function _importRessources($ressources) { - $harvestedIds = []; - foreach ($ressources as $ressource) { - $harvestedIds[] = $ressource->getId(); - if ($ressource->isAlreadyHarvested()) - continue; - - $ressource->import(); - } - return $harvestedIds; - } - - abstract protected function loadPage($page_number = 1); abstract public function isEnabled(); abstract public function getName(); diff --git a/library/Class/WebService/BibNumerique/ArteVOD.php b/library/Class/WebService/BibNumerique/ArteVOD.php index 96b8ac0a0a5fdf54bd305efee2bdc35362a013d2..d5ee4006c482c4d08ea866090664d197d080f274 100644 --- a/library/Class/WebService/BibNumerique/ArteVOD.php +++ b/library/Class/WebService/BibNumerique/ArteVOD.php @@ -16,17 +16,10 @@ * * 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_BibNumerique_ArteVOD extends Class_WebService_BibNumerique_Abstract { - const SESSION_NAMESPACE = 'ARTEVOD'; - - protected static $_harvested_ids_cache; - - protected $web_client; - protected $_harvested_ids = array(); - const BASE_URL = 'http://www.mediatheque-numerique.com/ws/'; const FILMS = 'films'; @@ -36,91 +29,6 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu const CATEGORY_LABEL = 'ArteVOD'; - public static function setHarvestedIdsCache($cache) { - self::$_harvested_ids_cache = $cache; - } - - - public static function getHarvestedIdsCache() { - if (!isset(self::$_harvested_ids_cache)) - self::$_harvested_ids_cache = new Zend_Session_Namespace(self::SESSION_NAMESPACE); - return self::$_harvested_ids_cache; - } - - - public function getHarvestedIds() { - return $this->_harvested_ids; - } - - - public function harvestPage($page_number = 1) { - if (1 == $page_number) - $this->getHarvestedIdsCache()->harvestedIds = array(); - $harvestedIds = $this->getHarvestedIdsCache()->harvestedIds; - - $response = array(); - if (null == ($reader = $this->loadPage($page_number))) { - $response['error'] = 'Erreur de communication'; - return $response; - } - - $response['total_count'] = $reader->getTotalCount(); - $response['current_page'] = $reader->getPageNumber(); - $response['page_count'] = $reader->getPageCount(); - $response['has_next'] = $reader->getPageNumber() < $reader->getPageCount(); - - $harvestedIds = array_merge($harvestedIds, $this->_importFilms($reader->getFilms())); - $this->getHarvestedIdsCache()->harvestedIds = $harvestedIds; - - if (!$response['has_next']) - $this->setHarvestedIds($harvestedIds); - - $this->_deleteNonHarvested(); - - return $response; - } - - - /** - * @param $films array - * @return array of harvested ids - */ - protected function _importFilms($films) { - $harvestedIds = array(); - foreach ($films as $film) { - $harvestedIds[] = $film->getId(); - if ($film->isAlreadyHarvested()) - continue; - - $this->loadFilm($film); - $film->import(); - } - return $harvestedIds; - } - - - protected function _importRessources($films) { - $harvestedIds = array(); - foreach ($films as $film) { - $harvestedIds[] = $film->getId(); - if ($film->isAlreadyHarvested()) - continue; - - $this->loadFilm($film); - $film->import(); - } - return $harvestedIds; - } - - - protected function _deleteNonHarvested() { - if (0 < count($this->getHarvestedIds())) - Class_Album::getLoader() - ->deleteBy(['where' => 'url_origine="'.self::BASE_URL.'" and id_origine not in (\'' . implode("', '", $this->getHarvestedIds()) . '\')']); - - } - - protected function loadPage($page_number = 1) { $url = self::BASE_URL . self::FILMS . ((1 != $page_number) ? '?page_nb=' . $page_number: ''); $content = $this->open_authenticated_url($url); @@ -133,13 +41,13 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu $this->getLogger()->info('Réponse reçue'); $reader = $this->getFilmsReader()->parse($content); - if (1 == $page_number) + if (1 == $page_number) $this->getLogger()->info($reader->getTotalCount() .' films dans la base'); return $reader; } - public function loadFilm($film) { + public function loadRessource($film) { $content = $this->open_authenticated_url(self::BASE_URL . self::FILMS . '/' . $film->getId()); if ('' == $content) { $this->getLogger()->err(sprintf('Erreur de communication lors de la récupération du film %s', @@ -153,7 +61,7 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu public function open_authenticated_url($url) { - $this->getWebClient()->setAuth(Class_AdminVar::get('ARTE_VOD_LOGIN'), + $this->getWebClient()->setAuth(Class_AdminVar::get('ARTE_VOD_LOGIN'), Class_AdminVar::get('ARTE_VOD_KEY')); return $this->getWebClient()->open_url($url); } @@ -168,7 +76,14 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu return new Class_WebService_BibNumerique_ArteVOD_FilmReader(); } - + + protected function _deleteNonHarvested() { + if (0 < count($this->getHarvestedIds())) + Class_Album::getLoader() + ->deleteBy(['where' => 'url_origine="'.self::BASE_URL.'" and id_origine not in (\'' . implode("', '", $this->getHarvestedIds()) . '\')']); + } + + public function getBaseUrl() { return self::BASE_URL; } diff --git a/library/Class/WebService/BibNumerique/ArteVOD/Film.php b/library/Class/WebService/BibNumerique/ArteVOD/Film.php index e1e32fd04d38cd96cd73d70c518b28cd96aa910b..ff05e37c4b8d46c1d2eebab31a5e0874bce1c51b 100644 --- a/library/Class/WebService/BibNumerique/ArteVOD/Film.php +++ b/library/Class/WebService/BibNumerique/ArteVOD/Film.php @@ -39,9 +39,6 @@ class Class_WebService_BibNumerique_ArteVOD_Film extends Class_WebService_BibNu ->setDuration($this->duration.' min') ->setTags($this->getTags()); - foreach ($this->getAuthors() as $author) - $album->addAuthor($author); - foreach ($this->getActors() as $actor) $album->addAuthor(trim($actor->last_name . ' ' . $actor->first_name), '005'); diff --git a/library/Class/WebService/BibNumerique/Cyberlibris/LivreNumerique.php b/library/Class/WebService/BibNumerique/Cyberlibris/LivreNumerique.php index 152aceeaa4acca1cc383e7128f6207dee883130d..d50442c8a68055d6e39dda351450991effacc89d 100644 --- a/library/Class/WebService/BibNumerique/Cyberlibris/LivreNumerique.php +++ b/library/Class/WebService/BibNumerique/Cyberlibris/LivreNumerique.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 */ @@ -34,8 +34,7 @@ class Class_WebService_BibNumerique_Cyberlibris_LivreNumerique extends Class_Web $album->beCyberlibris() ->setDescription($this->getDescription()) ->setEditeur($this->getEditeur()); - foreach($this->getAuthors() as $author) - $album->addAuthor($author); + return $album; } diff --git a/library/Class/WebService/BibNumerique/Dilicom/Book.php b/library/Class/WebService/BibNumerique/Dilicom/Book.php index 2fea88928b13e14abc45fae8eabb364498024292..b6198c6d029b41c3cd2f2ab6380efe235f27a0c8 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/Book.php +++ b/library/Class/WebService/BibNumerique/Dilicom/Book.php @@ -35,7 +35,8 @@ class Class_WebService_BibNumerique_Dilicom_Book extends Class_WebService_BibNum ->setISBN($this->_isbn) ->setSousTitre($this->_subtitle) ->addEditor($this->getEditeur()) - ->setUsageConstraints($this->_usage_constraints); + ->setUsageConstraints($this->_usage_constraints) + ->addItem(new Class_Album_Item()); if ($this->_order_line_id) $album @@ -43,7 +44,6 @@ class Class_WebService_BibNumerique_Dilicom_Book extends Class_WebService_BibNum ->getLoanConstraint() ->setOrderLineId($this->_order_line_id); - array_map([$album, 'addAuthor'], $this->getAuthors()); array_map([$album, 'addCollection'], $this->_collections); } diff --git a/library/Class/WebService/BibNumerique/Dilicom/Hub.php b/library/Class/WebService/BibNumerique/Dilicom/Hub.php index 80a29eeff9b7232c5a8722948112af195f16f142..8d2b23fd88947114428e57feb535685aef56bf1d 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/Hub.php +++ b/library/Class/WebService/BibNumerique/Dilicom/Hub.php @@ -21,16 +21,104 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstract { - use Trait_TimeSource; + use + Trait_TimeSource, + Trait_Translator; - public function consultBook($album, $ip_address) { - $order_line_id = $album->getUsageConstraints()->getLoanOrderLineId(); + protected $_now; + + + public function getLoanStatus($album) { + $content = json_decode($this->dilicomCall('getLoanStatus', + ['orderLineId[0]' => $this->getOrderLineId($album)])); + + return $content; + } + + + public function endLoanBook($loan) { + $content = json_decode($this->dilicomCall('endLoan', + ['orderLineId' => $loan->getOrderLineId(), + 'loanId' => $loan->getId()])); + + if(!$content->returnMessage) + $loan->setOngoing(false) + ->save(); + + return $content; + } + + + public function updateStatus($album) { + $content = (new Class_WebService_BibNumerique_Dilicom_Hub())->getLoanStatus($album); + + if (isset($content->loanResponseLine[0]) && ($simultaneous_users_remaining = $content->loanResponseLine[0]->nus1)) { + $item = $album->getItems()[0]; + $item->setLoanCount($album->getUsageConstraints()->getLoanMaxNumberOfUsers() - $simultaneous_users_remaining); + $item->setQuantity($album->getUsageConstraints()->getLoanQuantity() - $content->loanResponseLine[0]->nta); + } + + return $content; + } + + + public function loanBook($album) { + $user = Class_Users::getIdentity(); + $this->_now = $this->getCurrentTime(); + + $loan = Class_Loan_Pnb::findFirstBy(['user_id' => $user->getId(), + 'ongoing' => true, + 'record_origin_id' => $album->getIdOrigine()]); + + if($loan && ($this->iso8601(strtotime($loan->getExpectedReturnDate())) > $this->startDate())) + return (object) ['link' => (object) ['url' => $loan->getLoanLink()], + 'returnMessage' => []]; + + if(!$album->getUsageConstraints()->hasSimultaneousLoanRemaining()) + return (object) ['returnMessage' => [$this->_('Emprunt impossible. Le nombre d\'emprunts simultanés est atteint.')]]; + + if(!$album->getUsageConstraints()->hasAvailableQuantity()) + return (object) ['returnMessage' => [$this->_('Emprunt impossible. Le nombre d\'emprunts disponible est épuisé.')]]; + + if(!$album->getUsageConstraints()->isAValidOffer()) + return (object) ['returnMessage' => [$this->_('Emprunt impossible. L\'emprunt du document n\'est plus disponible.')]]; + + $loan = Class_Loan_Pnb::newInstance(['subscriber_id' => $user->getIdabon(), + 'user_id' => $user->getId(), + 'ongoing' => true, + 'loan_date' => $this->startDate(), + 'expected_return_date' => $this->endDate(), + 'record_origin_id' => $album->getIdOrigine()]); + $loan->save(); + + $response = $this->dilicomCall('loanBook', + ['orderLineId' => $this->getOrderLineId($album), + 'accessMedium' => 'DOWNLOAD', + 'localization' => 'EX_SITU', + 'loanEndDate' => urlencode($this->endDate()), + 'ean13' => $album->getISBN(), + 'loanId' => $loan->getId(), + ]); + + $content = json_decode($response); + + $loan->setLoanLink($content->link->url)->save(); + + if($content->returnMessage) + $loan->delete(); + + return $content; + } + + + public function consultBook($album, $ip_address) { + $this->_now = $this->getCurrentTime(); return $this->dilicomCall('consultBook', - ['orderLineId' => $order_line_id, + ['orderLineId' => $this->getOrderLineId($album), 'accessMedium' => 'STREAMING', 'localization' => 'IN_SITU', - 'consultEndDate' => urlencode(date(DATE_ISO8601 ,$this->getCurrentTime() + 3600)), + 'consultEndDate' => urlencode($this->endDate()), 'ean13' => $album->getISBN(), 'ipAddress' => $ip_address, 'loanId' => implode('', @@ -46,6 +134,26 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac } + public function getOrderLineId($album) { + return $album->getUsageConstraints()->getLoanOrderLineId(); + } + + + public function endDate() { + return $this->iso8601($this->_now + 3600); + } + + + public function startDate() { + return $this->iso8601($this->_now); + } + + + protected function iso8601($timestamp) { + return date(DATE_ISO8601, $timestamp); + } + + protected function dilicomCall($service, $params) { static::getHttpClient()->setAuth(Class_AdminVar::get('DILICOM_PNB_GLN_COLLECTIVITE'), Class_AdminVar::get('DILICOM_PNB_PWD_COLLECTIVITE')); diff --git a/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php b/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php index fc6d268b8ee6b651c93af64f28e481a7618edd22..cea4b3c75538d2391bfffb56c089097bc9a9156e 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php +++ b/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php @@ -212,6 +212,7 @@ class Class_WebService_BibNumerique_Dilicom_ONIXFile { public function endEPubUsageLimit() { if ($this->_current_usage_unit == self::USAGE_UNIT_DAYS) { $this->_current_usage_constraint->setDuration($this->_current_quantity); + $this->_current_usage_constraint->setEndDate(); return; } diff --git a/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php b/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php index d6b90910d6adc7b61529438d3bfddf2a3f56637a..df077f41575d62ad482ae33c49840fac37a43e6c 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php +++ b/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php @@ -57,6 +57,7 @@ class Class_WebService_BibNumerique_Dilicom_PNBOffersFile { end($this->_books)->setOrderLineId($data); } + public function endean13($data) { end($this->_books)->setISBN($data); } diff --git a/library/Class/WebService/BibNumerique/Jamendo.php b/library/Class/WebService/BibNumerique/Jamendo.php new file mode 100644 index 0000000000000000000000000000000000000000..548a52f5ae73d8db1b6168dabffe5334281e7bae --- /dev/null +++ b/library/Class/WebService/BibNumerique/Jamendo.php @@ -0,0 +1,127 @@ +<?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_BibNumerique_Jamendo extends Class_WebService_BibNumerique_Abstract { + protected + $_page_count=0, + $_total_count=0, + $_page_number=0, + $_jamendo_albums; + + public function getPageCount() { + return $this->_page_count; + } + + + public function getTotalCount() { + return $this->_total_count; + } + + + public function getPageNumber() { + return $this->_page_number; + } + + + public function getRessourcesNumeriques() { + return $this->_jamendo_albums; + } + + + public function isEnabled() { + return Class_AdminVar::isJamendoEnabled(); + } + + + public function getName() { + return 'Jamendo'; + } + + + protected function _deleteNonHarvested() { + return $this; + } + + + protected function jamendoGet($params, $action='tracks') { + $default_params = ['format' => 'json', + 'order' => 'id_desc', + 'limit' => '10', + 'client_id' => Class_AdminVar::get('JAMENDO_CLIENT_ID')]; + $url = + 'https://api.jamendo.com/v3.0/albums/' + .$action + .'?' + .http_build_query(array_merge($default_params, $params)); + return json_decode($this->httpGet($url)); + } + + + protected function loadPage($page_number = 1) { + $json = $this->jamendoGet(['offset' => ($page_number-1)*10]); + + if (!isset($json->results[0])) + return null; + + $this->_page_number = $page_number; + $this->_total_count = $json->results[0]->id; + $this->_page_count = (int)ceil($this->_total_count/10); + + $this->_jamendo_albums = []; + foreach($json->results as $result) { + $this->_jamendo_albums []= new Class_WebService_BibNumerique_Jamendo_Album($result, $this); + } + return $this; + } + + + public function harvest() { + $jamendo_type_doc = Class_TypeDoc::find(Class_TypeDoc::JAMENDO); + if ($jamendo_type_doc->getFamilleId() !== Class_CodifTypeDoc::SONORE) + $jamendo_type_doc->setFamilleId(Class_CodifTypeDoc::SONORE)->save(); + + parent::harvest(); + } + + + public function importFromUrl($url) { + if (!preg_match('/www.jamendo.com.*\/a([0-9]+)\//', $url, $matches)) + return null; + + $album_id = $matches[1]; + $json = $this->jamendoGet(['id' => $album_id]); + $album = new Class_WebService_BibNumerique_Jamendo_Album($json->results[0], $this); + return $album->import(); + } + + + public function updateMusicInfos($album) { + if (!$json = $this->jamendoGet(['id' => $album->getIdOrigine()], 'musicinfo')) + return; + + $infos = $json->results[0]->musicinfo; + $album + ->setDescription($infos->description->fr) + ->setTags(implode(';', $infos->tags)); + } +} + +?> \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/Jamendo/Album.php b/library/Class/WebService/BibNumerique/Jamendo/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..6d330efba2440524423cc0cb77b99d60f6dc91c1 --- /dev/null +++ b/library/Class/WebService/BibNumerique/Jamendo/Album.php @@ -0,0 +1,79 @@ +<?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_BibNumerique_Jamendo_Album extends Class_WebService_BibNumerique_RessourceNumerique { + protected $_connector; + + public function __construct($json, $connector = null) { + if (!$connector) + $connector = new Class_WebService_BibNumerique_Jamendo(); + + $this->_connector = $connector; + + $this + ->setId($json->id) + ->setTitle($json->name) + ->setYear(explode('-', $json->releasedate)[0]) + ->addAuthor($json->artist_name) + ->addPoster($json->image); + + + $tracks = []; + foreach($json->tracks as $track) { + $ressource = new Class_AlbumRessource(); + $ressource + ->setMediaType(Class_AlbumRessource::MEDIA_TYPE_URL) + ->setTitre($track->name) + ->setUrl($track->audio) + ->setDuration($track->duration) + ->setLicense($this->parseLicense($track->license_ccurl)); + $tracks []= $ressource; + } + $this->setRessources($tracks); + } + + + protected function parseLicense($url) { + return strtoupper( + implode('/', + array_filter(explode('/', + str_replace('http://creativecommons.org/licenses/', '', $url))))); + } + + protected function getTypeDoc() { + return Class_TypeDoc::JAMENDO; + } + + + public function fillAlbum($album) { + $this->_connector->updateMusicInfos($album); + $album->setTypeDocId(Class_TypeDoc::JAMENDO); + } + + + public function getRessourceCategorieLibelle(){ + return 'Jamendo'; + } + +} + +?> \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/NumeriquePremium/Publication.php b/library/Class/WebService/BibNumerique/NumeriquePremium/Publication.php index 52dfc63b96167df00640fe6e5e83bb7de3448c0b..b0dfe55886f54a19a09505827ac43e7890872381 100644 --- a/library/Class/WebService/BibNumerique/NumeriquePremium/Publication.php +++ b/library/Class/WebService/BibNumerique/NumeriquePremium/Publication.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 */ @@ -27,9 +27,6 @@ class Class_WebService_BibNumerique_NumeriquePremium_Publication extends Class_W ->beNumeriquePremium() ->setEditeur($this->getEditeur()); - foreach ($this->getAuthors() as $author) - $album->addAuthor($author); - return $album; } diff --git a/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php b/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php index 0bfbed4686008d352b52732d7e22b1e9f773cbf0..50777a09a9d066600b30c2c2c573115f793e5c15 100644 --- a/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.php +++ b/library/Class/WebService/BibNumerique/Numilog/LivreNumerique.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_BibNumerique_Numilog_LivreNumerique extends Class_WebService_BibNumerique_RessourceNumerique { @@ -33,8 +33,7 @@ class Class_WebService_BibNumerique_Numilog_LivreNumerique extends Class_WebServ $album->beNumilog() ->setDescription($this->getDescription()) ->setEditeur($this->getEditeur()); - foreach($this->getAuthors() as $author) - $album->addAuthor($author); + $this->addPoster('http://couverture.numilog.com/' . $this->_id.'_GRANDE.jpg'); return $album; } @@ -42,7 +41,7 @@ class Class_WebService_BibNumerique_Numilog_LivreNumerique extends Class_WebServ public function getRessourceCategorieLibelle() { return Class_WebService_BibNumerique_Numilog::CATEGORY_LABEL; - } + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/OneDTouch/Album.php b/library/Class/WebService/BibNumerique/OneDTouch/Album.php index a2d90c25bada7d4497b334f05c706b414d0755ec..695bab657a38b5f115ed0aa343bd2c5a9fcad397 100644 --- a/library/Class/WebService/BibNumerique/OneDTouch/Album.php +++ b/library/Class/WebService/BibNumerique/OneDTouch/Album.php @@ -31,8 +31,7 @@ class Class_WebService_BibNumerique_OneDTouch_Album extends Class_WebService_Bib $album->beOneDTouch() ->setDescription($this->getDescription()) ->setEditeur($this->getEditeur()); - foreach($this->getAuthors() as $author) - $album->addAuthor($author); + return $album; } diff --git a/library/Class/WebService/BibNumerique/Orphea/MetaDatasParser.php b/library/Class/WebService/BibNumerique/Orphea/MetaDatasParser.php index 87ccc40cecf499779dbc4103d24a3360e3424080..56d3596e68ee986ad7fc2795c2c7b404a3e63a42 100644 --- a/library/Class/WebService/BibNumerique/Orphea/MetaDatasParser.php +++ b/library/Class/WebService/BibNumerique/Orphea/MetaDatasParser.php @@ -52,7 +52,7 @@ class Class_WebService_BibNumerique_Orphea_MetaDatasParser { public function endByline($data) { - $this->_ressource->setAuthors($data); + $this->_ressource->addAuthor($data); } diff --git a/library/Class/WebService/BibNumerique/Orphea/Ressource.php b/library/Class/WebService/BibNumerique/Orphea/Ressource.php index 9f289d2ce6f22f1f1329c32214ba3fef96714198..3a5c49ce7e062d8c175df0d1055d2cbcf2a47a38 100644 --- a/library/Class/WebService/BibNumerique/Orphea/Ressource.php +++ b/library/Class/WebService/BibNumerique/Orphea/Ressource.php @@ -23,7 +23,6 @@ class Class_WebService_BibNumerique_Orphea_Ressource extends Class_WebService_BibNumerique_RessourceNumerique { protected $_id, $_rights, - $_authors, $_province_state, $_editors, $_genres, @@ -35,7 +34,6 @@ class Class_WebService_BibNumerique_Orphea_Ressource extends Class_WebService_Bi $album->setGenre(implode(';', $this->_genres)) ->addEditor($this->_editors) ->setProvenance($this->_province_state) - ->addAuthor($this->_authors) ->setDroits($this->_rights) ->setRessources($this->_ressources) ->beOrphea(); @@ -54,12 +52,6 @@ class Class_WebService_BibNumerique_Orphea_Ressource extends Class_WebService_Bi } - public function setAuthors($authors) { - $this->_authors = $authors; - return $this; - } - - public function setProvinceState($data) { $this->_province_state = $data; return $this; diff --git a/library/Class/WebService/BibNumerique/RessourceNumerique.php b/library/Class/WebService/BibNumerique/RessourceNumerique.php index f0ba15537aa471e342b96094a9f4179250d2378b..ec2f1b8bf64465362127598a5856fa072b2a9e29 100644 --- a/library/Class/WebService/BibNumerique/RessourceNumerique.php +++ b/library/Class/WebService/BibNumerique/RessourceNumerique.php @@ -254,6 +254,8 @@ class Class_WebService_BibNumerique_RessourceNumerique { ->setRessources($this->getRessources()) ->setStatus(Class_Album::STATUS_VALIDATED); + array_map([$album, 'addAuthor'], $this->getAuthors()); + $this->importMatieres($album); $this->fillAlbum($album); diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php index 3a34374ea0f7eb0b9274326fc590dc307b6d4689..f1a85586b301ab4fddcbacdbd6afd283c6c13be5 100644 --- a/library/Class/WebService/SIGB/AbstractService.php +++ b/library/Class/WebService/SIGB/AbstractService.php @@ -62,6 +62,8 @@ abstract class Class_WebService_SIGB_AbstractService { abstract public function getEmprunteur($user); + abstract public function getUserAnnexe($user); + abstract public function reserverExemplaire($user, $exemplaire, $code_annexe); diff --git a/library/Class/WebService/SIGB/BiblixNet/Service.php b/library/Class/WebService/SIGB/BiblixNet/Service.php index 540cbe20c348890cec7428e6fe603980c0ebcfbe..d3177ea2946e85f96261ea66fa6842f7ffae9ecc 100644 --- a/library/Class/WebService/SIGB/BiblixNet/Service.php +++ b/library/Class/WebService/SIGB/BiblixNet/Service.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_SIGB_BiblixNet_Service extends Class_WebService_SIGB_AbstractRESTService { @@ -49,6 +49,11 @@ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_Abst } + public function getUserAnnexe($user) { + return null; + } + + /** * @param Class_Users $user * @param int $notice_id @@ -89,13 +94,13 @@ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_Abst 'code'); } - + /** * @param string $id * @return Class_WebService_SIGB_Notice */ public function getNotice($id) { - return $this->ilsdiGetRecords($id, + return $this->ilsdiGetRecords($id, Class_WebService_SIGB_BiblixNet_GetRecordsResponseReader::newInstance()); } diff --git a/library/Class/WebService/SIGB/Carthame/Service.php b/library/Class/WebService/SIGB/Carthame/Service.php index 09e68594fbd5f9780b1ac25de6f6bf7d216ddd04..4114b98ca2323538fa6020d78bc16bfc133b4cce 100644 --- a/library/Class/WebService/SIGB/Carthame/Service.php +++ b/library/Class/WebService/SIGB/Carthame/Service.php @@ -118,6 +118,11 @@ class Class_WebService_SIGB_Carthame_Service extends Class_WebService_SIGB_Abstr } + public function getUserAnnexe($user) { + return null; + } + + /** * @param Class_Users $user * @param Class_Exemplaire exemplaire diff --git a/library/Class/WebService/SIGB/Dynix/Service.php b/library/Class/WebService/SIGB/Dynix/Service.php index 80bd597336393d4eacd4047ae5910c603820dd71..519b21a7b2bd6e8ed6a11b8079ed022c8c65e056 100644 --- a/library/Class/WebService/SIGB/Dynix/Service.php +++ b/library/Class/WebService/SIGB/Dynix/Service.php @@ -106,6 +106,11 @@ class Class_Webservice_SIGB_Dynix_Service extends Class_WebService_SIGB_Abstract } + public function getUserAnnexe($user) { + return null; + } + + public function reserverExemplaire($user, $exemplaire, $code_annexe){ if (!$sigb_exemplaire = $this->getExemplaire($exemplaire->getIdOrigine(), $exemplaire->getCodeBarres())) { diff --git a/library/Class/WebService/SIGB/Emprunt.php b/library/Class/WebService/SIGB/Emprunt.php index 3957c6c80bb126e20e5e5d3a457c0e5054e5c75e..933c5ee982a6deed1ddb0b5ee760e0452c0b5cf5 100644 --- a/library/Class/WebService/SIGB/Emprunt.php +++ b/library/Class/WebService/SIGB/Emprunt.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_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOperation { @@ -61,7 +61,7 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper if (!$date_retour = $this->getAttribute('retour')) $date_retour = $this->getAttribute('rendre'); - + return $this->setDateRetour($date_retour); } @@ -76,6 +76,16 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper return $this->enRetard; } + public function isLate() { + return $this->enRetard(); + } + + + public function isPNB() { + return false; + } + + /** * @param bool $enRetard */ @@ -83,7 +93,7 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper $this->enRetard = $enRetard; return $this; } - + /** * @param bool $renewable */ @@ -117,7 +127,7 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper return $this->type; } - + public function setType($type) { $this->type = $type; return $this; diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index 889ea7168795ecf555e89f2bead9a3529a83e5e8..ac93502a312a2580d774aadc0c46fd55a5beb92f 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -72,6 +72,11 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } + public function getUserAnnexe($user) { + return null; + } + + public function holdItem($user,$exemplaire,$code_annexe) { $itemnumber=$exemplaire->getSubfield(9); $args = ['patron_id' => $this->_authenticate($user), diff --git a/library/Class/WebService/SIGB/Microbib/Service.php b/library/Class/WebService/SIGB/Microbib/Service.php index 6624fe6e2c23a45845a288fae1357bb0166f8e35..cb6bb672545d54cc6742e35c6eec6f4249fd06a3 100644 --- a/library/Class/WebService/SIGB/Microbib/Service.php +++ b/library/Class/WebService/SIGB/Microbib/Service.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_SIGB_Microbib_Service extends Class_WebService_SIGB_AbstractService { @@ -49,6 +49,11 @@ class Class_WebService_SIGB_Microbib_Service extends Class_WebService_SIGB_Abstr } + public function getUserAnnexe($user) { + return null; + } + + public function reserverExemplaire($user, $exemplaire, $code_annexe) { $xml = $this->_search_client->ajout_reservation($user->getLogin(), $exemplaire->getCodeBarres()); return $this->_actionResponseFromXML($xml); @@ -73,7 +78,7 @@ class Class_WebService_SIGB_Microbib_Service extends Class_WebService_SIGB_Abstr if ($response == 'Ok') return array('statut' => true, 'erreur' => ''); - return array('statut' => false, 'erreur' => array_last(explode('_', $response))); + return array('statut' => false, 'erreur' => array_last(explode('_', $response))); } } diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index 38cc85b1fc9f966f9d97750735ad17e7119d531c..becd0a9da1d271c3e4ffb1cab7d3179a6d93f6d4 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -48,6 +48,11 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac } + public function getUserAnnexe($user) { + return $user->id_site; + } + + public function saveEmprunteur($emprunteur) { $xml = $this->getWebClient() ->postData($this->buildQueryURL(['service'=>'UpdatePatronInfo', diff --git a/library/Class/WebService/SIGB/Opsys/Service.php b/library/Class/WebService/SIGB/Opsys/Service.php index b8fcf5358256ecd437b6a5c2f67b01f14b1d26d9..c60379361eef51d782bdffa33661afbb634e985a 100644 --- a/library/Class/WebService/SIGB/Opsys/Service.php +++ b/library/Class/WebService/SIGB/Opsys/Service.php @@ -217,6 +217,9 @@ class Class_WebService_SIGB_Opsys_Service extends Class_WebService_SIGB_Abstract return $this->authentifierEmprunteur($user); } + public function getUserAnnexe($user) { + return null; + } /** * @param Class_Users $user diff --git a/library/Class/WebService/SIGB/Orphee/GetLstDmtResponseReader.php b/library/Class/WebService/SIGB/Orphee/GetLstDmtResponseReader.php index 457cdc82b417735f51081c14ab1d5aee5975d4ff..335cded0ae8d836008a4dde42575653bdba9f587 100644 --- a/library/Class/WebService/SIGB/Orphee/GetLstDmtResponseReader.php +++ b/library/Class/WebService/SIGB/Orphee/GetLstDmtResponseReader.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_SIGB_Orphee_GetLstDmtResponseReader extends Class_WebService_SIGB_AbstractXMLNoticeReader { @@ -26,17 +26,17 @@ class Class_WebService_SIGB_Orphee_GetLstDmtResponseReader extends Class_WebServ const CODE_SITUTATION_CATALOGAGE = 17; protected $_allow_hold_available_items; - + /** * @return Class_WebService_SIGB_Orphee_GetLstDmtResponseReader */ - public static function newInstance($allow_hold_available_items) { + public static function newInstance($allow_hold_available_items=null) { return new self($allow_hold_available_items); } public function __construct($allow_hold_available_items=null) { $this->_allow_hold_available_items = $allow_hold_available_items; - } + } public function startDocuments() { @@ -69,7 +69,7 @@ class Class_WebService_SIGB_Orphee_GetLstDmtResponseReader extends Class_WebServ $this->_current_exemplaire->setDisponibilite(trim($data)); } - + public function endSit($data) { $reservable = ($data==self::CODE_SITUTATION_SORTI || $data==self::CODE_SITUTATION_RESERVE); $this->_current_exemplaire->setReservable($reservable); diff --git a/library/Class/WebService/SIGB/Orphee/Service.php b/library/Class/WebService/SIGB/Orphee/Service.php index 7c049e9f576777e71a9e67dc627d5118521fc5ad..eff4c98be848fe21d726da5c7488bbc9f1288cdd 100644 --- a/library/Class/WebService/SIGB/Orphee/Service.php +++ b/library/Class/WebService/SIGB/Orphee/Service.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_SIGB_Orphee_Service extends Class_WebService_SIGB_AbstractService { @@ -73,7 +73,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac return $this->_search_client; try { - $this->_search_client = new Class_WebService_MappedSoapClient($this->_wsdl, + $this->_search_client = new Class_WebService_MappedSoapClient($this->_wsdl, $this->_soap_options); } catch (SoapFault $e) { } @@ -91,7 +91,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function getSessionStrategy() { if (null === $this->_session_strategy) { - $this->_session_strategy = Class_WebService_SIGB_Orphee_SessionStrategy::newFrom($this->getSearchClient(), + $this->_session_strategy = Class_WebService_SIGB_Orphee_SessionStrategy::newFrom($this->getSearchClient(), $this->_key); $this->_session_strategy->connect(); } @@ -104,7 +104,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac return $this->getSessionStrategy()->isConnected(); } catch(Exception $e) { } - return false; + return false; } @@ -120,7 +120,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function getEmprunteur($user) { return $this->willTry( function() use ($user) { - if (!$this->isConnected()) + if (!$this->isConnected()) return $this->newNullEmprunteur(); $result = ($this->hasGetAdh()) ? @@ -135,6 +135,10 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac }); } + public function getUserAnnexe($user) { + return null; + } + protected function hasGetAdh() { return $this->_search_client->hasFunction('GetAdh'); @@ -147,7 +151,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac ->empruntsAddAll([]); } - + /** @return array */ public function getReservationsOf($emprunteur) { return $this->willTry( @@ -161,7 +165,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac }); } - + /** @return array */ public function getEmpruntsOf($emprunteur) { return $this->willTry( @@ -186,7 +190,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac try { $result = $serviceClosure($id, $emprunteur); } catch (SoapFault $e) { - return ['statut' => false, + return ['statut' => false, 'erreur' => 'Le SIGB Orphée a retourné l\'erreur suivante: '.$e->getMessage()]; } @@ -198,13 +202,13 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function reserverExemplaire($user, $exemplaire, $code_annexe) { $notice_id = $this->removeOrpheeNoticePrefix($exemplaire->getIdOrigine()); - - $tome = $exemplaire->isPeriodique() + + $tome = $exemplaire->isPeriodique() ? $exemplaire->getSubfield('u') : 0; return $this->withUserDo( - $user, $notice_id, + $user, $notice_id, function ($id, $emprunteur) use ($code_annexe, $tome) { if ($this->hasSetAdhDispoAnx()) $this->getSearchClient() @@ -226,7 +230,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function supprimerReservation($user, $notice_id) { return $this->withUserDo( - $user, $notice_id, + $user, $notice_id, function ($id, $emprunteur) { return $this->getSearchClient() ->DelRsv(DelRsv::withNoticeUserNo($id, $emprunteur->getId())); @@ -239,7 +243,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function prolongerPret($user, $document_id) { return $this->withUserDo( - $user, $document_id, + $user, $document_id, function ($id, $emprunteur) { return $this->getSearchClient() ->ProlongePret(ProlongePret::withDocumentUser($id, $emprunteur->getId())); @@ -253,7 +257,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac public function getExemplaire($notice_id, $code_barre){ - if (!$this->isConnected() + if (!$this->isConnected() || (!$item = Class_Exemplaire::findFirstBy(['code_barres' => $code_barre])) || (!$notice = $item->getNotice())) return new Class_WebService_SIGB_Exemplaire(null); @@ -266,15 +270,15 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac $notice = Class_WebService_SIGB_Orphee_GetLstDmtResponseReader::newInstance($this->_allow_hold_available_items) ->getNoticeFromXML($xml); - return !isset($notice) + return !isset($notice) || (null == ($exemplaire = $notice->getExemplaireByCodeBarre($code_barre))) ? new Class_WebService_SIGB_Exemplaire(null) : $exemplaire; } - /** + /** * @deprecated - * @see getExemplaire + * @see getExemplaire */ public function getNotice($id) { return new Class_WebService_SIGB_Notice($id); @@ -295,13 +299,15 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac class Class_WebService_SIGB_Orphee_XMLFilter { public static function filter($xml) { $xml = trim($xml); + + // New Orphee version fixes CDATA escaping of XML response (see http://forge.afi-sa.fr/issues/23734 ) + if (0 !== strpos($xml, '<![CDATA')) + return $xml; + $xml = preg_replace('/<!\[CDATA\[+/', '', $xml); $xml = preg_replace('/\]+>+/', '', $xml); return $xml; - if (substr($xml, 0, 9)== '<![CDATA[') - return substr($xml, 9, -3); - } } diff --git a/library/Class/WebService/SIGB/Pergame/Service.php b/library/Class/WebService/SIGB/Pergame/Service.php index 40fadf007a975a19b0076983c912a8c4e6e47e7a..b0e927fe225001896b8f263ae0a4da4c8a773b9f 100644 --- a/library/Class/WebService/SIGB/Pergame/Service.php +++ b/library/Class/WebService/SIGB/Pergame/Service.php @@ -63,6 +63,11 @@ class Class_WebService_SIGB_Pergame_Service extends Class_WebService_SIGB_Abstra } + public function getUserAnnexe($user) { + return $user->getIdSite(); + } + + public function getEmpruntsOf($emprunteur) { $params = Class_IntBib::find($this->_id_bib)->getCommParamsAsArray(); $renouvelable = isset($params['Autoriser_prolongations']) ? $params['Autoriser_prolongations'] : false; diff --git a/library/Class/WebService/SIGB/VSmart/Service.php b/library/Class/WebService/SIGB/VSmart/Service.php index c21f6d7e1b165c902986186db3e8d78ad9a46ede..1f716d503f900c290bb056eb3fceccd58eb50b51 100644 --- a/library/Class/WebService/SIGB/VSmart/Service.php +++ b/library/Class/WebService/SIGB/VSmart/Service.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_SIGB_VSmart_Service extends Class_WebService_SIGB_AbstractRESTService { @@ -136,6 +136,10 @@ class Class_WebService_SIGB_VSmart_Service extends Class_WebService_SIGB_Abstrac ->setPassword($user->getPassword()); } + public function getUserAnnexe($user) { + return null; + } + /** * @param string $id diff --git a/library/Class/WebService/Vignette.php b/library/Class/WebService/Vignette.php index 93ca6a458bc7c117bad284b819f36d3eca041074..abca3011ce1c08f63177a1e1561e16e92140cde3 100644 --- a/library/Class/WebService/Vignette.php +++ b/library/Class/WebService/Vignette.php @@ -63,7 +63,12 @@ class Class_WebService_Vignette extends Class_WebService_Abstract { public static function getAjaxUrl($notice) { $clef_controle = Class_WebService_Vignette::getClefControle(); - return BASE_URL."/recherche/vignette?clef=".$clef_controle."&id_notice=".$notice->getId(); + return Class_Url::assemble(['controller' => 'recherche', + 'action' => 'vignette', + 'clef' => $clef_controle, + 'id_notice' => $notice->getId()], + null, + true); } //------------------------------------------------------------------------------------------------------ @@ -306,7 +311,6 @@ class Class_WebService_Thumbnail_Provider_Site extends Class_WebService_Thumbnai if (!$site=$notice->getSite()) return $this; $url = $site->getUrl(); - if (!$url_thumbnail = $webthumbnail->fetchFullUrl($url)) $url_thumbnail = 'NO'; diff --git a/library/Class/WebService/WebSiteThumbnail.php b/library/Class/WebService/WebSiteThumbnail.php index cdd1764c021e20a581d6bfe383d8037a05815aee..53f2166083b44254f9ebaaf6c9acea14c323570b 100644 --- a/library/Class/WebService/WebSiteThumbnail.php +++ b/library/Class/WebService/WebSiteThumbnail.php @@ -36,6 +36,14 @@ class Class_WebService_WebSiteThumbnail { } + public function getFilePath($url) { + $this->checkThumbsDir(); + + $filename = strtolower($this->fileNameFromUrl($url)); + return $this->fullPath($filename); + + } + public function getWebThumbnailURL($url) { $this->checkThumbsDir(); diff --git a/library/Class/Zone.php b/library/Class/Zone.php index 8e11ae508b359ee8a4071b82e8740b4053265035..f8d05c5ba57a4b4716c622e5483a87791be18bd4 100644 --- a/library/Class/Zone.php +++ b/library/Class/Zone.php @@ -16,10 +16,10 @@ * * 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 */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC 3 - Table Name +// OPAC 3 - Table Name // // @TODO@ : A nettoyer ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -28,24 +28,29 @@ class BibCZone extends Zend_Db_Table_Abstract protected $_name = 'bib_c_zone'; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC 3 - Class_Zone -> gestion des territoires +// OPAC 3 - Class_Zone -> gestion des territoires ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class Class_Zone extends Storm_Model_Abstract { private $sql; private $_dataBaseError = "Problème d'accès à  la base de données"; - private $statut_bib = array('Invisible','N\'envoie pas de données','Envoie des données'); + private $statut_bib = ['Invisible', + 'N\'envoie pas de données', + 'Envoie des données']; protected $_table_name = 'bib_c_zone'; protected $_table_primary = 'id_zone'; - protected $_has_many = array('bibs' => array( 'model' => 'Class_Bib', - 'role' => 'zone', - 'referenced_in' => 'ID_ZONE', - 'order' => 'libelle')); + protected $_has_many = ['bibs' => ['model' => 'Class_Bib', + 'role' => 'zone', + 'referenced_in' => 'ID_ZONE', + 'order' => 'libelle']]; - protected $_default_attribute_values = array('libelle' => '', - 'couleur' => '', - 'map_coords' => '', - 'image' => ''); + protected $_default_attribute_values = ['libelle' => '', + 'couleur' => '#fff', + 'map_coords' => '', + 'couleur_texte' => '#fff', + 'couleur_ombre' => '#000', + 'taille_fonte' => '12', + 'image' => '']; @@ -53,7 +58,7 @@ class Class_Zone extends Storm_Model_Abstract { return self::getLoaderFor(__CLASS__); } - + public function __construct() { $this->sql = Zend_Registry::get('sql'); } @@ -71,7 +76,7 @@ class Class_Zone extends Storm_Model_Abstract { public function setCouleur($couleur) { - if (substr($couleur,0,1)!="#") + if (substr($couleur,0,1)!="#") $couleur="#".$couleur; parent::_set('couleur', $couleur); return $this; @@ -88,7 +93,7 @@ class Class_Zone extends Storm_Model_Abstract { $data=fetchAll("select * from bib_c_zone ".$where. " order by LIBELLE"); return $data; } - + // Lire tous les territoires == OLD FUNCTION ======= public function getAllZone() { @@ -100,7 +105,7 @@ class Class_Zone extends Storm_Model_Abstract { return $this->_dataBaseError; } } - + public function getZoneById($id_zone) { try{ @@ -124,7 +129,7 @@ class Class_Zone extends Storm_Model_Abstract { return $img_infos; } - + public function getImageWithInfos($image = null) { if (!$image) $image = $this->getImage(); $img = "/userfiles/photobib/".$image; @@ -139,8 +144,8 @@ class Class_Zone extends Storm_Model_Abstract { $ret["url"]=BASE_URL.$img; return $ret; } - - + + // Rend un select avec la liste des zones pour la page d'accueil public function getComboZoneAvecUrl($id_selected =0) { @@ -159,7 +164,7 @@ class Class_Zone extends Storm_Model_Abstract { } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // méthode ADMIN + // méthode ADMIN ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Insert zone @@ -168,7 +173,7 @@ class Class_Zone extends Storm_Model_Abstract { { $id_zone=sqlInsert("bib_c_zone",$data); } - + //--------------------------------------------------------------------- // Update zone //--------------------------------------------------------------------- @@ -181,12 +186,12 @@ class Class_Zone extends Storm_Model_Abstract { $adresse_img=getcwd()."/userfiles/photobib/".$old_img; if(file_exists($adresse_img)) unlink($adresse_img); } - + // Ecriture sqlUpdate("update bib_c_zone set @SET@ where ID_ZONE=$id_zone",$data); } - + //--------------------------------------------------------------------- // supprimer zone //--------------------------------------------------------------------- @@ -217,7 +222,7 @@ class Class_Zone extends Storm_Model_Abstract { $html[]='</select>'; return implode('',$html); } - + //--------------------------------------------------------------------- // Vérification de saisie //--------------------------------------------------------------------- diff --git a/library/Trait/Facetable.php b/library/Trait/Facetable.php new file mode 100644 index 0000000000000000000000000000000000000000..47ce9562f167edfa7ce355b81dda901b034bb56c --- /dev/null +++ b/library/Trait/Facetable.php @@ -0,0 +1,28 @@ +<?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 + */ + + +trait Trait_Facetable { + /** @return string */ + public function asFacet() { + return static::CODE_FACETTE . $this->getId(); + } +} \ No newline at end of file diff --git a/library/Trait/Indexable.php b/library/Trait/Indexable.php index cbd2bf6b39f14159115e6efb15240700df016632..5663aed85ffaed3ac04e4d49af9941939afcdda3 100644 --- a/library/Trait/Indexable.php +++ b/library/Trait/Indexable.php @@ -44,13 +44,18 @@ trait Trait_Indexable { Class_NoticeDomain::deleteBy(['record_alpha_key' => $alpha_key, 'domain_id' => $to_delete]); - foreach(array_diff($domains_ids, $existing_ids) as $domain_id) { + $to_create = array_diff($domains_ids, $existing_ids); + + foreach($to_create as $domain_id) { $notice_domain = Class_NoticeDomain::newInstance(['domain_id' => $domain_id, 'record_alpha_key' => $alpha_key]); - $notice_domain->save(); $notice_domain->updateFacette(); + $notice_domain->save(); } + foreach(Class_NoticeDomain::findAllBy(['record_alpha_key' => $alpha_key]) as $notice_domain) + $notice_domain->updateFacette(); + return $this; } diff --git a/library/Trait/NoticeVisitor.php b/library/Trait/NoticeVisitor.php index 443126b9a74840f84038bf7fa06b1c8f309a8a94..596ec40663e4ba19f1db3a07af170ea27a4c4edd 100644 --- a/library/Trait/NoticeVisitor.php +++ b/library/Trait/NoticeVisitor.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_NoticeVisitor { public function visitClefAlpha($clef) {} @@ -38,6 +38,11 @@ trait Trait_NoticeVisitor { public function visitEan($ean) {} public function visitAlbum($album) {} public function visitSource($source) {} + public function visitPermalink($url) {} + public function visitSerialTitle($title) {} + public function visitVolume($volume) {} + public function visitCollections($collections) {} + public function visitGenres($genres) {} } ?> \ No newline at end of file diff --git a/library/Trait/SearchCriteriaVisitor.php b/library/Trait/SearchCriteriaVisitor.php new file mode 100644 index 0000000000000000000000000000000000000000..d1b60c4d03c3d2fe7d97a79d6b0098117f6e5c1f --- /dev/null +++ b/library/Trait/SearchCriteriaVisitor.php @@ -0,0 +1,47 @@ +<?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 + */ + + +trait Trait_SearchCriteriaVisitor { + public function visitClesNotices($notices) {} + public function visitDomain($criteria) {} + public function visitCoteDebutFin($start, $end) {} + public function visitNouveaute($months_delay) {} + public function visitAnneeDebutFin($start, $end) {} + public function visitFacetteDomainForOrConditions($catalog_id) {} + public function visitFilterOnDomain($criteria) {} + public function visitSerie($serial, $order) {} + public function visitCodeRebond($code) {} + public function visitRubrique($rubrique, $fil) {} + public function visitExpression($expression, $pertinence, $order) {} + public function visitTextInput($name, $operator, $type, $value, $pertinence) {} + public function visitTypeDoc($type) {} + public function visitSection($section) {} + public function visitAnnexe($annexe) {} + public function visitDigitalLib($flag) {} + public function visitPage($page) {} + public function visitTri($order, $label) {} + public function visitFacette($facette) {} + public function visitFiltre($filtre) {} + public function visitNoExtension($no_extension) {} + public function hasErreur() { return false; } + public function setErreur($error) {} +} \ No newline at end of file diff --git a/library/Trait/TimeSource.php b/library/Trait/TimeSource.php index e4be4f6aa7de04bc1ef4ab362880a61f444c6a87..93637558e061449d967bfc2440c2778de33e028f 100644 --- a/library/Trait/TimeSource.php +++ b/library/Trait/TimeSource.php @@ -42,6 +42,10 @@ trait Trait_TimeSource { return date('Y-m-d',self::getTimeSource()->time()); } + public static function getCurrentDateTime() { + return date('Y-m-d H:i:s',self::getTimeSource()->time()); + } + /** @return Class_TimeSource */ public static function getTimeSource() { diff --git a/library/ZendAfi/Controller/Action/Helper/AbstractListViewMode.php b/library/ZendAfi/Controller/Action/Helper/AbstractListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..4ea49989108ae284c066d0e44e6a958804e5e02c --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/AbstractListViewMode.php @@ -0,0 +1,264 @@ +<?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 ZendAfi_Controller_Action_Helper_AbstractListViewMode extends Zend_Controller_Action_Helper_Abstract { + protected + $_params, + $_items_paginator, + $_breadcrumb, + $_items_by_page = 25; + + public function isSearchEnabled() { + return true; + } + + + public function isCountEnabled() { + return true; + } + + + public function getBaseUrl() { + return []; + } + + + public function getSearchUrl() { + return $this->getBaseUrl() + ['title_search' => '']; + } + + + public function getBreadcrumbUrl() { + return $this->getBaseUrl(); + } + + + public function getParamKey() { + return 'id'; + } + + + public function getUrlParams($model) { + return array_merge($this->getStartParams(), + $this->getBaseUrl(), + [$this->getParamKey() => $model->getId()]); + } + + + protected function getStartParams() { + return ($start = $this->getRequestParam($this->getStartKey())) ? + [$this->getStartKey() => $start] : []; + } + + + public function getStartKey() { + return 'start_cat'; + } + + + public function getCategories() { + return []; + } + + + public function getCategoriesAttribs() { + return [$this->getCategoriesLabelAttrib()]; + } + + + public function getCategoriesGroupBy() { + return null; + } + + + public function getItems() { + return []; + } + + + protected function getItemsParams() { + $default_params = ['limitPage' => [$this->getPage(), $this->_items_by_page]]; + + $params = $this->getSearchValue() + ? $this->getSearchParams() + : [$this->getParamKey() => $this->getModelId()]; + + return array_merge($params, $default_params); + } + + + public function getCountSearchResult() { + return 0; + } + + + protected function getSearchParams() { + return ['where' => 'titre like ' . Zend_Db_Table::getDefaultAdapter()->quote('%' . $this->getSearch() . '%') , + 'order' => 'titre']; + } + + + public function getBreadcrumb() { + return $this->getSearchValue() ? + [] : + $this->getBreadcrumbFor($this->getModel(), [], $this->getStartKey()); + } + + + /** + * @param $model user of Trait_TreeNode + * @param $breadcrumb array + * @param $start_key string + * @return array + */ + public function getBreadcrumbFor($model, $breadcrumb=[], $start_key='') { + if (!$model) + return $breadcrumb; + + if (!$this->_shouldCheckParent($start_key, $model) + && $parent = $model->getParent()) + $breadcrumb = $this->getBreadcrumbFor($parent, $breadcrumb, $start_key); + + $breadcrumb[] = ['url' => array_merge($this->getStartParams(), + $this->getBreadcrumbUrl(), + [$this->getParamKey() => $model->getId()]), + 'label' => $model->getLibelle(), + 'options' => []]; + + return $breadcrumb; + } + + + protected function _shouldCheckParent($start_key, $model) { + return ($start_key && ($this->getRequestParam($start_key, '') == $model->getId())); + } + + + public function getDefaultModel() { + return null; + } + + + public function getStrategyLabel() { + return ''; + } + + + public function countItemsFor($model) { + return 0; + } + + + public function countRecursiveItemsFor($model) { + return 0; + } + + + public function countItemsInTreeFrom($model) { + return $this->countItemsFor($model); + } + + + public function getCategoriesLabelAttrib() { + return 'libelle'; + } + + + public function getCategoriesId() { + return ''; + } + + + public function getItemsId() { + return ''; + } + + + public function getItemsAttribs() { + return [$this->getItemsLabelAttrib()]; + } + + + public function getItemsLabelAttrib() { + return 'titre'; + } + + + public function getItemsGroupBy() { + return null; + } + + + public function getCategoryFor($model) { + return $model->getCategorie(); + } + + + public function getModel() { + return $this->getParam('model'); + } + + + public function getParams() { + return $this->_params; + } + + + public function getParam($name, $default=null) { + return array_key_exists($name, $this->_params) ? + $this->_params[$name] : $default; + } + + + public function getPage() { + return $this->getParam('page'); + } + + + public function getSearch() { + return $this->getSearchValue(); + } + + + public function getModelId() { + return ($model = $this->getModel()) ? $model->getId() : 0; + } + + + public function getSearchValue() { + return $this->getParam('search_value'); + } + + + public function getItemsPaginator() { + $count = $this->getSearchValue() ? + $this->getCountSearchResult() : $this->countItemsFor($this->getModel()); + + return (new Zend_Paginator(new Zend_Paginator_Adapter_Null($count))) + ->setItemCountPerPage($this->_items_by_page) + ->setCurrentPageNumber($this->getPage()); + } + + + public function getRequestParam($key, $default = null) { + return $this->getRequest()->getParam($key, $default); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php b/library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..bbac05e179cad0059f9719d9fddae6370c2b8d1d --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php @@ -0,0 +1,124 @@ +<?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_AlbumListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + use Trait_Translator; + + public function albumListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->albumListViewMode($params); + } + + + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'album']; + } + + + public function getParamKey() { + return 'cat_id'; + } + + + public function getCategories() { + $categories = []; + + if ($this->getModel() != Class_AlbumCategorie::defaultCategory()) + $categories = Class_AlbumCategorie::findAllBy(['parent_id' => $this->getModelId(), + 'order' => 'libelle']); + + if (in_array($this->getPage(), [0, 1]) && !$this->getModel()) + $categories[] = Class_AlbumCategorie::defaultCategory() + ->setAlbums(Class_Album::findAllBy(['cat_id' => 0])); + + return array_filter(array_unique($categories)); + } + + + public function getItems() { + return Class_Album::findAllBy($this->getItemsParams()); + } + + + public function getItemsParams() { + return array_merge(parent::getItemsParams(), ['order' => 'titre']); + } + + + public function getCountSearchResult() { + return Class_Album::countBy($this->getSearchParams()); + } + + + public function getBreadcrumb() { + $breadcrumb = [['url' => ['module' => 'admin', + 'controller' => 'album', + 'action' => 'index'], + 'label' => $this->_('Racine'), + 'options' => []]]; + + return array_merge($breadcrumb, + $this->getBreadcrumbFor($this->getModel())); + } + + + public function getDefaultModel() { + return ($model = $this->getModel()) ? + $model : Class_AlbumCategorie::defaultCategory(); + } + + + public function countItemsFor($model) { + return $model ? $model->numberOfAlbums() : 0; + } + + + public function getCategoriesCols() { + return [$this->_('Catégories d\'albums')]; + } + + + public function getCategoriesLabelAttrib() { + return 'libelle'; + } + + + public function getItemsCols() { + return [$this->_('Liste des albums')]; + } + + + public function getItemsLabelAttrib() { + return 'titre'; + } + + + public function getStrategyLabel() { + return 'album'; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..f54a3f5ce8c9654e9df17f56c25e92b1db998afe --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php @@ -0,0 +1,237 @@ +<?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_ArticleListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + use Trait_Translator; + + protected $_filtred_categories_ids = []; + + public function articleListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->articleListViewMode($params); + } + + + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'cms']; + } + + + public function getSearchUrl() { + return $this->getBaseUrl() + ['action' => 'index', + 'id_bib' => $this->getBibId(), + 'title_search' => '']; + } + + + public function getBreadcrumbUrl() { + return array_merge($this->getBaseUrl(), ['action' => 'index']); + } + + + public function getParamKey() { + return 'id_cat'; + } + + + public function getCategories() { + $categories = (!$id_cat = $this->getParam('id_cat')) + ? $this->getBib()->getArticleCategories() + : Class_ArticleCategorie::findAllBy(['id_cat_mere' => $id_cat]); + + return $this->getFiltredCategories($categories); + } + + + protected function getCurrentBib() { + if ($this->_current_bib) + return $this->_current_bib; + + if (!$this->_current_bib = Class_Bib::find($this->getParam('id_bib'))) + $this->_current_bib = Class_Bib::getPortail(); + + return $this->_current_bib; + } + + + protected function getFiltredCategories($categories) { + $cms_permissions = Class_Permission::getCmsPermissions(); + + $categories_filter = function($category) use ($cms_permissions) { + $user = Class_Users::getIdentity(); + return $user->hasAnyPermissionUnder($category, $cms_permissions) + || $user->hasAnyPermissionOn($category, $cms_permissions); + }; + + return array_filter($categories, $categories_filter); + } + + + public function getItems() { + return Class_Article::findAllBy($this->getItemsParams()); + } + + + protected function getItemsParams() { + return array_merge(parent::getItemsParams(), + ['order' => 'titre']); + } + + + protected function getSearchParams() { + return parent::getSearchParams() + ['id_cat' => $this->getFilteredCategoriesIds()]; + } + + + protected function getFilteredCategoriesIds() { + if ($this->_filtred_categories_ids) + return $this->_filtred_categories_ids; + + $categories = $this->getFiltredCategories($this->getCategoriesForUser()); + $this->_filtred_categories_ids = array_map(function($model) { return $model->getId(); }, + $categories); + + return $this->_filtred_categories_ids; + } + + + protected function getCategoriesForUser() { + return $this->getCategories(); + } + + + public function getCountSearchResult() { + return Class_Article::countBy($this->getSearchParams()); + } + + + public function getBreadcrumb() { + $breadcrumb = [['url' => ['module' => 'admin', + 'controller' => 'cms', + 'action' => 'index'], + 'label' => $this->_('Racine'), + 'options' => []], + + ['url' => ['module' => 'admin', + 'controller' => 'cms', + 'action' => 'index', + 'id_bib' => $this->getBibId()], + 'label' => $this->getBibLabel(), + 'options' => []]]; + + if ($this->getSearchValue()) + return $breadcrumb; + + if (Class_Users::getIdentity()->isRoleLibraryLimited()) + $breadcrumb = [['url' => ['module' => 'admin', + 'controller' => 'cms', + 'action' => 'index'], + 'label' => $this->getParam('bib')->getLibelle(), + 'options' => []]]; + + return array_merge($breadcrumb, + $this->getBreadcrumbFor($this->getModel())); + } + + + protected function getBibLabel() { + return $this->getBib()->getLibelle(); + } + + + protected function getBibId() { + return $this->getBib()->getId(); + } + + + protected function getBib() { + if ($bib = Class_Bib::find($this->getParam('id_bib'))) + return $bib; + + if ($id_cat = $this->getParam('id_cat')) + return $this->getModel()->getBib(); + + return Class_Bib::getPortail(); + } + + + public function getDefaultModel() { + return $this->getModel() ? $this->getModel() : $this->getBib(); + } + + + public function countItemsFor($model) { + return $model ? $model->numberOfArticles() : 0; + } + + + public function countItemsInTreeFrom($model) { + if (!$model) + return 0; + + return $model->numberOfArticles() + + $this->countItemsInChildrenOf($model); + } + + + protected function countItemsInChildrenOf($model) { + if (!$model) + return 0; + + $count = 0; + foreach($model->getChildren() as $child) + $count += $this->countItemsInTreeFrom($child); + + return $count; + } + + + public function getCategoriesCols() { + return [$this->_('Catégories d\'articles')]; + } + + + public function getCategoriesLabelAttrib() { + return 'libelle'; + } + + + public function getItemsCols() { + return [$this->_('Liste des articles')]; + } + + + public function getItemsLabelAttrib() { + return 'titre'; + } + + + public function getStrategyLabel() { + return 'article'; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/BibListViewMode.php b/library/ZendAfi/Controller/Action/Helper/BibListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..1d34920527f532b9145aaaf4c840948443373790 --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/BibListViewMode.php @@ -0,0 +1,82 @@ +<?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_BibListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + use Trait_Translator; + + public function bibListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->bibListViewMode($params); + } + + + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'cms']; + } + + + public function isSearchEnabled() { + return false; + } + + + public function isCountEnabled() { + return false; + } + + + public function getParamKey() { + return 'id_bib'; + } + + + public function getCategories() { + return $this->getParam('bibs', []); + } + + + public function countItemsFor($model) { + $id = $model ? $model->getId() : 0; + return Class_ArticleCategorie::countBy(['id_site' => $id]); + } + + + public function getCategoriesCols() { + return [$this->_('Localisation')]; + } + + + public function getCategoriesLabelAttrib() { + return 'libelle'; + } + + + public function getStrategyLabel() { + return 'bib'; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ReviewListViewMode.php b/library/ZendAfi/Controller/Action/Helper/ReviewListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..565054702f524af8cc11d532486213a9d544f974 --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/ReviewListViewMode.php @@ -0,0 +1,100 @@ +<?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_ReviewListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + + public function reviewListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->reviewListViewMode($params); + } + + + public function getBaseUrl() { + return ['module' => 'opac', + 'controller' => 'blog', + 'action' => 'hierarchical', + 'truncate_at' => $this->getParam('truncate_at')]; + } + + + public function getStartKey() { + return 'start_id'; + } + + + public function getReviewUrlContext() { + return [$this->getStartKey() => null, + 'truncate_at' => null]; + } + + + public function getCategories() { + return ($model = $this->getModel()) ? + $model->getSousDomaines() : []; + } + + + public function getCategoriesId() { + return 'review'; + } + + + public function getItemsId() { + return 'review'; + } + + + public function getItems() { + return Class_AvisNotice::getAvisFromPreferences(['id_catalogue' => $this->getModelId()], + [$this->getPage(), $this->_items_by_page]); + } + + + public function getStrategyLabel() { + return 'review'; + } + + + public function countItemsFor($model) { + return 0; + } + + + public function countRecursiveItemsFor($model) { + return 0; + } + + + public function isSearchEnabled() { + return false; + } + + + public function isCountEnabled() { + return false; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php b/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..3405694a30cbfc17f4db971a13fd0b61f88a5f82 --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php @@ -0,0 +1,112 @@ +<?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_SitothequeListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + + public function sitothequeListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->sitothequeListViewMode($params); + } + + + public function getBaseUrl() { + return ['module' => 'opac', + 'controller' => 'sito', + 'action' => 'viewcategory']; + } + + + public function getParamKey() { + return 'id_cat'; + } + + + public function getCategories() { + $params = ($id_cat = $this->getRequestParam('id_cat')) ? + ['id_cat_mere' => $id_cat] : []; + + return Class_SitothequeCategorie::findAllBy($params); + } + + + public function getCategoriesId() { + return 'sitotheque'; + } + + + public function getItemsId() { + return 'sitotheque'; + } + + + public function getItems() { + return Class_Sitotheque::findAllBy($this->getItemsParams()); + } + + + protected function getItemsParams() { + return array_merge(parent::getItemsParams(), ['order' => 'titre']); + } + + + public function getCountSearchResult() { + return Class_Sitotheque::countBy($this->getSearchParams()); + } + + + protected function getSearchParams() { + return ['where' => 'titre like \'%' . trim($this->getSearch()) . '%\'', + 'order' => 'titre']; + } + + + public function getDefaultModel() { + return Class_SitothequeCategorie::find($this->getRequestParam('id_cat')); + } + + + public function getStrategyLabel() { + return 'sitotheque'; + } + + + public function countItemsFor($model) { + return $model ? $model->numberOfSitotheques() : 0; + } + + + public function countRecursiveItemsFor($model) { + if (!$model) + return Class_Sitotheque::count(); + + $ids = (new Storm_Model_Collection(array_merge($model->getRecursiveSousCategories(), + [$model]))) + ->collect('id'); + + return Class_Sitotheque::countBy(['id_cat' => (array)$ids]); + } +} diff --git a/library/ZendAfi/Filters/Serialize.php b/library/ZendAfi/Filters/Serialize.php index 6ef9f02a4530b0853ce98840ebea8b713b00ef5b..1b82eb9b7f70eca3578e4ad0581b5bd4e1eb5323 100644 --- a/library/ZendAfi/Filters/Serialize.php +++ b/library/ZendAfi/Filters/Serialize.php @@ -16,46 +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 */ -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 : FILTRE POUR LES SERIALIZE ET UNSERIALIZE -////////////////////////////////////////////////////////////////////////////////////////////////////////// -class ZendAfi_Filters_Serialize -{ - -//---------------------------------------------------------------- -// Encodage -//---------------------------------------------------------------- - static function serialize($valeurs) - { - if(!$valeurs) return false; - $cls=new ZendAfi_Filters_Serialize(); - array_walk_recursive($valeurs, array(&$cls,'encodeItem')); - $chaine=serialize($valeurs); +class ZendAfi_Filters_Serialize { - $chaine=utf8_encode($chaine); + public static function serialize($valeurs) { + if(!$valeurs) + return false; + + $cls = new ZendAfi_Filters_Serialize(); + array_walk_recursive($valeurs, [&$cls,'encodeItem']); + $chaine = serialize($valeurs); + $chaine = utf8_encode($chaine); return $chaine; } - -//---------------------------------------------------------------- -// Decodage -//---------------------------------------------------------------- - static function unserialize($valeur) - { - $valeur=utf8_decode($valeur); - $valeurs=unserialize($valeur); + + + public static function unserialize($valeur) { + $valeur = utf8_decode($valeur); + $valeurs = unserialize($valeur); return $valeurs; } -//---------------------------------------------------------------- -// Fonction callback pour l'encodage -//---------------------------------------------------------------- - private function encodeItem(&$valeur,$key) - { - $valeur=stripslashes($valeur); + + protected function encodeItem(&$valeur, $key) { + $valeur = stripslashes($valeur); return $valeur; } - } \ No newline at end of file diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index d19c0d3d1af3c1f2a0a4f4307b8cfec99953f6fb..e0ee0177f26f0c39c3af56316d37b935e8b5b989 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -22,8 +22,9 @@ class ZendAfi_Form extends Zend_Form { use Trait_Translator; - protected $_text_size = 40; - protected $_num_size = 4; + protected $_text_size = 40, + $_num_size = 4, + $_summary; public static function newWithOptions($options = null) { @@ -139,10 +140,10 @@ class ZendAfi_Form extends Zend_Form { foreach($groups_definitions as $name => $definition) $this - ->addElementsFromDefinition($definition['elements']) - ->addDisplayGroup(array_keys($definition['elements']), - $name, - ['legend' => $definition['legend']]); + ->addElementsFromDefinition($definition['elements']) + ->addDisplayGroup(array_keys($definition['elements']), + $name, + ['legend' => $definition['legend']]); return $this; } @@ -167,6 +168,17 @@ class ZendAfi_Form extends Zend_Form { $names[] = $element->getName(); return $names; } + + + public function addSummary($summary) { + $this->_summary = $summary; + return $this; + } + + + public function getSummary() { + return $this->_summary; + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index 140325595ca4cadf3b82a4af26391698665c673e..ca227deb5cb36a7c247a48ae762105a74176c45f 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -24,6 +24,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form { const RIGHT_OTHER_KEY = 2; const RIGHT_PUBLIC_DOMAIN = 'Domaine public'; + protected $_simple_elements = ['titre', 'cat_id', 'type_doc_id', @@ -31,7 +32,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'status', 'frbr_multi']; - public static function newWithAlbum($album) { $form = new self(); @@ -233,12 +233,12 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ['label' => $this->_(''), 'fields' => [['name' => 'frbr_type', 'label' => $this->_('Type de lien'), - 'attribs' => ['style' => 'width:180px;'], + 'attribs' => ['style' => 'width:450px;'], 'type' => 'select', 'options' => ['' => $this->_('Aucun')] + Class_FRBR_LinkType::getSourceTargetComboList()], ['name' => 'frbr_url', 'label' => $this->_('Permalien de la notice'), - 'attribs' => ['style' => 'width:450px;']]], + 'attribs' => ['style' => 'width:180px;']]], 'values' => ['frbr_type' => [], 'frbr_url' => []], 'deleteMessage' => 'ce lien FRBR']); diff --git a/library/ZendAfi/Form/Configuration/DomainWidget.php b/library/ZendAfi/Form/Configuration/DomainWidget.php index 2381b018b7e2654c4f2e3ee4dc7c24cd7be38a1b..9d7ca88a6f801de326329eb5a5541d7d46162917 100644 --- a/library/ZendAfi/Form/Configuration/DomainWidget.php +++ b/library/ZendAfi/Form/Configuration/DomainWidget.php @@ -58,7 +58,12 @@ class ZendAfi_Form_Configuration_DomainWidget extends ZendAfi_Form { Class_Profil::getCurrentProfil()))->toArray()]) ->addElement('domainSelect', 'root_domain_id', - ['label' => $this->_('Choisissez le domaine de départ')]) + ['label' => $this->_('Choisissez le domaine de départ. Les domaines sélectionnables sont ceux qui ont des sous-domaines.'), + 'multiple_selection' => false, + 'items_selectable' => false, + 'url' => Class_Url::assemble(['module' => 'admin', + 'controller' => 'catalogue', + 'action' => 'browsable-domains'])]) ->addElement('select', 'display_mode', ['label' => $this->_('Format'), diff --git a/library/ZendAfi/Form/Configuration/SearchResult.php b/library/ZendAfi/Form/Configuration/SearchResult.php index 100d6bbf172d840cdbdb795da2c3b911eb089991..73bf4592a0bfbf1bc6326cdd56e1f5615769e5bf 100644 --- a/library/ZendAfi/Form/Configuration/SearchResult.php +++ b/library/ZendAfi/Form/Configuration/SearchResult.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 */ @@ -26,86 +26,88 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { protected $_text_size = 40; protected $_num_size = 4; - + public static function newConfigurationWith($conf) { $form = new self(); + + $facets_codes=(new Class_Codification())->cleanDeletedFacets($conf['facettes_codes']);//array_filter($conf['facettes_codes'],function($code) { return true;}) $form ->populate($conf) ->addSelectedFieldFor('liste_codes', $conf['liste_codes']) ->addSelectedFieldFor('tags_codes', $conf['tags_codes']) - ->addSelectedFieldFor('facettes_codes', $conf['facettes_codes']) + ->addSelectedFieldFor('facettes_codes', $facets_codes) ->addDisplayGroup(['titre', - 'boite', - 'suggestion_achat'], - 'Generalites', + 'boite', + 'suggestion_achat'], + 'Generalites', ['legend' => $form->_('Généralités')]) ->addDisplayGroup(['liste_format', - 'liste_nb_par_page', + 'liste_nb_par_page', 'liste_codes', - 'zones_titre'], - 'liste', + 'zones_titre'], + 'liste', ['legend' => $form->_('Liste')]) ->addDisplayGroup(['facettes_actif', - 'facettes_nombre', + 'facettes_nombre', 'facettes_codes', - 'facettes_message'], - 'facettes', + 'facettes_message'], + 'facettes', ['legend' => $form->_('Facettes')]) - ->addDisplayGroup(['tags_actif', + ->addDisplayGroup(['tags_actif', 'tags_position', - 'tags_calcul', - 'tags_nombre', - 'tags_codes' , - 'tags_message'], - 'tags', + 'tags_calcul', + 'tags_nombre', + 'tags_codes' , + 'tags_message'], + 'tags', ['legend' => $form->_('Nuage de tags')]) ->addCvsGroup() ->addDisplayGroup(['submit'], 'submit', ['legend' => '']); - + return $form; } - + public function init() { parent::init(); $this - ->setAttrib('id', + ->setAttrib('id', 'configuration_searchResult') - ->addElement('text', - 'titre', + ->addElement('text', + 'titre', ['label' => $this->_('Titre'), 'size' => $this->_text_size]) ->addElement('select', - 'boite', + 'boite', ['label' => $this->_('Style de boite'), 'multiOptions' => (new Class_Profil_Templates( Class_Profil::getCurrentProfil()))->toArray()]) - ->addElement('checkbox', - 'suggestion_achat', + ->addElement('checkbox', + 'suggestion_achat', ['label' => $this->_('Lien "Suggérer un achat"')]) - - ->addElement('select', - 'liste_format', + + ->addElement('select', + 'liste_format', ['label' => $this->_('Format'), 'multiOptions' => Class_Systeme_ModulesAppli::getAvailableListeNoticeFormat()]) - ->addElement('text', - 'liste_nb_par_page', + ->addElement('text', + 'liste_nb_par_page', ['label' => $this->_('Nombre de notices par page'), 'size' => $this->_num_size, 'validators' => [ ['name' => 'Between', 'value' => true, - 'options' => [ + 'options' => [ 'min' => 3, 'max' => 50, 'messages' => 'Le nombre de notices par page doit être compris entre 3 et 50']] ]]) - ->addElement('codeList', - 'liste_codes', + ->addElement('codeList', + 'liste_codes', ['label' => $this->_('Champs à afficher'), 'field' => 'liste', 'values' => '', @@ -116,32 +118,32 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { 'options' => [ 'messages' => 'Indiquez au moins 1 champ à afficher pour la liste']] ]]) - ->addElement('text' , - 'zones_titre', + ->addElement('text' , + 'zones_titre', ['label' => $this->_('Zones de titre(séparées par ;)'), 'size' => $this->_text_size]) - - ->addElement('select', - 'facettes_actif', + + ->addElement('select', + 'facettes_actif', ['label' => $this->_('Affichage'), 'multiOptions' => ['0' => $this->_('Ne pas afficher'), '1' => $this->_('Afficher les facettes')]]) - ->addElement('text', - 'facettes_nombre', + ->addElement('text', + 'facettes_nombre', ['label' => $this->_("Nombre d'éléments par facette"), 'size' => $this->_num_size, 'validators' => [ ['name' => 'Between', 'value' => true, - 'options' => [ + 'options' => [ 'min' => 2, 'max' => 10, 'messages' => 'Le nombre de facettes doit être compris entre 2 et 10'] ]]]) - ->addElement('codeList', - 'facettes_codes', + ->addElement('codeList', + 'facettes_codes', ['label' => $this->_('Facettes à afficher'), 'field' => 'facettes', 'values' => '', @@ -152,40 +154,40 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { 'options' => [ 'messages' => 'Indiquez au moins 1 facette à afficher'] ]]]) ->addElement('text', - 'facettes_message', + 'facettes_message', ['label' => $this->_('Message au dessus de la boite'), 'size' => $this->_text_size]) - ->addElement('select' , - 'tags_actif', + ->addElement('select' , + 'tags_actif', ['label' => $this->_('Affichage'), 'multiOptions' => ['0' => 'Ne pas afficher les tags', '1'=>'Afficher les tags']]) - ->addElement('select' , - 'tags_position', + ->addElement('select' , + 'tags_position', ['label' => $this->_('Position'), 'multiOptions' => ['2' => 'A côté de la liste', '1'=>'Sous la liste']]) - ->addElement('select' , - 'tags_calcul', + ->addElement('select' , + 'tags_calcul', ['label' => $this->_('Mode de calcul des tranches'), 'multiOptions' => ['0' => 'Par répartition', '1'=>'Par écart à la moyenne', '2' => 'Par écart à la moyenne pondéré']]) ->addElement('text', - 'tags_nombre', + 'tags_nombre', ['label' => $this->_('Nombre de tags à afficher'), 'size' => $this->_num_size, 'validators' => [ ['name' => 'Between', 'value' => true, - 'options' => [ + 'options' => [ 'min' => 5, 'max' => 1000, 'messages' =>'Le nombre de tags doit être compris entre 5 et 1000'] ]]]) - ->addElement('codeList', - 'tags_codes', + ->addElement('codeList', + 'tags_codes', ['label' => $this->_('Types de tags'), 'field' => 'tags', 'values' => '', @@ -197,18 +199,18 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ]]) ->addElement('text', - 'tags_message', + 'tags_message', ['label' => $this->_('Message au dessus de la boite'), 'size' => $this->_text_size]) ->addCvsElement() - ->addElement('submit', - 'submit', + ->addElement('submit', + 'submit', ['label' => $this->_('Valider')]); } public function addSelectedFieldFor($element, $values) { - + $this->$element->setValues($values); return $this; } @@ -217,8 +219,8 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { public function addCvsElement() { if(Class_AdminVar::isCVSEnabled()) $this - ->addElement('select' , - 'cvs_display_position', + ->addElement('select' , + 'cvs_display_position', ['label' => $this->_('Affichage'), 'multiOptions' => ['0' => $this->_('Ne pas afficher'), '1' => $this->_('Afficher au dessus des facettes'), @@ -245,7 +247,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { 'cvs_msg_droit', ['label' => $this->_("Message utilisateur sans droit d'accès"), 'size' => $this->_text_size]); - + return $this; } @@ -262,6 +264,6 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ['legend' => $this->_('Résultats CVS')]); return $this; } - -} + +} ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Decorator/DomainSelect.php b/library/ZendAfi/Form/Decorator/DomainSelect.php index 0f5bcc59a4f7fb6c4ea61553571db6498df9a49c..38cebe3d1147b991f1e7dd848355430a2966a873 100644 --- a/library/ZendAfi/Form/Decorator/DomainSelect.php +++ b/library/ZendAfi/Form/Decorator/DomainSelect.php @@ -23,18 +23,27 @@ class ZendAfi_Form_Decorator_DomainSelect extends Zend_Form_Decorator_Abstract { public function render($content) { - return $this->_element + $url = $this->_element->getUrl() ? $this->_element->getUrl() : $this->_element->getView()->url(['module' => 'admin', + 'controller' => 'catalogue', + 'action' => 'domaines']); + + $tree_select = $this->_element ->getView() - ->getHelper('TreeSelect') + ->getHelper('TreeSelect'); + + if(false === $this->_element->getMultipleSelection()) + $tree_select->disableMultipleSelection(); + + if(false === $this->_element->getItemsSelectable()) + $tree_select->itemsNotSelectable(); + + return $tree_select ->treeSelect('', $this->_element->getValue(), true, - $this->_element->getView()->url(['module' => 'admin', - 'controller' => 'catalogue', - 'action' => 'domaines']), + $url, 'form', - $this->_element->getName() - ); + $this->_element->getName()); } } ?> diff --git a/library/ZendAfi/Form/Decorator/Table.php b/library/ZendAfi/Form/Decorator/Table.php new file mode 100644 index 0000000000000000000000000000000000000000..18ee21da44d6fab852ec1458855f67c64bcec872 --- /dev/null +++ b/library/ZendAfi/Form/Decorator/Table.php @@ -0,0 +1,35 @@ +<?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_Decorator_Table extends Zend_Form_Decorator_Abstract { + public function render($content) { + $element = $this->getElement(); + $view = $element->getView(); + + if (null === $view) + return $content; + + $attribs = $this->getOptions(); + return $view->table($content, $attribs); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Element/DomainSelect.php b/library/ZendAfi/Form/Element/DomainSelect.php index b5914a1b50894c0737d5e894331af5020648941a..d67680eab3cf935773b4537c5c8c21568962afde 100644 --- a/library/ZendAfi/Form/Element/DomainSelect.php +++ b/library/ZendAfi/Form/Element/DomainSelect.php @@ -22,8 +22,12 @@ class ZendAfi_Form_Element_DomainSelect extends Zend_Form_Element { + protected $url, $multiple_selection, $items_selectable; + + public function __construct($spec, $options=null) { parent::__construct($spec, $options); + $decorators = $this->_decorators; $this->_decorators = ['DomainSelect' => new ZendAfi_Form_Decorator_DomainSelect()]; @@ -31,5 +35,21 @@ class ZendAfi_Form_Element_DomainSelect extends Zend_Form_Element { $this->_decorators[$name] = $value; $this->removeDecorator('ViewHelper'); } + + + public function getUrl() { + return $this->url; + } + + + public function getMultipleSelection() { + return $this->multiple_selection; + } + + + public function getItemsSelectable() { + return $this->items_selectable; + } + } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Login.php b/library/ZendAfi/Form/Login.php index 8ad2f8e5063d55e763a8f7ade1bc1e07f23d8289..072a9a837d35f1c9fbc831997288b14cde4bef45 100644 --- a/library/ZendAfi/Form/Login.php +++ b/library/ZendAfi/Form/Login.php @@ -16,11 +16,11 @@ * * 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_Form_Login extends ZendAfi_Form { - + protected $_data, $_redirect_url, $_id_notice,$_service; public function init() { @@ -35,46 +35,48 @@ class ZendAfi_Form_Login extends ZendAfi_Form { 'loginlink', 'lostpass', 'register']; - + $this->setMethod(Zend_Form::METHOD_POST) - ->setAttrib('autocomplete', $this->_data['autocomplete_off'] ? 'off' : 'on') - ->setAttrib('class', 'login') - ->addElement('text', - 'username', - ['label' => $this->_data['identifiant'], - 'placeholder' => $this->_data['identifiant_exemple'], - 'required' => true, - 'allowEmpty' => false, - 'size' => 15]) - - ->addElement('password', - 'password', - ['label' => $this->_data['mot_de_passe'], - 'placeholder' => $this->_data['mot_de_passe_exemple'], - 'required' => true, - 'allowEmpty' => false, - 'size' => 15, - 'onkeypress' => 'if (event.keyCode == 13) {this.form.submit();return false;}']) - - ->addElement('submit', - 'login', - ['label' => $this->_data['lien_connexion'], - 'onclick' => '$(this).parents(\'form\').submit()']) - - ->addElement('link', - 'loginlink', - ['onclick' => '$(this).parents(\'form\').submit()', - 'label' => $this->_data['lien_connexion']]) - - ->addElement('link', - 'lostpass', - ['value' => ['controller' => 'auth', 'action' => 'lostpass'], - 'onclick' => 'getUsername();', - 'target' => '_parent', - 'label' => $this->_data['lien_mot_de_passe_oublie']]); - - - if(Class_AdminVar::isEnregUtilAllowed()) { + ->setAttrib('autocomplete', $this->_data['autocomplete_off'] ? 'off' : 'on') + ->setAttrib('class', 'login') + ->addElement('text', + 'username', + ['label' => $this->_data['identifiant'], + 'placeholder' => $this->_data['identifiant_exemple'], + 'required' => true, + 'allowEmpty' => false, + 'size' => 15]) + ->addSummary($this->_('Formulaire d\'authentification')) + + ->addElement('password', + 'password', + ['label' => $this->_data['mot_de_passe'], + 'placeholder' => $this->_data['mot_de_passe_exemple'], + 'required' => true, + 'allowEmpty' => false, + 'size' => 15, + 'onkeypress' => 'if (event.keyCode == 13) {this.form.submit();return false;}']) + + ->addElement('submit', + 'login', + ['label' => $this->_data['lien_connexion'], + 'onclick' => '$(this).parents(\'form\').submit()']) + + ->addElement('link', + 'loginlink', + ['onclick' => '$(this).parents(\'form\').submit()', + 'label' => $this->_data['lien_connexion']]) + + ->addElement('link', + 'lostpass', + ['value' => ['controller' => 'auth', 'action' => 'lostpass'], + 'onclick' => 'getUsername();', + 'target' => '_parent', + 'label' => $this->_data['lien_mot_de_passe_oublie']]); + + $this->_ensureElementsLabel(); + + if (Class_AdminVar::isEnregUtilAllowed()) { $this->addElement('link', 'register', ['value' => ['controller' => 'auth', @@ -84,7 +86,7 @@ class ZendAfi_Form_Login extends ZendAfi_Form { array_push($group, 'register'); } - + if(!$this->_redirect_url==''){ $this->addElement('hidden', 'redirect', @@ -107,11 +109,27 @@ class ZendAfi_Form_Login extends ZendAfi_Form { array_push($group, 'ajoutPanier'); } - $this->addDisplayGroup($group,'login_form',[]); + $this->addDisplayGroup($group, 'login_form', ['legend' => $this->_('Login')]); } + public function setData($data){ $this->_data = $data; } + + protected function _ensureElementsLabel() { + $this->_ensureElementLabel('username', $this->_('Identifiant')); + $this->_ensureElementLabel('password', $this->_('Mot de passe')); + } + + + protected function _ensureElementLabel($name, $default) { + $element = $this->getElement($name); + if (!$element || $element->getLabel()) + return; + + $title = $element->placeholder ? $element->placeholder : $default; + $element->setAttrib('title', $title); + } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Abonne/LoanAction.php b/library/ZendAfi/View/Helper/Abonne/LoanAction.php new file mode 100644 index 0000000000000000000000000000000000000000..bfa773195c696da61cfba5f9ffcdf9928cc355dc --- /dev/null +++ b/library/ZendAfi/View/Helper/Abonne/LoanAction.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +class ZendAfi_View_Helper_Abonne_LoanAction extends ZendAfi_View_Helper_Abonne_Abstract { + use Trait_Translator; + + public function abonne_LoanAction($emprunt) { + if ($emprunt->isRenewable()) + return $this->renewLoanLink($emprunt); + + if ($emprunt->isPNB()) + return $this->endLoanBookLink($emprunt); + + return ''; + } + + + public function tagAnchor($url, $content) { + return $this->view->tagAnchor($url, + $content, + [ + 'data-popup' => 'true', + 'data-popup-refresh' => 'true', + ]); + } + + + public function renewLoanLink($emprunt) { + return $this->tagAnchor([ + 'action' => 'prolongerPret', + 'id_pret' => $emprunt->getId() + ], + $this->_('Prolonger')); + } + + + public function endLoanBookLink($emprunt) { + return $this->view->tagAnchor(['action' => 'end-loan-book', + 'id' => $emprunt->getId()], + $this->_('Rendre le livre')); + } + + +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Abonne/Multimedia.php b/library/ZendAfi/View/Helper/Abonne/Multimedia.php index 9088e65cb5cc0ff5d86c9927100f76e1a8f997b7..5e7d2dfe230aab6d13214bc4dbe8bdf2f26e8285 100644 --- a/library/ZendAfi/View/Helper/Abonne/Multimedia.php +++ b/library/ZendAfi/View/Helper/Abonne/Multimedia.php @@ -16,11 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_multimedia($user) { - if (Class_AdminVar::isMultimediaEnabled()) { + $ouvertures = Class_Ouverture::findAll(); + if (Class_AdminVar::isMultimediaEnabled() && !empty($ouvertures)) { $action_url = $this->getActionUrl('multimedia-hold-location'); @@ -28,7 +29,7 @@ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_A $this->view->_("Réserver un poste multimédia")); $html .= '<ul>'; foreach ($user->getFutureMultimediaHolds() as $hold) { - $html .= sprintf('<li><a href="%s">%s, %s %s, %s</li>', + $html .= sprintf('<li><a href="%s">%s, %s %s, %s</li>', $this->view->url(['controller' => 'abonne', 'action' => 'multimedia-hold-view', 'id' => $hold->getId()], @@ -38,8 +39,8 @@ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_A sprintf('pour %smn', (($hold->getEnd() - $hold->getStart()) / 60)), $hold->getLibelleBib()); } - - + + $html .= '</ul>'; return $this->tagFicheAbonne($html, 'multimedia', $action_url); @@ -52,7 +53,7 @@ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_A $html = $this->view->tagAnchor($action_url, $this->view->_("Réserver un poste Webkiosk")); - + return $this->tagFicheAbonne($html, 'multimedia', $action_url); } @@ -63,7 +64,7 @@ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_A protected function getActionUrl($action){ return $this->view->url(['controller' => 'abonne', - 'action' => $action], + 'action' => $action], null, true); } } diff --git a/library/ZendAfi/View/Helper/Abonne/Prets.php b/library/ZendAfi/View/Helper/Abonne/Prets.php index 0e4a3c9bb56b8a2df5405af78dba8822b788423f..f0f7ee7f0e28fb356f0716fd1241ad3e11011834 100644 --- a/library/ZendAfi/View/Helper/Abonne/Prets.php +++ b/library/ZendAfi/View/Helper/Abonne/Prets.php @@ -16,32 +16,28 @@ * * 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_Abonne_Prets extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_prets($user) { if (!$user->isAbonne()) return ''; - $fiche_sigb = $user->getFicheSigb(); - if (!isset($fiche_sigb['fiche'])) - return ''; - - $nb_prets = $fiche_sigb["fiche"]->getNbEmprunts(); + $nb_prets = $user->getNbEmprunts(); $str_prets = $this->view->_plural($nb_prets, "Vous n'avez aucun prêt en cours.", "Vous avez %d prêt en cours", "Vous avez %d prêts en cours", $nb_prets); - $nb_retards = $fiche_sigb["fiche"]->getNbPretsEnRetard(); + $nb_retards = $user->getNbEmpruntsRetard(); $str_retards = $nb_retards ? $this->view->_('(%d en retard)', $nb_retards) : ''; $action_url = $this->view->url(['controller' => 'abonne', 'action' => 'prets']); - return $this->tagFicheAbonne(sprintf('<a href=\'%s\'>%s %s</a>', - $action_url, - $str_prets, + return $this->tagFicheAbonne(sprintf('<a href=\'%s\'>%s %s</a>', + $action_url, + $str_prets, $str_retards), 'prets', $action_url); diff --git a/library/ZendAfi/View/Helper/Abonne/Reservations.php b/library/ZendAfi/View/Helper/Abonne/Reservations.php index 34bac2fe6e8c54636135247dcf7a8753a7ae6342..508137a7e2dfe75a1af54ad1a9fb1ceed66b1274 100644 --- a/library/ZendAfi/View/Helper/Abonne/Reservations.php +++ b/library/ZendAfi/View/Helper/Abonne/Reservations.php @@ -16,27 +16,23 @@ * * 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_Abonne_Reservations extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_reservations($user) { if (!$user->isAbonne()) return ''; - $fiche_sigb = $user->getFicheSigb(); - if (!isset($fiche_sigb['fiche'])) - return ''; - - $nb_resas = $fiche_sigb["fiche"]->getNbReservations(); + $nb_resas = $user->getNbReservations(); $str_resas = $this->view->_plural($nb_resas, "Vous n'avez aucune réservation en cours.", "Vous avez %d réservation en cours", "Vous avez %d réservations en cours", $nb_resas); - + $action_url = $this->view->url(['controller' => 'abonne', 'action' => 'reservations']); - return $this->tagFicheAbonne(sprintf("<a href='%s'>%s</a>", + return $this->tagFicheAbonne(sprintf("<a href='%s'>%s</a>", $action_url, $str_resas), 'reservations', diff --git a/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php b/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php index 2493c44d0824387d946a85fe29b37eb8fe1b02f1..fd2d7d28aab6ef0f8c171d51d8d7004a43d89151 100644 --- a/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php +++ b/library/ZendAfi/View/Helper/Accueil/AbonneAbstract.php @@ -53,10 +53,11 @@ abstract class ZendAfi_View_Helper_Accueil_AbonneAbstract extends ZendAfi_View_H public function getContenu() { - return implode('', - array_map( - [$this, 'renderModel'], - $this->getModels())); + return (new Storm_Collection($this->getModels())) + ->injectInto('', + function($html, $model) { + return $html.$this->renderModel($model); + }); } diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index 9dab4f3b53e64dbf623e04d490ba036f065c708e..d145397e3cee706ecdecedc4a6596e70b63e8863 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -18,10 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC 3 : classe de base pour le gestion des modules de la page D'ACCUEIL -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstract { protected static $modules_config; @@ -58,13 +55,6 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac } - public function setPreference($name, $value) { - $this->preferences[$name] = $value; - return $this; - } - - - public function setIdMenu($id_menu) { $this->_id_menu = $id_menu; return $this; @@ -93,11 +83,6 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac } - public function getPreferences() { - return $this->preferences; - } - - public static function getComboTemplates($valeur_select, $profil=null) { if (!$profil) $profil = Class_Profil::getCurrentProfil(); @@ -287,7 +272,12 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac else $html=$html_array["TITRE"].BR.$html_array["CONTENU"]; - return '<div id="boite_'.$this->id_module.'" class="boite '.strtolower($this->type_module).'">'.$html.'</div>'; + return '<div id="' . $this->_getBoxId() . '" class="boite '.strtolower($this->type_module).'">'.$html.'</div>'; + } + + + protected function _getBoxId() { + return 'boite_' . $this->id_module; } diff --git a/library/ZendAfi/View/Helper/Accueil/Critiques.php b/library/ZendAfi/View/Helper/Accueil/Critiques.php index b3dfc11a3685fac72bece1757e38a6956accf2e6..69111172cca1fbf05b1f4a705c1af7cb33cdecb4 100644 --- a/library/ZendAfi/View/Helper/Accueil/Critiques.php +++ b/library/ZendAfi/View/Helper/Accueil/Critiques.php @@ -16,50 +16,56 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Dernières critiques sur les notices -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_Base { public function getHtml() { - extract($this->preferences); + if ($this->isHierarchicalDisplay()) { + $this->titre = $this->getPreference('titre'); + $this->contenu = $this->view->domainTree($this->getPreference('id_catalogue'), + $this->getPreference('nb_words')); + return $this->getHtmlArray(); + } $this->titre = $this->_getTitle(); - if ($rss_avis) + if ($this->getPreference('rss_avis')) $this->rss_interne = $this->_getRSSurl('rss', 'critiques'); - $fetched_avis = Class_AvisNotice::getLoader()->getAvisFromPreferences($this->preferences); + $fetched_avis = Class_AvisNotice::getAvisFromPreferences($this->getPreferences()); - if ($display_order == 'Random') + if ($this->getPreferences('display_order') == 'Random') shuffle($fetched_avis); - $selected_avis = array(); - $only_img = ($this->preferences['only_img'] == '1'); + $selected_avis = []; + $only_img = $this->getPreference('only_img') == '1'; foreach($fetched_avis as $avis) { - if (count($selected_avis) >= $nb_aff_avis) + if (count($selected_avis) >= $this->getPreference('nb_aff_avis')) break; - if (null == $notice = $avis->getFirstNotice()) { + if (null == $notice = $avis->getFirstNotice()) continue; - } - if (($only_img===false) || ( $avis->getFirstNotice()->hasVignette() === true)) - $selected_avis []= $avis; + if ((!$only_img) || $notice->hasVignette()) + $selected_avis[] = $avis; } - if (count($selected_avis) == 0) - $this->contenu = sprintf('<p>%s</p>', $this->translate()->_('Aucune critique récente')); - else { - $avis_helper = $this->_newHelperAvis(); + if (count($selected_avis) == 0) { + $this->contenu = $this + ->decorateContenu($this->_tag('p', $this->_('Aucune critique récente'))); - foreach ($selected_avis as $avis) - $this->contenu .= $this->decorateAvisHtml($avis_helper->avis($avis)); + return $this->getHtmlArray(); } + $avis_helper = $this->_newHelperAvis(); + foreach ($selected_avis as $avis) + $this->contenu .= $this->decorateAvisHtml($avis_helper->avis($avis)); + $this->contenu = $this->decorateContenu($this->contenu); + return $this->getHtmlArray(); } @@ -70,7 +76,7 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ protected function decorateContenu($html) { - return $html . '<div class="clear"></div>'; + return $html . $this->_tag('div', '', ['class' => 'clear']); } @@ -80,6 +86,7 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ ->setLimitNbWord($this->preferences['nb_words']) ->setVignetteLinkToAvis() ->addUrlContext(['retour_avis' => $this->id_module]); + return $avis_helper; } @@ -93,5 +100,9 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ ['id_module' => $this->id_module, 'id_menu' => $this->_id_menu]); } -} -?> \ No newline at end of file + + + protected function isHierarchicalDisplay() { + return '1' == $this->getPreference('hierarchical'); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Kiosque.php b/library/ZendAfi/View/Helper/Accueil/Kiosque.php index 6520a4b926b16bb955f51b010b633fbca90a3d80..d83e502455cad6943974235ef1a62da45c47d72b 100644 --- a/library/ZendAfi/View/Helper/Accueil/Kiosque.php +++ b/library/ZendAfi/View/Helper/Accueil/Kiosque.php @@ -31,7 +31,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba protected function _renderHeadScriptsOn($script_loader) { - $script_loader->addJQueryReady('$(".embedcode>div:first-child").click(function(){$(this).next().toggle("fast")})'); + $script_loader->addJQueryReady('$(".embedcode-button").click(function(){$(this).next().toggle("fast")})'); if($this->isModeMur() || $this->isModeVignettes()){ $this->view->getHelper('ListeNotices_Mur')->loadScript(); $this->view->getHelper('Notice_LienReserver')->loadScript(); @@ -217,13 +217,12 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba 'action' => $action], $this->preferences)); - return sprintf('<div class="embedcode">'. - '<div><></div>'. - '<div style="display:none">%s<textarea cols="20" rows="10" readonly="readonly">%s</textarea></div>'. - '</div>', - $this->view->_('Copier le code suivant sur le site où vous voulez afficher le kiosque'), - htmlspecialchars($iframe->getHtml())) - .$iframe->getHtml(); + $embed_button = $this->view->tag('span', '<>', ['class' => 'embedcode-button']); + $embed_content = $this->view->tag('div', + $this->view->tag('p', $this->view->_('Copier le code suivant sur le site où vous voulez afficher le kiosque')) . $this->view->tag('span', htmlspecialchars($iframe->getHtml()), ['class' => 'embed-code-to-copy']), ['style' => 'display: none;']); + $embedcode = $this->view->tag('div', $embed_button . $embed_content, ['class' => 'embedcode']); + + return $embedcode . $iframe->getHtml(); } diff --git a/library/ZendAfi/View/Helper/Accueil/Login.php b/library/ZendAfi/View/Helper/Accueil/Login.php index d474024a47c2637c808d44946998f82f03b3df88..3717a46680ddca93b2ec2ba87475ebc7a9affbc3 100644 --- a/library/ZendAfi/View/Helper/Accueil/Login.php +++ b/library/ZendAfi/View/Helper/Accueil/Login.php @@ -16,35 +16,30 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Class module Recherche Simple -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + class ZendAfi_View_Helper_Accueil_Login extends ZendAfi_View_Helper_Accueil_Base { /* Désactive le cache: sinon la boîte n'est pas à jour si on se connecte / déconnecte */ public function shouldCacheContent() { return false; } -//--------------------------------------------------------------------- -// Construction du Html -//--------------------------------------------------------------------- public function getHtml() { $this->titre = $this->selectTitre(); - $this->contenu = "<div id='boite_login'>". - $this->view->partial('auth/boite-login.phtml', - array("preferences" => $this->preferences, - "id_module" => $this->id_module)). - "</div>"; + $this->contenu = $this + ->_tag('div', $this->view->partial('auth/boite-login.phtml', + ['preferences' => $this->preferences, + 'id_module' => $this->id_module]), + ['id' => 'boite_login']); return $this->getHtmlArray(); } + public function selectTitre() { - if($user = Class_Users::getLoader()->getIdentity()) + if ($user = Class_Users::getLoader()->getIdentity()) return $this->preferences['titre_connecte']; return $this->preferences['titre']; } - } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Sito.php b/library/ZendAfi/View/Helper/Accueil/Sito.php index d464440a47955463750f933dd0a592c5dd6702d2..c5457f290d0c7ce8e1f5feea9f9c866751b2d6b8 100644 --- a/library/ZendAfi/View/Helper/Accueil/Sito.php +++ b/library/ZendAfi/View/Helper/Accueil/Sito.php @@ -20,10 +20,20 @@ */ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base { + const ORDER_RANDOM = 'Random'; + const ORDER_SELECTION = 'Selection'; + + const DISPLAY_SELECTION = 1; + const DISPLAY_NOVELTY = 2; + const DISPLAY_HIERARCHY = 3; + + protected $sitotree_helper; + protected function _renderHeadScriptsOn($script_loader) { - if ($this->isGroupByCategorie()) + if ($this->isGroupByCategorie() + && !$this->isHierarchicalDisplay()) Class_ScriptLoader::getInstance() - ->addJQueryReady('$("ul.sitotheque>li>h2>a").click( + ->addJQueryReady('$("#'.$this->_getBoxId() .' ul.sitotheque>li>h2>a").click( function(event){ event.preventDefault(); $(this).closest("li").find("ul").slideToggle(); @@ -32,78 +42,108 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base public function getHtml() { - extract($this->preferences); + $this->sitotree_helper = $this->view->getHelper('SitoTree'); + $contenu = ''; - $nb_aff = $this->preferences['nb_aff']; + $nb_aff = $this->getPreference('nb_aff'); + + $box_title = $this->getPreference('titre') ? + $this->getPreference('titre') : $this->_('Derniers sites ajoutés'); + + if ($this->isHierarchicalDisplay()) { + $this->contenu = $this->sitotree_helper + ->sitoTree($this->getPreference('id_categorie')); + $this->titre = $box_title; + return $this->getHtmlArray(); + } + - if ($this->isTypeAffichageSelection()) { - $sites = Class_Sitotheque::getSitesFromIdsAndCategories( - explode('-', $this->preferences['id_items']), - explode('-', $this->preferences['id_categorie'])); + if ($this->isTypeAffichageSelection()) { + $sites = Class_Sitotheque::getSitesFromIdsAndCategories(explode('-', $this->getPreference('id_items')), + explode('-', $this->getPreference('id_categorie'))); - if ($this->preferences['display_order'] == 'Random') + if (static::ORDER_RANDOM == $this->getPreference('display_order')) shuffle($sites); - if ($this->preferences['display_order'] == 'Selection') + if (static::ORDER_SELECTION == $this->getPreference('display_order')) $nb_aff = count($sites); - $titre = sprintf('<a href="%s" title="%s">%s</a>', - htmlspecialchars(BASE_URL.'/opac/sito/viewselection/id_module/'.$this->id_module), - $this->translate()->_('Sélection de sites'), - $titre); + $this->titre = $this->renderTitleLink($box_title, + $this->_('Sélection de sites'), + $this->view->url(['module' => 'opac', + 'controller' => 'sito', + 'action' => 'viewselection', + 'id_module' => $this->id_module], + null, true)); } if ($this->isTypeAffichagePlusRecents() && $nb_aff > 0) { - $sites = Class_Sitotheque::findAllBy(['limit' => 50]); - shuffle($sites); + $sites = Class_Sitotheque::findAllBy(['order' => 'date_maj desc', + 'limit' => 50]); - if(!$titre) - $titre = $this->translate()->_("Derniers sites ajoutés"); + if (static::ORDER_RANDOM == $this->getPreference('display_order')) + shuffle($sites); - $titre = sprintf('<a href="%s" title="%s">%s</a>', - htmlspecialchars(BASE_URL.'/opac/sito/viewrecent/nb/50'), - $this->translate()->_('Liste des derniers sites ajoutés'), - $titre); + $this->titre = $this->renderTitleLink($box_title, + $this->_('Liste des derniers sites ajoutés'), + $this->view->url(['controller' => 'sito', + 'action' => 'viewrecent', + 'nb' => 50], + null,true)); } - $this->titre = $titre; $this->contenu = $this->renderSitesSlice($sites, $nb_aff); return $this->getHtmlArray(); } + public function renderTitleLink($content, $title, $url) { + return $this->view->tagAnchor($url, $content, ['title' => $this->translate()->_($title)]); + } + + public function isTypeAffichageSelection() { - return $this->preferences['type_aff'] == 1; + return $this->_isDisplayType(static::DISPLAY_SELECTION); } public function isTypeAffichagePlusRecents() { - return $this->preferences['type_aff'] == 2; + return $this->_isDisplayType(static::DISPLAY_NOVELTY); } - public function isGroupByCategorie() { - if (!array_isset('group_by_categorie', $this->preferences)) - return false; + public function isHierarchicalDisplay() { + return $this->_isDisplayType(static::DISPLAY_HIERARCHY); + } - return $this->preferences['group_by_categorie'] == true; + + protected function _isDisplayType($type) { + return $this->getPreference('type_aff') == $type; + } + + + public function isGroupByCategorie() { + return (array_isset('group_by_categorie', $this->preferences) + && true == $this->getPreference('group_by_categorie')); } public function groupSitesByCategorie($sites) { - $categories = array(); + $categories = []; foreach ($sites as $site) { $categorie = $site->getCategorieLibelle(); if (!array_isset($categorie, $categories)) - $categories[$categorie] = array(); - $categories[$categorie] []= $site; + $categories[$categorie] = []; + $categories[$categorie][] = $site; } + return $categories; } - protected function renderSitesSlice($sites,$nb_aff) { - if(!$sites) return ""; + protected function renderSitesSlice($sites, $nb_aff) { + if (!$sites) + return ''; $sites = array_slice($sites, 0, $nb_aff); @@ -111,45 +151,39 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base return $this->renderSites($sites); $categories = $this->groupSitesByCategorie($sites); - $htmls = array(); + $htmls = []; foreach ($categories as $libelle_categorie => $sites) - $htmls []= sprintf('<li><h2><a href="#">%s</a></h2><ul><li>%s</li></ul></li>', - $libelle_categorie, - $this->renderSites($sites)); + $htmls[] = $this->_renderGroup($libelle_categorie, $sites); - return sprintf('<ul class="sitotheque">%s</ul>', - implode('', $htmls)); + return $this->_tag('ul', implode('', $htmls), + ['class' => 'sitotheque']); } - protected function renderSites($sites) { - return implode('', array_map([$this, 'renderSite'], $sites)); + protected function _renderGroup($label, $sites) { + return $this->_tag('li', + $this->_tag('h2', + $this->_tag('a', $label, ['href' => '#'])) + . $this->_tag('ul', + $this->_tag('li', $this->renderSites($sites)))); } - protected function renderSite($site) { - if($this->division == 1) { - $site->setDescription($this->extractHeader($site->getDescription())); - } - - $html = sprintf('<h2><a href="%s" title="%s">', - $site->getUrl(), - $this->translate()->_('Aller sur le site')); - - if ($img_url = $this->getThumbnail($site->getUrl())) - $html.= sprintf('<img src="%s" alt="%s" />',$img_url, $this->translate()->_('vignette du site %s', $site->getTitre())); + protected function renderSites($sites) { + return implode('', array_map([$this, 'renderSiteDiv'], $sites)); + } - $html .= $site->getTitre().'</a></h2>'; - $html .= $site->getDescription(); - return '<div class="sitotheque">'.$html.'</div>'; + protected function renderSiteDiv($site) { + return $this->_tag('div', $this->renderSite($site), + ['class' => 'sitotheque']); } - public function getThumbnail($url) { - if (!isset($this->thumbnails_helper)) - $this->thumbnails_helper = (new ZendAfi_View_Helper_WebThumbnail()) - ->setView($this->view); - return $this->thumbnails_helper->webThumbnail($url); + protected function renderSite($site) { + if ($this->division == 1) + $site->setDescription($this->extractHeader($site->getDescription())); + + return $this->sitotree_helper->renderSite($site); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Admin/ComboCatalogue.php b/library/ZendAfi/View/Helper/Admin/ComboCatalogue.php index 7ec98c03b2480323ce98a02f1189c4259b212d2f..107d8dcb12ee0b0cd00ec897f5b97328b8aa7ef7 100644 --- a/library/ZendAfi/View/Helper/Admin/ComboCatalogue.php +++ b/library/ZendAfi/View/Helper/Admin/ComboCatalogue.php @@ -16,47 +16,55 @@ * * 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_Admin_ComboCatalogue extends ZendAfi_View_Helper_BaseHelper { - protected $_selected_catalogue; - - public function comboCatalogue($catalogue) { - $this->_selected_catalogue = $catalogue; + protected $_selected, $_display_closure; - return sprintf('<select name="parent_id" id="parent_id"><option value=""></option>%s</select>', - $this->_getAllCatalogues()); + public function comboCatalogue($selected, $display_closure=null) { + $this->_selected = $selected; + $this->_display_closure = $display_closure; + + return $this->_tag('select', + $this->_tag('option', '', ['value' => '']) + . $this->_getAllCatalogues(), + ['name' => 'parent_id', 'id' => 'parent_id']); } public function _getAllCatalogues() { - $root_catalogues = Class_Catalogue::findTopCatalogues(); - $html = ''; + return $this->_getCatalogs(Class_Catalogue::findTopCatalogues()); + } - foreach($root_catalogues as $catalogue) - $html .= $this->_getLeveledCatalogueOption($catalogue); + protected function _getCatalogs($catalogs, $level=0) { + $html = ''; + foreach($catalogs as $catalog) + $html .= $this->_getLeveledOption($catalog, $level); return $html; } - protected function _getLeveledCatalogueOption($catalogue, $level = 0) { - if ($catalogue->getId() == $this->_selected_catalogue->getId()) + protected function _getLeveledOption($catalog, $level = 0) { + if ($this->_selected + && $catalog->getId() == $this->_selected->getId()) return ''; - $prefix = str_repeat(' ', $level*2); - $html = '<option value="' . $catalogue->getId() . '"' - . (($catalogue->getId() == $this->_selected_catalogue->getParentId()) ? ' selected="selected"' : '') . '>' - . $prefix . $catalogue->getLibelle() . '</option>'; + if (($closure = $this->_display_closure) + && !$closure($catalog)) + return ''; - foreach ($catalogue->getSousDomaines() as $sub_catalogue) { - $html .= $this->_getLeveledCatalogueOption($sub_catalogue,$level+1); - } + $attribs = ['value' => $catalog->getId()]; + if ($this->_selected && $catalog->getId() == $this->_selected->getParentId()) + $attribs['selected'] = 'selected'; - return $html; - } + $html = $this->_tag('option', + str_repeat(' ', $level*2) . $catalog->getLibelle(), + $attribs); + return $html . $this->_getCatalogs($catalog->getSousDomaines(), $level + 1); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Admin/HelpLink.php b/library/ZendAfi/View/Helper/Admin/HelpLink.php index 2d8887c10276c21ab1c7affae54ef8fea8991eef..8e636ece5b633249af07be040b61f292551a8bd3 100644 --- a/library/ZendAfi/View/Helper/Admin/HelpLink.php +++ b/library/ZendAfi/View/Helper/Admin/HelpLink.php @@ -131,14 +131,12 @@ class ZendAfi_View_Helper_Admin_HelpLinkBokehWiki protected $_pattern = 'http://wiki.bokeh-library-portal.org/index.php/%s'; protected $_mapping = - [ - 'modules' => ['recherche_viewnotice' => 'Affichage_d%27une_notice'], - 'catalogue' => ['index' => 'Gestions_des_domaines'], - 'profil' => [ - 'index' => 'Configurer_un_profil', - 'menusindex' => 'Configurer_un_menu', - ] - ]; + ['modules' => ['recherche_viewnotice' => 'Affichage_d%27une_notice'], + 'catalogue' => ['index' => 'Gestions_des_domaines'], + 'profil' => ['index' => 'Configurer_un_profil', + 'menusindex' => 'Configurer_un_menu'], + 'accueil' => ['critiques' => 'Boite_Critiques'], + 'harvest' => ['jamendo-browse' => 'Jamendo']]; } ?> diff --git a/library/ZendAfi/View/Helper/Admin/ListViewMode.php b/library/ZendAfi/View/Helper/Admin/ListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..b8a5e1d287822245dd9fb35ca13feceda892dde0 --- /dev/null +++ b/library/ZendAfi/View/Helper/Admin/ListViewMode.php @@ -0,0 +1,160 @@ +<?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_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHelper { + protected $_list; + + public function admin_listViewMode($list) { + if(!$this->_list = $list) + return ''; + + $html = $this->getSearchFormHTML() + . $this->getBreadcrumbHTML() + . $this->getCategoriesHTML() + . $this->getItemsHTML() + . $this->getItemsPaginatorHTML(); + + return $html; + } + + + + protected function getSearchFormHTML() { + if (!$this->_list->isSearchEnabled()) + return ''; + + $url = $this->view->url($this->_list->getSearchUrl(), null, true); + $submit = "$('#list_search_form').submit(function(event) {event.preventDefault(); event.stopImmediatePropagation(); var search = $('#list_title_search').val();var url = '". $url ."' + search; document.location.href = url;});"; + + $search_input = $this->_tag('input', '', + ['type' => 'text', + 'name' => 'title_search', + 'id' => 'list_title_search', + 'placeholder' => $this->_('titre du document'), + 'value' => $this->_list->getSearchValue()]); + + Class_ScriptLoader::getInstance()->addJQueryReady($submit); + + $search_button = $this->_tag('button', $this->_('Filtrer'), + ['id' => 'list_filter_button']); + + return $this->_tag('form', $search_input . $search_button, + ['style' => 'text-align: right;', + 'id' => 'list_search_form']); + } + + + protected function getBreadcrumbHTML() { + $html = $this->getBreadcrumbHTMLFor($this->_list->getBreadcrumb()) + . ' ' + . $this->view->modelActions($this->_list->getDefaultModel(), $this->getCategoriesActions($this->_list->getModel()), true); + return $this->_tag('div', $html, + ['style' => 'font-size:140%;']); + } + + + protected function getBreadcrumbHTMLFor($breadcrumb) { + $breadcrumb_html = []; + + foreach($breadcrumb as $loc) { + $breadcrumb_html[] = $this->view->tagAnchor($this->view->url($loc['url'], null, true), + $loc['label'], + $loc['options']); + } + + return implode(' > ',$breadcrumb_html); + } + + + protected function getCategoriesHTML() { + if ($this->_list->getSearchValue()) + return ''; + + $labelWithCount = function($model, $attrib) { + return $this->_renderCategory($model, $attrib); + }; + + return $this->view + ->tagModelTable($this->_list->getCategories(), + $this->_list->getCategoriesCols(), + $this->_list->getCategoriesAttribs(), + [function($model) { + return $this->view->modelActions($model, $this->getCategoriesActions($model));}], + $this->_list->getCategoriesId(), + $this->_list->getCategoriesGroupBy(), + [$this->_list->getCategoriesLabelAttrib() => $labelWithCount]); + } + + + protected function _renderCategory($model, $attrib) { + $url = $this->view->url(array_merge($this->_list->getBaseUrl(), + ['action' => 'index', + $this->_list->getParamKey() => $model->getId()]), + null, true); + + $label = $this->view->tagImg(URL_ADMIN_IMG . 'ico/cat.gif') + . $model->$attrib; + + if ($this->_list->isCountEnabled()) + $label .= ' (' . $this->_list->countItemsInTreeFrom($model) . ')'; + + return $this->view->tagAnchor($url, $label); + } + + + protected function getItemsHTML() { + if (!$this->_list->getModel() && !$this->_list->getSearchValue()) + return ''; + + $labelWithBreadcrumb = function($model, $attrib) { + return $this->_tag('span', $model->$attrib) + . $this->_tag('p', + $this->getBreadcrumbHTMLFor($this->_list->getBreadcrumbFor($this->_list->getCategoryFor($model))), + ['style' => 'font-size:0.9em;']); + }; + + return $this + ->view->tagModelTable($this->_list->getItems(), + $this->_list->getItemsCols(), + $this->_list->getItemsAttribs(), + [function($model) { + return $this->view->modelActions($model, $this->getItemsActions($model));}], + $this->_list->getItemsId(), + $this->_list->getItemsGroupBy(), + $this->_list->getSearchValue() ? [$this->_list->getItemsLabelAttrib() => $labelWithBreadcrumb] : []); + } + + + protected function getItemsPaginatorHTML() { + return $this->view->paginationControl($this->_list->getItemsPaginator()); + } + + + protected function getCategoriesActions($model) { + return $this->view->categoriesActions($model, $this->_list->getStrategyLabel()); + } + + + protected function getItemsActions($model) { + return $this->view->itemsActions($model, $this->_list->getStrategyLabel()); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php index c1468515d46272e58c82b8bda41a55367afaf66e..be97611682be6a39fe22a32a0eca0ba023f34ca0 100644 --- a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php +++ b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php @@ -122,10 +122,14 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdmin extends ZendAfi_View_Helper_Base .$this->addMenu("numeriquepremium_16.png", $this->translate()->_("Numérique Premium"), "/admin/harvest/numerique-premium-browse", Class_AdminVar::isNumeriquePremiumEnabled() && $this->filterAdmin($this->user)) + .$this->addMenu("oai_16.png", $this->translate()->_("Numilog"), "/admin/harvest/numilog-browse", Class_AdminVar::isNumilogEnabled() && $this->filterAdmin($this->user)) + .$this->addMenu("jamendo_16.png", $this->translate()->_("Jamendo"), "/admin/harvest/jamendo-browse", + Class_AdminVar::isJamendoEnabled()) + /* disabled until interactive harvesting is implemented .$this->addMenu("oai_16.png", $this->translate()->_("Cyberlibris"), "/admin/harvest/cyberlibris-browse", Class_AdminVar::isCyberlibrisEnabled() diff --git a/library/ZendAfi/View/Helper/Admin/TagSelectionChamps.php b/library/ZendAfi/View/Helper/Admin/TagSelectionChamps.php index f6a5b0b3ec51a9b9976dff58e05b4a2bbee5f636..2e13a1e35a1e877a32d5b8c64373e6c4e66551dd 100644 --- a/library/ZendAfi/View/Helper/Admin/TagSelectionChamps.php +++ b/library/ZendAfi/View/Helper/Admin/TagSelectionChamps.php @@ -74,7 +74,9 @@ class ZendAfi_View_Helper_Admin_TagSelectionChamps extends ZendAfi_View_Helper_B foreach ($rubriques_selectionnees as $rubrique_facette) { $code_facette=$rubrique_facette->getCode(); - $nom_facette= $rubrique_facette->getLibelle();//Class_Codification::getInstance()->getNomChamp($code_facette); + $nom_facette= $rubrique_facette->getLibelle(); + if ($nom_facette=='') + continue; $bloc.='<div class="drag_item" id="'.$rubrique.'_box_'.$code_facette.'" code="'.$code_facette.'">'.$nom_facette.'</div>'; } diff --git a/library/ZendAfi/View/Helper/Album/Download.php b/library/ZendAfi/View/Helper/Album/Download.php index 9b585919e0e8c821adc127b70d2c7c6d3a1cd749..59fcab856c0e6f509aa98f27f729d27e733409f8 100644 --- a/library/ZendAfi/View/Helper/Album/Download.php +++ b/library/ZendAfi/View/Helper/Album/Download.php @@ -16,31 +16,29 @@ * * 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_Album_Download extends Zend_View_Helper_HtmlElement { public function album_Download($album){ - - - $podcast_url = $this->view->url(['module' => 'opac', + $podcast_url = $this->view->url(['module' => 'opac', 'controller' => 'bib-numerique', - 'action' => 'album-rss-feed', + 'action' => 'album-rss-feed', 'id' => $album->getId()],null,true); return '<ul>' - .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($this->getXspfUrl($album).'.xspf'), + .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($this->getXspfUrl($album).'.xspf'), $this->view->_('Téléchargez la playlist (VLC, WinAmp)'), ['data-ajax' => 'false']).'</li>' - .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($podcast_url.'.xml'), + .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($podcast_url.'.xml'), $this->view->_('Podcastez l\'album (iTunes, Lecteur RSS)'), ['data-ajax' => 'false']).'</li>' .'</ul>'; } public function getXspfUrl($album) { - return $this->view->url(['module' => 'opac', + return $this->view->url(['module' => 'opac', 'controller' => 'bib-numerique', - 'action' => 'album-xspf-playlist', + 'action' => 'album-xspf-playlist', 'id' => $album->getId()],null,true); } } diff --git a/library/ZendAfi/View/Helper/Album/PlayRessourceUrl.php b/library/ZendAfi/View/Helper/Album/PlayRessourceUrl.php index 9facbf626ad99d0de664e767566640c2a6936e80..fb0e26014646d823e96635f3edbc45ccea7cf5fb 100644 --- a/library/ZendAfi/View/Helper/Album/PlayRessourceUrl.php +++ b/library/ZendAfi/View/Helper/Album/PlayRessourceUrl.php @@ -16,15 +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_Album_PlayRessourceUrl extends Zend_View_Helper_Abstract { public function album_PlayRessourceUrl($ressource) { + if ($ressource->getAlbum()->isAudioRecord() && $ressource->getUrl()) + return $ressource->getUrl(); + $extension = $ressource->getFileExtension(); if (!$extension && $ressource->hasUrl()) return $this->view->absoluteUrl($ressource->getOriginalUrl()); - + return $this->view->absoluteUrl('/bib-numerique/play-ressource/id/'.$ressource->getId(),null,true).'.'.$extension; } } diff --git a/library/ZendAfi/View/Helper/AlbumAudioJsPlayer.php b/library/ZendAfi/View/Helper/AlbumAudioJsPlayer.php index 84969b58d857b0750b9f64077da49affe4eb7557..cbcfc8b39c1df55a0bb72e75cd8a7a4e71fd8446 100644 --- a/library/ZendAfi/View/Helper/AlbumAudioJsPlayer.php +++ b/library/ZendAfi/View/Helper/AlbumAudioJsPlayer.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 */ @@ -58,10 +58,10 @@ $(function() { audio.load(first); // Load in a track on click - $("ol li.audio_track").click(function(e) { + $("ol li.audio_track a:first-child").click(function(e) { e.preventDefault(); - $(this).addClass("playing").siblings().removeClass("playing"); - audio.load($("a", this).attr("data-src")); + $(this).closest("li").addClass("playing").siblings().removeClass("playing"); + audio.load($(this).attr("data-src")); audio.play(); }); @@ -69,14 +69,14 @@ $(function() { e.preventDefault(); var prev = $("li.playing").prev(); if (!prev.length) prev = $("ol li.audio_track").last(); - prev.click(); + prev.find("a:first-child").click(); }); $(".audio_tracks_control .next").click(function(e) { e.preventDefault(); var next = $("li.playing").next(); if (!next.length) next = $("ol li.audio_track").first(); - next.click(); + next.find("a:first-child").click(); }); });'); @@ -85,13 +85,13 @@ $(function() { protected function renderAudioControl() { - return - $this->tag('audio', '', ['preload' => 'preload']) . - $this->tag('div', - $this->tag('a', '<< '. $this->_('Piste précédente'), - ['href' => '#', 'class' => 'previous']) . - $this->tag('a', $this->_('Piste suivante') . ' >>', - ['href' => '#', 'class' => 'next']), + return + $this->tag('audio', '', ['preload' => 'preload']) . + $this->tag('div', + $this->tag('a', '<< '. $this->_('Piste précédente'), + ['href' => '#', 'class' => 'previous']) . + $this->tag('a', $this->_('Piste suivante') . ' >>', + ['href' => '#', 'class' => 'next']), ['class' => 'audio_tracks_control']); } @@ -106,11 +106,29 @@ $(function() { protected function renderTrack($track) { return $this->tag( - 'li', - $this->tag('a', $this->view->albumRessourceInfos($track), - ['href' => '#', - 'data-src' => $this->view->album_PlayRessourceUrl($track)]), - ['class' => 'audio_track']); + 'li', + $this->tag('a', + $this->view->albumRessourceInfos($track), + ['href' => '#', + 'data-src' => $this->view->album_PlayRessourceUrl($track)]) + . $this->renderLicense($track), + ['class' => 'audio_track']); + } + + + protected function renderLicense($track) { + if (!$license = $track->getLicense()) + return ''; + + $cc_icon = strtolower(explode('/', $license)[0]).'.png'; + return $this->tag('a', + $this->tag('img', + '', + ['src' => URL_SHARED_IMG.'/cc/'.$cc_icon, + 'height' => '15px', + 'style' => 'vertical-align:middle; margin-left: 10px']), + ['href' => 'http://creativecommons.org/licenses/'.strtolower($license).'/deed.fr', + 'target' => '_blank']); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php b/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php index 1fd44145f0d1c35d90f283a2ae0f0fab2553548c..10f195ea79052f44a8e535adf20ab0e491c5420e 100644 --- a/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php +++ b/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php @@ -16,30 +16,27 @@ * * 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_Article_FormulairesCsvVisitor extends Zend_View_Helper_Json { public function article_formulairesCsvVisitor($article) { - $filename = PATH_TEMP.'formulaires.csv'; - $fp_csv = fopen($filename, 'w'); + $fp_csv = fopen('php://memory', 'r+'); $formulaires = $article->getFormulaires(); $data_names = Class_Formulaire::mergeDataNames($formulaires); fputcsv($fp_csv, array_merge(['date_creation', 'compte', 'libelle_bib'], $data_names),';'); foreach($formulaires as $formulaire) { - $datas = [$formulaire->getDateCreation(), - $formulaire->getCompte(), + $datas = [$formulaire->getDateCreation(), + $formulaire->getCompte(), $formulaire->getLibelleBib()]; foreach($data_names as $name) $datas[]=$formulaire->getDataNamed($name); fputcsv($fp_csv, $datas,';'); } - - fclose($fp_csv); - - return file_get_contents($filename); + rewind($fp_csv); + return stream_get_contents($fp_csv); } } diff --git a/library/ZendAfi/View/Helper/Avis.php b/library/ZendAfi/View/Helper/Avis.php index 5c13d06fe3e7c6eb4c2438ba2200feaa353949ad..3495a19d9fcf2a153abe694852fecb459960af60 100644 --- a/library/ZendAfi/View/Helper/Avis.php +++ b/library/ZendAfi/View/Helper/Avis.php @@ -59,6 +59,9 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { public function avis($avis, $limit_nb_word = 0, $vignette_link_to_avis = false){ if (!$avis) return ''; + if ($limit_nb_word) + $this->setLimitNbWord($limit_nb_word); + return ($avis->isAvisNotice()) ? $this->avisNotice($avis, $limit_nb_word, $vignette_link_to_avis) : $this->avisCms($avis); @@ -66,101 +69,98 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { protected function avisCms($avis) { - $contenu_avis = $this->contenu_avis($avis); - $html = sprintf( - "<div class='critique'>". - "<h2>%s</h2>". - "%s". - "</div>", - ($article = $avis->getArticle()) - ? $this->view->tagAnchor($this->view->url(['module' => 'admin', - 'controller' => 'cms', - 'action' => 'viewcms', - 'id' => $article->getId()]), - $article->getTitre()) : '', - $contenu_avis); - return $html; + $title = ($article = $avis->getArticle()) ? + $this->view->tagAnchor($this->view->url(['module' => 'admin', + 'controller' => 'cms', + 'action' => 'viewcms', + 'id' => $article->getId()]), + $article->getTitre()) : + ''; + + $content = $this->contenu_avis($avis); + + return $this + ->_tag('div', + $this->_tag('h2', $title) . $content, + ['class' => 'critique']); } - protected function avisNotice($avis, $limit_nb_word, $vignette_link_to_avis) { - $url_vignette = URL_ADMIN_IMG."supports/vignette_vide.gif"; - $titre_notice = $this->translate()->_('Oeuvre non trouvée'); - $url_notice = $this->_getUrlNotice($avis); - $url_click_vignette = $this->_getUrlClickVignette($avis); - + protected function avisNotice($avis, $vignette_link_to_avis) { + $url_vignette = URL_ADMIN_IMG . 'supports/vignette_vide.gif'; + $title = $this->_('Oeuvre non trouvée'); if (null !== $notice = $avis->getFirstNotice()) { - $titre_notice = $notice->getTitrePrincipal(); + $title = $notice->getTitrePrincipal(); if (strlen($auteur_principal = $notice->getAuteurPrincipal()) > 0) - $titre_notice = "$titre_notice ($auteur_principal)"; + $title .= ' (' . $auteur_principal . ')'; $url_vignette = $notice->fetchUrlVignette(); } - $contenu_avis = $this->contenu_avis($avis); - $html = sprintf( - "<div class='critique'>". - "<h2>%s</h2>". - "<div class='vignette_notice'>". - "<a href='%s'>". - "<img alt='%s' src='%s'/>". - "</a>". - "<a href='%s'>%s</a>". - "</div>%s". - "</div>", - $titre_notice, - $url_click_vignette, - $this->translate()->_('vignette de la notice'), $url_vignette, - $url_notice, $this->translate()->_('Voir la notice'), - $contenu_avis); - - return $html; + $content = $this->contenu_avis($avis); + + return $this-> + _tag('div', + $this->_tag('h2', $title) + . $this->_tag('div', + $this->_tag('a', $this->view->tagImg($url_vignette), + ['href' => $this->_getUrlClickVignette($avis)]) + . $this->_tag('a', $this->_('Voir la notice'), + ['href' => $this->_getUrlNotice($avis)]), + ['class' => 'vignette_notice']) + . $content, + ['class' => 'critique']); } public function contenu_avis($avis) { - $entete = $this->view->escape($avis->getEntete()); - $url_avis = $this->_getUrlAvis($avis); - $format_text_avis = $avis->getAbonOuBib() ? - ['text_avis' => $avis->getAvis(), 'lire_la_suite' => false] : - $this->_formatTextAvis($this->view->escape($avis->getAvis())); + $format_text_avis = $this->_formatTextAvis($avis); $text_avis = $format_text_avis['text_avis']; $lire_la_suite = ''; if ($format_text_avis['lire_la_suite'] == true) - $lire_la_suite = sprintf("<div class='lire_la_suite'><a href='%s'>%s</a></div>", - $url_avis, - $this->translate()->_('Lire la suite')); + $lire_la_suite = $this->_tag('div', $this->_tag('a', $this->_('Lire la suite'), + ['href' => $url_avis]), + ['class' => 'lire_la_suite']); + + $read_speaker_tag = $this->_getReadSpeakerTag($avis); + $moderation_tag = $this->_getModerationTag($avis); - $date_avis = $avis->getReadableDateAvis(); + $entete = $this->view->escape($avis->getEntete()); + $entete_tag = ('#' != $url_avis || $avis->isAvisNotice()) ? + $this->_tag('a', $entete, + ['class' => 'entete_critique', 'href' => $url_avis]) : + $entete; + + return $this-> + _tag('div', + $this->view->noteImg($avis->getNote()) + . $entete_tag + . $this->_renderAuthor($avis) + . $read_speaker_tag + . $this->_tag('p', $text_avis) + . $moderation_tag + . $lire_la_suite, + ['class' => 'contenu_critique']); + } + + protected function _renderAuthor($avis) { $auteur = $this->view->escape($avis->getUserName()); $url_auteur = $this->_url($this->_getUrlAuthor($avis)); - $read_speaker_tag = $this->_getReadSpeakerTag($avis); - $actions_tag = $this->_getActionsTag($avis); - $moderation_tag = $this->_getModerationTag($avis); - $entete_tag = ('#' != $url_avis || $avis->isAvisNotice()) - ? '<a class="entete_critique" href="'.$url_avis.'">'.$entete."</a>" - : $entete; - - $html = - "<div class='contenu_critique'>". - $this->view->noteImg($avis->getNote()). - $entete_tag . - "<span class='auteur_critique'>". - ('' != $auteur ? " <a href='$url_auteur'>$auteur</a>" : ''). - " <span>- $date_avis</span>" . $actions_tag . $this->_getAdminActionsTag($avis). - "</span>". - "$read_speaker_tag". - "<p>$text_avis</p>". - $moderation_tag. - $lire_la_suite. - "</div>"; - - return $html; + $html = '' != $auteur ? + ' ' . $this->_tag('a', $auteur, ['href' => $url_auteur]) + : ''; + + $html .= ' ' . $this->_tag('span', '- ' . $avis->getReadableDateAvis()) + . $this->_getActionsTag($avis) + . $this->_getAdminActionsTag($avis); + + return $this->_tag('span', $html, + ['class' => 'auteur_critique']); } @@ -187,7 +187,7 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { public function renderOneAvisPopup($avis) { - return '<li>' . $this->contenu_avis($avis) . '</li>'; + return $this->_tag('li', $this->contenu_avis($avis)); } @@ -198,10 +198,10 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { protected function _getModerationTag($avis) { - if ($avis->isWaitingForModeration()) - return sprintf('<div class="moderation">%s</div>', - $this->translate()->_('En attente de modération')); - return ''; + return $avis->isWaitingForModeration() ? + $this->_tag('div', $this->_('En attente de modération'), + ['class' => 'moderation']) : + ''; } @@ -211,15 +211,17 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { foreach($this->_actions as $action) { $link = $this->view->tagAnchor($this->_url(['action' => $action . $suffix, 'id' => $avis->getId()]), - $this->view->boutonIco("type=$action")); - $html_actions .= "<span rel='$action'>$link</span>"; + $this->view->boutonIco('type=' . $action)); + $html_actions .= $this->_tag('span', $link, ['rel' => $action]); } if (!$avis->isAvisNotice() && $avis->hasUserMail()) $html_actions .= $this->view->boutonIco('type=MAIL', 'mailto='.$avis->getUserMail().'?Subject='.rawurlencode($this->view->_('Avis:').' '.$avis->getEntete())); - return ($html_actions ? "<span class='actions'>$html_actions</span>" : ''); + return $html_actions ? + $this->_tag('span', $html_actions, ['class' => 'actions']) : + ''; } @@ -228,23 +230,27 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { foreach($this->_admin_actions as $action) { $link = $this->view->tagAnchor($this->_url(['controller' => 'abonne', - 'action' => $action.'avisnotice', + 'action' => $action . 'avisnotice', 'id' => $avis->getId()]), - $this->view->boutonIco("type=$action"), ['data-popup' => 'true']); - $html_actions .= "<span rel='$action'>$link</span>"; + $this->view->boutonIco('type=' .$action), + ['data-popup' => 'true']); + $html_actions .= $this->_tag('span', $link, ['rel' => $action]); } - return ($html_actions ? "<span class='actions'>$html_actions</span>" : ''); + return $html_actions ? + $this->_tag('span', $html_actions, ['class' => 'actions']) : + ''; } protected function _getUrlAvis($avis) { if (null == $avis->getId() || !$avis->isAvisNotice()) return '#'; - return $this->_url(array('module' => 'opac', - 'controller' => 'blog', - 'action' => 'viewavis', - 'id' => $avis->getId())); + + return $this->_url(['module' => 'opac', + 'controller' => 'blog', + 'action' => 'viewavis', + 'id' => $avis->getId()]); } @@ -261,34 +267,51 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { protected function _getUrlClickVignette($avis) { - if ($this->_vignette_link_to_avis) - return $this->_getUrlAvis($avis); - - return $this->_getUrlNotice($avis); + return $this->_vignette_link_to_avis ? + $this->_getUrlAvis($avis) : $this->_getUrlNotice($avis); } protected function _getReadSpeakerTag($avis) { if (null == $avis->getId()) return ''; + $read_speaker_helper = new ZendAfi_View_Helper_ReadSpeaker(); return $read_speaker_helper->readSpeaker('blog', 'readavis', - array('id' => $avis->getId())); + ['id' => $avis->getId()]); } - protected function _formatTextAvis($txt_avis) { - if (($this->_limit_nb_word <= 0) or - (count($words = explode(' ', $txt_avis)) <= $this->_limit_nb_word)) - return array('text_avis' => nl2br($txt_avis), - 'lire_la_suite' => false); + protected function _formatTextAvis($avis) { + return $avis->getAbonOuBib() ? + $this->_formatAdminText($avis) : + $this->_formatWithTruncate($this->view->escape($avis->getAvis())); + } + - $fmt_avis = implode(' ', array_slice($words, 0, $this->_limit_nb_word)); - return array('text_avis' => nl2br($fmt_avis).' [...]', - 'lire_la_suite' => true); + protected function _formatAdminText($avis) { + $value = $avis->getAvis(); + if ($this->_is_html($value) && $this->_limit_nb_word) { + $value = str_replace(['<br>', '<br/>', '<br />'], "\n", $value); + return $this->_formatWithTruncate(strip_tags($value)); + } + + return ['text_avis' => nl2br($value), 'lire_la_suite' => false]; + } + + + protected function _formatWithTruncate($txt_avis) { + if (($this->_limit_nb_word <= 0) + || count($words = explode(' ', $txt_avis)) <= $this->_limit_nb_word) + return ['text_avis' => nl2br($txt_avis), 'lire_la_suite' => false]; + + $txt_avis = implode(' ', array_slice($words, 0, $this->_limit_nb_word)); + return ['text_avis' => nl2br($txt_avis) . ' [...]', 'lire_la_suite' => true]; } -} -?> \ No newline at end of file + protected function _is_html($value) { + return preg_match('/<[^<]+>/', $value); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/BaseHelper.php b/library/ZendAfi/View/Helper/BaseHelper.php index 41aadd05f23bfa3f4573cb32c63cbbc9d844c508..5b5e2cb1ae1a1a18ae0813328d3a3cd6e6f0208c 100644 --- a/library/ZendAfi/View/Helper/BaseHelper.php +++ b/library/ZendAfi/View/Helper/BaseHelper.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_BaseHelper extends Zend_View_Helper_HtmlElement { protected static $_translate; @@ -79,6 +79,17 @@ class ZendAfi_View_Helper_BaseHelper extends Zend_View_Helper_HtmlElement { return $html; } + + protected function _tag() { + return call_user_func_array([$this->view, 'tag'], func_get_args()); + } + + + protected function _() { + return call_user_func_array([$this->view, '_'], func_get_args()); + } + + /** * @return Zend_Translate */ diff --git a/library/ZendAfi/View/Helper/Biographie.php b/library/ZendAfi/View/Helper/Biographie.php index 73730c6d385a6de12f75d1b08bee0a349325f833..2071d1496ceb8e5b87ec21f8c2e5e2f083a35fc8 100644 --- a/library/ZendAfi/View/Helper/Biographie.php +++ b/library/ZendAfi/View/Helper/Biographie.php @@ -16,20 +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_Biographie extends Zend_View_Helper_HtmlElement { - use Trait_Translator; - +class ZendAfi_View_Helper_Biographie extends ZendAfi_View_Helper_BaseHelper { public function biographie($notice) { $notice_html = new Class_NoticeHtml(); - if (!$auteur = $notice->getAuteurPrincipal()) - return $notice_html->getNonTrouve($this->view->_("Cette notice n'a pas d'auteur"),true); + if (!$auteur = $notice->getAuteurPrincipal()) + return $notice_html->getNonTrouve($this->_("Cette notice n'a pas d'auteur"),true); - if (!Class_CosmoVar::get('url_services')) - return $notice_html->getNonTrouve($this->view->_("Service non disponible")); + if (!Class_CosmoVar::get('url_services')) + return $notice_html->getNonTrouve($this->_('Service non disponible')); $args = ['auteur' => $auteur, 'clef_oeuvre' => $notice->getClefOeuvre()]; @@ -44,73 +42,145 @@ class ZendAfi_View_Helper_Biographie extends Zend_View_Helper_HtmlElement { if (!Class_Users::isCurrentUserCanAccesBackend()) return ''; - return sprintf('<a href="#" onclick="showPopWin(\'%s\', 750, 350); return false;">%s</a>', - $this->view->url(['module' => 'admin', - 'controller' => 'upload', - 'action' => 'biographie-notice', - 'id' => $notice->getId(), - ]), - $this->view->_('Modifier la biographie')); + $url = $this->view->url(['module' => 'admin', + 'controller' => 'upload', + 'action' => 'biographie-notice', + 'id' => $notice->getId()]); + + return $this->_tag('a', $this->_('Modifier la biographie'), + ['href' => $url, + 'onclick' => 'showPopWin(\'' . $url .'\', 750, 350); return false;']); } - public function renderBiographie($data,$notice) { - if(!$data["biographie"]) { + public function renderBiographie($data, $notice) { + if(!$data['biographie']) { $data['source'] = $this->_("Aucune information n'a été trouvée"); - $data["biographie"] = []; + $data['biographie'] = []; } + $source = $this->view->tag('p', $this->view->_('Source'). ' : ' . $data['source']); + $biographie = $data['biographie']; + + if(!is_array($biographie) && preg_match("/<[^<]+>/", $biographie) != 0) + return $source . $biographie; + $auteur = $notice->getAuteurPrincipal(); - $html = '<table width="100%">'; - $html.=sprintf('<tr><td class="notice_info_titre" align="left" width="100%%"><h3>%s<font size="-2"> (%s : %s)</font></h3></td></tr>', - $auteur, - $this->view->_('Source'), - $data["source"]); + $content = $this->_renderTitle($auteur, $data['source']); + $suite = false; - foreach ($data["biographie"] as $ligne) { - if(!isset($ligne["texte"])) continue; - if(isset($ligne["liste"])){ - $liste='<ul class="notice_info">'; - foreach($ligne["liste"] as $item) $liste.='<li class="notice_liste">'.$item.'</li>'; - $liste.='</ul>'; - $ligne["texte"]=str_replace("@LISTE@",$liste,$ligne["texte"]); - } - if ($suite){ - if(isset($ligne["titre"])) - $html.='<tr><td class="notice_info_titre" align="left" width="100%"><h3>'.$ligne["titre"].'</h3></td></tr>'; - - $html.='<tr><td class="notice_info" align="left" width="100%">'.$ligne["texte"].'</td></tr>'; - } - else - { - if(!$data["vignette"]) $vignette=''; - else - { - $vignette = $this->view->_('<img src="%s" style="%s" alt="%s" />', - $data["vignette"], - 'border:0;width:100px;float:left;margin-right:5px;cursor:pointer', - $this->view->_('Vignette')); - if($data["image"]) - { - $id="auteur_".$notice->getId(); - $vignette='<a id="'.$id.'" href="'.$data["image"].'" rel="lightbox" title="'.$auteur.'">'.$vignette; - $vignette.='</a>'; - $vignette.='<script type="text/javascript">$("a[id=\''.$id.'\']").slimbox({}, null, null)</script>'; - } - } - - $html.='<tr><td><table>'; - $html.='<tr><td class="notice_info">'.$vignette; - $html.=$ligne["texte"].'</td></tr>'; - $html.='</table></td></tr>'; - $suite=true; - } + + foreach ($data['biographie'] as $ligne) { + $content .= $this->_renderBio($ligne, $suite, $data, $auteur, $notice); + $suite = true; } - $html.='</table>'; - return $html; + + return $this->view->table($content, ['style' => 'width:100%']); + } + + + protected function _renderTitle($author, $source) { + $content = $author + . $this->_tag('span', + str_repeat(' ', 6) + . '(' . $this->_('Source : %s', $source) . ')', + ['style' => 'font-size:smaller']); + + return $this->_renderTitleContent($content); + } + + + protected function _renderTitleContent($content) { + return $this->_renderBioRow($this->_tag('h3', $content), 'notice_info_titre'); + } + + + protected function _renderBioText($text) { + return $this->_renderBioRow($text, 'notice_info'); + } + + + protected function _renderBioRow($content, $class) { + return $this + ->_tag('tr', + $this->_tag('td', $content, + ['class' => $class, + 'style' => 'text-align:left;width:100%'])); + } + + + protected function _renderBio($bio, $suite, $data, $auteur, $notice) { + if (!isset($bio['texte'])) + return ''; + + if (isset($bio['liste'])) + $bio['texte'] = str_replace('@LISTE@', + $this->_renderBioList($bio['liste']), + $bio['texte']); + + if ($suite) + return $this->_renderBioSuite($bio); + + $subtable = $this + ->_tag('table', + $this->_tag('tr', + $this->_tag('td', + $this->_renderVignette($bio, $data, $auteur, $notice) + . $bio['texte'], + ['class' => 'notice_info']))); + + return $this->_tag('tr', $this->_tag('td', $subtable)); + } + + + protected function _renderVignette($bio, $data, $auteur, $notice) { + if (!$data['vignette']) + return ''; + + $html = $this + ->view->tagImg($data['vignette'], + ['style' => 'border:0;width:100px;float:left;margin-right:5px;cursor:pointer', + 'alt' => $this->_('Vignette')]); + + if (!$data['image']) + return $html; + + $id = 'auteur_' . $notice->getId(); + Class_ScriptLoader::getInstance() + ->addJQueryReady('$("a[id=\''.$id.'\']").slimbox({}, null, null)'); + + return $this->_tag('a', $html, + ['id' => $id, + 'href' => $data['image'], + 'rel' => 'lightbox', + 'title' => $auteur]); + } + + + protected function _renderBioSuite($bio) { + $html = ''; + if (isset($bio['titre'])) + $html .= $this->_renderTitleContent($bio['titre']); + + return $html . $this->_renderBioText($bio['texte']); + } + + + protected function _renderBioList($list) { + return $this->_tag('ul', $this->_renderBioListItems($list), + ['class' => 'notice_info']); } + + protected function _renderBioListItems($list) { + $html = ''; + foreach($list as $item) + $html .= $this->_tag('li', $item, + ['class' => 'notice_liste']); + + return $html; + } } ?> diff --git a/library/ZendAfi/View/Helper/Calendar/Table.php b/library/ZendAfi/View/Helper/Calendar/Table.php index 2b0948df6af4b431d7f5220bcd258d6c27de5522..b62f0a5409c5ff80c6b14264e23ec266f0afde1a 100644 --- a/library/ZendAfi/View/Helper/Calendar/Table.php +++ b/library/ZendAfi/View/Helper/Calendar/Table.php @@ -183,11 +183,20 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement { protected function getTableCalendarContent($articles) { return $this->view->tag('table', - $this->getTableCalendarHeader() . $this->getTableCalendarTable($articles), + $this->getCaption($this->view->_('Calendrier')) + . $this->getTableCalendarHeader() + . $this->getTableCalendarTable($articles), ['class' => 'calendar_main']); } + protected function getCaption($summary) { + return $this->view->tag('caption', + $this->view->tag('details', + $this->view->tag('summary', $summary)), ['style' => 'display: none']); + } + + protected function getTableCalendarHeader() { $anchor_class= ['class' => 'calendar_title_month_clickable']; @@ -239,7 +248,9 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement { protected function calendarTable($articles) { return $this->view->tag('table', - $this->getCalendarTableHeaders().$this->getCalendarTableDays($articles), + $this->getCaption($this->view->_('Calendrier en jours du mois')) + . $this->getCalendarTableHeaders() + . $this->getCalendarTableDays($articles), ['class' => 'calendar_table']); } @@ -247,14 +258,14 @@ class ZendAfi_View_Helper_Calendar_Table extends Zend_View_Helper_HtmlElement { protected function getCalendarTableHeaders() { $headers=''; for ($counter = 0; $counter < 7; $counter++) { - $headers.= $this->view->tag('th', $this->WEEK_DAYS[(1 + $counter) % 7]); + $headers.= $this->view->tag('th', $this->WEEK_DAYS[(1 + $counter) % 7], ['scope' => 'col']); } return $this->view->tag('tr', $headers); } protected function getCalendarTableDays($articles) { - $html=''; + $html = ''; $first_month_day = gmmktime(0, 0, 0, $this->month, 1, $this->year); $offset = (7 - (1 % 7 - gmdate("w", $first_month_day))) % 7; $current_day = $first_month_day - 3600 * 24 * $offset; diff --git a/library/ZendAfi/View/Helper/CategoriesActions.php b/library/ZendAfi/View/Helper/CategoriesActions.php new file mode 100644 index 0000000000000000000000000000000000000000..6bfbb5cc7141189f88edc3e2e876cb1afd9a4fc0 --- /dev/null +++ b/library/ZendAfi/View/Helper/CategoriesActions.php @@ -0,0 +1,37 @@ +<?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_CategoriesActions extends Zend_View_Helper_Abstract { + public function categoriesActions($model, $strategy) { + if('album' == $strategy) + return (new ZendAfi_View_Helper_ModelActionsTable_AlbumCategories($this->view, $model))->getActions(); + + if(('article' == $strategy && !$model) || ('bib' == $strategy && $model)) + return (new ZendAfi_View_Helper_ModelActionsTable_Bib($this->view, $model))->getActions(); + + if('article' == $strategy) + return (new ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories($this->view, $model))->getActions(); + + return ''; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/CkEditor.php b/library/ZendAfi/View/Helper/CkEditor.php index 35b02fee9dcb21577c12342a8bbe7eb69c5b61a4..3ad429c998e848f61d792a67605bdbe12c2b2e18 100644 --- a/library/ZendAfi/View/Helper/CkEditor.php +++ b/library/ZendAfi/View/Helper/CkEditor.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ include_once(CKBASEPATH . "ckeditor.php"); @@ -73,6 +73,10 @@ class ZendAfi_View_Helper_CkEditor extends ZendAfi_View_Helper_BaseHelper 'styles' => '*' ] ]; + if (($user = Class_Users::getIdentity()) ? $user->isBibliothecaire():false) { + $config['allowedContent']=true; + $config['autoParagraph'] = false; + } if (Class_AdminVar::isCmsFormulairesEnabled()) { $config['toolbar'][]=['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField']; @@ -86,7 +90,7 @@ class ZendAfi_View_Helper_CkEditor extends ZendAfi_View_Helper_BaseHelper $config['extraPlugins'] = 'colordialog'; - + $oCKeditor = new CKeditor(CKBASEURL); $oCKeditor->returnOutput = true; return $oCKeditor->editor($editorId, $initial, $config); diff --git a/library/ZendAfi/View/Helper/ComboProfils.php b/library/ZendAfi/View/Helper/ComboProfils.php index 195bfcad7ce63175f76d0af241b04287d798953b..7bebe4b3387f28ef7fcce380f1831fb85fa8e258 100644 --- a/library/ZendAfi/View/Helper/ComboProfils.php +++ b/library/ZendAfi/View/Helper/ComboProfils.php @@ -1,4 +1,4 @@ -<?php +<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -16,11 +16,11 @@ * * 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_ComboProfils extends ZendAfi_View_Helper_BaseHelper { - protected + protected $_select_profil_id, $_select_id = 'select_clef_profil', $_select_name = 'clef_profil', @@ -28,7 +28,7 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { $_id_zone, $_id_bib; - public function comboProfils($id_zone='ALL', $id_bib='ALL', $id_profil=1, + public function comboProfils($id_zone='ALL', $id_bib='ALL', $id_profil=1, $autoload=false, $empty_option=false) { $this->_select_profil_id = $id_profil; if ($empty_option) @@ -72,8 +72,8 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { $content = '<option value=""></option>' . $content; $extra = ''; - if ($autoload) - $extra = ' onchange="window.location=\''.BASE_URL.'?id_profil=\' + this.value"'; + if ($autoload) + $extra = ' onchange="window.location=\''.BASE_URL.'?id_profil=\' + this.value"'; return sprintf('<select id="%s" name="%s"%s>%s</select>', $this->_select_id, $this->_select_name, $extra, $content); @@ -85,11 +85,11 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { $this->_id_bib); $profils_by_bib = []; foreach ($profils as $profil) { - if ($profil->hasParentProfil()) + if ($profil->hasParentProfil()) continue; $libelle = ($profil->isInPortail()) ? - $this->translate()->_('Portail') : + $this->translate()->_('Portail') : $profil->getBibLibelle(); if (!array_key_exists($libelle, $profils_by_bib)) @@ -105,22 +105,22 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { public function renderBibProfils($bib, $profils) { - $html = ''; - foreach($profils as $profil) { - $libelle = $profil->getLibelle(); + $html = ''; + foreach($profils as $profil) { + $libelle = $profil->getLibelle(); - $html .= $this->renderProfilOption($profil, $libelle.': '.$this->translate()->_('Accueil')); + $html .= $this->renderProfilOption($profil, $libelle.': '.$this->translate()->_('Accueil')); - foreach ($profil->getSubProfils() as $page) - $html .= $this->renderProfilOption($page, $libelle.': '.$page->getLibelle()); - } + foreach ($profil->getSubProfils() as $page) + $html .= $this->renderProfilOption($page, $libelle.': '.$page->getLibelle()); + } - return '<optgroup label="'.htmlentities($bib).'">'.$html.'</optgroup>'; + return '<optgroup label="'.htmlentities($bib).'">'.$html.'</optgroup>'; } public function renderProfilOption($profil, $libelle) { - $selected = ($this->_select_profil_id == $profil->getId()) + $selected = ($this->_select_profil_id == $profil->getId()) ? 'selected="selected"' : ''; return '<option value="'.$profil->getId().'" '.$selected.'>'.$libelle.'</option>'; } diff --git a/library/ZendAfi/View/Helper/CosmoFacets.php b/library/ZendAfi/View/Helper/CosmoFacets.php new file mode 100644 index 0000000000000000000000000000000000000000..dd6b44e91ce08f45f95f661eee5ff4a12cde7fdc --- /dev/null +++ b/library/ZendAfi/View/Helper/CosmoFacets.php @@ -0,0 +1,117 @@ +<?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_CosmoFacets extends ZendAfi_View_Helper_CosmoEmplacement { + public function cosmoFacets($model, $display) { + $this->model = $model; + return $this->view + ->tag('div', $this->_getForm(), [ + 'class' => 'form', + 'id' => 'facet'. $model->getId(), + 'style' => 'width:600px;margin-left:20px;' + . ((!$display) ? 'display:none;': '')]); + } + + + protected function _getForm() { + return $this->view + ->tag('form', $this->_getFields(), [ + 'method' => 'post', + 'action' => $this->view->url([ + 'module' => 'cosmo', + 'controller' => 'facets', + 'action' => 'validate', + 'id' => $this->model->getId()], null, true)]); + } + + + protected function _getFields() { + return $this->view + ->tag( + 'table', + $this->_getTitle() + . $this->_getLabel() + . $this->_getHelp() + . $this->_getRules() + . $this->_getDisplay() + . $this->_getActions(), + ['class' => 'form', 'cellspacing' => 0, 'cellpadding' => 5]); + } + + + protected function _getTitle() { + return $this->view->tag('tr', $this->view->tag('th', 'Création de facettes dynamiques', [ + 'class' => 'form', 'colspan' => 2, 'align' => 'left' + ])); + } + + + protected function _getLabel() { + return $this->view->tag( + 'tr', + $this->view->tag('td', 'Libellé', [ + 'class' => 'form_first', 'align' => 'right', 'width' => '35%']) . + $this->view->tag('td', $this->view->formText('libelle_facette', $this->model->getLibelleFacette(), ['size' => 43]), ['class' => 'form_first'])); + } + + + protected function _getHelp() { + return '<tr> + <td class="form_first" align="center" colspan="2"> + <div class="commentaire">Syntaxe : zone$champ</div> + </td> + </tr>'; + } + + + protected function _getRules() { + return $this->_getSimpleInput( + 'Règles de reconnaissance', + $this->view->formTextarea('rules', $this->model->getRulesLabel(), [ + 'cols' => 40, 'rows' => 5]) + ); + } + + + protected function _getDisplay() { + return ''; + } + + protected function _getActions() { + return $this->view->tag('tr', + $this->view->tag( + 'th', + $this->view->formSubmit('facetsSubmit', 'Valider', ['class' => 'bouton']) . + ($this->model->getId() ? str_repeat(' ', 5) . + $this->view->cosmoButton( + 'Supprimer', + $this->view->url([ + 'module' => 'cosmo', + 'controller' => 'facets', + 'action' => 'delete', + 'id' => $this->model->getId()], null, true), + 'Voulez-vous vraiment supprimer cet facets ?') : ''), + ['class' => 'form', 'align' => 'center', 'colspan' => 2] + ) + ); + } +} diff --git a/library/ZendAfi/View/Helper/Division.php b/library/ZendAfi/View/Helper/Division.php index 7d55c99c3fcd25036feaf9917e9cc38708ab0c68..af3e0b2574a089286e785d217f362a1a3fbba2fd 100644 --- a/library/ZendAfi/View/Helper/Division.php +++ b/library/ZendAfi/View/Helper/Division.php @@ -89,7 +89,12 @@ class ZendAfi_View_Helper_Division extends Zend_View_Helper_HtmlElement { $width += $this->profil->getLargeurDivision3(); $marge = $this->profil->_get('marge_division'.$this->division); - $this->style = "float:left;overflow:hidden;width:".$width."px;max-width:".$width."px"; + $scale = $this->profil->_get('width_division'.$this->division.'_scale'); + $this->style = "float:left;overflow:hidden;width:".$width."%;max-width:".$width."%"; + if ($scale=="px") + $this->style = "float:left;overflow:hidden;width:".$width."px;max-width:".$width."px"; + + $this->style_inner = "padding-left:".$marge."px;padding-right:".$marge."px"; $this->barre_nav = ''; diff --git a/library/ZendAfi/View/Helper/DomainTree.php b/library/ZendAfi/View/Helper/DomainTree.php new file mode 100644 index 0000000000000000000000000000000000000000..0fdd84a5c59330ef342bd091155f1c6de9467b51 --- /dev/null +++ b/library/ZendAfi/View/Helper/DomainTree.php @@ -0,0 +1,51 @@ +<?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_DomainTree extends ZendAfi_View_Helper_BaseHelper { + protected $_truncate_at; + + public function domainTree($id, $truncate_at=null) { + $html = ''; + if (!$parent = Class_Catalogue::find((int)$id)) + return $html; + + $this->_truncate_at = $truncate_at; + foreach ($parent->getSousDomaines() as $domain) + $html .= $this->_renderDomain($domain); + + return $this->_tag('ul', $html, + ['class' => 'review-domains']); + } + + + protected function _renderDomain($domain) { + return $this + ->_tag('li', + $this->_tag('a', $domain->getLibelle(), + ['href' => $this->view->url(['controller' => 'blog', + 'action' =>'hierarchical', + 'id' => $domain->getId(), + 'start_id' => $domain->getId(), + 'truncate_at' => $this->_truncate_at], + null, true)])); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/IconeSupport.php b/library/ZendAfi/View/Helper/IconeSupport.php index 7c452ffe8e77144aa91d109479d2a990ef9ed1ea..45be7259a681d0b515b0f0bbd8cd6edf800133fb 100644 --- a/library/ZendAfi/View/Helper/IconeSupport.php +++ b/library/ZendAfi/View/Helper/IconeSupport.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_IconeSupport extends Zend_View_Helper_HtmlElement { protected $_filename_by_support = array( @@ -36,8 +36,9 @@ class ZendAfi_View_Helper_IconeSupport extends Zend_View_Helper_HtmlElement { Class_TypeDoc::OAI => 'oai.gif', Class_TypeDoc::ARTEVOD => 'artevod.png', Class_TypeDoc::VODECLIC => 'vodeclic.png', + Class_TypeDoc::JAMENDO => 'jamendo_s.png', ); - + public function iconeSupport($type_doc_id) { $type_doc = Class_TypeDoc::find($type_doc_id); return sprintf('<img class="icone_support" src="%s" alt="%s" style="border:0" title="%s" />', @@ -54,7 +55,7 @@ class ZendAfi_View_Helper_IconeSupport extends Zend_View_Helper_HtmlElement { public function urlInSkin($filename) { return URL_IMG.'supports/'.$filename; } - + public function pathInAdmin($filename) { return PATH_ADMIN_SUPPORTS.$filename; } @@ -68,11 +69,11 @@ class ZendAfi_View_Helper_IconeSupport extends Zend_View_Helper_HtmlElement { //keep format support_xxx_.gif for backward compatibility foreach(['gif', 'png'] as $extension) { $filename = 'support_'.$type_doc_id.'.'.$extension; - + if ($this->fileExists($this->pathInSkin($filename))) return $this->urlInSkin($filename); } - + //then back to new icons $filename = $this->getFileNameBySupport($type_doc_id); if ($this->fileExists($this->pathInSkin($filename))) diff --git a/library/ZendAfi/View/Helper/IframeContainer.php b/library/ZendAfi/View/Helper/IframeContainer.php index b61aabb7a5ccf5339abb077d10792531420447b1..00d2d177adace56c4051e3125aaee21c672f3f45 100644 --- a/library/ZendAfi/View/Helper/IframeContainer.php +++ b/library/ZendAfi/View/Helper/IframeContainer.php @@ -23,14 +23,14 @@ ////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_IframeContainer extends ZendAfi_View_Helper_BaseHelper { - protected $_params = array(); - protected $_src_args = array(); + protected $_params = []; + protected $_src_args = []; protected $_url; //------------------------------------------------------------------------------------------------------ // Main routine //------------------------------------------------------------------------------------------------------ - public function iframeContainer($largeur,$hauteur,$url_array,$preferences=false) { + public function iframeContainer($largeur,$hauteur,$url_array,$preferences = []) { if($preferences) { foreach($preferences as $clef => $valeur) $this->_src_args[$clef] = urlencode($valeur); @@ -39,10 +39,11 @@ class ZendAfi_View_Helper_IframeContainer extends ZendAfi_View_Helper_BaseHelper $this->_url = $this->view->url($url_array, null, true); - $this->_params = array('height' => $hauteur, - 'style' => 'border: 0px; overflow:hidden', - 'width' => $largeur, - 'scrolling' => 'no'); + $this->_params = ['height' => $hauteur, + 'style' => 'border: 0px; overflow:hidden', + 'width' => $largeur, + 'scrolling' => 'no', + 'title' => ($title = isset($preferences['titre'])) ? $title : 'iframe']; return $this->getHtml(); } diff --git a/library/ZendAfi/View/Helper/ItemsActions.php b/library/ZendAfi/View/Helper/ItemsActions.php new file mode 100644 index 0000000000000000000000000000000000000000..0de9a4b9f2920a0b0c1a83decf8725c497f0ff54 --- /dev/null +++ b/library/ZendAfi/View/Helper/ItemsActions.php @@ -0,0 +1,30 @@ +<?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_ItemsActions extends Zend_View_Helper_Abstract { + public function itemsActions($model, $strategy) { + $helper_class = 'ZendAfi_View_Helper_ModelActionsTable_'.ucfirst($strategy); + return (new $helper_class($this->view, $model))->getActions(); + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php index 1c2327d79d23584348ff1a5988ce264e17260af5..957571966f278b012b0bf26f2ce3c904720e6abc 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php @@ -16,58 +16,104 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_ListeNotices_Abstract { + protected $_read_speaker; + public function listeNotices_Vignettes($data, $preferences=[]) { + $this->loadScript(); $champs = isset($preferences['liste_codes']) ? $preferences['liste_codes'] : 'TANE'; - $read_speaker_helper = new ZendAfi_View_Helper_ReadSpeaker(); - //liste container - $html='<div class="liste_vignettes">'; - + $html = ''; foreach($data as $notice){ - // calcul url en fonction du type de doc $type_doc = $notice->getTypeDoc(); - $html.= $this->vignetteHtml($notice, $type_doc, $champs, $read_speaker_helper, $preferences); + $html .= $this->_vignetteHtml($notice, $type_doc, $champs, $preferences); } - - return $html.='</div>'; + + return $this->_tag('div', $html, ['class' => 'liste_vignettes']); } - public function vignetteHtml($notice, $type_doc,$champs, $read_speaker_helper, $preferences){ - $this->loadScript(); + protected function _vignetteHtml($notice, $type_doc, $champs, $preferences){ $url_notice = $this->view->urlNotice($notice, $preferences); - $read_speaker_tag = $read_speaker_helper->readSpeaker('recherche', - 'readnotice', ['id' => $notice->getIdNotice()]); - $html='<div class="vignette" data-id="'.$notice->getId().'">'; + $html = $this->_hold($notice) + . $this->_cart($notice) + . $this->_title($notice, $url_notice) + . $this->_author($notice, $url_notice) + . $this->_docType($notice) + . $this->_image($notice, $preferences) + . $this->_info($notice, $champs); + + return $this->_tag('div', $html, ['class' => 'vignette', + 'data-id' => $notice->getId()]); + } + + + protected function _hold($record) { + return $this->_tag('div', $this->view->Notice_LienReserver($record), + ['class' => 'vignette_lien_reserver']); + } + - $html.='<div class="vignette_lien_reserver">'.$this->view->Notice_LienReserver($notice).'</div>'; + protected function _cart($record) { + return $this->_tag('div', $this->view->tagAddToCart($record), + ['class' => 'vignette_lien_panier']); + } + + + protected function _title($record, $url) { + return $this->_tag('div', + $this->_tag('a', $record->getTitreEtSousTitre(), + ['href' => $url]) + . ' ' + . $this->_readSpeakerTagFor($record), + ['class' => 'vignette_titre']); + } - $html.='<div class="vignette_lien_panier">'.$this->view->tagAddToCart($notice).'</div>'; - $html.='<div class="vignette_titre">' - .'<a href="'.$url_notice.'">'.$notice->getTitreEtSousTitre().'</a> '.$read_speaker_tag - .'</div>'; + protected function _author($record, $url) { + $author = $record->getAuteurPrincipal() ? + $this->_tag('a', $record->getAuteurPrincipal(), ['href' => $url]) : ''; - $html.='<div class="vignette_auteur"><a href="'.$url_notice.'">'.$notice->getAuteurPrincipal().'</a></div>'; + return $this->_tag('div', $author, ['class' => 'vignette_auteur']); + } - $html.= '<div class="vignette_support">'.$this->view->iconeSupport($type_doc).'<div>'.Class_Codification::getInstance()->getLibelleFacette("T".$type_doc).'</div></div>'; - //image container - $html.='<div class="vignette_img">'.$this->view->notice_Vignette($notice, $preferences).'</div>'; + protected function _docType($record) { + $type_doc = $record->getTypeDoc(); + $icon = $this->view->iconeSupport($type_doc); + $label = Class_Codification::getInstance()->getLibelleFacette('T'.$type_doc); + return $this->_tag('div', $icon . $this->_tag('div', $label), + ['class' => 'vignette_support']); + } - $html.='<div class="vignette_info">'; - $html.= $this->view->notice_Entete($notice, - ['entete' => str_replace('T', '', $champs)]); + + protected function _image($record, $preferences) { + return $this->_tag('div', $this->view->notice_Vignette($record, $preferences), + ['class' => 'vignette_img']); + } + + + protected function _info($record, $fields) { + return $this + ->_tag('div', + $this->view->notice_Entete($record, + ['entete' => str_replace('T', '', $fields)]), + ['class' => 'vignette_info']); + } - $html.='</div>'; + protected function _readSpeakerTagFor($record) { + if (!$this->_read_speaker) + $this->_read_speaker = new ZendAfi_View_Helper_ReadSpeaker(); - return $html.='</div>'; + return $this->_read_speaker->readSpeaker('recherche', 'readnotice', + ['id' => $record->getId()]); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Menu/Entry.php b/library/ZendAfi/View/Helper/Menu/Entry.php index 947e2b8926c9a9087f2646b42d9cac91af49bdf7..654363aa19344078a6c6e7eb054ae238dffef759 100644 --- a/library/ZendAfi/View/Helper/Menu/Entry.php +++ b/library/ZendAfi/View/Helper/Menu/Entry.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_Menu_Entry extends ZendAfi_View_Helper_Menu_Base { @@ -36,18 +36,18 @@ class ZendAfi_View_Helper_Menu_Entry extends ZendAfi_View_Helper_Menu_Base { public function getBoite($li_class = '') { $html = $this->getTagAnchor(); - + if ($this->_sous_menus) { $helper = new ZendAfi_View_Helper_Menu_SousMenus($this->_sous_menus); $helper->setView($this->view); $helper->setIdMenu($this->_id_menu); $html .= $helper->getBoite(); } - - $li_class.= strpos($html,'selected_profil')>0 ? + + $li_class.= strpos($html,'selected_profil')>0 ? ' selected_profil' :''; - - return $li_class + + return $li_class ? '<li class="'.$li_class.'">'.$html.'</li>' : '<li>'.$html.'</li>'; } @@ -59,16 +59,16 @@ class ZendAfi_View_Helper_Menu_Entry extends ZendAfi_View_Helper_Menu_Base { $url = $params['url']; $img_URL = URL_IMG.'menus/'; - - $target = $params['target'] + + $target = $params['target'] ? "target='".$params['target']."'" : ''; $anchor='<a href="'.htmlspecialchars($url).'" '.$target.'>'; - + if($this->_picto > '' and $this->_picto != "vide.gif") { $anchor.= $this->view->tagImgHover($img_URL.$this->_picto, - ['alt' => 'pictogramme pour '.$this->_libelle]); + ['alt' => 'pictogramme '.$this->_libelle]); } $anchor.=$this->_preferences["libelle"].'</a>'; diff --git a/library/ZendAfi/View/Helper/Menu/Profil.php b/library/ZendAfi/View/Helper/Menu/Profil.php index c759646e3562a785943f9234ee972309a32b14dc..40e14574e356e4155cd38844144a6bba8e77fc77 100644 --- a/library/ZendAfi/View/Helper/Menu/Profil.php +++ b/library/ZendAfi/View/Helper/Menu/Profil.php @@ -16,14 +16,15 @@ * * 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_Menu_Profil extends ZendAfi_View_Helper_Menu_Entry { public function getBoite($li_class = '') { - return (Class_Profil::getCurrentProfil()->getId() == (int)$this->_preferences['clef_profil']) - ? parent::getBoite(trim($li_class.' selected_profil')) - : parent::getBoite($li_class); + if (isset($this->_preferences['clef_profil']) && + (Class_Profil::getCurrentProfil()->getId() == (int)$this->_preferences['clef_profil'])) + return parent::getBoite(trim($li_class.' selected_profil')); + return parent::getBoite($li_class); } } diff --git a/library/ZendAfi/View/Helper/ModelActions.php b/library/ZendAfi/View/Helper/ModelActions.php index ca91c5852dbf30139d6138ba09c8a4d250536b00..2bb5ed516ed7b651fc44af4b035dda8a540a61b2 100644 --- a/library/ZendAfi/View/Helper/ModelActions.php +++ b/library/ZendAfi/View/Helper/ModelActions.php @@ -64,7 +64,7 @@ class ZendAfi_View_Helper_ModelAction { $caption = array_key_exists(self::CAPTION, $this->_conf) ? $model->{$this->_conf[self::CAPTION]}() : ''; - $url = sprintf($this->_conf[self::URL], $model->getId()); + $url = str_replace('%s', $model->getId(), $this->_conf[self::URL]); $icon = $this->_initIcon($model); $anchorOptions = $this->_initAnchorOptions(); diff --git a/library/ZendAfi/View/Helper/ModelActionsTable.php b/library/ZendAfi/View/Helper/ModelActionsTable.php new file mode 100644 index 0000000000000000000000000000000000000000..c4f6a835bccb0296cbe2300b07c7be51aa052c9c --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_ModelActionsTable { + use Trait_Translator; + + protected $view, + $_model; + + + public function __construct($view, $model) { + $this->view = $view; + $this->_model = $model; + } + + + public function setActions($actions) { + $actions = array_map(function($element) { return $element; }, $actions); + $actions = array_map(function($element) { $element['label'] = $this->view->_($element['label']); return $element; }, $actions); + return $actions; + } + + + protected function _getUrlForAction($action, $reset = false) { + return $this->_getUrlFor('', $action, 'id', $reset); + } + + + protected function _getUrlFor($controller = '', $action = '', $id_key = 'id', $reset = false) { + return $this->view->url(array_merge($this->getBaseUrl(), + array_filter(['controller'=> $controller, + 'action' => $action, + $id_key => ''])), null, $reset) + . '/' . $id_key . '/%s'; + } + + + protected function _getUrlForActionAndIdName($action, $id_key = '') { + return $this->_getUrlFor('', $action, $id_key); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Album.php b/library/ZendAfi/View/Helper/ModelActionsTable/Album.php new file mode 100644 index 0000000000000000000000000000000000000000..bff5f2d0415146e6e776009e0ec0f4962ef30293 --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable/Album.php @@ -0,0 +1,52 @@ +<?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_ModelActionsTable_Album extends ZendAfi_View_Helper_ModelActionsTable { + + protected function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'album']; + } + + + public function getActions() { + if(!$this->_model) + return []; + + $actions = [['url' => $this->_getUrlForAction('edit_album'), + 'icon' => 'ico/edit.gif', + 'label' => 'Modifier l\'album'], + ['url' => $this->_getUrlForAction('edit_images'), + 'icon' => 'ico/album_images.png', + 'label' => 'Gérer les médias', + 'caption' => 'formatedCount'], + ['url' => $this->_getUrlForAction('preview_album'), + 'icon' => function($model) {return $model->isVisible() ? 'ico/show.gif' : 'ico/hide.gif';}, + 'label' => 'Visualisation de l\album'], + ['url' => $this->_getUrlForAction('delete_album'), + 'icon' => 'ico/del.gif', + 'label' => 'Supprimer l\'album', + 'anchorOptions' => ['onclick' => 'return confirm(\'' . $this->view->_('Êtes-vous sûr de vouloir supprimer cet album') . ';\')']]]; + return $this->setActions($actions); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php b/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php new file mode 100644 index 0000000000000000000000000000000000000000..055883e2a15c53a2ebf03924c7a258896021808a --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php @@ -0,0 +1,58 @@ +<?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_ModelActionsTable_AlbumCategories extends ZendAfi_View_Helper_ModelActionsTable { + protected function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'album']; + } + + + public function getActions() { + if(!$this->_model || $this->_model == Class_AlbumCategorie::defaultCategory()) + return $this->setActions([ ['url' => $this->_getUrlForAction('add_categorie'), + 'icon' => 'ico/add_cat.gif', + 'label' => 'Ajouter une sous-catégorie']]); + + $actions = Class_AdminVar::isBibNumEnabled() + ? [['url' => $this->_getUrlForAction('add_categorie_to'), + 'icon' => 'ico/add_cat.gif', + 'label' => 'Ajouter une sous-catégorie'], + + ['url' => $this->_getUrlForAction('add_album_to'), + 'icon' => 'ico/add_news.gif', + 'label' => 'Ajouter un album']] + : []; + + $actions = array_merge($actions, + [ ['url' => $this->_getUrlForAction('edit_categorie'), + 'icon' => 'ico/edit.gif', + 'label' => 'Modifier la catégorie'], + + ['url' => $this->_getUrlForAction('delete_categorie'), + 'icon' => 'ico/del.gif', + 'label' => 'Supprimer la catégorie', + 'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]]); + return $this->setActions($actions); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Article.php b/library/ZendAfi/View/Helper/ModelActionsTable/Article.php new file mode 100644 index 0000000000000000000000000000000000000000..4223a168529ac0f02cfe02830977b380b0e2bc1c --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable/Article.php @@ -0,0 +1,76 @@ +<?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_ModelActionsTable_Article extends ZendAfi_View_Helper_ModelActionsTable { + protected $identity; + + + protected function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'cms']; + } + + + public function getActions() { + $this->identity = Class_Users::getIdentity(); + + $permission_closure = function($model) { + return $this->identity + ->hasAnyPermissionOn($model->getCategorie(), + [Class_Permission::createArticle(), + Class_Permission::createArticleCategory()]); + }; + + $actions[] = [ + 'url' => $this->_getUrlForAction('makeinvisible'), + 'icon' => 'ico/show.gif', + 'label' => 'Rendre cet article invisible', + 'condition' => function($model) use ($permission_closure) { + return $permission_closure($model) && $model->isVisible(); + }]; + + $actions[] = [ + 'url' => $this->_getUrlForAction('makevisible'), + 'icon' => 'ico/hide.gif', + 'label' => 'Rendre cet article visible', + 'condition' => function($model) use ($permission_closure) { + return $permission_closure($model) && $model->isNotVisible(); + }]; + + $actions[] = ['url' => $this->_getUrlForAction('edit'), + 'icon' => 'ico/edit.gif', + 'label' => 'Modifier', + 'condition' => $permission_closure]; + + $actions[] = ['url' => $this->_getUrlForAction('newsduplicate'), + 'icon' => 'ico/copier.gif', + 'label' => 'Dupliquer', + 'condition' => $permission_closure]; + + $actions[] = ['url' => $this->_getUrlForAction('delete'), + 'icon' => 'ico/del.gif', + 'label' => 'Supprimer', + 'condition' => $permission_closure]; + + return $this->setActions($actions); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php b/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php new file mode 100644 index 0000000000000000000000000000000000000000..c3ce7cc3320d238a5c98b5960034f92f599e5f9d --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php @@ -0,0 +1,80 @@ +<?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_ModelActionsTable_ArticlesCategories extends ZendAfi_View_Helper_ModelActionsTable { + protected $identity; + + protected function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'cms-category']; + } + + + public function getActions() { + $this->identity = Class_Users::getIdentity(); + $parent_permission = function($model) { + return $this->identity + ->hasParentPermissionOn(Class_Permission::createArticleCategory(), + $model); + }; + + $actions[] = ['url' => $this->_getUrlForAction('edit'), + 'icon' => 'ico/edit.gif', + 'label' => 'Modifier', + 'condition' => $parent_permission]; + + $actions[] = [ + 'url' => $this->_getUrlForAction('delete'), + 'icon' => 'ico/del.gif', + 'label' => 'Supprimer', + 'condition' => function($model) use ($parent_permission) { + return $parent_permission($model) && $model->hasNoChild(); + }, + 'anchorOptions' => [ + 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]; + + + $actions[] = [ + 'url' => $this->_getUrlFor('cms', 'add', 'id_cat', true), + 'icon' => 'ico/add_news.gif', + 'label' => 'Ajouter un article', + 'condition' => function($model) { + return $this->identity + ->hasAnyPermissionOn($model, + [Class_Permission::createArticle(), + Class_Permission::createArticleCategory()]); + }]; + + $actions[] = [ + 'url' => $this->_getUrlForAction('add', true), + 'icon' => 'ico/add_cat.gif', + 'label' => 'Ajouter une sous-catégorie', + 'condition' => function($model) { + return $this->identity + ->hasPermissionOn(Class_Permission::createArticleCategory(), + $model); + }]; + + return $this->setActions($actions); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php b/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php new file mode 100644 index 0000000000000000000000000000000000000000..7b66ad4afe80bc08c0dd1c76a1937e9861c6d44c --- /dev/null +++ b/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php @@ -0,0 +1,59 @@ +<?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_ModelActionsTable_Bib extends ZendAfi_View_Helper_ModelActionsTable { + protected $_identity; + + protected function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'cms-category']; + } + + + public function getActions() { + $this->_identity = Class_Users::getIdentity(); + $actions = []; + $actions[] = ['url' => $this->_getUrlForActionAndIdName('add', 'id_bib'), + 'icon' => 'ico/add_cat.gif', + 'label' => $this->_('Ajouter une catégorie'), + 'condition' => function($model) { + return $this->_identity->isRoleMoreThanModoPortail() + || $this->_identity->hasPermissionOn(Class_Permission::createArticleCategory(), + $model); + }]; + + $actions[] = ['url' => $this->_getUrlFor('bib', 'permissions'), + 'icon' => 'picto/groupes_16.png', + 'label' => $this->_('Permissions par défaut'), + 'condition' => function($model) { + return $this->_identity->isRoleMoreThanModoPortail(); + }]; + + return $this->setActions($actions); + } + + + protected function _getUrlForAction($actions, $reset = false) { + return $actions; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModuleAbstract.php b/library/ZendAfi/View/Helper/ModuleAbstract.php index f3419b75f08ce484d2ae98c542c821fe5ac5cc2c..474d3fc75e380dbc790549985410ed156a50d2cd 100644 --- a/library/ZendAfi/View/Helper/ModuleAbstract.php +++ b/library/ZendAfi/View/Helper/ModuleAbstract.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 ZendAfi_View_Helper_ModuleAbstract extends ZendAfi_View_Helper_BaseHelper { @@ -40,6 +40,23 @@ abstract class ZendAfi_View_Helper_ModuleAbstract extends ZendAfi_View_Helper_Ba } + public function getPreference($name, $default=null) { + return array_key_exists($name, $this->preferences) ? + $this->preferences[$name] : $default; + } + + + public function setPreference($name, $value) { + $this->preferences[$name] = $value; + return $this; + } + + + public function getPreferences() { + return $this->preferences; + } + + /** * @return string le contenu au format HTML */ diff --git a/library/ZendAfi/View/Helper/Notice/Abstract.php b/library/ZendAfi/View/Helper/Notice/Abstract.php index c0aab4fb7f3e7913fbe3ddeb54085a03a4ac24af..9f3434802dd8a9fe7d11ef60fd6c6ba8fe0f9223 100644 --- a/library/ZendAfi/View/Helper/Notice/Abstract.php +++ b/library/ZendAfi/View/Helper/Notice/Abstract.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 ZendAfi_View_Helper_Notice_Abstract extends Zend_View_Helper_HtmlElement { use Trait_Translator; @@ -26,13 +26,20 @@ abstract class ZendAfi_View_Helper_Notice_Abstract extends Zend_View_Helper_Html const ONGLET = 3; - protected function getOnclick($rubrique,$isbn,$id_onglet) { - $_SESSION["onglets"][$rubrique]=$id_onglet; - return sprintf("(this.id,'%s','%s',0,'',%d, '%s')", - is_array($isbn) ? $isbn["isbn"] : $isbn, - $rubrique, + protected function getOnclick($rubrique, $notice, $id_onglet) { + return sprintf("(this.id,'%s','%s',0,'',%d, '%s')", + $notice->getIsbn(), + $rubrique, in_array($rubrique, ['avis', 'exemplaires']) ? 1 : 0, - $this->view->absoluteUrl(['controller' => 'noticeajax', 'action' => $rubrique])); + $this->view->absoluteUrl(['controller' => 'noticeajax', + 'action' => $rubrique, + 'id' => $notice->getId()])); + } + + protected function getUrl($rubrique, $notice) { + return $this->view->url(['controller' => 'noticeajax', + 'action' => $rubrique, + 'id' => $notice->getId()]); } @@ -41,7 +48,7 @@ abstract class ZendAfi_View_Helper_Notice_Abstract extends Zend_View_Helper_Html $onglets = []; foreach($preferences['onglets'] as $nom => $config) { - if (!in_array((int)$config['aff'], $aff_values)) + if (!in_array((int)$config['aff'], $aff_values)) continue; $onglet = Class_Codification::getInstance()->getOnglet($nom); @@ -53,8 +60,8 @@ abstract class ZendAfi_View_Helper_Notice_Abstract extends Zend_View_Helper_Html if ($onglet->callDisplayMethod($notice)) $onglets[] = $onglet; } - - uasort($onglets, + + uasort($onglets, function($cfg_a, $cfg_b) { return (int)$cfg_a->getOrder() - (int)$cfg_b->getOrder(); }); diff --git a/library/ZendAfi/View/Helper/Notice/Blocs.php b/library/ZendAfi/View/Helper/Notice/Blocs.php index ab2a5a68a36a346d3ada8fe97abb3c9af3014d85..6953e88cb2a98063a3ae71e264a1879ad7c58d99 100644 --- a/library/ZendAfi/View/Helper/Notice/Blocs.php +++ b/library/ZendAfi/View/Helper/Notice/Blocs.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_Notice_Blocs extends ZendAfi_View_Helper_Notice_Abstract { public function notice_Blocs($notice, $preferences) { @@ -30,12 +30,12 @@ class ZendAfi_View_Helper_Notice_Blocs extends ZendAfi_View_Helper_Notice_Abstra public function getBlocsFromPreferences($preferences, $notice) { - return $this->selectOngletsFromPreferences($preferences, - [self::BLOC_DEPLIE, self::BLOC_FERME], + return $this->selectOngletsFromPreferences($preferences, + [self::BLOC_DEPLIE, self::BLOC_FERME], $notice); } - - + + public function renderBlocsForNotice($blocs, $notice) { $id = $notice->getId(); $isbn = $notice->getIsbn(); @@ -47,19 +47,19 @@ class ZendAfi_View_Helper_Notice_Blocs extends ZendAfi_View_Helper_Notice_Abstra foreach($blocs as $bloc) { $type = $bloc->getType(); $id_bloc="bloc_".$id."_".$i++; - $js ='infos_bloc'.$this->getOnclick($type, $isbn, $id_bloc); + $js ='infos_bloc'.$this->getOnclick($type, $notice, $id_bloc); if ((int)$bloc->getDisplayMode()==1) Class_ScriptLoader::getInstance() ->addJQueryReady('infos_bloc'. str_replace('this.id', '"'.$id_bloc.'"', - $this->getOnclick($type, $isbn, $id_bloc))); + $this->getOnclick($type, $notice, $id_bloc))); Class_ScriptLoader::getInstance() ->addJQueryReady('$("#'.$id_bloc.'").click(function(){'.$js.'})'); // Titre - $html.='<div class="'.$type.' block_info_notice">'; + $html.='<div class="'.$type.' block_info_notice">'; $html.='<div id="'.$id_bloc.'" class="notice_bloc_titre"><img id="I'.$id_bloc.'" src="'.URL_IMG.'bouton/plus_carre.gif" alt="Déplier" /><h2>'.$bloc->getLibelle().'</h2></div>'; $html.='<div id="'.$id_bloc.'_contenu_row"></div>'; $html.= '<div id="'.$id_bloc.'_contenu" class="notice_bloc">'; @@ -69,7 +69,7 @@ class ZendAfi_View_Helper_Notice_Blocs extends ZendAfi_View_Helper_Notice_Abstra $html.='</div>'; $html.='</div>'; } - + return $html; } diff --git a/library/ZendAfi/View/Helper/Notice/Entete.php b/library/ZendAfi/View/Helper/Notice/Entete.php index f5950cec9c240db40004e284ca0b5c96085d2fdd..f330ad01a731a5bea08add35fd7c6822ccd4761a 100644 --- a/library/ZendAfi/View/Helper/Notice/Entete.php +++ b/library/ZendAfi/View/Helper/Notice/Entete.php @@ -20,6 +20,9 @@ */ class ZendAfi_View_Helper_Notice_Entete extends Zend_View_Helper_HtmlElement { public function notice_Entete($notice, $preferences) { + if(!$notice) + return ''; + if (!array_isset('entete', $preferences)) return ''; diff --git a/library/ZendAfi/View/Helper/Notice/Exemplaires.php b/library/ZendAfi/View/Helper/Notice/Exemplaires.php index 98a18408c8e89db4b155541fb5734b7148c2316d..5bb31977de47bacf2cac9e784fdc8da6398952bc 100644 --- a/library/ZendAfi/View/Helper/Notice/Exemplaires.php +++ b/library/ZendAfi/View/Helper/Notice/Exemplaires.php @@ -18,8 +18,8 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_Notice_Exemplaires extends Zend_View_Helper_HtmlElement { - use Trait_Translator; + +class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper { protected $renderers = []; public function Notice_Exemplaires($exemplaires, $nb_notices_oeuvre=0, $aff="normal") { @@ -32,58 +32,72 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends Zend_View_Helper_HtmlElemen : $this->view->Notice_Exemplaires_RenderByItem($exemplaires, $preferences, $nb_notices_oeuvre, $aff); } + public function exemplairesToRows($exemplaires) { - $rows=[]; - foreach ($exemplaires as $exemplaire) { + $rows = []; + foreach ($exemplaires as $exemplaire) $rows[] = $exemplaire->toRaw() ; - } return $rows; } + public function renderExemplairesTable($exemplaires, $preferences, $aff) { - $renderers[]=$this->view->getHelper('Notice_Exemplaires_Num'); - if($preferences["bib"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Bib'); - if($preferences["annexe"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Annexe'); - if($preferences["section"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Section'); - if($preferences["emplacement"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Emplacement'); - if($preferences["grouper"]==0) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Grouper'); - $renderers[]=$this->view->getHelper('Notice_Exemplaires_Cote'); - if($preferences["dispo"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Dispo'); - if($preferences["date_retour"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_DateRetour'); - if($preferences["localisation"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Localisation'); - if($preferences["plan"]==1) $renderers[]=$this->view->getHelper('Notice_Exemplaires_Plan'); - if($preferences["resa"]==1 && $aff=="normal") $renderers[]=$this->view->getHelper('Notice_Exemplaires_Resa'); - if($aff=="oeuvre") $renderers[]=$this->view->getHelper('Notice_Exemplaires_Oeuvre'); - - - $html ='<table class="exemplaires" cellpadding="5" cellspacing="1">'; - $html.='<tr>'; - - foreach ($renderers as $renderer) { - $renderer->setExemplaires($exemplaires); - $html.=$renderer->renderHead(); - } + $renderers = $this->_getRenderers($exemplaires, $preferences, $aff); - $html.='</tr>'; + return $this->view + ->table($this->_renderHeaders($renderers) + . $this->_renderItems($exemplaires, $renderers), + ['class' => 'exemplaires', + 'summary' => $this->_('Liste des exemplaires'), + 'cellpadding' => 5, + 'cellspacing' => 1]); + } - foreach($exemplaires as $ex) { - if (!$bib=Class_Bib::find($ex["id_bib"])) - $bib=new Class_Bib(); - // html - $html.='<tr>'; + protected function _renderHeaders($renderers) { + $html = ''; + foreach ($renderers as $renderer) + $html .= $renderer->renderHead(); - foreach ($renderers as $renderer) { - $html.=$renderer->renderContent($ex); - } + return $this->_tag('tr', $html); + } + + + protected function _renderItems($items, $renderers) { + $html = ''; + foreach($items as $item) + $html .= $this->_renderItem($item, $renderers); - $html.='</tr>'; - } - $html.='</table>'; return $html; } + protected function _renderItem($item, $renderers) { + if (!$bib = Class_Bib::find($item['id_bib'])) + $bib = new Class_Bib(); + + $html =''; + foreach ($renderers as $renderer) + $html .= $renderer->renderContent($item); + + return $this->_tag('tr', $html); + } + + + protected function _getRenderers($exemplaires, $preferences, $aff) { + $renderers = []; + $names = ZendAfi_View_Helper_Notice_Exemplaires_Abstract::renderersNameFor($preferences, + $aff); + foreach($names as $name) { + $renderer = $this->view->getHelper(ZendAfi_View_Helper_Notice_Exemplaires_Abstract::NAME_PREFIX . $name); + $renderer->setExemplaires($exemplaires); + $renderers[] = $renderer; + } + + return $renderers; + } + + public function renderSameWorkLink($nb_notices_oeuvre, $id_notice) { if (!$nb_notices_oeuvre) return ''; @@ -96,20 +110,29 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends Zend_View_Helper_HtmlElemen ."});"; return - '<div class="notice_bloc_titre" onclick="'.$onclick.'">' - . sprintf('<b>%s</b>', $this->_('Afficher toutes les éditions de ce document')) - .'</div>' - . '<div class="exemplaires_oeuvre" style="display:none"><img src="'.URL_IMG.'patience.gif"></div>'; + $this->_tag('div', + $this->_tag('b', + $this->_('Afficher toutes les éditions de ce document')), + ['class' => 'notice_bloc_titre', 'onclick' => $onclick]) + + . $this->_tag('div', $this->view->tagImg(URL_IMG . 'patience.gif'), + ['class' => 'exemplaires_oeuvre', + 'style' => 'display:none']); } public function renderLocalizationMap() { return - '<div id="plan_localisation" style="display:none"></div>' - . sprintf('<div id="point_localisation" style="%s"><img src="" border="0" alt="%s" /></div>', - 'position:absolute;z-index:10000;display:none;cursor:pointer', - $this->_('Localisation')) - . '<div id="bulle_localisation" style="display:none"></div>'; + $this->_tag('div', '', + ['id' => 'plan_localisation', 'style' => 'display:none']) + + . $this->_tag('div', $this->view->tagImg('', + ['alt' => $this->_('Localisation')]), + ['id' => 'point_localisation', + 'style' => 'position:absolute;z-index:10000;display:none;cursor:pointer']) + + . $this->_tag('div', '', + ['id' => 'bulle_localisation', 'style' => 'display:none']); } @@ -142,6 +165,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends Zend_View_Helper_HtmlElemen } + class ZendAfi_View_Helper_Notice_Exemplaires_RenderByGroup extends ZendAfi_View_Helper_Notice_Exemplaires { public function Notice_Exemplaires_RenderByGroup($exemplaires, $preferences, $nb_notices_oeuvre=0, $aff="normal") { @@ -160,6 +184,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires_RenderByGroup extends ZendAfi_View_ } + class ZendAfi_View_Helper_Notice_Exemplaires_RenderByItem extends ZendAfi_View_Helper_Notice_Exemplaires { public function Notice_Exemplaires_RenderByItem($exemplaires, $preferences, $nb_notices_oeuvre=0, $aff="normal") { return $this->render((new Class_CommSigb())->getDispoExemplaires($exemplaires), @@ -170,30 +195,66 @@ class ZendAfi_View_Helper_Notice_Exemplaires_RenderByItem extends ZendAfi_View_H } -class ZendAfi_View_Helper_Notice_Exemplaires_Abstract extends Zend_View_Helper_HtmlElement { - use Trait_Translator; + +class ZendAfi_View_Helper_Notice_Exemplaires_Abstract extends ZendAfi_View_Helper_BaseHelper { + const NAME_PREFIX = 'Notice_Exemplaires_'; protected $_exemplaires; + + public static function renderersNameFor($preferences, $display_mode) { + $mapping = ['Num' => true, + 'Bib' => $preferences['bib'] == 1, + 'Annexe' => $preferences['annexe'] == 1, + 'Section' => $preferences['section'] == 1, + 'Emplacement' => $preferences['emplacement'] = 1, + 'Grouper' => $preferences['grouper'] == 0, + 'Cote' => true, + 'Dispo' => $preferences['dispo'] == 1, + 'DateRetour' => $preferences['date_retour'] == 1, + 'Localisation' => $preferences['localisation'] == 1, + 'Plan' => $preferences['plan'] == 1, + 'Resa' => $preferences['resa'] == 1 && $display_mode == 'normal', + 'Oeuvre' => $display_mode == 'oeuvre']; + + $names = array_filter($mapping); + return array_keys($names); + } + + + protected static function _isActive($preferences, $name) { + return isset($preferences[$name]) && 1 == $preferences[$name]; + } + + public function setExemplaires($exemplaires) { - $this->_exemplaires=$exemplaires; + $this->_exemplaires = $exemplaires; } + + public function renderHead() { - return '<th class="'.$this->getHeadClass().'" >'.$this->getLibelle().'</th>'; + return $this->_tag('th', $this->getLibelle(), + ['class' => $this->getHeadClass(), + 'scope' => 'col']); } + public function getHeadClass() { - $parts=explode('_',get_class($this)); + $parts = explode('_', get_class($this)); return Storm_Inflector::underscorize(end($parts)); } + public function renderContent($exemplaire) { - return '<td class="'.$this->getHeadClass().'" >'.$this->getContent($exemplaire).'</td>'; + return $this->_tag('td', $this->getContent($exemplaire), + ['class' => $this->getHeadClass()]); } + public function getContent($exemplaire) { return ''; } + public function getBib($exemplaire){ return ($bib = Class_Bib::find($exemplaire['id_bib'])) ? $bib @@ -201,17 +262,21 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Abstract extends Zend_View_Helper_H } } + + class ZendAfi_View_Helper_Notice_Exemplaires_Bib extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Bibliothèque'); } + public function getContent($exemplaire) { return $this->getBib($exemplaire)->getLibelle(); } - } + + class ZendAfi_View_Helper_Notice_Exemplaires_Annexe extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Bibliothèque'); @@ -228,6 +293,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Annexe extends ZendAfi_View_Helper_ } + + class ZendAfi_View_Helper_Notice_Exemplaires_Section extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Section'); @@ -239,6 +306,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Section extends ZendAfi_View_Helper } + + class ZendAfi_View_Helper_Notice_Exemplaires_Grouper extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Exemplaires'); @@ -250,6 +319,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Grouper extends ZendAfi_View_Helper } + + class ZendAfi_View_Helper_Notice_Exemplaires_Dispo extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Disponibilité'); @@ -297,6 +368,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Cote extends ZendAfi_View_Helper_No } } + + class ZendAfi_View_Helper_Notice_Exemplaires_DateRetour extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Retour'); @@ -309,6 +382,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires_DateRetour extends ZendAfi_View_Hel } + class ZendAfi_View_Helper_Notice_Exemplaires_Localisation extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Situer'); @@ -334,6 +408,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Localisation extends ZendAfi_View_H } + class ZendAfi_View_Helper_Notice_Exemplaires_Plan extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Plan'); @@ -356,6 +431,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Plan extends ZendAfi_View_Helper_No } + class ZendAfi_View_Helper_Notice_Exemplaires_Resa extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Réserver'); @@ -367,6 +443,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Resa extends ZendAfi_View_Helper_No } + + class ZendAfi_View_Helper_Notice_Exemplaires_Oeuvre extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Voir'); @@ -390,6 +468,8 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Oeuvre extends ZendAfi_View_Helper_ } + + class ZendAfi_View_Helper_Notice_Exemplaires_Num extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { protected $num=0; public function getLibelle() { @@ -402,6 +482,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Num extends ZendAfi_View_Helper_Not } + class ZendAfi_View_Helper_Notice_Exemplaires_Emplacement extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { public function getLibelle() { return $this->_('Emplacement'); @@ -410,11 +491,5 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Emplacement extends ZendAfi_View_He public function getContent($exemplaire) { return Class_Codification::getLibelleFacette("E".$exemplaire["emplacement"]); } - - } - - - - ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Onglets.php b/library/ZendAfi/View/Helper/Notice/Onglets.php index 5349cd6fa88e69498be8aeda77c81eec51fd0e50..8322eac79ef76f428ab06657da5f8e8354455f8a 100644 --- a/library/ZendAfi/View/Helper/Notice/Onglets.php +++ b/library/ZendAfi/View/Helper/Notice/Onglets.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_Notice_Onglets extends ZendAfi_View_Helper_Notice_Abstract { public function notice_Onglets($notice, $preferences) { @@ -34,12 +34,12 @@ class ZendAfi_View_Helper_Notice_Onglets extends ZendAfi_View_Helper_Notice_Abst public function getOngletsFromPreferences($preferences, $notice) { return $this->selectOngletsFromPreferences($preferences, [self::ONGLET], $notice); } - - + + public function renderOngletsForNotice($onglets, $notice) { $id = $notice->getId(); $isbn = $notice->getIsbn(); - + // Html du set $tag_patience ='<div class="notice_patience" style="text-align:right;width:15px"><img src="'.URL_IMG.'patience.gif" alt="'.$this->_('Chargement en cours').'" /></div>'; $tag_patience.='<div class="notice_patience">'.$this->_translate->_('Veuillez patienter : lecture en cours...').'</div>'; @@ -51,27 +51,26 @@ class ZendAfi_View_Helper_Notice_Onglets extends ZendAfi_View_Helper_Notice_Abst $tabs = array(); foreach($onglets as $onglet) { $id_onglet = sprintf('set%d_onglet_%d', $id, $i++); - $js_onclick = $this->getOnclick($onglet->getType(), $isbn, $id_onglet); + $js_onclick = $this->getOnclick($onglet->getType(), $notice, $id_onglet); - if($i==1) + if($i==1) Class_ScriptLoader::getInstance() ->addJQueryReady("infos_onglet". str_replace("this.id", - "'".$id_onglet."'", + "'".$id_onglet."'", $js_onclick)); $html_onglets.= sprintf('<div id="%s" class="titre_onglet" style="width:%d%%" onclick="infos_onglet%s"><h2>%s</h2></div>', $id_onglet, - // $onglet["largeur"] ? $onglet["largeur"] : 20, 20, $js_onclick, $onglet->getLibelle()); // Boite contenu - $html_contenu.=sprintf('<div class="%s" id="%s_contenu_row">%s</div>', + $html_contenu.=sprintf('<div class="%s" id="%s_contenu_row">%s</div>', $onglet->getType(), - $id_onglet, - sprintf('<div id="%s_contenu" class="onglet">%s</div>', - $id_onglet, + $id_onglet, + sprintf('<div id="%s_contenu" class="onglet">%s</div>', + $id_onglet, $tag_patience)); } @@ -81,8 +80,8 @@ class ZendAfi_View_Helper_Notice_Onglets extends ZendAfi_View_Helper_Notice_Abst '<div>%s</div>'. '</div>'. '<div class="onglets_contenu">%s</div>'. - '</div>', - $html_onglets, + '</div>', + $html_onglets, $html_contenu); } diff --git a/library/ZendAfi/View/Helper/Notice/ReservationLink.php b/library/ZendAfi/View/Helper/Notice/ReservationLink.php index 5d9adec5650f1abf3246480c5eaec2424eb7e576..1042511b3938f24d7e47819611d41dcb7f67fa8f 100644 --- a/library/ZendAfi/View/Helper/Notice/ReservationLink.php +++ b/library/ZendAfi/View/Helper/Notice/ReservationLink.php @@ -18,9 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_Notice_ReservationLink extends Zend_View_Helper_HtmlElement { - use Trait_Translator; - +class ZendAfi_View_Helper_Notice_ReservationLink extends ZendAfi_View_Helper_BaseHelper { const HOLD_IMG = 'resa.png'; protected $_bib; @@ -39,30 +37,29 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends Zend_View_Helper_HtmlEl * @return string modified html */ public function renderItemOn($ex, $html) { - $html .= '<td class="resa" style="text-align:center;">'; - if (1 == $this->_bib->getInterdireResa()) - return $html .= ' </td>'; + return $this->_renderCellWith(' '); $type_comm = ($int_bib = Class_IntBib::find($ex['id_int_bib'])) ? $int_bib->getCommSigb() : 0; if (!$type_comm) - return $this->_renderStandardOn($ex, $html); + return $this->_renderCellWith($this->_renderStandardOn($ex)); if (!$ex['reservable']) - return $html . ' </td>'; + return $this->_renderCellWith(' '); - return $this->_renderAjaxOn($ex, $html); + return $this->_renderCellWith($this->_renderAjaxOn($ex)); } /** @return string */ - protected function getHoldImage() { - return Class_Profil::getCurrentProfil()->getUrlImage(self::HOLD_IMG); + protected function _renderCellWith($content) { + return $this->_tag('td', $content, ['class' => 'resa', + 'style' => 'text-align:center;']); } /** @return string */ - protected function _renderStandardOn($ex, $html) { + protected function _renderStandardOn($ex) { $link = $this->view->url(['controller' => 'recherche', 'action' => 'reservation', 'id_int_bib' => $ex['id_int_bib'], @@ -70,22 +67,14 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends Zend_View_Helper_HtmlEl 'id_notice' => $ex['id_notice'], 'cote' => $ex['cote']]); - $html .= sprintf('<a href="%s"><img src="%s" border="0" title="%s" alt="%s"/></a>', - $link, - $this->getHoldImage(), - $this->_holdLabel, - $this->_holdLabel); - return $html . '</td>'; - } - - /** @return string */ - protected function _renderAjaxOn($ex, $html) { - return $this->_renderAjaxLinkOn($ex, $html, 'reservation'); + return $this + ->_tag('a', $this->_getHoldImage(), + ['href' => $link]); } /** @return string */ - protected function _renderAjaxLinkOn($ex, $html, $functionName) { + protected function _renderAjaxOn($ex) { $link = $this->view->url(['controller' => 'recherche', 'action' => 'reservation-pickup-ajax', 'id_int_bib' => $ex['id_int_bib'], @@ -93,12 +82,25 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends Zend_View_Helper_HtmlEl 'id_origine' => $ex['id'], 'code_annexe' => $ex['code_annexe']]); - $html .= sprintf('<a data-popup="true" href="%s"><img src="%s" border="0" alt="%s" title="%s" style="cursor:pointer" /></a>', - $link, - $this->getHoldImage(), - $this->_holdLabel, - $this->_holdLabel); - return $html .= '</td>'; + return $this + ->_tag('a', $this->_getHoldImage(), + ['href' => $link, + 'data-popup' => 'true']); + } + + + /** @return string */ + protected function _getHoldImageUrl() { + return Class_Profil::getCurrentProfil()->getUrlImage(self::HOLD_IMG); + } + + + /** @return string */ + protected function _getHoldImage() { + return $this->view + ->tagImg($this->_getHoldImageUrl(), + ['title' => $this->_holdLabel, + 'style' => 'border-style:none;']); } } diff --git a/library/ZendAfi/View/Helper/Notice/Vignette.php b/library/ZendAfi/View/Helper/Notice/Vignette.php index 353226ff1ff310284b7da29837e60a1e9b8857b0..2d4fa99bd28c451b40d1647a5844652b350eac6c 100644 --- a/library/ZendAfi/View/Helper/Notice/Vignette.php +++ b/library/ZendAfi/View/Helper/Notice/Vignette.php @@ -22,6 +22,7 @@ class ZendAfi_View_Helper_Notice_Vignette extends Zend_View_Helper_HtmlElement { use Trait_Translator; public function notice_Vignette($notice, $preferences=[]) { + if (!$notice->getUrlVignette()) $notice->fetchUrlVignette(); @@ -34,6 +35,7 @@ class ZendAfi_View_Helper_Notice_Vignette extends Zend_View_Helper_HtmlElement { public function imgVignette($notice, $preferences) { $img = $notice->fetchUrlVignette(); + return $this->linkTagForNoticeUrlVignetteTitle($notice, $img, Class_WebService_Vignette::getSource($img), $preferences); } diff --git a/library/ZendAfi/View/Helper/Permalink.php b/library/ZendAfi/View/Helper/Permalink.php index 4d8ab3105d7e4b8657d647d9b7d18fe81ccb9a98..f5517a95642c1e827a76847e128e957c41e58b87 100644 --- a/library/ZendAfi/View/Helper/Permalink.php +++ b/library/ZendAfi/View/Helper/Permalink.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_Permalink extends ZendAfi_View_Helper_BaseHelper { public function permalink($url) { @@ -33,12 +33,12 @@ class ZendAfi_View_Helper_Permalink extends ZendAfi_View_Helper_BaseHelper { 'alt' => $lien_permanent, 'onclick' => '$(this).next().children().first().toggle()']); - $html .= '<div><div style="display:none;">'; + $html .= '<div><div style="display:none; z-index: 101;">'; $html .= '<div>' . $lien_permanent . '</div>'; $html .= '<div>' . '<a href="#" onclick="$(this).parent().parent().hide(); return false">» ' . $this->translate()->_('fermer cette fenêtre') . '</a>'. '</div>'; - $html .='<input type="text" value="' . $url . '"/>'; + $html .= $this->view->tag('span', $url, ['class' => 'permalink-url']); $html .='</div></div>'; return $html; diff --git a/library/ZendAfi/View/Helper/PublicListViewMode.php b/library/ZendAfi/View/Helper/PublicListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..6548899b801df4995ac071067168f3f9b7c7a289 --- /dev/null +++ b/library/ZendAfi/View/Helper/PublicListViewMode.php @@ -0,0 +1,96 @@ +<?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_PublicListViewMode extends ZendAfi_View_Helper_Admin_ListViewMode { + protected $_item_renderer; + + public function publicListViewMode($list, $item_renderer=null) { + $default_item_renderer = function($item) { + return $this->view->getHelper('SitoTree')->renderSite($item); + }; + + $this->_item_renderer = $item_renderer ? + $item_renderer : + $default_item_renderer; + + if (!$this->_list = $list) + return ''; + + $html = $this->getSearchFormHtml() + . $this->getBreadcrumbHtml() + . $this->getCategoriesHtml() + . $this->getItemsHtml() + . $this->getItemsPaginatorHtml(); + + return $html; + } + + + protected function getCategoriesHtml() { + if ($this->_list->getSearchValue()) + return ''; + + $html = ''; + foreach($this->_list->getCategories() as $category) + $html .= $this->getCategoryHtml($category); + + return $this->_tag('ul', $html, + ['class' => $this->_list->getCategoriesId()]); + } + + + protected function getCategoryHtml($category) { + $label_attrib = $this->_list->getCategoriesLabelAttrib(); + $label = $category->$label_attrib; + if ($this->_list->isCountEnabled()) + $label .= ' (' . $this->_list->countRecursiveItemsFor($category) . ')'; + + return $this + ->_tag('li', + $this->_tag('a', $label, + ['href' => $this->view->url($this->_list->getUrlParams($category), + null, true)])); + } + + + protected function getItemsHtml() { + if (!$this->_list->getModel() && !$this->_list->getSearchValue()) + return ''; + + $html = ''; + foreach ($this->_list->getItems() as $item) + $html .= $this->getItemHtml($item); + + return $html; + } + + + protected function getItemHtml($item) { + if (!$item) + return ''; + + $renderer = $this->_item_renderer; + return $this->_tag('div', + $renderer($item), + ['class' => $this->_list->getItemsId()]); + } +} diff --git a/library/ZendAfi/View/Helper/RenderAlbum.php b/library/ZendAfi/View/Helper/RenderAlbum.php index d5ae5fa2183a31fa870a6e23847905afffc190ed..4616c27659280fbb7302d60310f98f5d65b6091d 100644 --- a/library/ZendAfi/View/Helper/RenderAlbum.php +++ b/library/ZendAfi/View/Helper/RenderAlbum.php @@ -33,7 +33,6 @@ class ZendAfi_View_Helper_RenderAlbum extends Zend_View_Helper_HtmlElement { public function renderAlbumHelper($album) { - if ($album->isLivreNumerique()) { Class_ScriptLoader::getInstance()->loadBooklet($album->getId(), '#resnum'); return ''; @@ -66,6 +65,9 @@ class ZendAfi_View_Helper_RenderAlbum extends Zend_View_Helper_HtmlElement { if ($album->isEPUB()) return $this->view->monocleReaderServerSide($album); + if ($album->isJamendo()) + return $this->view->tagJamendoPlayer($album); + if ($album->isAudioRecord()) return $this->view->tagAlbumTrackList($album); diff --git a/library/ZendAfi/View/Helper/RenderForm.php b/library/ZendAfi/View/Helper/RenderForm.php index cf6dbac8113575caaabc5d444d03c8253a695f96..1c948e5f1332d05379ca9d817943502c1b2e88fc 100644 --- a/library/ZendAfi/View/Helper/RenderForm.php +++ b/library/ZendAfi/View/Helper/RenderForm.php @@ -59,14 +59,17 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { public function setupTableDecoratorsForForm($form) { + $params = ['FormElements', + ['HtmlTag',['tag' => 'table']], + 'Fieldset']; + + if($form instanceof ZendAfi_Form) + $params[1]= ['Table', ['summary' => $form->getSummary()]]; + $form - ->setDisplayGroupDecorators(array( - 'FormElements', - array('HtmlTag', array('tag' => 'table')), - 'Fieldset')) + ->setDisplayGroupDecorators($params) ->removeDecorator('HtmlTag'); - foreach ($form->getElements() as $element) $element->setDecorators($this->_decoratorsForTableRendering($element)); @@ -75,15 +78,15 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { protected function _decoratorsForTableRendering($element) { - $newDecorators = array(); - $decorators = $element->getDecorators(); + $newDecorators = array(); + $decorators = $element->getDecorators(); - foreach ($decorators as $name => $decorator) { - $name = explode('_', $name); - $name = end($name); - $name = strtolower($name); + foreach ($decorators as $name => $decorator) { + $name = explode('_', $name); + $name = end($name); + $name = strtolower($name); - switch ($name) { + switch ($name) { case 'label': $newDecorators[] = array(array('input_data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'gauche')); @@ -110,10 +113,10 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { default: $newDecorators[$name] = $decorator; break; - } } + } - return $newDecorators; + return $newDecorators; } @@ -143,7 +146,7 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { */ protected function _getBackUrl($form) { return ($form->getAttrib('data-backurl')) ? - $form->getAttrib('data-backurl') : - $this->view->url(['action' => 'index']); + $form->getAttrib('data-backurl') : + $this->view->url(['action' => 'index']); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/SitoTree.php b/library/ZendAfi/View/Helper/SitoTree.php new file mode 100644 index 0000000000000000000000000000000000000000..ba615d26aa22b2e6b16590ecc8e8892007202a0f --- /dev/null +++ b/library/ZendAfi/View/Helper/SitoTree.php @@ -0,0 +1,91 @@ +<?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_SitoTree extends ZendAfi_View_Helper_BaseHelper { + protected $titre, $contenu, $preferences, $division; + + public function sitoTree($id_category) { + $category = Class_SitothequeCategorie::find($id_category); + return $this->renderHierarchicalCategories($category); + } + + + protected function renderHierarchicalCategories($category) { + if (!$category) + return $this->_('Aucune catégorie sélectionnée.'); + + $html = ''; + $children = $category->getChildren(); + foreach ($children as $child_category) + $html .= $this->renderHierarchicalCategory($child_category); + + foreach ($category->getItems() as $site) + $html .= $this->_tag('li', $this->renderSite($site)); + + return $this->_tag('ul', $html, ['class' => 'sitotheque']); + } + + + protected function renderHierarchicalCategory($category) { + if (!$category) + return ''; + + return $this->_tag('li', $this->_renderCategory($category)); + } + + + protected function _renderCategory($category) { + return $this->_tag('h2', + $this->_tag('a', $category->getLibelle(), + ['href' => $this->_urlOf($category)])); + } + + + protected function _urlOf($category) { + return $this->view->url(['controller' => 'sito', + 'action' => 'viewcategory', + 'id_cat' => $category->getId(), + 'start_cat' => $category->getId()], + null,true); + } + + + public function renderSite($site) { + return $this->_renderLabelOf($site) . $site->getDescription(); + } + + + protected function _renderLabelOf($site) { + return $this->_tag('h2', + $this->_tag('a', + $this->_renderImageOf($site) . $site->getTitre(), + ['href' => $site->getUrl(), + 'title' => $this->_('Aller sur le site %s', + $site->getTitre())])); + } + + + protected function _renderImageOf($site) { + return ($url = $this->view->webThumbnail($site->getUrl())) ? + $this->view->tagImg($url) : ''; + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Table.php b/library/ZendAfi/View/Helper/Table.php new file mode 100644 index 0000000000000000000000000000000000000000..879c714e632adce1a28d2d7cd9c44951ab29f905 --- /dev/null +++ b/library/ZendAfi/View/Helper/Table.php @@ -0,0 +1,44 @@ +<?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_Table extends ZendAfi_View_Helper_BaseHelper { + public function table($content, $attribs=[]) { + $summary = ''; + if (array_key_exists('summary', $attribs)) { + $summary = $attribs['summary']; + unset($attribs['summary']); + } + + return $this->_tag('table', $this->_renderSummary($summary) . $content, $attribs); + } + + + protected function _renderSummary($summary) { + if (!$summary) + return ''; + + return $this + ->_tag('caption', $this->_tag('details', $this->_tag('summary', $summary)), + ['style' => 'display:none;']); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Tag.php b/library/ZendAfi/View/Helper/Tag.php index 459bbf5b585f09232cc324a9f9df462ca6aba941..fa92f2e22c891585ef226474bcd6d51831ee69a2 100644 --- a/library/ZendAfi/View/Helper/Tag.php +++ b/library/ZendAfi/View/Helper/Tag.php @@ -16,12 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Tag extends Zend_View_Helper_HtmlElement { public function tag($name, $content=null, $attribs=[]) { - $html = '<' . $name . ' ' . $this->_htmlAttribs($attribs); + $html = '<' . $name . $this->_htmlAttribs($attribs); if (null === $content) return $html . $this->getClosingBracket(); return $html . '>' . $content . '</' . $name . '>'; diff --git a/library/ZendAfi/View/Helper/TagAlbumTrackList.php b/library/ZendAfi/View/Helper/TagAlbumTrackList.php index 8ad071cf3e8b8b7a8c57aecf2862b88a8f54696c..671456a2342e832dc485a41b8459c08e379ba324 100644 --- a/library/ZendAfi/View/Helper/TagAlbumTrackList.php +++ b/library/ZendAfi/View/Helper/TagAlbumTrackList.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 */ @@ -27,10 +27,10 @@ class ZendAfi_View_Helper_TagAlbumTrackList extends Zend_View_Helper_HtmlElement * Voir: http://kolber.github.com/audiojs/ */ public function tagAlbumTrackList($album) { - return + return $this->view->album_Download($album) . $this->view->albumAudioJsPlayer($album); - } + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagBanniere.php b/library/ZendAfi/View/Helper/TagBanniere.php index 3168000c42b316f9ac0f6725ef286e3e46402f4c..99223d81159329dde3b1e306222900e6c75d06e2 100644 --- a/library/ZendAfi/View/Helper/TagBanniere.php +++ b/library/ZendAfi/View/Helper/TagBanniere.php @@ -32,7 +32,7 @@ class ZendAfi_View_Helper_TagBanniere extends Zend_View_Helper_HtmlElement { $top_profil = $this->_profil->getParentsAndSelf()[0]; - return sprintf('<div id="banniere">%s<a class="home" href="%s" style="display:block">%s</a></div>', + return sprintf('<div id="banniere">%s<a class="home" href="%s" style="display:block">%s</a></div>', $this->_getLogos(), $this->view->url(['id_profil' => $top_profil->getId()], null, @@ -50,7 +50,7 @@ class ZendAfi_View_Helper_TagBanniere extends Zend_View_Helper_HtmlElement { protected function _getLogo($position) { if ($this->_profil->_has('logo_'.$position.'_img')) return sprintf( - '<div class="logo_%s"><a href="%s"><img src="%s" alt=""/></a></div>', + '<div class="logo_%s"><a href="%s"><img src="%s" alt="logo"/></a></div>', $position, $this->_profil->_get('logo_'.$position.'_link'), $this->_profil->_get('logo_'.$position.'_img')); @@ -60,14 +60,12 @@ class ZendAfi_View_Helper_TagBanniere extends Zend_View_Helper_HtmlElement { protected function _getImages() { $images = ''; - $largeur_site = $this->_profil->getLargeurSite(); - + $largeur_site = $this->_profil->getWidthSite(); foreach ($this->_profil->getAllHeaderImg() as $img) { if (!$img) continue; + $images .= '<img alt="page accueil" src="'.$img.'" style="width:'.$largeur_site.'" />'; - $images .= sprintf('<img alt="" src="%s" style="width:%dpx" />', - $img, $largeur_site); } return $images; diff --git a/library/ZendAfi/View/Helper/TagCVSCriteresRecherche.php b/library/ZendAfi/View/Helper/TagCVSCriteresRecherche.php index b8e08478789b2ea9060f60715736e40e9cd83505..3ee220b4e65189156bb964a4caf3fbc5e120642d 100644 --- a/library/ZendAfi/View/Helper/TagCVSCriteresRecherche.php +++ b/library/ZendAfi/View/Helper/TagCVSCriteresRecherche.php @@ -16,129 +16,66 @@ * * 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_TagCVSCriteresRecherche extends Zend_View_Helper_HtmlElement { - use Trait_Translator; + use Trait_Translator, Trait_SearchCriteriaVisitor; protected $_html = ''; protected $_current_facettes = []; - protected $criteres=[]; + protected $criteres = []; + public function tagCVSCriteresRecherche($criteres_recherche) { $this->visitCriteresRecherche($criteres_recherche); return implode('+',$this->criteres); } + public function visitCriteresRecherche($criteres_recherche) { if (!isset($criteres_recherche)) return ''; - $this->_criteres_recherche=$criteres_recherche; + $this->_criteres_recherche = $criteres_recherche; $this->_current_facettes = $criteres_recherche->getFacettes(); + $this->_libelles_criteres = ['titres' => 'album', + 'auteurs' => 'artist', + 'matieres' => '', + 'dewey' => '', + 'editeur' => 'label', + 'collection' => '' ]; - $this->_libelles_criteres = [ - 'titres' => 'album', - 'auteurs' => 'artist', - 'matieres' => '', - 'dewey' => '', - 'editeur' => 'label', - 'collection' => '' ]; - - if (isset($criteres_recherche)) + if (isset($criteres_recherche)) $criteres_recherche->acceptVisitor($this); - - - } - - public function visitTextInput($name, $operateur, $type_recherche, $value) { - - if (strlen($this->_libelles_criteres[$name]) >0) - $this->criteres[]=$value; - - } - - public function visitNouveaute($nouveaute) { - } - - public function visitClesNotices($cles_notices) { - } - - public function setErreur($message) { - } - - public function hasErreur() { - return false; - } - - public function visitRubrique($rubrique,$fil) { } - public function visitAnnexe($annexe) { - - } - - - public function visitTypeDoc($type_doc) { - + public function visitTextInput($name, $operateur, $type_recherche, $value) { + if (strlen($this->_libelles_criteres[$name]) > 0) + $this->criteres[] = $value; } - public function visitCodeRebond($code_rebond) { - $libelle_rebond=Class_Codification::getInstance()->getLibelleFacette($code_rebond); - $this->criteres[]=$libelle_rebond; + $libelle_rebond = Class_Codification::getInstance()->getLibelleFacette($code_rebond); + $this->criteres[] = $libelle_rebond; } public function visitSerie($serie) { - - $this->criteres[]=$serie; - } - - - public function visitAnneeDebutFin($annee_debut, $annee_fin) { - + $this->criteres[] = $serie; } public function visitFacette($facette) { - - $libelle_facette=Class_Codification::getInstance()->getLibelleFacette($facette); - $this->criteres[]=$libelle_facette; - } - - - public function visitCatalogue($catalogue) { - } - - - public function visitCoteDebutFin($cote_debut, $cote_fin) { - + $libelle_facette = Class_Codification::getInstance()->getLibelleFacette($facette); + $this->criteres[] = $libelle_facette; } public function visitExpression($expression) { - $this->criteres[]=$expression; - } - - - public function visitFiltre($filtre) { - return; - - } - - - public function visitSection($section) { - } - - - public function visitPage($page) { - } - - public function visitTri($tri, $libelle) { + $this->criteres[] = $expression; } } diff --git a/library/ZendAfi/View/Helper/TagCriteresRecherche.php b/library/ZendAfi/View/Helper/TagCriteresRecherche.php index e78627e92c6a75c0057031dcd51c74239f4859f3..d8ef5debf5aad047f7402a43c27dec8d6101711c 100644 --- a/library/ZendAfi/View/Helper/TagCriteresRecherche.php +++ b/library/ZendAfi/View/Helper/TagCriteresRecherche.php @@ -18,8 +18,10 @@ * 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_TagCriteresRecherche extends Zend_View_Helper_HtmlElement { - use Trait_Translator; + use Trait_Translator, Trait_SearchCriteriaVisitor; protected $_html = ''; protected $_current_facettes = []; @@ -29,18 +31,21 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem return '<div class="criteres_recherche">'.$this->_html.'</div>'; } + public function visitCriteresRecherche($criteres_recherche) { if (!isset($criteres_recherche)) return ''; - $this->_criteres_recherche=$criteres_recherche; + + $this->_criteres_recherche = $criteres_recherche; $this->_current_facettes = $criteres_recherche->getFacettes(); - $this->_libelles_operateur = array("and" => $this->view->_(""), - "or" => $this->view->_(" ou "), - "and not" => $this->view->_(" sauf ")); - $this->_libelles_criteres = [ - 'titres' => $this->_("Titre"), + $this->_libelles_operateur = ['and' => '', + 'or' => $this->view->_(' ou '), + 'and not' => $this->view->_(' sauf ')]; + + $this->_libelles_criteres = [ + 'titres' => $this->_('Titre'), 'auteurs' => ($libelle = Class_AdminVar::get('FACETTE_AUTEUR_LIBELLE')) ? $libelle : $this->_("Auteur"), 'matieres' => ($libelle = Class_AdminVar::get('FACETTE_MATIERE_LIBELLE')) ? $libelle :$this->_("Sujet"), 'dewey' => ($libelle = Class_AdminVar::get('FACETTE_DEWEY_LIBELLE')) ? $libelle :$this->_("Dewey / pcdm4"), @@ -49,56 +54,31 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem if (isset($criteres_recherche)) $criteres_recherche->acceptVisitor($this); - - } - public function visitTextInput($name, $operateur, $type_recherche, $value) { - - if (!$operateur) - $libelle_operateur = " et "; - else $libelle_operateur = $this->_libelles_operateur[$operateur]; - $libelle=$libelle_operateur. - $this->_libelles_criteres[$name].' '. - $this->_($type_recherche == 'commence' ? 'commence par': ':').' '.$value; - $url=$this->_criteres_recherche->getUrlCriteresWithoutElement('rech_'.$name); + public function visitTextInput($name, $operateur, $type_recherche, $value) { + $libelle_operateur = $operateur ? $this->_libelles_operateur[$operateur] : ' et '; + $libelle = $libelle_operateur. + $this->_libelles_criteres[$name] . ' ' . + $this->_($type_recherche == 'commence' ? 'commence par': ':') .' ' . $value; - $this->htmlAppend( - $this->getSuppressionImgUrlForLibelle($libelle,$url)); + $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('rech_'.$name); + $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); } + public function visitNouveaute($nouveaute) { if ($nouveaute == 0) return; $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('nouveaute'); - $libelle = $this->view->_('Nouveautés de moins de: ').$nouveaute.' mois'; + $libelle = $this->view->_('Nouveautés de moins de: ') . $nouveaute . ' mois'; $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle,$url)); } - public function visitClesNotices($cles_notices) { - } - - - public function visitClesNoticesForOrConditions($cles_notices) { - } - - - public function setErreur($message) { - - } - - public function hasErreur() { - return false; - } - - public function visitRubrique($rubrique,$fil) { - } - - public function visitAnnexe($annexe) { $this ->htmlAppend($this->view->_("Site: ".Class_Codification::getInstance()->getLibelleFacette("Y".$annexe))) @@ -153,15 +133,6 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem } - public function visitCatalogue($catalogue) { - } - - - public function visitCoteDebutFin($cote_debut, $cote_fin) { - - } - - public function htmlAppend($text) { $this->_html .= '<div>'.$text.'</div>'; return $this; @@ -192,21 +163,6 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem $libelle = $this->view->_("Section: %s", Class_Codification::getInstance()->getLibelleFacette("S".$section)); $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle,$url)); } - - - public function visitPage($page) {} - - - public function visitDomain($criteres) {} - - - public function visitTri($tri, $libelle) {} - - - public function visitFilterOnDomain($criteres) {} - - - public function visitFacetteDomainForOrConditions($facette) {} } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index 97126d62caf4c071ad2cfeb27cb365e0920d4510..682038686a3ba124f6050869be0699eb8856984b 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -21,23 +21,77 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement { + protected $_album, + $_user; + public function tagDilicomWidget($album) { + $this->_album = $album; + (new Class_WebService_BibNumerique_Dilicom_Hub())->updateStatus($album); + + $infos = $this->view->tag('p', $this->getInfos()); + $iframe = $this->view->tag('iframe', null, - ['src' => $album->getExternalURI(), + ['src' => $this->_album->getExternalURI(), 'width' => '100%', 'height' => '600px']); - $link = $this->view->tag('p', $this->view->_('Vous devez vous connecter pour accéder à la consultation en ligne.')); + $links = $this->view->tag('p', $this->view->_('Vous devez vous connecter pour accéder à la consultation en ligne.')); + + if(($this->_user = Class_Users::getIdentity()) && ($this->_user->hasRightAccessDilicom())) + $links = $infos + . $this->getConsultBookAnchor() + . $this->getLoanBookAnchor() + . $this->getEndLoanBookAnchor(); + + return $links . $iframe; + } + + + protected function getConsultBookAnchor() { + return $this->getDilicomAnchor(['controller' => 'bib-numerique', + 'action' => 'consult-book', + 'id' => $this->_album->getId()], + $this->view->_('Consulter le livre en ligne'), ['target' => '_blank']); + } + + + protected function getLoanBookAnchor() { + return $this->getDilicomAnchor(['controller' => 'bib-numerique', + 'action' => 'loan-book', + 'id' => $this->_album->getId(),], + $this->view->_('Emprunter le livre au format EPUB')); + } + + + protected function getEndLoanBookAnchor() { + if(!$loan = Class_Loan_Pnb::findOngoingByUserAndAlbum($this->_user, $this->_album)) + return ''; + + return $this->getDilicomAnchor(['controller' => 'bib-numerique', + 'action' => 'end-loan-book', + 'id' => $loan->getId()], + $this->view->_('Rendre le livre emprunté')); + } + + + protected function getInfos() { + $item = Class_Album_Item::findFirstBy(['album_id' => $this->_album->getId()]); + + return sprintf('Nombre d\'emprunts total: %d / %d, Nombre d\'emprunts en cours: %d / %d', + $item->getQuantity(), + $this->_album->getUsageConstraints()->getLoanQuantity(), + $item->getLoanCount(), + $this->_album->getUsageConstraints()->getLoanMaxNumberOfUsers()); + } - if(($user = Class_Users::getIdentity()) && ($user->hasRightAccessDilicom())) - $link = $this->view->tagAnchor(['controller' => 'bib-numerique', - 'action' => 'consult-book', - 'id' => $album->getId()], - $this->view->_('Consulter le livre en ligne'), - ['target' => '_blank']); - return $link . $iframe; + protected function getDilicomAnchor($url, $label, $attribs = []) { + return $this->view->tag('div', + $this->view->tagAnchor($url, + $label, + array_merge(['style' => 'padding: 5px;margin: 5px; border: 1px solid #aaa; border-radius: 3px;display: inline-block;'], + $attribs))); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagImg.php b/library/ZendAfi/View/Helper/TagImg.php index 64d7f71eca655d4dc7a5321df4b0a7bc3b630ec3..b1fc3e069624840a1fdcbc3d1a111988dbd711c0 100644 --- a/library/ZendAfi/View/Helper/TagImg.php +++ b/library/ZendAfi/View/Helper/TagImg.php @@ -18,19 +18,25 @@ * 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_TagImg extends Zend_View_Helper_HtmlElement { + +class ZendAfi_View_Helper_TagImg extends ZendAfi_View_Helper_BaseHelper { /** * @param string $url * @param array $attribs * @return string */ - public function tagImg($url, Array $attribs = array()) { - if (!array_key_exists('alt', $attribs)) - $attribs['alt'] = ''; + public function tagImg($url, $attribs = []) { + $new_attribs = ['src' => $url]; + foreach($attribs as $k => $v) + $new_attribs[$k] = $v; - return '<img src="' . $url . '"' . $this->_htmlAttribs($attribs) . $this->getClosingBracket(); + if (!array_key_exists('alt', $new_attribs) && array_key_exists('title', $new_attribs)) + $new_attribs['alt'] = $new_attribs['title']; - } + if (!array_key_exists('alt', $new_attribs)) + $new_attribs['alt'] = ''; + return $this->_tag('img', null, $new_attribs); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagJamendoPlayer.php b/library/ZendAfi/View/Helper/TagJamendoPlayer.php new file mode 100644 index 0000000000000000000000000000000000000000..f1ec6154f7d55e175135ee4b816ce0b862ccb367 --- /dev/null +++ b/library/ZendAfi/View/Helper/TagJamendoPlayer.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_TagJamendoPlayer extends ZendAfi_View_Helper_TagAlbumTrackList { + public function tagJamendoPlayer($album) { + return + $this->view->tag('p', + $this->view->tag('img', + '', + ['src' => URL_ADMIN_IMG.'/supports/jamendo_s.png', + 'style' => 'vertical-align: middle; margin-right: 2px']) . + $this->view->tag('a', + $this->view->_('Voir l\'album "%s" sur Jamendo', + $album->getTitre()), + ['href' => 'https://www.jamendo.com/fr/list/a'.$album->getIdOrigine(), + 'target' => '_blank'])). + $this->view->tagAlbumTrackList($album); + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagList.php b/library/ZendAfi/View/Helper/TagList.php new file mode 100644 index 0000000000000000000000000000000000000000..cbb32f3fa489ff0c88b760dfc3f85b9f758fda23 --- /dev/null +++ b/library/ZendAfi/View/Helper/TagList.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_TagList extends ZendAfi_View_Helper_BaseHelper { + protected $models, $attribs, $css_class, $callbacks; + + public function tagList($models, $attribs, $css_class, $callbacks = []) { + $this->models = $models; + $this->attribs = $attribs; + $this->css_class = $css_class; + $this->callbacks = $callbacks; + + return $this->renderModels(); + } + + + public function renderModels() { + $html = ''; + + foreach ($this->models as $model) + $html .= $this->renderModel($model); + + return $html; + } + + + public function renderModel($model) { + $html = ''; + + $default_callback = function ($model, $attrib) { + return $this->view->escape($model->$attrib); + }; + + foreach ($this->attribs as $attrib) { + $callback = array_key_exists($attrib, $this->callbacks) ? + $this->callbacks[$attrib] : $default_callback; + $html .= $this->_tag('li', $callback($model, $attrib)); + } + + return $this->_tag('ul', $html, ['class' => $this->css_class]); + } +} diff --git a/library/ZendAfi/View/Helper/TagRechercheSimple.php b/library/ZendAfi/View/Helper/TagRechercheSimple.php index cbff9af3cc19967a790da658691d198dd4efc409..1f5b0118a473bc4fed4cb2dc54b1b898253e3b92 100644 --- a/library/ZendAfi/View/Helper/TagRechercheSimple.php +++ b/library/ZendAfi/View/Helper/TagRechercheSimple.php @@ -181,9 +181,9 @@ class ZendAfi_View_Helper_TagRechercheSimple extends Zend_View_Helper_HtmlElemen 'placeholder' => $this->preferences['placeholder'], 'style' => 'width:'.$this->preferences["largeur"].'px', 'onkeypress' => 'if (event.keyCode == 13) {this.form.submit();return false;}']; - + $search_button_value=isset($this->preferences['search_button']) ? $this->preferences['search_button'] :""; $ret= '<input '.$this->_htmlAttribs($attribs).' />'. - '<input name="button" type="submit" class="submit" value="" />'; + '<input name="button" type="submit" class="submit" value="'.$search_button_value.'" />'; if ($this->preferences["exemple"]) $ret.='<div>'.$this->preferences["exemple"].'</div>'; diff --git a/library/ZendAfi/View/Helper/TagSlideshow.php b/library/ZendAfi/View/Helper/TagSlideshow.php index 2310d851d651fbc7ef3f62424db262b88056e43f..7fcae0d8fd0305c0e52649fe2dacc1025c1fa280 100644 --- a/library/ZendAfi/View/Helper/TagSlideshow.php +++ b/library/ZendAfi/View/Helper/TagSlideshow.php @@ -109,7 +109,7 @@ class ZendAfi_View_Helper_TagSlideshow extends Zend_View_Helper_HtmlElement { '$(\'%s\').cycle(%s); var container = $(\'%1$s\').parent(); container.addClass(\'slideshow\'); - container.prepend(\'<div class="controls"><a href="#"></a><a href="#"></a></div>\'); + container.prepend(\'<div class="controls"><a href="#"> </a><a href="#"> </a></div>\'); container.find(\'.controls a:first-child\').click( function(event){ event.preventDefault(); diff --git a/library/ZendAfi/View/Helper/TagTriRecherche.php b/library/ZendAfi/View/Helper/TagTriRecherche.php index 03daa8f2880712193ed2626f65fed7337ed24fd1..8844821d8f55aaae0dbba28817dabe5bb4f11aa3 100644 --- a/library/ZendAfi/View/Helper/TagTriRecherche.php +++ b/library/ZendAfi/View/Helper/TagTriRecherche.php @@ -16,25 +16,31 @@ * * 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_TagTriRecherche extends Zend_View_Helper_HtmlElement { +class ZendAfi_View_Helper_TagTriRecherche extends Zend_View_Helper_HtmlElement { + use Trait_Translator; + public function tagTriRecherche($criteres_recherche) { - $tri_selected = $criteres_recherche->getTri(); - // combo tri - if($url = $criteres_recherche->getUrlCriteresWithoutTri()) { - $url_str = $this->view->url($url,null,true); - $onchange="var tri=$('#tri').val();document.location='".$url_str."/tri/'+tri;"; - $html='<div class="tri-recherche"><span>Trier par '; - $html.=$this->view->formSelect('tri', - $tri_selected, - ['onchange' => $onchange], - $criteres_recherche->getListeTris()); - $html.='</span></div>'; - } - return $html; + if (!$url = $criteres_recherche->getUrlCriteresWithoutTri()) + return; + + $tri_selected = $criteres_recherche->getTri(); + $url_str = $this->view->url($url, null, true); + + $onchange = "var tri=$('#tri').val();document.location='" . $url_str . "/tri/'+tri;"; + + $html = $this->view->tag('label', $this->_('Trier par'), ['for' => 'tri']) + . ' ' . $this->view->formSelect('tri', + $tri_selected, + ['onchange' => $onchange], + $criteres_recherche->getListeTris()); + + return $this->view + ->tag('div', $this->view->tag('span', $html), + ['class' => 'tri-recherche']); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TreeSelect.php b/library/ZendAfi/View/Helper/TreeSelect.php index 88af59209f70ca9a1a72c0d08b7197e68e45b996..aeb683d8c383c243ff61d7b1959c43d57cbee3a1 100644 --- a/library/ZendAfi/View/Helper/TreeSelect.php +++ b/library/ZendAfi/View/Helper/TreeSelect.php @@ -25,6 +25,7 @@ class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper { protected $_categories_selectable = true, + $_items_selectable = true, $_multiple_selection = true; function treeSelect($id_items = 0, @@ -60,11 +61,19 @@ class ZendAfi_View_Helper_TreeSelect extends ZendAfi_View_Helper_BaseHelper { return $this; } + + function itemsNotSelectable() { + $this->_items_selectable = false; + return $this; + } + + function disableMultipleSelection() { $this->_multiple_selection = false; return $this; } + function getJSTreeSelect(){ $js_id_items = str_replace('-', ',', $this->id_items); $js_id_categories = str_replace('-', ',', $this->id_categories); @@ -87,6 +96,9 @@ CONTENT; if (!$this->_categories_selectable) $content .= "$(\".treeselect\").treeselect('categoriesNotSelectable');"; + if (!$this->_items_selectable) + $content .= "$(\".treeselect\").treeselect('itemsNotSelectable');"; + if (!$this->_multiple_selection) $content .= "$(\".treeselect\").treeselect('disableMultipleSelection');"; diff --git a/library/ZendAfi/View/Helper/UrlNotice.php b/library/ZendAfi/View/Helper/UrlNotice.php index ca5369c0f12a1126bb63cbadd040eaaf8a820968..9f3e55c7f059c1d362a87838580e9f1ec8fb2afc 100644 --- a/library/ZendAfi/View/Helper/UrlNotice.php +++ b/library/ZendAfi/View/Helper/UrlNotice.php @@ -31,46 +31,7 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement { if (is_array($notice)) $notice = Class_Notice::find($notice['id_notice']); - $type_doc = $notice->getTypeDoc(); - - $options = ['controller' => 'recherche', - 'action' => 'viewnotice', - 'clef' => $notice->getClefAlpha(), - 'id' => $notice->getId()]; - - - if (in_array($type_doc, [Class_TypeDoc::ARTICLE, - Class_TypeDoc::RSS, - Class_TypeDoc::SITE, - Class_TypeDoc::CVS])) { - $id_ressource=$notice->getChamp856b(); - switch($type_doc) { - case Class_TypeDoc::ARTICLE: - $options = ['controller' => 'cms', - 'action' => 'articleview', - 'id' => $id_ressource]; - break; - - case Class_TypeDoc::RSS: - $options = ['controller' => 'rss', - 'action' => 'main', - 'id_flux' => $id_ressource]; - break; - - case Class_TypeDoc::SITE: - $options = ['controller' => 'sito', - 'action' => 'sitoview', - 'id_items' => $id_ressource]; - break; - - case Class_TypeDoc::CVS: - $options = ['controller' => 'modules', - 'action' => 'cvs', - 'docid' => $notice->getId()]; - break; - - } - } + $options = (new Class_Notice_Permalink())->paramsFor($notice); $options = array_merge($options, array_intersect_key(array_filter($preferences), diff --git a/library/startup.php b/library/startup.php index 40b89b76326f5ec9e9ac4b0a71b55b891e0d8480..76ee458b29e0caf18bf71061e413c52464588c52 100644 --- a/library/startup.php +++ b/library/startup.php @@ -26,7 +26,14 @@ if (!function_exists('xdebug_break')) { function setupOpac() { + require_once('Class/Url.php'); + + defineConstant('ROOT_URL', Class_Url::rootUrl()); + defineConstant('BASE_URL', Class_Url::baseUrl()); + + require_once "Zend/Loader.php"; Zend_Loader::registerAutoload(); + setupConstants(); require_once('requires.php'); @@ -44,6 +51,7 @@ function setupOpac() { $front_controller = setupFrontController($cfg); setupPagination(); setupRestful(); + return $front_controller; } @@ -56,7 +64,7 @@ function defineConstant($name, $value) { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.1'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.19'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.34'); defineConstant('ROOT_PATH', realpath(dirname(__FILE__).'/..').'/'); @@ -65,7 +73,7 @@ function setupConstants() { defineConstant('MODULEDIRECTORY', ROOT_PATH . 'application/modules'); defineConstant('LANG_DIR', ROOT_PATH . 'library/translation/'); - defineConstant('USERFILESPATH', '..' . BASE_URL . '/userfiles'); + defineConstant('USERFILESPATH', ROOT_PATH . 'userfiles'); defineConstant('USERFILESURL', BASE_URL . '/userfiles/'); defineConstant('PATH_TEMP', ROOT_PATH . 'temp/'); @@ -270,7 +278,7 @@ function newFrontController() { function setupFrontController($cfg) { $front_controller = newFrontController() ->addControllerDirectory(ROOT_PATH.'afi/application/modules/opacpriv/controllers','opacpriv') - ->setBaseUrl(BASE_URL); + ->setBaseURL(BASE_URL); setupRoutes($front_controller, $cfg); diff --git a/library/storm b/library/storm index fa7d2ff2c3c3def70d67ee8ee7f7c7ec3601fdda..6c0d145c72ad2ab90ec1fdadffe9eabb3a02d10b 160000 --- a/library/storm +++ b/library/storm @@ -1 +1 @@ -Subproject commit fa7d2ff2c3c3def70d67ee8ee7f7c7ec3601fdda +Subproject commit 6c0d145c72ad2ab90ec1fdadffe9eabb3a02d10b diff --git a/public/admin/images/picto/jamendo_16.png b/public/admin/images/picto/jamendo_16.png new file mode 100755 index 0000000000000000000000000000000000000000..8b594016d6948ecf7028b2965beab9eea9a8926d Binary files /dev/null and b/public/admin/images/picto/jamendo_16.png differ diff --git a/public/admin/images/picto/jamendo_48.png b/public/admin/images/picto/jamendo_48.png new file mode 100755 index 0000000000000000000000000000000000000000..29d42ca74ece62b89b618f1374749cd6462500a6 Binary files /dev/null and b/public/admin/images/picto/jamendo_48.png differ diff --git a/public/admin/images/supports/jamendo_g.png b/public/admin/images/supports/jamendo_g.png new file mode 100755 index 0000000000000000000000000000000000000000..c924fa4138d0100c37836f8b10f61f89743835a6 Binary files /dev/null and b/public/admin/images/supports/jamendo_g.png differ diff --git a/public/admin/images/supports/jamendo_s.png b/public/admin/images/supports/jamendo_s.png new file mode 100755 index 0000000000000000000000000000000000000000..8b594016d6948ecf7028b2965beab9eea9a8926d Binary files /dev/null and b/public/admin/images/supports/jamendo_s.png differ diff --git a/public/admin/js/multi_inputs/multi_inputs.js b/public/admin/js/multi_inputs/multi_inputs.js index d1367e58ce29f1ce4fbecff0a50a485e4a5c05c1..f13f97121ee00a6225c2d144dcfd49d3ab946eec 100644 --- a/public/admin/js/multi_inputs/multi_inputs.js +++ b/public/admin/js/multi_inputs/multi_inputs.js @@ -76,10 +76,22 @@ if (input.options) { for (var option_value in input.options) { - var option = $('<option value="' + option_value + '">' + input.options[option_value] + '</option>'); - if (option_value == value) - option.attr('selected', 'selected'); - node.append(option); + if (typeof input.options[option_value] === 'string') { + var option = $('<option value="' + option_value + '">' + input.options[option_value] + '</option>'); + if (option_value == value) + option.attr('selected', 'selected'); + node.append(option); + } else { + var optgroup = $('<optgroup label="' + option_value + '"></optgroup>'); + var optgroup_options = input.options[option_value]; + for (var optgroup_value in optgroup_options) { + var optgroup_option = $('<option value="' + optgroup_value + '">' + optgroup_options[optgroup_value] + '</option>'); + if (optgroup_value == value) + optgroup_option.attr('selected', 'selected'); + optgroup.append(optgroup_option) + } + node.append(optgroup); + } } } diff --git a/public/admin/js/multi_inputs/test.js b/public/admin/js/multi_inputs/test.js index 65bdd674533eb416d1335f96ff400fcc77a12647..6819b1b91c8f5db8acecc273a597040346743a11 100644 --- a/public/admin/js/multi_inputs/test.js +++ b/public/admin/js/multi_inputs/test.js @@ -67,6 +67,17 @@ test('one select input', function () { equal(insertion_point.find('select[name="testing[]"]').children('option[value="3"][selected="selected"]').length, 1, 'opt3 selected'); }); +test('one select input with optgroups', function () { + var insertion_point = call_multi_inputs_for({ + fields:[{name:'testing', type:'select', options:{ 'label1':{1:'opt1', 2:'opt2'}, 'label2':{3:'opt3', 4:'opt4'}}}], + values:{testing:[3]} + }); + equal(insertion_point.find('select[name="testing[]"]').length, 1, 'first input'); + equal(insertion_point.find('select[name="testing[]"]').children('optgroup[label="label1"]').length, 1, 'optgroup'); + equal(insertion_point.find('optgroup[label="label2"]').children('option[value="3"][selected="selected"]').length, 1, 'opt3 selected'); + equal(insertion_point.find('optgroup[label="label2"]').children('option[value="4"]').text(), 'opt4', 'value for opt4 is set'); +}); + test('one input and two values', function () { var insertion_point = call_multi_inputs_for({ diff --git a/public/admin/js/onload_utils.js b/public/admin/js/onload_utils.js index f3c8223bf513e6d5688928aceb71180b961c8822..5c6cd20804990d53354889b3ba04a36f112f2411 100644 --- a/public/admin/js/onload_utils.js +++ b/public/admin/js/onload_utils.js @@ -48,22 +48,26 @@ if (typeof jQuery != "undefined") //Les liens qui référencent des sites externes doivent être ouverts dans un nouvel onglet var setupAnchorsTarget = function() { - var internalLink = new RegExp('/' + window.location.host + '/'); - $('a[href^="http"]').each(function() { - if (!internalLink.test($(this).attr('href')) && (undefined == this.onclick) && (undefined == $(this).data('events') || undefined == $(this).data('events').click)) { - if ($.browser.msie || !!navigator.userAgent.match(/Trident/)) { - // Otherwise IE doesn't send HTTP Referer - this.target = '_blank'; - return; - } - - $(this).click(function(event) { - event.preventDefault(); - event.stopPropagation(); - window.open(this.href, '_blank'); + var internalLink = new RegExp('/' + window.location.host + '/'); + $('a[href^="http"]').each(function() { + if (!internalLink.test($(this).attr('href')) + && (undefined == this.onclick) + && (undefined == $(this).data('events') || undefined == $(this).data('events').click) // jquery < 1.8 + && (undefined == $._data(this, 'events') || undefined == $._data(this, 'events').click) // jquery >= 1.8 + ) { + if ($.browser.msie || !!navigator.userAgent.match(/Trident/)) { + // Otherwise IE doesn't send HTTP Referer + this.target = '_blank'; + return; + } + + $(this).click(function(event) { + event.preventDefault(); + event.stopPropagation(); + window.open(this.href, '_blank'); }); - } - }); + } + }); } diff --git a/public/admin/js/subModal.js b/public/admin/js/subModal.js index a750546912736c3097a616d307ba09ef3a32e7dc..a44f10e037d1e0794f4abf1ade1c050c79f1f1e1 100644 --- a/public/admin/js/subModal.js +++ b/public/admin/js/subModal.js @@ -59,7 +59,7 @@ function initPopUp() '<img alt="Fermer la fenêtre" src="' + imagesUrl + 'bouton/close.gif" onclick="hidePopWin(false);" id="popCloseBox" title="Fermer"/>' + '</div>' + '</div>' + - '<iframe style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' + + '<iframe title="PopupFrame" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' + '</div>'; theBody.appendChild(popmask); theBody.appendChild(popcont); @@ -327,4 +327,4 @@ function displaySelectBoxes() { } } } -} \ No newline at end of file +} diff --git a/public/admin/js/treeselect/treeselect.js b/public/admin/js/treeselect/treeselect.js index 1289bbc5586fa517e108a893ccd44092e6347e49..b42b728d00ed7ebc85020c512b67e195df0773b8 100644 --- a/public/admin/js/treeselect/treeselect.js +++ b/public/admin/js/treeselect/treeselect.js @@ -473,6 +473,12 @@ $('li.ui-treeselect-category>input:first-child').remove(); }, + itemsNotSelectable: function() { + $('li.ui-treeselect-item>input:first-child').remove(); + $('li.ui-treeselect-item').attr('style', 'padding-left: 25px'); + }, + + readSelection: function(callback) { callback( this._getSelectedDataByType('item'), diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 2bf319356e93430e0e6d6a7d0fb728d0667f19cd..f3a40dc555ab8217cf1d618017358ed573d56681 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -794,29 +794,36 @@ ul.view-raw-rss li { border: 2px solid rgba(0,0,0, 0.4); border-radius: 5px; float: left; - opacity: 50%; + opacity: 0.5; position: absolute; } -.embedcode>div + div { +.embedcode { max-width: 200px; padding: 5px; + margin-top: 5px; } -.embedcode>div + div textarea{ - width: 190px; +.embedcode span.embed-code-to-copy { + width: 180px; + color: black; } -.embedcode>div:first-child { +.embedcode-button { cursor: pointer; font-size: 1.1em; - opacity: 50%; } -.embedcode:hover>div:first-child { - color: white; - opacity: 100%; +.embedcode > * { + opacity: 0.5; + font-size: 0.9em; +} + + +.embedcode:hover, +.embedcode:hover > * { + opacity: 1; } @@ -2107,14 +2114,22 @@ button.vodeclic_link + img { border:1px solid #C8C8C8; } -.permalien-img+div div:first-child div:first-child { +.permalien-img + div div:first-child div:first-child { float:left; } -.permalien-img+div input { +.permalink-url, +.embed-code-to-copy { margin:5px; border:1px solid #C8C8C8; - width: 404px; + width: 20em; + overflow-y: hidden; + overflow-x: scroll; + white-space: nowrap; + display: block; + padding: 5px; + height: 2.3em; + background-color: white; } @@ -2150,6 +2165,29 @@ button.vodeclic_link + img { max-width: 95%; } +.audiojs { + max-width: 500px; +} + +.audio_track { + position: relative; + max-width: 300px; +} + +.audio_track a + a { + position: absolute; + right: 20px; +} + +.audio_track.playing { + font-weight: bold; +} + +.audio_tracks_control .previous { + margin-right: 20px; +} + + /** barre de lien Mur **/ .barre-de-lien { @@ -2930,4 +2968,14 @@ a.loan-export { box-shadow: 2px 2px 2px black; cursor: pointer; color: black; +} + + +#fieldset-login_form legend { + display: none; +} + + +.boite .contenu { + min-height: 20px; } \ No newline at end of file diff --git a/public/opac/images/cc/by-nc-nd.png b/public/opac/images/cc/by-nc-nd.png new file mode 100644 index 0000000000000000000000000000000000000000..9abe7bdd149f986ee4fbb7bbaf5101ba66607e5c Binary files /dev/null and b/public/opac/images/cc/by-nc-nd.png differ diff --git a/public/opac/images/cc/by-nc-sa.png b/public/opac/images/cc/by-nc-sa.png new file mode 100644 index 0000000000000000000000000000000000000000..9fb8f62a320348239f2c3e2ec6602519f9d00aca Binary files /dev/null and b/public/opac/images/cc/by-nc-sa.png differ diff --git a/public/opac/images/cc/by-nc.png b/public/opac/images/cc/by-nc.png new file mode 100644 index 0000000000000000000000000000000000000000..e5a98f22be4785ddb7c651484159f825ce9fc92e Binary files /dev/null and b/public/opac/images/cc/by-nc.png differ diff --git a/public/opac/images/cc/by-nd.png b/public/opac/images/cc/by-nd.png new file mode 100644 index 0000000000000000000000000000000000000000..d9e71862dad90bd203994b76c3a89d4b93184b49 Binary files /dev/null and b/public/opac/images/cc/by-nd.png differ diff --git a/public/opac/images/cc/by-sa.png b/public/opac/images/cc/by-sa.png new file mode 100644 index 0000000000000000000000000000000000000000..8386b1bbea9ca6286ac6493b2311433c84ac992b Binary files /dev/null and b/public/opac/images/cc/by-sa.png differ diff --git a/public/opac/images/cc/by.png b/public/opac/images/cc/by.png new file mode 100644 index 0000000000000000000000000000000000000000..b88177353fa83102799b01641e474461a4dfe69b Binary files /dev/null and b/public/opac/images/cc/by.png differ diff --git a/public/opac/images/cc/cc-zero.png b/public/opac/images/cc/cc-zero.png new file mode 100644 index 0000000000000000000000000000000000000000..6ab8c29c96f7ab66e8caf9534bdb29a34e5f03fe Binary files /dev/null and b/public/opac/images/cc/cc-zero.png differ diff --git a/public/opac/images/cc/publicdomain.png b/public/opac/images/cc/publicdomain.png new file mode 100644 index 0000000000000000000000000000000000000000..3585ea59a6a6b80446610f5ebfa219194e85bbe8 Binary files /dev/null and b/public/opac/images/cc/publicdomain.png differ diff --git a/public/opac/js/butterfly/alert-64.png b/public/opac/js/butterfly/alert-64.png new file mode 100644 index 0000000000000000000000000000000000000000..c836fec1ef19889577ae1a930ed0ea2be25461ea Binary files /dev/null and b/public/opac/js/butterfly/alert-64.png differ diff --git a/public/opac/js/butterfly/butterfly-ie.css b/public/opac/js/butterfly/butterfly-ie.css new file mode 100644 index 0000000000000000000000000000000000000000..5f2d24399cb5db0d1ee1eb3ed8adad8e86a8462e --- /dev/null +++ b/public/opac/js/butterfly/butterfly-ie.css @@ -0,0 +1,37 @@ +/** + * jquery.butterfly.js + * @version 0.10 + * @see http://irama.org/web/dhtml/butterfly/ + * @license GNU GENERAL PUBLIC LICENSE (GPL) <http://www.gnu.org/licenses/gpl.html> + */ + /* butterfly lightbox IE6 hacks */ + * html #jb-overlay { + position: absolute !important; + top: expression(eval(document.documentElement.scrollTop)); + height: expression(eval(document.documentElement.clientHeight) + 'px'); + filter: alpha(opacity = 70); + } + * html #jb-window { + position: absolute; + top: expression(eval(document.documentElement.scrollTop)); + height: expression(eval(document.documentElement.clientHeight) + 'px'); + } + * html #jb-window.reactive { + background-image: url(../images/skin/reactive-overlay.gif); + } + * html #jb-window-inner { + margin-top: expression( (( this.parentNode.clientHeight - this.clientHeight ) / 2 ) + "px" ); + margin-left: auto; + margin-right: auto; + overflow: auto !important; + } + * html #jb-window-content { + overflow: hidden; + } + + + /* IE6 Fixed Position Jitter Fix */ + * html { + background-image: url(about:blank); + background-attachment: fixed; + } diff --git a/public/opac/js/butterfly/butterfly-thumb.jpg b/public/opac/js/butterfly/butterfly-thumb.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9c6db5c8eec1f07aec972b6bf150bbf48337e2d7 Binary files /dev/null and b/public/opac/js/butterfly/butterfly-thumb.jpg differ diff --git a/public/opac/js/butterfly/butterfly.css b/public/opac/js/butterfly/butterfly.css new file mode 100644 index 0000000000000000000000000000000000000000..4c3bc39b8deb5414352d64d44fecaec33b9580d5 --- /dev/null +++ b/public/opac/js/butterfly/butterfly.css @@ -0,0 +1,125 @@ +/** + * jquery.butterfly.js + * @version 0.10 + * @see http://irama.org/web/dhtml/butterfly/ + * @license GNU GENERAL PUBLIC LICENSE (GPL) <http://www.gnu.org/licenses/gpl.html> + */ + +#jb-overlay { + background: #000; + z-index: 999; + position: fixed; + top: 0; + height: 100%; + left: 0; + width: 100%; +} +#jb-window { + z-index: 1000; + position: fixed; + top: 0; + height: 100%; + left: 0; + width: 100%; +} + +#jb-window-inner { + background-color: #fff; + color: #444; + width: 50%; + height: 50%; + margin: auto; + overflow: auto; + /*position: relative;*/ +} + +#jb-loading { /* For semantic value, not to be seen */ + position: absolute; + left: 0; top: 0; + width: 0; height: 0; + padding: 0; margin: 0; + line-height: 0; + display: block; + overflow: hidden; +} + +#jb-window.reactive { + background: transparent url(reactive-overlay.png) right top no-repeat; +} + + +#jb-window.loading #jb-window-inner { + background-image: url(loading-black-on-white.gif); + background-position: center center; + background-repeat: no-repeat; +} +/*.type-fragment #jb-window-content, */ +.type-ajax #jb-window-content { + padding: 0 1em 1em; +} + +.type-media #jb-window-content { + padding: 0; +} + +#jb-window-content:focus { + outline: none; +} + +#jb-window-content .jb-caption { + display: block; + clear: both; + margin: 0; + position: absolute; + bottom: 0; + left: 0; + background: #fff; + width: 100%; +} +#jb-window-content .jb-caption span { + display: block; + padding: .5em 1em; +} + + + + +#jb-close-button img { + border: none; +} + +#jb-window.error-no-content #jb-window-content { + background: transparent url(alert-64.png) 15px center no-repeat; + padding-left: 70px; +} + +/* Image replacement on gallery controls */ + #jb-gallery-prev, + #jb-gallery-next { + height: 0; + padding-top: 85px; + width: 49px; + background: transparent url(gallery-controls-sprite.png) left top no-repeat; + } + #jb-gallery-next { + background-position: -49px top; + } + #jb-gallery-prev:hover, + #jb-gallery-prev:focus { + background-position: left -85px; + } + #jb-gallery-next:hover, + #jb-gallery-next:focus { + background-position: -49px -85px; + } + #jb-gallery-prev.disabled, + #jb-gallery-next.disabled { + background: none; + cursor: default; + } + + .type-iframe #jb-window-content iframe { + border: none; + background: transparent; + padding: 0; + } diff --git a/public/opac/js/butterfly/butterfly.jpg b/public/opac/js/butterfly/butterfly.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e407b320cf9a2394cfa23b6a20b850ea14c3f7ae Binary files /dev/null and b/public/opac/js/butterfly/butterfly.jpg differ diff --git a/public/opac/js/butterfly/close-black.png b/public/opac/js/butterfly/close-black.png new file mode 100644 index 0000000000000000000000000000000000000000..6ac5532fc1a9047f7b0b9d36dcec38850171da81 Binary files /dev/null and b/public/opac/js/butterfly/close-black.png differ diff --git a/public/opac/js/butterfly/close.png b/public/opac/js/butterfly/close.png new file mode 100644 index 0000000000000000000000000000000000000000..a758a3d79b130e5008c5aedc5e2bdc773ced2283 Binary files /dev/null and b/public/opac/js/butterfly/close.png differ diff --git a/public/opac/js/butterfly/external.html b/public/opac/js/butterfly/external.html new file mode 100644 index 0000000000000000000000000000000000000000..c965a231f703eacba2a4312d39d04fb059c0fe54 --- /dev/null +++ b/public/opac/js/butterfly/external.html @@ -0,0 +1,34 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>Test content</title> +</head> + +<body> + +<p>A page with test content.</p> + +<div id="external-fragment"> + <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <a href="#">Aliquam hendrerit lacinia justo,</a> eu ornare eros convallis sed. Nam lacus urna, auctor quis fringilla in, malesuada sit amet lacus. Aliquam erat volutpat. Vivamus turpis sapien, luctus sit amet rutrum vitae, dapibus sed ipsum. Ut interdum suscipit pretium. Etiam semper aliquam sapien nec porttitor. Nunc quis lacinia augue. Fusce eros neque, vulputate ut dignissim quis, fringilla fermentum velit. Nulla lacinia sollicitudin faucibus. In id nibh justo. Quisque hendrerit, nulla at placerat accumsan, magna augue placerat sem, eget tempus dui ipsum eu tellus. Phasellus interdum semper sapien, sit amet tristique metus porta ac. Integer vestibulum, dolor eu rhoncus porta, augue risus condimentum tortor, sed rhoncus ante dui sit amet lorem. Sed pellentesque nulla et erat sollicitudin at scelerisque lectus faucibus. Nulla quis dapibus turpis. Sed id velit sapien, at pulvinar nibh. In tincidunt laoreet urna vel molestie.</p> + <p>Praesent mauris nisl, vulputate id ultricies non, semper quis nisl. Integer enim neque, egestas eget consequat ut, facilisis non lectus. Nam molestie vulputate tincidunt. Sed at dui dui, nec lacinia mi. Praesent posuere leo eget nibh fermentum a eleifend tortor aliquet. Sed ac urna mauris, eu cursus elit. Nunc quis felis et justo aliquet pretium. Ut massa quam, interdum vitae rutrum vitae, auctor non ligula. Ut facilisis faucibus lorem, vitae rhoncus felis posuere ac. Vivamus vitae tellus eget tellus tincidunt scelerisque vel at tortor. Donec non ullamcorper nulla. Mauris pulvinar interdum felis eget egestas. Donec ac nunc velit, at eleifend sem. Duis mollis tempus vehicula. Etiam id mauris nunc. Vivamus sollicitudin sem ullamcorper leo commodo non pellentesque est fermentum. Maecenas adipiscing dui vel odio vulputate lacinia. Vestibulum sed mattis sapien. Aenean odio justo, ultrices eu dignissim laoreet, mattis id lacus. Vestibulum sed felis nulla, ac molestie nisl.</p> + <p>Nulla rhoncus mi eget nisi aliquam id porta metus consectetur. Nulla tempor magna ut odio tincidunt sollicitudin. Quisque ac venenatis felis. Donec blandit nisl id turpis rhoncus molestie. Pellentesque consequat dapibus lobortis. Pellentesque ut arcu metus. Morbi vel dui quis augue convallis placerat non at sem. Morbi quis sem ut felis hendrerit mattis. Proin non ante in sapien accumsan adipiscing id sit amet nulla. Nunc accumsan fringilla diam, quis molestie nibh bibendum ac. Aenean libero libero, placerat quis laoreet in, lobortis ac risus. Nam lorem sapien, laoreet nec vehicula sit amet, placerat malesuada sapien. Mauris mattis placerat quam, sit amet blandit nulla viverra et. Proin condimentum egestas est in mattis.</p> + + <p>Nam ultrices pulvinar quam ac aliquam. Praesent vel ultricies massa. Donec varius mi non tortor sodales quis ullamcorper odio volutpat. Morbi dapibus eros et justo convallis eget dictum elit fringilla. Suspendisse volutpat auctor pulvinar. Donec mattis feugiat mi eu suscipit. Sed sed nisl enim. Sed eu urna eu risus eleifend pellentesque eu sit amet odio. Vivamus sodales felis ac diam pellentesque ut tincidunt sem tincidunt. Maecenas magna dolor, tincidunt vitae luctus quis, tincidunt a justo. Mauris eros leo, varius vel vestibulum quis, interdum feugiat nulla. </p> + <p>Quisque ut nisl mattis metus dictum viverra. Aliquam enim ante, lobortis eget varius sed, tincidunt sagittis justo. In fermentum ullamcorper eros at mollis. Donec semper feugiat justo et varius. Ut ultrices, massa sit amet pellentesque malesuada, velit eros dictum justo, vitae pellentesque mauris dui ac nunc. Suspendisse posuere eleifend orci, ac dictum risus venenatis ac. Cras ut justo ac tortor egestas condimentum. Suspendisse quis mi nec nunc convallis laoreet ut vitae lorem. Fusce nisi odio, dapibus quis auctor quis, facilisis accumsan sem. Vestibulum sem ante, condimentum ut pellentesque porta, lacinia id mauris. Etiam dapibus nisi sit amet nisl euismod facilisis. In quis lacus eget lectus venenatis tincidunt vitae sit amet nibh. Nunc fermentum tellus mollis magna rhoncus pellentesque. Praesent scelerisque odio a diam ultricies sed bibendum leo adipiscing. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut aliquet, libero eget vestibulum posuere, est ante aliquet urna, ac rhoncus ligula arcu et leo. Cras fermentum gravida auctor. Morbi ac elit eget velit <a href="#">malesuada blandit</a>. In tincidunt nisi sed ligula viverra malesuada. Sed eleifend luctus arcu in tincidunt. </p> + + <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam hendrerit lacinia justo, eu ornare eros convallis sed. Nam lacus urna, auctor quis fringilla in, malesuada sit amet lacus. Aliquam erat volutpat. Vivamus turpis sapien, luctus sit amet rutrum vitae, dapibus sed ipsum. Ut interdum suscipit pretium. Etiam semper aliquam sapien nec porttitor. Nunc quis lacinia augue. Fusce eros neque, vulputate ut dignissim quis, fringilla fermentum velit. Nulla lacinia sollicitudin faucibus. In id nibh justo. Quisque hendrerit, nulla at placerat accumsan, magna augue placerat sem, eget tempus dui ipsum eu tellus. Phasellus interdum semper sapien, sit amet tristique metus porta ac. Integer vestibulum, dolor eu rhoncus porta, augue risus condimentum tortor, sed rhoncus ante dui sit amet lorem. Sed pellentesque nulla et erat sollicitudin at scelerisque lectus faucibus. Nulla quis dapibus turpis. Sed id velit sapien, at pulvinar nibh. In tincidunt laoreet urna vel molestie.</p> + <p>Praesent mauris nisl, vulputate id ultricies non, semper quis nisl. Integer enim neque, egestas eget consequat ut, facilisis non lectus. Nam molestie vulputate tincidunt. Sed at dui dui, nec lacinia mi. Praesent posuere leo eget nibh fermentum a eleifend tortor aliquet. Sed ac urna mauris, eu cursus elit. Nunc quis felis et justo aliquet pretium. Ut massa quam, interdum vitae rutrum vitae, auctor non ligula. Ut facilisis faucibus lorem, vitae rhoncus felis posuere ac. Vivamus vitae tellus eget tellus tincidunt scelerisque vel at tortor. Donec non ullamcorper nulla. Mauris pulvinar interdum felis eget egestas. Donec ac nunc velit, at eleifend sem. Duis mollis tempus vehicula. Etiam id mauris nunc. Vivamus sollicitudin sem ullamcorper leo commodo non pellentesque est fermentum. Maecenas adipiscing dui vel odio vulputate lacinia. Vestibulum sed mattis sapien. Aenean odio justo, ultrices eu dignissim laoreet, mattis id lacus. Vestibulum sed felis nulla, ac molestie nisl.</p> + <p>Nulla rhoncus mi eget nisi aliquam id porta metus consectetur. Nulla tempor magna ut odio tincidunt sollicitudin. Quisque ac venenatis felis. Donec blandit nisl id turpis rhoncus molestie. Pellentesque consequat dapibus lobortis. Pellentesque ut arcu metus. Morbi vel dui quis augue convallis placerat non at sem. Morbi quis sem ut felis hendrerit mattis. Proin non ante in sapien accumsan adipiscing id sit amet nulla. Nunc accumsan fringilla diam, quis molestie nibh bibendum ac. Aenean libero libero, placerat quis laoreet in, lobortis ac risus. Nam lorem sapien, laoreet nec vehicula sit amet, placerat malesuada sapien. Mauris mattis placerat quam, sit amet blandit nulla viverra et. Proin condimentum egestas est in mattis.</p> +</div> + +<div id="another-fragment"> + + <p>Praesent mauris nisl, <a href="#">vulputate id ultricies non</a>, semper quis nisl. Integer enim neque, egestas eget consequat ut, facilisis non lectus. Nam molestie vulputate tincidunt. Sed at dui dui, nec lacinia mi. Praesent posuere leo eget nibh fermentum a eleifend tortor aliquet. Sed ac urna mauris, eu cursus elit. Nunc quis felis et justo aliquet pretium. Ut massa quam, interdum vitae rutrum vitae, auctor non ligula. Ut facilisis faucibus lorem, vitae rhoncus felis posuere ac. Vivamus vitae tellus eget tellus tincidunt scelerisque vel at tortor. Donec non ullamcorper nulla. Mauris pulvinar interdum felis eget egestas. Donec ac nunc velit, at eleifend sem. Duis mollis tempus vehicula. Etiam id mauris nunc. Vivamus sollicitudin sem ullamcorper leo commodo non pellentesque est fermentum. Maecenas adipiscing dui vel odio vulputate lacinia. Vestibulum sed mattis sapien. Aenean odio justo, ultrices eu dignissim laoreet, mattis id lacus. Vestibulum sed felis nulla, ac molestie nisl.</p> + <p>Nulla rhoncus mi eget nisi aliquam id porta metus consectetur. Nulla tempor magna ut odio tincidunt sollicitudin. Quisque ac venenatis felis. Donec blandit nisl id turpis rhoncus molestie. Pellentesque consequat dapibus lobortis. Pellentesque ut arcu metus. Morbi vel dui quis augue convallis placerat non at sem. Morbi quis sem ut felis hendrerit mattis. Proin non ante in sapien accumsan adipiscing id sit amet nulla. Nunc accumsan fringilla diam, quis molestie nibh bibendum ac. Aenean libero libero, placerat quis laoreet in, lobortis ac risus. Nam lorem sapien, laoreet nec vehicula sit amet, placerat malesuada sapien. Mauris mattis placerat quam, sit amet blandit nulla viverra et. Proin condimentum egestas est in mattis.</p> + +</div> + + +</body> +</html> diff --git a/public/opac/js/butterfly/gallery-controls-sprite.png b/public/opac/js/butterfly/gallery-controls-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..9eb249870c4926a8ff2179d0d00711f54debef30 Binary files /dev/null and b/public/opac/js/butterfly/gallery-controls-sprite.png differ diff --git a/public/opac/js/butterfly/gallery-controls-sprite.psd b/public/opac/js/butterfly/gallery-controls-sprite.psd new file mode 100644 index 0000000000000000000000000000000000000000..5f1f9b3bc203a2e746fdf311a2557df3c12f9919 Binary files /dev/null and b/public/opac/js/butterfly/gallery-controls-sprite.psd differ diff --git a/public/opac/js/butterfly/index.html b/public/opac/js/butterfly/index.html new file mode 100644 index 0000000000000000000000000000000000000000..8b46b90c30004a6038dcbc90a02ca7e1cab26efe --- /dev/null +++ b/public/opac/js/butterfly/index.html @@ -0,0 +1,145 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>Butterfly lightbox test page</title> +<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js"></script> +<script type='text/javascript' src='jquery.resize-events.js'></script> +<script type='text/javascript' src='jquery.history.js'></script> +<script type='text/javascript' src='jquery.pxToEm.js'></script> +<script type='text/javascript' src='jquery.butterfly.js'></script> +<script type="text/javascript"> +$(function(){ + /* Enhance all image links, and internal (relative) links only */ + //$('a:not([href^="http://"]), a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"]').butterfly(options={ + $('#examples a').not('.image').butterfly(options={ + contentDefaultWidth: '50em', // for content + contentDefaultHeight: '100%', // for content + mediaMaxWidth: '100%', // for images + mediaMaxHeight: '100%', // for images + lightBoxMargin: '2em', // margin around screen (can be em, % or px) + animateResize: true, + //animationSpeed: 250, // in ms + //preloadNextGalleryImage: false, + //reuseFragment: true, + //closeButton: true, + //closeButtonImage: 'close.png', + //galleryMode: 'all', + //galleryLoops: true, + galleryContainers: '.gallery-test', // can specify more than one, i.e. '#gallery-container, .gallery-test' + preloadLoadingImage: 'loading-black-on-white.gif', + preloadGalleryControlsSprite: 'gallery-controls-sprite.png' + }); + + options.treatAsImage = true; + $('#examples a.image').butterfly(options); +}); +</script> +<link type="text/css" rel="stylesheet" href="butterfly.css" /> +<!--[if lt IE 9]> + <link type="text/css" rel="stylesheet" href="butterfly-ie.css" /> +<![endif]--> +<style type="text/css"> + /* + Styles for this page + */ + body { + font-family: Helvetica, Arial, sans-serif; + background: #efefef; + color: #000; + } + #page-container { + width: 48em; + padding: 1em; + margin: 1em auto; + background: #fff; + } + + .butterfly-gallery-demo { + overflow: hidden; + clear: both; + } + .butterfly-gallery-demo ul { + overflow: hidden; + clear: both; + background: #000; + float: left; + padding: 0 1em; + } + .butterfly-gallery-demo li { + list-style-type: none; + float: left; + margin: 1em; + padding: 0; + } + .butterfly-gallery-demo li a { + display: block; + float: left; + } + .butterfly-gallery-demo li a:hover, + .butterfly-gallery-demo li a:focus { + outline: 2px solid #fff; + } + +</style> +</head> + +<body> + +<div id="page-container"> + + <h1>Butterfly lightbox test page</h1> + <p>This page demonstrates <a href="http://irama.org/web/dhtml/butterfly/"><em>Butterfly</em>, a robust, flexible and fully accessible lightbox solution</a>.</p> + + <p>Note: This lightbox effect will not work in IE6, but the fallback (linked content) is still accessible and usable to visitors using IE6.</p> + <p>Butterfly has been tested and works in Internet Explorer 7–9, Safari 5, Chrome 11, Opera 11 and Firefox 3–4.</p> + + <div id="examples"> + <p>Butterfly can link to any content, for example:</p> + <ul class="gallery-test"> + <li><a href="butterfly.jpg" rel="gallery" title="The Cairns Birdwing butterfly">An image (with a caption)</a></li> + <li><a href="#same-page-fragment" rel="gallery">A fragment of content from the same page</a></li> + <li><a href="external.html" rel="gallery">Another page of content (using Ajax)</a></li> + <li><a href="external.html#external-fragment" rel="gallery">A fragment from within the external content page</a></li> + <li><a href="http://en.wikipedia.org/wiki/Cairns_Birdwing" rel="gallery">External domain, via iframe</a></li> + </ul> + + <p>Test also:</p> + <ul> + <li>An image with thumbnail (at right) <a href="http://irama.org/assets/images/dhtml/butterfly/butterfly-1.jpg" style="float: right;"><img src="http://irama.org/assets/images/dhtml/butterfly/butterfly-1-preview.jpg" alt="test image" /></a></li> + <li><a href="external.html#another-fragment">Another fragment from the external content page</a></li> + <li>Try resizing the window and making it quite narrow or short (or change the text size)!</li> + <li><a class="image" href="http://chart.apis.google.com/chart?cht=qr&chs=500x500&chl=http://irama.org/web/dhtml/butterfly/">Link to an image without an image file extension (option set to treat as imnage anyway).</a></li> + </ul> + + <div class="section" id="gallery"> + <h2>Gallery</h2> + <p>A gallery can be created using a container element or by specifying links with the same <code>rel</code> attribute.</p> + <div class="butterfly-gallery-demo"> + <ul> + <li><a href="http://irama.org/assets/images/dhtml/butterfly/butterfly-1.jpg" rel="butterflies"><img src="http://irama.org/assets/images/dhtml/butterfly/butterfly-1-preview.jpg" alt="Cairns Birdwing" /></a></li> + <li><a href="http://irama.org/assets/images/dhtml/butterfly/butterfly-2.jpg" rel="butterflies"><img src="http://irama.org/assets/images/dhtml/butterfly/butterfly-2-preview.jpg" alt="Orange butterfly" /></a></li> + <li><a href="http://irama.org/assets/images/dhtml/butterfly/butterfly-3.jpg" rel="butterflies"><img src="http://irama.org/assets/images/dhtml/butterfly/butterfly-3-preview.jpg" alt="Blue butterfly" /></a></li> + <li><a href="http://irama.org/assets/images/dhtml/butterfly/butterfly-4.jpg" rel="butterflies"><img src="http://irama.org/assets/images/dhtml/butterfly/butterfly-4-preview.jpg" alt="Green butterfly" /></a></li> + </ul> + </div> + </div> + + <div class="section" id="same-page-fragment"> + <h2>A fragment of this page</h2> + The <a href="butterfly.jpg">Cairns Birdwing</a> (<em>Ornithoptera euphorion</em>) is Australia's largest endemic butterfly species, with females reaching a wingspan of up to 16 cm. Males are usually a few centimeters smaller. A closely allied species, the New Guinea or Priam's Birdwing (<em>Ornithoptera priamus</em>) reaches 19 cm and is the largest butterfly species found in Australia, but it is not endemic. Cairns Birdwings are found southwards from Mount Webb and Cooktown to Mackay in Queensland. Its favoured habitat is primary rainforest, although the species will breed readily in a home garden if the correct larval host plants are grown. (via <a href="http://en.wikipedia.org/wiki/Cairns_Birdwing">Wikipedia</a>)</div> + + <div class="section" id="error-handling"> + <h2>Error handling</h2> + <p>These links are all broken:</p> + <ul> + <li><a href="butterfly-error.jpg">A broken image</a></li> + <li><a href="#fragment-error">A non-existent fragment</a></li> + <li><a href="external-error.html">A non-page</a></li> + <li><a href="external.html#fragment-error">A non-existent fragment from within a real external content page</a></li> + </ul> + </div> + </div> + </div> +</body> +</html> diff --git a/public/opac/js/butterfly/jquery.butterfly.js b/public/opac/js/butterfly/jquery.butterfly.js new file mode 100644 index 0000000000000000000000000000000000000000..191e5cdcce8690d78e52c741eda9ca657dcdb32f --- /dev/null +++ b/public/opac/js/butterfly/jquery.butterfly.js @@ -0,0 +1,1472 @@ +/* + * "Float like a butterfly" + * Muhammad Ali (a not-so-lightboxer). + * + * jquery.butterfly is a fairly light-weight and fully accessible lightbox implementation for jQuery. + * + * jquery.butterfly.js + * @version 0.13 + * Changelog: + * * 0.1 Initial implementation. + * * 0.2: Support for window resizing added. + * * 0.3: Support added for callback functions (open/close/resize pre and post events). Error handling added for when lightbox target resource doesn't exist. + * * 0.4: Accessibility features added (controlling focus for user initiated lightboxes, keyboard support) - as per: http://irama.org/web/dhtml/lightbox/#accessibility + * * 0.5: Bug fixes for webkit. Blocked IE6 (no LB for them). Basic caption support (thanks to Ray Latchmanan). Gallery support. + * * 0.6: ARIA style keyboard support for navigating through galleries. Keyboard access now trapped in lightbox while lightbox is open. Support for preloading next image in galleries. + * * 0.7: Captions can be configured to come from link title attribute, link text (including any img alt text within), or not be displayed at all. + * * 0.8: Added ability to load pages in an iFrame (kicks in automatically for external-domain URLs). + * * 0.9: Support restored for IE6 (all thanks to the perseverance of github.com/bboyle - he has more patience than I). Added support for back button (through jquery.history.js) + * * 0.10: Set default close icon; fixing issues reported by jslint; minor jquery optimisations + * * 0.11: Fix for jQuery 1.8 compatibility issue + * * 0.12: Fix for captions extending outside lightbox (thanks to Roger Kowallis) + * * 0.13: Added option to treat links as image links (overriding automatic type detection). Handy for image URLs that don't have an image file extension (like Google Charts API URLs) + * + * @author Andrew Ramsden <http://irama.org/> + * @see http://irama.org/web/dhtml/butterfly/ + * @license GNU GENERAL PUBLIC LICENSE (GPL) <http://www.gnu.org/licenses/gpl.html> + * + * @requires jQuery (tested with 1.8.3) <http://jquery.com/> + * @requires jQuery jARIA plugin <http://outstandingelephant.com/jaria/> + * + * @optional (but reccommended) jQuery ResizeEvents plugin <http://irama.org/web/dhtml/resize-events/> + * @optional (but reccommended) jQuery Got Style? plugin <http://irama.org/web/dhtml/got-style/> + * @optional (but reccommended) jQuery ARIA keyboard navigation plugin <http://irama.org/web/dhtml/aria/key-nav/> + * + */ +jQuery.butterfly = {}; + +jQuery.butterfly.defaultOptions = { + contentDefaultWidth: null, // For content (can be em, % or px) - null default means 50em if pxToEm is available or 700px otherwise (a good line length for legibility) + contentDefaultHeight: '100%', // For content (can be em, % or px) + mediaMaxWidth: '100%', // For images (can be em, % or px) + mediaMaxHeight: '100%', // For images (can be em, % or px) + treatAsMedia: false, // Set to true for content to be resized as if it's media (good for video content) + lightBoxMargin: null, // Margin around screen (can be em, % or px) - null default === 2em if pxToEm is available or 20px otherwise + animateResize: true, + animationSpeed: 150, + useIframe: 'autodetect', // load contents in an iframe (good for cross-domain URLs). Options are: 'autodetect' (will load iframe for external URLs), true (will load in an iframe). false (will atempt to load with ajax). + collapseHeightWhenPossible: true, // When content is shorter than available height, collapse height of lightbox + reuseFragment: false, // When using a fragment from the same page as the link, reuse the same DOM nodes (persisting their state) or clone a new copy? + closeButton: true, // Should we have a close button? + closeButtonImage: 'close.png', // Set to the path of your close button image + closeButtonCorner: 'tr', // Top left 'tl' or top right 'tr' or bottom left (bl) or bottom right (br) - top left is the most intuitive option that doesn't overlap scrollabrs + clickOverlayCloses: true, // Will clicking the overlay layer (the dark tinted area) close the lightbox? + preloadLoadingImage: '', // Specify an image path here and it will be preloaded + preloadGalleryControlsSprite: '', // Specify an image path here and it will be preloaded + galleryControlWidth: 49, // width of each control (default based on sprite that ships with butterfly) + galleryControlHeight: 85, // height of each control (default based on sprite that ships with butterfly) + galleryMode: 'rel', // Allow navigation between lightboxed images? Options are: rel (all links that have the same 'rel' attribute), 'container' (all links within the one container), 'all' (all linked images), or nothing '' (don't use galleries) + galleryContainers: '', // CSS selectors specifying elements that contain linked images to form discrete galleries. e.g: '.gallery-pets, #gallery-flowers' + galleryLoops: false, // When you reach the end of the gallery, should 'next' take you back to the begining? (and vice versa) + captionMode: 'title', // Whether to use captions, and if so, where to grab the caption text from? Options are: 'title' (the title attribute of the link), 'text' (any text within the link, including image alt text), or nothing '' (don't display captions) + preloadNextGalleryImage: true, // Should the next lightbox be preloaded if it's an image? + zoomFromClicked: false, // Experimental + callbackPreOpen: null, // Six callback functions can be defined that will be called at various points in the opening, closing and resizing of lightboxes + callbackPreResize: null, + callbackPostResize: null, + callbackPostOpen: null, + callbackPreClose: null, + callbackPostClose: null, + treatAsImage: false // If set to true, will treat all links as image links (overriding automatic type detection). +}; + +jQuery.butterfly.conf = { + overlayOpacity: '.7', + lightboxClass: 'lightbox', + lightboxLinkSelector: 'a.lightbox' +}; + +jQuery.butterfly.linkCount = 0; + +/** + * Standard key mappings + */ + DOM_VK_END = 35; + DOM_VK_HOME = 36; + DOM_VK_LEFT = 37; + DOM_VK_UP = 38; + DOM_VK_RIGHT = 39; + DOM_VK_DOWN = 40; + DOM_VK_ESCAPE = 27; + +(function( $, ResizeEvents ) {// start closure + 'use strict'; + + + // functions and vars + var resizeLightBox, closeLightBox, initLightBox, openLightBox, loadLightBoxContent, + lightBoxKeypress, overlayClicked, loadLightBoxComplete, galleryControlsClick, + isImage, parsePixels, findOffsetToCentre, checkForContent; + + + // helper functions + + /** + * Get the keycode of an event + */ + function getKeyCode(evt) { + evt = evt || window.event; + + if (evt.keyCode) { + return evt.keyCode; + } else if (evt.which) { + return evt.which; + } + return null; + } + + /** + * jQuery plugin that returns the text nodes within the target element, combined/concatenated with any alt text. + */ + $.fn.accessibleText = function() { + if (this.is('img')) { + return this.attr( 'alt' ); + } else if (this.is('input')) { + return this.attr( 'value' ); + } else { + return $.map( this.contents(), function( domElement ) { + if ( domElement.nodeType === 3 ) { + return domElement.data; + } else if ( domElement.nodeType === 1 ) { + var $element = $( domElement ); + if ( $element.is( 'img, input' ) || $element.find( 'img[alt], input[value]' ).length > 0 ) { + return $element.accessibleText(); + } else { + return $element.text(); + } + } + }).join( '' ); + } + }; + + + // On DOMLoad + $(function() { + /*// IE6 fails, bail here. + if ($.browser.msie && $.browser.version < 7) { + return; + } + */ + + // If ResizeEvents plugin is available, listen for resize events + if (typeof ResizeEvents !== 'undefined') { + $(this).each(function(){ + ResizeEvents.bind ( + 'x-text-resize x-window-resize', // no need to catch 'x-initial-sizes', lightbox not open initially + resizeLightBox + ); + }); + } + + // Create containers + $( document.body ) + .append( '<div id="jb-overlay"></div><div id="jb-window"><div id="jb-window-inner"><div id="jb-window-content" style="width: auto; height: auto;" tabindex="0"></div></div></div>') + .bind( 'keydown', lightBoxKeypress ) + ; + $( '#jb-overlay' ) + .fadeTo( 0, $.butterfly.conf.overlayOpacity, function() { + // hide when animation complete + $( this ).hide(); + }) + ; + $( '#jb-window' ) + .hide() + .click( overlayClicked ) + ; + $( '#jb-window-inner' ) + .centre() + ; + $( '#jb-window-content' ) + .css({ + overflow: 'hidden' + }) + .hide() + ; + + $.history.init( + function( hash ){ + if( hash === '' ) { + closeLightBox.apply(); + } else { + // restore the state from hash + if( /^!/.test( hash )) { + hash = hash.substring( 1 ); + $( '#' + hash ).trigger( 'click', [/*storeState*/false] ); + } + } + }, + { unescape: ',/' } + ); + }); + + + $.fn.butterfly = function( options ) { + + // IE6 fails, bail here. + /*if ($.browser.msie && $.browser.version < 7) { + return; + }*/ + + options = typeof options !== 'undefined' ? options : {}; + + // Pre-load images + if (options.closeButtonImage) { + $('<img src="'+options.closeButtonImage+'" alt="" />'); + } + if (options.preloadLoadingImage) { + $('<img src="'+options.preloadLoadingImage+'" alt="" />'); + } + if (options.preloadGalleryControlsSprite) { + $('<img src="'+options.preloadGalleryControlsSprite+'" alt="" />'); + } + + // Initialise lightbox links for each match + return this.each(function () { + initLightBox.apply(this, [options]); + }); + }; + + + initLightBox = function( options ) { + var pxToEmExists = (typeof Number.prototype.pxToEm !== 'undefined') ? true : false; + + // Merge runtime options with defaults + // Note: The first argument sent to extend is an empty object to + // prevent extend from overriding the default $.AKN.defaultOptions object. + options = (typeof options === 'undefined') + ? $.butterfly.defaultOptions + : $.extend({}, $.butterfly.defaultOptions, options) + ; + + if (options.lightBoxMargin === null) { + // if no margin specified, use 2em if pxToEm available, otherwise use 20px + options.lightBoxMargin = pxToEmExists ? '2em' : '20px' ; + } + if (options.contentDefaultWidth === null) { + // if no default width specified, use 50em if pxToEm available, otherwise use 700px (good line lengths for legibility) + options.contentDefaultWidth = pxToEmExists ? '50em' : '700px' ; + } + + // Assign an id if none exists + if (typeof $(this).attr('id') === 'undefined' || $(this).attr('id') === '') { // cater for jquery 1.6 and previous versions + $(this).attr('id', $.butterfly.conf.lightboxClass+'-uid-'+$.butterfly.linkCount); + } + options.linkID = $(this).attr('id'); + $.butterfly.linkCount++; + + $(this).data('options', options); + $(this).addClass($.butterfly.conf.lightboxClass); + $(this).click(openLightBox); + }; + + + openLightBox = function( e, storeState ) { + var options, originalTrigger, href, location, title, linkText, thisLink, selector, previousOptions; + + if (typeof e !== 'undefined') { + e.preventDefault(); // so that links aren't followed + } + + // Add state to history + storeState = (typeof storeState !== 'undefined') ? storeState : true ; + if (storeState) { + $.history.load('!'+$(this).attr('id')); + return; // This function will be called again by history.load after storing the state in the hash + } + + // when opening, overflow should always be set to hidden (it is changed as appropriate later once the content loads) + $('#jb-window-inner').css('overflow','hidden'); + + // if lightbox is open already and fragment was reused... clean up + if ($('#jb-overlay').is(':visible')) { + options = $('#jb-overlay').data('options'); + if (options.linkType === 'fragment' && options.reuseFragment) { + $('.jb-placeholder').remove(); + } + originalTrigger = options.originalTrigger; + } else { + // if opening for the first time, set the original trigger + originalTrigger = this; + } + + // get target content + location = window.location.href.replace( /#.*$/, '' ); + href = $(this).attr('href'); + if ( href.indexOf( location ) === 0 ) { + href = href.substring( location.length ); + } + title = $(this).attr('title'); + linkText = $(this).accessibleText(); + + // get options + options = $(this).data('options'); + options.href = href; + options.title = title; + options.linkText = linkText; + options.trigger = this; // current trigger element + options.originalTrigger = originalTrigger; // original trigger element + + // custom class? + document.getElementById( 'jb-window-inner' ).className = options.className || ''; + + if (options.treatAsImage || isImage(href)) { + options.linkType = 'image'; + } else if (href.substring(0,1) === '#') { + options.linkType = 'fragment'; + } else if (options.useIframe === true || (options.useIframe !== false && this.hostname !== window.location.hostname)) { + options.linkType = 'iframe'; + options.useIframe = true; + options.contentDefaultWidth = '100%'; + options.contentDefaultHeight = '100%'; + } else { + options.linkType = 'ajax'; + } + + // run preOpen callback function + if (options.callbackPreOpen !== null && typeof options.callbackPreOpen === 'function') { + options.callbackPreOpen.apply(this); + } + + // add/remove close button + if (options.closeButton) { + if ($('#jb-close-button').length === 0) { + $('#jb-window').prepend('<a href="#" id="jb-close-button"><img src="'+options.closeButtonImage+'" alt="Close lightbox" /></a>'); + $('#jb-close-button').click(closeLightBox); + } + } else { + $('#jb-close-button').remove(); + } + + // add class if overlay can be clicked to close + if (options.clickOverlayCloses) { + $('#jb-window').addClass('reactive'); + } else { + $('#jb-window').removeClass('reactive'); + } + + // Find and store details of gallery (if configured) + thisLink = $(this); + if (options.galleryContainers !== '') { + options.galleryMode = 'container'; + } + options.gallerySelector = ''; + switch (options.galleryMode) { + case 'all': + options.gallerySelector = $.butterfly.conf.lightboxLinkSelector; + break; + case 'container': + $.each( options.galleryContainers.split( ',' ), function() { + selector = this + ' ' + $.butterfly.conf.lightboxLinkSelector; + if ( thisLink.is( selector )) { + options.gallerySelector = selector; + return false; // we found the container, break loop + } + }); + break; + // default: do nothing + } + if (options.gallerySelector === '' && $(this).attr('rel') !== '') { + options.gallerySelector = $.butterfly.conf.lightboxLinkSelector+'[rel="'+$(this).attr('rel')+'"]'; + } + + // grab previousOptions + previousOptions = $('#jb-overlay').data('options') || {}; + + // assign link options to lightbox + $(this).data('options', options); + $('#jb-overlay').data('options', options); + + // Temporarily focus here, until loading is complete + $('#jb-window').append('<p id="jb-loading">Loading...</p>'); + $('#jb-loading').attr('tabindex', '0').focus(); + + if ($('#jb-overlay').is(':visible')) { + // if lightbox is open: + + // cleanup after fragment positioning + if (previousOptions.linkType === 'fragment' && previousOptions.reuseFragment) { + $('.jb-placeholder').after($(previousOptions.href)); + $('.jb-placeholder').remove(); + $(previousOptions.href).disableFocussableElements(); + } + + // hide/clear content + $('#jb-window-content') + .hide() + .empty() + ; + $('#jb-window').addClass('loading'); + + loadLightBoxContent.apply(this, [loadLightBoxComplete]); + + } else { + // if lightbox is closed: + // Disable focussable elements + $( document.body ).disableFocussableElements( '#jb-window *' ); + + // hide button + $('#jb-close-button').hide(); + + // hide gallery controls + $('#jb-gallery-controls').hide(); + + // show overlay + $('#jb-overlay').fadeIn(options.animationSpeed).centre(); + + // open small lightbox with loading spinner + $('#jb-window') + .addClass('loading') + .show() + ; + + // to zoom or not to zoom? + if (options.zoomFromClicked) { + // align window with clicked element (for 'zoom in' effect) + $('#jb-window-inner').css({ + top: $(this).offset().top, + left: $(this).offset().left, + width: $(this).width(), + height: $(this).height() + }); + } else { + // just centre + $('#jb-window-inner') + .css({ + width: '100px', + height: '100px' + }) + .centre() + ; + } + + // load new content to hidden layer + loadLightBoxContent.apply(this, [loadLightBoxComplete]); + } + // for any images in the lightbox, if they are now physically smaller than the relevant max-size, add click-to-zoom capability + }; + + + loadLightBoxComplete = function(){ + // once loaded + // init options + var options = $('#jb-overlay').data('options'); + + // restore focussable elements inside content (in case content cloned from current page) + $('#jb-window').restoreFocussableElements(); + + // remove spinner + $('#jb-window').removeClass('loading'); + + + // Redundant settimeout for webkit, cause otherwise dimensions are 0 when image loaded from cache. Thanks JKS! <http://stackoverflow.com/users/144149/jks> + // @see http://stackoverflow.com/questions/318630/get-real-image-width-and-height-with-javascript-in-safari-chrome#answer-4909227 + setTimeout(function(){ + + // Establish appropriate classes for new content type before fade in + $('#jb-window').removeClass('type-media type-image type-fragment type-ajax'); + switch (options.linkType) { + case 'image': + $('#jb-window').addClass('type-image type-media'); + $('#jb-window-inner').css('overflow','hidden'); + break; + case 'fragment': + $('#jb-window').addClass('type-fragment'); + $('#jb-window-inner').css('overflow','auto'); + break; + case 'iframe': + $('#jb-window').addClass('type-iframe'); + $('#jb-window-inner').css('overflow','hidden'); + break; + case 'ajax': + $('#jb-window').addClass('type-ajax'); + $('#jb-window-inner').css('overflow','auto'); + break; + } + if (options.treatAsMedia) { + $('#jb-window').addClass('type-media'); + } + + // resize + resizeLightBox.apply(this, [function(){ + var nextControl; + + if (options.linkType === 'iframe') { + $('#jb-window-content').css('visibility', 'visible'); + } + // fade in new content + $('#jb-window-content').fadeIn(options.animationSpeed, function(){ + + // set focus to start of lightbox content + $('#jb-window-content') + //.attr('tabindex',0) // add to tab index (now occurs during initialisation) + .focus() // set focus + ; + + // Remove temporary loading message + $('#jb-loading').remove(); + + // run postOpen callback function + if (options.callbackPostOpen !== null && typeof options.callbackPostOpen === 'function') { + options.callbackPostOpen.apply(this); + } + + // preload next gallery image? + nextControl = $('#jb-gallery-next'); + if ( + options.preloadNextGalleryImage && + nextControl.length > 0 && + nextControl.is(':visible') && + nextControl.attr('href') !== '#' && + isImage(nextControl.attr('href')) + ) { + $('<img src="'+nextControl.attr('href')+'" alt="" />'); + } + }); + }]); + }, 0); + }; + + + resizeLightBox = function( callback ) { + + var options = $('#jb-overlay').data('options'), + lbMargin, availableWidth, availableHeight, contentDefaultWidth, contentDefaultHeight, mediaMaxWidth, mediaMaxHeight, w, h, + reductionRatio, prevWidth, topLeft, animationSpeed, buttonWidth, buttonHeight, buttonLeft, buttonTop, prevTop, prevLeft, nextTop, nextLeft; + + if (typeof options === 'undefined') { + return; // options haven't been assigned to lightbox overlay yet + } + + lbMargin = parseInt(parsePixels(options.lightBoxMargin), 10); + + availableWidth = $('#jb-window').width() - (lbMargin * 2); + availableHeight = $('#jb-window').height() - (lbMargin * 2); + + // find current default/max dimensions (convert to pixels if necessary) + contentDefaultWidth = parsePixels(options.contentDefaultWidth, availableWidth); + contentDefaultHeight = parsePixels(options.contentDefaultHeight, availableHeight); + mediaMaxWidth = parsePixels(options.mediaMaxWidth, availableWidth); + mediaMaxHeight = parsePixels(options.mediaMaxHeight, availableHeight); + + + // run preResize callback function + if (options.callbackPreResize !== null && typeof options.callbackPreResize === 'function') { + options.callbackPreResize.apply($('#jb-window'), [availableWidth, availableHeight, contentDefaultWidth, contentDefaultHeight, mediaMaxWidth, mediaMaxHeight]); + } + + /*// IE6 needs help with resizing the overlay and window + if ( + $.browser.msie && $.browser.version === 6 + ) { + + $('#jb-overlay, #jb-window').css({ + position: 'absolute', + top: 0-$( document.body ).css('margin-top'), + left: 0-$( document.body ).css('margin-left'), + width: $(window).width(), + height: $(window).height() + }); + + } + */ + + if (options.linkType === 'image' || options.treatAsMedia) { + + + + // measure content size + w = $('#jb-window-content').lightBoxContentWidth(); + h = $('#jb-window-content').lightBoxContentHeight(); + + + // compare dimensions against max width and height + if (w > mediaMaxWidth) { + reductionRatio = w / mediaMaxWidth; + w = mediaMaxWidth; + h = h / reductionRatio; + // $.debug('w ratio = '+reductionRatio); + } + if (h > mediaMaxHeight) { + reductionRatio = h / mediaMaxHeight; + h = mediaMaxHeight; + w = w / reductionRatio; + // $.debug('h ratio = '+reductionRatio); + } + + // compare dimensions against available width and height + if (w > availableWidth) { + reductionRatio = w / availableWidth; + w = availableWidth; + h = h * reductionRatio; + // $.debug('w ratio = '+reductionRatio); + } + if (h > availableHeight) { + reductionRatio = h / availableHeight; + h = availableHeight; + w = w * reductionRatio; + // $.debug('h ratio = '+reductionRatio); + } + // $.debug('max img width = '+options.mediaMaxWidth); + // $.debug('max img height = '+options.mediaMaxHeight); + + } else if (options.linkType === 'iframe') { + + w = contentDefaultWidth; + h = contentDefaultHeight; + + } else { + + // not an image or treat as media (must be content fragment) + + // $.debug('contentDefaultWidth = '+options.contentDefaultWidth); + // $.debug('contentDefaultHeight = '+options.contentDefaultHeight); + + // measure content width + w = $('#jb-window-content').lightBoxContentWidth(); + + if ( + contentDefaultWidth === '' || + contentDefaultWidth === '100%' || + availableWidth < contentDefaultWidth + ) { + w = availableWidth; + } else { + w = contentDefaultWidth; + } + + if (options.collapseHeightWhenPossible) { + + // set new width temporarily + prevWidth = $('#jb-window-inner').width(); + //$('#jb-window-inner').width(w); // not kicking in fast enough, use animate to lock in new width + $('#jb-window-inner').animate({width: w}, 0); + + // measure height + h = $('#jb-window-content').lightBoxContentHeight( false ); + + // set width back to previous value + $('#jb-window-inner').width(prevWidth); + + if ( + availableHeight < h + ) { + h = availableHeight; + // } else { + // do nothing + // h = contentDefaultHeight; + } + + } else { + + // same height for all content boxes (based on contentDefaultHeight) + h = $('#jb-window-content').lightBoxContentHeight(); + if ( + contentDefaultHeight === '' || + contentDefaultHeight === '100%' || + availableHeight < contentDefaultHeight + ) { + h = availableHeight; + } else { + h = contentDefaultHeight; + } + } + } + + // $.debug('availableWidth = '+availableWidth); + // $.debug('availableHeight = '+availableHeight); + // $.debug('final w = '+w); + // $.debug('final h = '+h); + + topLeft = findOffsetToCentre(w, h); + + // if not animating resize, set speed to 0 + animationSpeed = options.animateResize ? options.animationSpeed : 0; + + $('#jb-close-button').hide(); + $('#jb-gallery-controls').hide(); + + if (options.linkType === 'iframe') { + $('#jb-window-inner iframe').css('visibility','hidden'); + } + + $('#jb-window-inner').animate({ + 'width' : w, + 'height' : h, + 'left' : topLeft[1], + 'top' : topLeft[0] + }, animationSpeed, 0, function() { + + options = $('#jb-overlay').data('options'); + w = $('#jb-window-inner').width(); + h = $('#jb-window-inner').height(); + + + // Show iframe + if (options.linkType === 'iframe') { + $('#jb-window-inner iframe') + .width(w) + .height(h) + ; + $('#jb-window-inner iframe').css('visibility','visible'); + } + + // Show close button + if ($('#jb-close-button').length > 0) { + buttonWidth = parseInt($('#jb-close-button').width(), 10); + buttonHeight = parseInt($('#jb-close-button').height(), 10); + + switch (options.closeButtonCorner) { + case 'tr': + buttonLeft = topLeft[1] + w - buttonWidth/2; + buttonTop = topLeft[0] - buttonHeight/2; + break; + case 'br': + buttonLeft = topLeft[1] + w - buttonWidth/2; + buttonTop = topLeft[0] + h - buttonHeight/2; + break; + case 'bl': + buttonLeft = topLeft[1] - buttonWidth/2; + buttonTop = topLeft[0] + h - buttonHeight/2; + break; + default: + // case 'tl': + buttonLeft = topLeft[1] - buttonWidth/2; + buttonTop = topLeft[0] - buttonHeight/2; + } + + $('#jb-close-button') + .css({ + position: 'absolute', + 'z-index': '999999', + left: buttonLeft, + top: buttonTop + }) + .show() + ; + } + + // Are gallery controls relevant? + if ($('#jb-gallery-controls').is('.active')) { + // Position gallery controls + prevTop = topLeft[0] + h/2 - options.galleryControlHeight/2; + prevLeft = topLeft[1] - options.galleryControlWidth; + $('#jb-gallery-prev').css({top: prevTop, left: prevLeft}); + + nextTop = topLeft[0] + h/2 - options.galleryControlHeight/2; + nextLeft = topLeft[1] + w; + $('#jb-gallery-next').css({top: nextTop, left: nextLeft}); + + // Show gallery controls + $('#jb-gallery-controls') + //.fadeIn() + .show() // faster! + ; + } + + // run postResize callback function + if (options.callbackPostResize !== null && typeof options.callbackPostResize === 'function') { + options.callbackPostResize.apply($('#jb-window'), [availableWidth, availableHeight, contentDefaultWidth, contentDefaultHeight, mediaMaxWidth, mediaMaxHeight]); + } + + if (typeof callback !== 'undefined' && typeof callback.apply !== 'undefined') { + callback.apply(); + } + }); + }; + + + loadLightBoxContent = function( callback ) { + + var options = $( '#jb-overlay' ).data( 'options' ), + href = options.href, + caption, gallerySet, prevControl, nextControl, prevLink, nextLink, + lbMargin, availableWidth, availableHeight, contentDefaultWidth, contentDefaultHeight, ajaxHref; + + // Populate caption + switch (options.captionMode) { + case 'title': + caption = options.title ? '<p class=\'jb-caption\'><span>' + options.title + '</span></p>':''; + break; + case 'text': + caption = options.linkText ? '<p class=\'jb-caption\'><span>' + options.linkText + '</span></p>':''; + break; + default: + caption = ''; + break; + } + + + // remove previous error states + $('#jb-window').removeClass('error-no-content'); + + // Setup/adjust gallery (next/prev) links + // Find the gallery set + gallerySet = $(options.gallerySelector); + + $('#jb-gallery-controls').removeClass('active'); + + if (gallerySet.length > 1 && gallerySet.isInSet('#'+options.linkID)) { + + // Setup the HTML for the gallery controls + if ($('#jb-gallery-controls').length === 0) { + $('#jb-window').append('<div id="jb-gallery-controls"></div>'); + prevControl = $('<a id="jb-gallery-prev" href="#">Previous</a>').click(galleryControlsClick); + nextControl = $('<a id="jb-gallery-next" href="#">Next</a>').click(galleryControlsClick); + $('#jb-gallery-controls').append(prevControl).append(nextControl); + prevControl.add(nextControl).css({ + position: 'absolute', + 'z-index': '99999', + display: 'block', + overflow: 'hidden' + }); + } else { + prevControl = $('#jb-gallery-prev'); + nextControl = $('#jb-gallery-next'); + prevControl.add(nextControl) + .removeClass('disabled') + .attr('tabindex', '0') + .attr('title', '') + .show() + ; + } + $('#jb-gallery-controls').hide(); + $('#jb-gallery-controls').addClass('active'); + + + // Find previous link + prevLink = gallerySet.prevInSet('#'+options.linkID); + if (prevLink === false) { + if (options.galleryLoops) { + prevLink = gallerySet.lastInSet(); + } else { + prevLink = $('<a href="#" id=""></a>'); + prevControl + .addClass('disabled') + .attr('tabindex', '-1') + // hide it or it traps mouse clicks + .hide() + ; + } + } + prevControl + .attr('href', prevLink.attr('href')) + .data('linkID', prevLink.attr('id')) + .attr('title', $.trim( prevLink.accessibleText() )) + ; + + // Find next link + nextLink = gallerySet.nextInSet('#'+options.linkID); + if (nextLink === false) { + if (options.galleryLoops) { + nextLink = gallerySet.firstInSet(); + } else { + nextLink = $('<a href="#" id=""></a>'); + nextControl + .addClass('disabled') + .attr('tabindex', '-1') + // hide it or it traps mouse clicks + .hide() + ; + } + } + nextControl + .attr('href', nextLink.attr('href')) + .data('linkID', nextLink.attr('id')) + .attr('title', $.trim( nextLink.accessibleText() )) + ; + + } else { + $('#jb-gallery-controls').hide(); + } + + switch (options.linkType) { + case 'fragment': // internal page fragment + + if (options.reuseFragment) { + $(href).after('<span class="jb-placeholder"></span>'); + $('#jb-window-content').empty().append($(href)); // href becomes a selector for an id fragment + } else { + $('#jb-window-content').empty().append($(href).clone(true)); + } + + checkForContent.apply(this, [options.linkType, href]); + callback.apply(this); + break; + + case 'image': // link to image + + $('#jb-window-content').empty().append( + '<img src="'+href+'" alt="" style="max-width: 100%; max-height: 100%; float: left;" />'+caption + ); + $('#jb-window-content img') + .error(function(){ + checkForContent.apply(this, [options.linkType, href, callback]); + }) + .data('full-width', '') + .data('full-height', '') + .load(callback) + ; + break; + + case 'iframe': // link to iframe URL + $('#jb-window-content').show().css('visibility', 'hidden'); + $('#jb-window-content').empty().append( + '<iframe src="'+href+'" title="'+caption+'" width="100%" height="1000" />' + ); + $('#jb-window-content').css('visibility', 'hidden'); + + lbMargin = parseInt(parsePixels(options.lightBoxMargin), 10); + availableWidth = $('#jb-window').width() - (lbMargin * 2); + availableHeight = $('#jb-window').height() - (lbMargin * 2); + // find current default/max dimensions (convert to pixels if necessary) + contentDefaultWidth = parsePixels(options.contentDefaultWidth, availableWidth); + contentDefaultHeight = parsePixels(options.contentDefaultHeight, availableHeight); + + $('#jb-window-content > iframe') + .width(contentDefaultWidth) + .height(contentDefaultHeight) + .error(function(){ + checkForContent.apply(this, [options.linkType, href, callback]); + }) + .load(callback) + ; + break; + + default: + // case 'ajax': + // case '': // link to external page (or fragment of a page) + // ajax call on remote file + $.ajaxSetup ({ + cache: true + }); + if (href.indexOf('#') !== -1) { + ajaxHref = href.split('#').join(' #'); + } else { + ajaxHref = href; + } + $('#jb-window-content').empty().load(ajaxHref, function(){ + checkForContent.apply(this, [options.linkType, href]); + callback.apply(this); + }); + } + }; + + + checkForContent = function( linkType, href, callback ) { + // check if no content loaded + var wasError = false, + options; + + // checkForContent only called for images on .error() + // otherwise, if no children() exist + if (linkType === 'image' || $('#jb-window-content').children().length === 0) { + wasError = true; + } + + if (wasError) { + options = $('#jb-overlay').data('options'); + options.linkType = 'fragment'; + options.treatAsMedia = false; + $('#jb-overlay').data('options', options); + $('#jb-window') + .removeClass('type-image type-media') + .addClass('type-fragment error-no-content') + ; + $('#jb-window-content').empty().append('<p>There was an error loading lightbox content. <strong>'+$(options.trigger).text()+'</strong> (<samp>'+href+'</samp>) could not be found.</p>'); + } + if (typeof callback !== 'undefined') { + callback.apply(this); + } + }; + + + closeLightBox = function( evt ) { + var options, href, originalTriggerEL; + + if ( evt ) { + evt.preventDefault(); // prevent click from following link + } + + if ($('#jb-window:hidden').length) { + return; // Already closed, do nothing + } + + options = $('#jb-overlay').data('options'); + href = options.href; + + // run preClose callback function + if (options.callbackPreClose !== null && typeof options.callbackPreClose === 'function') { + options.callbackPreClose.apply(options.trigger); + } + + // cleanup after fragment positioning + if (options.linkType === 'fragment' && options.reuseFragment) { + $('.jb-placeholder').after($(href)); + $('.jb-placeholder').remove(); + } + + + // Restore all focussable elements + $( document.body ).restoreFocussableElements(); + + $('#jb-overlay').fadeOut(options.animationSpeed); + $('#jb-window').hide(); + $('#jb-window-content').hide(); + + // return focus to original trigger element + originalTriggerEL = $(options.originalTrigger); + if (typeof originalTriggerEL.attr('tabindex') === 'undefined') { + originalTriggerEL.attr('tabindex',0); + } + originalTriggerEL.focus(); + + // Remove temporary loading message + $('#jb-loading').remove(); + + // run postClose callback function + if (options.callbackPostClose !== null && typeof options.callbackPostClose === 'function') { + options.callbackPostClose.apply(options.trigger); + } + + // TODO pop history? ... if this was a gallery, pop the entire gallery? + // window.history.back(); + + // TODO + // load '' = jump to top of screen + // load '!' = no jump, back links do not work + $.history.load( '' ); + }; + + + /** + * A plugin to measure the width of an element accurately (even if it is hidden) + */ + $.fn.lightBoxContentWidth = function () { + + var jbWindow = this.closest('#jb-window'), + jbWindowInner = $('#jb-window-inner'), + isImageType = jbWindow.hasClass('type-media') ? true : false, + isImageMedia = jbWindow.hasClass('media-image') ? true : false, + currentWidth = jbWindowInner.width(), + currentHeight = jbWindowInner.height(), + currentLeft = jbWindowInner.css('left'), + currentTop = jbWindowInner.css('top'), + fullWidth + ; + + // relax size for measurement + if ( + $.browser.msie && + $.browser.version === 7 && + isImageType && + isImageMedia && + this.find('img').outerWidth(true) === 0 // IE7 width === 0 on initial load + ) { // only works with '100%' for IE7 on initial load + jbWindowInner.css({ + width: '100%', + height: '100%', + left:0, + top:0 + }); + } else { // must use 'auto' for all other situations + jbWindowInner.css({ + width: 'auto', + height: 'auto', + left:0, + top:0 + }); + } + + + // if element is hidden, unhide it, then measure + if ( this.css('display') === 'none') { + + // make element display for a nanosecond + this.css('display', 'block'); + + // measure + if (isImageType) { + fullWidth = this.find('img').outerWidth(true); + } else { + fullWidth = this.outerWidth(true); + } + // restore + this.css('display', 'none'); + + } else { + fullWidth = this.outerWidth(true); + } + + + // reinstate previous size/position + jbWindowInner.css({'left':currentLeft,'top':currentTop}); + jbWindowInner.animate({ + width: currentWidth, + height: currentHeight//, + //left: curentLeft, + //top: currentTop + },0); + + return fullWidth; + }; + + + /** + * A plugin to measure the height of an element accurately (even if it is hidden) + */ + $.fn.lightBoxContentHeight = function( relaxWidth ) { + + var jbWindow = this.closest('#jb-window'), + jbWindowInner = jbWindow.find( '#jb-window-inner' ), + isImageType = jbWindow.hasClass('type-media') ? true : false, + isImageMedia = jbWindow.hasClass('media-image') ? true : false, + + // always relax height + currentWidth = jbWindowInner.width(), + currentHeight = jbWindowInner.height(), + currentLeft = jbWindowInner.css('left'), + currentTop = jbWindowInner.css('top'), + + fullHeight + ; + + relaxWidth = typeof relaxWidth !== 'undefined' ? relaxWidth : true; + + // relax size for measurement + if ( + $.browser.msie && + $.browser.version === 7 && + isImageType && + isImageMedia && + this.find('img').outerWidth(true) === 0 // IE7 width === 0 on initial load + ) { // only works with '100%' for IE7 on initial load + $('#jb-window-inner').height('100%'); + if (relaxWidth) { + $('#jb-window-inner').width('100%').css({left:0,top:0}); + } + } else { // must use 'auto' for all other situations + $('#jb-window-inner').height('auto'); + if (relaxWidth) { + $('#jb-window-inner').width('auto').css({left:0,top:0}); + } + } + + // if element is hidden, unhide it, then measure + if ( this.css('display') === 'none' ) { + + // make element display for a nanosecond + this.css('display', 'block'); + + // measure + fullHeight = this.outerHeight(true); + + // restore + this.css('display', 'none'); + + + } else { + fullHeight = $(this).outerHeight(true); + } + + // reinstate previous size + $('#jb-window-inner') + .width(currentWidth) + .height(currentHeight) + .css({left:currentLeft,top:currentTop}) + ; + + return fullHeight; + }; + + + overlayClicked = function( evt ) { + var options = $('#jb-overlay').data('options'); + + if ( evt.target === $('#jb-window').get(0) && options.clickOverlayCloses ) { + closeLightBox.apply(); + // } else { + // do nothing + } + }; + + + /** + * Key pressed on keyboard + */ + lightBoxKeypress = function( evt ) { + var evtKeyCode; + + //$.debug('Key pressed: '+evt.keyCode); + + // If lightbox is not open or if modifier keys are down, ignore key presses + if ( + !$('#jb-overlay').is(':visible') || + evt.ctrlKey || + evt.altKey || + evt.shiftKey || + evt.metaKey + ) { + return true; /* facilitate further bubbling */ + } + + // Get the key that was pressed + evtKeyCode = getKeyCode(evt); + + + // handle keypresses here + switch (evtKeyCode) { + case DOM_VK_UP: + case DOM_VK_LEFT: + $('#jb-gallery-prev').click(); + break; + case DOM_VK_DOWN: + case DOM_VK_RIGHT: + $('#jb-gallery-next').click(); + break; + case DOM_VK_HOME: + $($('#jb-overlay').data('options').gallerySelector).firstInSet().click(); + break; + case DOM_VK_END: + $($('#jb-overlay').data('options').gallerySelector).lastInSet().click(); + break; + case DOM_VK_ESCAPE: + closeLightBox.apply(); + break; + default: + // A different (untracked) key was pressed, just ignore it + return true; /* facilitate further bubbling */ + } + + // Event already handled, prevent default + evt.preventDefault(); + }; + + + /** + * Someone activated gallery 'next' or 'prev' links + */ + galleryControlsClick = function( evt ) { + var lightboxLink, + $this = $( this ); + + // Prevent default action + evt.preventDefault(); + + // find the gallery link, and activate it + if ( $this.data( 'linkID' ) !== '' ) { + + $( '#jb-gallery-controls' ).hide(); // hide gallery controls for the transition + + lightboxLink = $( '#' + $this.data( 'linkID' )); + return lightboxLink.click(); + } + }; + + + /** + * A plugin to centre a visible element on the screen + */ + $.fn.centre = function () { + return this.css({ + 'position': 'fixed', + 'top': ( $(window).height() - this.outerHeight() ) / 2 + 'px', + 'left': ( $(window).width() - this.outerWidth() ) / 2 + 'px' + }); + }; + + + findOffsetToCentre = function( w, h ) { + var topOffset = ( $(window).height() - h ) / 2, + leftOffset = ( $(window).width() - w ) / 2; + + //// $.debug ('w = '+w+' | h = '+h+' | top = '+top+' | left = '+left); + + return [ topOffset, leftOffset ]; + }; + + + /** + * Find if the node is in the set of nodes + */ + $.fn.isInSet = function( currentElement ) { + return this.index( $( currentElement )) !== -1; + }; + + + /** + * Find the next node in the currently selected set of nodes + */ + $.fn.nextInSet = function( currentElement ) { + var currentIndex = this.index( $( currentElement )); + if ( this.length > currentIndex + 1 ) { + return this.eq( currentIndex + 1 ); + } else { + return false; + } + }; + + + /** + * Find the previous node in the currently selected set of nodes + */ + $.fn.prevInSet = function( currentElement ) { + var currentIndex = this.index( $( currentElement )); + if ( currentIndex > 0 ) { + return this.eq( currentIndex - 1 ); + } else { + return false; + } + }; + + + /** + * Find the first node in the currently selected set of nodes + */ + $.fn.firstInSet = function() { + if ( this.length > 0 ) { + return this.eq( 0 ); + } else { + return false; + } + }; + + + /** + * Find the last node in the currently selected set of nodes + */ + $.fn.lastInSet = function() { + if ( this.length > 0 ) { + return this.eq( -1 ); + } else { + return false; + } + }; + + + /** + * from: http://stackoverflow.com/questions/1933501/how-to-put-targetblank-in-jquery + */ + isImage = function( fileName ) { + + if (typeof fileName === 'undefined' || fileName === '') { + return false; + } + var pos = String( fileName ).lastIndexOf( '.' ), + extension; + + if (pos === -1 ) { + return false; + } else { + return ( /^\.(jpg|png|gif|bmp|jpeg)$/i ).test( fileName.substring( pos )); + } + }; + + + /** + * Disable all focussable elements outside the lightbox. Stores previous tabindex for later restoration + * Currently targets links, common form elements and anything with tabindex > -1 + * @see http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus + */ + $.fn.disableFocussableElements = function( excludeElements ) { + excludeElements = excludeElements || ''; + var focussable = this.find( 'a, input, button, area, frame, iframe, [tabindex]' ).not( excludeElements ).not( '*[tabindex="-1"]' ); + + focussable.each(function() { + var $this = $( this ), + prevTabIndex = $this.attr( 'tabindex' ) + ; + + prevTabIndex = typeof ( prevTabIndex ) === 'undefined' || prevTabIndex === '' ? '' : prevTabIndex; + + $this + .data( 'prevTabIndex', prevTabIndex ) + .addClass( 'jb-unfocussed' ) + .attr( 'tabindex', '-1' ) + ; + }); + }; + + + /** + * Restore all focussable elements outside the lightbox. + */ + $.fn.restoreFocussableElements = function() { + var focussable = this.find( '.jb-unfocussed' ); + + focussable.each(function() { + var $this = $( this ), + prevTabIndex = $this.data( 'prevTabIndex' ); + + switch ( prevTabIndex ) { + case '': + $this.removeAttr( 'tabindex' ); + break; + default: + $this.attr( 'tabindex', prevTabIndex ); + } + + $this.removeClass( 'jb-unfocussed' ); + }); + }; + + + /** + * Converts % or em values to a number of pixels (integer). + * Use pxToEm (reverse mode) to convert em values to pixels (if the plugin is available) + * @param String input The dimenion to be converted (may include % or em or px) + * @param integer centDimension The dimension that represents 100% + * @return integer Converted dimension in pixels + */ + parsePixels = function( input, centDimension ) { + + centDimension = typeof centDimension !== 'undefined' ? centDimension : $( document.body ).width() ; + + input = input + .replace('px','') // remove px units if present + .replace(/^\s+|\s+$/g,"") // trim leading and trailing whitespace + ; + + if (!isNaN(input)) { + // int already, return as pixels + return parseInt(input, 10); + + } else if (input.substr(input.length - 1) === '%') { + // %, convert to pixels + + if (typeof centDimension !== 'undefined') { + input = parseInt(input + .substr(0, input.length - 1) // strip unit + .replace(/^\s+|\s+$/g,"") // trim + , 10); + return input/100 * parseInt(centDimension, 10); + } else { + $.debug('Warning: percentage unit was supplied to parsePixels() but could not be calculated because centDimension was not supplied.'); + return parseInt(input, 10); + } + + } else if (input.substr(input.length - 2) === 'em') { + // em, check for pxToEm and convert (or warn) + if (typeof Number.prototype.pxToEm !== 'undefined') { + input = parseInt(input + .substr(0, input.length - 2) // strip unit + .replace(/^\s+|\s+$/g,"") // trim + , 10); + input = input.pxToEm({ + reverse: true + }); + return input.substr(0, input.length - 2); // strip unit px; + + } else { + $.debug('Warning: em unit was supplied to parsePixels() but could not be calulated because pxToEm plugin was not found.'); + return parseInt(input, 10); + } + } else { + // unknown units, warn + $.debug('Warning: unknown unit was supplied. parsePixels() can support px, em or % units only.'); + return parseInt(input, 10); + } + }; + + +}( jQuery, ResizeEvents )); +/* end closure */ diff --git a/public/opac/js/butterfly/jquery.butterfly.min.js b/public/opac/js/butterfly/jquery.butterfly.min.js new file mode 100644 index 0000000000000000000000000000000000000000..991d111330950f792bbbd69d5e822564b82fb5ef --- /dev/null +++ b/public/opac/js/butterfly/jquery.butterfly.min.js @@ -0,0 +1,6 @@ +/** + * @author Andrew Ramsden <http://irama.org/> + * @see http://irama.org/web/dhtml/butterfly/ + * @license GNU GENERAL PUBLIC LICENSE (GPL) <http://www.gnu.org/licenses/gpl.html> + */ +jQuery.butterfly={},jQuery.butterfly.defaultOptions={contentDefaultWidth:null,contentDefaultHeight:"100%",mediaMaxWidth:"100%",mediaMaxHeight:"100%",treatAsMedia:!1,lightBoxMargin:null,animateResize:!0,animationSpeed:150,useIframe:"autodetect",collapseHeightWhenPossible:!0,reuseFragment:!1,closeButton:!0,closeButtonImage:"close.png",closeButtonCorner:"tr",clickOverlayCloses:!0,preloadLoadingImage:"",preloadGalleryControlsSprite:"",galleryControlWidth:49,galleryControlHeight:85,galleryMode:"rel",galleryContainers:"",galleryLoops:!1,captionMode:"title",preloadNextGalleryImage:!0,zoomFromClicked:!1,callbackPreOpen:null,callbackPreResize:null,callbackPostResize:null,callbackPostOpen:null,callbackPreClose:null,callbackPostClose:null,treatAsImage:!1},jQuery.butterfly.conf={overlayOpacity:".7",lightboxClass:"lightbox",lightboxLinkSelector:"a.lightbox"},jQuery.butterfly.linkCount=0,DOM_VK_END=35,DOM_VK_HOME=36,DOM_VK_LEFT=37,DOM_VK_UP=38,DOM_VK_RIGHT=39,DOM_VK_DOWN=40,DOM_VK_ESCAPE=27,function(e,t){"use strict";function i(e){return e=e||window.event,e.keyCode?e.keyCode:e.which?e.which:null}var n,a,o,l,s,r,d,c,h,b,p,u,f;e.fn.accessibleText=function(){return this.is("img")?this.attr("alt"):this.is("input")?this.attr("value"):e.map(this.contents(),function(t){if(3===t.nodeType)return t.data;if(1===t.nodeType){var i=e(t);return i.is("img, input")||i.find("img[alt], input[value]").length>0?i.accessibleText():i.text()}}).join("")},e(function(){"undefined"!=typeof t&&e(this).each(function(){t.bind("x-text-resize x-window-resize",n)}),e(document.body).append('<div id="jb-overlay"></div><div id="jb-window"><div id="jb-window-inner"><div id="jb-window-content" style="width: auto; height: auto;" tabindex="0"></div></div></div>').bind("keydown",r),e("#jb-overlay").fadeTo(0,e.butterfly.conf.overlayOpacity,function(){e(this).hide()}),e("#jb-window").hide().click(d),e("#jb-window-inner").centre(),e("#jb-window-content").css({overflow:"hidden"}).hide(),e.history.init(function(t){""===t?a.apply():/^!/.test(t)&&(t=t.substring(1),e("#"+t).trigger("click",[!1]))},{unescape:",/"})}),e.fn.butterfly=function(t){return t="undefined"!=typeof t?t:{},t.closeButtonImage&&e('<img src="'+t.closeButtonImage+'" alt="" />'),t.preloadLoadingImage&&e('<img src="'+t.preloadLoadingImage+'" alt="" />'),t.preloadGalleryControlsSprite&&e('<img src="'+t.preloadGalleryControlsSprite+'" alt="" />'),this.each(function(){o.apply(this,[t])})},o=function(t){var i="undefined"!=typeof Number.prototype.pxToEm?!0:!1;t="undefined"==typeof t?e.butterfly.defaultOptions:e.extend({},e.butterfly.defaultOptions,t),null===t.lightBoxMargin&&(t.lightBoxMargin=i?"2em":"20px"),null===t.contentDefaultWidth&&(t.contentDefaultWidth=i?"50em":"700px"),("undefined"==typeof e(this).attr("id")||""===e(this).attr("id"))&&e(this).attr("id",e.butterfly.conf.lightboxClass+"-uid-"+e.butterfly.linkCount),t.linkID=e(this).attr("id"),e.butterfly.linkCount++,e(this).data("options",t),e(this).addClass(e.butterfly.conf.lightboxClass),e(this).click(l)},l=function(t,i){var n,o,l,r,d,h,p,u,f;if("undefined"!=typeof t&&t.preventDefault(),i="undefined"!=typeof i?i:!0)return void e.history.load("!"+e(this).attr("id"));switch(e("#jb-window-inner").css("overflow","hidden"),e("#jb-overlay").is(":visible")?(n=e("#jb-overlay").data("options"),"fragment"===n.linkType&&n.reuseFragment&&e(".jb-placeholder").remove(),o=n.originalTrigger):o=this,r=window.location.href.replace(/#.*$/,""),l=e(this).attr("href"),0===l.indexOf(r)&&(l=l.substring(r.length)),d=e(this).attr("title"),h=e(this).accessibleText(),n=e(this).data("options"),n.href=l,n.title=d,n.linkText=h,n.trigger=this,n.originalTrigger=o,document.getElementById("jb-window-inner").className=n.className||"",n.treatAsImage||b(l)?n.linkType="image":"#"===l.substring(0,1)?n.linkType="fragment":n.useIframe===!0||n.useIframe!==!1&&this.hostname!==window.location.hostname?(n.linkType="iframe",n.useIframe=!0,n.contentDefaultWidth="100%",n.contentDefaultHeight="100%"):n.linkType="ajax",null!==n.callbackPreOpen&&"function"==typeof n.callbackPreOpen&&n.callbackPreOpen.apply(this),n.closeButton?0===e("#jb-close-button").length&&(e("#jb-window").prepend('<a href="#" id="jb-close-button"><img src="'+n.closeButtonImage+'" alt="Close lightbox" /></a>'),e("#jb-close-button").click(a)):e("#jb-close-button").remove(),n.clickOverlayCloses?e("#jb-window").addClass("reactive"):e("#jb-window").removeClass("reactive"),p=e(this),""!==n.galleryContainers&&(n.galleryMode="container"),n.gallerySelector="",n.galleryMode){case"all":n.gallerySelector=e.butterfly.conf.lightboxLinkSelector;break;case"container":e.each(n.galleryContainers.split(","),function(){return u=this+" "+e.butterfly.conf.lightboxLinkSelector,p.is(u)?(n.gallerySelector=u,!1):void 0})}""===n.gallerySelector&&""!==e(this).attr("rel")&&(n.gallerySelector=e.butterfly.conf.lightboxLinkSelector+'[rel="'+e(this).attr("rel")+'"]'),f=e("#jb-overlay").data("options")||{},e(this).data("options",n),e("#jb-overlay").data("options",n),e("#jb-window").append('<p id="jb-loading">Loading...</p>'),e("#jb-loading").attr("tabindex","0").focus(),e("#jb-overlay").is(":visible")?("fragment"===f.linkType&&f.reuseFragment&&(e(".jb-placeholder").after(e(f.href)),e(".jb-placeholder").remove(),e(f.href).disableFocussableElements()),e("#jb-window-content").hide().empty(),e("#jb-window").addClass("loading"),s.apply(this,[c])):(e(document.body).disableFocussableElements("#jb-window *"),e("#jb-close-button").hide(),e("#jb-gallery-controls").hide(),e("#jb-overlay").fadeIn(n.animationSpeed).centre(),e("#jb-window").addClass("loading").show(),n.zoomFromClicked?e("#jb-window-inner").css({top:e(this).offset().top,left:e(this).offset().left,width:e(this).width(),height:e(this).height()}):e("#jb-window-inner").css({width:"100px",height:"100px"}).centre(),s.apply(this,[c]))},c=function(){var t=e("#jb-overlay").data("options");e("#jb-window").restoreFocussableElements(),e("#jb-window").removeClass("loading"),setTimeout(function(){switch(e("#jb-window").removeClass("type-media type-image type-fragment type-ajax"),t.linkType){case"image":e("#jb-window").addClass("type-image type-media"),e("#jb-window-inner").css("overflow","hidden");break;case"fragment":e("#jb-window").addClass("type-fragment"),e("#jb-window-inner").css("overflow","auto");break;case"iframe":e("#jb-window").addClass("type-iframe"),e("#jb-window-inner").css("overflow","hidden");break;case"ajax":e("#jb-window").addClass("type-ajax"),e("#jb-window-inner").css("overflow","auto")}t.treatAsMedia&&e("#jb-window").addClass("type-media"),n.apply(this,[function(){var i;"iframe"===t.linkType&&e("#jb-window-content").css("visibility","visible"),e("#jb-window-content").fadeIn(t.animationSpeed,function(){e("#jb-window-content").focus(),e("#jb-loading").remove(),null!==t.callbackPostOpen&&"function"==typeof t.callbackPostOpen&&t.callbackPostOpen.apply(this),i=e("#jb-gallery-next"),t.preloadNextGalleryImage&&i.length>0&&i.is(":visible")&&"#"!==i.attr("href")&&b(i.attr("href"))&&e('<img src="'+i.attr("href")+'" alt="" />')})}])},0)},n=function(t){var i,n,a,o,l,s,r,d,c,h,b,f,w,g,y,j,m,v,k,x,C,I=e("#jb-overlay").data("options");"undefined"!=typeof I&&(i=parseInt(p(I.lightBoxMargin),10),n=e("#jb-window").width()-2*i,a=e("#jb-window").height()-2*i,o=p(I.contentDefaultWidth,n),l=p(I.contentDefaultHeight,a),s=p(I.mediaMaxWidth,n),r=p(I.mediaMaxHeight,a),null!==I.callbackPreResize&&"function"==typeof I.callbackPreResize&&I.callbackPreResize.apply(e("#jb-window"),[n,a,o,l,s,r]),"image"===I.linkType||I.treatAsMedia?(d=e("#jb-window-content").lightBoxContentWidth(),c=e("#jb-window-content").lightBoxContentHeight(),d>s&&(h=d/s,d=s,c/=h),c>r&&(h=c/r,c=r,d/=h),d>n&&(h=d/n,d=n,c*=h),c>a&&(h=c/a,c=a,d*=h)):"iframe"===I.linkType?(d=o,c=l):(d=e("#jb-window-content").lightBoxContentWidth(),d=""===o||"100%"===o||o>n?n:o,I.collapseHeightWhenPossible?(b=e("#jb-window-inner").width(),e("#jb-window-inner").animate({width:d},0),c=e("#jb-window-content").lightBoxContentHeight(!1),e("#jb-window-inner").width(b),c>a&&(c=a)):(c=e("#jb-window-content").lightBoxContentHeight(),c=""===l||"100%"===l||l>a?a:l)),f=u(d,c),w=I.animateResize?I.animationSpeed:0,e("#jb-close-button").hide(),e("#jb-gallery-controls").hide(),"iframe"===I.linkType&&e("#jb-window-inner iframe").css("visibility","hidden"),e("#jb-window-inner").animate({width:d,height:c,left:f[1],top:f[0]},w,0,function(){if(I=e("#jb-overlay").data("options"),d=e("#jb-window-inner").width(),c=e("#jb-window-inner").height(),"iframe"===I.linkType&&(e("#jb-window-inner iframe").width(d).height(c),e("#jb-window-inner iframe").css("visibility","visible")),e("#jb-close-button").length>0){switch(g=parseInt(e("#jb-close-button").width(),10),y=parseInt(e("#jb-close-button").height(),10),I.closeButtonCorner){case"tr":j=f[1]+d-g/2,m=f[0]-y/2;break;case"br":j=f[1]+d-g/2,m=f[0]+c-y/2;break;case"bl":j=f[1]-g/2,m=f[0]+c-y/2;break;default:j=f[1]-g/2,m=f[0]-y/2}e("#jb-close-button").css({position:"absolute","z-index":"999999",left:j,top:m}).show()}e("#jb-gallery-controls").is(".active")&&(v=f[0]+c/2-I.galleryControlHeight/2,k=f[1]-I.galleryControlWidth,e("#jb-gallery-prev").css({top:v,left:k}),x=f[0]+c/2-I.galleryControlHeight/2,C=f[1]+d,e("#jb-gallery-next").css({top:x,left:C}),e("#jb-gallery-controls").show()),null!==I.callbackPostResize&&"function"==typeof I.callbackPostResize&&I.callbackPostResize.apply(e("#jb-window"),[n,a,o,l,s,r]),"undefined"!=typeof t&&"undefined"!=typeof t.apply&&t.apply()}))},s=function(t){var i,n,a,o,l,s,r,d,c,b,u,w,g=e("#jb-overlay").data("options"),y=g.href;switch(g.captionMode){case"title":i=g.title?"<p class='jb-caption'><span>"+g.title+"</span></p>":"";break;case"text":i=g.linkText?"<p class='jb-caption'><span>"+g.linkText+"</span></p>":"";break;default:i=""}switch(e("#jb-window").removeClass("error-no-content"),n=e(g.gallerySelector),e("#jb-gallery-controls").removeClass("active"),n.length>1&&n.isInSet("#"+g.linkID)?(0===e("#jb-gallery-controls").length?(e("#jb-window").append('<div id="jb-gallery-controls"></div>'),a=e('<a id="jb-gallery-prev" href="#">Previous</a>').click(h),o=e('<a id="jb-gallery-next" href="#">Next</a>').click(h),e("#jb-gallery-controls").append(a).append(o),a.add(o).css({position:"absolute","z-index":"99999",display:"block",overflow:"hidden"})):(a=e("#jb-gallery-prev"),o=e("#jb-gallery-next"),a.add(o).removeClass("disabled").attr("tabindex","0").attr("title","").show()),e("#jb-gallery-controls").hide(),e("#jb-gallery-controls").addClass("active"),l=n.prevInSet("#"+g.linkID),l===!1&&(g.galleryLoops?l=n.lastInSet():(l=e('<a href="#" id=""></a>'),a.addClass("disabled").attr("tabindex","-1").hide())),a.attr("href",l.attr("href")).data("linkID",l.attr("id")).attr("title",e.trim(l.accessibleText())),s=n.nextInSet("#"+g.linkID),s===!1&&(g.galleryLoops?s=n.firstInSet():(s=e('<a href="#" id=""></a>'),o.addClass("disabled").attr("tabindex","-1").hide())),o.attr("href",s.attr("href")).data("linkID",s.attr("id")).attr("title",e.trim(s.accessibleText()))):e("#jb-gallery-controls").hide(),g.linkType){case"fragment":g.reuseFragment?(e(y).after('<span class="jb-placeholder"></span>'),e("#jb-window-content").empty().append(e(y))):e("#jb-window-content").empty().append(e(y).clone(!0)),f.apply(this,[g.linkType,y]),t.apply(this);break;case"image":e("#jb-window-content").empty().append('<img src="'+y+'" alt="" style="max-width: 100%; max-height: 100%; float: left;" />'+i),e("#jb-window-content img").error(function(){f.apply(this,[g.linkType,y,t])}).data("full-width","").data("full-height","").load(t);break;case"iframe":e("#jb-window-content").show().css("visibility","hidden"),e("#jb-window-content").empty().append('<iframe src="'+y+'" title="'+i+'" width="100%" height="1000" />'),e("#jb-window-content").css("visibility","hidden"),r=parseInt(p(g.lightBoxMargin),10),d=e("#jb-window").width()-2*r,c=e("#jb-window").height()-2*r,b=p(g.contentDefaultWidth,d),u=p(g.contentDefaultHeight,c),e("#jb-window-content > iframe").width(b).height(u).error(function(){f.apply(this,[g.linkType,y,t])}).load(t);break;default:e.ajaxSetup({cache:!0}),w=-1!==y.indexOf("#")?y.split("#").join(" #"):y,e("#jb-window-content").empty().load(w,function(){f.apply(this,[g.linkType,y]),t.apply(this)})}},f=function(t,i,n){var a,o=!1;("image"===t||0===e("#jb-window-content").children().length)&&(o=!0),o&&(a=e("#jb-overlay").data("options"),a.linkType="fragment",a.treatAsMedia=!1,e("#jb-overlay").data("options",a),e("#jb-window").removeClass("type-image type-media").addClass("type-fragment error-no-content"),e("#jb-window-content").empty().append("<p>There was an error loading lightbox content. <strong>"+e(a.trigger).text()+"</strong> (<samp>"+i+"</samp>) could not be found.</p>")),"undefined"!=typeof n&&n.apply(this)},a=function(t){var i,n,a;t&&t.preventDefault(),e("#jb-window:hidden").length||(i=e("#jb-overlay").data("options"),n=i.href,null!==i.callbackPreClose&&"function"==typeof i.callbackPreClose&&i.callbackPreClose.apply(i.trigger),"fragment"===i.linkType&&i.reuseFragment&&(e(".jb-placeholder").after(e(n)),e(".jb-placeholder").remove()),e(document.body).restoreFocussableElements(),e("#jb-overlay").fadeOut(i.animationSpeed),e("#jb-window").hide(),e("#jb-window-content").hide(),a=e(i.originalTrigger),"undefined"==typeof a.attr("tabindex")&&a.attr("tabindex",0),a.focus(),e("#jb-loading").remove(),null!==i.callbackPostClose&&"function"==typeof i.callbackPostClose&&i.callbackPostClose.apply(i.trigger),e.history.load(""))},e.fn.lightBoxContentWidth=function(){var t,i=this.closest("#jb-window"),n=e("#jb-window-inner"),a=i.hasClass("type-media")?!0:!1,o=i.hasClass("media-image")?!0:!1,l=n.width(),s=n.height(),r=n.css("left"),d=n.css("top");return n.css(e.browser.msie&&7===e.browser.version&&a&&o&&0===this.find("img").outerWidth(!0)?{width:"100%",height:"100%",left:0,top:0}:{width:"auto",height:"auto",left:0,top:0}),"none"===this.css("display")?(this.css("display","block"),t=a?this.find("img").outerWidth(!0):this.outerWidth(!0),this.css("display","none")):t=this.outerWidth(!0),n.css({left:r,top:d}),n.animate({width:l,height:s},0),t},e.fn.lightBoxContentHeight=function(t){var i,n=this.closest("#jb-window"),a=n.find("#jb-window-inner"),o=n.hasClass("type-media")?!0:!1,l=n.hasClass("media-image")?!0:!1,s=a.width(),r=a.height(),d=a.css("left"),c=a.css("top");return t="undefined"!=typeof t?t:!0,e.browser.msie&&7===e.browser.version&&o&&l&&0===this.find("img").outerWidth(!0)?(e("#jb-window-inner").height("100%"),t&&e("#jb-window-inner").width("100%").css({left:0,top:0})):(e("#jb-window-inner").height("auto"),t&&e("#jb-window-inner").width("auto").css({left:0,top:0})),"none"===this.css("display")?(this.css("display","block"),i=this.outerHeight(!0),this.css("display","none")):i=e(this).outerHeight(!0),e("#jb-window-inner").width(s).height(r).css({left:d,top:c}),i},d=function(t){var i=e("#jb-overlay").data("options");t.target===e("#jb-window").get(0)&&i.clickOverlayCloses&&a.apply()},r=function(t){var n;if(!e("#jb-overlay").is(":visible")||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey)return!0;switch(n=i(t)){case DOM_VK_UP:case DOM_VK_LEFT:e("#jb-gallery-prev").click();break;case DOM_VK_DOWN:case DOM_VK_RIGHT:e("#jb-gallery-next").click();break;case DOM_VK_HOME:e(e("#jb-overlay").data("options").gallerySelector).firstInSet().click();break;case DOM_VK_END:e(e("#jb-overlay").data("options").gallerySelector).lastInSet().click();break;case DOM_VK_ESCAPE:a.apply();break;default:return!0}t.preventDefault()},h=function(t){var i,n=e(this);return t.preventDefault(),""!==n.data("linkID")?(e("#jb-gallery-controls").hide(),i=e("#"+n.data("linkID")),i.click()):void 0},e.fn.centre=function(){return this.css({position:"fixed",top:(e(window).height()-this.outerHeight())/2+"px",left:(e(window).width()-this.outerWidth())/2+"px"})},u=function(t,i){var n=(e(window).height()-i)/2,a=(e(window).width()-t)/2;return[n,a]},e.fn.isInSet=function(t){return-1!==this.index(e(t))},e.fn.nextInSet=function(t){var i=this.index(e(t));return this.length>i+1?this.eq(i+1):!1},e.fn.prevInSet=function(t){var i=this.index(e(t));return i>0?this.eq(i-1):!1},e.fn.firstInSet=function(){return this.length>0?this.eq(0):!1},e.fn.lastInSet=function(){return this.length>0?this.eq(-1):!1},b=function(e){if("undefined"==typeof e||""===e)return!1;var t=String(e).lastIndexOf(".");return-1===t?!1:/^\.(jpg|png|gif|bmp|jpeg)$/i.test(e.substring(t))},e.fn.disableFocussableElements=function(t){t=t||"";var i=this.find("a, input, button, area, frame, iframe, [tabindex]").not(t).not('*[tabindex="-1"]');i.each(function(){var t=e(this),i=t.attr("tabindex");i="undefined"==typeof i||""===i?"":i,t.data("prevTabIndex",i).addClass("jb-unfocussed").attr("tabindex","-1")})},e.fn.restoreFocussableElements=function(){var t=this.find(".jb-unfocussed");t.each(function(){var t=e(this),i=t.data("prevTabIndex");switch(i){case"":t.removeAttr("tabindex");break;default:t.attr("tabindex",i)}t.removeClass("jb-unfocussed")})},p=function(t,i){return i="undefined"!=typeof i?i:e(document.body).width(),t=t.replace("px","").replace(/^\s+|\s+$/g,""),isNaN(t)?"%"===t.substr(t.length-1)?"undefined"!=typeof i?(t=parseInt(t.substr(0,t.length-1).replace(/^\s+|\s+$/g,""),10),t/100*parseInt(i,10)):(e.debug("Warning: percentage unit was supplied to parsePixels() but could not be calculated because centDimension was not supplied."),parseInt(t,10)):"em"===t.substr(t.length-2)?"undefined"!=typeof Number.prototype.pxToEm?(t=parseInt(t.substr(0,t.length-2).replace(/^\s+|\s+$/g,""),10),t=t.pxToEm({reverse:!0}),t.substr(0,t.length-2)):(e.debug("Warning: em unit was supplied to parsePixels() but could not be calulated because pxToEm plugin was not found."),parseInt(t,10)):(e.debug("Warning: unknown unit was supplied. parsePixels() can support px, em or % units only."),parseInt(t,10)):parseInt(t,10)}}(jQuery,ResizeEvents); diff --git a/public/opac/js/butterfly/jquery.history.js b/public/opac/js/butterfly/jquery.history.js new file mode 100644 index 0000000000000000000000000000000000000000..7f91079d4a96886cd50a78032310561c9c1cefda --- /dev/null +++ b/public/opac/js/butterfly/jquery.history.js @@ -0,0 +1,194 @@ +/* + * jQuery history plugin + * + * The MIT License + * + * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari) + * Copyright (c) 2010 Takayuki Miwa + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +(function($) { + var locationWrapper = { + put: function(hash, win) { + (win || window).location.hash = this.encoder(hash); + }, + get: function(win) { + var hash = ((win || window).location.hash).replace(/^#/, ''); + try { + return $.browser.mozilla ? hash : decodeURIComponent(hash); + } + catch (error) { + return hash; + } + }, + encoder: encodeURIComponent + }; + + var iframeWrapper = { + id: "__jQuery_history", + init: function() { + var html = '<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />'; + $("body").prepend(html); + return this; + }, + _document: function() { + return $("#"+ this.id)[0].contentWindow.document; + }, + put: function(hash) { + var doc = this._document(); + doc.open(); + doc.close(); + locationWrapper.put(hash, doc); + }, + get: function() { + return locationWrapper.get(this._document()); + } + }; + + function initObjects(options) { + options = $.extend({ + unescape: false + }, options || {}); + + locationWrapper.encoder = encoder(options.unescape); + + function encoder(unescape_) { + if(unescape_ === true) { + return function(hash){ return hash; }; + } + if(typeof unescape_ == "string" && + (unescape_ = partialDecoder(unescape_.split(""))) + || typeof unescape_ == "function") { + return function(hash) { return unescape_(encodeURIComponent(hash)); }; + } + return encodeURIComponent; + } + + function partialDecoder(chars) { + var re = new RegExp($.map(chars, encodeURIComponent).join("|"), "ig"); + return function(enc) { return enc.replace(re, decodeURIComponent); }; + } + } + + var implementations = {}; + + implementations.base = { + callback: undefined, + type: undefined, + + check: function() {}, + load: function(hash) {}, + init: function(callback, options) { + initObjects(options); + self.callback = callback; + self._options = options; + self._init(); + }, + + _init: function() {}, + _options: {} + }; + + implementations.timer = { + _appState: undefined, + _init: function() { + var current_hash = locationWrapper.get(); + self._appState = current_hash; + self.callback(current_hash); + setInterval(self.check, 100); + }, + check: function() { + var current_hash = locationWrapper.get(); + if(current_hash != self._appState) { + self._appState = current_hash; + self.callback(current_hash); + } + }, + load: function(hash) { + if(hash != self._appState) { + locationWrapper.put(hash); + self._appState = hash; + self.callback(hash); + } + } + }; + + implementations.iframeTimer = { + _appState: undefined, + _init: function() { + var current_hash = locationWrapper.get(); + self._appState = current_hash; + iframeWrapper.init().put(current_hash); + self.callback(current_hash); + setInterval(self.check, 100); + }, + check: function() { + var iframe_hash = iframeWrapper.get(), + location_hash = locationWrapper.get(); + + if (location_hash != iframe_hash) { + if (location_hash == self._appState) { // user used Back or Forward button + self._appState = iframe_hash; + locationWrapper.put(iframe_hash); + self.callback(iframe_hash); + } else { // user loaded new bookmark + self._appState = location_hash; + iframeWrapper.put(location_hash); + self.callback(location_hash); + } + } + }, + load: function(hash) { + if(hash != self._appState) { + locationWrapper.put(hash); + iframeWrapper.put(hash); + self._appState = hash; + self.callback(hash); + } + } + }; + + implementations.hashchangeEvent = { + _init: function() { + self.callback(locationWrapper.get()); + $(window).bind('hashchange', self.check); + }, + check: function() { + self.callback(locationWrapper.get()); + }, + load: function(hash) { + locationWrapper.put(hash); + } + }; + + var self = $.extend({}, implementations.base); + + if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) { + self.type = 'iframeTimer'; + } else if("onhashchange" in window) { + self.type = 'hashchangeEvent'; + } else { + self.type = 'timer'; + } + + $.extend(self, implementations[self.type]); + $.history = self; +})(jQuery); diff --git a/public/opac/js/butterfly/jquery.pxToEm.js b/public/opac/js/butterfly/jquery.pxToEm.js new file mode 100644 index 0000000000000000000000000000000000000000..50bb9f41144420338472559e710140b82b2b9e5d --- /dev/null +++ b/public/opac/js/butterfly/jquery.pxToEm.js @@ -0,0 +1,56 @@ +/*-------------------------------------------------------------------- + * javascript method: "pxToEm" + * by: + Scott Jehl (scott@filamentgroup.com) + Maggie Wachs (maggie@filamentgroup.com) + http://www.filamentgroup.com + * + * Copyright (c) 2008 Filament Group + * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses. + * + * Description: Extends the native Number and String objects with pxToEm method. pxToEm converts a pixel value to ems depending on inherited font size. + * Article: http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/ + * Demo: http://www.filamentgroup.com/examples/pxToEm/ + * + * Options: + scope: string or jQuery selector for font-size scoping + reverse: Boolean, true reverses the conversion to em-px + * Dependencies: jQuery library + * Usage Example: myPixelValue.pxToEm(); or myPixelValue.pxToEm({'scope':'#navigation', reverse: true}); + * + * Version: 2.0, 08.01.2008 + * Changelog: + * 08.02.2007 initial Version 1.0 + * 08.01.2008 - fixed font-size calculation for IE +--------------------------------------------------------------------*/ + +Number.prototype.pxToEm = String.prototype.pxToEm = function(settings){ + //set defaults + settings = jQuery.extend({ + scope: 'body', + reverse: false + }, settings); + + var pxVal = (this == '') ? 0 : parseFloat(this); + var scopeVal; + var getWindowWidth = function(){ + var de = document.documentElement; + return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; + }; + + /* When a percentage-based font-size is set on the body, IE returns that percent of the window width as the font-size. + For example, if the body font-size is 62.5% and the window width is 1000px, IE will return 625px as the font-size. + When this happens, we calculate the correct body font-size (%) and multiply it by 16 (the standard browser font size) + to get an accurate em value. */ + + if (settings.scope == 'body' && jQuery.browser.msie && (parseFloat(jQuery('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) { + var calcFontSize = function(){ + return (parseFloat(jQuery('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16; + }; + scopeVal = calcFontSize(); + } + else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); }; + + var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em'; + return result; +}; \ No newline at end of file diff --git a/public/opac/js/butterfly/jquery.resize-events.js b/public/opac/js/butterfly/jquery.resize-events.js new file mode 100644 index 0000000000000000000000000000000000000000..2c9cae82a2074d45969e822c18947ad9a61739e1 --- /dev/null +++ b/public/opac/js/butterfly/jquery.resize-events.js @@ -0,0 +1,173 @@ +/** + * Resize Events + * @version 0.7 + * Changelog: + * * 0.5 Added API bind() function to make it easier to add listeners. + * * 0.6 Added support for window height changes + * * 0.7 Clean up outstanding bugs (duplicate event firing) and refactor. + * + * There is no standard event for when a user resizes the text in their browser. + * There is also no consistency between browser implementations of the window resize event + * (some trigger as the window is resized, some only trigger as the user drops the resize handle). + * This extension polls to detect these changes, and reports them immediately as custom events + * ('x-text-resize' and 'x-window-resize') that other code can listen for and react to accordingly. + * Resize Events also send an 'x-initial-size' event on load. + * + * The custom events triggered are sent with emPixels, textHeight and windowWidth variables. + * emPixels is a unit that estimates much space you have to work with but is resolution, text size + * and zoom level independant. Use this value to base layout decisions on, and the layout will + * always fit. + * + * This extension is based on the 'text resize' events work of Lawrence Carvalho <http://www.alistapart.com/articles/fontresizing/>. + * + * @author Lawrence Carvalho <carvalho@uk.yahoo-inc.com> + * @author Andrew Ramsden <http://irama.org/> + * + * @see http://irama.org/web/dhtml/resize-events/ + * @license GNU GENERAL PUBLIC LICENSE (GPL) <http://www.gnu.org/licenses/gpl.html> + * @requires jQuery (tested with 1.4.2) <http://jquery.com/> + */ +var ResizeEvents = { + baseTextHeight : null, + currentTextHeight : null, + baseWindowWidth : null, + baseWindowHeight : null, + currentWindowWidth : null, + currentWindowHeight : null, + initialised : false, + intervalReference : null, + textSizeTestElement : null, + eventElement : jQuery(document), + conf : { + textResizeEvent : 'x-text-resize', + windowResizeEvent : 'x-window-resize', + windowWidthResizeEvent : 'x-window-width-resize', + windowHeightResizeEvent : 'x-window-height-resize', + initialResizeEvent : 'x-initial-sizes', + pollFrequency : 500, + textSizeTestElId : 'text-resize' + } +}; + + // start closure (protects variables from global scope) +(function($){ + + + /** + * A simple way to add a listener for resize events. + * + * @param String events A space delimited list of events that should trigger this handler. + * @param function handler The handler function to be called when an event occurs. + */ + ResizeEvents.bind = function (events, handler) { + + // on DOMReady + $(function(){ + // initialise if it hasn't happened already + if (ResizeEvents.initialised !== true) { + ResizeEvents.initialise(); + } + }); + + ResizeEvents.eventElement.bind( + events, + handler + ); + }; + + /** + * Initialisation + */ + ResizeEvents.initialise = function () { + + if (ResizeEvents.initialised === true) { + return; // already initialised + } + + // create text resize control element, and push it offscreen + ResizeEvents.textSizeTestElement = $( + '<span id="'+ResizeEvents.conf.textSizeTestElId+'" style="position: absolute; left: -9999px; '+ + 'font-size: 100%; font-family: Courier New, mono; margin: 0; padding: 0;"> </span>' + ).get(0); + + // append control element + $('body').append(ResizeEvents.textSizeTestElement); + + // initialise variables + windowWidthNow = $(window).width(); + windowHeightNow = $(window).height(); + textHeightNow = getTextHeight(); + ResizeEvents.baseTextHeight = textHeightNow; + ResizeEvents.currentTextHeight = textHeightNow; + ResizeEvents.baseWindowWidth = windowWidthNow; + ResizeEvents.currentWindowWidth = windowWidthNow; + ResizeEvents.baseWindowHeight = windowHeightNow; + ResizeEvents.currentWindowHeight = windowHeightNow; + + // start polling + if (ResizeEvents.intervalReference == null) { + ResizeEventsPoll(); + ResizeEvents.intervalReference = window.setInterval('ResizeEventsPoll()', ResizeEvents.conf.pollFrequency); + } + + // trigger onload + ResizeEvents.eventElement.trigger(ResizeEvents.conf.initialResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + + // flag initialisation complete + ResizeEvents.initialised = true; + + + }; + + /** + * This function is called a number of times each second to check if text size + * or window size has changed + */ + ResizeEventsPoll = function () { + + // get current values + windowWidthNow = $(window).width(); + windowHeightNow = $(window).height(); + textHeightNow = getTextHeight(); + emPixelNow = windowWidthNow/textHeightNow; + widthChanged = false; + + // test for window width change + if (ResizeEvents.currentWindowWidth != windowWidthNow) { + // Send custom event + ResizeEvents.eventElement.trigger(ResizeEvents.conf.windowWidthResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + ResizeEvents.eventElement.trigger(ResizeEvents.conf.windowResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + // update current height + ResizeEvents.currentWindowWidth = windowWidthNow; + widthChanged = true; + } + + // test for window height change + if (ResizeEvents.currentWindowHeight != windowHeightNow) { + // Send custom event + ResizeEvents.eventElement.trigger(ResizeEvents.conf.windowHeightResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + if (!widthChanged) { // don't send window-resize event twice + ResizeEvents.eventElement.trigger(ResizeEvents.conf.windowResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + } + // update current height + ResizeEvents.currentWindowHeight = windowHeightNow; + } + + + // test for text size change + if (ResizeEvents.currentTextHeight != textHeightNow) { + // Send custom event (with new text size) + ResizeEvents.eventElement.trigger(ResizeEvents.conf.textResizeEvent, [emPixelNow, textHeightNow, windowWidthNow, windowHeightNow]); + // update current height + ResizeEvents.currentTextHeight = textHeightNow; + } + }; + + /** + * @return The current text height in pixels + */ + getTextHeight = function () { + return ResizeEvents.textSizeTestElement.offsetHeight+''; + }; + +})(jQuery); /* end closure */ \ No newline at end of file diff --git a/public/opac/js/butterfly/loading-black-on-white.gif b/public/opac/js/butterfly/loading-black-on-white.gif new file mode 100644 index 0000000000000000000000000000000000000000..b50e9f9bb214b0ce18d12110a9f9bda61a9ad46e Binary files /dev/null and b/public/opac/js/butterfly/loading-black-on-white.gif differ diff --git a/public/opac/js/butterfly/reactive-overlay.png b/public/opac/js/butterfly/reactive-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..0b89c400208e949e869970cbb6152c2f657c3283 Binary files /dev/null and b/public/opac/js/butterfly/reactive-overlay.png differ diff --git a/public/opac/js/butterfly/reactive-overlay.psd b/public/opac/js/butterfly/reactive-overlay.psd new file mode 100644 index 0000000000000000000000000000000000000000..1d574af2f46064a4c617a7f4945904b32cfcbd36 Binary files /dev/null and b/public/opac/js/butterfly/reactive-overlay.psd differ diff --git a/public/opac/skins/original/css/global.css b/public/opac/skins/original/css/global.css index f8d3499b2ed43188a844390ceafd673a02ef98e4..aa519344819e10a7c193589887e1b75a91ce0d6c 100644 --- a/public/opac/skins/original/css/global.css +++ b/public/opac/skins/original/css/global.css @@ -299,3 +299,8 @@ div#header .boiteBanniereDroiteInner { .boite.login a:hover { color: #D44100; } + + +#fieldset-login_form legend { + display: none; +} \ No newline at end of file diff --git a/router.php b/router.php new file mode 100644 index 0000000000000000000000000000000000000000..5e99f33e6f4d9cd9102938baace4cbac3988f6d4 --- /dev/null +++ b/router.php @@ -0,0 +1,41 @@ +<?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 + */ + + +/** + * Used to run Bokeh using php built-in web server: + * php -S localhost:8080 router.php + */ + +$path = pathinfo($_SERVER["SCRIPT_FILENAME"]); + +if ($path["extension"] && in_array(strtolower($path["extension"]), + ['js','ico','txt','gif','jpg','jpeg','png','css','xml','swf','mov','pdf','doc','docx','woff','eot','svg','ttf','xls','wsdl','mp3','m4v','ogg','ogv','epub','html','xhtml','asmx','zip','sql','bro'])) { + + require_once('library/Class/File/Mime.php'); + header('Content-Type: '.Class_File_Mime::getType($path['extension'])); + readfile($_SERVER["SCRIPT_FILENAME"]); + exit; +} + +require_once 'index.php'; + +?> \ No newline at end of file diff --git a/scripts/clean_articles_url.php b/scripts/clean_articles_url.php index 1c8e0bc33664d21bad9401b65a9935f4b53662c7..37704fa228e2b13d5faf62aea0bac46b027ade18 100644 --- a/scripts/clean_articles_url.php +++ b/scripts/clean_articles_url.php @@ -1,13 +1,31 @@ <?php +if (!$argv[2]) { + echo "Missing arguments : hostname basedir"; + exit(1); +} +$hostname=$argv[1]; +$basedir = $argv[2]; + +chdir($basedir); + require('console.php'); -$search = 'http://web.afi-sa.net'; -$replace = ''; -$articles = Class_Article::findAllBy(['where' => 'concat(description,contenu) like "%'.$search.'%"']); +echo BASE_URL."\n"; + +$occurences = 0; +$articles = Class_Article::findAllBy(['where' => 'concat(description,contenu) like "%'. $basedir .'%"']); foreach ($articles as $art) { $art - ->setDescription(str_replace($search, $replace, $art->getDescription())) - ->setContenu(str_replace($search, $replace, $art->getContenu())) + ->setDescription(Class_CmsUrlTransformer::removeHost($hostname,$basedir, $art->getDescription(), $countDesc)) + ->setContenu(Class_CmsUrlTransformer::removeHost($hostname,$basedir, $art->getContenu(), $countCont)) ->save(); + $occurences += $countDesc + $countCont; +} + +$articles = Class_Article::findAllBy(['where' => 'concat(description,contenu) like "%' . $basedir . '%"']); +if (count($articles)) { + $ids = array_map(function($a) {return $a->getId();}, $articles); + echo "check articles: " . implode(', ', $ids) . "\n"; } +echo "$occurences occurence(s) replaced.\n" ?> \ No newline at end of file diff --git a/scripts/clean_newletters_url.php b/scripts/clean_newletters_url.php new file mode 100644 index 0000000000000000000000000000000000000000..ec500cf8c975b0fc97052218181ae0b733e187b2 --- /dev/null +++ b/scripts/clean_newletters_url.php @@ -0,0 +1,29 @@ +<?php +if (!$argv[2]) { + echo "Missing arguments: hostname basedir"; + exit(1); +} +$hostname=$argv[1]; +$basedir = $argv[2]; +// $_SERVER['HTTP_HOST'] = 'http://www.genevois-biblio.fr/genevois-biblio.fr'; +$_SERVER['HTTP_HOST']=$hostname; +chdir($basedir); + +require('console.php'); + +echo BASE_URL."\n"; + +$occurences = 0; +$news_checked = 0; + +$news = Class_Newsletter::findAllBy(['where' => 'contenu like "%' . $basedir . '%"']); +foreach ($news as $new) { + $news_checked++; + $new->setContenu(Class_CmsUrlTransformer::removeHost($hostname,$basedir, $new->getContenu(), $countContenu)) + ->save(); + + $occurences += $countContenu; +} +echo "News checked: $news_checked\n"; +echo "$occurences occurence(s) replaced.\n"; +?> diff --git a/scripts/clean_profils_url.php b/scripts/clean_profils_url.php new file mode 100644 index 0000000000000000000000000000000000000000..104f33e69d25a6d46ef6360f4299056ba381c8db --- /dev/null +++ b/scripts/clean_profils_url.php @@ -0,0 +1,36 @@ +<?php +if (!$argv[1]) { + echo "Missing argument site"; + exit(1); +} +$hostname= $argv[1]; +$basedir = $argv[2]; + + +chdir($basedir); + +require('console.php'); + +echo BASE_URL."\n"; + +$occurences = 0; +$profils_checked = 0; +$profils = Class_Profil::findAllBy(['where' => 'concat(cfg_site,cfg_accueil) like "%' . $basedir . '%"']); +foreach ($profils as $profil) { + $profils_checked++; + $profil + ->setCfgSite((Class_CmsUrlTransformer::removeHostFromArray($hostname,$basedir, $profil->getCfgSiteAsArray(), $countSite))) + ->setCfgAccueil((Class_CmsUrlTransformer::removeHostFromArray($hostname,$basedir, $profil->getCfgAccueilAsArray(), $countAccueil))) + ->save(); + + $occurences += $countSite + $countAccueil; +} + +foreach (Class_FRBR_Link::findAll() as $frbr) { + $frbr->setSource(Class_CmsUrlTransformer::removeBaseDir($hostname,$basedir, $frbr->getSource())); + $frbr->setTarget(Class_CmsUrlTransformer::removeBaseDir($hostname,$basedir, $frbr->getTarget())); + $frbr->save(); +} + +echo "Profils checked: $profils_checked\n"; +echo "$occurences occurence(s) replaced.\n"; diff --git a/scripts/import_typo3.php b/scripts/import_typo3.php index 3b059a8111ba02b19075bafb5b5f33b281b0c487..a52897db47e76bfc1381ae550cfa2454e6b25720 100644 --- a/scripts/import_typo3.php +++ b/scripts/import_typo3.php @@ -2,7 +2,9 @@ /* * Launch import_typo3.php like: * php import_typo3.php <arg> - * <arg> can be users (import users only), docu(update dossiers documentaires only), articles (import articles only) or all (import all) + * <arg> can be users (import users only), docu(update dossiers documentaires only), articles (import articles only), + * sito (import image file for sitotheque) or sito_reimport (delete and reimport sito) + * or all (import all) * php import_typo3.php update <last_update_date 20-11-2015 > * Script import data in a database named miop_typo3. To change it, edit the line 109. */ diff --git a/scripts/install-bokeh.php b/scripts/install-bokeh.php new file mode 100644 index 0000000000000000000000000000000000000000..cbb42629b29368f1160211ee3c158363de11239d --- /dev/null +++ b/scripts/install-bokeh.php @@ -0,0 +1,220 @@ +<?php + function clean($in,$wa=0) { + //return preg_replace('@[^a-zA-Z0-9_\-\.]@','',$in); + $accents = 'éèêëÊËà âäÂÄîïÎÃûùüÛÜôöÔÖ'; + return preg_replace('#[^a-zA-Z0-9_\-\.\ @'.(($wa==1)?$accents:'').']#','',$in); + } + function extractSqlInstructions($data) { + $instructions = []; + $instruction = ''; + foreach($data as $ligne) { + $ligne = trim($ligne); + if (!$ligne or substr($ligne,0,2) == '--') + continue; + $instruction .= $ligne . ' '; + if(substr($ligne,-1) != ';') + continue; + + $instructions[] = $instruction; + $instruction = ''; + } + + return $instructions; + } + function paramFileConstruction($source,$remplacements) { + $fichier = file_get_contents($source); + $avant = array_keys($remplacements); $apres = array_values($remplacements); + return str_replace($avant,$apres,$fichier); + } + + function paramBokeh($parametres) { + $logs = ''; + //on commence par tester la connexion à la base de données + //si la connexion est impossible on s'arrête la + $opac = mysqli_init(); + $opac->real_connect($parametres['host'], $parametres['user'] , $parametres['pass']); + if ($opac->connect_errno) { + $logs .= "<b>Problème de connexion au serveur base de donnée</b> : Erreur MySQL : ".$opac->connect_errno." )<br />".$opac->connect_error; + $parametres['formulaire'] .= '<br/>'.$logs; + return $parametres; + } + else { + $logs .= "Connexion au serveur de base de donnée : <b>OK</b><br/>"; + $opac->query('SET NAMES utf8'); + $opac->query("SET CHARACTER SET 'utf8'"); + //création de la base de donnée BOKEH + $sql = 'USE `'.$parametres['name'].'`;'; + $opac->query($sql); + if (!empty($opac->error)) { + if (preg_match("@^Unknown database@",$opac->error)) { + //création de la base + $logs .= "création de la base <b>'".$parametres['name']."'</b><br/>"; + $sql = 'CREATE DATABASE `'.$parametres['name'].'` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;'; + $opac->query($sql); + $sql = 'USE `'.$parametres['name'].'`;'; + $opac->query($sql); + } + else { + $logs .= "<b>Problème d'accès à la base de donnée</b> : Erreur MySQL : ".$opac->error; + $parametres['formulaire'] .= '<br/>'.$logs; + return $parametres; + } + } + else + $logs .= "La base de donnée <b>".$parametres['name']."</b> existe déjà <br/>"; + + //vérification d'état du paramétrage de la base + $tabletest = 'variables'; + $sql = 'select * from '.$tabletest; + $opac->query($sql); + if (preg_match("@^Table.*doesn't exist@",$opac->error)) { + $logs .= "Paramétrage de la base de donnée<br/>"; + //on lance l'initialisation de la base + $data = file($parametres['init']); + //merci Class_Migration_Patchs + $instructions = extractSqlInstructions($data); + $i = 0; $e = false; + foreach($instructions as $sql) { + $i++; // pour pouvoir tracer quelle instruction est en erreur + $opac->query($sql); + if (!empty($opac->error)) { + $logs .= " - Erreur MySQL (i:".$i."): ".$opac->error." <br />"; + $e = true; + } + } + if (!$e) $logs .= "Paramétrage effectué sans erreur<br/>"; + } + else $logs .= "base de donnée <b>".$parametres['name']."</b> déjà paramétrée<br/>"; + $logs .= "<br/>"; + + //création des fichiers de configuration + foreach ($parametres['configs'] as $fichier => $donnees) { + if (!file_exists($fichier)) { + file_put_contents($fichier,$donnees); + $logs .= 'Paramétrage du fichier <b>'.$fichier."</b><br/>"; + } + else $logs .= $fichier." existe déjà <br/>"; + } + $logs .= "<br/>"; + + //on utilise une iframe pour lancer de manière transparente la mis a jour des donnée de la base + $logs .= "<div id='majdb'><img src='".$parametres['path']."/public/opac/images/patience.gif'/>Mise à jour de la base en cours - veuillez patienter<br/></div>"; + $logs .= "<iframe class='' src='".$parametres['path'].$parametres['url_MAJ']."' onload=\"$('#majdb')[0].setAttribute('class','masquee');$('#majdbdone')[0].setAttribute('class','');\"></iframe>"; + //on retourne les liens permettant d'accéder a l'administration du portail et du cosmogramme + $logs .= "<div id='majdbdone' class='masquee'>Mise à jour de la base terminée<br/>"; + $logs .= "<ul><li><a href='".$parametres['path'].$parametres['url_admin']."'>Accèder a l'administration</a></li>"; + $logs .= "<li><a href='".$parametres['path'].$parametres['url_cosmogramme']."'>Accèder au cosmogramme</a></li></ul>"; + $logs .= "<b>Identification</b> : admin / achanger</div>"; + + //on remplace le formulaire par la trace des opérations + $parametres['formulaire'] = $logs; + } + return $parametres; + } + + //install bokeh php - variables defaut + $vars = array('user' => 'Nom Utilisateur', 'pass' => 'Mot de passe', 'name' => 'Base de donnée', 'host' => 'Adresse'); + $path = pathinfo($_SERVER["PHP_SELF"]); + $parametres = array( + 'path' => '', + 'user' => 'root', + 'pass' => '', + 'name' => 'opacce', + 'host' => 'localhost', + 'init' => 'scripts/opac2.sql', + 'url_MAJ' => '/database-migration/migrate/', + 'url_admin' => '/admin/', + 'url_cosmogramme' => '/cosmogramme/', + 'install-bokeh' => false, + 'formulaire' => '' + ); + if (!empty($path['dirname']) && $path['dirname'] != "\\") + $parametres['path'] = $path['dirname']; + + + $parametres['formulaire'] = "Bokeh n'est pas configuré sur votre environnement<br/>\n"; + $parametres['formulaire'] .= "Veuillez modifier les paramètres suivant selon vos besoin et Valider pour lancer le paramétrage<br/>\n"; + $parametres['formulaire'] .= '<br/>'; + foreach ($vars as $k => $v) { + if ($k == 'pass') { + $parametres[$k] = (!empty($_POST[$k]))?clean($_POST[$k],1):$parametres[$k]; + } + else { + $parametres[$k] = (!empty($_POST[$k]))?clean($_POST[$k]):$parametres[$k]; + } + $parametres['formulaire'] .= "<label for='".$k."'>".$v."</label><input id='".$k."' name='".$k."' value='".$parametres[$k]."'><br/>\n"; + } + $k = 'install-bokeh'; + + $parametres['formulaire'] .= '<br/>'; + $parametres['formulaire'] .= "<input id='".$k."' name='".$k."' value='".$k."' type='checkbox'> <label for='".$k."'>Je souhaite Paramétrer Bokeh</label><br/>"; + $parametres['formulaire'] .= '<br/>'; + $parametres['formulaire'] .= "<input type='submit' value='Valider'>"; + + $parametres[$k] = (!empty($_POST[$k]))?clean($_POST[$k]):$parametres[$k]; + $parametres[$k] = ($parametres[$k] == $k); + + + //préparation des fichiers de configuration + $configIni = array( + "sgbd.config.host = localhost" => "sgbd.config.host = ".$parametres['host'], + "sgbd.config.username =" => "sgbd.config.username = ".$parametres['user'], + "sgbd.config.password = " => "sgbd.config.password = ".$parametres['pass'], + "sgbd.config.dbname =" => "sgbd.config.dbname = ".$parametres['name'], + ); + $configCosmo = array( + "integration_server=localhost" => "integration_server=".$parametres['host'], + "integration_user=root" => "integration_user=".$parametres['user'], + "integration_pwd=" => "integration_pwd=".$parametres['pass'], + "integration_base=opac3" => "integration_base=".$parametres['name'], + "pwd_master=opac3" => "pwd_master=opacce" + ); + $parametres['configs'] = array( + 'local.php' => '', + 'config.ini' => paramFileConstruction("config.ini.default",$configIni), + 'cosmogramme/config.php' => paramFileConstruction("cosmogramme/config.ref.php",$configCosmo) + ); + + if ($parametres['install-bokeh'] == true) { + $parametres = paramBokeh($parametres); + } + echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title></title> + <style type="text/css"> + body { + font-family: arial; font-size: 12; + } + table { + border:2px solid; + -moz-border-radius:5px; + -khtml-border-radius:5px; + border-radius:5px; + /* border-collapse:collapse; */ + border-spacing: 0; + } + th { border-bottom:solid 2px; } + th { padding: 2 5 2 5; text-align:center; border-top:solid 1px; border-left:solid 1px; border-bottom:solid 1px; border-right:solid 1px; vertical-align:middle;} + .bbottom {} + th { padding: 2 5 2 5; text-align:center; border:solid 2px; vertical-align:middle; } + td { padding: 2 5 2 5; text-align:center; border-top:solid 1px; border-left:solid 1px; border-bottom:solid 1px; border-right:solid 1px; vertical-align:top;} + td { padding: 2 5 2 5; border-top:solid 1px; border-left:solid 1px; border-bottom:solid 1px; border-right:solid 1px; vertical-align:top;} + .left { text-align:left; } + label { min-width: 100px; display: inline-block; margin-right: 5px; } + .masquee { display:none;} + iframe { width:100%; padding:0; border:0;} + </style> + <script src="'.$parametres['path'].'/public/admin/js/jquery-1.8.3.js" type="text/javascript"></script> + <script src="'.$parametres['path'].'/public/admin/js/jquery_ui/jquery-ui-1.10.3.full.js" type="text/javascript"></script> + <script type="text/javascript"> + <!-- + //--> + </script> + </head> +<body> +<form id=form method=POST>'.$parametres['formulaire'].'</form> +</body> +</html>'; + exit; +?> \ No newline at end of file diff --git a/tests/TestSpeedTrap.php b/tests/TestSpeedTrap.php index db39c54f9af3bd07735ec18d297c6f2e71721a9b..2eae8b45a4601d55b3137633ef8e889b99d440e5 100644 --- a/tests/TestSpeedTrap.php +++ b/tests/TestSpeedTrap.php @@ -22,8 +22,7 @@ /** * @package Tests */ -class TestSpeedTrap extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener { - +class TestSpeedTrap extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener { protected static $_speed_trapped_test = [], $_speed_limit = 0.01; @@ -41,7 +40,7 @@ class TestSpeedTrap extends PHPUnit_Util_Printer implements PHPUnit_Framework_T public function endTest(PHPUnit_Framework_Test $test, $length) { if ($length > self::$_speed_limit) - $this->collect($test->getName(), round($length, 4)); + $this->collect(get_class($test) . '::' . $test->getName(), round($length, 4)); } /** @@ -139,8 +138,15 @@ END; if(1 > ($count = count(self::$_speed_trapped_test))) { print <<<END + _ + /(| + ( : + __\ \ _____ + (____) `| +(____)| | + (____).__| + (___)__.|_____ - :D http://ljdchost.com/zLWnDY0.gif END; return; @@ -148,7 +154,13 @@ END; print <<<END - :( http://ljdchost.com/UlaUCrU.gif + .-"-. .-"-. .-"-. + _/_-.-_\_ _/.-.-.\_ _/.-.-.\_ + / __} {__ \ /|( o o )|\ ( ( o o ) ) + / // " \\\\ \ | // " \\\\ | |/ " \| +/ / \'---'/ \ \ / / \'---'/ \ \ \'/^\'/ +\ \_/`"""`\_/ / \ \_/`"""`\_/ / /`\ /`\ + \ / \ / / /|\ \ END; diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index c8513965ba1ac6cbce78f33fa7ced1fbd347f09c..ef9ecc7b987bd12e5f6ddf980ef289b672baedd7 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -20,7 +20,9 @@ */ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase { use Storm_Test_THelpers; - protected $_registry_sql; + protected + $_registry_sql, + $_storm_default_to_volatile = false; //permet d'authentifier sur la partie admin avant test public $bootstrap = 'bootstrap_frontcontroller.php'; @@ -147,10 +149,16 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe Storm_Cache::setDefaultZendCache(null); Class_WebService_AllServices::setHttpClient(null); Class_SessionFormationInscription::beVolatile(); + + if($this->_storm_default_to_volatile) + Storm_Model_Loader::defaultToVolatile(); } public function tearDown() { + if($this->_storm_default_to_volatile) + Storm_Model_Loader::defaultToDb(); + Storm_Model_Abstract::unsetLoaders(); Zend_Registry::set('sql', $this->_registry_sql); Class_Codification::resetInstance(); diff --git a/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php b/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d2e16effd6df2b4cc56fa879f0d946a67bd9e0e7 --- /dev/null +++ b/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php @@ -0,0 +1,114 @@ +<?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 Admin_AccueilControllerCritiquesTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->onLoaderOfModel('Class_PanierNotice') + ->whenCalled('findAllBelongsToAdmin') + ->answers([]); + + $this->dispatch('admin/accueil/critiques?config=accueil&id_profil=1&id_module=1&type_module=CRITIQUES', + true); + } + + + /** @test */ + public function titleShouldBePresent() { + $this->assertXPathContentContains('//h1', 'Critiques'); + } + + + /** @test */ + public function boxTitleShouldBePresent() { + $this->assertXPath('//input[@name="titre"]'); + } + + + /** @test */ + public function styleShouldBePresent() { + $this->assertXPath('//select[@name="boite"]'); + } + + + /** @test */ + public function rssChoiceShouldBePresent() { + $this->assertXPath('//input[@type="checkbox"][@name="rss_avis"]'); + } + + + /** @test */ + public function originShouldBePresent() { + $this->assertXPath('//select[@name="abon_ou_bib"]'); + } + + + /** @test */ + public function hierarchicalChoiceShouldBePresent() { + $this->assertXPath('//input[@type="checkbox"][@name="hierarchical"]'); + } + + + /** @test */ + public function displayCountShouldBePresent() { + $this->assertXPath('//input[@name="nb_aff_avis"]'); + } + + + /** @test */ + public function displayOrderShouldBePresent() { + $this->assertXPath('//input[@type="radio"][@name="display_order"]'); + } + + + /** @test */ + public function contentCutShouldBePresent() { + $this->assertXPath('//input[@name="nb_words"]'); + } + + + /** @test */ + public function thumbsChoiceShouldBePresent() { + $this->assertXPath('//select[@name="only_img"]'); + } + + + /** @test */ + public function domainsShouldBePresent() { + $this->assertXPath('//select[@name="id_catalogue"]'); + } + + + /** @test */ + public function basketsShouldBePresent() { + $this->assertXPath('//select[@name="id_panier"]'); + } + + + /** @test */ + public function submitShouldBePresent() { + $this->assertXPath('//input[@type="submit"][@name="Valider"]'); + } +} \ 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 f82c9f25adb18c56d9c720278b5d8d2b7fa6a58e..25620bc3fa7e73df35f7440d972d2cdaac66d2f1 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -209,6 +209,64 @@ class AccueilControllerConfigCalendrierTest extends Admin_AbstractControllerTest +class AccueilControllerConfigSitothequePostTest extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + Class_Profil::beVolatile(); + Class_Profil::getCurrentProfil() + ->updateModuleConfigAccueil(25, + array('type_module' => 'SITO', + 'division' => 1, + 'id_module' => 25, + 'preferences' => ['id_items' => '12-13'])); + + } + + + /** @test */ + public function selectHierachicalDisplayShouldSaveOnlyFirstCategory() { + $this->postDispatch('/admin/accueil/sitotheque?config=accueil&id_profil=1&type_module=SITO&id_module=25', + [ + 'type_aff' => 3, + 'nb_aff' => 2, + 'group_by_categorie' => true, + 'id_categorie' => '12-17' + ]); + + $this->assertEquals('12',Class_Profil::find(1)->getModuleAccueilConfig(25,'SITO')['preferences']['id_categorie']); + + } + + /** @test */ + public function selectHierachicalDisplayShouldForceGroupByCategoryToFalse() { + $this->postDispatch('/admin/accueil/sitotheque?config=accueil&id_profil=1&type_module=SITO&id_module=25', + [ + 'type_aff' => 3, + 'nb_aff' => 2, + 'group_by_categorie' => true, + 'id_categorie' => '12-17' + ]); + + + $this->assertEquals('0', Class_Profil::find(1)->getModuleAccueilConfig(25,'SITO')['preferences']['group_by_categorie']); + + } + /** @test */ + public function selectHierachicalDisplayWithEmptyCategoriesShouldSaveOnlyFirstCategory() { + $this->postDispatch('/admin/accueil/sitotheque?config=accueil&id_profil=1&type_module=SITO&id_module=25', + [ + 'type_aff' => 3, + 'nb_aff' => 2, + 'group_by_categorie' => 0, + 'id_categorie' => '' + ]); + + $this->assertEquals('',Class_Profil::find(1)->getModuleAccueilConfig(25,'SITO')['preferences']['id_categorie']); + + } + + +} class AccueilControllerConfigSitothequeDefaultsTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -296,6 +354,11 @@ class AccueilControllerConfigSitothequeWithPreferencesTest extends Admin_Abstrac public function displayOrderSelectionShouldBeChecked() { $this->assertXPath('//input[@type="radio"][@name="display_order"][@checked="checked"][@value="Selection"]'); } + +/** @test */ + public function typeHierarchicCanBeSelected() { + $this->assertXPathContentContains('//select[@id="type_aff"]//option[@value=3]','Affichage hiérarchique par catégorie'); + } } diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index 92d2fe4d395f0e453c05a7a1561ce532c3d4604c..7bf29ff1658647b47a4336dff95ea43601405c1a 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -34,71 +34,6 @@ abstract class AdminIndexControllerTestCase extends Admin_AbstractControllerTest } -class AdminIndexControllerTestBabelio extends AdminIndexControllerTestCase { - protected $_old_cfg; - - public function setUp() { - parent::setUp(); - $this->_old_cfg = Zend_Registry::get('cfg'); - } - - - public function tearDown() { - Zend_Registry::set('cfg', $this->_old_cfg); - parent::tearDown(); - } - - - protected function _setExpiration($expire_at) { - Zend_Registry::set('cfg', new Zend_Config(array('babelio' => array('expire_at' => $expire_at)))); - } - - - /** @test */ - public function withNullExpirationShouldBeDisabled() { - $this->_setExpiration(null); - - $this->dispatch('/admin/index', true); - $this->assertQueryContentContains('div.ligne_info b', 'Désactivé'); - $this->assertQueryContentContains('div.ligne_info', 'souscrire à un abonnement'); - } - - - /** @test */ - public function withExpirationNeverShouldBeActivated() { - $this->_setExpiration('never'); - - $this->dispatch('/admin/index'); - $this->assertQueryContentContains('div.ligne_info b', 'Activé'); - $this->assertNotQueryContentContains('div.ligne_info', 'souscrire à un abonnement'); - } - - - /** @test */ - public function withPastExpirationDateShouldBeDisabled() { - $yesterday = new Zend_Date(); - $yesterday->addDay(-1); - $this->_setExpiration($yesterday->toString('yyyy/MM/dd')); - - $this->dispatch('/admin/index'); - $this->assertQueryContentContains('div.ligne_info b', 'Désactivé, expiration le'); - $this->assertQueryContentContains('div.ligne_info', 'souscrire à un abonnement'); - } - - - /** @test */ - public function withFutureExpirationDateShouldBeActivated() { - $tomorrow = new Zend_Date(); - $tomorrow->addDay(1); - $this->_setExpiration($tomorrow->toString('yyyy/MM/dd')); - - $this->dispatch('/admin/index'); - $this->assertQueryContentContains('div.ligne_info b', 'Activé, expiration le'); - $this->assertQueryContentContains('div.ligne_info', 'souscrire à un abonnement'); - } -} - - class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { diff --git a/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fe86cc2dd2d5507000deda97b55e05d9675b7ee5 --- /dev/null +++ b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php @@ -0,0 +1,316 @@ +<?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 Admin_AlbumControllerListViewModeTestCase extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'liste' => '1:cd\r\n200:non identifié\r\n201:livres\r\n202:bd']); + + $this->fixture('Class_CosmoVar', + ['id' => 'nature_docs', + 'liste' => '1:Collection\r\n2:Manuscrits\r\n3:Image']); + + Class_AdminVar::newInstanceWithId('ALBUMS_LIST_MODE', ['valeur' => '1']); + Storm_Model_Loader::defaultToVolatile(); + + $this->fixture('Class_Album', ['id' => 1, + 'titre' => 'Our first album']); + + $this->fixture('Class_AlbumCategorie', + ['id' => 1, + 'libelle' => 'Empty Cat']); + + + $this->fixture('Class_AlbumCategorie', + ['id' => 2, + 'libelle' => 'Cat with children']); + + $this->fixture('Class_AlbumCategorie', + ['id' => 3, + 'libelle' => 'child cat', + 'parent_id' => 2]); + + $this->fixture('Class_AlbumCategorie', + ['id' => 4, + 'libelle' => 'child of child cat', + 'parent_id' => 3]); + + + $this->fixture('Class_Album', ['id' => 2, + 'titre' => 'Second album', + 'cat_id' => 2]); + + } + + + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + Class_AdminVar::newInstanceWithId('ALBUMS_LIST_MODE', ['valeur' => '']); + parent::tearDown(); + } +} + + + +class Admin_AlbumControllerListViewModeIndexTest extends Admin_AlbumControllerListViewModeTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('admin/album/index', true); + } + + + /** @test */ + public function tableTitleShouldBeAlbumsCategories() { + $this->assertXPathContentContains('//th', 'Catégories d\'albums', $this->_response->getBody()); + } + + + /** @test */ + public function defaultCategoryShouldBePresent() { + $this->assertXPathContentContains('//td', 'Albums non classés', $this->_response->getBody()); + } + + + /** @test */ + public function linkToGoInCategoryShouldBePresent() { + $this->assertXPathContentContains('//td//a[contains(@href,"admin/album/index/cat_id/0")]', 'Albums non classés (1)', $this->_response->getBody()); + } + + + /** @test */ + public function emptyCatShouldBePresent() { + $this->assertXPathContentContains('//td', 'Empty Cat', $this->_response->getBody()); + } + + + + /** @test */ + public function breadcumbShouldBePresent() { + $this->assertXPathContentContains('//div//a[contains(@href, "admin/album")]', 'Racine', $this->_response->getBody()); + } + + + /** @test */ + public function breadcumbShouldContainsAddAction() { + $this->assertXPathContentContains('//div[@style="font-size:140%;"]//a[contains(@href, "admin/album/add_categorie")]', 'img', $this->_response->getBody()); + } +} + + + + +class Admin_AlbumControllerListViewModeSearchTest extends Admin_AlbumControllerListViewModeTestCase { + + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') + ->whenCalled('findAllBy') + ->with(['where' => 'titre like \'%Second%\'', + 'order' => 'titre', + 'limitPage' => [0, 25]]) + ->answers([Class_Album::find(2)]) + + ->whenCalled('countBy') + ->with(['where' => 'titre like \'%Second%\'', + 'order' => 'titre']) + ->answers(200) + + ->beStrict(); + + $this->dispatch('admin/album/index/title_search/Second', true); + } + + + /** @test */ + public function searchSecondAlbumShouldDisplayIt() { + $this->assertXPathContentContains('//td', 'Second album', $this->_response->getBody()); + } + + + /** @test */ + public function albumBreadcrumbShouldBePresent() { + $this->assertXPathContentContains('//td//p', 'Cat with children', $this->_response->getBody()); + } + + + /** @test */ + public function paginationShouldContainsSearch() { + $this->assertXPath('//div[@class="paginationControl"]//a[contains(@href,"admin/album/index/title_search/Second/page/2")]', + $this->_response->getBody()); + } + + + /** @test */ + public function editAlbumShouldContainsTitleSearchAndPage() { + $this->assertXPath('//div[@class="actions"]//a[contains(@href,"admin/album/edit_album/title_search/Second/id/2")]', $this->_response->getBody()); + } +} + + + + +class Admin_AlbumControllerListViewModeIndexCategoriesTest extends Admin_AlbumControllerListViewModeTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('admin/album/index/cat_id/0', true); + } + + + /** @test */ + public function defaultCategoryShouldContainsOurFirstAlbum() { + $this->assertXPathContentContains('//td', 'Our first album', $this->_response->getBody()); + } + + + /** @test */ + public function emptyCatShouldNotBePresent() { + $this->assertNotXPathContentContains('//td', 'Empty Cat', $this->_response->getBody()); + } + + + /** @test */ + public function ourFirstAlbumShouldContainsEditAction() { + $this->assertXPathContentContains('//td//a[contains(@href,"album/edit_album/cat_id/0/id/1")]', 'img', $this->_response->getBody()); + } + + + /** @test */ + public function withCatId0BreadcumbShouldContainsAddAction() { + $this->assertXPathContentContains('//div//a[contains(@href, "admin/album/add_categorie")]', 'img', $this->_response->getBody()); + } + + + /** @test */ + public function withCatId0BreadcumbShouldNotContainsEditAndDeleteAction() { + $this->assertNotXPath('//div//a[contains(@href, "admin/album/edit_categorie/id/0")][following-sibling::a[contains(@href,"delete_categorie/id/0")]]'); + } +} + + + +class Admin_AlbumControllerListViewModeIndexSubCategoriesTest extends Admin_AlbumControllerListViewModeTestCase { + + + /** @test */ + public function withCatId2SecondAlbumShouldBePresent() { + $this->dispatch('admin/album/index/cat_id/2', true); + $this->assertXPathContentContains('//td', 'Second album', $this->_response->getBody()); + } + + + /** @test */ + public function withCatId2ChildCatShouldBePresent() { + $this->dispatch('admin/album/index/cat_id/2', true); + $this->assertXPathContentContains('//td', 'child cat', $this->_response->getBody()); + } + + + /** @test */ + public function withCatId3breadcumbShouldContainsParentCat() { + $this->dispatch('admin/album/index/cat_id/3', true); + $this->assertXPathContentContains('//div[@style="font-size:140%;"]', 'Cat with children', $this->_response->getBody()); + } + + + /** @test */ + public function withCatId4breadcumbShouldContainsParentsCat() { + $this->dispatch('admin/album/index/cat_id/4', true); + $this->assertXPathContentContains('//div[@style="font-size:140%;"]', 'Cat with children', $this->_response->getBody()); + } + + + /** @test */ + public function searchInputShouldBePresent() { + $this->dispatch('admin/album/index/cat_id/4', true); + $this->assertXPath('//form//input[@type="text"][@name="title_search"]'); + } +} + + + +class AlbumControllerListModeEditWithPaginationTest + extends Admin_AlbumControllerListViewModeTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/album/edit_album/id/2/page/34', true); + } + + + /** @test */ + public function formCancelShouldContainPage34() { + $this->assertXPath('//div[@class="bouton"][contains(@onclick, "/page/34")]'); + } +} + + + +class AlbumControllerListModeEditPostWithPaginationTest + extends Admin_AlbumControllerListViewModeTestCase { + public function setUp() { + parent::setUp(); + $this->postDispatch('/admin/album/edit_album/id/2/page/34/title_search/erik', + ['titre' => 'Erik Truffaz - Ladyland quartet en concert', + 'type_doc_id' => '102']); + } + + + /** @test */ + public function redirectShouldContainPage34() { + $this->assertContains('/admin/album/edit_album/id/2/page/34/title_search/erik', $this->_response->getHeaders()[0]); + } +} + + + + +class Admin_AlbumControllerListViewModeSearchSpecialCharTest extends Admin_AlbumControllerListViewModeTestCase { + + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') + ->whenCalled('findAllBy') + ->with(['where' => 'titre like \'%é%\'', + 'order' => 'titre', + 'limitPage' => [0, 25]]) + ->answers([Class_Album::find(2)]) + + ->whenCalled('countBy') + ->with(['where' => 'titre like \'%é%\'', + 'order' => 'titre']) + ->answers(200) + + ->beStrict(); + + $this->dispatch('admin/album/index/title_search/é', true); + } + + + /** @test */ + public function editAlbumShouldContainsEditActionWithTitleSearchParam() { + $this->assertXPath('//div[@class="actions"]//a[contains(@href,"admin/album/edit_album/title_search/%C3%A9/id/2")]', $this->_response->getBody()); + } +} diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index d9571f188769040ba2e181ad2245b2f14496e5b2..ef4c6afaf52ccf23066455ab71bc60394bc9bbd3 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -719,7 +719,7 @@ class Admin_AlbumControllerAddAlbumToPatrimoineTest extends Admin_AlbumControlle /** @test */ public function frbrMultiShouldContainFrbrType() { $this->assertXPathContentContains('//script', - '{"name":"frbr_type","label":"Type de lien","attribs":{"style":"width:180px;"},"type":"select","options":{"":"Aucun","2:source":"Diaporama - Est le diaporama de","2:target":"Diaporama - A pour diaporama","1:source":"Ebook - A pour ebook","1:target":"Ebook - Est l\'ebook de"}}', + '{"name":"frbr_type","label":"Type de lien","attribs":{"style":"width:450px;"},"type":"select","options":{"":"Aucun","Diaporama":{"2:source":"Est le diaporama de","2:target":"A pour diaporama"},"Ebook":{"1:source":"A pour ebook","1:target":"Est l\'ebook de"}}}', $this->_response->getBody()); } } @@ -951,8 +951,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest /** @test */ public function shouldRedirectToEditAlbum() { - $this->assertRedirectTo('/admin/album/edit_album/id/'.$this->new_album->getId(), - implode(' :: ', $this->new_album->getErrors())); + $this->assertContains('/admin/album/edit_album/id/'.$this->new_album->getId(), $this->_response->getHeaders()[0]['value']); } @@ -1202,7 +1201,6 @@ abstract class Admin_AlbumControllerEditAlbumMesBDTestCase extends Admin_AlbumCo ->addCollection('Ratm') ->setDistributor('Geffen Records') ->save(); - } } @@ -1609,7 +1607,7 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerEditA /** @test */ public function frbrLinkDescShouldBePresent() { - $this->assertXPathContentContains('//script', '<a href=\\"' . str_replace('/', '\\/', ROOT_URL . BASE_URL) . '\\/recherche\\/viewnotice\\/id\\/8\\/id_notice\\/8\\/type_doc\\/1\\/clef\\/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1?id_profil=7', $this->_response->getBody()); + $this->assertXPathContentContains('//script', '<a href=\\"' . str_replace('/', '\\/', ROOT_URL . BASE_URL) . '\\/recherche\\/viewnotice\\/id\\/8\\/id_notice\\/8\\/type_doc\\/1\\/clef\\/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1?id_profil=7', $this->_response->getBody()); } } @@ -1705,7 +1703,7 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT /** @test */ public function shouldRedirectToEditAlbumIdFourtyThree() { - $this->assertRedirectTo('/admin/album/edit_album/id/43'); + $this->assertContains('/admin/album/edit_album/id/43', $this->_response->getHeaders()[0]['value']); } diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php index c59af9b2f539a5a20df1d199ff26aaa128da2998..bfffb46bec4621633fb257c9fb366218c4a6bcce 100644 --- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php +++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php @@ -273,7 +273,7 @@ class CatalogueControllerWithAdminBibAndRightTotalAccessTest extends AdminCatalo -class CatalogueControllerWithModoPortailIndexTest extends AdminCatalogueControllerTestCase { +class CatalogueControllerWithModoPortailTotalAccessIndexTest extends AdminCatalogueControllerTestCase { protected function _loginHook($account) { $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL; $account->ROLE = 'modo_portail'; @@ -282,14 +282,24 @@ class CatalogueControllerWithModoPortailIndexTest extends AdminCatalogueControll public function setUp() { parent::setUp(); - Class_UserGroup::beVolatile(); + Storm_Model_Loader::defaultToVolatile(); + + Class_Users::getIdentity() + ->setUserGroups([Class_UserGroup::newInstanceWithId(667) + ->addRightDomainesTotalAccess()]); Class_AdminVar::newInstanceWithId('OAI_SERVER', ['valeur' => '1']); $this->dispatch('admin/catalogue/index'); } + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } + + /** @test */ - function responseToIndexShouldNotBeARedirectToAccueil() { + public function shouldNotRedirect() { $this->assertNotRedirect(); } @@ -301,19 +311,19 @@ class CatalogueControllerWithModoPortailIndexTest extends AdminCatalogueControll /** @test */ - public function ulLiShouldContainsHistoire() { + public function shouldContainsHistoire() { $this->assertXPathContentContains('//ul//li', 'Histoire'); } /** @test */ - public function ulLiUlLiShouldContainsPolitique() { + public function shouldContainsPolitique() { $this->assertXPathContentContains('//ul//li//ul//li', 'Politique', $this->_response->getBody()); } /** @test */ - public function pageShouldContainsLinkToEditCataloguePolitique() { + public function shouldContainsLinkToEditCataloguePolitique() { $this->assertXPath('//a[contains(@href, "catalogue/edit/id_catalogue/200")]'); } @@ -325,8 +335,8 @@ class CatalogueControllerWithModoPortailIndexTest extends AdminCatalogueControll /** @test */ - public function pageShouldNotContainsLinkToDeleteCataloguePolitique() { - $this->assertNotXPath('//a[contains(@href, "catalogue/delete/id_catalogue/200")]'); + public function pageShouldContainsLinkToDeleteCataloguePolitique() { + $this->assertXPath('//a[contains(@href, "catalogue/delete/id_catalogue/200")]'); } @@ -338,7 +348,7 @@ class CatalogueControllerWithModoPortailIndexTest extends AdminCatalogueControll /** @test */ public function pageShouldContainsPermalinkForCataloguePolitique() { - $this->assertXPath('//div//input[contains(@value, "recherche/simple/id_catalogue/200")]'); + $this->assertXPathContentContains('//div//span', "recherche/simple/id_catalogue/200"); } @@ -503,8 +513,8 @@ class CatalogueControllerWithAModoBibWithRightAccesDomainesIndexTest extends Adm /** @test */ - public function pageShouldNotContainsLinkToDuplicate() { - $this->assertNotXPath('//a[contains(@href, "catalogue/duplicate")]'); + public function pageShouldContainsLinkToDuplicate() { + $this->assertXPath('//a[contains(@href, "catalogue/duplicate")]'); } @@ -514,8 +524,8 @@ class CatalogueControllerWithAModoBibWithRightAccesDomainesIndexTest extends Adm } /** @test */ - public function pageShouldNotContainsButtonAdd() { - $this->assertNotXPath('//div[contains(@onclick, "catalogue/add")]'); + public function pageShouldContainsButtonAdd() { + $this->assertXPath('//div[contains(@onclick, "catalogue/add")]'); } @@ -1180,12 +1190,12 @@ class CatalogueControllerDeleteActionForReferent extends AdminCatalogueControlle class CatalogueControllerEditActionForReferent extends AdminCatalogueControllerTestCase { - protected function _loginHook($account) { $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL; - $account->ROLE = 'referent'; + $account->ROLE = ZendAfi_Acl_AdminControllerRoles::getNomRole(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL); } + public function setUp() { parent::setUp(); $this->addUserToRightsReferent($this->user_referent); @@ -1193,17 +1203,17 @@ class CatalogueControllerEditActionForReferent extends AdminCatalogueControllerT /** @test */ - public function withReferentShouldHideValiderButtonIfNotCreator() { + public function shouldNotAccessOthersEdition() { $this->dispatch('/admin/catalogue/edit/id_catalogue/6'); - $this->assertNotXPathContentContains('//td', 'Valider'); + $this->assertRedirectTo('/admin/catalogue/index'); } + /** @test */ - public function withReferentShouldShowValiderButtonIfCreator() { + public function shouldAccessItsDomainEdition() { $this->dispatch('/admin/catalogue/edit/id_catalogue/300'); $this->assertXPathContentContains('//td', 'Valider'); } - } @@ -1249,7 +1259,7 @@ class CatalogueControllerPaniersHistoireTest extends AdminCatalogueControllerTes /** @test */ public function pageShouldContainsPermalinkForPanier() { - $this->assertXPath('//div//input[contains(@value, "recherche/simple/id_panier/8")]'); + $this->assertXPathContentContains('//div//span', "recherche/simple/id_panier/8"); } @@ -1519,4 +1529,70 @@ class CatalogueControllerPaniersRemovePanierAndUnindexTest extends AbstractContr public function pommeShouldNotContainsFacetH1() { $this->assertNotContains('Q98', Class_Notice::find(1456)->getFacettes()); } +} + + + + + +class CatalogueControllerGetBrowsableDomainsJsonTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Catalogue', + ['id' => 6, + 'libelle' => 'News', + 'indexer' => true]); + + $this->fixture('Class_Catalogue', + ['id' => 3, + 'libelle' => 'Music', + 'sous_domaines' => [$this->fixture('Class_Catalogue', + ['id' => 8, + 'libelle' => 'Rock', + 'indexer' => true]), + $this->fixture('Class_Catalogue', + ['id' => 42, + 'libelle' => 'Heavy', + 'sous-domaines' => [$this->fixture('Class_Catalogue', + ['id' => 31, + 'libelle' => 'Korn', + 'indexer' => true])], + 'indexer' => true])], + 'indexer' => true]); + + $this->dispatch('admin/catalogue/browsable-domains', true); + } + + + /** @test */ + public function domainMusicShouldBePresent() { + $this->assertContains('Music', $this->_response->getBody()); + } + + + /** @test */ + public function domainHeavyShouldBePresent() { + $this->assertContains('Heavy', $this->_response->getBody()); + } + + + /** @test */ + public function domainNewsShouldBeAnItem() { + $this->assertContains('News', $this->_response->getBody()); + } + + + /** @test */ + public function domainRockShouldBeAnItem() { + $this->assertContains('"items":[{"id":8,"label":"Rock"', $this->_response->getBody()); + } + + + /** @test */ + public function domainKornShouldBeAnItem() { + $this->assertContains('"items":[{"id":31,"label":"Korn"', $this->_response->getBody()); + } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/CmsControllerListModeTest.php b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php index 56c21cf9b7dffdc11fce08ab301645c05b050c66..3e676ebfb85e2f18f9e70d94862865fb21cad8d3 100644 --- a/tests/application/modules/admin/controllers/CmsControllerListModeTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php @@ -62,6 +62,7 @@ class CmsControllerListModeAdminRootTest extends CmsControllerListModeTestCase { + class CmsControllerListModeAdminBibRootTest extends CmsControllerListModeTestCase { public function setUp() { parent::setUp(); @@ -86,12 +87,50 @@ class CmsControllerListModeAdminBibRootTest extends CmsControllerListModeTestCas /** @test */ public function shouldDisplayRootCategory() { $this->assertXPathContentContains('//td/a[contains(@href, "cms/index/id_cat/1")]', - 'Root'); + 'Root', + $this->_response->getBody()); } } + +class CmsControllerListModeAdminBibRootWithDefaultPermissionsOnlyTest extends CmsControllerListModeTestCase { + public function setUp() { + parent::setUp(); + Class_UserGroup_Permission::deleteBy([]); + Class_UserGroup_Permission::permit(Class_Permission::createArticleCategory(), + Class_UserGroup::find(22), + $this->annecy); + ZendAfi_Auth::getInstance()->logUser($this->_admin_bib); + $this->dispatch('/admin/cms', true); + } + + + /** @test */ + public function shouldNotDisplayPortal() { + $this->assertNotXPath('//td/a[contains(@href, "cms/index/id_bib/0")]'); + } + + + /** @test */ + public function shouldDisplayLibraryInBreadcrumbAtRoot() { + $this->assertXPathContentContains('//a[contains(@href, "admin/cms")]', + 'Annecy'); + } + + + /** @test */ + public function shouldDisplayRootCategory() { + $this->assertXPathContentContains('//td/a[contains(@href, "cms/index/id_cat/1")]', + 'Root', + $this->_response->getBody()); + } +} + + + + class CmsControllerListModeAdminBibRootWithoutPermissionsTest extends CmsControllerListModeTestCase { public function setUp() { @@ -115,6 +154,13 @@ class CmsControllerListModeAdminBibSubCategoryTest public function setUp() { parent::setUp(); ZendAfi_Auth::getInstance()->logUser($this->_admin_bib); + + $this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'Wtf', + 'contenu' => 'Welcome', + 'id_cat' => 1]); + $this->dispatch('/admin/cms/index/id_cat/1', true); } @@ -137,6 +183,59 @@ class CmsControllerListModeAdminBibSubCategoryTest $this->assertXPathContentContains('//td/a[contains(@href, "cms/index/id_cat/23")]', 'A la Une'); } + + + /** @test */ + public function shouldDisplayAddArticleAction() { + $this->assertXPath('//td//a[contains(@href, "cms/add/id_cat/23")]', + $this->_response->getBody()); + } +} + + + +class CmsControllerListModeAdminBibSearchTest + extends CmsControllerListModeTestCase { + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->logUser($this->_admin_bib); + + $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)]); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') + ->whenCalled('findAllBy') + ->with(['where' => 'titre like \'%news%\'', + 'id_cat' => [1], + 'order' => 'titre', + 'limitPage' => [0, 25]]) + ->answers([Class_Article::find(1)]) + + ->whenCalled('countBy') + ->with(['where' => 'titre like \'%news%\'', + 'id_cat' => [1], + 'order' => 'titre']) + ->answers(2) + + ->beStrict(); + + $this->dispatch('/admin/cms/index/title_search/news', true); + } + + + /** @test */ + public function newsFromPortailShouldNotBePresent() { + $this->assertNotXPathContentContains('//td', 'News from portail', $this->_response->getBody()); + } } @@ -157,31 +256,41 @@ class CmsControllerListModeEditWithPaginationTest -class CmsControllerListModeEditPostWithPaginationTest - extends CmsControllerListModeTestCase { +class CmsControllerListModeEditPostTest extends CmsControllerListModeTestCase { + protected $_datas; + public function setUp() { parent::setUp(); - $this->postDispatch('/admin/cms/edit/id/4/page/34', - ['titre' => 'Erik Truffaz - Ladyland quartet en concert', - 'auteur' => $this->fixture('Class_Users', - ['id' => 1, - 'login' => 'tom', - 'password' => 'pwd']), - 'id_cat' => 34, - 'debut' => '01/03/2011', - 'fin' => '26/03/2011', - 'events_debut' => '02/03/2011 08:35', - 'events_fin' => '05/03/2011 10:42', - 'contenu' => 'Ici: <img src="../../images/bonlieu.jpg" />', - 'description' => 'Affiche: <img src="http://localhost' . BASE_URL . '/images/concert.jpg" />', - 'id_lieu' => 3, - 'domaine_ids' => ['10'], - 'id_items' => ['1']]); - } - - - /** @test */ - public function redirectShouldContainPage34() { - $this->assertRedirectRegex('|/edit/id/4/page/34|'); - } -} \ No newline at end of file + $this->_datas = ['titre' => 'Erik Truffaz - Ladyland quartet en concert', + 'auteur' => $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'tom', + 'password' => 'pwd']), + 'id_cat' => 34, + 'debut' => '01/03/2011', + 'fin' => '26/03/2011', + 'events_debut' => '02/03/2011 08:35', + 'events_fin' => '05/03/2011 10:42', + 'contenu' => 'Ici: <img src="../../images/bonlieu.jpg" />', + 'description' => 'Affiche: <img src="http://localhost' . BASE_URL . '/images/concert.jpg" />', + 'id_lieu' => 3, + 'domaine_ids' => ['10'], + 'id_items' => ['1']]; + } + + + /** @test */ + public function withPage34AndSearchRedirectShouldContainPage3() { + $this->postDispatch('/admin/cms/edit/id/4/page/3/title_search/erik', $this->_datas); + $this->assertRedirectRegex('|/edit/id/4/page/3/title_search/erik|', $this->getResponseLocation()); + } + + + /** @test */ + public function withIdCat34RedirectShouldContainIdCat() { + $this->postDispatch('/admin/cms/edit/id/4/id_cat/34', $this->_datas); + $this->assertRedirectRegex('|/edit/id/4/id_cat/34|', $this->getResponseLocation()); + } +} + +?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index d2d89edd994e6446b5b05395153fc6ba1c1052cf..e796d2c66baa4041790c9e2f29b7dcb663de09fc 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -153,7 +153,8 @@ abstract class CmsControllerTestCase extends Admin_AbstractControllerTestCase { $cat_a_la_une->setSousCategories([$this->cat_evenements]); $this->annecy - ->setArticleCategories([$this->root_category]); + ->setArticleCategories([$this->root_category]) + ->assertSave(); $this->concert = $this->fixture('Class_Article', ['id' => 4, @@ -689,7 +690,7 @@ class CmsControllerArticleConcertEditActionTest extends CmsControllerWithPermiss /** @test */ public function permalinkShouldContainsArticleAbsoluteUrl() { - $this->assertXPath('//div//input[contains(@value, "cms/articleview/id/4")][contains(@value, "http://")]'); + $this->assertXPathContentContains('//div//span', "cms/articleview/id/4"); } @@ -860,6 +861,13 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer 'date_creation' => '2010-12-25']); + $this->fixture('Class_NoticeDomain', + ['id' => 1, + 'domain_id' => 10, + 'panier_id' => 0, + 'record_alpha_key' => 'ERIKTRUFFAZLADYLANDQUARTETENCONCERT-4-TOM----8']); + + $post_datas= ['titre' => 'Erik Truffaz - Ladyland quartet en concert', 'auteur' => $this->fixture('Class_Users', ['id' => 1, @@ -900,6 +908,12 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer } + /** @test */ + public function erikTruffazShouldBeLinkedToExpectedDomainByFacet() { + $this->assertContains('Q10', Class_Notice::findFirstBy(['alpha_titre' =>'ERIK TRUFFAZ LADYLAND QUARTET EN CONCERT'])->getFacettes()); + } + + /** @test */ public function articleShouldNotHaveIdItems() { $this->assertTrue(Class_Article::find(4)->isAttributeEmpty('id_items')); @@ -1219,7 +1233,7 @@ class CmsControllerArticleAddActionPostTest extends CmsControllerWithPermissionT /** @test */ function redirectToEditNewArticle() { - $this->assertRedirectTo('/admin/cms/edit/id/5', $this->getResponseLocation()); + $this->assertRedirectTo('/admin/cms/edit/id/5/id_cat/23', $this->getResponseLocation()); } @@ -2238,7 +2252,7 @@ class CmsControllerArticleExistingTraductionEditTest extends CmsControllerWithPe /** @test */ function permalinkShouldContainsArticleUrl() { - $this->assertXPath('//div//input[contains(@value, "cms/articleview/id/41")]'); + $this->assertXPathContentContains('//div//span', "cms/articleview/id/41"); } diff --git a/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php b/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php index 9cfd0dfe6939f06f2036d1c0362b5eb99bb1a0bc..83ab23fda79e99ce990f73bf0fe9e6bb5aa79611 100644 --- a/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php +++ b/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php @@ -21,11 +21,15 @@ require_once 'AdminAbstractControllerTestCase.php'; abstract class ModoControllerFormulaireForArticleTestCase extends Admin_AbstractControllerTestCase { - protected $formulaire_de_bougie; + protected + $formulaire_de_bougie, + $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); + Class_AdminVar::newInstanceWithId('CMS_FORMULAIRES')->setValeur(1); + $zork = $this->fixture('Class_Users', ['id' => 34, 'login' => 'zork', @@ -189,6 +193,12 @@ class ModoControllerFormulaireForArticleListWithListeAllParameterTest extends Mo $this->assertXPathContentContains('//a[contains(@href, "admin/modo/export-csv-formulaire/id_article/12")]', 'Export CSV'); } + + + /** @test */ + public function mainFormulairesMenuShouldNotContainsIdArticleParam() { + $this->assertXPath('//div[@class="menu"]//a[@href="/admin/modo/formulaires/liste/all"]'); + } } @@ -297,6 +307,8 @@ class ModoControllerFormulaireExportCSVForArticlTest extends ModoControllerFormu class ModoControllerFormulaireListTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); $hackaton = $this->fixture('Class_Article', diff --git a/tests/application/modules/admin/controllers/ModulesControllerTest.php b/tests/application/modules/admin/controllers/ModulesControllerTest.php index ba59622c2aab83d006d3f0a210d4577ad228a5f5..35f052891c62a1094841590b999059ad0b59a3c5 100644 --- a/tests/application/modules/admin/controllers/ModulesControllerTest.php +++ b/tests/application/modules/admin/controllers/ModulesControllerTest.php @@ -471,6 +471,12 @@ class ModulesControllerConfigRechercheResultatWithPreferencesWithPreferencesTest class ModulesControllerConfigRechercheResultatWithPreferencesTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); + $this->fixture('Class_CodifThesaurus',['id' => 5, + 'id_thesaurus' => 'NEWF', + 'libelle' => 'Custum Facet ', + 'libelle_facette' => 'New Facet']); + + Class_Profil::getCurrentProfil() ->setCfgModules( ['recherche' => ['resultatsimple' => ['suggestion_achat' => 0, @@ -481,7 +487,7 @@ class ModulesControllerConfigRechercheResultatWithPreferencesTest extends Admin_ 'liste_codes' => 'TAENR', 'facettes_actif' => '1', 'facettes_nombre' => '6', - 'facettes_codes' => 'SAMDL', + 'facettes_codes' => 'SAMDLHDELFHNEWF', 'facettes_message' => 'Affiner le résultat...', 'tags_actif' => '1', 'tags_position' => '2', @@ -512,6 +518,14 @@ class ModulesControllerConfigRechercheResultatWithPreferencesTest extends Admin_ } + + + /** @test */ + public function facettesCodesShouldNotContainsDeletedFacet() { + $this->assertXPath('//input[@id="facettes_codes"][@value="SAMDLHNEWF"]'); + } + + /** @test */ public function profilZonesTitreShouldReturnArrayWithZones() { $this->assertEquals(['200$e', '200$f'], Class_Profil::getCurrentProfil()->getZonesTitre()); @@ -542,6 +556,20 @@ class ModulesControllerConfigRechercheResultatWithPreferencesTest extends Admin_ } + + /** @test */ + public function deletedFacetShouldNotAppearInDragAndDrop() { + $this->assertNotXPath('//div[@code="HDELF"]', $this->_response->getBody()); + } + + + + /** @test */ + public function customFacetShouldAppearInDragAndDrop() { + $this->assertXPathContentContains('//div[@code="HNEWF"]', 'New Facet',$this->_response->getBody()); + } + + /** @test */ public function champDisponibiliteShouldBeAvailableForDisplayModeTable() { $this->assertXPathContentContains('//div[@code="V"]', 'En rayon', $this->_response->getBody()); diff --git a/tests/application/modules/admin/controllers/OuverturesControllerTest.php b/tests/application/modules/admin/controllers/OuverturesControllerTest.php index c597c11dfd81fabed4ce8a71804c630b47da3efa..8b9ff6e185539e9c31854c0dcdbe2b2f98a2fe13 100644 --- a/tests/application/modules/admin/controllers/OuverturesControllerTest.php +++ b/tests/application/modules/admin/controllers/OuverturesControllerTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AdminAbstractControllerTestCase.php'; @@ -30,7 +30,7 @@ abstract class OuverturesControllerTestCase extends Admin_AbstractControllerTest Class_Bib::newInstanceWithId(1)->setLibelle('Cran-Gévrier'); Class_Bib::newInstanceWithId(3)->setLibelle('Annecy'); - + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Ouverture') ->whenCalled('save') @@ -105,7 +105,7 @@ class OuverturesControllerIndexActionSiteCranTest extends OuverturesControllerTe /** @test */ public function titleShouldBePlagesDouvertureDeLaBibliothequeCranGevrier() { - $this->assertXPathContentContains('//h1', 'Cran-Gévrier: plages d\'ouverture'); + $this->assertXPathContentContains('//h1', 'Cran-Gévrier: plages ouvertes à la réservation des postes multimédia'); } } @@ -164,7 +164,7 @@ class OuverturesControllerEditOuvertureMardiTest extends OuverturesControllerTes public function formShouldContainsSelectForJour() { $this->assertXPath('//form//input[@name="jour"][@value="23/07/2012"]'); } - + /** @test */ public function formShouldContainsSelectForDebutMatinWithHours() { @@ -237,7 +237,7 @@ class OuverturesControllerAddOuvertureCranTest extends OuverturesControllerTestC $this->dispatch('/admin/ouvertures/add/id_site/1', true); } - + /** @test */ public function formShouldContainsSelectForDebutMatin() { $this->assertXPath('//form//select[@name="debut_matin"]'); @@ -273,8 +273,8 @@ class OuverturesControllerPostAddOuvertureCranTest extends OuverturesControllerT public function setUp() { parent::setUp(); - Class_Ouverture::whenCalled('save')->willDo(function($model) { - $model->setId(99); + Class_Ouverture::whenCalled('save')->willDo(function($model) { + $model->setId(99); return true; }); diff --git a/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php b/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php index 51a1d8fcaf97da0404e7b11171fce4f2fdca4bb7..ae6a55641b268b15fb8f34ef56035bf827e7f900 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php @@ -888,4 +888,43 @@ class Admib_ProfilControllerPageAccueilWithWidgetInBannerPostDispatchTest extend $this->assertFalse(array_key_exists(4, Class_Profil::find(3)->getBoitesDivision(Class_Profil::DIV_BANNIERE))); } } + + + + +class Admin_ProfilControllerPageAccueilWithMenuBoiteEnabledTest extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Profil', ['id' => 712, 'libelle' => 'Parent profile', + 'cfg_accueil' => 'a:4:{s:7:"modules";a:12:{i:5;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:8:{s:4:"menu";s:3:"1-V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"1";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:7:"Valider";s:7:"Valider";s:0:"";s:0:"";}}i:2;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:16:{s:5:"titre";s:14:"ne_pas_toucher";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:1:"1";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:1:"0";s:8:"rss_avis";s:1:"0";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:10:"boite_vide";s:11:"style_liste";s:4:"none";s:13:"styles_reload";s:1:"0";s:7:"Valider";s:7:"Valider";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:7;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:9;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:12;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:2:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";}}i:6;a:3:{s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:16:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";}s:8:"division";s:1:"4";}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}']); + + $this->fixture('Class_Profil', ['id' => 713, + 'parent_id' => 712, + 'id_site' => 0, + 'libelle' => 'My page', + 'cfg_accueil' => 'a:4:{s:7:"modules";a:8:{i:2;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:5;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"4";s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:17:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";s:0:"";s:0:"";}}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}', + ]); + + + $this->fixture('Class_AdminVar',['id'=>'MENU_BOITE', 'valeur' => 1]); + + $cfg_module = "box1|2|NEWS|titre=Articles/type_aff=1/id_categorie=/id_items=/nb_aff=1/nb_analyse=5/display_order=Selection/display_titles_only=/rss_avis=1/op_largeur_img=200/op_hauteur_boite=400/boite=/=/;box1|3|NEWS|titre=Articles/type_aff=1/id_categorie=/id_items=/nb_aff=1/nb_analyse=5/display_order=Selection/display_titles_only=/rss_avis=1/op_largeur_img=200/op_hauteur_boite=400/boite=/=/;box1|1|KIOSQUE|titre=Kiosque/style_liste=slide_show/nb_notices=20/only_img=1/aleatoire=1/tri=1/nb_analyse=50/op_hauteur_img=0/op_transition=/op_largeur_img=0/op_hauteur_boite=0/op_captions=0/op_autoplay=0/op_visible=0/op_speed=0/op_auto=0/op_scroll=1/rss_avis=1/id_catalogue=0/id_panier=0/profil_redirect=/boite=/=/;box1|4|KIOSQUE|titre=Kiosque/style_liste=slide_show/nb_notices=20/only_img=1/aleatoire=1/tri=1/nb_analyse=50/op_hauteur_img=0/op_transition=/op_largeur_img=0/op_hauteur_boite=0/op_captions=0/op_autoplay=0/op_visible=0/op_speed=0/op_auto=0/op_scroll=1/rss_avis=1/id_catalogue=0/id_panier=0/profil_redirect=/boite=/=/;box2|8|MENU_VERTICAL|menu=V/afficher_titre=1/menu_deplie=0/new_html=0/boite=/titre=/=/;box2|5|MENU_VERTICAL|menu=V/afficher_titre=1/menu_deplie=0/new_html=0/boite=/titre=/=/;box3|10|PANIER|titre=Panier/boite=/=/;box3|new|PANIER|;box4|6|LOGIN|titre=Mon compte lecteur/titre_connecte=/identifiant=N° de carte/identifiant_exemple=/mot_de_passe=Année de naissance/mot_de_passe_exemple=/lien_connexion=Se connecter/lien_mot_de_passe_oublie=» Mot de passe oublié ?/lien_creer_compte=» S'enregistrer/message_connecte=Bienvenue/lien_compte=Mon compte/lien_deconnection=Se déconnecter/autocomplete_off=1/profil_redirect=/profil_logout_redirect=/boite=boite_banniere_droite/"; + + + $this + ->getRequest() + ->setMethod('POST') + ->setPost(array('saveContent' => $cfg_module)); + $this->dispatch('/admin/profil/accueil/id_profil/713'); + } + + + /** @test */ + public function newCartModuleShouldBeAdded() { + $profil = Class_Profil::find(713); + $cfg_accueil = $profil->getCfgAccueilAsArray(); + $this->assertCount(9, $cfg_accueil['modules']); + } +} ?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index 37a02c60db108b030a673c01ac263534dfd4d9e5..83f87c6b3189167453141982bab3b99d8ee15ded 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -101,6 +101,29 @@ class Admin_ProfilControllerEditProfilJeunesseTest extends Admin_ProfilControlle parent::tearDown(); } + /** @test */ + public function allowInputPercentAndPixels() { + $this->assertXPathContentContains("//select[@name='size_site_scale']","pixels"); + } + + + + /** @test */ + public function allowInputDivision1PercentAndPixels() { + $this->assertXPathContentContains("//select[@name='width_division1_scale']","pixels",$this->_response->getBody()); + } + + + /** @test */ + public function allowInputDivision2PercentAndPixels() { + $this->assertXPathContentContains("//select[@name='width_division2_scale']","pixels"); + } + + /** @test */ + public function allowInputDivision3PercentAndPixels() { + $this->assertXPathContentContains("//select[@name='width_division3_scale']","pixels"); + } + /** * @test @@ -563,7 +586,8 @@ class Admin_ProfilControllerEditProfilVideTest extends Admin_AbstractControllerT $data = array('libelle' => '', 'largeur_site' => 200, 'largeur_division1' => 100, - 'largeur_division2' => 500); + 'largeur_division2' => 500 + ); $this ->getRequest() ->setMethod('POST') @@ -803,30 +827,33 @@ class Admin_ProfilControllerProfilPostAddTest extends Admin_ProfilControllerProf public function setUp() { parent::setUp(); - $wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Profil') +/* $wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Profil') ->whenCalled('save') ->willDo(function($model) { $model->setId(456); return true; }); - +*/ $data = array( 'libelle' => "Histoire", 'id_site' => 1, - 'nb_divisions' => 2, + 'nb_divisions' => 3, 'largeur_division1' => 400, 'marge_division1' => 5, 'largeur_division2' => 500, + 'size_site_scale' => 'percent', + 'largeur_division3' => '30', + 'width_division3_scale' => 'percent', 'marge_division2' => 8, - 'largeur_site' => 900, + 'largeur_site' => 100, 'access_level' => 6); $this ->getRequest() ->setMethod('POST') ->setPost($data); - $this->dispatch('/admin/profil/add'); + $this->dispatch('/admin/profil/add',true); - $this->_new_profil = $wrapper->getFirstAttributeForLastCallOn('save'); + $this->_new_profil = Class_Profil::findFirstBy(['libelle' => "Histoire"]);//$wrapper->getFirstAttributeForLastCallOn('save'); } @@ -838,7 +865,7 @@ class Admin_ProfilControllerProfilPostAddTest extends Admin_ProfilControllerProf /** @test */ public function responseShouldRedirectToEditNewProfil() { - $this->assertRedirectTo('/admin/profil/edit/id_profil/456'); + $this->assertRedirectTo('/admin/profil/edit/id_profil/'.$this->_new_profil->getId()); } @@ -846,7 +873,7 @@ class Admin_ProfilControllerProfilPostAddTest extends Admin_ProfilControllerProf * @test */ public function getNbDivisionsShouldReturnTwo() { - $this->assertEquals(2, $this->_new_profil->getNbDivisions()); + $this->assertEquals(3, $this->_new_profil->getNbDivisions()); } @@ -869,22 +896,20 @@ class Admin_ProfilControllerProfilPostAddTest extends Admin_ProfilControllerProf /** * @test */ - public function getLargeurSiteShouldReturnNineHundred() { - $this->assertEquals(900, $this->_new_profil->getLargeurSite()); + public function getLargeurSiteShouldReturnHundredPercent() { + $this->assertEquals(100, $this->_new_profil->getLargeurSite()); } - /** - * @test - */ - public function currentProfilShouldBeNewProfil() { - $this->assertEquals(456, Class_Profil::getCurrentProfil()->getId()); - } - /** @test */ public function sessionIdProfilShould456() { - $this->assertEquals(456, Zend_Registry::get('session')->id_profil); + $this->assertEquals($this->_new_profil->getId(), Zend_Registry::get('session')->id_profil); + } + +/** @test */ + public function largeurDivision3ShouldBe30percent() { + $this->assertEquals(30, $this->_new_profil->getLargeurDivision3()); } } diff --git a/tests/application/modules/admin/controllers/SitothequeControllerTest.php b/tests/application/modules/admin/controllers/SitothequeControllerTest.php index b07d08fc6ce1c9ac62a25bb9487bffc8714f5ed0..59dd1f60caabcce03a89cd258bb28a63bee8b6fe 100644 --- a/tests/application/modules/admin/controllers/SitothequeControllerTest.php +++ b/tests/application/modules/admin/controllers/SitothequeControllerTest.php @@ -30,7 +30,7 @@ abstract class SitothequeControllerTestCase extends Admin_AbstractControllerTest Class_Exemplaire::beVolatile(); Class_Notice::beVolatile(); Class_CodifThesaurus::beVolatile(); - + Storm_Model_Loader::defaultToVolatile(); $categorie_informations = $this->fixture('Class_SitothequeCategorie', ['id' => 2, 'libelle' => 'Informations', @@ -59,6 +59,12 @@ abstract class SitothequeControllerTestCase extends Admin_AbstractControllerTest Class_Bib::getPortail()->setSitothequeCategories([]); } + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } + + public function setupDomaines() { $this->fixture('Class_Catalogue', ['id' => 10, diff --git a/tests/application/modules/admin/controllers/UploadControllerTest.php b/tests/application/modules/admin/controllers/UploadControllerTest.php index d409deb9f45f21c327d07d76e9938cb14cec1cb2..90866ff569b421ec7c6553ff7bd32f645870be0d 100644 --- a/tests/application/modules/admin/controllers/UploadControllerTest.php +++ b/tests/application/modules/admin/controllers/UploadControllerTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AbstractControllerTestCase.php'; @@ -121,18 +121,18 @@ class UploadControllerMultipleProcessPostAction extends AbstractControllerTestCa } - /** + /** * @depends withModelShouldCallFileProcessingMethod - * @test + * @test */ public function modelShouldBeSavedAfterAddFile($album) { $this->assertTrue($album->methodHasBeenCalled('save')); } - /** + /** * @depends withModelShouldCallFileProcessingMethod - * @test + * @test */ public function albumDateMajShouldBeNow($album) { $today = new Zend_Date(); @@ -219,13 +219,14 @@ class UploadControllerVignetteNoticeActionPostValidUrlTest extends UploadControl .'&auteur='.urlencode('J.K.Rowling') .'&image='.urlencode('http://upload.wikimedia.org/potter.jpg') .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' .'&action=12') ->answers(json_encode(['vignette' => 'http://cache.org/potter_thumb.jpg', 'image' => 'http://cache.org/potter.jpg', 'statut_recherche' => 2])) ->beStrict(); - $this->postDispatch('/admin/upload/vignette-notice/id/12345', + $this->postDispatch('/admin/upload/vignette-notice/id/12345', ['url_vignette' => 'http://upload.wikimedia.org/potter.jpg'], true); } @@ -244,14 +245,14 @@ class UploadControllerVignetteNoticeActionPostValidUrlTest extends UploadControl /** @test */ public function pageShouldDisplayVignetteTransferee() { - $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); + $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); } /** @test */ public function pageShouldContainsAButtonToCloseWindow() { - $this->assertXPathContentContains('//button[contains(@onclick, "hidePopWin")]', - 'Fermer'); + $this->assertXPathContentContains('//button[contains(@onclick, "hidePopWin")]', + 'Fermer'); } } @@ -278,13 +279,14 @@ class UploadControllerVignetteNoticeActionPostValidUrlForPeriodiqueTest extends .'&numero=1118' .'&clef_chapeau='.urlencode('SCIENCE VIE') .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' .'&action=12') ->answers(json_encode(['vignette' => 'http://cache.org/science_vie_thumb.jpg', 'image' => 'http://cache.org/science_vie.jpg', 'statut_recherche' => 2])) ->beStrict(); - $this->postDispatch('/admin/upload/vignette-notice/id/12345', + $this->postDispatch('/admin/upload/vignette-notice/id/12345', ['url_vignette' => 'http://upload.wikimedia.org/science_vie.jpg'], true); } @@ -292,7 +294,7 @@ class UploadControllerVignetteNoticeActionPostValidUrlForPeriodiqueTest extends /** @test */ public function pageShouldDisplayVignetteTransferee() { - $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); + $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); } } @@ -305,11 +307,11 @@ class UploadControllerVignetteNoticePostServeurCacheErrorTest extends UploadCont Class_WebService_AllServices::setHttpClient($http_client = Storm_Test_ObjectWrapper::mock() ->whenCalled('open_url') - ->answers(json_encode(['statut_recherche' => 'erreur', + ->answers(json_encode(['statut_recherche' => 'erreur', 'erreur' => 'Image indisponible']))); - $this->postDispatch('/admin/upload/vignette-notice/id/12345', + $this->postDispatch('/admin/upload/vignette-notice/id/12345', ['url_vignette' => 'http://upload.wikimedia.org/potter.jpg'], true); } @@ -317,7 +319,7 @@ class UploadControllerVignetteNoticePostServeurCacheErrorTest extends UploadCont /** @test */ public function pageShouldDisplayErrorMessageImageIndisponible() { - $this->assertXPathContentContains('//div[@class="error"]', 'Erreur: Image indisponible'); + $this->assertXPathContentContains('//div[@class="error"]', 'Erreur: Image indisponible'); } @@ -363,27 +365,27 @@ class UploadControllerVignetteNoticeActionInvalidPostTest extends UploadControll } - /** + /** * @dataProvider validUrls - * @test + * @test */ public function pageShouldDisplayErrorIfExtensionNotAllowed($url) { - $this->postDispatch('/admin/upload/vignette-notice/id/12345', + $this->postDispatch('/admin/upload/vignette-notice/id/12345', ['url_vignette' => $url], true); - $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); + $this->assertXPathContentContains('//p', 'La vignette a bien été transférée'); } - /** + /** * @dataProvider invalidUrls - * @test + * @test */ public function pageShouldNotDisplayErrorIfUrlCorrect($url) { - $this->postDispatch('/admin/upload/vignette-notice/id/12345', + $this->postDispatch('/admin/upload/vignette-notice/id/12345', ['url_vignette' => $url], true); - $this->assertXPath('//ul[@class="errors"]'); + $this->assertXPath('//ul[@class="errors"]'); } } @@ -422,12 +424,13 @@ class UploadControllerBiographieNoticeActionPostValidUrlTest extends UploadContr .'?url_auteur='.urlencode('http://fr.wikipedia.org/wiki/J.K_Rowling') .'&clef_oeuvre=HARRY_POTTER' .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' .'&action=13') ->answers(json_encode(['url_auteur' => 'http://fr.wikipedia.org/wiki/J.K_Rowling', 'statut_recherche' => 2])) ->beStrict(); - $this->postDispatch('/admin/upload/biographie-notice/id/12345', + $this->postDispatch('/admin/upload/biographie-notice/id/12345', ['url_auteur' => 'http://fr.wikipedia.org/wiki/J.K_Rowling'], true); } @@ -435,7 +438,7 @@ class UploadControllerBiographieNoticeActionPostValidUrlTest extends UploadContr /** @test */ public function pageShouldDisplayBiographieAJour() { - $this->assertXPathContentContains('//p', 'La nouvelle URL a bien été enregistrée'); + $this->assertXPathContentContains('//p', 'La nouvelle URL a bien été enregistrée'); } } @@ -447,11 +450,11 @@ class UploadControllerBiographieNoticePostServeurCacheErrorTest extends UploadCo Class_WebService_AllServices::setHttpClient($http_client = Storm_Test_ObjectWrapper::mock() ->whenCalled('open_url') - ->answers(json_encode(['statut_recherche' => 'erreur', + ->answers(json_encode(['statut_recherche' => 'erreur', 'message' => 'Biographie non trouvée']))); - $this->postDispatch('/admin/upload/biographie-notice/id/12345', + $this->postDispatch('/admin/upload/biographie-notice/id/12345', ['url_auteur' => 'http://fr.wikipedia.org/wiki/J.K_Rowling'], true); } @@ -459,7 +462,7 @@ class UploadControllerBiographieNoticePostServeurCacheErrorTest extends UploadCo /** @test */ public function pageShouldDisplayErrorMessageBiographieNonTrouvee() { - $this->assertXPathContentContains('//div[@class="error"]', 'Erreur: Biographie non trouvée'); + $this->assertXPathContentContains('//div[@class="error"]', 'Erreur: Biographie non trouvée'); } } diff --git a/tests/application/modules/admin/controllers/ZoneControllerTest.php b/tests/application/modules/admin/controllers/ZoneControllerTest.php index 21e019877aa5890a6de8947feb5ddb780c6ad0a7..54647bbd57396ee20f651bea1866eb9eb0d7c0d2 100644 --- a/tests/application/modules/admin/controllers/ZoneControllerTest.php +++ b/tests/application/modules/admin/controllers/ZoneControllerTest.php @@ -16,35 +16,37 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AbstractControllerTestCase.php'; abstract class ZoneControllerTestCase extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - $this->zone_annecy = Class_Zone::getLoader() - ->newInstanceWithId(2) - ->setLibelle('Annecy') - ->setCouleur('#123') - ->setMapCoords('93,14,87,20') - ->setImage('bassin annecy.jpg'); - - $this->zone_pringy = Class_Zone::getLoader() - ->newInstanceWithId(4) - ->setLibelle('Pringy') - ->setCouleur('#456') - ->setImage('pringy.jpg'); - - - $this->loader_wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Zone') - ->whenCalled('findAll') - ->answers(array($this->zone_annecy, $this->zone_pringy)) - ->getWrapper(); - } + Storm_Model_Loader::defaultToVolatile(); + $this->zone_annecy = $this->fixture('Class_Zone', + ['id' => 2, + 'libelle' => 'Annecy', + 'couleur' => '#123', + 'map_coords' => '93,14,87,20', + 'image' => 'bassin annecy.jpg']); + + $this->zone_pringy = $this->fixture('Class_Zone', + ['id' => 4, + 'libelle' => 'Pringy', + 'couleur' => '#456', + 'image' => 'pringy.jpg']); + } + + + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } } + class ZoneControllerIndexActionTest extends ZoneControllerTestCase { public function setUp(){ parent::setUp(); @@ -69,7 +71,14 @@ class ZoneControllerIndexActionTest extends ZoneControllerTestCase { class ZoneControllerPlacerBibsActionTest extends ZoneControllerTestCase { public function setUp() { parent::setUp(); - $this->dispatch('admin/zone/placerbibs/id_zone/2'); + + $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'Annecy', + 'id_zone' => 2, + 'visibilite' => 1]); + + $this->dispatch('admin/zone/placerbibs/id_zone/2', true); } @@ -81,6 +90,105 @@ class ZoneControllerPlacerBibsActionTest extends ZoneControllerTestCase { +abstract class ZoneControllerPlacerBibsPostActionTestCase extends ZoneControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Profil', + ['id' => 1, + 'libelle' => 'Home']); + + $this->fixture('Class_Profil', + ['id' => 2, + 'libelle' => 'Bib d\'Annecy']); + + $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'Annecy', + 'id_zone' => 2, + 'visibilite' => 1]); + } +} + + + +class ZoneControllerPlacerBibsPostActionWithProfilTest extends ZoneControllerPlacerBibsPostActionTestCase { + + public function setUp() { + parent::setUp(); + + $aff_zone = ZendAfi_Filters_Serialize::serialize(['posX' => '25', + 'posY' => '65', + 'posPoint' => 'above', + 'profilID' => '1']); + + Class_Bib::find(1)->setAffZone($aff_zone)->save(); + + $this->postDispatch('admin/zone/placerbibs/id_zone/2', ['posX_1' => '50', + 'posY_1' => '150', + 'posPoint_1' => 'left', + 'profilID_1' => '2']); + } + + + /** @test */ + public function urlForAnnecyShouldBeProfil() { + $this->assertEquals('/index/index/id_profil/2', Class_Bib::find(1)->getUrl()); + } + + + /** @test */ + public function annecyPosXShouldBe50() { + $this->assertEquals('50', Class_Bib::find(1)->getPosX()); + } + +} + + + +class ZoneControllerPlacerBibsPostActionWithOutTest extends ZoneControllerPlacerBibsPostActionTestCase { + + public function setUp() { + parent::setUp(); + $this->postDispatch('admin/zone/placerbibs/id_zone/2', ['posX_1' => '50', + 'posY_1' => '150', + 'posPoint_1' => 'left']); + } + + + /** @test */ + public function urlForAnnecyShouldBeBeBibView() { + $this->assertEquals('/bib/bibview/id/1', Class_Bib::find(1)->getUrl()); + } + + + /** @test */ + public function annecyPosXShouldBe50() { + $this->assertEquals('50', Class_Bib::find(1)->getPosX()); + } + + + /** @test */ + public function annecyPosYShouldBe150() { + $this->assertEquals('150', Class_Bib::find(1)->getPosY()); + } + + + /** @test */ + public function posPointForAnnecyShouldBeLeft() { + $this->assertEquals('left', Class_Bib::find('1')->getPosPoint()); + } + + + /** @test */ + public function profilForAnnecyShouldBeEmpty() { + $this->assertEquals('0', Class_Bib::find('1')->getProfilId()); + } +} + + + + class ZoneControllerEditAnnecyTest extends ZoneControllerTestCase { public function setUp() { parent::setUp(); @@ -137,21 +245,10 @@ class ZoneControllerPostValidDataForAnnecyTest extends ZoneControllerTestCase { public function setUp() { parent::setUp(); - $data = array('libelle' => 'Bassin annécien', - 'couleur' => '123456', - 'map_coords' => '34,45', - 'image' => 'paquier.jpg'); - - $this->loader_wrapper - ->whenCalled('save') - ->answers(true); - - $this - ->getRequest() - ->setMethod('POST') - ->setPost($data); - - $this->dispatch('admin/zone/edit/id/2'); + $this->postDispatch('admin/zone/edit/id/2', ['libelle' => 'Bassin annécien', + 'couleur' => '123456', + 'map_coords' => '34,45', + 'image' => 'paquier.jpg']); } @@ -163,7 +260,7 @@ class ZoneControllerPostValidDataForAnnecyTest extends ZoneControllerTestCase { /** @test */ function shouldRedirectToIndexPage() { - $this->assertRedirect('admin/zone/index'); + $this->assertRedirect('admin/zone/index'); } @@ -174,28 +271,18 @@ class ZoneControllerPostValidDataForAnnecyTest extends ZoneControllerTestCase { } + class ZoneControllerPostEmptyLabelForAnnecyTest extends ZoneControllerTestCase { public function setUp() { parent::setUp(); - $data = array('libelle' => ''); - - $this->loader_wrapper - ->whenCalled('save') - ->answers(true); - - $this - ->getRequest() - ->setMethod('POST') - ->setPost($data); - - $this->dispatch('admin/zone/edit/id/2'); + $this->postDispatch('admin/zone/edit/id/2', ['libelle' => '']); } /** @test */ function shouldNotRedirectToIndexPage() { - $this->assertNotRedirect('admin/zone/index'); + $this->assertNotRedirect('admin/zone/index'); } /** @test */ @@ -223,24 +310,12 @@ class ZoneControllerAddActionTest extends ZoneControllerTestCase { /** @test */ function postShouldSaveNewObject() { - $data = array('libelle' => 'Cran', - 'couleur' => '#456', - 'map_coords' => '34,45', - 'image' => 'paquier.jpg'); - - $this->loader_wrapper - ->whenCalled('save') - ->answers(true); - - $this - ->getRequest() - ->setMethod('POST') - ->setPost($data); - - $this->dispatch('admin/zone/add'); + $this->postDispatch('admin/zone/add', ['libelle' => 'Cran', + 'couleur' => '#456', + 'map_coords' => '34,45', + 'image' => 'paquier.jpg']); - $new_zone = $this->loader_wrapper->getFirstAttributeForLastCallOn('save'); - $this->assertEquals('Cran', $new_zone->getLibelle()); + $this->assertEquals('Cran', Class_Zone::find(5)->getLibelle()); } } diff --git a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php index 60e2f57f558bf635f90d7856ac1332ebe9f640f3..b80041d229fec075a64442d52a826dcd94ce1c71 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php @@ -24,14 +24,30 @@ require_once 'application/modules/opac/controllers/AbonneController.php'; trait TAbonneControllerMultimediaFixtureHoldSuccessOnSept12 { protected function _launch() { - $this->onLoaderOfModel('Class_Multimedia_Location') +/* $this->onLoaderOfModel('Class_Multimedia_Location') ->whenCalled('findByIdOrigine') ->answers(Class_Multimedia_Location::newInstanceWithId(1)); $this->onLoaderOfModel('Class_Multimedia_Device') ->whenCalled('findByIdOrigineAndLocation') - ->answers(Class_Multimedia_Device::newInstanceWithId(1)); + ->answers(Class_Multimedia_Device::newInstanceWithId(1));*/ + $this->fixture('Class_Multimedia_Device', + ['id' => 1, + 'id_origine' => '1-1', + 'group' => $this->fixture('Class_Multimedia_DeviceGroup', + ['id' => 1, + 'location' => $this->fixture('Class_Multimedia_Location', + ['id' => 1, 'id_origine' => 1, + 'ouvertures' => $this->fixture('Class_Ouverture', + ['id' => 1, + 'Jour' => '2012-09-12', + 'horaires' => ['08:00', '12:00', '12:00', '18:00']]) + ]) + ]) + ]); + + $this->onLoaderOfModel('Class_Multimedia_DeviceHold') ->whenCalled('getHoldOnDeviceAtTime') @@ -119,20 +135,15 @@ abstract class AbonneControllerMultimediaAuthenticateTestCase extends AbstractCo * @param $group_label string */ protected function _expectGroupForUser($user, $group_label) { - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroupMembership') - ->whenCalled('findAllBy') - ->with(['role' => 'user', 'model' => $user]) - ->answers(array(Class_UserGroupMembership::getLoader() - ->newInstance() - ->setUserGroup(Class_UserGroup::getLoader() - ->newInstanceWithId(1) - ->setLibelle($group_label)))); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') - ->whenCalled('findAllBy') - ->with(['role_level' => $user->getRoleLevel(), - 'group_type' => Class_UserGroup::TYPE_DYNAMIC]) - ->answers([]); + $this->fixture('Class_UserGroupMembership', + ['id' => 1, + 'user'=>$user, + 'user_group'=> $this->fixture('Class_UserGroup', + ['id'=>1, + 'libelle'=>$group_label, + 'group_type' => Class_UserGroup::TYPE_MULTIMEDIA]) + ]); + } } @@ -215,6 +226,40 @@ class AbonneControllerMultimediaAuthenticateMireilleTest extends AbonneControlle } +class AbonneControllerMultimediaAuthenticateInviteNonAfiMultimediaTest extends AbonneControllerMultimediaAuthenticateTestCase { + public function setUp() { + parent::setUp(); + $user = AbonneControllerMultimediaUsersFixtures::getInvite(); + $this->_expectUserToLoad($user); + + $this->_json = $this->getJson('/abonne/authenticate/login/invite/password/invite/poste/1/site/1'); + } + + + /** @test */ + public function shouldReturnSubscriptionExpired() { + $this->assertEquals('SubscriptionExpired', $this->_json->error); + } + +} + +class AbonneControllerMultimediaAuthenticateInviteAfiMultimediaTest extends AbonneControllerMultimediaAuthenticateTestCase { + public function setUp() { + parent::setUp(); + $user = AbonneControllerMultimediaUsersFixtures::getInvite(); + $this->_expectUserToLoad($user); + $this->_expectGroupForUser($user, 'Abonne multimedia'); + + $this->_json = $this->getJson('/abonne/authenticate/login/invite/password/invite/poste/1/site/1'); + } + + + /** @test */ + public function shouldReturnDeviceNotFound() { + $this->assertEquals('DeviceNotFound', $this->_json->error); + } + +} abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends AbonneControllerMultimediaAuthenticateTestCase { @@ -222,6 +267,7 @@ abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends Abonn protected $_group; public function setUp() { + Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:00:00')); parent::setUp(); $this->_initUser(); @@ -230,21 +276,47 @@ abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends Abonn $this->_launch(); } + protected function _initUser() {} +} +abstract class AbonneControllerMultimediaCheckedHoldableDayTestCase extends AbonneControllerMultimediaAuthenticateValidTestCase { protected function _launch() { - $this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1', + $this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1/mode/holdable-day', $this->_user->getLogin(), $this->_user->getPassword())); } +} + + +class AbonneControllerMultimediaHoldableDay extends AbonneControllerMultimediaCheckedHoldableDayTestCase { + use + TAbonneControllerMultimediaFixtureHoldSuccessOnSept12, + TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; + + /** @test */ + public function shouldHaveAuth() { + $this->assertEquals(1, $this->_json->auth); + } + + /** @test */ + public function shouldHaveHoldedDay() { + $this->assertEquals(1, $this->_json->holding); + } - protected function _initUser() {} } +abstract class AbonneControllerMultimediaHoldedTestCase extends AbonneControllerMultimediaAuthenticateValidTestCase { + protected function _launch() { + $this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1/mode/hold', + $this->_user->getLogin(), + $this->_user->getPassword())); + } +} -class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneControllerMultimediaAuthenticateValidTestCase { +class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneControllerMultimediaHoldedTestCase { use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12, TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; @@ -299,107 +371,24 @@ class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneController /** @test */ - public function shouldHaveHold() { + public function shouldHaveAuth() { $this->assertEquals(1, $this->_json->auth); } - - /** @test */ - public function holdShouldLastUntil16h40() { - $this->assertEquals('2012-09-12T16:40:00+02:00', $this->_json->until); - } -} - - -class AbonneControllerMultimediaAuthenticateLaurentAtClosingDaysDeviceHoldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase { - use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; - - protected function _launch() { - - Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:30:00')); - - $this->onLoaderOfModel('Class_Multimedia_Location') - ->whenCalled('findByIdOrigine') - ->answers($location = Class_Multimedia_Location::newInstanceWithId(1) - ->setSlotSize(30) - ->setAutoholdSlotsMax(1) - ->setAuthDelay(1) - ->setAutohold(1) - ->setOuvertures([]) - ->setAutoholdForClosingDays(1) - ->setOpenHour('09:00') - ->setCloseHour('17:00')); - - $this->onLoaderOfModel('Class_Multimedia_Device') - ->whenCalled('findByIdOrigineAndLocation') - ->answers(Class_Multimedia_Device::newInstanceWithId(1) - ->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(34)->setLocation($location))); - - - $this->onLoaderOfModel('Class_Multimedia_DeviceHold') - ->whenCalled('getHoldOnDeviceAtTime') - ->answers(null); - - parent::_launch(); - } - - /** @test */ public function shouldHaveHold() { - $this->assertEquals(1, $this->_json->auth); - } - - /** @test */ - public function holdShouldLastUntil16h40() { - $this->assertEquals('2012-09-12T10:00:00+02:00', $this->_json->until); - } - - -} - - -class AbonneControllerMultimediaAuthenticateLaurentAtClosingDaysDeviceNotHeldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase { - use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; - - protected function _launch() { - - Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:30:00')); - - $this->onLoaderOfModel('Class_Multimedia_Location') - ->whenCalled('findByIdOrigine') - ->answers($location = Class_Multimedia_Location::newInstanceWithId(1) - ->setAuthDelay(1) - ->setAutohold(1) - ->setOuvertures([]) - ->setAutoholdForClosingDays(0) - ->setOpenHour('09:00') - ->setCloseHour('17:00')); - - $this->onLoaderOfModel('Class_Multimedia_Device') - ->whenCalled('findByIdOrigineAndLocation') - ->answers(Class_Multimedia_Device::newInstanceWithId(1) - ->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(34)->setLocation($location))); - - - $this->onLoaderOfModel('Class_Multimedia_DeviceHold') - ->whenCalled('getHoldOnDeviceAtTime') - ->answers(null); - - parent::_launch(); + $this->assertEquals(1, $this->_json->holded); } /** @test */ - public function shouldHaveNotHeld() { - $this->assertEquals(0, $this->_json->auth); + public function holdShouldLastUntil16h40() { + $this->assertEquals('2012-09-12T16:40:00+02:00', $this->_json->until); } - - } - -class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase { +class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest extends AbonneControllerMultimediaHoldedTestCase { use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; protected function _launch() { @@ -407,7 +396,6 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest exten ->whenCalled('findByIdOrigine') ->answers($location = Class_Multimedia_Location::newInstanceWithId(1) ->setAuthDelay(1) - ->setAutoholdForClosingDays(0) ->setAutohold(1)); $this->onLoaderOfModel('Class_Multimedia_Device') @@ -447,7 +435,7 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest exten -class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends AbonneControllerMultimediaAuthenticateValidTestCase { +class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends AbonneControllerMultimediaHoldedTestCase { use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles; protected function _launch() { $this->onLoaderOfModel('Class_Multimedia_Location') @@ -476,7 +464,7 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends Ab -class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerMultimediaAuthenticateValidTestCase { +class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerMultimediaHoldedTestCase { use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12; protected function _initUser() { @@ -500,7 +488,7 @@ class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerM -class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControllerMultimediaAuthenticateValidTestCase { +class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControllerMultimediaHoldedTestCase { use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12; protected function _initUser() { @@ -529,8 +517,6 @@ class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControlle } - - /* Début test du workflow de réservation */ abstract class AbonneControllerMultimediaHoldTestCase extends AbstractControllerTestCase { protected $_session; @@ -566,7 +552,6 @@ abstract class AbonneControllerMultimediaHoldTestCase extends AbstractController ->setLibelle('Antibes') ->setSlotSize(30) ->setMaxSlots(4) - ->setAutoholdForClosingDays(0) ->setHoldDelayMin(0) ->setHoldDelayMax(60) ->setOuvertures([Class_Ouverture::chaqueLundi('08:30', '12:00', '12:00', '17:45')->setId(1)->cache(), @@ -1314,6 +1299,8 @@ class AbonneControllerMultimediaHoldFicheAbonneTest extends AbstractControllerTe ->setBib(Class_Bib::newInstanceWithId(5) ->setLibelle('Médiathèque d\'Antibes'))))) ]); + $this->fixture('Class_Ouverture', ['id' => 1]); + $this->dispatch('/abonne/fiche', true); } @@ -1372,6 +1359,13 @@ class AbonneControllerMultimediaUsersFixtures { ->setDateFin('1999-01-01'); } + public static function getInvite() { + return Class_Users::getLoader()->newInstanceWithId(12) + ->beInvite() + ->setLogin("invite") + ->setPassword("invite"); + + } public static function getArnaud() { return Class_Users::getLoader()->newInstanceWithId(11) diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index c18f4296cf90cf42cc776627447823a29f611cd1..0f429f978b671b14211fd54cc3242b78cc55cd59 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -21,7 +21,9 @@ require_once 'AbstractControllerTestCase.php'; abstract class AbstractAbonneControllerPretsTestCase extends AbstractControllerTestCase { - protected $_old_zend_cache; + protected + $_old_zend_cache, + $_storm_default_to_volatile = true; protected function _loginHook($account) { $account->ROLE = "abonne_sigb"; @@ -58,7 +60,7 @@ abstract class AbstractAbonneControllerPretsTestCase extends AbstractControllerT -abstract class AbonneControllerPretsListTwoPretsTestCase extends AbstractAbonneControllerPretsTestCase { +abstract class AbonneControllerPretsListThreePretsTestCase extends AbstractAbonneControllerPretsTestCase { public function setUp() { parent::setUp(); $potter = new Class_WebService_SIGB_Emprunt('12', new Class_WebService_SIGB_Exemplaire(123)); @@ -99,6 +101,18 @@ abstract class AbonneControllerPretsListTwoPretsTestCase extends AbstractAbonneC $emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence'); $emprunteur->empruntsAddAll([$potter, $alice]); + $this->fixture('Class_Loan_Pnb', + ['id' => 5, + 'user_id' => $this->florence->getId(), + 'ongoing' => true, + 'expected_return_date' => '2022-05-02 18:14:14', + 'album' => $this->fixture('Class_Album', + ['id' => 4, + 'notice_id' => 5, + 'id_origine' => 'Dilicom-88817216', + 'titre' => 'Pinocchio'])->addAuthor('Collodi') + ]); + $this->florence ->setFicheSigb(['type_comm' => 2, //OPSYS 'fiche' => $emprunteur, @@ -110,15 +124,16 @@ abstract class AbonneControllerPretsListTwoPretsTestCase extends AbstractAbonneC } -class AbonneControllerPretsExportTwoPretsTest extends AbonneControllerPretsListTwoPretsTestCase { +class AbonneControllerPretsExportThreePretsTest extends AbonneControllerPretsListThreePretsTestCase { protected + $_storm_default_to_volatile = true, $_dl_file, $unimarc = '01201nam0 22002891 450 001001500000010003700015100004100052101000800093102000700101105001800108106000600126200009300132210002400225211001300249215006400262300002400326307002900350330027300379345001800652461005600670700001800726701003000744801003300774856008300807940000700890995001400897frOr0354235228 a978-2-35592-635-8bbr.d7,65 EUR a20140225d2014 | |0fre|0103||||ba afre aFR a 0||y| ar1 aAlice au royaume de TrÁefleeCheshire cat Waltzh5fQuinRosegdessin Mamenosuke Fujimaru aPariscKi-oond2014 1a20140227 a1 vol. (164 p.)cillustrations en noir et blancd18 x 13 cm aTraduit du japonais aSens de lecture japonais aPerdue dans la forÃet aux portes, Alice tombe nez Áa nez avec Ace. Devenue malgrÂe elle la confidente du chevalier, elle ne sait comment repousser ses avances. Lorsque le chat du Cheshire, qui a assistÂe Áa la scÁene, intervient, la rencontre tourne Áa l\'affrontement. b9782355926358 1tAlice au royaume de TrÁefle : Cheshire cat Waltzv5 1aQuinRose4070 1aFujimarubMamenosuke4440 aFRbElectrec20140225gAFNOR uhttp://www.electre.com//GetBlob.ashx?Ean=9782355926358,0-1913692&Size=Original aLR 1aAliceItem00604nam0 22001931 450 001001500000010001800015100004100033101000800074200010700082210003000189215001100219461002000230606002900250676000800279700004500287801005600332940000700388995001500395frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliothÁeque de l\'agglomÂeration de Saint-Omer apm 1aPotterItem'; public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/loan-export'); + $this->dispatch('/opac/abonne/loan-export', true); $this->_dl_file = tempnam('/tmp', 'UNIMARC'); file_put_contents($this->_dl_file, $this->_response->getBody()); } @@ -158,7 +173,7 @@ class AbonneControllerPretsExportTwoPretsTest extends AbonneControllerPretsListT -class AbonneControllerPretsListTwoPretsTest extends AbonneControllerPretsListTwoPretsTestCase { +class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListThreePretsTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/abonne/prets', true); @@ -245,6 +260,13 @@ class AbonneControllerPretsListTwoPretsTest extends AbonneControllerPretsListTwo } + /** @test */ + public function pinocchioLoanShouldHaveLinkToEndLoanBook() { + $this->assertXPathContentContains("//td//a[@href='/abonne/end-loan-book/id/5']", + 'Rendre le livre'); + } + + /** @test */ public function potterLoanShouldBePresent() { $this->assertXPathContentContains("//tbody/tr[2]//td", 'Potter', $this->_response->getBody()); @@ -286,10 +308,36 @@ class AbonneControllerPretsListTwoPretsTest extends AbonneControllerPretsListTwo public function colonneInformationShouldContainsP1(){ $this->assertXPathContentContains('//tbody//td','P1', $this->_response->getBody()); } + + + /** @test */ + public function pnbH2TitleShouldBePresent() { + $this->assertXpathContentContains('//h2', utf8_encode('Prêts numériques en cours')); + } } +class AbonneControllerEndLoanBookTest extends AbonneControllerPretsListThreePretsTestCase { + public function setUp() { + parent::setUp(); + $loan = Storm_Test_ObjectWrapper::on(Class_Loan_Pnb::find(5)); + $loan + ->whenCalled('endLoanDo') + ->answers(true); + + Class_Loan_Pnb::cacheInstance($loan); + $this->dispatch('/abonne/end-loan-book/id/5', true); + } + + + /** @test */ + public function endLoanShouldHaveBeenSentOnLoanInstance() { + $this->assertTrue(Class_Loan_Pnb::find(5)->methodHasBeenCalled('endLoanDo')); + } +} + + class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerPretsTestCase { public function setUp() { @@ -333,12 +381,12 @@ class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerP 'zone995' => '']); $this->florence + ->setPseudo('FloFlo') ->setFicheSigb(['type_comm' => Class_IntBib::COM_OPSYS, 'fiche' => (new Class_WebService_SIGB_Emprunteur('1234', 'Florence')) ->reservationsAddAll([$potter, $dobby]), 'message' => '', - 'erreur' => '', - 'nom_aff' => 'FloFlo']); + 'erreur' => '']); $this->dispatch('/opac/abonne/reservations'); } @@ -422,7 +470,7 @@ class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerP -abstract class AbonneControllerPretsRenewTwoPretsTestCase extends AbonneControllerPretsListTwoPretsTestCase { +abstract class AbonneControllerPretsRenewThreePretsTestCase extends AbonneControllerPretsListThreePretsTestCase { public function setUp() { parent::setUp(); Class_CommSigb::setInstance($this->getSigbMock()); @@ -464,7 +512,7 @@ abstract class AbonneControllerPretsRenewTwoPretsTestCase extends AbonneControll -class AbonneControllerPretsRenewErrorTwoPretsTest extends AbonneControllerPretsRenewTwoPretsTestCase { +class AbonneControllerPretsRenewErrorThreePretsTest extends AbonneControllerPretsRenewThreePretsTestCase { protected function getSigbMock() { return $this->mock() ->whenCalled('prolongerPret') @@ -486,7 +534,7 @@ class AbonneControllerPretsRenewErrorTwoPretsTest extends AbonneControllerPretsR -class AbonneControllerPretsRenewSuccessTwoPretsTest extends AbonneControllerPretsRenewTwoPretsTestCase { +class AbonneControllerPretsRenewSuccessThreePretsTest extends AbonneControllerPretsRenewThreePretsTestCase { protected function getSigbMock() { return $this->mock() ->whenCalled('prolongerPret') diff --git a/tests/application/modules/opac/controllers/AbonneVSmartTest.php b/tests/application/modules/opac/controllers/AbonneVSmartTest.php index 92724a7f6b0781802ba39d5c326202d1d7c3af21..149aa07b8d05d94f1bd05cf15b03243b32c87d22 100644 --- a/tests/application/modules/opac/controllers/AbonneVSmartTest.php +++ b/tests/application/modules/opac/controllers/AbonneVSmartTest.php @@ -22,16 +22,11 @@ require_once 'AbstractControllerTestCase.php'; abstract class AbonneVSmartTestCase extends AbstractControllerTestCase { - + protected + $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - Class_Users::beVolatile(); - Class_UserGroup::beVolatile(); - Class_UserGroupMembership::beVolatile(); - Class_Notice::beVolatile(); - Class_PanierNotice::beVolatile(); - Class_PanierNoticeCatalogue::beVolatile(); $this->manon = Class_Users::newInstanceWithId(34, ['pseudo' => 'Marcus', 'login' => 'mlaffont', 'password' => '123', @@ -44,13 +39,12 @@ abstract class AbonneVSmartTestCase extends AbstractControllerTestCase { $emprunteur ->expects($this->once()) - ->method('getNbPretsEnRetard') - ->will($this->returnValue(1)); + ->method('getEmprunts') + ->will($this->returnValue([Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire() + ->setDateRetour('25/12/2022'), - $emprunteur - ->expects($this->once()) - ->method('getNbEmprunts') - ->will($this->returnValue(2)); + Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire() + ->setDateRetour('25/12/2010')])); $emprunteur ->expects($this->once()) diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 7846f11e6d114557a9beae759e649cf374298e61..8c5a5095856e509fc345f90195973afbc4a98fd3 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -102,12 +102,12 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa ->reservationsAddAll(array(Class_WebService_SIGB_Reservation::newInstanceWithEmptyExemplaire())); ZendAfi_Auth::getInstance()->logUser( - Class_Users::newInstanceWithId(5, - ['login' => 'patrick', - 'idabon' => 456, - 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, - 'id_site' => 1, - 'fiche_sigb' => ['fiche' => $this->emprunteur_patrick]])); + Class_Users::newInstanceWithId(5, + ['login' => 'patrick', + 'idabon' => 456, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'fiche_sigb' => ['fiche' => $this->emprunteur_patrick]])); @@ -155,7 +155,7 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa class AuthControllerAbonneSIGBLoggedLogoutTest -extends PortailWithOneLoginModuleTestCase { + extends PortailWithOneLoginModuleTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/auth/logout'); @@ -171,7 +171,7 @@ extends PortailWithOneLoginModuleTestCase { class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutTest -extends PortailWithOneLoginModuleTestCase { + extends PortailWithOneLoginModuleTestCase { protected $_profile, $_parent_profile; public function setUp() { @@ -268,7 +268,7 @@ class AuthControllerNobodyLoggedActivateTest extends AuthControllerNobodyLoggedT class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest -extends AuthControllerNobodyLoggedTestCase { + extends AuthControllerNobodyLoggedTestCase { public function setUp() { parent::setUp(); @@ -398,9 +398,9 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedAjaxLoginTest extends Auth '//div//a[contains(@href, "auth/register")]'); $this->_xpath->assertXPathContentContains( - $this->_json->content, - '//div//a[contains(@href, "auth/register")]', - "S'enregistrer"); + $this->_json->content, + '//div//a[contains(@href, "auth/register")]', + "S'enregistrer"); } @@ -588,12 +588,12 @@ class AuthControllerUserIsLoggedTest extends PortailWithOneLoginModuleTestCase { public function setUp() { parent::setUp(); $marcus = $this->fixture('Class_Users', [ - 'id' => 1, - 'pseudo' => '', - 'login' => 'sysadm', - 'password' => 'sysadmPassword', - 'nom' => 'Miller', - 'prenom' => 'Marcus']); + 'id' => 1, + 'pseudo' => '', + 'login' => 'sysadm', + 'password' => 'sysadmPassword', + 'nom' => 'Miller', + 'prenom' => 'Marcus']); ZendAfi_Auth::getInstance()->logUser($marcus); $this->dispatch('/opac/auth/login',true); } @@ -609,12 +609,12 @@ class AuthControllerUserNameIsEscaped extends PortailWithOneLoginModuleTestCase public function setUp() { parent::setUp(); $marcus = $this->fixture('Class_Users', - ['id' => 1, - 'pseudo' => '', - 'login' => 'sysadm', - 'password' => 'sysadmPassword', - 'nom' => '<script>Miller', - 'prenom' => '<script>Marcus']); + ['id' => 1, + 'pseudo' => '', + 'login' => 'sysadm', + 'password' => 'sysadmPassword', + 'nom' => '<script>Miller', + 'prenom' => '<script>Marcus']); ZendAfi_Auth::getInstance()->logUser($marcus); $this->dispatch('/opac/auth/login',true); } @@ -636,12 +636,12 @@ class AuthControllerPseudoIsEscaped extends PortailWithOneLoginModuleTestCase { public function setUp() { parent::setUp(); $marcus = $this->fixture('Class_Users', - ['id' => 1, - 'pseudo' => '<script>pseudo', - 'login' => 'sysadm', - 'password' => 'sysadmPassword', - 'nom' => 'Miller', - 'prenom' => 'Marcus']); + ['id' => 1, + 'pseudo' => '<script>pseudo', + 'login' => 'sysadm', + 'password' => 'sysadmPassword', + 'nom' => 'Miller', + 'prenom' => 'Marcus']); ZendAfi_Auth::getInstance()->logUser($marcus); $this->dispatch('/opac/auth/login',true); } @@ -861,7 +861,7 @@ abstract class AuthControllerPostSimpleSuccessfulTestCase extends AuthController $this->group_musicme = $this->fixture('Class_UserGroup', ['id' => 20, 'libelle' => 'Multimedia']) - ->addRight(Class_UserGroup::RIGHT_ACCES_MUSICME); + ->addRight(Class_UserGroup::RIGHT_ACCES_MUSICME); $marcel = Class_Users::newInstanceWithId(2, ['nom' => 'Marcel','login' =>'foo']) ->beAbonneSIGB() @@ -871,10 +871,10 @@ abstract class AuthControllerPostSimpleSuccessfulTestCase extends AuthController ->whenCalled('authenticateLoginPassword') ->with('foo', 'bar') ->willDo( - function() use($marcel) { - $this->_auth->whenCalled('getIdentity')->answers($marcel); - return true; - }); + function() use($marcel) { + $this->_auth->whenCalled('getIdentity')->answers($marcel); + return true; + }); $this->_web_analytics_client = Storm_Test_ObjectWrapper::mock() @@ -1087,6 +1087,12 @@ class AuthControllerLoginActionRenderTest extends AuthControllerNobodyLoggedTest public function authLoginShouldContainForm() { $this->assertXPath('//form//fieldset[contains(@id, "fieldset-login_form")]'); } + + + /** @test */ + public function authLoginTableShouldContainCaption() { + $this->assertXPath('//form//table/caption/details/summary'); + } } @@ -1337,12 +1343,12 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController public function fields() { return [ - ['login',], - ['mail'], - ['mail2'], - ['mdp'], - ['mdp2'], - ]; + ['login',], + ['mail'], + ['mail2'], + ['mdp'], + ['mdp2'], + ]; } @@ -1447,14 +1453,14 @@ class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT 'id_module' => 4, 'type_module' => 'LOGIN', 'preferences' => [ - 'identifiant' => 'Numéro de carte', - 'mot_de_passe'=> 'Année de naissance', - 'identifiant_exemple' => 'jj-mm-aaaa', - 'mot_de_passe_exemple' => '1983', - 'titre_connecte' => 'Vous êtes connecté(e)', - 'lien_connexion' => 'please, log me', - 'lien_mot_de_passe_oublie' => 'me rappelle plus', - 'profil_redirect' => 0]]], + 'identifiant' => 'Numéro de carte', + 'mot_de_passe'=> 'Année de naissance', + 'identifiant_exemple' => 'jj-mm-aaaa', + 'mot_de_passe_exemple' => '1983', + 'titre_connecte' => 'Vous êtes connecté(e)', + 'lien_connexion' => 'please, log me', + 'lien_mot_de_passe_oublie' => 'me rappelle plus', + 'profil_redirect' => 0]]], 'options' => []]; Class_Profil::getCurrentProfil() @@ -1463,14 +1469,14 @@ class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT ZendAfi_Auth::getInstance()->logUser( - $this->fixture('Class_Users', - ['id' => 5, - 'login' => 'Pioup', - 'idabon' => 48, - 'password' => 'one ok password', - 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, - 'id_site' => 1, - 'fiche_sigb' => []])); + $this->fixture('Class_Users', + ['id' => 5, + 'login' => 'Pioup', + 'idabon' => 48, + 'password' => 'one ok password', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'fiche_sigb' => []])); $this->dispatch('/opac/'); } @@ -1505,38 +1511,38 @@ class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT - class AuthControllerAbonneSIGBNotValidLoggedTest extends PortailWithOneLoginModuleTestCase { - public function setUp() { - parent::setUp(); +class AuthControllerAbonneSIGBNotValidLoggedTest extends PortailWithOneLoginModuleTestCase { + public function setUp() { + parent::setUp(); - ZendAfi_Auth::getInstance()->logUser( - Class_Users::newInstanceWithId(5, - ['login' => 'tomato', - 'idabon' => 48, - 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, - 'id_site' => 1, - 'date_fin' => '2014-01-01', - 'fiche_sigb' => []])); + ZendAfi_Auth::getInstance()->logUser( + Class_Users::newInstanceWithId(5, + ['login' => 'tomato', + 'idabon' => 48, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'date_fin' => '2014-01-01', + 'fiche_sigb' => []])); - $this->dispatch('/opac/'); - } + $this->dispatch('/opac/'); + } - /** @test */ - public function shouldDisplayExpiredSubscription() { - $this->assertXPathContentContains('//div[@class="boite login"]//p[@class="expired"]', 'Abonnement expiré - Merci de contacter la médiathèque'); - } + /** @test */ + public function shouldDisplayExpiredSubscription() { + $this->assertXPathContentContains('//div[@class="boite login"]//p[@class="expired"]', 'Abonnement expiré - Merci de contacter la médiathèque'); } +} class AuthControllerNobodyLoggedAndRegisterNewsletterWithNoNewsletterTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { - parent::setUp(); + parent::setUp(); - $this->dispatch('/opac/auth/newsletter-register', true); - } + $this->dispatch('/opac/auth/newsletter-register', true); + } /** @test */ @@ -1550,10 +1556,10 @@ class AuthControllerNobodyLoggedAndRegisterNewsletterWithNoNewsletterTest extend class AuthControllerNobodyLoggedAndRegisterNewsletterWithWrongNewsletterTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { - parent::setUp(); - Class_Newsletter::beVolatile(); - $this->dispatch('/opac/auth/newsletter-register/id/1', true); - } + parent::setUp(); + Class_Newsletter::beVolatile(); + $this->dispatch('/opac/auth/newsletter-register/id/1', true); + } /** @test */ @@ -1568,15 +1574,15 @@ class AuthControllerNobodyLoggedAndRegisterNewsletterWithWrongNewsletterTest ext class AuthControllerNewsletterRegisterKickSpamBotsTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { - parent::setUp(); - $this->fixture('Class_Newsletter', - ['id' => 5, - 'titre' => 'Daily News']); + parent::setUp(); + $this->fixture('Class_Newsletter', + ['id' => 5, + 'titre' => 'Daily News']); - $this->postDispatch('/opac/auth/newsletter-register/id/5', [ - 'email' => 'imnotabot@factory.bot', - 'emailCheck' => 'imnotabot@factory.bot']); - } + $this->postDispatch('/opac/auth/newsletter-register/id/5', [ + 'email' => 'imnotabot@factory.bot', + 'emailCheck' => 'imnotabot@factory.bot']); + } /** @test */ @@ -1591,13 +1597,13 @@ class AuthControllerNewsletterRegisterKickSpamBotsTest extends AuthControllerNob class AuthControllerNobodyLoggedAndRegisterNewsletterTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { - parent::setUp(); - $this->fixture('Class_Newsletter', - ['id' => 5, - 'titre' => 'Daily News']); + parent::setUp(); + $this->fixture('Class_Newsletter', + ['id' => 5, + 'titre' => 'Daily News']); - $this->dispatch('/opac/auth/newsletter-register/id/5', true); - } + $this->dispatch('/opac/auth/newsletter-register/id/5', true); + } /** @test */ @@ -1651,7 +1657,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsTest extends AuthControllerNo $this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'iwanttobespamed@abo.com', 'emailCheck' => '']); - } + } protected function getSentMail() { @@ -1740,30 +1746,30 @@ class AuthControllerPostRegisterNewsletterDailyNewsTest extends AuthControllerNo class AuthControllerPostRegisterNewsletterDailyNewsWithNonUniqueMailTest extends AuthControllerNobodyLoggedTestCase { public function setUp() { - parent::setUp(); + parent::setUp(); - $this->fixture('Class_Users', - ['id' => 1, - 'login' => 'Tom', - 'password' => 'pwd', - 'mail' => 'imalreadyused@mail.com']); + $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'Tom', + 'password' => 'pwd', + 'mail' => 'imalreadyused@mail.com']); - Class_UsersNonValid::beVolatile(); + Class_UsersNonValid::beVolatile(); - $this->fixture('Class_Newsletter', - ['id' => 5, - 'titre' => 'Daily News']); + $this->fixture('Class_Newsletter', + ['id' => 5, + 'titre' => 'Daily News']); - $this->postDispatch('/opac/auth/newsletter-register/id/5', [ - 'email' => 'imalreadyused@mail.com', - 'emailCheck' => '']); - } + $this->postDispatch('/opac/auth/newsletter-register/id/5', [ + 'email' => 'imalreadyused@mail.com', + 'emailCheck' => '']); + } /** @test */ public function shouldReturnNonUniqueMailMessage() { $this->assertXPathContentContains('//span[@class="error"]', - "Un utilisateur a déjà renseigné cet email. Merci de vous identifier avec le compte qui utilise cet email."); + "Un utilisateur a déjà renseigné cet email. Merci de vous identifier avec le compte qui utilise cet email."); } @@ -1835,8 +1841,8 @@ class AuthControllerNewsletterActiveUserWithWrongParamsTest extends AuthControll /** @test */ public function wrongKeyShouldDisplayExpectedMessage() { $this->fixture('Class_Newsletter', - ['id' => 1, - 'titre' => 'News of the month']); + ['id' => 1, + 'titre' => 'News of the month']); $this->dispatch('opac/auth/newsletter-active-user/c/4897sd8fsdf/id/1', true); $this->assertXPathContentContains('//p', 'Inscription à la newsletter invalide.'); @@ -1854,22 +1860,22 @@ class AuthControllerNewsletterActiveUserTest extends AuthControllerNoBodyLoggedT Class_Users::beVolatile(); $this->fixture('Class_Newsletter',[ - 'id' => 1, - 'titre' => 'News of the month']); + 'id' => 1, + 'titre' => 'News of the month']); $this->fixture('Class_UsersNonValid', [ - 'id' => 1, - 'login' => 'future@i.am', - 'mail' => 'future@i.am', - 'password' => 'random', - 'cle' => '12345678']); + 'id' => 1, + 'login' => 'future@i.am', + 'mail' => 'future@i.am', + 'password' => 'random', + 'cle' => '12345678']); $this->fixture('Class_UsersNonValid', [ - 'id' => 2, - 'login' => 'future@i.am', - 'mail' => 'future@i.am', - 'password' => 'random', - 'cle' => '12345678']); + 'id' => 2, + 'login' => 'future@i.am', + 'mail' => 'future@i.am', + 'password' => 'random', + 'cle' => '12345678']); $this->dispatch('opac/auth/newsletter-active-user/c/12345678/id/1', true); } @@ -1997,16 +2003,16 @@ class AuthControllerNewsletterUnsubscribeTest extends AbstractControllerTestCase parent::setUp(); $tomato = $this->fixture('Class_Users', - ['id' => 156, - 'login' => 'tomato', - 'password' => 'pwd']); + ['id' => 156, + 'login' => 'tomato', + 'password' => 'pwd']); ZendAfi_Auth::getInstance() ->logUser($tomato); $daily_news = $this->fixture('Class_Newsletter', - ['id' => 1, - 'titre' => 'Daily News']); + ['id' => 1, + 'titre' => 'Daily News']); $subscription = $this->fixture('Class_NewsletterSubscription', ['id' => 1]); diff --git a/tests/application/modules/opac/controllers/BibControllerTest.php b/tests/application/modules/opac/controllers/BibControllerTest.php index cc9814c65bca68b5ec3a51095b11ec9b98927e7d..632c528ae7432e1cf4ecd397f0639941ee65a629 100644 --- a/tests/application/modules/opac/controllers/BibControllerTest.php +++ b/tests/application/modules/opac/controllers/BibControllerTest.php @@ -197,19 +197,30 @@ class BibControllerIndexWithShowNewsTest extends BibControllerWithZoneTestCase { } -class BibControllerMapViewTest extends BibControllerWithZoneTestCase { + +abstract class BibControllerMapViewTest extends BibControllerWithZoneTestCase { public function setUp() { parent::setUp(); $this->fixture('Class_Profil', ['id' => 3, 'libelle' => 'Annecy']); + } +} + + + +class BibControllerMapViewWithProfilTest extends BibControllerMapViewTest { + + public function setUp() { + parent::setUp(); $aff_zone = ['profilID' => '3', 'libelle' => 'Annecy', 'posX' => 2, 'posY' => 5, 'posPoint' => 'droite']; + $this->bib_annecy->setAffZone(ZendAfi_Filters_Serialize::serialize($aff_zone)); $this->dispatch('bib/mapzoneview/id/1'); @@ -236,7 +247,32 @@ class BibControllerMapViewTest extends BibControllerWithZoneTestCase { /** @test */ public function bibAnnecyShouldBeVisibleOnMap() { - $this->assertXPathContentContains("//span[contains(@onclick, '/id_profil/3')]", "Annecy"); + $this->assertXPathContentContains("//span[contains(@onclick, 'index/index/id_profil/3')]", "Annecy", $this->_response->getBody()); + } +} + + + +class BibControllerMapViewWithoutProfilTest extends BibControllerMapViewTest { + + public function setUp() { + parent::setUp(); + + $aff_zone = ['profilID' => '', + 'libelle' => 'Annecy', + 'posX' => 2, + 'posY' => 5, + 'posPoint' => 'droite']; + + $this->bib_annecy->setAffZone(ZendAfi_Filters_Serialize::serialize($aff_zone)); + + $this->dispatch('bib/mapzoneview/id/1'); + } + + + /** @test */ + public function bibAnnecyShouldBeVisibleOnMap() { + $this->assertXPathContentContains("//span[contains(@onclick, 'bibview/id/4')]", "Annecy", $this->_response->getBody()); } } diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php index 81cbc8965ccb25df4ed1e42b3960a995cf179a9f..28154cfae24824369ee4441e51a9a1b8a43c02a6 100644 --- a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php +++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php @@ -18,12 +18,13 @@ * 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/DilicomFixtures.php'; abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTestCase { protected $_http, - $_time_source; + $_time_source, + $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -49,14 +50,24 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe 'external_uri' => 'http://www.edenlivres.fr/p/23416', 'type_doc_id' => Class_TypeDoc::DILICOM, 'isbn' => '435465', + 'items' => [$this->fixture('Class_Album_Item', + ['id' => 1, + 'album_id' => 3, + 'loan_count' => 2, + 'quantity' => 4])], 'usage_constraints' => [$this->fixture('Class_Album_UsageConstraint', ['id' => 1, - 'id_album' => 3, - 'titre ' => 'Totem et Thora', + 'album_id' => 3, 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, - 'order_line_id' => 'x321'])]]); - - + Class_Album_UsageConstraint::MAX_NB_OF_USERS => 40, + Class_Album_Usageconstraint::QUANTITY => 50, + 'order_line_id' => 'x321']), + $this->fixture('Class_Album_UsageConstraint', + ['id' => 2, + 'album_id' => 3, + 'usage_type' => Class_Album_UsageConstraint::AVAILABILITY_CONSTRAINT, + Class_Album_UsageConstraint::DURATION => '100', + Class_Album_UsageConstraint::END_DATE => '2018-04-01 00:00:00'])]]); RessourcesNumeriquesFixtures::activateDilicom(); @@ -71,6 +82,7 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe $this->_time_source = new TimeSourceForTest('2014-05-02 14:14:14'); Class_WebService_BibNumerique_Dilicom_Hub::setTimeSource($this->_time_source); + Class_Album_UsageConstraint::setTimeSource($this->_time_source); } } @@ -156,4 +168,277 @@ class BibNumeriqueContollerDilicomConsultBookWithErrorsActionTest extends BibNum } -?> \ No newline at end of file + + +class BibNumeriqueControllerDilicomLoanBookActionTest extends BibNumeriqueContollerDilicomTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&loanId=1') + ->answers(DilicomFixtures::loanBookResponse()) + ->beStrict(); + + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + /** @test */ + public function responseShouldReturnDownloadUrl() { + $this->assertRedirectTo('https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do'); + } + + + /** @test */ + public function bokehLoanShouldHaveBeenSaved() { + $this->assertNotNull(Class_Loan_Pnb::findFirstBy(['record_origin_id' => 'Dilicom-88817216'])); + } + + + /** @test */ + public function loanUrlShouldHaveBeenSaved() { + $this->assertEquals('https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do', Class_Loan_Pnb::findFirstBy(['record_origin_id' => 'Dilicom-88817216'])->getLoanLink()); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookActionErrorsTest extends BibNumeriqueContollerDilicomTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&loanId=1') + ->answers(DilicomFixtures::loanBookErrorResponse()) + ->beStrict(); + + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + + /** @test */ + public function responseShouldRedirectToReferrer() { + $this->assertRedirectTo('/viewnotice/id/3', $this->getResponseLocation()); + } + + + /** @test */ + public function errorMessageShouldBeInNotifications() { + $this->assertFlashMessengerContains('Are you trying to download this book ?'); + } + + + /** @test */ + public function loanShouldHaveBeedDeleted() { + $this->assertNull(Class_Loan_Pnb::find(1)); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookWrongAlbumTest extends BibNumeriqueContollerDilicomTestCase { + /** @test */ + public function responseShouldRedirectToIndex() { + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3789'; + $this->dispatch('/bib-numerique/loan-book/id/3789', true); + $this->assertRedirectTo('/viewnotice/id/3789'); + } +} + + + +class BibNumeriqueControllerDilicomEndLoanBookTest extends BibNumeriqueContollerDilicomTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/endLoan?glnContractor=123456789&orderLineId=x321&loanId=1') + ->answers(DilicomFixtures::endLoanBookResponse()) + ->beStrict(); + + $this->fixture('Class_Loan_Pnb', + ['id' => 1, + 'record_origin_id' => 'Dilicom-88817216', + 'user_id' => '6', + 'ongoing' => true]); + + $this->dispatch('/bib-numerique/end-loan-book/id/1', true); + } + + + /** @test */ + public function responseShouldRedirectToReferrer() { + $this->assertRedirectTo('/viewnotice/id/3'); + } + + + /** @test */ + public function endLoanMessageShouldBeInNotifications() { + $this->assertFlashMessengerContains('Votre retour a bien été enregistré'); + } + + + /** @test */ + public function loanShouldNotBeInProgress() { + $this->assertFalse(Class_Loan_Pnb::find(1)->getOngoing()); + } +} + + + + +class BibNumeriqueControllerDilicomEndLoanBookErrorTest extends BibNumeriqueContollerDilicomTestCase { + /** @test */ + public function responseShouldRedirectToReferrer() { + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3789'; + $this->dispatch('/bib-numerique/end-loan-book/id/3789', true); + $this->assertRedirectTo('/viewnotice/id/3789'); + } + + + + /** @test */ + public function notifyMessageShouldContainsAlreadyEnded() { + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/endLoan?glnContractor=123456789&orderLineId=x321&loanId=1') + ->answers(DilicomFixtures::endLoanBookErrorResponse()) + ->beStrict(); + + $this->fixture('Class_Loan_Pnb', + ['id' => 1, + 'record_origin_id' => 'Dilicom-88817216', + 'user_id' => '6', + 'ongoing' => true]); + + $this->dispatch('/bib-numerique/end-loan-book/id/1', true); + $this->assertFlashMessengerContains('The loan with orderlineId \'524ade40bbd31c6240a30dff\' and loanId \'loanId\' is already ended'); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookActionTwiceWithSameUserTest extends BibNumeriqueContollerDilicomTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $this->_http + ->whenCalled('open_url') + ->never(); + + $this->fixture('Class_Loan_Pnb', + ['id' => 5, + 'user_id' => '6', + 'record_origin_id' => 'Dilicom-88817216', + 'ongoing' => true, + 'expected_return_date' => '2014-05-02 18:14:14', + 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do']); + + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + /** @test */ + public function responseShouldReturnDownloadUrl() { + $this->assertRedirectTo('https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do'); + } +} + + + +abstract class BibNumeriqueContollerDilicomSecondUserTestCase extends BibNumeriqueContollerDilicomTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3'; + + $second_user = $this->fixture('Class_Users', + ['id' => 78, + 'nom'=>'Dily', + 'login'=>'Chaton', + 'password'=>'123456', + 'id_site' => 1, + 'idabon' => '654321', + 'user_groups' => [Class_UserGroup::find(20)]]); + + $second_user->beAbonneSIGB()->assertSave(); + ZendAfi_Auth::getInstance()->logUser($second_user); + + $this->_http + ->whenCalled('open_url') + ->never(); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookActionWithASecondUserAndLoanCountExcededTest extends BibNumeriqueContollerDilicomSecondUserTestCase { + public function setUp() { + parent::setUp(); + Class_Album_Item::find(1)->setLoanCount(40)->save(); + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + /** @test */ + public function responseShouldRedirectToReferer() { + $this->assertRedirectTo('/viewnotice/id/3'); + } + + + /** @test */ + public function notificationShouldReturnNoLoansAvailable() { + $this->assertFlashMessengerContains('Emprunt impossible. Le nombre d\'emprunts simultanés est atteint.'); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookActionWithASecondUserAndQuantityExcededTest extends BibNumeriqueContollerDilicomSecondUserTestCase { + public function setUp() { + parent::setUp(); + Class_Album_Item::find(1)->setQuantity(50)->save(); + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + /** @test */ + public function responseShouldRedirectToReferer() { + $this->assertRedirectTo('/viewnotice/id/3'); + } + + + /** @test */ + public function notificationShouldContainsNoLoansAvailable() { + $this->assertFlashMessengerContains('Emprunt impossible. Le nombre d\'emprunts disponible est épuisé.', $this->_getFlashMessengerMessages()[0]); + } +} + + + +class BibNumeriqueControllerDilicomLoanBookActionWithASecondUserAndOfferValidityExcededTest extends BibNumeriqueContollerDilicomSecondUserTestCase { + public function setUp() { + parent::setUp(); + + $this->_time_source = new TimeSourceForTest('2018-05-02 14:14:14'); + Class_WebService_BibNumerique_Dilicom_Hub::setTimeSource($this->_time_source); + Class_Album_UsageConstraint::setTimeSource($this->_time_source); + + $this->dispatch('/bib-numerique/loan-book/id/3', true); + } + + + /** @test */ + public function notificationShouldContainsErrorMessage() { + $this->assertFlashMessengerContains('Emprunt impossible. L\'emprunt du document n\'est plus disponible.', $this->_getFlashMessengerMessages()[0]); + } +} diff --git a/tests/application/modules/opac/controllers/BlogControllerTest.php b/tests/application/modules/opac/controllers/BlogControllerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a025be963cdc54f5a5fd144cee3b940d9f8286c4 --- /dev/null +++ b/tests/application/modules/opac/controllers/BlogControllerTest.php @@ -0,0 +1,185 @@ +<?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 BlogControllerHierarchicalTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('AVIS_MIN_SAISIE', 0); + Class_AdminVar::set('AVIS_MAX_SAISIE', 1000); + + $this->theme = $this->fixture('Class_Catalogue', + ['id' => 10, 'libelle' => 'THEME']); + + $this->art = $this->fixture('Class_Catalogue', + ['id' => 12, 'libelle' => 'Art', + 'tags' => 'jeuxvideo', + 'domaine_parent' => $this->theme]); + + $this->music = $this->fixture('Class_Catalogue', + ['id' => 14, 'libelle' => 'Musique', + 'domaine_parent' => $this->art]); + + $this->bd = $this->fixture('Class_Catalogue', + ['id' => 15, 'libelle' => 'BD', + 'domaine_parent' => $this->art]); + + $this->ksp = $this->fixture('Class_Notice', + ['id' => 233134, + 'titre_principal' => 'Kerbal Space Program', + 'clef_oeuvre' => 'KERBALSPACEPROG-SQUAD-', + 'clef_alpha' => 'KERBALSPACEPROG-SQUAD-']); + + $this + ->onLoaderOfModel('Class_Catalogue') + + ->whenCalled('getNoticesByPreferences') + ->with(['id_panier' => 0, + 'id_catalogue' => 12, + 'abon_ou_bib' => 'all', + 'nb_notices' => null, + 'aleatoire' => 0, + 'avec_avis' => 1]) + ->answers([$this->ksp]); + + $this->fixture('Class_AvisNotice', + ['id' => 1, + 'note' => 5, + 'entete' => 'Incroyable', + 'avis' => 'What a wonderful game', + 'statut' => 1, + 'date_avis' => '2015-05-18 00:00:00', + 'id_user' => 3, + 'clef_oeuvre' => $this->ksp->getClefOeuvre()]); + + $this->fixture('Class_Users', + ['id' => 3, + 'login' => 'Harlock', + 'password' => 'arcadia']); + + $this->dispatch('/blog/hierarchical/id/12/start_id/12/truncate_at/30', true); + } + + + /** @test */ + public function shouldNotDisplaySearch() { + $this->assertNotXPath('//input[@name="title_search"]'); + } + + + /** @test */ + public function shouldNotDisplayCount() { + $this->assertNotXPathContentContains('//a', '(0)'); + } + + + /** @test */ + public function rootDomainLinkShouldNotBePresent() { + $this->assertNotDomainLink($this->theme, 12); + } + + + /** @test */ + public function startDomainLinkShouldBePresent() { + $this->assertDomainLink($this->art, 12); + } + + + /** @test */ + public function musicDomainShouldBePresent() { + $this->assertDomainLink($this->music, 12); + } + + + /** @test */ + public function bdDomainShouldBePresent() { + $this->assertDomainLink($this->bd, 12); + } + + + /** @test */ + public function kspShouldBePresent() { + $this->assertXPathContentContains('//h2', 'Kerbal Space Program'); + } + + + /** @test */ + public function kspRecordLinkShouldBePresent() { + $this->assertXPathContentContains('//a[contains(@href, "recherche/viewnotice/id/233134/clef/KERBALSPACEPROG-SQUAD-")]', + 'Voir la notice', + $this->_response->getBody()); + } + + + /** @test */ + public function kspRatingShouldBeFive() { + $this->assertXPath('//img[contains(@src, "stars-5.gif")]'); + } + + + /** @test */ + public function kspReviewTitleShouldBePresent() { + $this->assertXPathContentContains('//a[contains(@href, "blog/viewavis/id/1")]', + 'Incroyable'); + } + + + /** @test */ + public function kspAuthorShouldBePresent() { + $this->assertXPathContentContains('//a[contains(@href, "blog/viewauteur/id/3")]', + 'Harlock'); + } + + + /** @test */ + public function kspDateShouldBePresent() { + $this->assertXPathContentContains('//span', '18 mai 2015'); + } + + + /** @test */ + public function kspReviewContentShouldBePresent() { + $this->assertXPathContentContains('//p', 'What a wonderful game'); + } + + + protected function assertDomainLink($domain, $start) { + call_user_func_array([$this, 'assertXPathContentContains'], + $this->_linkDomainAssertParams($domain, $start)); + } + + + protected function assertNotDomainLink($domain, $start) { + call_user_func_array([$this, 'assertNotXPathContentContains'], + $this->_linkDomainAssertParams($domain, $start)); + } + + + protected function _linkDomainAssertParams($domain, $start) { + return [sprintf('//a[contains(@href, "blog/hierarchical/start_id/%s/truncate_at/30/id/%s")]', + $start, $domain->getId()), + $domain->getLibelle(), + $this->_response->getBody()]; + } +} diff --git a/tests/application/modules/opac/controllers/CasServerControllerTest.php b/tests/application/modules/opac/controllers/CasServerControllerTest.php index c67cef6acd870bf98c52ff74ae6bc2bed38d6cae..c3a23d3478faf66683b242a0b305d5307aac60ad 100644 --- a/tests/application/modules/opac/controllers/CasServerControllerTest.php +++ b/tests/application/modules/opac/controllers/CasServerControllerTest.php @@ -89,7 +89,22 @@ class CasServerControllerValidateActionTest extends AbstractControllerTestCase { $this->dispatch( '/opac/cas-server-v10/validate?ticket=ST-'.md5(Zend_Session::getId().'300').'&service=http://test.com', true); - $this->assertEquals('yes'.chr(10).'georges|87364'.chr(10), $this->_response->getBody()); + $this->assertEquals('yes'.chr(10).'georges|87364||'.chr(10), $this->_response->getBody()); + } + + /** + * @test + */ + public function validateOnCasOneZeroWithValidTicketShouldAnswerYesLFUsernameLoginMailBirthdate() { + Class_Users::find(300) + ->setMail('georges@souris.fr') + ->setNaissance('1978-02-17'); + $this->dispatch( + '/opac/cas-server-v10/validate?ticket=ST-'.md5(Zend_Session::getId().'300').'&service=http://test.com', + true); + $this->assertEquals('yes'.chr(10) + .'georges|87364|georges@souris.fr|1978/02/17'.chr(10), + $this->_response->getBody()); } diff --git a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php index b49997b1ee78e045b625aa31be8421c5e6b6f65e..a3d3d9700c46aab38bb34688be87556c4187acda 100644 --- a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php @@ -18,6 +18,8 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTestCase { protected $_nanook2; @@ -348,33 +350,35 @@ class CmsControllerCalendarActionWithDayTest extends AbstractControllerTestCase } } + + class CmsControllerCalendarActionHeaderTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); $this->cfg_accueil = [ - 'modules' => [ - '1' => [ - 'division' => '1', - 'type_module' => 'CALENDAR', - 'preferences' => [ - 'titre' => 'Rendez-vous', - 'rss_avis' => false, - 'id_categorie' => '12-2', - 'display_cat_select' => true, - 'enabled_filters' => 'date;place;custom_field_2;zork', - 'display_event_info' => 'none' - ] - ] - ], - 'options' => [] + 'modules' => [ + '1' => [ + 'division' => '1', + 'type_module' => 'CALENDAR', + 'preferences' => [ + 'titre' => 'Rendez-vous', + 'rss_avis' => false, + 'id_categorie' => '12-2', + 'display_cat_select' => true, + 'enabled_filters' => 'date;place;custom_field_2;zork', + 'display_event_info' => 'none' + ] + ] + ], + 'options' => [] ]; $this->fixture('Class_Profil', - ['id' => 3, - 'browser' => 'opac', - 'libelle' => 'Rendez-vous', - 'cfg_accueil' => $this->cfg_accueil]); + ['id' => 3, + 'browser' => 'opac', + 'libelle' => 'Rendez-vous', + 'cfg_accueil' => $this->cfg_accueil]); $this->dispatch('/index/index/id_profil/3'); } @@ -387,4 +391,65 @@ class CmsControllerCalendarActionHeaderTest extends AbstractControllerTestCase { } } -?> \ No newline at end of file + + + +class CmsControllerCalendarActionWithOutDateTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $time_source = new TimeSourceForTest('2014-09-02 14:14:14'); + ZendAfi_View_Helper_CalendarContent::setTimeSource($time_source); + ZendAfi_View_Helper_Calendar_Table::setTimeSource($time_source); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true, + 'event_start_after' => '2014-09', + 'event_end_after' => '', + 'limit' => 3]) + ->answers([]) + + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '2014-09', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true, + 'event_end_after' => '2014-09-02']) + ->answers([$this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'Kitchen', + 'contenu' => 'Cook'])]) + + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => '', + 'events_only' => true, + 'event_date' => '2014-09', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true]) + ->answers([]) + ->beStrict(); + + $this->dispatch('/cms/calendar/render/ajax', true); + } + + + /** @test */ + public function gatArticleByPreferencesShouldBeCallWithEventDAteAfter() { + $this->assertXPathContentContains('//div', 'Kitchen', $this->_response->getBody()); + } +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index cb6cad7bf4105712ff2eb2ce7babf4832658dde8..39dfdebdd0819ffafca85ecd116370d92274eec9 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1603,6 +1603,7 @@ class NoticeAjaxControllerBiographieTest extends NoticeAjaxControllerBiographieT .'?auteur='.urlencode('J.K Rowling') .'&clef_oeuvre=HARRY_POTTER' .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' .'&action=8') ->answers(json_encode(['statut_recherche' => '0', diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index df595d8ec415833790219697f0480fdeee4f9b3d..3fdd5ff748e075361df04dc260e2f811c33b34df 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -23,12 +23,15 @@ require_once 'AbstractControllerTestCase.php'; abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractControllerTestCase { - protected $admin_var; + protected + $admin_var; public function setUp() { parent::setUp(); + Class_Loan_Pnb::beVolatile(); + $this->fixture('Class_AdminVar',['id'=>'MENU_BOITE', 'valeur' => 1]); Class_Systeme_ModulesMenu::reset(); $this->admin_var=$this->fixture('Class_AdminVar',['id' => 'FORMATIONS', @@ -837,8 +840,6 @@ class ProfilOptionsControllerProfilAdulteAsAdminPostConfigKiosqueStyleReloadTest abstract class ProfilOptionsControllerProfilJeunesseWithPagesJeuxMusiqueTestCase extends ProfilOptionsControllerWithProfilAdulteTestCase { - - protected function _loginHook($account) { $account->ROLE = ""; $account->ROLE_LEVEL = 0; @@ -1033,7 +1034,6 @@ class ProfilOptionsControllerProfilJeunesseAndJeuxTest extends ProfilOptionsCont /** @test **/ public function titleBoitePanierShouldLinkToPanierIndex() { - ZendAfi_Auth::getInstance()->logUser($this->admin); $this->dispatch('/opac'); $this->assertXPath('//div[contains(@class,"panier")]//h1/a[contains(@href,"/panier")]',$this->_response->getBody()); @@ -1080,14 +1080,25 @@ class ProfilOptionsControllerPageJeuxViewModuleCritiquesTest extends ProfilOptio public function setUp() { parent::setUp(); $this->page_jeux->setBarreNavOn(true); - $this->dispatch('/opac/blog/viewcritiques?id_module=4&id_profil=12'); + $this->dispatch('/opac/blog/viewcritiques?id_module=4&id_profil=12&titre=my-kiosque'); } /** @test */ public function iframeKiosqueUrlShouldHaveIdModuleSeven() { - $this->assertXPath('//iframe[contains(@src, "/id_module/7/id_profil/12/vue/cube")]', - $this->_response->getBody()); + $this->assertXPath('//iframe[contains(@src, "/id_module/7/id_profil/12/vue/cube")][@title="iframe"]'); + } + + + /** @test */ + public function embedcodeMessageToCopyShouldBePresent() { + $this->assertXPathContentContains('//p', 'Copier le code suivant sur le site'); + } + + + /** @test */ + public function embedCodeIframeShouldBePresent() { + $this->assertXPathContentContains('//span', 'iframe'); } @@ -1101,7 +1112,7 @@ class ProfilOptionsControllerPageJeuxViewModuleCritiquesTest extends ProfilOptio */ public function breadcrumbShouldNotContainsSpanProfilJeunesse() { $this->assertNotXPathContentContains('//div[@class="barre_nav"]//span', - 'Jeunesse',$this->_response->getBody()); + 'Jeunesse',$this->_response->getBody()); } @@ -1184,7 +1195,7 @@ class ProfilOptionsControllerProfilBreadcrumbHomePageTest extends ProfilOptionsC */ public function breadcrumbShouldNotContainsSpanProfilHomePage() { $this->assertNotXPathContentContains('//div[@class="barre_nav"]//span', - 'HomePage',$this->_response->getBody()); + 'HomePage',$this->_response->getBody()); } } @@ -1649,6 +1660,43 @@ class ProfilOptionsControllerProfilBoiteCalendarWithCalendarDisplayedAndModeSimp } + /** + * @group rgaa + * @test + */ + public function calendarMainShouldContainsSummary() { + $this->assertXPathContentContains('//table[@class="calendar_main"]/caption/details/summary', 'Calendrier'); + } + + + /** + * @group rgaa + * @test + */ + public function thShouldContainsScopeCol() { + $this->assertXPath('//table[@class="calendar_main"]//th[@scope="col"]'); + } + + + /** + * @group rgaa + * @test + */ + public function calendarTableShouldContainsSummary() { + $this->assertXPathContentContains('//table[@class="calendar_table"]/caption/details/summary', 'Calendrier'); + } + + + /** + * @group rgaa + * @test + */ + public function calendarTableShouldContainsCaption() { + $this->assertXPath('//table[@class="calendar_table"]//caption'); + } + + + /** @test **/ public function boiteCalendarShouldDisplayProchainsEvenements() { $this->assertXPathContentContains('//b', 'Prochains évènements'); @@ -1725,7 +1773,9 @@ class ProfilOptionsControllerProfilBoiteCalendarWithCalendarDisplayedWithModeWal } - /** @test */ + /** + * @test + * */ public function pageShouldBeHTML5Valid() { $this->assertHTML5(); } @@ -2364,4 +2414,98 @@ class ProfilOptionsControllerSelectedActionInMenuVerticalWidgetInHomeTest extend $this->assertXPathContentContains('//ul/li//ul/li[@class="menuGauche"]', 'Bokeh FAQ'); } } -?> \ No newline at end of file + + + +abstract class ProfilOptionControllerHeritedModulesTestCase extends AbstractControllerTestCase { + protected $_profil_portal, $_profil_gnu; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_AdminVar',['id'=>'MENU_BOITE', 'valeur' => 0]); + + $this->_profil_portal = $this->fixture('Class_Profil', + ['id' => 1, + 'browser' => 'opac', + 'libelle' => 'Bokeh Portal']) + ->setCfgAccueil(['modules' => ['1' => ['division' => '4', + 'type_module' => 'RECH_SIMPLE', + 'preferences' => []], + '4' => ['division' => '4', + 'type_module' => 'NEWS']]]); + + $this->_profil_gnu = $this->fixture('Class_profil', + ['id' => 2, + 'parent_profil' => $this->_profil_portal, + 'browser' => 'opac', + 'libelle' => 'A GNU Portal']) + ->setCfgAccueil(['modules' => ['4' => ['division' => '1', + 'type_module' => 'NEWS'], + '10' => ['division' => '1', + 'type_module' => 'CALENDAR']]]); + } +} + + + +class ProfilOptionControllerWithHeritedBannerTest extends ProfilOptionControllerHeritedModulesTestCase { + + public function setUp() { + parent::setUp(); + $this->_profil_gnu->beCurrentProfil()->save(); + $this->dispatch('/opac', true); + } + + + /** @test */ + public function htmlShouldContainsOnlyOneIdBoite4() { + $this->assertXPathCount('//div[@id="boite_4"]', 1); + } + + + /** @test */ + public function htmlShouldContainsIdBoite11() { + $this->assertXPathCount('//div[@id="boite_11"]', 1); + } + + + /** @test */ + public function profilShouldIncrementCfgIdsAndDeleteOldIdAndKeepPositions() { + $this->assertEquals([11,10], array_keys(Class_Profil::find(2)->getCfgAccueilAsArray()['modules'])); + } +} + + + +class ProfilOptionControllerWithHeritedPagesTest extends ProfilOptionControllerHeritedModulesTestCase { + + public function setUp() { + parent::setUp(); + + $this->_profil_portal + ->setSubProfils([$this->_profil_gnu]) + ->beCurrentProfil() + ->save(); + + $this->dispatch('/opac', true); + } + + + /** @test */ + public function htmlShouldContainsIdBoite1() { + $this->assertXPathCount('//div[@id="boite_1"]', 1); + } + + + /** @test */ + public function htmlShouldContainsIdBoite4() { + $this->assertXPathCount('//div[@id="boite_4"]', 1); + } + + + /** @test */ + public function profilShouldIncrementCfgIdsAndDeleteOldIdAndKeepPosition() { + $this->assertEquals([11,10], array_keys(Class_Profil::find(2)->getCfgAccueilAsArray()['modules'])); + } +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php b/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1ce99fb1911f2ca971b9a0c3d80c24a687fdf81e --- /dev/null +++ b/tests/application/modules/opac/controllers/RechercheControllerJsonTest.php @@ -0,0 +1,345 @@ +<?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 RechercheControllerJsonTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + protected $_json; + + public function setUp() { + parent::setUp(); + + $this->_prepareLoader($this->onLoaderOfModel('Class_Notice')); + $mock_sql = $this->mock(); + $this->_prepareSql($mock_sql); + Zend_Registry::set('sql', $mock_sql); + + $this->dispatch($this->_searchUrl(), true); + $this->_json = json_decode($this->_response->getBody()); + } + + + protected function _prepareLoader($loader) {} + + protected function _prepareSql($sql) {} + + + protected function _searchUrl() { + return 'recherche/simple/expressionRecherche//tri/*/format/json'; + } + + + protected function _unimarcFrom($file_name) { + return file_get_contents(dirname(__FILE__) . '/' . $file_name); + } +} + + + +class RechercheControllerJsonEmptyResultTest extends RechercheControllerJsonTestCase { + protected function _prepareLoader($loader) { + $loader->whenCalled('findAllByRequeteRecherche') + ->with('Select id_notice from notices', 10, 1) + ->answers([]) + ->beStrict(); + } + + + protected function _prepareSql($sql) { + $sql->whenCalled('fetchOne') + ->with('Select count(*) from notices') + ->answers(0) + + ->whenCalled('execute') + ->answers(true) + ; + } + + + /** @test */ + public function urlShouldBeCurrentAbsoluteUrl() { + $this->assertEquals(Class_Url::absolute(), $this->_json->url); + } + + + /** @test */ + public function totalShouldBeZero() { + $this->assertEquals(0, $this->_json->total); + } + + + /** @test */ + public function pageSizeShouldBeTen() { + $this->assertEquals(10, $this->_json->page_size); + } + + + /** @test */ + public function pageShouldBeFirstOne() { + $this->assertEquals(1, $this->_json->page); + } + + + /** @test */ + public function recordsShouldBeEmpty() { + $this->assertEmpty($this->_json->records); + } +} + + + +class RechercheControllerJsonWithResultTest extends RechercheControllerJsonTestCase { + protected $_first, $_second; + + protected function _prepareLoader($loader) { + $this->fixture('Class_CodifGenre', + ['id' => 3, 'libelle' => 'Science fiction']); + + $potter = $this->fixture('Class_Notice', + ['id' => 234, + 'clef_alpha' => 'HARRYPOTTERALECOLEDESSORCIERS--ROWLINGJ-1-GALLIMARDJEUNESSE-2011-1', + 'type_doc' => 1, + 'unimarc' => $this->_unimarcFrom('harry_potter_ecole_sorciers.txt'), + 'annee' => '1998', + 'facettes' => 'G3', + 'url_vignette' => 'http://ecx.images-amazon.com/images/I/51KVZWGHASL._SL160_.jpg', + 'url_image' => 'http://ecx.images-amazon.com/images/I/51KVZWGHASL.jpg']); + + + $rdv = $this->fixture('Class_Notice', + ['id' => 10141532, + 'clef_alpha' => 'RENDEZVOUSAKIRUNA--ANNANOVIONDARROUSSINJEANPIERRESOULISANASTASIOSLJUNGMARKCLAESBODNIAKIMHENRY---2012-104', + 'type_doc' => 104, + 'unimarc' => $this->_unimarcFrom('rdv_a_kiruna.txt'), + 'annee' => '2012', + 'facettes' => 'T104 A62646 A19260 A77257 A77258 A77259 A44958 A77260 A77261 A77262 A77263 A77264 A56926 A77265 A77266 A77267 A77268 M4566 M12096 Lfre Z39 Z20 Z21 Z22 Z7 Z34 Z64 Z154 Z59', + 'url_vignette' => BASE_URL .'/userfiles/album/154191/thumb_154191_e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png', + 'url_image' => 'http://media.universcine.com/e7/bc/e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png']); + + + $loader->whenCalled('findAllByRequeteRecherche') + ->with('Select id_notice from notices', 10, 1) + ->answers([$potter, $rdv]) + ->beStrict(); + } + + + protected function _prepareSql($sql) { + $sql->whenCalled('fetchOne') + ->with('Select count(*) from notices') + ->answers(2) + + ->whenCalled('execute') + ->answers(true) + ; + } + + + public function setUp() { + parent::setUp(); + $this->_first = $this->_json->records[0]; + $this->_second= $this->_json->records[1]; + } + + + /** @test */ + public function totalShouldBeTwo() { + $this->assertEquals(2, $this->_json->total); + } + + + /** @test */ + public function recordsShouldContainsTwoResults() { + $this->assertEquals(2, count($this->_json->records)); + } + + + /** @test */ + public function identifierShouldBeAsExpected() { + $this->assertEquals('HARRYPOTTERALECOLEDESSORCIERS--ROWLINGJ-1-GALLIMARDJEUNESSE-2011-1', + $this->_first->identifier); + } + + + /** @test */ + public function permalinkShouldBeAsExpected() { + $this->assertEquals(Class_Url::absolute(['controller' => 'recherche', + 'action' => 'viewnotice', + 'clef' => 'HARRYPOTTERALECOLEDESSORCIERS--ROWLINGJ-1-GALLIMARDJEUNESSE-2011-1', + 'id' => 234], null, true), + $this->_first->permalink); + } + + + /** @test */ + public function typeCodeShouldBeOne() { + $this->assertEquals(1, $this->_first->type->code); + } + + + /** @test */ + public function typeLabelShouldBeLivres() { + $this->assertEquals('Livres', $this->_first->type->label); + } + + + /** @test */ + public function firstThumbnailShouldBePresent() { + $this->assertEquals('http://ecx.images-amazon.com/images/I/51KVZWGHASL._SL160_.jpg', + $this->_first->thumbnail); + } + + + /** @test */ + public function secondThumbnailShouldBePresentAndAbsolute() { + $this->assertEquals(ROOT_URL . BASE_URL + . '/userfiles/album/154191/thumb_154191_e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png', + $this->_second->thumbnail); + } + + + /** @test */ + public function firstTitleShouldBeHarryPotter() { + $this->assertEquals('Harry Potter', $this->_first->titles[0]); + } + + + /** @test */ + public function secondTitleShouldBeALEcoleDesSorciers() { + $this->assertEquals('A l\'école des sorciers', $this->_first->titles[1]); + } + + + /** @test */ + public function serialTitleShouldBeHarryPotter() { + $this->assertEquals('Harry Potter', $this->_first->serial); + } + + + /** @test */ + public function shouldHave2Creators() { + $this->assertEquals(2, count($this->_first->creators)); + } + + + /** @test */ + public function firstCreatorShouldBeJKRowling() { + $this->assertEquals('Rowling|Joanne Kathleen', $this->_first->creators[0]); + } + + + /** @test */ + public function secondCreatorShouldBeJFMenard() { + $this->assertEquals('Ménard|Jean-François', $this->_first->creators[1]); + } + + + /** @test */ + public function firstPublishersShouldBeGallimardJeunesse() { + $this->assertEquals('Gallimard Jeunesse (Paris)', $this->_first->publishers[0]); + } + + + /** @test */ + public function dateShouldBe1998() { + $this->assertEquals('1998', $this->_first->date); + } + + + /** @test */ + public function volumeShouldBeOne() { + $this->assertEquals('1', $this->_first->volume); + } + + + /** @test */ + public function languageShouldNotBePresent() { + $this->assertFalse(property_exists($this->_first, 'language')); + } + + + /** @test */ + public function descriptionShouldNotBePresent() { + $this->assertFalse(property_exists($this->_first, 'description')); + } + + + /** @test */ + public function firstCollectionShouldBeFolioJunior() { + $this->assertEquals('Folio junior', $this->_first->collections[0]); + } + + + /** @test */ + public function shouldContainFirstClassification() { + $this->assertNotNull($classif = $this->classifAt(0)); + return $classif; + } + + + /** + * @test + * @depends shouldContainFirstClassification + */ + public function firstClassificationTypeShouldBeKind($classif) { + $this->assertEquals(Class_Notice_JsonVisitor::KIND_CODE, $classif->type); + } + + + /** + * @test + * @depends shouldContainFirstClassification + */ + public function firstClassificationLabelShouldBeGenre($classif) { + $this->assertEquals('Genre', $classif->label); + } + + + /** + * @test + * @depends shouldContainFirstClassification + */ + public function firstClassificationShouldContainsEntries($classif) { + $this->assertNotEmpty($classif->entries); + } + + + /** + * @test + * @depends shouldContainFirstClassification + */ + public function firstClassificationEntryCodeShouldBeG3($classif) { + $this->assertEquals('G3', $classif->entries[0]->code); + } + + + /** + * @test + * @depends shouldContainFirstClassification + */ + public function firstClassificationEntryLabelShouldBeScienceFiction($classif) { + $this->assertEquals('Science fiction', $classif->entries[0]->label); + } + + + protected function classifAt($position) { + return $this->_first->classifications[$position]; + } +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationPergameTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationPergameTest.php new file mode 100644 index 0000000000000000000000000000000000000000..00cffccd96316d936a639305fcad5c387987426c --- /dev/null +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationPergameTest.php @@ -0,0 +1,106 @@ +<?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 RechercheControllerReservationPergameTestCase extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $bib_toulon = $this->fixture('Class_Bib', + ['id' => 1]); + + $int_bib_toulon = $this->fixture('Class_IntBib', ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_PERGAME, + 'comm_params' => ['url_serveur' => 'bib-toulon.sud'], + 'id_bib' => 1]); + + $bib_can = $this->fixture('Class_Bib', + ['id' => 2]); + + $int_bib_canne = $this->fixture('Class_IntBib', ['id' => 2, + 'comm_sigb' => Class_IntBib::COM_PERGAME, + 'comm_params' => ['url_serveur' => 'bib-canne.sud'], + 'id_bib' => 2]); + + $jacques = $this->fixture('Class_Users', ['id' => 1, + 'login' => 'jacques', + 'password' => 'secret', + 'idabon' => '1414', + 'ordreabon' => '1', + 'id_site' => 1]); + + + ZendAfi_Auth::getInstance()->logUser($jacques); + + $this->fixture('Class_Notice', ['id' => 31084, + 'titres' => 'TITEUF TITEF FILLES FIL C00 EST NUL']); + + $this->fixture('Class_Exemplaire', ['id' => 1142445, + 'id_notice' => 31084, + 'code_barres' => '0229923321', + 'id_origine' => '00021243', + 'id_int_bib' => 2, + 'id_bib' => 2, + 'code_annexe' => 2]); + } +} + + + +class RechercheControllerReservationPergameWithPickupToItemLibrary extends RechercheControllerReservationPergameTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', ['id' => 'site_retrait_resa', + 'valeur' => 0]); + + $this->dispatch('recherche/reser$vationajax/id_bib/2/id_origine/1142445/code_annexe/2',true); + } + + + /** @test */ + public function holdShouldHaveBeenCreatedWithCanneLibrary() { + $this->assertEquals(2, Class_Reservation::findFirstBy(['id_notice_origine' => '00021243', + 'idabon' => 1414])->getIdSite()); + } +} + + + +class RechercheControllerReservationPergameWithPickupToPatronLibrary extends RechercheControllerReservationPergameTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', ['id' => 'site_retrait_resa', + 'valeur' => 2]); + + $this->dispatch('recherche/reservationajax/id_bib/8/id_origine/1142445/code_annexe/18',true); + } + + + /** @test */ + public function holdShouldHaveBeenCreatedWithJacqueLibraryToulon() { + $this->assertEquals('1', Class_Reservation::findFirstBy(['id_notice_origine' => '00021243', + 'idabon' => 1414])->getIdSite()); + } +} diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php index 1b94c2ed647cb6baa46dc50cac3372bed1bc3561..3d4d5c8210b2680cee917443869a92728f42811b 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php @@ -16,10 +16,10 @@ * * 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 RechercheControllerReservationPickupAjaxActionTest extends AbstractControllerTestCase { +class RechercheControllerReservationPickupAjaxActionTestWithChosenPickup extends AbstractControllerTestCase { protected $_json, $_xpath; public function setUp() { @@ -35,8 +35,10 @@ class RechercheControllerReservationPickupAjaxActionTest extends AbstractControl Class_CodifAnnexe::getLoader()->newInstanceWithId(3) ->setLibelle('Cran') ->setCode('CRN'))); - Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur'=>1]); - + + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 1]); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); $this->_json = json_decode($this->_response->getBody()); $this->_xpath = new Storm_Test_XPath(); @@ -61,9 +63,165 @@ class RechercheControllerReservationPickupAjaxActionTest extends AbstractControl public function layoutShouldBeEmpty() { $this->_xpath->assertNotXPath($this->_json->content, '//div[@id="banniere"]'); } + +} + + +class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true); + + + + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 1]); + + $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + /** @test */ + public function parameterCodeAnnexeShouldBeUsedForReservation() { + $this->assertEquals('23', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } + + } +class RechercheControllerReservationPickupAjaxActionTestWithPatronLibraryPickup extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 12, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true) + ->whenCalled('getUserAnnexe')->answers('12'); + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') + ->whenCalled('findAllBy') + ->with(array('no_pickup' => '0', + 'order' => 'libelle')) + ->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2) + ->setLibelle('Annecy') + ->setCode('ANN'), + Class_CodifAnnexe::getLoader()->newInstanceWithId(3) + ->setLibelle('Cran') + ->setCode('CRN'))); + + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 2]); + + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + + /** @test */ + public function getUserAnnexeResultShouldBeUsedForReservation() { + $this->assertEquals('12', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } +} + + + +class RechercheControllerReservationPickupAjaxActionTestWithItemLibraryPickup extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true); + + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') + ->whenCalled('findAllBy') + ->with(array('no_pickup' => '0', + 'order' => 'libelle')) + ->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2) + ->setLibelle('Annecy') + ->setCode('ANN'), + Class_CodifAnnexe::getLoader()->newInstanceWithId(3) + ->setLibelle('Cran') + ->setCode('CRN'))); + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 0]); + + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + /** @test */ + public function itemAnnexeShouldBeUsedForReservation() { + $this->assertEquals('ANN', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } + + +} class RechercheControllerReservationWithMailPostAction extends AbstractControllerTestCase { @@ -107,21 +265,21 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle /** @test */ public function firstMailFromShouldBeNanuk() { - $this->assertEquals('nanuk@gloub.com', + $this->assertEquals('nanuk@gloub.com', $this->first_mail->getFrom()); } /** @test */ public function firstMailSubjectShouldBeDemandeDeReservation() { - $this->assertContains('Demande de réservation de document', + $this->assertContains('Demande de réservation de document', quoted_printable_decode($this->first_mail->getSubject())); } /** @test */ public function firstMailToShouldBeZork() { - $this->assertContains('zork@gloub.fr', + $this->assertContains('zork@gloub.fr', $this->first_mail->getRecipients()); } @@ -141,14 +299,14 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle /** @test */ public function secondMailFromShouldBeNobody() { - $this->assertEquals('nobody@noreply.fr', + $this->assertEquals('nobody@noreply.fr', $this->last_mail->getFrom()); } /** @test */ public function secondMailToShouldBeNanuk() { - $this->assertContains('nanuk@gloub.com', + $this->assertContains('nanuk@gloub.com', $this->last_mail->getRecipients()); } } @@ -158,13 +316,13 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle class RechercheControllerReservationWithWebServiceKohaTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - - $this->jajm = $this->fixture('Class_Users', + + $this->jajm = $this->fixture('Class_Users', ['id' => 1, 'login' => 'jajm', 'password' => 'secret', - 'int_bib' => $this->fixture('Class_IntBib', - ['id' => 1, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA, 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) ]); @@ -197,9 +355,9 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr /** @test */ public function withMatchingHoldAndRecordMessageShouldContainsPickupLocationAndRecordTitleAuthor() { - $exemplaire = $this->fixture('Class_Exemplaire', + $exemplaire = $this->fixture('Class_Exemplaire', ['id' => 456, - 'notice' => $this->fixture('Class_Notice', + 'notice' => $this->fixture('Class_Notice', ['id' => 8890, 'titre_principal' => 'Arcadia', 'auteur_principal' => 'Matsumoto'])]); @@ -212,7 +370,7 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr /** @test */ public function withoutMatchingHoldMessageShouldNotContainsPickupLocation() { $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding(null, 'Valensole'), + $this->_prepareEmprunteurHolding(null, 'Valensole'), 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document sera disponible'); } @@ -243,7 +401,7 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr protected function _dispatchWithEmprunteurAndAssertContentEquals($emprunteur, $content) { $this->koha ->whenCalled('isConnected')->answers(true) - ->whenCalled('reserverExemplaire')->answers(['statut' => true, + ->whenCalled('reserverExemplaire')->answers(['statut' => true, 'erreur' => '', 'popup' => false]) ->whenCalled('getEmprunteur')->answers($emprunteur); diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 3161e37f2208fac8b33d805691baee06c055e815..20de4d72869cfc9c2090a18a01a5248fb784ac8c 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -776,7 +776,7 @@ class RechercheControllerViewNoticeAndResnumeriqueTabAsAdminTest extends Recherc 'boite' => null]; Class_Profil::beVolatile(); - $this->fixture('Class_Profil', ['id' => 1, + $this->fixture('Class_Profil', ['id' => 1, 'libelle' => 'Afibre']) ->setBarreNavOn(true) ->setCfgModules(['recherche' => ['viewnotice1' => $preferences]]) @@ -801,7 +801,7 @@ class RechercheControllerReadNoticeTest extends RechercheControllerNoticeTestCas } - /** @test */ + /** @test */ public function titreShouldBeDisplayed() { $this->assertXPathContentContains('//p', 'Titre: Cinéma d\'animation'); } @@ -831,10 +831,10 @@ abstract class RechercheAvanceeControllerSimpleActionTestCase extends AbstractCo class RechercheAvanceeControllerSimpleActionWithDefaultConfigTest extends RechercheAvanceeControllerSimpleActionTestCase { - public function setUp() { + public function setUp() { parent::setUp(); - Class_Profil::getCurrentProfil()->setCfgModules([]); + Class_Profil::getCurrentProfil()->setCfgModules([]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') ->whenCalled('findAllByRequeteRecherche') @@ -859,19 +859,26 @@ class RechercheAvanceeControllerSimpleActionWithDefaultConfigTest extends Recher ]])); - $this->dispatch('/recherche/simple?rech_titres=maupassant',true); - } + $this->dispatch('/recherche/simple?rech_titres=maupassant',true); + } -/** @test */ + /** @test */ public function tagsCloudLevel5ShouldBePresent() { $this->assertXPath('//a[contains(@class,"nuage_niveau5")]', $this->_response->getBody()); } + /** @test */ public function tagsCloudLevel10ShouldBePresent() { $this->assertXPath('//a[contains(@class,"nuage_niveau10")]', $this->_response->getBody()); } + + + /** @test */ + public function orderSelectShouldHaveLabel() { + $this->assertXPath('//label[@for="tri"]', $this->_response->getBody()); + } } @@ -1947,7 +1954,7 @@ class RechercheControllerAjoutNoticePanierUrlWithMurConfigTest extends Recherche /** @test **/ public function permalinkShouldBeDisplay() { - $this->assertXPath('//input[contains(@value,"recherche/viewnotice")][contains(@value,"/clef/")][contains(@value,"/id/")]'); + $this->assertXPathContentContains('//span', "recherche/viewnotice/expressionRecherche/potter/facettes/T1/facette/B1/page/2/clef/PETITESSCENESDEBALCONTERRASSE-SUIVIDE100PLANTESPO---RUSTICA-2009-1/id/42225?id_profil=2"); } } diff --git a/tests/application/modules/opac/controllers/RssControllerTest.php b/tests/application/modules/opac/controllers/RssControllerTest.php index fd3712bcdee22d65a4320534bc02b638276ed67d..1f23f9c7064cb0c33a73261361ddfca058603bda 100644 --- a/tests/application/modules/opac/controllers/RssControllerTest.php +++ b/tests/application/modules/opac/controllers/RssControllerTest.php @@ -310,12 +310,12 @@ class RssControllerCritiquesTest extends AbstractControllerTestCase { /** @test */ public function rssShouldContainsTwoItems() { - $this->assertXPath('//item[2]'); + $this->assertXPath('//item[2]', $this->_response->getBody()); } /** @test */ public function rssLinkShouldContainExpectedUrl() { - $this->assertXPathContentContains('//channel/link', BASE_URL); + $this->assertXPathContentContains('//channel/link', BASE_URL, $this->_response->getBody()); } /** @test */ diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 0a18cc72cc260791aef4bf42e4744b803ad225c4..623666b79d0f11fae02b2d8e4b946cc8264a9471 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -19,9 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class SitoControllerTestCase extends AbstractControllerTestCase { + protected $hackers; public function setUp() { parent::setUp(); - $this->fixture('Class_SitothequeCategorie', + $this->hackers=$this->fixture('Class_SitothequeCategorie', ['id' => 3, 'libelle' => 'Hackers']); @@ -57,6 +58,87 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { } +class SitoControllerViewCategoyTest extends SitoControllerTestCase { + public function setUp() { + parent::setUp(); + $collectif = $this->fixture('Class_SitothequeCategorie', + ['id' => 12, + 'parent_categorie' => $this->hackers, + 'libelle' => 'Collectifs' ]); + + $associations = $this->fixture('Class_SitothequeCategorie', + ['id' => 17, + 'parent_categorie' => $collectif, + 'libelle' => 'Associations' ]); + + $libre = $this->fixture('Class_SitothequeCategorie', + ['id' => 19, + 'parent_categorie' => $associations, + 'libelle' => 'Libre' ]); + + $this->fixture('Class_Sitotheque', + ['id' => 280, + 'categorie' => $libre, + 'titre' => 'La quadrature du net', + 'description' => 'Internet et libertés', + 'url' => 'http://laquadrature.net']); + + $this->fixture('Class_Sitotheque', + ['id' => 282, + 'categorie' => $associations, + 'titre' => 'April', + 'description' => 'Promouvoir le logiciel libre', + 'url' => 'http://april.org']); + + $this->fixture('Class_Sitotheque', + ['id' => 281, + 'categorie' => $collectif, + 'titre' => 'Framasoft', + 'description' => 'Degooglisons internet', + 'url' => 'http://framasoft.org']); + + Class_Profil::getCurrentProfil() + ->setCfgAccueil(['modules' => ['1' => ['division' => '2', + 'type_module' => 'SITO', + 'preferences' => ['id_categorie' => '12', + 'type_aff' => '3', + 'id_items' => '280-281']]], + 'options' => []]); + + $this->dispatch('/sito/viewcategory/id_cat/12/start_cat/12', true); + } + + + /** @test */ + public function linuxFrShouldNotBeShown() { + $this->assertNotXPath('//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', + $this->_response->getBody()); + } + + + /** @test */ + public function framasoftShouldBeShown() { + $this->assertXPath('//div[@class="sitotheque"]//a[@href="http://framasoft.org"]', + $this->_response->getBody()); + } + + + /** @test */ + public function catAssocShouldContains2sites() { + $this->assertXPathContentContains('//div//a[@href="/sito/viewcategory/start_cat/12/id_cat/17"]', 'Associations (2)', + $this->_response->getBody()); + } + + + /** @test */ + public function breadCrumbShouldStartWithCollectifs() { + $this->assertXPath('//div/a[1][@href="/sito/viewcategory/start_cat/12/id_cat/12"]', + $this->_response->getBody()); + } +} + + + class SitoControllerViewRecentTest extends SitoControllerTestCase { public function setUp() { @@ -79,7 +161,7 @@ class SitoControllerViewSelectionTest extends SitoControllerTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/sito/viewselection/id_module/1', true); + $this->dispatch('/sito/viewselection/id_module/1', true);; } diff --git a/tests/application/modules/opac/controllers/harry_potter_ecole_sorciers.txt b/tests/application/modules/opac/controllers/harry_potter_ecole_sorciers.txt new file mode 100644 index 0000000000000000000000000000000000000000..9b7fe49af0a1399079e6a666b53abd45184a9b9b --- /dev/null +++ b/tests/application/modules/opac/controllers/harry_potter_ecole_sorciers.txt @@ -0,0 +1 @@ +00654nam2 2200169 450 001000400000010002200004100001300026200002800039210003600067300007300103410002200176461002500198700004100223700005800264801001700322992014500339929 a978-2-07-051842-5 a201502281 aA l'école des sorciers aPariscGallimard Jeunessed1998 atraduit de : Harry Potter and the philosopher's stone, J. K. Rowling 0tFolio juniorv899 tHarry Potterv10923 1aRowlingbJoanne Kathleen3OPS0089313 1aMénardbJean-François3OPS005699940006Traduit par 2aFrc20150228 uhttp://websvc.pergame.net/afi_opac_services/images/jaquettes/0/0/0/2/thumbs/2387.jpegvhttp://ecx.images-amazon.com/images/I/51KVZWGHASL.jpg \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/rdv_a_kiruna.txt b/tests/application/modules/opac/controllers/rdv_a_kiruna.txt new file mode 100644 index 0000000000000000000000000000000000000000..ddc3aceff7d61ab14a1e4eac6c81087112559d67 --- /dev/null +++ b/tests/application/modules/opac/controllers/rdv_a_kiruna.txt @@ -0,0 +1 @@ +02518nm40 22004811i 450 00100090000010000410000910100080005020000050005820000260006321000090008921500110009830005700010931700050067961000120068461000100069670100160070670100320072270100270075470100250078170100200080670100220082670100200084870100250086870100220089370100240091570100230093970100260096270100220098870100250101070100280103570100230106385600820108685600880116885600890125685600870134585600870143285600870151985600870160685600870169385600870178085600870186785600820195410141532 a20150228a|||||||||||y0frey0103####ba0 afre1 e1 aRendez-vous à Kiruna d20121 a97 min aErnest, un architecte renommé, ne vit que pour son travail. Un jour, il reçoit un appel de la police suédoise qui le décide à entreprendre un long voyage jusqu’à Kiruna, en Laponie. Il doit y reconnaître le corps d’un parfait étranger, son fils qu’il n’a jamais connu. Son chemin va croiser celui de Magnus, un jeune homme sensible et perdu que tout oppose à Ernest, autoritaire et méfiant. Ce voyage en compagnie d’un fils possible va révéler à Ernest une part inconnue de lui-même et l’aider à mieux comprendre ce rendez-vous à Kiruna. a1 aCinéma1 aDrame aAnna Novion1 aDarroussin Jean-Pierre40051 aSoulis Anastasios40051 aLjungmark Claes40051 aBodnia Kim40051 aHenry Judith40051 aBoysen Lia40051 aPettersson Tord40051 aMalmberg Dag40051 aFalk Elizabeth40051 aBretet Adrien40051 aMathieu Caroline40051 aDenys Marion40051 aGödicke Stefan40051 aEmretsson Jan-Erik40051 aDumont Alfred4005 ahttp://opac3.pergame.net/bibliothequeyerres.net/bib-numerique/notice/ido/74211 xposterahttp://media.universcine.com/e7/bc/e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png1 xtrailerahttp://media.universcine.com/8e/fc/8efca835-d1cb-11e2-9bdb-9f0286f96b63.mp41 xphotoahttp://media.universcine.com/86/a0/86a03f42-743b-11e2-a70a-95d22b967ef4.jpg1 xphotoahttp://media.universcine.com/2f/ef/2fef1f40-743b-11e2-b26c-97244ce89526.jpg1 xphotoahttp://media.universcine.com/9c/2f/9c2fd46b-743b-11e2-8eee-913472587237.jpg1 xphotoahttp://media.universcine.com/95/7e/957ef3c7-743b-11e2-a7cf-a1ff1e819f2d.jpg1 xphotoahttp://media.universcine.com/39/83/398345c5-743b-11e2-937c-69aa3c6808e4.jpg1 xphotoahttp://media.universcine.com/a4/91/a491b170-743b-11e2-bf1f-215951818fb4.jpg1 xphotoahttp://media.universcine.com/8e/b2/8eb2ab6e-743b-11e2-9b17-d79fac5fbefa.jpg1 xexternal_uriahttp://www.mediatheque-numerique.com/films/rendez-vous-a-kiruna \ No newline at end of file diff --git a/tests/application/modules/push/controllers/MultimediaControllerTest.php b/tests/application/modules/push/controllers/MultimediaControllerTest.php index d2531cebb071cd10d0fa7012f23c421b68c163a9..940bb8530269693a3fd39ea7b5a2cb54668cd763 100644 --- a/tests/application/modules/push/controllers/MultimediaControllerTest.php +++ b/tests/application/modules/push/controllers/MultimediaControllerTest.php @@ -503,6 +503,285 @@ class AllBorrowersMultimediaControllerFirstBorrowerReturnedIsLoasTest extends Al } + +abstract class BorrowerMultimediaAddInBokehControllerTestCase extends AbstractControllerTestCase { + protected + $_resp, + $_private_key ="-----BEGIN RSA PRIVATE KEY----- +MIICWwIBAAKBgQCm1hgee4LI7ji06BkuV8O4XpxHe59n80Gge/r3uROj+Tuxx2AO +Sk9gX7e4JNVsdfw22ft+xVqwAii8qu4/fYuicrrZl66WXceACmsgGWEdHMB7ZPUd +4HqR5bdE1Xnr1Q0Z9IIku6Naxt/yy0P5Gv+ZlW7U287hF3sdh2dp7UgguQIDAQAB +AoGAUQv+aYh8r1myqId7/Bxckws7BirS9G+iuPChqYf6N5US37lIO4jz6JB3MniK +SYdDf+4DE8GR3aEe4xBybttxYi9JSG28LxSMvUCv13AOpj8GT34cDxDgwczDI9nb +549/hdGpRF+vW0imfA1lguyuteoQHRMUImoHdl8ZRzPXlaUCQQDWEThzawIlbjah +v5uEQ5OjHIJfDECDyV4IIBGfwcpsiCH98Rb4SzcFRvoIJ7HtmNuHT6/fR5JQmnQG +0Vn6qTw3AkEAx4Rk4e/uLSxdDrsqI3rXg+mSNUAXc1IlHUJpRvoktbpfxTwRjwxO +Pp7HmcaApw5RuJ0nOnNGE0J4GBjEAglyjwJAKJ+p+9VB2gKZYYawJ6B/YwPlBc6Y +a6oKKzaSwaOQG5qWANAA0OvNLDY0+tk1neZVOs93i8LUVHGLNUQDdFsrbwJATEXi +wzUUGpThJmaK33Fwvm8mg9DyphV7NspSsN2j9w0+24nxNHyB1RKiP7lRKYwh1a/O +dVvoKCi6/ItLM3QlJQJAEyvWEfvqKnFH13ID5oe/GVOih7O6VzgecEgd3ZawBVWd +dsZ77MnSRzIyzrfJ3LlluaXhJl2qJBITE7X8y5RTKw== +-----END RSA PRIVATE KEY-----", + + $_public_key = "-----BEGIN PUBLIC KEY----- +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCm1hgee4LI7ji06BkuV8O4XpxH +e59n80Gge/r3uROj+Tuxx2AOSk9gX7e4JNVsdfw22ft+xVqwAii8qu4/fYuicrrZ +l66WXceACmsgGWEdHMB7ZPUd4HqR5bdE1Xnr1Q0Z9IIku6Naxt/yy0P5Gv+ZlW7U +287hF3sdh2dp7UgguQIDAQAB +-----END PUBLIC KEY-----", + + + $_invalid_public_key = "-----BEGIN PUBLIC KEY----- +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6Q3TAOV6nWuS720NH4uas8Wdn +NMBZnbqsshKYeCzCCvqZJfwAyHMcSDQVvbqN452cqsZGKmxUbsRQMtcIml0gablf +Eq5k1SeviSt8OtxkK+pzJHrsC2GBlZuppoKsS9zwwlTEPttY9EgEY53mCSLF4IGD +yIuUs1qpg+Vx0R+3VwIDAQAB +-----END PUBLIC KEY-----"; + + /** + * @param $url string + * @return stdClass + */ + public function getResponseJsonDecode($url) { + $this->dispatch('/push/multimedia/'.$url, true); + return $this->_response->getBody(); + } + + public function getPublicKey(){ + return $this->_public_key; + } + + public function signUrl($json){ + openssl_sign($json, + $sign, + $this->_private_key); + return base64_encode($sign); + } +} + + +class CreateBorrowerInviteWithInvalidInfoMultimediaControllerMessageReturnedIsInvalidInfoUserTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '[{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}]'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('create-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsInvalidInfoUser() { + $this->assertEquals('INVALID_INFO_USER', $this->_resp); + } + +} + + +class CreateBorrowerInviteButNoGroupUserMultimediaControllerMessageReturnedIsUndefinedGroupUserAfimTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') + ->whenCalled('findFirstBy') + ->with(['group_type'=>Class_UserGroup::TYPE_MULTIMEDIA]) + ->answers(null); + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '[{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"85","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}]'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('create-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsUndefinedGroupUserAfim() { + $this->assertEquals('UNDEFINED_GROUP_USER_AFIM', $this->_resp); + } + +} + + + +class CreateBorrowerInviteMultimediaControllerBorrowerReturnedIsInviteTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') + ->whenCalled('findFirstBy') + ->with(['login'=> 'invite']) + ->answers(null) + + ->whenCalled('save') + ->answers(true); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') + ->whenCalled('findFirstBy') + ->with(['group_type' => Class_UserGroup::TYPE_MULTIMEDIA]) + ->answers(Class_UserGroup::getLoader() + ->newInstanceWithId(1) + ->setLibelle('groupe abonne multimedia')); +; + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '[{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"85","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}]'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('create-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsAddNewUserOk() { + $this->assertEquals('ADD_NEW_USER_OK', $this->_resp); + } + +} + + + +class ModifyBorrowerMultimediaNoPresentControllerReturnedMessageTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') + ->whenCalled('findFirstBy') + ->with(['login'=> 'invite']) + ->answers(null) + + ->whenCalled('save') + ->answers(true); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') + ->whenCalled('findFirstBy') + ->with(['group_type' => Class_UserGroup::TYPE_MULTIMEDIA]) + ->answers(Class_UserGroup::getLoader() + ->newInstanceWithId(1) + ->setLibelle('groupe abonne multimedia')); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroupMembership') + ->whenCalled('findFirstBy') + ->with(['user_id'=> 14, 'user_group_id' => 1]) + ->answers(Class_UserGroupMembership::getLoader() + ->newInstanceWithId(1)); + + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"invite","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('modify-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsAddNewUserOk() { + $this->assertEquals('ADD_NEW_USER_OK', $this->_resp); + } + +} + + +class ModifyBorrowerMultimediaPresentControllerReturnedMessageTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') + ->whenCalled('findFirstBy') + ->with(['login'=> 'invite']) + ->answers(AbonneMultimediaControllerMultimediaUsersFixtures::getInviteAfim()) + + ->whenCalled('save') + ->answers(true); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') + ->whenCalled('findFirstBy') + ->with(['group_type' => Class_UserGroup::TYPE_MULTIMEDIA]) + ->answers(Class_UserGroup::getLoader() + ->newInstanceWithId(1) + ->setLibelle('groupe abonne multimedia')); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroupMembership') + ->whenCalled('findFirstBy') + ->with(['user_id'=> 14, 'user_group_id' => 1]) + ->answers(Class_UserGroupMembership::getLoader() + ->newInstanceWithId(1)); + + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"invite","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('modify-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsModificationUserOk() { + $this->assertEquals('MODIFICATION_USER_OK', $this->_resp); + } + +} + +class DeleteBorrowerMultimediaControllerReturnedMessageTest extends BorrowerMultimediaAddInBokehControllerTestCase { + public function setUp() { + parent::setUp(); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') + ->whenCalled('findFirstBy') + ->with(['login'=> 'invite']) + ->answers(AbonneMultimediaControllerMultimediaUsersFixtures::getInviteAfim()) + + ->whenCalled('delete') + ->answers(true); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroup') + ->whenCalled('findFirstBy') + ->with(['group_type' => Class_UserGroup::TYPE_MULTIMEDIA]) + ->answers(Class_UserGroup::getLoader() + ->newInstanceWithId(1) + ->setLibelle('groupe abonne multimedia')); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroupMembership') + ->whenCalled('findFirstBy') + ->with(['user_id'=> 14, 'user_group_id' => 1]) + ->answers(Class_UserGroupMembership::getLoader() + ->newInstanceWithId(1)); + + + + Class_AdminVar::getLoader() + ->newInstanceWithId('MULTIMEDIA_KEY') + ->setValeur($this->getPublicKey()); + + $json = '{"site":{"id":"1","libelle":"Site 1","admin_url":"192.168.2.92"},"login":"invite","pwd":"3ef815416f775098fe977004015c6193","nom":"85","prenom":"85","temps":0,"jeton":0,"groupe":2,"opac":0,"naissance":"","datefin":""}'; + $sign = $this->signUrl($json); + $this->_resp = $this->getResponseJsonDecode('delete-borrower?sign=' . urlencode($sign) .'&json='.$json); + } + + /** @test */ + public function shouldReturnedMessageIsSUCCESS_DELETING() { + $this->assertEquals('SUCCESS_DELETING', $this->_resp); + } + +} + class AbonneMultimediaControllerMultimediaUsersFixtures { public static function getLoas() { return Class_Users::getLoader()->newInstanceWithId(12) @@ -534,4 +813,17 @@ class AbonneMultimediaControllerMultimediaUsersFixtures { ->setDateDebut('2029-01-01') ->setEmail('loas@mail.fr'); } + + public static function getInviteAfim() { + return Class_Users::getLoader()->newInstanceWithId(14) + ->beInvite() + ->setLogin("invite") + ->setPassword("invite") + ->setNom('invite') + ->setPrenom('invite') + ->setRoleLevel(0) + ->setIdabon('invite') + ->setNaissance('1983-02-17') + ->setDateFin('2030-01-01'); + } } \ No newline at end of file diff --git a/tests/application/modules/telephone/controllers/IndexControllerTest.php b/tests/application/modules/telephone/controllers/IndexControllerTest.php index 2b0c1b0a8b98ac7c308f43ebd605db46f72d0a57..5a90b38124f69309b87ceaff3a767f8e7dab6d03 100644 --- a/tests/application/modules/telephone/controllers/IndexControllerTest.php +++ b/tests/application/modules/telephone/controllers/IndexControllerTest.php @@ -80,9 +80,11 @@ abstract class AbstractIndexControllerTelephoneWithModulesTest extends Telephone ->setHeaderCss('mon_style.css') ->setHauteurBanniere(150) ->setBrowser('telephone') - ->setSubProfils([$this->fixture('Class_Profil', ['id' => 34])]) ->beCurrentProfil(); + $this->fixture('Class_Profil', ['id' => 34, + 'parent_profil' => $this->profil_adulte]); + Class_Profil_Skin::setFileSystem((new Storm_FileSystem_Volatile()) ->mkdir('/public/opac/skins/vide/css/') ->touch('/public/opac/skins/vide/css/mobile.css')); @@ -98,6 +100,7 @@ abstract class AbstractIndexControllerTelephoneWithModulesTest extends Telephone } + class IndexControllerTelephoneOnSubpageTest extends AbstractIndexControllerTelephoneWithModulesTest { public function setUp() { parent::setUp(); diff --git a/tests/application/modules/telephone/controllers/RechercheControllerTest.php b/tests/application/modules/telephone/controllers/RechercheControllerTest.php index 52b146603a7ddb831933df106ac66a73bb5bcee8..91e018fa23cd124814ebc6f3d79cd5b4da24c831 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerTest.php @@ -255,7 +255,7 @@ class Telephone_RechercheControllerFrbrWithLinksTest extends TelephoneAbstractCo /** @test */ public function tintinPicarosShouldHaveImageFromVignetteAction() { - $this->assertXPath('//li/a/img[contains(@src, "/recherche/vignette?clef=")]'); + $this->assertXPath('//li/a/img[contains(@src, "/recherche/vignette/clef")][contains(@src, "/id_notice/555")]'); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 784c43ec45fd4a429290d7175447959e7e4699a4..6e794a0cfe82d1cf2c1bb5f4fab70c1a7953dabe 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -54,6 +54,11 @@ defineConstant('ROOT_URL', 'http://localhost'); defineConstant("URL_IMG", BASE_URL . "/public/opac/skins/original/images/"); defineConstant("URL_SHARED_IMG", BASE_URL . "/public/opac/images"); +$_SERVER['SERVER_NAME'] = 'localhost'; +$_SERVER['SERVER_PORT'] = '80'; +$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; +$_SERVER['HTTP_HOST'] = 'localhost'; + setupOpac(); (new Storm_Cache())->getCache()->setOption('caching', true); @@ -73,13 +78,9 @@ $cfg->amber = new Zend_Config(array('deploy' => false)); Zend_Registry::set('cfg', $cfg); $translate = Zend_Registry::get('translate'); -$translate->setLocale('fr'); $translate->addTranslation(LANG_DIR.'ro.mo', 'ro'); $translate->addTranslation(LANG_DIR.'en.mo', 'en'); - -$_SERVER['SERVER_NAME'] = 'localhost'; -$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; -$_SERVER['HTTP_HOST'] = 'localhost'; +$translate->setLocale('fr'); //Initialize the router for tests that do not rely on dispatch Zend_Controller_Front::getInstance()->getRouter()->route(new Zend_Controller_Request_Http('http://localhost/')); diff --git a/tests/fixtures/DilicomFixtures.php b/tests/fixtures/DilicomFixtures.php new file mode 100644 index 0000000000000000000000000000000000000000..1c3f86b87904bc030d86baf46af4a42233ced0bd --- /dev/null +++ b/tests/fixtures/DilicomFixtures.php @@ -0,0 +1,135 @@ +<?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 DilicomFixtures { + use Storm_Test_THelpers; + + public static function loanBookResponse() { + return '{ + "link" : { + "format" : "E101", + "url" : "https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do", + "ean13" : "9782021153057", + "formatDescription" : "EPUB", + "mimetype" : "application/epub+zip" + }, + "requestId":"aw01v2_000000035_201502261456", + "returnStatus" : "OK", + "returnMessage" : [], + "orderLineId" : "53f1b4817b698cfb72afd7e1", + "loanId" : "WIKI001", + "loanEndDate" : "2014-09-22T02:37:25.000+02:00" +}'; + } + + + public static function loanBookErrorResponse() { + return '{ + "link" : { + "format" : "E101", + "url" : "https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do", + "ean13" : "9782021153057", + "formatDescription" : "EPUB", + "mimetype" : "application/epub+zip" + }, + "requestId":"aw01v2_000000035_201502261456", + "returnStatus" : "FAIL", + "returnMessage" : ["Are you trying to download this book ?"], + "orderLineId" : "53f1b4817b698cfb72afd7e1", + "loanId" : "WIKI001", + "loanEndDate" : "2014-09-22T02:37:25.000+02:00" +}'; + } + + + public static function endLoanBookErrorResponse() { + return '{ + "requestId":"aw01v2_000000041_201502261510", + "returnStatus" : "ACCES_DENIED", + "returnMessage" : [ "The loan with orderlineId \'524ade40bbd31c6240a30dff\' and loanId \'loanId\' is already ended" ] +}'; + } + + + public static function endLoanBookResponse() { + return '{ + "requestId":"aw01v2_000000041_201502261510", + "returnStatus" : "OK", + "returnMessage" : [] +}'; + } + + + public static function getLoanStatusResponse() { + return '{ + "date" : "2014-08-14T11:32:12.786+02:00", + "returnStatus" : "OK", + "returnMessage" : [ ], + "loanResponseLine" : [ { + "returnStatus" : "OK", + "orderLineId" : "537119f5975a1d3260801864", + "nta" : 24, + "nus1" : 5, + "nus2" : 30, + "beginDate" : "2014-05-12T20:59:03+02:00", + "endDate" : "2015-05-12T20:59:03+02:00" + } ] +}'; + } + + + public static function getLoanStatusErrorResponse() { + return '{ + "date" : "2014-08-14T11:32:12.786+02:00", + "returnStatus" : "OK", + "returnMessage" : ["INVALID_ARGUMENTS"], +}'; + } + + public function albumTotemThora() { + return $this->fixture('Class_Album', + ['id' => 3, + 'libelle' => 'Totem et Thora', + 'id_origine' => 'Dilicom-88817216', + 'external_uri' => 'http://www.edenlivres.fr/p/23416', + 'type_doc_id' => Class_TypeDoc::DILICOM, + 'items' => [$this->fixture('Class_Album_Item', + ['id' => 1, + 'album_id' => 3, + 'loan_count' => 2, + 'quantity' => 4])], + 'usage_constraints' => [$this->fixture('Class_Album_UsageConstraint', + ['id' => 1, + 'album_id' => 3, + 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, + Class_Album_UsageConstraint::MAX_NB_OF_USERS => 50, + Class_Album_Usageconstraint::QUANTITY => 50, + 'order_line_id' => 'x321']), + $this->fixture('Class_Album_UsageConstraint', + ['id' => 2, + 'album_id' => 3, + 'usage_type' => Class_Album_UsageConstraint::AVAILABILITY_CONSTRAINT, + Class_Album_UsageConstraint::DURATION => '100', + Class_Album_UsageConstraint::END_DATE => '2018-04-01 00:00:00'])]]); + } +} +?> \ No newline at end of file diff --git a/tests/fixtures/RessourcesNumeriquesFixtures.php b/tests/fixtures/RessourcesNumeriquesFixtures.php index 3babce9846ec52bcf5ba8fbd626217e0ce517eb5..d5861f7c75ed3397eb2204a399f8984a538cb250 100644 --- a/tests/fixtures/RessourcesNumeriquesFixtures.php +++ b/tests/fixtures/RessourcesNumeriquesFixtures.php @@ -35,6 +35,7 @@ class RessourcesNumeriquesFixtures { self::deactivateMyCow(); self::deactivatePlanetNemo(); self::deactivateKidilangues(); + self::deactivateJamendo(); } @@ -54,6 +55,7 @@ class RessourcesNumeriquesFixtures { self::activateMyCow(); self::activatePlanetNemo(); self::activateKidilangues(); + self::activateJamendo(); } @@ -99,6 +101,16 @@ class RessourcesNumeriquesFixtures { } + public static function activateJamendo() { + Class_AdminVar::newInstanceWithId('JAMENDO_CLIENT_ID', ['valeur' => 'xxx']); + } + + + public static function deactivateJamendo() { + Class_AdminVar::newInstanceWithId('JAMENDO_CLIENT_ID', ['valeur' => '']); + } + + public static function deactivateVodeclic() { Class_AdminVar::newInstanceWithId('VODECLIC_KEY', ['valeur' => '']); } @@ -261,4 +273,5 @@ class RessourcesNumeriquesFixtures { Class_AdminVar::newInstanceWithId('DILICOM_PNB_GLN_CONTRACTOR', ['valeur' => '']); } } + ?> diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index 27aa464b0ebec137406903595f4ad62db240b9c6..14d5aba865bce6ebfd674d3ee4514dbbfe9504a3 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -125,12 +125,12 @@ class AlbumHarlockBasicTest extends AlbumHarlockTestCase { /** @test */ function basePathShouldBeUserfiles_Slash_Album_999() { - $this->assertEquals('..' . BASE_URL . '/userfiles/album/999/', $this->_album->getBasePath()); + $this->assertEquals(USERFILESPATH . '/album/999/', $this->_album->getBasePath()); } /** @test */ function thumbnailsPathShouldBeUserfiles_Slash_thumbs_999() { - $this->assertEquals('..' . BASE_URL . '/userfiles/album/999/thumbs/', $this->_album->getThumbnailsPath()); + $this->assertEquals(USERFILESPATH . '/album/999/thumbs/', $this->_album->getThumbnailsPath()); } /** @test */ diff --git a/tests/library/Class/BatchTest.php b/tests/library/Class/BatchTest.php index 5eb95b5923b9161c18e9d3ed4293de78d4bf5021..c1edbbba9911fee9fa7591505625c6e2a9043a98 100644 --- a/tests/library/Class/BatchTest.php +++ b/tests/library/Class/BatchTest.php @@ -97,6 +97,8 @@ class BatchModelTest extends Storm_Test_ModelTestCase { } + + class BatchLoaderWithoutRessourcesNumeriquesTest extends Storm_Test_ModelTestCase { public function setUp() { parent::setUp(); @@ -134,7 +136,7 @@ class BatchLoaderWithRessourcesNumeriquesTest extends Storm_Test_ModelTestCase { /** @test */ public function ressourcesNumeriquesShouldBeAvailable() { foreach(array_keys(Class_Batch::getRessourcesNumeriqueTypes()) as $type) - $this->assertTrue(in_array($type, array_keys($this->_types))); + $this->assertTrue(in_array($type, array_keys($this->_types)), $type); } } diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php index 298b5c7dcb4a056d21af2d2f23d5a72df63e7de4..e741ad77eab6884c12dd79354896a30b9945d479 100644 --- a/tests/library/Class/CatalogueTest.php +++ b/tests/library/Class/CatalogueTest.php @@ -925,7 +925,7 @@ class CatalogueAddOrCreateTest extends CatalogueParentTest { public function saveCatalogueAndMoveDomaineWithNonExistingThesarusShouldCreateThesaurus() { Class_CodifThesaurus::getLoader() ->whenCalled('findNextThesaurusChildId') - ->with('YYYY0001') + ->with('catalogue','YYYY0001') ->answers('YYYY00010005') ->whenCalled('deleteAllWithIdOrigineAndCode') @@ -1035,6 +1035,35 @@ class CatalogueGetRequetesWithCatalogueTest extends ModelTestCase { } + /** @test */ + public function requetesShouldBeEmpty() { + $this->assertEquals([], $this->_requetes); + } +} + + + +class CatalogueGetAllNoticeIdsForDomaineTest extends ModelTestCase { + protected $_catalogue; + + + public function setUp() { + parent::setUp(); + $catalogue = $this->fixture('Class_Catalogue', + ['id' => 5, + 'libelle' => 'My catalogue']); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') + ->whenCalled('getRequetes') + ->answers(['req_liste' => '', + 'req_comptage' => '', + 'req_facettes' => '', + 'req_ids' => '']); + + $this->_requetes = $catalogue->getAllNoticeIdsForDomaine(5, 1); + } + + /** @test */ public function requetesShouldBeEmpty() { $this->assertEquals([], $this->_requetes); diff --git a/tests/library/Class/CmsUrlTransformerTest.php b/tests/library/Class/CmsUrlTransformerTest.php index 1533672335fe3be11e1bf859b2846a29061ffee9..e6996a651203fac269b52c1ce2edf08c10013cfa 100644 --- a/tests/library/Class/CmsUrlTransformerTest.php +++ b/tests/library/Class/CmsUrlTransformerTest.php @@ -16,17 +16,116 @@ * * 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 CmsUrlTransformerTest extends PHPUnit_Framework_TestCase { +class CmsUrlTransformerTest extends Storm_Test_ModelTestCase { public function setUp(){ - $_SERVER['HTTP_HOST'] = 'localhost'; + parent::setUp(); + Class_Profil::beVolatile(); + $cfg_accueil_jeunesse = ['modules' => ['1' => ['division' => '4', + 'type_module' => 'RECH_SIMPLE', + 'preferences' => ['recherche_avancee' => "on", + 'select_doc' => 'on', + 'select_annexe' => 'on' + ]], + + '2' => ['division' => '4', + 'type_module' => 'LOGIN', + 'preferences' => ['lien_connexion' => 'http://www.ma-mediatheque.net/afi-opac3?id_profil=1']], + + '4' => ['division' => '1', + 'type_module' => 'NEWS'], + + '45' => ['division' => '1', + 'type_module' => 'CALENDAR', + 'preferences' => ['display_calendar' => '0', + 'mode-affichage' => 'simple']], + + '8' => ['division' => '2', + 'type_module' => 'RESERVATIONS', + 'preferences' => ['titre' => 'Mes réservations']], + + '9' => ['division' => '2', + 'type_module' => 'PRETS', + 'preferences' => ['titre' => 'Mes documents']], + + '10' => ['division' => '1', + 'type_module' => 'NEWSLETTERS', + 'preferences' => ['titre' => 'Lettres d\'informations']], + + '11' => ['division' => '2', + 'type_module' => 'MULTIMEDIA', + 'preferences' => ['titre' => '/afi-opac3/Postes_multimédia']], + + '12' => ['division' => '2', + 'type_module' => 'KIOSQUE', + 'preferences' => ['style_liste' => 'vignettes']], + + '18' => ['division' => '1', + 'type_module' => 'PANIER', + 'preferences' => ['titre' => 'Mes Paniers']], + + '19' => ['division' => '5', + 'type_module' => 'PANIER', + 'preferences' => ['titre' => 'Mes Paniers flottants']] + + ], + 'options' => []]; + + $this->profil_jeunesse = $this + ->fixture('Class_Profil', + ['id' => 230, + 'browser' => 'opac', + 'titre_site' => null, + 'libelle' => 'Profil Jeunesse', + 'cfg_accueil' => $cfg_accueil_jeunesse, + 'favicon' => '/afi-opac3/userfiles/favicon.ico', + 'header_css' => '/afi-opac3/userfiles/jeunesse.css', + 'header_js' => '/afi-opac3/userfiles/jeunesse.js', + 'logo_gauche_img' => '/userfiles/mabib.png', + 'logo_gauche_link' => 'http://mabib.fr', + 'logo_droite_img' => '/userfiles/macommune.png', + 'logo_droite_link' => 'http://macommune.fr', + 'header_img_cycle' => true]); + $this->transformer = new Class_CmsUrlTransformer; } - public function testRelativeUrlToAbsolute() { + /** @test */ + public function connectUrlShouldNotContainHost() { + $this->profil_jeunesse + ->setCfgAccueil(Class_CmsUrlTransformer::removeHostFromArray("ma-mediatheque.net", + "afi-opac3", + $this->profil_jeunesse->getCfgAccueilAsArray(), + $countSite)); + + $this->assertEquals('/?id_profil=1', + $this->profil_jeunesse->getCfgAccueilAsArray()['modules'][2]['preferences']['lien_connexion']); + } + + + /** @test */ + public function baseDirShouldBeRemoved() { + $this->assertEquals("http://ma-mediatheque.fr/recherche/viewnotice/expressionRecherche/dragon/tri/*/clef/DRAGONJAUNEETLEDRAGONBLEULE-CONTECOREEN-LOUISC--PPICQUIER-2012-1/id/1805295", + Class_CmsUrlTransformer::removeBaseDir('ma-mediatheque.fr', + 'casa', + 'http://ma-mediatheque.fr/casa/recherche/viewnotice/expressionRecherche/dragon/tri/*/clef/DRAGONJAUNEETLEDRAGONBLEULE-CONTECOREEN-LOUISC--PPICQUIER-2012-1/id/1805295')); + } + + + /** @test */ + public function headerJsShouldNotContainHost() { + $this->profil_jeunesse->setCfgSite(Class_CmsUrlTransformer::removeHostFromArray("ma-mediatheque.net","afi-opac3", $this->profil_jeunesse->getCfgSiteAsArray(), $countSite)); + Class_Profil::clearCache(); + $this->assertEquals('/userfiles/jeunesse.js', + $this->profil_jeunesse->getCfgSiteAsArray()['header_js']); + } + + + /** @test */ + public function forEditingShouldTransformToAbsoluteUrls() { $this->assertEquals('<p>plan: <img src="http://localhost/userfile/image.png" />'. '</p><img src="http://example.com/test.jpg"></img>', @@ -38,7 +137,8 @@ class CmsUrlTransformerTest extends PHPUnit_Framework_TestCase { } - public function testAbsoluteToRelativeUrl() { + /** @test */ + public function forSavingShouldTransformToRelativeUrls() { $this->assertEquals('<p>plan: <img src="'.BASE_URL.'/userfile/image.png" />'. '</p><img src="'.BASE_URL.'/images/test.jpg"></img>'. '<img src="http://example.com/../test.jpg" />', @@ -50,7 +150,8 @@ class CmsUrlTransformerTest extends PHPUnit_Framework_TestCase { } - public function testChatenaySaveNonRegression() { + /** @test */ + public function chatenaySaveShouldNotRegress() { $this->assertEquals('<a href="http://www.histoireencartes.com/" target="_blank">'. '<img alt="" src="'.BASE_URL.'/userfiles/image/Histoire/armistice.jpg" style="width: 123px; height: 93px; " />'. '<img alt="" src="'.BASE_URL.'/userfiles/image/Histoire/armistice.jpg" />'. @@ -61,6 +162,77 @@ class CmsUrlTransformerTest extends PHPUnit_Framework_TestCase { '<img alt="" src="'.BASE_URL.BASE_URL.'/userfiles/image/Histoire/armistice.jpg" />'. '<br /></a>')); } + + + public function urlTransmormDataProvider() { + return [ + ['Concert <a class="popup" href="/cms/id/12">de maiden</a> à la bib !', + 'Concert <a class="popup" href="http://www.genevois-biblio.fr/genevois-biblio.fr/cms/id/12">de maiden</a> à la bib !', + 'genevois-biblio.fr'], + + + ['Concert <a class="popup" href="/cms/id/12">de maiden</a> à la bib !', + 'Concert <a class="popup" href="http://web.afi-sa.net/genevois-biblio.fr/cms/id/12">de maiden</a> à la bib !', + 'genevois-biblio.fr'], + + + ['Concert <a class="popup" href="/cms/id/12">de maiden</a> à la bib !', + 'Concert <a class="popup" href="http://opac3.pergame.net/genevois-biblio.fr/cms/id/12">de maiden</a> à la bib !', + 'genevois-biblio.fr'], + + + ['Concert <a class="popup" href="/cms/id/12">de maiden</a> à la bib !', + 'Concert <a class="popup" href="/genevois-biblio.fr/cms/id/12">de maiden</a> à la bib !', + 'genevois-biblio.fr'], + + ['Concert <a class="popup" href="/cms/id/12">de maiden</a> à la bib !', + 'Concert <a class="popup" href="www.genevois-biblio.fr/genevois-biblio.fr/cms/id/12">de maiden</a> à la bib !', + 'genevois-biblio.fr'], + + ['Concert <img class="popup" src="/userfiles/maiden.jpg">de maiden à la bib !', + 'Concert <img class="popup" src="www.genevois-biblio.fr/genevois-biblio.fr/userfiles/maiden.jpg">de maiden à la bib !', + 'genevois-biblio.fr'], + + ['Concert <img class="popup" src="/userfiles/maiden.jpg" />de maiden à la bib !', + 'Concert <img class="popup" src="www.genevois-biblio.fr/genevois-biblio.fr/userfiles/maiden.jpg" />de maiden à la bib !', + 'genevois-biblio.fr'], + + ['Concert <img class="popup" src="/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'Concert <img class="popup" src="www.genevois-biblio.fr/genevois-biblio.fr/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'genevois-biblio.fr'], + + ['Concert <img class="popup" src="www.genevois-biblio.com/genevois-biblio.fr/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'Concert <img class="popup" src="www.genevois-biblio.com/genevois-biblio.fr/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'genevois-biblio.fr'], + + ['Concert <img class="popup" src="/mediatheque-casa.fr/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'Concert <img class="popup" src="http://www.ma-mediatheque.net/mediatheque-casa.fr/userfiles/maiden.jpg" ></img>de maiden à la bib !', + 'ma-mediatheque.net'], + ['/userfiles/maiden.jpg', + '/ma-mediatheque.net/userfiles/maiden.jpg', + 'ma-mediatheque.net'], + ['/userfiles/maiden.jpg', + 'http://www.ma-mediatheque.net/ma-mediatheque.net/userfiles/maiden.jpg', + 'ma-mediatheque.net'], + ['/userfiles/maiden.jpg', + 'www.ma-mediatheque.net/ma-mediatheque.net/userfiles/maiden.jpg', + 'ma-mediatheque.net'], + ['/?id_profil=1', + 'http://www.mediathequebron.fr/mediathequebron.fr/?id_profil=1', + 'mediathequebron.fr'] + + ]; + } + + + /** + * @test + * @dataProvider urlTransmormDataProvider + */ + public function removeHostShouldTransformUrlsToRelative($expected, $content, $host) { + $this->assertEquals($expected, + $this->transformer->removeHost("ma-mediatheque.net",$host, $content)); + } } diff --git a/tests/library/Class/CodifThesaurusTest.php b/tests/library/Class/CodifThesaurusTest.php index 030a9a023032f5624c8bd2021a965029a9097f05..87e46122bf1af8a740d2d76f8cc10e932fea3336 100644 --- a/tests/library/Class/CodifThesaurusTest.php +++ b/tests/library/Class/CodifThesaurusTest.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 CodifThesaurusTest extends ModelTestCase { @@ -26,7 +26,8 @@ class CodifThesaurusTest extends ModelTestCase { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifThesaurus') ->whenCalled('findFirstBy') - ->with(['where' => 'code like "catalogue" and id_thesaurus like "CCCC0001%"', + ->with(['code' => 'catalogue', + 'where' => 'id_thesaurus like "CCCC0001%"', 'order' => 'id_thesaurus desc']) ->answers(Class_CodifThesaurus::newInstanceWithId(60,['id_thesaurus'=>'CCCC00010022'])) ; @@ -37,21 +38,21 @@ class CodifThesaurusTest extends ModelTestCase { /** @test */ public function findNextThesaurusChildIdShouldReturnCCCC00010001() { - $this->assertEquals('CCCC00010023',Class_CodifThesaurus::findNextThesaurusChildId('CCCC0001')); + $this->assertEquals('CCCC00010023',Class_CodifThesaurus::findNextThesaurusChildId('catalogue','CCCC0001')); } /** @test */ public function code01Sur4ChiffresShouldReturn0100() { $this->assertEquals('0100',Class_CodifThesaurus::getCodeSur4Chiffres('01')); - + } /** @test */ public function codeASur4ChiffresShouldReturn0100() { $this->assertEquals('A000',Class_CodifThesaurus::getCodeSur4Chiffres('A')); - + } /** @test */ @@ -74,10 +75,9 @@ class CodifThesaurusTest extends ModelTestCase { ->whenCalled('findParent') ->with('THEM00010050') ->answers(Class_CodifThesaurus::newInstanceWithId(20,['id_thesaurus'=>'THEM0001'])->setLibelle('Culture')); - - + + $this->assertEquals('Culture : Spectacles : Conférences Gesticulées',Class_CodifThesaurus::getLibelleHierarchique(Class_CodifThesaurus::newInstanceWithId(10,['id_thesaurus'=>'THEM000100503000'])->setLibelle('Conférences Gesticulées'))); } } - diff --git a/tests/library/Class/CodificationTest.php b/tests/library/Class/CodificationTest.php index 5671aa36021f9a0c7747e84ec7b7e369504c597f..a7cdb1e96fbdc483d1981a34b04899cd5b8ff57e 100644 --- a/tests/library/Class/CodificationTest.php +++ b/tests/library/Class/CodificationTest.php @@ -63,6 +63,7 @@ class CodificationNomChampsTest extends Storm_Test_ModelTestCase { [ ['G'],[$translate->_('Genre')]], [ ['HGENR'],[$translate->_('Genre Electre')]], [ ['HTHEM'],[$translate->_('Themes Electre')]], + [ ['HFDEL'],['']], [ ['I'],[$translate->_('Identifiant')]], [ ['K'],[$translate->_('Collation')]], [ ['L'],[$translate->_('Langue')]], diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7ffe169a310b37e0b0d47d62fbfcf7b56d3ecc8b --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhaseItemFacetsTest.php @@ -0,0 +1,114 @@ +<?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 PhaseItemFacetsTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + public function setUp() { + parent::setUp(); + + $this->_phase = $this->_buildPhase('ItemFacets') + ->noDbReset() + ->run(); + } +} + + + +class PhaseItemFacetsBadPreviousPhaseTest extends PhaseItemFacetsTestCase { + protected function _getPreviousPhase() { + return new Class_Cosmogramme_Integration_Phase(2); + } + + + /** @test */ + public function shouldNotChangePhase() { + $this->assertTrue($this->_phase->isId(2)); + } +} + + + +class PhaseItemFacetsExpectedPreviousPhaseTest extends PhaseItemFacetsTestCase { + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(4)) + ->beCron(); + } + + + protected function _prepareFixtures() { + $this->fixture('Class_CosmoVar', + ['id' => 'date_maj_facettes', + 'valeur' => '']); + + $this + ->onLoaderOfModel('Class_Notice') + ->whenCalled('findAllAfter') + ->answers([$this->fixture('Class_Notice', + ['id' => 1, + 'date_maj' => '2015-04-05 15:08:34'])]); + } + + + /** @test */ + public function shouldChangePhase() { + $this->assertTrue($this->_phase->isId(7)); + } + + + /** @test */ + public function logShouldContainsPhaseLabel() { + $this->assertLogContains('Mise à jour des facettes exemplaires'); + } + + + /** @test */ + public function logShouldContainsProcessedRecordCount() { + $this->assertLogContains('1 notices traitées'); + } + + + /** @test */ + public function lastFacetsUpdateDateShouldBeSet() { + $this->assertNotEquals('', Class_CosmoVar::getValueOf('date_maj_facettes')); + } +} + + + +abstract class PhaseItemFacetsCallbackTest extends PhaseItemFacetsTestCase { + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(4)); + } + + + protected function _prepareFixtures() { + $this->fixture('Class_CosmoVar', + ['id' => 'date_maj_facettes', + 'valeur' => '']); + + $this + ->onLoaderOfModel('Class_Notice') + ->whenCalled('findAllAfter') + ->answers([$this->fixture('Class_Notice', + ['id' => 1, + 'date_maj' => '2015-04-05 15:08:34'])]); + } +} \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php new file mode 100644 index 0000000000000000000000000000000000000000..66960529113125c0c4db785f161031815320cc10 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php @@ -0,0 +1,369 @@ +<?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 PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + protected $_log, $_phase, $_printer; + + public function setUp() { + parent::setUp(); + + $this->_phase = $this->_buildPhase('Panier') + ->setPrinter($this->_printer) + ->run(); + } + + + public function _prepareFixtures() { + $this->fixture('Class_CosmoVar', + ['id' => 'traitement_phase', 'valeur' => 'Base bloquée']); + + $this->fixture('Class_CosmoVar', + ['id' => 'integration_path', 'valeur' => realpath(dirname(__FILE__)) . '/']); + + + $this->fixture('Class_CosmoVar', ['id' => 'import_type_operation', 'liste' => '']); + Class_CosmoVar::addLabelInList('import_type_operation', + Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL, + 'Import total'); + + Class_CosmoVar::addLabelInList('import_type_operation', + Class_Cosmogramme_Integration::TYPE_OPERATION_INCREMENT, + 'Import incrémentiel'); + + $this->fixture('Class_CosmoVar', ['id' => 'import_format', 'liste' => '']); + Class_CosmoVar::addLabelInList('import_format', + Class_IntProfilDonnees::FORMAT_CSV, + 'CSV'); + + $this->fixture('Class_IntBib', + ['id' => 2, + 'nom_court' => 'Annexe 2', + 'sigb' => 1]); + + $this->fixture('Class_IntProfilDonnees', + ['id' => 102, + 'libelle' => 'Koha Baskets', + 'accents' => Class_IntProfilDonnees::ENCODING_UTF8, + 'type_fichier' => Class_IntProfilDonnees::FT_BASKETS, + 'format' => Class_IntProfilDonnees::FORMAT_CSV, + 'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]); + + $this->fixture('Class_Cosmogramme_Integration', + ['id' => 999, + 'bib' => Class_IntBib::find(2), + 'profil_donnees' => Class_IntProfilDonnees::find(102), + 'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL, + 'traite' => 'non', + 'fichier' => 'baskets.txt', + 'pointeur_reprise' => 0]); + + + + $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'milou_pro', + 'password' => 'secret', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL, + 'idabon' => '0006', + 'mail' => 'milou@herge.fr']); + + $this->fixture('Class_Users', + ['id' => 2, + 'login' => 'milou', + 'password' => 'secret', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 2, + 'idabon' => '0006', + 'mail' => 'milou@herge.fr']); + + + $this->fixture('Class_Users', + ['id' => 3, + 'login' => 'tintin', + 'password' => 'secret', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL, + 'mail' => 'tintin@herge.fr', + 'idabon' => '']); + + $this->fixture('Class_PanierNotice', + ['id' => 1, + 'id_sigb' => 1, + 'id_int_bib' => 999, + 'libelle' => 'ciné', + 'notices' => 'COKEENSTOCK']); + + $this->fixture('Class_PanierNotice', + ['id' => 2, + 'id_user' => 2, + 'id_sigb' => null, + 'libelle' => 'mon panier', + 'notices' => 'AFFAIRETOURNESOL']); + + $this->fixture('Class_PanierNotice', + ['id' => 3, + 'id_user' => 4, + 'id_sigb' => 1, + 'id_int_bib' => 98, + 'libelle' => 'mon autre panier', + 'notices' => 'VOL714']); + + $this->fixture('Class_PanierNotice', + ['id' => 4, + 'id_user' => 3, + 'id_sigb' => 1, + 'id_int_bib' => 999, + 'libelle' => 'will be killed', + 'notices' => 'VOL714']); + + + $this->fixture('Class_Notice', + ['id' => 23, + 'clef_alpha' => 'CASTAFIORE', + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 231, + 'id_origine' => 39925])]]); + + $this->fixture('Class_Notice', + ['id' => 24, + 'clef_alpha' => 'LUNE', + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 241, + 'id_origine' => 58265])]]); + + $this->fixture('Class_Notice', + ['id' => 45, + 'clef_alpha' => 'TIBET', + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 4511, + 'id_origine' => 72490])]]); + } + + + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(14)) + ->beCron(); + } +} + + +class PhasePanierFullImportTest extends PhasePanierTestCase { + public function _prepareFixtures() { + parent::_prepareFixtures(); + Class_Cosmogramme_Integration::find(999)->beTotalImport()->save(); + } + + /** @test */ + public function newPhaseShouldBe17() { + $this->assertTrue($this->_phase->isId(15)); + } + + /** @test */ + public function logShouldContainsPhaseLabel() { + $this->assertLogContains('Intégration des fichiers paniers'); + } + + + /** @test */ + public function numberOfBasketsShouldBeSeven() { + $this->assertCount(7, Class_PanierNotice::findAll()); + } + + + /** @test */ + public function firstBasketLibelleShouldBeCineRomans() { + $this->assertEquals('ciné-romans', Class_PanierNotice::find(1)->getLibelle()); + } + + + /** @test */ + public function basketFiveLibelleShouldBeFroidLitterature() { + $this->assertEquals('froid litterature', Class_PanierNotice::find(5)->getLibelle()); + } + + + /** @test */ + public function firstBasketShouldBeOwnedByMilou() { + $this->assertEquals('milou', Class_PanierNotice::find(1)->getUser()->getLogin()); + } + + + /** @test */ + public function firstBasketIdAbonShouldBe0006() { + $this->assertEquals('0006', Class_PanierNotice::find(1)->getIdabon()); + } + + + /** @test */ + public function secondBasketShouldNotBeModified() { + $this->assertEquals(['AFFAIRETOURNESOL'], Class_PanierNotice::find(2)->getClesNotices()); + } + + + /** @test */ + public function thirdBasketShouldNotBeModified() { + $this->assertEquals(['VOL714'], Class_PanierNotice::find(3)->getClesNotices()); + } + + + /** @test */ + public function basketAtFiveShouldBeOwnedByTintin() { + $this->assertEquals('tintin', Class_PanierNotice::find(5)->getUser()->getLogin()); + } + + + /** @test */ + public function fourthBasketShouldBeDeleted() { + $this->assertNull(Class_PanierNotice::find(4)); + } + + /** @test */ + public function litteratureShouldHave1Item() { + $this->assertEquals(1, sizeof(Class_PanierNotice::findFirstBy(['libelle' => 'froid litterature'])->getClesNotices())); + } + + + /** @test */ + public function firstBasketRecordsShouldContains3items() { + $this->assertEquals([ 'CASTAFIORE', 'LUNE'], + Class_PanierNotice::find(1)->getClesNotices()); + } + + + /** @test */ + public function basketFiveRecordsShouldContainsTIBET() { + $this->assertEquals(['TIBET'], + Class_PanierNotice::find(5)->getClesNotices()); + } + + + /** @test */ + public function logShouldContainsPanierOrphelinTrouNoir() { + $this->assertLogContains('Panier orphelin: trou noir'); + } + + /** @test */ + public function logShouldContainsPanierOrphelinVideSideral() { + $this->assertLogContains('Panier orphelin: vide sideral'); + } + + /** @test */ + public function missingIDAbonWithEmailShouldBeOk(){ + $this->assertEquals('tintin', Class_PanierNotice::findFirstBy(['libelle' => 'bd,texte'])->getUser()->getLogin()); + } +} + + + + +class PhasePanierFullImportWithCSVSemicolonTest extends PhasePanierFullImportTest { + public function _prepareFixtures() { + parent::_prepareFixtures(); + $this->fixture('Class_IntProfilDonnees', + ['id' => 103, + 'libelle' => 'Koha Baskets', + 'accents' => Class_IntProfilDonnees::ENCODING_UTF8, + 'type_fichier' => Class_IntProfilDonnees::FT_BASKETS, + 'format' => Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII, + 'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]); + + $integration=Class_Cosmogramme_Integration::find(999); + $integration->setFichier('baskets-semicolon.txt')->setProfilDonnees(Class_IntProfilDonnees::find(103)); + $integration->save(); + + } +} + + + + +class PhasePanierFullImportWithCSVPipedTest extends PhasePanierFullImportTest { + public function _prepareFixtures() { + parent::_prepareFixtures(); + $this->fixture('Class_IntProfilDonnees', + ['id' => 104, + 'libelle' => 'Koha Baskets', + 'accents' => Class_IntProfilDonnees::ENCODING_UTF8, + 'type_fichier' => Class_IntProfilDonnees::FT_BASKETS, + 'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII, + 'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]); + + + + + $integration=Class_Cosmogramme_Integration::find(999); + $integration->setFichier('baskets-piped.txt')->setProfilDonnees(Class_IntProfilDonnees::find(104)); + $integration->save(); + + } + +} + + + +class PhasePanierPartialImportTest extends PhasePanierTestCase { + public function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_Cosmogramme_Integration::find(999)->beIncrementImport()->save(); + } + + + /** @test */ + public function firstBasketRecordsShouldContainsCASTAFIORE_LUNE() { + $this->assertEquals(['COKEENSTOCK', 'CASTAFIORE', 'LUNE'], + Class_PanierNotice::find(1)->getClesNotices()); + } + + /** @test */ + public function fourthBasketShouldNotBeDeleted() { + $this->assertNotNull(Class_PanierNotice::find(4)); + } +} + + + +class PhasePanierFullImportWithWrongProfilTest extends PhasePanierTestCase { + public function _prepareFixtures() { + parent::_prepareFixtures(); + Class_IntProfilDonnees::find(102) + ->setAttributs([3 => ['champs' => 'LIBELLE']]) + ->save(); + } + + + /** @test */ + public function logShouldContainsErrorID_SIGB_ColumnRequired() { + $this->assertLogContains('Configuration: colonne ID_SIGB requise'); + } + + /** @test */ + public function logShouldContainsErrorIDABON_OR_MAIL_ColumnRequired() { + $this->assertLogContains('Configuration: colonne IDABON ou MAIL requise'); + } + + /** @test */ + public function numberOfBasketsShouldBeFour() { + $this->assertCount(4, Class_PanierNotice::findAll()); + } + +} + +?> \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseReservationTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseReservationTest.php index 639bcbd81a7e76c91ba1eaa0e40ea27f080fd0b0..a8c0511ce1d782463dea3bfbd9064c52efd0dd00 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseReservationTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseReservationTest.php @@ -20,13 +20,18 @@ */ -abstract class PhaseReservationTestCase extends Storm_Test_ModelTestCase { - protected $_log, $_phase, $_log_content, $_printer, $_printer_content; +abstract class PhaseReservationTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + protected $_phase; public function setUp() { parent::setUp(); - Storm_Model_Loader::defaultToVolatile(); + $this->_phase = $this->_buildPhase('Reservation') + ->run(); + } + + + protected function _prepareFixtures() { $this->fixture('Class_CosmoVar', ['id' => 'traitement_phase', 'valeur' => 'Base bloquée']); @@ -47,50 +52,14 @@ abstract class PhaseReservationTestCase extends Storm_Test_ModelTestCase { 'nom_court' => 'Annexe 2', 'sigb' => 1]); - $profil = $this->fixture('Class_Cosmogramme_ProfilDonnees', + $profil = $this->fixture('Class_IntProfilDonnees', ['id' => 102, 'libelle' => 'Réservations Pergame', 'accents' => 2, - 'type_fichier' => Class_Cosmogramme_ProfilDonnees::FILE_TYPE_HOLDS, + 'type_fichier' => Class_IntProfilDonnees::FT_HOLDS, 'format' => 3, 'attributs' => 'a:4:{i:0;a:6:{s:8:"type_doc";a:11:{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:6:"LIV;MS";}i:2;a:3:{s:4:"code";s:1:"2";s:5:"label";s:2:"as";s:8:"zone_995";s:3:"PER";}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:20:"DIAPO;DVD;VHS;VHD;VD";}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:"6";s:5:"label";s:3:"c;d";s:8:"zone_995";s:3:"MM;";}i:7;a:3:{s:4:"code";s:1:"7";s:5:"label";s:3:"f;k";s:8:"zone_995";s:21:"PHOTO;EST;EKTA;CPL;CP";}i:8;a:3:{s:4:"code";s:1:"8";s:5:"label";s:0:"";s:8:"zone_995";s:3:"DOS";}i:9;a:3:{s:4:"code";s:1:"9";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:10;a:3:{s:4:"code";s:2:"10";s:5:"label";s:0:"";s:8:"zone_995";s:6:"WEB;MF";}}s:17:"champ_code_barres";s:1:"f";s:11:"champ_genre";s:0:"";s:13:"champ_section";s:1:"q";s:17:"champ_emplacement";s:1:"u";s:12:"champ_annexe";s:1:"a";}i:1;a:1:{s:6:"champs";s:63:"ID_PERGAME;IDABON;ORDREABON;SUPPORT;ID_NOTICE_ORIGINE;DATE_RESA";}i:2;a:1:{s:6:"champs";s:63:"ID_PERGAME;IDABON;ORDREABON;SUPPORT;ID_NOTICE_ORIGINE;DATE_RESA";}i:3;a:1:{s:6:"champs";s:63:"ID_PERGAME;IDABON;ORDREABON;SUPPORT;ID_NOTICE_ORIGINE;DATE_RESA";}}']); - $this->_log = $this->mock() - ->whenCalled('ecrire') - ->willDo(function($content) { $this->_log_content .= $content; }); - - $this->_chrono = new Class_Cosmogramme_Integration_Chronometre(); - $this->_printer = $this->mock() - ->whenCalled('nextPutAll') - ->willDo(function($content) { $this->_printer_content .= $content; }); - - $this->_prepareFixtures(); - - $this->_phase = (new Class_Cosmogramme_Integration_PhaseReservation($this->_getPreviousPhase(), - $this->_log, - $this->_chrono)) - ->setPrinter($this->_printer) - ->run(); - } - - - protected function _getPreviousPhase() { - return null; - } - - - protected function _prepareFixtures() { - } - - - protected function assertLogContains($value) { - $this->assertContains($value, $this->_log_content); - } - - - public function tearDown() { - Storm_Model_Loader::defaultToDb(); - parent::tearDown(); } @@ -134,6 +103,7 @@ class PhaseReservationCallBackBeforeLastTest protected function _prepareFixtures() { + parent::_prepareFixtures(); $this->_time_source = $this ->mock(new Class_TimeSource()) ->whenCalled('time')->answers(mktime(0, 0, 13, 2, 4, 2015)) @@ -147,7 +117,7 @@ class PhaseReservationCallBackBeforeLastTest $this->_integration = $this->fixture('Class_Cosmogramme_Integration', ['id' => 22331, 'bib' => Class_IntBib::find(2), - 'profil_donnees' => Class_Cosmogramme_ProfilDonnees::find(102), + 'profil_donnees' => Class_IntProfilDonnees::find(102), 'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL, 'traite' => 'non', 'fichier' => 'holds.txt', @@ -197,6 +167,8 @@ class PhaseReservationCallBackBeforeLastTest } + + class PhaseReservationValidCronFirstRunTest extends PhaseReservationTestCase { protected function _getPreviousPhase() { return (new Class_Cosmogramme_Integration_Phase(12))->beCron(); @@ -204,10 +176,11 @@ class PhaseReservationValidCronFirstRunTest extends PhaseReservationTestCase { protected function _prepareFixtures() { + parent::_prepareFixtures(); $this->fixture('Class_Cosmogramme_Integration', ['id' => 22331, 'bib' => Class_IntBib::find(2), - 'profil_donnees' => Class_Cosmogramme_ProfilDonnees::find(102), + 'profil_donnees' => Class_IntProfilDonnees::find(102), 'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL, 'traite' => 'non', 'fichier' => 'holds.txt', diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseTestCase.php b/tests/library/Class/Cosmogramme/Integration/PhaseTestCase.php new file mode 100644 index 0000000000000000000000000000000000000000..d9d4320eaff3b6e0a488127b2302d287b55b0b7a --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhaseTestCase.php @@ -0,0 +1,69 @@ +<?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 Class_Cosmogramme_Integration_PhaseTestCase extends ModelTestCase { + protected + $_storm_default_to_volatile = true, + $_log_content, + $_log, + $_printer_content, + $_printer, + $_phase; + + public function setUp() { + parent::setUp(); + + $append_log = function($content) { $this->_log_content .= $content; }; + $this->_log = $this->mock() + ->whenCalled('addError')->willDo($append_log) + ->whenCalled('ecrire')->willDo($append_log); + + $this->_chrono = new Class_Cosmogramme_Integration_Chronometre(); + $this->_printer = $this->mock() + ->whenCalled('nextPutAll') + ->willDo(function($content) { $this->_printer_content .= $content; }); + + $this->_prepareFixtures(); + } + + + protected function _buildPhase($name) { + $class_name = 'Class_Cosmogramme_Integration_Phase'.ucfirst($name); + return (new $class_name($this->_getPreviousPhase(), + $this->_log, + $this->_chrono)) + ->setPrinter($this->_printer); + } + + + protected function _prepareFixtures() { + } + + + protected function assertLogContains($value) { + $this->assertContains($value, $this->_log_content); + } + + protected function _getPreviousPhase() { + return null; + } +} + +?> \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/baskets-piped.txt b/tests/library/Class/Cosmogramme/Integration/baskets-piped.txt new file mode 100644 index 0000000000000000000000000000000000000000..b5e6c772de9f023e5b1fe71fedc2fd386c95ab82 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/baskets-piped.txt @@ -0,0 +1,14 @@ +8|"trou noir"|666||1|72490 +1|"ciné-romans",cine|0006||0|39925 +1|"ciné-romans"|0006||0|399250 +1|ciné-romans|0006|milou@herge.fr|0|58265 +1|"ciné-romans"|0006||0| +6|"froid litterature"|1234|tintin@herge.fr|1|72490 +6|"froid litterature"|1234|tintin@herge.fr|1|67220 +6|"froid litterature"|1234|tintin@herge.fr|1| +7|"titi"||tintin@herge.fr|1|72490 +9|bd,texte||tintin@herge.fr|1|72490 +10|"vide sideral"|||1|72490 +|"cine"|0006||0|39925 + + diff --git a/tests/library/Class/Cosmogramme/Integration/baskets-semicolon.txt b/tests/library/Class/Cosmogramme/Integration/baskets-semicolon.txt new file mode 100644 index 0000000000000000000000000000000000000000..9da53d8dbd99b38ddfe1c60c8c5e47ea12fba9fe --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/baskets-semicolon.txt @@ -0,0 +1,14 @@ +8;"trou noir";666;;1;72490 +1;"ciné-romans";0006;;0;39925 +1;"ciné-romans";0006;;0;399250 +1;"ciné-romans";0006;milou@herge.fr;0;58265 +1;"ciné-romans";0006;;0; +6;"froid litterature";1234;tintin@herge.fr;1;72490 +6;"froid litterature";1234;tintin@herge.fr;1;67220 +6;"froid litterature";1234;tintin@herge.fr;1; +7;"titi";;tintin@herge.fr;1;72490 +9;"bd,texte";;tintin@herge.fr;1;72490 +10;"vide sideral";;;1;72490 +;"cine";0006;;0;39925 + + diff --git a/tests/library/Class/Cosmogramme/Integration/baskets.txt b/tests/library/Class/Cosmogramme/Integration/baskets.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ec9c4d8ea0b8dc3825d95486145275194393630 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/baskets.txt @@ -0,0 +1,12 @@ +8,"trou noir",666,,1,72490 +1,"ciné-romans",0006,,0,39925 +1,"ciné-romans",0006,milou@herge.fr,0,58265 +1,"ciné-romans",0006,,0, +6,"froid litterature",1234,tintin@herge.fr,1,72490 +6,"froid litterature",1234,tintin@herge.fr,1,67220 +6,"froid litterature",1234,tintin@herge.fr,1, +7,"titi",,tintin@herge.fr,1,72490 +9,"bd,texte",,tintin@herge.fr,1,72490 +10,"vide sideral",,,1,72490 +,"cine",0006,,0,39925 + diff --git a/tests/library/Class/CriteresRechercheTest.php b/tests/library/Class/CriteresRechercheTest.php index 6fd5666ff370175711c1e876ff0b688a2b09350b..d539b1b8bc2f0e4f6dc422d9d6a2f91315bbe278 100644 --- a/tests/library/Class/CriteresRechercheTest.php +++ b/tests/library/Class/CriteresRechercheTest.php @@ -362,11 +362,9 @@ class CriteresRechercheSerieTest extends AbstractControllerTestCase { /** @test */ public function visitCatalogueShouldNotBeCalled() { - $visitor = Storm_Test_ObjectWrapper::mock() + $visitor = Storm_Test_ObjectWrapper::on(new TestingSearchCriteriaVisitor()) ->whenCalled('visitCatalogue')->never() - ->whenCalled('visitSerie')->answers(true) - ->whenCalled('hasErreur')->answers(false); - + ->getWrapper(); $this->criteres_recherche->acceptVisitor($visitor); } @@ -394,21 +392,15 @@ class CriteresRechercheWithGenreTest extends AbstractControllerTestCase { /** @test */ public function visitFiltresShouldBeCalledWithG10AndG56() { - $visitor = Storm_Test_ObjectWrapper::mock() - ->whenCalled('visitFiltre') - ->answers(true) - - ->whenCalled('hasErreur') - ->answers(false) - - ->whenCalled('visitTri') - ->answers(true); - + $visitor = Storm_Test_ObjectWrapper::on(new TestingSearchCriteriaVisitor()); $this->criteres_recherche->acceptVisitor($visitor); - $this->assertEquals(['G10','G56'], $visitor->getFirstAttributeForLastCallOn('visitFiltre')); + $this->assertEquals(['G10','G56'], + $visitor->getFirstAttributeForLastCallOn('visitFiltre')); } +} -} -?> \ No newline at end of file +class TestingSearchCriteriaVisitor { + use Trait_SearchCriteriaVisitor; +} \ No newline at end of file diff --git a/tests/library/Class/Import/Typo3Fixture.php b/tests/library/Class/Import/Typo3Fixture.php index b6b630390af0bd4b41fd77eef6d9a461b7f54b71..720eeab45890d25573da0e175410c3d74253fc01 100644 --- a/tests/library/Class/Import/Typo3Fixture.php +++ b/tests/library/Class/Import/Typo3Fixture.php @@ -19,6 +19,35 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +class MockFileWriter { + protected $contents="image"; + protected $path; + protected $image; + public function fileExists() { + return false; + } + public function dirExists() { + return true; + } + public function getContents($image) { + $this->image=$image; + return $this->contents; + } + + public function getPath() { + return $this->path; + } + public function getImage() { + return $this->image; + } + public function putContents($path, $contents) { + $this->contents=$contents; + $this->path= $path; + } + +} + + class MockTypo3DB { public function findAllUsers() { @@ -136,10 +165,26 @@ class MockTypo3DB { } + public function findAllExternalSites() { + + return [ ['crdate' => '1412781027', + 'category' => 1, + 'image' => 'Federation_francaise_de_Go.JPG,fede_go.jpg', + 'title' => 'MuséoParc Alésia', + 'ext_url' => 'http://www.alesia.com/:Profil _blank', + 'tx_danpextendnews_tags' => 'Alésia, Jules César, Vercingétorix, Gaule, armée, bataille', + 'short' => null, + 'uid' => 14478, + 'pid' => 49]]; + + } + + public function findAllSites() { return [ ['crdate' => '1412781027', 'category' => 1, + 'image' => 'Federation_francaise_de_Go.JPG', 'title' => 'MuséoParc Alésia', 'ext_url' => 'http://www.alesia.com/', 'tx_danpextendnews_tags' => 'Alésia, Jules César, Vercingétorix, Gaule, armée, bataille', @@ -149,6 +194,7 @@ class MockTypo3DB { ['crdate' => '1412769359', 'category' => 1, + 'image' => '', 'title' => 'L\'ouest canadien', 'ext_url' => 'http://koha.mediathequeouestprovence.fr/cgi-bin/koha/opac-detail.pl?biblionumber=268360', 'tx_danpextendnews_tags' => 'Canada', @@ -157,6 +203,7 @@ class MockTypo3DB { 'pid' => 0], ['crdate' => '1412769359', 'category' => 1, + 'image' => '', 'title' => 'Qui a dit que les pingouins ne savaient pas taper ? ', 'ext_url' => 'http://koha.mediathequeouestprovence.fr/cgi-bin/koha/opac-detail.pl?foo=bar', 'tx_danpextendnews_tags' => 'Canada', diff --git a/tests/library/Class/Import/Typo3Test.php b/tests/library/Class/Import/Typo3Test.php index 781eab29075ba3aa103ad3dd76b50a2197749b65..432770c95bc9252cad03482c7d8d1cab86da01ec 100644 --- a/tests/library/Class/Import/Typo3Test.php +++ b/tests/library/Class/Import/Typo3Test.php @@ -533,6 +533,39 @@ class Import_Typo3CalendarTest extends Import_Typo3TestCase { +class Import_Typo3SitothequeUpdateTest extends Import_Typo3TestCase { + protected $filewriter; + public function setUp() { + parent::setUp(); + + $this->filewriter=new MockFileWriter(); + Class_Import_Typo3::setFileWriter($this->filewriter); + Class_WebService_WebSiteThumbnail::setFileWriter($this->filewriter); + $this->sito = Class_Sitotheque::findFirstBy(['titre' => 'MuséoParc Alésia']); + $this->migration->updateSites(); + } + + /** @test */ + public function imageShouldBeImported() { + $this->assertEquals('image', $this->filewriter->getContents('picto.jpg')); + + } + + /** @test */ + public function imageShouldBeFederationFrancaiseGo() { + $this->assertEquals('http://www.mediathequeouestprovence.fr/uploads/pics/Federation_francaise_de_Go.JPG',$this->filewriter->getImage()); + } + + /** @test */ + public function blankShouldBeRemovedFromUrlAndShouldLowerCasesName() { + $this->assertContains('www_alesia_com__profil.jpg', $this->filewriter->getPath()); + + } + + + +} + class Import_Typo3SitothequeTest extends Import_Typo3TestCase { public function setUp() { parent::setUp(); @@ -585,7 +618,6 @@ class Import_Typo3SitothequeTest extends Import_Typo3TestCase { } - /** @test */ public function ouestCanadienShouldStoreUidTypo3() { $this->assertEquals(14479, Class_Sitotheque::findFirstBy(['titre' => 'L\'ouest canadien'])->getCustomField('uid_typo3')); diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index c90b7e003e9e8f8b70a7e2db071a2dc9bad9612f..047fb681beab0449985643c58de29c8ae2da8e26 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/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 { @@ -36,9 +36,12 @@ abstract class TestFixtures { } -abstract class ModelTestCase extends PHPUnit_Framework_TestCase { +abstract class ModelTestCase extends Storm_Test_ModelTestCase { 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')); @@ -63,10 +66,14 @@ abstract class ModelTestCase extends PHPUnit_Framework_TestCase { protected function setUp() { Storm_Model_Abstract::unsetLoaders(); - Class_SessionFormationInscription::beVolatile(); + 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(); } diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index f6490b17c25679fe9705f7462f4b21edb32af66c..cb2dc1568dd1c28b545f74bab0074590e16143ab 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -31,14 +31,16 @@ abstract class MoteurRechercheTestCase extends Storm_Test_ModelTestCase { $this->_original_sql = Zend_Registry::get('sql'); $this->mock_sql = $this->mock(); - Zend_Registry::set('sql', $this->mock_sql); + Storm_Model_Loader::defaultToVolatile(); + Class_MoteurRecherche::setTimeSource(new TimeSourceForTest('2012-05-03 09:00:00')); } public function tearDown() { + Storm_Model_Loader::defaultToDb(); Zend_Registry::set('sql', $this->_original_sql); Class_MoteurRecherche::setTimeSource(null); parent::tearDown(); @@ -242,6 +244,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { $match_axes = 'MATCH(titres, auteurs, editeur, collection, matieres, dewey)'; $count_sql = 'Select count(*) from notices Where ' . $match_axes . ' AGAINST(%s IN BOOLEAN MODE)'; $facet_sql = 'Select id_notice, type_doc, facettes from notices Where %s limit 15000'; + return [ [['expressionRecherche' => 'Bakounine'], 'nb_mots' => 1, @@ -302,7 +305,15 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'nb_mots'=> 1, 'req_comptage' => sprintf($count_sql, "'+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP) +(S1 S12 S9)'"), 'req_liste' => "Select id_notice, MATCH(alpha_titre) AGAINST(' LOGO') as rel1, MATCH(alpha_auteur) AGAINST(' LOGO') as rel2 from notices Where " . $match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP) +(S1 S12 S9)' IN BOOLEAN MODE) order by (rel1 * 1.5) + (rel2) desc", - 'req_facettes' => sprintf($facet_sql, $match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP) +(S1 S12 S9)' IN BOOLEAN MODE)")]]; + 'req_facettes' => sprintf($facet_sql, $match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP) +(S1 S12 S9)' IN BOOLEAN MODE)")], + + [['expressionRecherche' => '', + 'digital_lib' => '1'], + 'nb_mots'=> 0, + 'req_comptage' => 'Select count(*) from notices Where type_doc >= 100', + 'req_liste' => 'Select id_notice from notices Where type_doc >= 100', + 'req_facettes' => 'Select id_notice, type_doc, facettes from notices Where type_doc >= 100 limit 15000'] + ]; } @@ -312,11 +323,11 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { */ public function lancerRechercheSimpleShouldBe($params, $nb_mots,$req_comptage ,$req_notices ,$req_facettes) { $this->mockReqProfilAndZone($req_comptage,$params); - $this->criteres_recherche= new Class_CriteresRecherche(); + $this->criteres_recherche = new Class_CriteresRecherche(); $this->moteur_recherche = new Class_MoteurRecherche(); $this->criteres_recherche->setParams($params); - $retour = $this->moteur_recherche->lancerRecherche( $this->criteres_recherche); + $retour = $this->moteur_recherche->lancerRecherche($this->criteres_recherche); $this->assertEquals(['nombre' => 10, 'nb_mots' => $nb_mots, 'statut' => '', @@ -926,4 +937,48 @@ class MoteurRechercheWithCatalogueWithNoSettingsAndUrlParamsTest extends MoteurR public function requestShouldUseProfilSettings() { $this->assertEquals('Select id_notice from notices Where (MATCH(facettes) AGAINST(\'Q5\' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST(\'+T4 +T8\' IN BOOLEAN MODE)', $this->request['req_liste']); } +} + + + +class MoteurRechercheExtendingTest extends MoteurRechercheTestCase { + protected $_engine, $_extension_sql; + + public function setUp() { + parent::setUp(); + $this->mock_sql + ->whenCalled('fetchOne') + ->answers(0) + + ->whenCalled('execute') + ->answers(true); + + $this->_engine = new Class_MoteurRecherche(); + $this->_extension_sql = "Select count(*) from notices Where MATCH(titres, auteurs, editeur, collection, matieres, dewey) AGAINST(' (VIE VIES) (GEEK GEEKS JEK)')"; + } + + + /** @test */ + public function withoutResultShouldExtend() { + $result = $this->_engine + ->lancerRecherche((new Class_CriteresRecherche()) + ->setParams(['expressionRecherche' => 'La vie des geeks'])); + + $this->assertTrue($this->mock_sql + ->methodHasBeenCalledWithParams('fetchOne', + [$this->_extension_sql])); + } + + + /** @test */ + public function withoutResultWithNoExtensionParamShouldNotExtend() { + $criteria = (new Class_CriteresRecherche()) + ->setParams(['expressionRecherche' => 'La vie des geeks', + 'no_extension' => '1']); + $this->_engine->lancerRecherche($criteria); + + $this->assertFalse($this->mock_sql + ->methodHasBeenCalledWithParams('fetchOne', + [$this->_extension_sql])); + } } \ No newline at end of file diff --git a/tests/library/Class/Multimedia/DeviceTest.php b/tests/library/Class/Multimedia/DeviceTest.php index 9f15bd401c740ee6da04da8d8dfbc883a6180ec4..499fc6a3b339e52f9974d2e4273e174ca0c182b6 100644 --- a/tests/library/Class/Multimedia/DeviceTest.php +++ b/tests/library/Class/Multimedia/DeviceTest.php @@ -179,7 +179,6 @@ class Multimedia_DeviceCurrentHoldForUserWithoutHoldAndAnotherValidHoldTest exte ->setAuthDelay(10) ->setAutohold(1) ->setSlotSize(15) - ->setAutoholdForClosingDays(1) ->save(); } diff --git a/tests/library/Class/Multimedia/LocationTest.php b/tests/library/Class/Multimedia/LocationTest.php index 4ecc4ef33575d78f2acf4b4624aeec78b88049df..287bb49adf968295b78ecb96b22fed5f4c8976b3 100644 --- a/tests/library/Class/Multimedia/LocationTest.php +++ b/tests/library/Class/Multimedia/LocationTest.php @@ -181,8 +181,7 @@ class Multimedia_LocationWithBibTest extends Multimedia_LocationWithBibTestCase /** @test */ public function getDatesOuvertureShouldAnswersAllMercrediJeudiForNextTwoMonthsWith9and19Sept() { $this->_time_source->setTime(strtotime('2012-08-05')); - $this->_location->setHoldDelayMax(60) - ->setAutoholdForClosingDays(false); + $this->_location->setHoldDelayMax(60); $this->assertEquals(['2012-08-08', '2012-08-09', '2012-08-15', '2012-08-16', '2012-08-22', '2012-08-23', @@ -195,28 +194,6 @@ class Multimedia_LocationWithBibTest extends Multimedia_LocationWithBibTestCase '2012-10-03', '2012-10-04'], $this->_location->getHoldableDays()); } - - /** @test */ - public function getDatesOuvertureMardiClosingDayShouldAnswersOpenHour0800() { - $this->_time_source->setTime(strtotime('2012-12-04')); - $this->_location->setAutoholdForClosingDays(true) - ->setOpenHour('08:00') - ->setCloseHour('17:00'); - $this->_autohold = 1; - $this->assertEquals('08:00', $this->_location->getOuvertureForDate($this->_time_source->time(), $this->_autohold)->getDebutMatin()); - - } - - /** @test */ - public function getDatesOuvertureMardiClosingDayShouldAnswersCloseHour1700() { - $this->_time_source->setTime(strtotime('2012-12-04')); - $this->_location->setAutoholdForClosingDays(true) - ->setOpenHour('08:00') - ->setCloseHour('17:00'); - $this->_autohold = 1; - $this->assertEquals('17:00', $this->_location->getOuvertureForDate($this->_time_source->time(),$this->_autohold)->getFinApresMidi()); - - } } diff --git a/tests/library/Class/NoticeTest.php b/tests/library/Class/NoticeTest.php index 76469df673c799dcc25da1082adfba059c2c16d1..b00af223c850c59a135cadb4790b6cd7efd0a2a0 100644 --- a/tests/library/Class/NoticeTest.php +++ b/tests/library/Class/NoticeTest.php @@ -118,7 +118,7 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { /** @test */ public function withoutThumbnailFetchUrlVignetteShouldAnswerVignetteActionForAjax() { - $this->assertContains('/recherche/vignette?clef=', + $this->assertContains('/recherche/vignette/clef/', $this->_notice_without_thumbnails->fetchUrlVignette()); $this->assertFalse($this->_http_client->methodHasBeenCalled('open_url')); } diff --git a/tests/library/Class/StatsNoticesTest.php b/tests/library/Class/StatsNoticesTest.php index 5bba20c63c032cfa5ff71b05bef71c4bf711ec0d..fa1e8f908214e39f50a839f67e49eda46b352836 100644 --- a/tests/library/Class/StatsNoticesTest.php +++ b/tests/library/Class/StatsNoticesTest.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_StatsNoticesTest extends Storm_Test_ModelTestCase { @@ -69,11 +69,14 @@ class Class_StatsNoticesTest extends Storm_Test_ModelTestCase { } - /** @test */ - public function notBlackListedShouldAddVisuNotice() { + /** + * @test + * @see http://forge.afi-sa.fr/issues/23151 + */ + public function notBlackListedShouldNotAddVisuNotice() { $_SERVER['REMOTE_ADDR'] = '192.168.2.12'; $this->_model->addStatVisu(12); - $this->assertTrue($this->_sql->methodHasBeenCalled('execute')); + $this->assertFalse($this->_sql->methodHasBeenCalled('execute')); } diff --git a/tests/library/Class/Systeme/PergameServiceTest.php b/tests/library/Class/Systeme/PergameServiceTest.php index e7f66d80c16ffd63712e320ca2e267d81f89834c..f65ad1d8a10c5b3048b45f84112e9e6fa6a46207 100644 --- a/tests/library/Class/Systeme/PergameServiceTest.php +++ b/tests/library/Class/Systeme/PergameServiceTest.php @@ -19,82 +19,111 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** Tests de non régression sur requetes avec IDABON non entier */ -class PergameServiceUserTest extends ModelTestCase { +abstract class PergameServiceTestCase extends ModelTestCase { + protected $pergame, $mock_sql, $old_sql, $time_source; + public function setUp() { parent::setUp(); - $user = $this->fixture('Class_Users', ['id'=>3, + + $this->mock_sql = Storm_Test_ObjectWrapper::mock(); + + $this->old_sql = Zend_Registry::get('sql'); + Zend_Registry::set('sql', $this->mock_sql); + + $user = $this->fixture('Class_Users', ['id' => 3, 'login' => 'gaz', 'password' => 'toto', - 'id_abon'=>'A-01', + 'idabon' => 'A-01', 'ordreabon' => 2]); $this->pergame = new Class_Systeme_PergameService($user); + $this->time_source = new PergameServiceTestingTimeSource(); + Class_Systeme_PergameService::setTimeSource($this->time_source); + } + + + public function tearDown() { + Zend_Registry::set('sql', $this->old_sql); + parent::tearDown(); + } +} + + + +/** Tests de non régression sur requetes avec IDABON non entier */ +class PergameServiceUserTest extends PergameServiceTestCase { + public function setUp() { + parent::setUp(); + $this->mock_sql + ->whenCalled('fetchOne') + ->with('select count(*) from prets where IDABON=\'A-01\' and ORDREABON=2 and EN_COURS=1 and DATE_RETOUR < \'2012-09-23\'') + ->answers(12) + + ->whenCalled('fetchOne') + ->with('select count(*) from prets where IDABON=\'A-01\' and ORDREABON=2 and EN_COURS=1') + ->answers(24) + + ->whenCalled('fetchOne') + ->with('select count(*) from reservations where IDABON=\'A-01\' and ORDREABON=2') + ->answers(3) + + ->whenCalled('fetchAll') + ->with('select * from prets where IDABON=\'A-01\' and ORDREABON=2 and EN_COURS=1', + false) + ->answers([]) + + ->whenCalled('fetchAll') + ->with('select * from reservations where IDABON=\'A-01\' and ORDREABON=2', + false) + ->answers([]) + + ->beStrict(); } + /** @test */ - function nbPretsEnRetardShouldNotFail() { - $this->pergame->getNbPretsEnRetard(); + public function shouldHave12OverdueLoans() { + $this->assertEquals(12, $this->pergame->getNbPretsEnRetard()); } /** @test */ - function getNbEmpruntsShouldNotFail() { - $this->pergame->getNbEmprunts(); + public function shouldHave24Loans() { + $this->assertEquals(24, $this->pergame->getNbEmprunts()); } /** @test */ - function getNbReservationsShouldNotFail() { - $this->pergame->getNbReservations(); + public function shouldHave3Holds() { + $this->assertEquals(3, $this->pergame->getNbReservations()); } /** @test */ - function getPretsShouldNotFail() { + public function getPretsShouldNotFail() { $this->pergame->getPrets(); } /** @test */ - function getReservationsShouldReturnResa() { - $this->assertEquals([],$this->pergame->getReservations()); + public function getReservationsShouldReturnResa() { + $this->assertEquals([], $this->pergame->getReservations()); } } -class PergameServiceRegleReservationTest extends ModelTestCase { - protected $pergame; - +class PergameServiceRegleReservationTest extends PergameServiceTestCase { public function setUp() { parent::setUp(); - $user = $this->fixture('Class_Users', ['id' => 3, - 'login' => 'gaz', - 'password' => 'toto', - 'id_abon' => 'A-01', - 'ordreabon' => 2]); - - $this->pergame = new Class_Systeme_PergameService($user); - $data='a:8:{s:26:"Autoriser_docs_disponibles";s:1:"1";s:13:"Max_par_carte";s:1:"3";s:16:"Max_par_document";s:1:"4";s:23:"Autoriser_prolongations";s:0:"";s:24:"Interdire_si_reservation";s:0:"";s:23:"Nombre_max_par_document";s:0:"";s:14:"Duree_en_jours";s:0:"";s:24:"Anteriorite_max_en_jours";s:0:"";}'; - $this->mock_sql = Storm_Test_ObjectWrapper::mock(); - - $this->old_sql = Zend_Registry::get('sql'); - Zend_Registry::set('sql', $this->mock_sql); + $data = 'a:8:{s:26:"Autoriser_docs_disponibles";s:1:"1";s:13:"Max_par_carte";s:1:"3";s:16:"Max_par_document";s:1:"4";s:23:"Autoriser_prolongations";s:0:"";s:24:"Interdire_si_reservation";s:0:"";s:23:"Nombre_max_par_document";s:0:"";s:14:"Duree_en_jours";s:0:"";s:24:"Anteriorite_max_en_jours";s:0:"";}'; $this->mock_sql ->whenCalled('fetchOne') ->answers($data); - $this->fixture('Class_IntBib', ['id' => 2, - 'comm_params'=> $data]); - } - - - public function tearDown() { - Zend_Registry::set('sql', $this->old_sql); - parent::tearDown(); + $this->fixture('Class_IntBib', ['id' => 2, 'comm_params'=> $data]); } diff --git a/tests/library/Class/UrlTest.php b/tests/library/Class/UrlTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f8a58c11be1299fbd3c398c6a548ec1fa59fe486 --- /dev/null +++ b/tests/library/Class/UrlTest.php @@ -0,0 +1,66 @@ +<?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 UrlBaseUrlTest extends PHPUnit_Framework_TestCase { + protected $_server_backup; + + public function setUp() { + parent::setUp(); + $this->_server_backup = $_SERVER; + } + + public function tearDown() { + $_SERVER = $this->_server_backup; + parent::tearDown(); + } + + + /** @test */ + public function bokehInstalledInASubdirectory() { + $_SERVER['SCRIPT_NAME'] = '/home/tom/public_html/bokeh/index.php'; + $this->assertEquals('/home/tom/public_html/bokeh', + Class_Url::baseUrl()); + } + + + /** @test */ + public function bokehInstalledAtRoot() { + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $this->assertEquals('', + Class_Url::baseUrl()); + } + + + /** @test */ + public function bokehInstalledWithApacheUserMod() { + $_SERVER['SCRIPT_NAME'] = '/home/tom/public_html/bokeh/index.php'; + $this->assertEquals('/home/tom/public_html/bokeh', + Class_Url::baseUrl()); + } + + + /** @test */ + public function absoluteUrlShouldReturnCorrectSyntax() { + $this->assertContains('http://' . $_SERVER['SERVER_NAME'] . '/', Class_Url::absolute(['module' => 'admin', + 'controller' => 'cms', + 'action' => 'index'])); + } +} diff --git a/tests/library/Class/UsersTest.php b/tests/library/Class/UsersTest.php index ebf2df944b981b960b5894bc5d371c90c7687a72..e6bc78bc270bfb47452faa2cad5177ac1d944f3e 100644 --- a/tests/library/Class/UsersTest.php +++ b/tests/library/Class/UsersTest.php @@ -604,7 +604,10 @@ class UsersLostPassTest extends UsersMailingActionTestCase { -class UsersFicheAbonneTest extends Storm_Test_ModelTestCase { +class UsersFicheAbonneTest extends ModelTestCase { + protected + $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); Zend_Registry::get('translate')->setLocale('fr'); @@ -663,20 +666,20 @@ class UsersFicheAbonneTest extends Storm_Test_ModelTestCase { /** @test */ public function withoutIdAbonGetEmpruntsShouldReturnEmptyArray() { - $this->assertEquals(array(),$this->patrick->getEmprunts()); + $this->assertEquals(0,$this->patrick->getEmprunts()->count()); } /** @test */ public function withoutIdAbonGetReservationssShouldReturnEmptyArray() { - $this->assertEquals(array(),$this->patrick->getReservations()); + $this->assertEquals([],$this->patrick->getReservations()); } /** @test */ public function getEmpruntsShouldConnectToWebService() { - $this->assertEquals(array($this->pret_alice, $this->pret_alien, $this->pret_potter), - $this->amadou->getEmprunts()); + $this->assertEquals([$this->pret_alice, $this->pret_alien, $this->pret_potter], + (array)$this->amadou->getEmprunts()); } diff --git a/tests/library/Class/WebService/Dilicom/HubTest.php b/tests/library/Class/WebService/Dilicom/HubTest.php index 2655ed4186e58f105fb6035b851df45e1f7718d3..583529a1322b0bee95a7867553d93e0e5ecfaf31 100644 --- a/tests/library/Class/WebService/Dilicom/HubTest.php +++ b/tests/library/Class/WebService/Dilicom/HubTest.php @@ -18,10 +18,12 @@ * 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/DilicomFixtures.php'; abstract class Class_Webservice_Dilicom_HubTestCase extends Storm_Test_ModelTestCase { public function setUp() { parent::setUp(); + Storm_Model_Loader::defaultToVolatile(); RessourcesNumeriquesFixtures::activateDilicom(); @@ -31,11 +33,21 @@ abstract class Class_Webservice_Dilicom_HubTestCase extends Storm_Test_ModelTest $this->_response = json_encode(['requestId' => 'xxx', 'returnStatus' => 'OK', 'returnMessage' => []]); + + $this->_http->whenCalled('setAuth') + ->with('afi-bib', 'secretPassword') + ->answers(null) + ->beStrict(); + + + $this->book = (new DilicomFixtures())->albumTotemThora(); } + public function tearDown() { Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null); RessourcesNumeriquesFixtures::deactivateDilicom(); + Storm_Model_Loader::defaultToDb(); parent::tearDown(); } } @@ -43,16 +55,6 @@ abstract class Class_Webservice_Dilicom_HubTestCase extends Storm_Test_ModelTest class Class_Webservice_Dilicom_HubDeclareIpTest extends Class_Webservice_Dilicom_HubTestCase { - public function setUp() { - parent::setUp(); - - $this->_http->whenCalled('setAuth') - ->with('afi-bib', 'secretPassword') - ->answers(null) - ->beStrict(); - - } - /** @test */ public function savingDilicomPnbIPAddressShouldCallWebserviceDeclareIP() { $this->_http->whenCalled('open_url') @@ -83,4 +85,54 @@ class Class_Webservice_Dilicom_HubDeclareIpTest extends Class_Webservice_Dilicom $this->assertTrue($this->_http->methodHasBeenCalled('open_url')); } } + + + + +class Class_Webservice_Dilicom_HubUpdateStatusSuccessfulTest extends Class_Webservice_Dilicom_HubTestCase { + public function setUp() { + parent::setUp(); + + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/getLoanStatus?glnContractor=123456789&orderLineId[0]=x321') + ->answers(DilicomFixtures::getLoanStatusResponse()) + ->beStrict(); + + (new Class_WebService_BibNumerique_Dilicom_Hub())->updateStatus($this->book); + $this->loan_constraint = Class_Album_UsageConstraint::loanConstraint($this->book); + } + + + /** @test */ + public function numberOfSimultaneousLoansRemaningShouldBeFiveOnSuccessfulUpddate() { + $this->assertEquals(5, $this->loan_constraint->numberOfSimultaneousLoansRemaning()); + } + + + /** @test */ + public function loanQuantityRemainingShouldBe24OnSuccessfulUpdate() { + $this->assertEquals(24, $this->loan_constraint->quantityOfLoansRemaining()); + } +} + + + + +class Class_Webservice_Dilicom_HubUpdateStatusErrorTest extends Class_Webservice_Dilicom_HubTestCase { + /** @test */ + public function numberOfSimultaneousLoansRemaningShouldNotHaveBeenUpdatedOnError() { + $this->_http + ->whenCalled('open_url') + ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/getLoanStatus?glnContractor=123456789&orderLineId[0]=x321') + ->answers(DilicomFixtures::getLoanStatusErrorResponse()) + ->beStrict(); + + (new Class_WebService_BibNumerique_Dilicom_Hub())->updateStatus($this->book); + + + $this->assertEquals(48, + Class_Album_UsageConstraint::loanConstraint($this->book)->numberOfSimultaneousLoansRemaning()); + } +} ?> \ No newline at end of file diff --git a/tests/library/Class/WebService/Dilicom/PNBOffersParserTest.php b/tests/library/Class/WebService/Dilicom/PNBOffersParserTest.php index cba6a0806fc2957a2cc592ef2db454152f8fefda..72c68945c8e4b4dd632e9ec2fba18beb67faf939 100644 --- a/tests/library/Class/WebService/Dilicom/PNBOffersParserTest.php +++ b/tests/library/Class/WebService/Dilicom/PNBOffersParserTest.php @@ -32,6 +32,9 @@ class DilicomPNBOfferParserTest extends Storm_Test_ModelTestCase { Class_WebService_Abstract::setDefaultHttpClient($this->_http_client); Storm_Model_Loader::defaultToVolatile(); + + Class_Album_UsageConstraint::setTimeSource(new TimeSourceForTest('2014-05-02 14:14:14')); + $this->_books = Class_WebService_BibNumerique_Dilicom_PNBOffersFile::booksFromXML($xml); } @@ -95,6 +98,15 @@ class DilicomPNBOfferParserTest extends Storm_Test_ModelTestCase { } + /** + * @depends firstAlbumShouldBePlusJamaisSansElle + * @test + */ + public function firstAlbumShouldHaveOneItem($album) { + $this->assertCount(1, $album->getItems()); + } + + /** * @depends firstAlbumShouldBePlusJamaisSansElle * @test @@ -131,6 +143,15 @@ class DilicomPNBOfferParserTest extends Storm_Test_ModelTestCase { } + /** + * @depends firstAlbumShouldBePlusJamaisSansElle + * @test + */ + public function firstAlbumAvailabilityEndDateBeAsExpected($album) { + $this->assertEquals('2019-05-01T14:14:14+0200', $album->getUsageConstraints()->getAvailabilityEndDate()); + } + + /** * @depends firstAlbumShouldBePlusJamaisSansElle * @test @@ -193,6 +214,25 @@ class DilicomPNBOfferParserTest extends Storm_Test_ModelTestCase { } -} + /** + * @depends firstAlbumShouldBePlusJamaisSansElle + * @test + */ + public function removeUsageConstraintsAndAskForLoanQuantityShouldAnswers0($album) { + $album->setUsageConstraints(new Class_Album_UsageConstraints()); + $this->assertEquals(0, $album->getUsageConstraints()->getLoanQuantity()); + } + + + /** + * @depends firstAlbumShouldBePlusJamaisSansElle + * @test + */ + public function removeUsageConstraintsAndAskForValidityOfferShouldReturnFalse($album) { + $album->setUsageConstraints(new Class_Album_UsageConstraints()); + $this->assertFalse($album->getUsageConstraints()->isAValidOffer()); + } + +} ?> \ No newline at end of file diff --git a/tests/library/Class/WebService/Jamendo/JamendoTest.php b/tests/library/Class/WebService/Jamendo/JamendoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..07a210695d58f0e8492ee36ddbbb7b4be735cd07 --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/JamendoTest.php @@ -0,0 +1,440 @@ +<?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 JamendoFixtures { + public static function prepare() { + Class_AdminVar::newInstanceWithId('JAMENDO_CLIENT_ID', + ['valeur' => 'f2345']); + + $base_url = 'https://api.jamendo.com/v3.0/albums/tracks?format=json&order=id_desc&limit=10&client_id=f2345'; + $mock_http = Storm_Test_ObjectWrapper::mock(); + foreach([0,1,2] as $page) { + $mock_http + ->whenCalled('open_url') + ->with($base_url.'&offset='.$page*10) + ->answers(file_get_contents(__DIR__.'/tracks_page_'.$page.'.json')); + } + $mock_http + ->whenCalled('open_url') + ->with($base_url.'&id=146203') + ->answers(file_get_contents(__DIR__.'/album_tracks.json')) + + ->whenCalled('open_url') + ->with('https://api.jamendo.com/v3.0/albums/musicinfo?format=json&order=id_desc&limit=10&client_id=f2345&id=146203') + ->answers(file_get_contents(__DIR__.'/album_tracks_info.json')) + + ->whenCalled('open_url') + ->answers(''); + + Class_WebService_BibNumerique_Jamendo::setDefaultHttpClient($mock_http); + } +} + + + +abstract class JamendoTestCase extends ModelTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + JamendoFixtures::prepare(); + } +} + + + + +class JamendoImportTracksFromUrlTest extends JamendoTestCase { + public function setUp() { + parent::setUp(); + $this->_jamendo = new Class_WebService_BibNumerique_Jamendo(); + $this->_jamendo->importFromUrl('https://www.jamendo.com/fr/list/a146203/tracks'); + } + + + /** @test */ + public function albumTracksShouldHaveBeenCreated() { + $this->assertNotNull($album = Class_Album::find(1)); + $this->assertEquals('Tracks', $album->getTitre()); + } + + + /** @test */ + public function albumTracksDescriptionShouldBePremierAlbum() { + $this->assertContains('<p>Premier album d\'Alvaro', Class_Album::find(1)->getDescription()); + } + + + /** @test */ + public function tagsShouldContainsGuitarRock() { + $this->assertContains('guitar;rock', Class_Album::find(1)->getTags()); + } + + + /** @test */ + public function importingAlbumTwiceShouldNotRecreateIt() { + $this->_jamendo->importFromUrl('https://www.jamendo.com/fr/list/a146203/tracks'); + $this->assertCount(1, Class_Album::findAll()); + } + + + /** @test */ + public function importingWithWrongUrlShouldNotCreateAlbum() { + $this->assertNull($this->_jamendo->importFromUrl('https://www.jamendo.com/fr/list/')); + } +} + + + + +class JamendoWithTwoResultPagesTest extends JamendoTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', ['id' => 'types_docs', + 'liste' => '']); + + $this->_jamendo = new Class_WebService_BibNumerique_Jamendo(); + $this->_jamendo->harvest(); + } + + + /** @test */ + public function jamendoServiceShouldBeEnabled() { + $this->assertTrue($this->_jamendo->isEnabled()); + } + + + /** @test */ + public function getNameShouldAnswersJamendo() { + $this->assertEquals('Jamendo', $this->_jamendo->getName()); + } + + + /** @test */ + public function numberOfAlbumsShouldBeTwenty() { + $this->assertCount(20, Class_Album::findAll()); + } + + + /** @test */ + public function firstAlbumNoticeShouldBeTypeDocSonore() { + $album = Class_Album::find(1); + $album->index(); + $this->assertTrue($album->getNotice()->isTypeDocSonore()); + } +} + + + + +class JamendoAlbumEcosTest extends JamendoTestCase{ + public function setUp() { + parent::setUp(); + + $json = json_decode(file_get_contents(__DIR__.'/tracks_page_0.json')); + $this->_album = (new Class_WebService_BibNumerique_Jamendo_Album($json->results[0]))->import(); + $this->_album = Class_Album::find(1); + $this->_album->index(); + } + + + /** @test */ + public function idShouldBe146232() { + $this->assertEquals(146232, $this->_album->getIdOrigine()); + } + + + /** @test */ + public function nameShouldBeEcos() { + $this->assertEquals('Ecos', $this->_album->getTitre()); + } + + + /** @test */ + public function categoryNameShouldBeJamendo() { + $this->assertEquals('Jamendo', $this->_album->getCategorie()->getLibelle()); + } + + + /** @test */ + public function authorShouldBeDamanegra() { + $this->assertContains('damanegra', $this->_album->getAuthorsNames()); + } + + + /** @test */ + public function posterShouldBeCovers1200DotJPG() { + $this->assertEquals('https://imgjam1.jamendo.com/albums/s146/146232/covers/1.200.jpg', + $this->_album->getPoster()); + + } + + + /** @test */ + public function shouldBeAudioRecord() { + $this->assertTrue($this->_album->isAudioRecord()); + + } + + + /** @test */ + public function noticeShouldHaveThreeTracks() { + $this->assertCount(3, + $this->_album->getNotice()->getMorceaux()['morceaux'][1]); + } + + + /** @test */ + public function albumTracksShouldBeAudio() { + $this->assertCount(3, $this->_album->getAudioTracks()); + } + + + /** @test */ + public function typeDocShouldBeJamendo() { + $this->assertEquals(Class_TypeDoc::JAMENDO, + $this->_album->getTypeDoc()->getId()); + } + + + /** @test */ + public function yearShouldBe2015() { + $this->assertEquals(2015, $this->_album->getAnnee()); + } + + + /** @test */ + public function numberOfResourcesShouldBeThree() { + $album = $this->_album; + $this->assertCount(3, $album->getRessources()); + return $album->getRessources(); + } + + + /** + * @depends numberOfResourcesShouldBeThree + * @test + */ + public function firstTrackTitleShouldBeEcosDeMi($ressources) { + $this->assertEquals('Ecos_de_mi', $ressources[0]->getTitre()); + } + + + /** + * @depends numberOfResourcesShouldBeThree + * @test + */ + public function firstTrackLicenseShouldBeBY_ND_30($ressources) { + $this->assertEquals('BY-ND/3.0', $ressources[0]->getLicense()); + } + + + /** + * @depends numberOfResourcesShouldBeThree + * @test + */ + public function secondTrackLicenseShouldBeBY_NC_SA_30($ressources) { + $this->assertEquals('BY-NC-SA/3.0', $ressources[1]->getLicense()); + } + + + /** + * @depends numberOfResourcesShouldBeThree + * @test + */ + public function firstTrackDurationShouldBe198($ressources) { + $this->assertEquals(198, $ressources[0]->getDuration()); + } + + + /** + * @depends numberOfResourcesShouldBeThree + * @test + */ + public function firstUrlShouldBeTrackId1219106($ressources) { + $this->assertEquals('https://storage-new.newjamendo.com/?trackid=1219106&format=mp31&from=app-f919df7d', + $ressources[0]->getUrl()); + } +} + + + + +class JamendRenderAlbumInnefectiveEveningTest extends ViewHelperTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + JamendoFixtures::prepare(); + + $json = json_decode(file_get_contents(__DIR__.'/tracks_page_0.json')); + $album = (new Class_WebService_BibNumerique_Jamendo_Album($json->results[2]))->import(); + + $helper = new ZendAfi_View_Helper_RenderAlbum(); + $helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_html = $helper->renderAlbum($album); + } + + + /** @test */ + public function audioPlayerShouldBeLoaded() { + $this->assertXPath($this->_html, '//audio[@preload]'); + } + + + /** @test */ + public function whatABadDayTrackShouldBePresent() { + $this->assertXPath($this->_html, + '//ol//li[1]//a[@data-src="https://storage-new.newjamendo.com/?trackid=1219079&format=mp31&from=app-f919df7d"]'); + } + + + /** @test */ + public function whatABadDayLicenseShouldLinkToBy30() { + $this->assertXPath($this->_html, + '//ol//li[1]//a[@href="http://creativecommons.org/licenses/by/3.0/deed.fr"]', + $this->_html); + } + + /** @test */ + public function whatABadDayLicenseShouldDisplayImageByPng() { + $this->assertXPath($this->_html, + '//ol//li[1]//a/img[contains(@src, "public/opac/images/cc/by.png")]', + $this->_html); + } + + + /** @test */ + public function linkToAlbumOnJamendoShouldBePresent() { + $this->assertXPathContentContains($this->_html, + '//p/a[@href="https://www.jamendo.com/fr/list/a146222"]', + 'Voir l\'album "Turin, No?" sur Jamendo'); + } +} + + + + +abstract class HarvestControllerJamendoTestCase extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + JamendoFixtures::prepare(); + } +} + + + +class HarvestControllerJamendoTest extends HarvestControllerJamendoTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/harvest/jamendo-browse', true); + + } + + + /** @test */ + public function pageShouldContainsHarvestForm() { + $this->assertXPath('//form[@id="source_harvest"]', + $this->_response->getBody()); + } + + + /** @test */ + public function pageShouldContainsImportForm() { + $this->assertXPath('//form[@id="import"]//input[@type="url"][@name="url"]', + $this->_response->getBody()); + } + + + /** @test */ + public function importFormShouldHaveASubmitButton() { + $this->assertXPath('//form[@id="import"]//input[@type="submit"]'); + } +} + + + +class HarvestControllerJamendoImportActionTest extends HarvestControllerJamendoTestCase { + /** @test */ + public function importTracksAlbumShouldCreateAlbum() { + $this->postDispatch('/admin/harvest/jamendo-browse', + ['url' => 'https://www.jamendo.com/fr/list/a146203/tracks']); + $this->assertEquals('Tracks', Class_Album::find(1)->getTitre()); + } + + + /** @test */ + public function importAlbumsShouldRedirectToPageAlbum() { + $this->postDispatch('/admin/harvest/jamendo-browse', + ['url' => 'https://www.jamendo.com/fr/list/a146203/tracks']); + $this->assertRedirectTo('/admin/album/edit_album/id/1'); + + } + + + /** @test */ + public function importAlbumsShouldNotifySuccessfullImport() { + $this->postDispatch('/admin/harvest/jamendo-browse', + ['url' => 'https://www.jamendo.com/fr/list/a146203/tracks']); + $this->assertFlashMessengerContentContains('Album "Tracks" importé de Jamendo'); + } + + + /** @test */ + public function importAlbumsWithNoURlShouldDisplayError() { + $this->postDispatch('/admin/harvest/jamendo-browse', + ['url' => '']); + $this->assertXPathContentContains('//ul[@class="errors"]//li', 'Une valeur est requise'); + } + + + /** @test */ + public function importAlbumsWithWrongURlShouldDisplayError() { + $this->postDispatch('/admin/harvest/jamendo-browse', + ['url' => 'http://google.fr']); + $this->assertXPathContentContains('//ul[@class="errors"]//li', 'URL invalide'); + } +} + + + +class HarvestControllerJamendoAjaxActionsTest extends HarvestControllerJamendoTestCase { + /** @test */ + public function ajaxActionShouldHarvestPageOne() { + $this->dispatch('/admin/harvest/jamendo-ajax/page/1', true); + $this->assertContains('{"total_count":"146232","current_page":"1","page_count":14624,"has_next":true}', $this->_response->getBody()); + } + + + /** @test */ + public function ajaxActionShouldHarvestPageTwo() { + $this->dispatch('/admin/harvest/jamendo-ajax/page/2', true); + $this->assertContains('{"total_count":"146203","current_page":"2","page_count":14621,"has_next":true}', $this->_response->getBody()); + } +} + +?> \ No newline at end of file diff --git a/tests/library/Class/WebService/Jamendo/album_tracks.json b/tests/library/Class/WebService/Jamendo/album_tracks.json new file mode 100644 index 0000000000000000000000000000000000000000..d3f7aba3da1bc83511f9fd1feb19f989b73447dc --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/album_tracks.json @@ -0,0 +1,103 @@ +{ + "headers":{ + "status":"success", + "code":0, + "error_message":"", + "warnings":"", + "results_count":10 + }, + "results":[ + { + "id":"146203", + "name":"Tracks", + "releasedate":"2015-04-08", + "artist_id":"467750", + "artist_name":"Alvaro Galan", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146203\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146203\/mp32\/", + "tracks":[ + { + "id":"1218917", + "position":"1", + "name":"Intro - Simus Veritatis", + "duration":"111", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218917&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218917\/mp32\/" + }, + { + "id":"1218921", + "position":"2", + "name":"Sunset Fire", + "duration":"228", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218921&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218921\/mp32\/" + }, + { + "id":"1218920", + "position":"3", + "name":"Strings", + "duration":"193", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218920&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218920\/mp32\/" + }, + { + "id":"1218918", + "position":"4", + "name":"Milky Way", + "duration":"233", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218918&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218918\/mp32\/" + }, + { + "id":"1218919", + "position":"5", + "name":"Fenix", + "duration":"242", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218919&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218919\/mp32\/" + }, + { + "id":"1218916", + "position":"6", + "name":"Night Dance", + "duration":"119", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218916&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218916\/mp32\/" + }, + { + "id":"1218922", + "position":"7", + "name":"Golden Sickle", + "duration":"229", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218922&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218922\/mp32\/" + }, + { + "id":"1218923", + "position":"8", + "name":"Yours", + "duration":"203", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218923&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218923\/mp32\/" + }, + { + "id":"1218924", + "position":"9", + "name":"Dogma", + "duration":"280", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218924&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218924\/mp32\/" + } + ] + } + ] +} diff --git a/tests/library/Class/WebService/Jamendo/album_tracks_info.json b/tests/library/Class/WebService/Jamendo/album_tracks_info.json new file mode 100644 index 0000000000000000000000000000000000000000..2d45312c00711c2ce6ebf3b0e2025342b9c111dc --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/album_tracks_info.json @@ -0,0 +1 @@ +{"headers":{"status":"success","code":0,"error_message":"","warnings":"","results_count":1},"results":[{"id":"146203","name":"Tracks","releasedate":"2015-04-08","artist_id":"467750","artist_name":"Alvaro Galan","image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146203\/covers\/1.200.jpg","zip":"https:\/\/storage-new.newjamendo.com\/download\/a146203\/mp32\/","shorturl":"http:\/\/jamen.do\/l\/a146203","shareurl":"http:\/\/www.jamendo.com\/list\/a146203","musicinfo":{"tags":["guitar","rock","symphonic","pop","epic","ambient","metal","sintetizer","violas","motivational","violins","flute","strings"],"description":{"en":"<p>First solo album by Alvaro Galan. Enjoy ;)<\/p>","fr":"<p>Premier album d'Alvaro Galan</p>","es":"<p>Primer álbum en solitario del músico y compositor Álvaro Galán<\/p>","de":"","pl":"","it":""}}}]} diff --git a/tests/library/Class/WebService/Jamendo/tracks_page_0.json b/tests/library/Class/WebService/Jamendo/tracks_page_0.json new file mode 100644 index 0000000000000000000000000000000000000000..a98f3aa6c410b3d29148679965bb36baf96d7eff --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/tracks_page_0.json @@ -0,0 +1,643 @@ +{ + "headers":{ + "status":"success", + "code":0, + "error_message":"", + "warnings":"", + "results_count":10 + }, + "results":[ + { + "id":"146232", + "name":"Ecos", + "releasedate":"2015-04-09", + "artist_id":"467822", + "artist_name":"damanegra", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146232\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146232\/mp32\/", + "tracks":[ + { + "id":"1219106", + "position":"1", + "name":"Ecos_de_mi", + "duration":"198", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219106&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219106\/mp32\/" + }, + { + "id":"1219118", + "position":"2", + "name":"Alma", + "duration":"151", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219118&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219118\/mp32\/" + }, + { + "id":"1219120", + "position":"3", + "name":"Al-otro-lado", + "duration":"168", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219120&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219120\/mp32\/" + } + ] + }, + { + "id":"146228", + "name":"Childrens - 001", + "releasedate":"2015-04-09", + "artist_id":"466600", + "artist_name":"MuswayStudio", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146228\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146228\/mp32\/", + "tracks":[ + { + "id":"1219099", + "position":"1", + "name":"Childrens - 001 - 1", + "duration":"135", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219099&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219099\/mp32\/" + }, + { + "id":"1219100", + "position":"2", + "name":"Childrens - 001 - 2", + "duration":"79", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219100&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219100\/mp32\/" + }, + { + "id":"1219101", + "position":"3", + "name":"Childrens - 001 - 3", + "duration":"38", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219101&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219101\/mp32\/" + } + ] + }, + { + "id":"146222", + "name":"Turin, No?", + "releasedate":"2015-04-09", + "artist_id":"436021", + "artist_name":"Barcroft45", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146222\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146222\/mp32\/", + "tracks":[ + { + "id":"1219079", + "position":"1", + "name":"Turin", + "duration":"98", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219079&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219079\/mp32\/" + } + ] + }, + { + "id":"146220", + "name":"Ineffective evening", + "releasedate":"2015-04-09", + "artist_id":"370953", + "artist_name":"Pidelta sound", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146220\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146220\/mp32\/", + "tracks":[ + { + "id":"1218996", + "position":"1", + "name":"Thinking of you", + "duration":"458", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218996&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218996\/mp32\/" + }, + { + "id":"1218997", + "position":"2", + "name":"What a bad day (on the beach)", + "duration":"261", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218997&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218997\/mp32\/" + }, + { + "id":"1218998", + "position":"3", + "name":"Night flight (version one)", + "duration":"134", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218998&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218998\/mp32\/" + }, + { + "id":"1219037", + "position":"4", + "name":"Digital improvisations", + "duration":"349", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219037&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219037\/mp32\/" + }, + { + "id":"1219038", + "position":"5", + "name":"Ineffective evening", + "duration":"199", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219038&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219038\/mp32\/" + }, + { + "id":"1219039", + "position":"6", + "name":"Romantic (version one)", + "duration":"53", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219039&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219039\/mp32\/" + }, + { + "id":"1219042", + "position":"7", + "name":"Late at night", + "duration":"202", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219042&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219042\/mp32\/" + }, + { + "id":"1219043", + "position":"8", + "name":"Signs of life", + "duration":"298", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219043&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219043\/mp32\/" + }, + { + "id":"1219044", + "position":"9", + "name":"Difficult love (version one)", + "duration":"287", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219044&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219044\/mp32\/" + }, + { + "id":"1219058", + "position":"10", + "name":"What about you", + "duration":"149", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219058&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219058\/mp32\/" + }, + { + "id":"1219059", + "position":"11", + "name":"Romantic (version two)", + "duration":"72", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219059&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219059\/mp32\/" + }, + { + "id":"1219060", + "position":"12", + "name":"Donna di citt\u00e0 (guitar and voice)", + "duration":"326", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219060&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219060\/mp32\/" + }, + { + "id":"1219061", + "position":"13", + "name":"Per te (guitar and voice)", + "duration":"302", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219061&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219061\/mp32\/" + } + ] + }, + { + "id":"146219", + "name":"NADA MUDOU (LIVE IN THE STUDIO)", + "releasedate":"2015-04-09", + "artist_id":"368175", + "artist_name":"marcello correa e castro", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146219\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146219\/mp32\/", + "tracks":[ + { + "id":"1219064", + "position":"1", + "name":"NADA (Nothing)", + "duration":"206", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219064&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219064\/mp32\/" + }, + { + "id":"1219047", + "position":"2", + "name":"MEU CANTO, MEU CH\u00c3O (Live in The Studio)", + "duration":"305", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219047&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219047\/mp32\/" + }, + { + "id":"1219062", + "position":"3", + "name":"NADA MUDOU (LIVE IN THE STUDIO)", + "duration":"348", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219062&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219062\/mp32\/" + }, + { + "id":"1219063", + "position":"4", + "name":"BAILARINAS NEGRAS (LIVE IN THE STUDIO)", + "duration":"175", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219063&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219063\/mp32\/" + } + ] + }, + { + "id":"146217", + "name":"Beats of the Streets", + "releasedate":"2015-04-09", + "artist_id":"349710", + "artist_name":"Ray Poima", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146217\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146217\/mp32\/", + "tracks":[ + { + "id":"1219052", + "position":"1", + "name":"Ray Poima - Beats of the streets (Edit)", + "duration":"126", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219052&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219052\/mp32\/" + }, + { + "id":"1219051", + "position":"2", + "name":"Ray Poima - Beats of the streets (Original Mix)", + "duration":"226", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219051&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219051\/mp32\/" + } + ] + }, + { + "id":"146216", + "name":"NOPE", + "releasedate":"2015-04-09", + "artist_id":"337965", + "artist_name":"Branton", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146216\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146216\/mp32\/", + "tracks":[ + { + "id":"1218701", + "position":"1", + "name":"Desprektis", + "duration":"422", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218701&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218701\/mp32\/" + }, + { + "id":"1218700", + "position":"2", + "name":"Give It Like This", + "duration":"254", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218700&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218700\/mp32\/" + }, + { + "id":"1218699", + "position":"3", + "name":"Monolith", + "duration":"291", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218699&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218699\/mp32\/" + }, + { + "id":"1217919", + "position":"4", + "name":"Dogma Essence QQ", + "duration":"347", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1217919&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1217919\/mp32\/" + }, + { + "id":"1217917", + "position":"5", + "name":"Mr.McDave QQ", + "duration":"282", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1217917&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1217917\/mp32\/" + } + ] + }, + { + "id":"146214", + "name":"STORMWIND - Il Combo di Viale Firenze 1994", + "releasedate":"2015-04-09", + "artist_id":"467768", + "artist_name":"Luca Marzetti", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146214\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146214\/mp32\/", + "tracks":[ + { + "id":"1219036", + "position":"1", + "name":"Dimmi cos'\u00e8", + "duration":"347", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219036&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219036\/mp32\/" + }, + { + "id":"1219040", + "position":"2", + "name":"Ritornerai", + "duration":"264", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219040&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219040\/mp32\/" + }, + { + "id":"1219085", + "position":"3", + "name":"Il mio cuore ancora", + "duration":"329", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219085&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219085\/mp32\/" + }, + { + "id":"1219088", + "position":"4", + "name":"Dove trovar le parole", + "duration":"308", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219088&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219088\/mp32\/" + }, + { + "id":"1219089", + "position":"5", + "name":"Wake love", + "duration":"275", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219089&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219089\/mp32\/" + }, + { + "id":"1219097", + "position":"6", + "name":"Come cielo e mare", + "duration":"284", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219097&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219097\/mp32\/" + } + ] + }, + { + "id":"146212", + "name":"Tarvo M. - En Directo", + "releasedate":"2015-04-09", + "artist_id":"459175", + "artist_name":"gldjproductions", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146212\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146212\/mp32\/", + "tracks":[ + { + "id":"1219000", + "position":"1", + "name":"Talviaika (Kesaika)", + "duration":"142", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219000&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219000\/mp32\/" + }, + { + "id":"1219001", + "position":"2", + "name":"Huamenta Ylta (Moi, Terve)", + "duration":"152", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219001&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219001\/mp32\/" + }, + { + "id":"1219005", + "position":"3", + "name":"Silence", + "duration":"173", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219005&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219005\/mp32\/" + }, + { + "id":"1219002", + "position":"4", + "name":"Yhdistetty (Zauberton)", + "duration":"197", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219002&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219002\/mp32\/" + }, + { + "id":"1219004", + "position":"5", + "name":"Confidence", + "duration":"163", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219004&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219004\/mp32\/" + }, + { + "id":"1219003", + "position":"6", + "name":"Horizon (Nadiiri)", + "duration":"241", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219003&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219003\/mp32\/" + }, + { + "id":"1219007", + "position":"7", + "name":"Emanuel", + "duration":"194", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219007&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219007\/mp32\/" + }, + { + "id":"1219006", + "position":"8", + "name":"Uusi Vuosi (Marraskuu\/Tuurilat)", + "duration":"223", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219006&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219006\/mp32\/" + }, + { + "id":"1219010", + "position":"9", + "name":"Riippumattomuus (Independence)", + "duration":"164", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219010&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219010\/mp32\/" + }, + { + "id":"1219009", + "position":"10", + "name":"No quiero ver lagrimas", + "duration":"221", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219009&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219009\/mp32\/" + }, + { + "id":"1219008", + "position":"11", + "name":"Olen Hyppassin (In a Jump)", + "duration":"140", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1219008&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1219008\/mp32\/" + } + ] + }, + { + "id":"146206", + "name":"OLD", + "releasedate":"2015-04-08", + "artist_id":"337662", + "artist_name":"meveric", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146206\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146206\/mp32\/", + "tracks":[ + { + "id":"1218970", + "position":"1", + "name":"Mobile (first version)", + "duration":"159", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218970&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218970\/mp32\/" + }, + { + "id":"1218898", + "position":"2", + "name":"the trumpet", + "duration":"115", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218898&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218898\/mp32\/" + }, + { + "id":"1218969", + "position":"3", + "name":"R n B", + "duration":"197", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218969&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218969\/mp32\/" + }, + { + "id":"1218968", + "position":"4", + "name":"good old", + "duration":"4", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218968&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218968\/mp32\/" + }, + { + "id":"1218955", + "position":"5", + "name":"fuck", + "duration":"256", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218955&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218955\/mp32\/" + }, + { + "id":"1218938", + "position":"6", + "name":"bass (old)", + "duration":"263", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218938&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218938\/mp32\/" + }, + { + "id":"1218901", + "position":"7", + "name":"shit mus\u00e4k", + "duration":"223", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218901&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218901\/mp32\/" + }, + { + "id":"1218928", + "position":"8", + "name":"it is bas", + "duration":"189", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218928&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218928\/mp32\/" + }, + { + "id":"1218934", + "position":"9", + "name":"the ghostdog (detuned)", + "duration":"129", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218934&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218934\/mp32\/" + }, + { + "id":"1218897", + "position":"10", + "name":"government (very old)", + "duration":"258", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218897&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218897\/mp32\/" + } + ] + } + ] +} diff --git a/tests/library/Class/WebService/Jamendo/tracks_page_1.json b/tests/library/Class/WebService/Jamendo/tracks_page_1.json new file mode 100644 index 0000000000000000000000000000000000000000..a7c4f3c74c9aec1a556d35b5694b57df2e7eb09f --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/tracks_page_1.json @@ -0,0 +1,1075 @@ +{ + "headers":{ + "status":"success", + "code":0, + "error_message":"", + "warnings":"", + "results_count":10 + }, + "results":[ + { + "id":"146203", + "name":"Tracks", + "releasedate":"2015-04-08", + "artist_id":"467750", + "artist_name":"Alvaro Galan", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146203\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146203\/mp32\/", + "tracks":[ + { + "id":"1218917", + "position":"1", + "name":"Intro - Simus Veritatis", + "duration":"111", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218917&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218917\/mp32\/" + }, + { + "id":"1218921", + "position":"2", + "name":"Sunset Fire", + "duration":"228", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218921&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218921\/mp32\/" + }, + { + "id":"1218920", + "position":"3", + "name":"Strings", + "duration":"193", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218920&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218920\/mp32\/" + }, + { + "id":"1218918", + "position":"4", + "name":"Milky Way", + "duration":"233", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218918&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218918\/mp32\/" + }, + { + "id":"1218919", + "position":"5", + "name":"Fenix", + "duration":"242", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218919&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218919\/mp32\/" + }, + { + "id":"1218916", + "position":"6", + "name":"Night Dance", + "duration":"119", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218916&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218916\/mp32\/" + }, + { + "id":"1218922", + "position":"7", + "name":"Golden Sickle", + "duration":"229", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218922&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218922\/mp32\/" + }, + { + "id":"1218923", + "position":"8", + "name":"Yours", + "duration":"203", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218923&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218923\/mp32\/" + }, + { + "id":"1218924", + "position":"9", + "name":"Dogma", + "duration":"280", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218924&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218924\/mp32\/" + } + ] + }, + { + "id":"146202", + "name":"LONDON HYMNS", + "releasedate":"2015-04-08", + "artist_id":"461369", + "artist_name":"Roy Smiles", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146202\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146202\/mp32\/", + "tracks":[ + { + "id":"1218893", + "position":"1", + "name":"Lorna Doone", + "duration":"214", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218893&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218893\/mp32\/" + }, + { + "id":"1218880", + "position":"2", + "name":"The Subways And The Sidewalks", + "duration":"208", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218880&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218880\/mp32\/" + }, + { + "id":"1218875", + "position":"3", + "name":"Christ This City", + "duration":"187", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218875&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218875\/mp32\/" + }, + { + "id":"1218881", + "position":"4", + "name":"War With The East", + "duration":"203", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218881&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218881\/mp32\/" + }, + { + "id":"1218877", + "position":"5", + "name":"I Will Give You The Sun", + "duration":"177", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218877&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218877\/mp32\/" + }, + { + "id":"1218864", + "position":"6", + "name":"Ship That Died Of Shame", + "duration":"185", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218864&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218864\/mp32\/" + }, + { + "id":"1218879", + "position":"7", + "name":"A Man Who Walks Alone", + "duration":"150", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218879&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218879\/mp32\/" + }, + { + "id":"1218872", + "position":"8", + "name":"Clancy", + "duration":"242", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218872&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218872\/mp32\/" + }, + { + "id":"1218915", + "position":"9", + "name":"Seize The Day", + "duration":"227", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218915&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218915\/mp32\/" + }, + { + "id":"1218883", + "position":"10", + "name":"Girls Of Summer", + "duration":"152", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218883&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218883\/mp32\/" + }, + { + "id":"1218873", + "position":"11", + "name":"Magpie", + "duration":"201", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218873&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218873\/mp32\/" + }, + { + "id":"1218874", + "position":"12", + "name":"A Land Called Home", + "duration":"186", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218874&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218874\/mp32\/" + }, + { + "id":"1218876", + "position":"13", + "name":"Drunks And Dreamers", + "duration":"234", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218876&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218876\/mp32\/" + }, + { + "id":"1218869", + "position":"14", + "name":"A Better Land", + "duration":"260", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218869&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218869\/mp32\/" + }, + { + "id":"1218870", + "position":"15", + "name":"El Dorado", + "duration":"195", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218870&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218870\/mp32\/" + }, + { + "id":"1218878", + "position":"16", + "name":"Lighthouse Keeper", + "duration":"170", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218878&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218878\/mp32\/" + }, + { + "id":"1218894", + "position":"17", + "name":"Vera In Autumn", + "duration":"165", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218894&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218894\/mp32\/" + }, + { + "id":"1218882", + "position":"18", + "name":"Bremen", + "duration":"250", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218882&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218882\/mp32\/" + }, + { + "id":"1218884", + "position":"19", + "name":"Time Is Moving On", + "duration":"227", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218884&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218884\/mp32\/" + }, + { + "id":"1218887", + "position":"20", + "name":"Dreaming Of Toronto", + "duration":"286", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218887&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218887\/mp32\/" + } + ] + }, + { + "id":"146201", + "name":"GLDJ Productions - The Rocking Station", + "releasedate":"2015-04-09", + "artist_id":"459175", + "artist_name":"gldjproductions", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146201\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146201\/mp32\/", + "tracks":[ + { + "id":"1218860", + "position":"1", + "name":"Euclasion - Silence", + "duration":"165", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218860&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218860\/mp32\/" + }, + { + "id":"1218861", + "position":"2", + "name":"Euclasion - Forrest Whispering", + "duration":"131", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218861&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218861\/mp32\/" + }, + { + "id":"1218863", + "position":"3", + "name":"Euclasion - Confidence", + "duration":"148", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218863&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218863\/mp32\/" + }, + { + "id":"1218865", + "position":"4", + "name":"Euclasion - Emanuel", + "duration":"179", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218865&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218865\/mp32\/" + }, + { + "id":"1218867", + "position":"5", + "name":"Euclasion - Somewhere Blind", + "duration":"204", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218867&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218867\/mp32\/" + }, + { + "id":"1218866", + "position":"6", + "name":"Euclasion - Echo", + "duration":"118", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218866&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218866\/mp32\/" + }, + { + "id":"1218888", + "position":"7", + "name":"Euclasion - I dont wanna see any tears", + "duration":"193", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218888&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218888\/mp32\/" + }, + { + "id":"1218889", + "position":"8", + "name":"Euclasion - Luckily Song", + "duration":"78", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218889&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218889\/mp32\/" + }, + { + "id":"1218896", + "position":"9", + "name":"Euclasion - Leaking Tave", + "duration":"145", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218896&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218896\/mp32\/" + }, + { + "id":"1218903", + "position":"10", + "name":"Euclasion - Summertime (Radio)", + "duration":"136", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218903&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218903\/mp32\/" + }, + { + "id":"1218961", + "position":"11", + "name":"Euclasion - Horizon (Radio)", + "duration":"150", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218961&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218961\/mp32\/" + }, + { + "id":"1218905", + "position":"12", + "name":"Euclasion - Follow Your Heart (Radio Mix)", + "duration":"168", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218905&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218905\/mp32\/" + }, + { + "id":"1218906", + "position":"13", + "name":"Euclasion - Hello, GDay", + "duration":"170", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218906&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218906\/mp32\/" + }, + { + "id":"1218907", + "position":"14", + "name":"Freefusal - EarthWater (Radio Mix)", + "duration":"137", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218907&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218907\/mp32\/" + }, + { + "id":"1218908", + "position":"15", + "name":"Ylpea Oxenta - Riippumattomuus", + "duration":"87", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218908&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218908\/mp32\/" + }, + { + "id":"1218909", + "position":"16", + "name":"Ylpea Oxenta - In a Jump", + "duration":"114", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218909&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218909\/mp32\/" + }, + { + "id":"1218910", + "position":"17", + "name":"Ylpea Oxenta - Uusi Vuosi", + "duration":"189", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218910&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218910\/mp32\/" + }, + { + "id":"1218911", + "position":"18", + "name":"Ylpea Oxenta - Yhdistetty", + "duration":"184", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218911&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218911\/mp32\/" + }, + { + "id":"1218962", + "position":"19", + "name":"Euclasion - Summertime (Long)", + "duration":"195", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218962&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218962\/mp32\/" + }, + { + "id":"1218963", + "position":"20", + "name":"Euclasion - Horizon (Long)", + "duration":"211", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218963&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218963\/mp32\/" + }, + { + "id":"1218964", + "position":"21", + "name":"Euclasion - Follow Your Heart (Full 12 Inch Mix)", + "duration":"451", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218964&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218964\/mp32\/" + }, + { + "id":"1218965", + "position":"22", + "name":"Freefusal - Earthwater (Conception Mix)", + "duration":"332", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218965&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218965\/mp32\/" + }, + { + "id":"1218967", + "position":"23", + "name":"Euclasion - Echo (Long)", + "duration":"315", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218967&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218967\/mp32\/" + }, + { + "id":"1218966", + "position":"24", + "name":"Euclasion - Silence (Rap dat Crap Mix)", + "duration":"169", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218966&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218966\/mp32\/" + } + ] + }, + { + "id":"146197", + "name":"Valdragz", + "releasedate":"2015-04-08", + "artist_id":"467730", + "artist_name":"VALDRAGZ", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146197\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146197\/mp32\/", + "tracks":[ + { + "id":"1218828", + "position":"1", + "name":"voyage", + "duration":"363", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218828&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218828\/mp32\/" + }, + { + "id":"1218829", + "position":"2", + "name":"circus swing", + "duration":"350", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218829&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218829\/mp32\/" + }, + { + "id":"1218832", + "position":"3", + "name":"xtrem conscience", + "duration":"397", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218832&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218832\/mp32\/" + }, + { + "id":"1218830", + "position":"4", + "name":"black cat", + "duration":"286", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218830&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218830\/mp32\/" + }, + { + "id":"1218833", + "position":"5", + "name":"electro django (remix )", + "duration":"402", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218833&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218833\/mp32\/" + }, + { + "id":"1218831", + "position":"6", + "name":"ska swing", + "duration":"286", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218831&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218831\/mp32\/" + }, + { + "id":"1218834", + "position":"7", + "name":"business in ( remix )", + "duration":"408", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218834&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218834\/mp32\/" + }, + { + "id":"1218835", + "position":"8", + "name":"cat swing", + "duration":"286", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218835&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218835\/mp32\/" + }, + { + "id":"1218836", + "position":"9", + "name":"positive", + "duration":"300", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218836&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218836\/mp32\/" + }, + { + "id":"1218838", + "position":"10", + "name":"unite", + "duration":"228", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218838&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218838\/mp32\/" + }, + { + "id":"1218837", + "position":"11", + "name":"it dont mean a thing ( remix )", + "duration":"291", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218837&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218837\/mp32\/" + }, + { + "id":"1218839", + "position":"12", + "name":"bastet", + "duration":"376", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218839&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218839\/mp32\/" + }, + { + "id":"1218840", + "position":"13", + "name":"moove your big ass", + "duration":"317", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218840&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218840\/mp32\/" + }, + { + "id":"1218841", + "position":"14", + "name":"caught me", + "duration":"332", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218841&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218841\/mp32\/" + }, + { + "id":"1218842", + "position":"15", + "name":"sex club bitch", + "duration":"326", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218842&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218842\/mp32\/" + } + ] + }, + { + "id":"146195", + "name":"Elegia per Violino e Orchestra", + "releasedate":"2015-04-08", + "artist_id":"347673", + "artist_name":"Aufklarung", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146195\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146195\/mp32\/", + "tracks":[ + { + "id":"1218815", + "position":"1", + "name":"Elegia per Violino e Orchestra", + "duration":"264", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218815&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218815\/mp32\/" + } + ] + }, + { + "id":"146194", + "name":"Hard Trance Mix", + "releasedate":"2015-04-08", + "artist_id":"433172", + "artist_name":"DJ STIVIT", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146194\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146194\/mp32\/", + "tracks":[ + { + "id":"1218816", + "position":"1", + "name":"DJ STIVIT- Hard Trance Mix Track 1", + "duration":"339", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218816&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218816\/mp32\/" + }, + { + "id":"1218817", + "position":"2", + "name":"DJ STIVIT- Hard Trance Mix Track 2", + "duration":"228", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218817&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218817\/mp32\/" + }, + { + "id":"1218819", + "position":"3", + "name":"DJ STIVIT- Hard Trance Mix Track 3", + "duration":"265", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218819&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218819\/mp32\/" + }, + { + "id":"1218818", + "position":"4", + "name":"DJ STIVIT- Hard Trance Mix Track 4", + "duration":"165", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218818&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218818\/mp32\/" + }, + { + "id":"1218821", + "position":"5", + "name":"DJ STIVIT- Hard Trance Mix Track 5", + "duration":"276", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218821&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218821\/mp32\/" + }, + { + "id":"1218820", + "position":"6", + "name":"DJ STIVIT- Hard Trance Mix Track 6", + "duration":"254", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218820&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218820\/mp32\/" + } + ] + }, + { + "id":"146189", + "name":"The Last?", + "releasedate":"2015-04-08", + "artist_id":"337662", + "artist_name":"meveric", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146189\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146189\/mp32\/", + "tracks":[ + { + "id":"1218643", + "position":"1", + "name":"andy\u00b4s ghost", + "duration":"68", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218643&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218643\/mp32\/" + }, + { + "id":"1218644", + "position":"2", + "name":"spacebass (+origin)", + "duration":"363", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218644&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218644\/mp32\/" + }, + { + "id":"1218648", + "position":"3", + "name":"my new kid", + "duration":"163", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218648&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218648\/mp32\/" + }, + { + "id":"1218912", + "position":"4", + "name":"every time I heard this song on the radio", + "duration":"209", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218912&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218912\/mp32\/" + }, + { + "id":"1218656", + "position":"5", + "name":"technot (instrumental)", + "duration":"292", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218656&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218656\/mp32\/" + }, + { + "id":"1218689", + "position":"6", + "name":"7NA (Bad Version)", + "duration":"371", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218689&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218689\/mp32\/" + }, + { + "id":"1218647", + "position":"7", + "name":"project alpha", + "duration":"264", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218647&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218647\/mp32\/" + }, + { + "id":"1218931", + "position":"8", + "name":"the journey", + "duration":"172", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218931&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218931\/mp32\/" + }, + { + "id":"1218895", + "position":"9", + "name":"english harpflow", + "duration":"193", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218895&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218895\/mp32\/" + }, + { + "id":"1218658", + "position":"10", + "name":"mlp", + "duration":"213", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218658&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218658\/mp32\/" + }, + { + "id":"1218677", + "position":"11", + "name":"Bell", + "duration":"202", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218677&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218677\/mp32\/" + }, + { + "id":"1218926", + "position":"12", + "name":"raeggaton", + "duration":"120", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218926&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218926\/mp32\/" + }, + { + "id":"1218929", + "position":"13", + "name":"glass", + "duration":"117", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218929&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218929\/mp32\/" + }, + { + "id":"1218890", + "position":"14", + "name":"hanzinhousefever (crazy\/chill)", + "duration":"147", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218890&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218890\/mp32\/" + }, + { + "id":"1218925", + "position":"15", + "name":"cake", + "duration":"23", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218925&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218925\/mp32\/" + } + ] + }, + { + "id":"146188", + "name":"ASEA EP", + "releasedate":"2015-04-08", + "artist_id":"466654", + "artist_name":"ASEA", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146188\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146188\/mp32\/", + "tracks":[ + { + "id":"1218780", + "position":"1", + "name":"Born to Be Free", + "duration":"222", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218780&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218780\/mp32\/" + }, + { + "id":"1218783", + "position":"2", + "name":"Brisk", + "duration":"201", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218783&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218783\/mp32\/" + }, + { + "id":"1218784", + "position":"3", + "name":"Perfect Senses", + "duration":"202", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218784&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218784\/mp32\/" + }, + { + "id":"1218785", + "position":"4", + "name":"Shadow of Delusion", + "duration":"187", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218785&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218785\/mp32\/" + } + ] + }, + { + "id":"146186", + "name":"Belligerent Incredulity", + "releasedate":"2015-04-08", + "artist_id":"437011", + "artist_name":"CloudBurstSound", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146186\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146186\/mp32\/", + "tracks":[ + { + "id":"1218757", + "position":"1", + "name":"Love", + "duration":"283", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218757&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218757\/mp32\/" + }, + { + "id":"1218756", + "position":"2", + "name":"No way no how", + "duration":"196", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218756&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218756\/mp32\/" + }, + { + "id":"1218758", + "position":"3", + "name":"Lies", + "duration":"278", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218758&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218758\/mp32\/" + }, + { + "id":"1218763", + "position":"4", + "name":"War", + "duration":"245", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218763&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218763\/mp32\/" + }, + { + "id":"1218761", + "position":"5", + "name":"Tears", + "duration":"247", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218761&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218761\/mp32\/" + }, + { + "id":"1218760", + "position":"6", + "name":"Patience", + "duration":"248", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218760&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218760\/mp32\/" + }, + { + "id":"1218764", + "position":"7", + "name":"Lyme Park", + "duration":"264", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218764&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218764\/mp32\/" + }, + { + "id":"1218762", + "position":"8", + "name":"The night", + "duration":"198", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218762&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218762\/mp32\/" + }, + { + "id":"1218765", + "position":"9", + "name":"The Bet", + "duration":"211", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218765&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218765\/mp32\/" + }, + { + "id":"1218759", + "position":"10", + "name":"Pain", + "duration":"116", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218759&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218759\/mp32\/" + }, + { + "id":"1218755", + "position":"11", + "name":"Dream", + "duration":"287", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218755&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218755\/mp32\/" + } + ] + }, + { + "id":"146185", + "name":"Rusalina (Original and Amind Two Guys Mixes)", + "releasedate":"2015-04-08", + "artist_id":"455020", + "artist_name":"Flowers On Mars ", + "image":"https:\/\/imgjam1.jamendo.com\/albums\/s146\/146185\/covers\/1.200.jpg", + "zip":"https:\/\/storage-new.newjamendo.com\/download\/a146185\/mp32\/", + "tracks":[ + { + "id":"1218734", + "position":"1", + "name":"Flowers On Mars - Rusalina (Original Mix)", + "duration":"288", + "license_ccurl":"http:\/\/creativecommons.org\/licenses\/by-nc\/3.0\/", + "audio":"https:\/\/storage-new.newjamendo.com\/?trackid=1218734&format=mp31&from=app-f919df7d", + "audiodownload":"https:\/\/storage-new.newjamendo.com\/download\/track\/1218734\/mp32\/" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/library/Class/WebService/Jamendo/tracks_page_2.json b/tests/library/Class/WebService/Jamendo/tracks_page_2.json new file mode 100644 index 0000000000000000000000000000000000000000..932c371ea72c6e06111528ad7154128dc6cb71a9 --- /dev/null +++ b/tests/library/Class/WebService/Jamendo/tracks_page_2.json @@ -0,0 +1,12 @@ +{ + "headers":{ + "status":"success", + "code":0, + "error_message":"", + "warnings":"", + "results_count":0 + }, + "results":[ + + ] +} \ No newline at end of file diff --git a/tests/library/Class/WebService/OneDTouchTest.php b/tests/library/Class/WebService/OneDTouchTest.php index 7ea0928502a85732dcc18cb907032b37a206e92e..d87812f0993484910e88d54e0d0e669f5b408635 100644 --- a/tests/library/Class/WebService/OneDTouchTest.php +++ b/tests/library/Class/WebService/OneDTouchTest.php @@ -214,8 +214,6 @@ class OneDTouchIncTest extends Storm_Test_ModelTestCase { /** @test */ public function albumShouldHaveBeenUpdated() { - $album = Class_Album::find(3); - xdebug_break(); $this->assertEquals(1, Class_Album::findFirstBy(['titre' => 'WOLFEP026'])->getId()); } } diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index dbe120805e5812bc3993e18c83f72e4af141c843..e0ecfa97e6fb1aab70e68340d1db4a7a0a6ba7e2 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -78,15 +78,11 @@ abstract class NanookTestCase extends Storm_Test_ModelTestCase { ->setServerRoot('http://localhost:8080/afi_Nanook/ilsdi/') ->setWebClient($this->_mock_web_client); - $annexe_cran = Class_CodifAnnexe::getLoader()->newInstanceWithId(3) - ->setLibelle('Annexe Cran-Gevrier') - ->setIdBib(3) - ->setCode(10); + $this->fixture('Class_CodifAnnexe' , ['id' => 3, + 'libelle' => 'Annexe Cran-Gevrier', + 'id_bib' => 3, + 'code' => 10]); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') - ->whenCalled('findFirstBy')->answers(null) - ->whenCalled('findFirstBy')->with(array('id_bib' => 3))->answers($annexe_cran) - ->whenCalled('findFirstBy')->with(array('code' => 10))->answers($annexe_cran); } } @@ -371,6 +367,26 @@ class NanookGetNoticeWithErrorTest extends NanookTestCase { } +class NanookGetUserAnnexeTest extends NanookTestCase { + public function setUp() { + parent::setUp(); + $this->_chrystel = Class_Users::newInstance(['id_sigb' => 1, + 'login' => 8765, + 'password' => 2002, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 12, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + } + + /** @test */ + public function getUserAnnexeShouldMatchUserGetIdSite() { + $this->assertEquals($this->_service->getUserAnnexe($this->_chrystel), $this->_chrystel->getUserIdSite()); + } + +} class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase { diff --git a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php index ee4dd3ffe4d000dd37b552a35303f07b17453712..9552d3ee30885dc45998c0ec0b225ece30a83d5d 100644 --- a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php +++ b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php @@ -390,5 +390,9 @@ renouvellement --> </documents> </datas> '; } + + public static function xmlGetLstPretsNewOrpheeVersion() { + return '<?xml version="1.0" encoding="utf-8"?><datas><infos><nb_res><![CDATA[11]]></nb_res></infos><documents><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[231054]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002310543]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[354050841]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[237009]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002370091]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Le Carrer, Olivier (1955-....)]]></auteur><cote><![CDATA[133.1 LEC]]></cote><titre><![CDATA[Atlas des lieux maudits]]></titre><editeur><![CDATA[Arthaud]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1300600674]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[133858]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001338586]]></cb><lib_sup><![CDATA[ DVD]]></lib_sup><sup><![CDATA[114]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Porte, Gilles]]></auteur><cote><![CDATA[F POR]]></cote><titre><![CDATA[Quand la mer monte]]></titre><editeur><![CDATA[Ognon pictures]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[354666415]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[234221]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002342215]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Campbell, James W. P]]></auteur><cote><![CDATA[027 CAM]]></cote><titre><![CDATA[Bibliothèques]]></titre><editeur><![CDATA[Citadelles & Mazenod]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[01/04/2015]]></date_pret><nprol><![CDATA[1]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[214356]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002143563]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[191095]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001910954]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1301002547]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[143359]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001433593]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Dimery, Robert]]></auteur><cote><![CDATA[782 DIM]]></cote><titre><![CDATA[Les 1001 albums qu\'il faut avoir écoutés dans sa vie : rock, hip hop, soul dance, techno ...]]></titre><editeur><![CDATA[Flammarion]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1414909049]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[195118]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001951180]]></cb><lib_sup><![CDATA[ DVD]]></lib_sup><sup><![CDATA[114]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Bonvoisin, Bernie]]></auteur><cote><![CDATA[F BON]]></cote><titre><![CDATA[Les démons de Jésus]]></titre><editeur><![CDATA[Studio Canal vidéo]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[134321153]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[212098]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002120983]]></cb><lib_sup><![CDATA[ CD]]></lib_sup><sup><![CDATA[110]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Jarrett, Keith]]></auteur><cote><![CDATA[1.3 JAR]]></cote><titre><![CDATA[Hymns, spheres]]></titre><editeur /><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1301003693]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[234801]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002348014]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Sciences humaines]]></titre><editeur><![CDATA[Sciences humaines éditions]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1314912055]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[203232]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002032329]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Leroux, Léonnard (1977-....)]]></auteur><cote><![CDATA[248.4 LER]]></cote><titre><![CDATA[En chemin vers Compostelle]]></titre><editeur><![CDATA[Presses de la Renaissance]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document></documents></datas>'; + } } ?> diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php index 0b4794c393963afdbc6c85d41f2cbe61cdffe6b2..be6dcacffd6937119a8a87d1e168cafeb971777b 100644 --- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php @@ -532,6 +532,15 @@ class OrpheeServiceGetLstDmtResponseTest extends PHPUnit_Framework_TestCase { } + /** @test */ + public function withOrpheeNewVersionXmlShouldNotRemoveCDatas() { + $xml = GetLstPretResponse::withResult(OrpheeFixtures::xmlGetLstPretsNewOrpheeVersion())->getXml(); + $prets = Class_WebService_SIGB_Orphee_GetLstPretResponseReader::newInstance() + ->getEmpruntsFromXML($xml); + $this->assertCount(11, $prets); + } + + /** @test */ public function withLivreEspagnolShouldRemoveAllCDATA() { $actual_xml = GetLstDmtResponse::withResult(OrpheeFixtures::xmlGetLstDmtLivreEspagnol())->getXml(); @@ -1201,4 +1210,5 @@ class OrpheeServiceProlongetPretTest extends OrpheeServiceTestCase { } } + ?> diff --git a/tests/library/Class/WebService/SIGB/PergameTest.php b/tests/library/Class/WebService/SIGB/PergameTest.php index bf02aaf64610899a66f1b5cfc739cfd11eadaed6..4a76abf48f730aaa30362f5f5ebaae28d9243e48 100644 --- a/tests/library/Class/WebService/SIGB/PergameTest.php +++ b/tests/library/Class/WebService/SIGB/PergameTest.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class PergameServiceTestCase extends Storm_Test_ModelTestCase { +abstract class PergameTestCase extends Storm_Test_ModelTestCase { public function setUp() { parent::setUp(); @@ -100,7 +100,7 @@ abstract class PergameServiceTestCase extends Storm_Test_ModelTestCase { -class PergameServiceGetEmprunteurTest extends PergameServiceTestCase { +class PergameServiceGetEmprunteurTest extends PergameTestCase { public function setUp() { parent::setUp(); @@ -254,7 +254,7 @@ class PergameServiceGetEmprunteurTest extends PergameServiceTestCase { -class PergameServiceGetExemplairePotterTest extends PergameServiceTestCase { +class PergameServiceGetExemplairePotterTest extends PergameTestCase { public function setUp() { parent::setUp(); @@ -373,7 +373,7 @@ class PergameServiceGetExemplairePotterTest extends PergameServiceTestCase { -class PergameServiceDelegateLegacyTest extends PergameServiceTestCase { +class PergameServiceDelegateLegacyTest extends PergameTestCase { public function setUp() { parent::setUp(); $this->_legacy_service = Storm_Test_ObjectWrapper::on($this->_service_cran->getLegacyService()); diff --git a/tests/library/Class/WebService/VignetteTest.php b/tests/library/Class/WebService/VignetteTest.php index f02d97374647e81453a6e8683f8fac1091ca2982..adda910feaf1cf95863170bda645d5fbe553f799 100644 --- a/tests/library/Class/WebService/VignetteTest.php +++ b/tests/library/Class/WebService/VignetteTest.php @@ -49,6 +49,7 @@ class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase { .'&type_doc=1' .'&numero=' .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' .'&action=10') ->answers(json_encode(['vignette' => 'http://cache.org/potter_thumb.jpg', diff --git a/tests/library/ZendAfi/Form/LoginTest.php b/tests/library/ZendAfi/Form/LoginTest.php new file mode 100644 index 0000000000000000000000000000000000000000..05395fde556af9955508b94e0246ab6c57f2a6ee --- /dev/null +++ b/tests/library/ZendAfi/Form/LoginTest.php @@ -0,0 +1,114 @@ +<?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 ZendAfi_Form_LoginTestCase extends Storm_Test_ModelTestCase { + protected $_form; + + public function setUp() { + parent::setUp(); + Storm_Model_Loader::defaultToVolatile(); + $this->_form = ZendAfi_Form_Login::newWithOptions(['data' => $this->_getDatas()]); + } + + + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } + + + protected function _getDatas() { + return ['redirect_url' => '', + 'id_notice' => '', + 'autocomplete_off' => '', + 'identifiant' => '', + 'identifiant_exemple' => '', + 'mot_de_passe' => '', + 'mot_de_passe_exemple' => '', + 'lien_connexion' => '', + 'lien_mot_de_passe_oublie' => '', + 'lien_creer_compte' => '']; + } +} + + + +class ZendAfi_Form_LoginRGAAWithEmptyDatasTest extends ZendAfi_Form_LoginTestCase { + /** @test */ + public function usernameShouldHaveDefaultTitle() { + $this->assertEquals('Identifiant', $this->_form->username->getAttrib('title')); + } + + + /** @test */ + public function passwordShouldHaveDefaultTitle() { + $this->assertEquals('Mot de passe', $this->_form->password->getAttrib('title')); + } +} + + + + +class ZendAfi_Form_LoginRGAAWithPlaceholdersTest extends ZendAfi_Form_LoginTestCase { + protected function _getDatas() { + $datas = parent::_getDatas(); + $datas['identifiant_exemple'] = 'Mon identifiant'; + $datas['mot_de_passe_exemple'] = 'Mon mot de passe'; + return $datas; + } + + + /** @test */ + public function usernameTitleShouldHaveBeMonIdentifiant() { + $this->assertEquals('Mon identifiant', $this->_form->username->getAttrib('title')); + } + + + /** @test */ + public function passwordTitleShouldBeMonMotDePasse() { + $this->assertEquals('Mon mot de passe', $this->_form->password->getAttrib('title')); + } +} + + + + +class ZendAfi_Form_LoginRGAAWithLabelsTest extends ZendAfi_Form_LoginTestCase { + protected function _getDatas() { + $datas = parent::_getDatas(); + $datas['identifiant'] = 'Mon identifiant'; + $datas['mot_de_passe'] = 'Mon mot de passe'; + return $datas; + } + + + /** @test */ + public function usernameShouldNotHaveTitle() { + $this->assertNull($this->_form->username->getAttrib('title')); + } + + + /** @test */ + public function passwordShouldNotHaveTitle() { + $this->assertNull($this->_form->password->getAttrib('title')); + } +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Abonne/ResumeTest.php b/tests/library/ZendAfi/View/Helper/Abonne/ResumeTest.php index e7a448b2f8e4bbad076b303aeee954f9d9253ca7..4b92eb0d01a30bf026a828e2dd756cbb8c1780b4 100644 --- a/tests/library/ZendAfi/View/Helper/Abonne/ResumeTest.php +++ b/tests/library/ZendAfi/View/Helper/Abonne/ResumeTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; @@ -28,32 +28,48 @@ class View_Helper_Abonne_ResumeAsAbonneSIGBTest extends ViewHelperTestCase { $this->_helper = new ZendAfi_View_Helper_Abonne_Resume(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $emprunteur = Storm_Test_ObjectWrapper::mock() - ->whenCalled('getNbEmprunts')->answers(2) - ->whenCalled('getNbPretsEnRetard')->answers(1) - ->whenCalled('getNbReservations')->answers(0); + $emprunteur = Class_WebService_SIGB_Emprunteur::nullInstance(); + $emprunteur + ->empruntsAddAll([Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire()->setDateRetour('13/03/2011'), + Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire()->setDateRetour('13/03/2022')]); $user = Class_Users::newInstanceWithId(3, ['fiche_sigb' => ['fiche' => $emprunteur], - 'avis' => [Class_Avis::newInstanceWithId(34), + 'avis' => [Class_Avis::newInstanceWithId(34), Class_Avis::newInstanceWithId(35)]]) ->beAbonneSIGB(); + $this->fixture('Class_Loan_Pnb', + ['id' => 5, + 'user_id' => 3, + 'record_origin_id' => 'Dilicom-88817216', + 'ongoing' => true, + 'expected_return_date' => '2022-05-02 18:14:14']); + + + $this->fixture('Class_Loan_Pnb', + ['id' => 6, + 'user_id' => 3, + 'record_origin_id' => 'Dilicom-88817217', + 'ongoing' => false, + 'expected_return_date' => '2014-05-02 12:12:12']); + + $this->_html = $this->_helper->abonne_Resume($user); } /** @test */ - public function linkPretsShouldContainsDeuxPretsUnRetard() { - $this->assertXPathContentContains($this->_html, + public function linkPretsShouldContainsTroisPretsUnRetard() { + $this->assertXPathContentContains($this->_html, '//div/a[contains(@href, "abonne/prets")]', - utf8_encode('2 prêts en cours dont 1 retard')); + utf8_encode('3 prêts en cours dont 1 retard')); } /** @test */ public function linkReservationsShouldContainsAucuneReservation() { - $this->assertXPathContentContains($this->_html, + $this->assertXPathContentContains($this->_html, '//div/a[contains(@href, "abonne/reservations")]', utf8_encode('Aucune réservation')); } @@ -61,7 +77,7 @@ class View_Helper_Abonne_ResumeAsAbonneSIGBTest extends ViewHelperTestCase { /** @test */ public function linkAvisShouldContainsDeuxAvis() { - $this->assertXPathContentContains($this->_html, + $this->assertXPathContentContains($this->_html, '//div/a[contains(@href, "abonne/viewavis/id/3")]', '2 avis'); } @@ -73,7 +89,7 @@ class View_Helper_Abonne_ResumeAsAbonneSIGBTest extends ViewHelperTestCase { $this->assertXPathContentContains($this->_helper->abonne_Resume($user), '//div/a[contains(@href, "abonne/viewavis/id/3")]', 'Aucun avis'); - + } } @@ -96,14 +112,14 @@ class View_Helper_Abonne_ResumeAsInviteTest extends ViewHelperTestCase { /** @test */ public function linkReservationsShouldNotBeVisible() { - $this->assertNotXPath($this->_html, + $this->assertNotXPath($this->_html, '//a[contains(@href, "abonne/reservations")]'); } /** @test */ public function linkPretsShouldNotBeVisible() { - $this->assertNotXPath($this->_html, + $this->assertNotXPath($this->_html, '//a[contains(@href, "abonne/prets")]'); } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php index b0f262e56e2796da2feeebe1c8c81d59950102f6..dde8f064d26d15cfbfea602b82f0afb78ecfc216 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php @@ -16,137 +16,127 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; -require_once 'Class/AvisNotice.php'; -class CritiquesAvisEmptyTestCase extends ViewHelperTestCase { + +class CritiquesAvisEmptyTest extends ViewHelperTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); - $params = array('type_module' => 'CRITIQUES', - 'division' => 2, - 'preferences' => array()); - - $this->avis_loader = $this->getMock('MockLoader', array('getAvisFromPreferences')); - Storm_Model_Abstract::setLoaderFor('Class_AvisNotice', $this->avis_loader); - $this->avis_loader - ->expects($this->once()) - ->method('getAvisFromPreferences') - ->will($this->returnValue(array())); + $params = ['type_module' => 'CRITIQUES', + 'division' => 2, + 'preferences' => []]; $helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $params); $helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->html = $helper->getBoite(); } - public function testAucuneCritiquesPresent() { + + /** @test */ + public function aucuneCritiquesShouldBePresent() { $this->assertQueryContentContains($this->html, 'p', utf8_encode('Aucune critique récente')); } - public function testBoiteDivisionMilieu() { - $this->assertXPath($this->html, "//div[@class='boiteMilieu']"); + + /** @test */ + public function boiteMilieuShouldBePresent() { + $this->assertXPath($this->html, '//div[@class="boiteMilieu"]'); } } abstract class CritiquesAvisTestCase extends ViewHelperTestCase { - public function setUp() { - parent::setUp(); - $lolo = new Class_Users(); - $lolo - ->setId(91) - ->setPseudo('Lolo'); - - $millenium = new Class_Notice(); - $millenium - ->setId(9867) - ->setTitrePrincipal('Millenium (Stieg Larsson)') - ->setClefAlpha('MILLENIUM') - ->setUrlVignette('http://amazon.com/vignette.png'); - - $avis_millenium = new Class_AvisNotice(); - $avis_millenium - ->setId(23) - ->setEntete("J'adore") - ->setAvis("Suspense intense") - ->setNote(5) - ->setDateAvis('2010-03-18 13:00:00') - ->setUser($lolo) - ->setAbonOuBib(0) - ->setStatut(1) - ->setNotices(array($millenium)); - - $avis_orphan = new Class_AvisNotice(); - $avis_orphan - ->setId(34) - ->setEntete("J'ai oublié") - ->setAvis("Ce que c'était") - ->setNote(2) - ->setDateAvis('2010-03-18 13:00:00') - ->setUser($lolo) - ->setAbonOuBib(0) - ->setStatut(1) - ->setNotices(array()); - - - $potter = new Class_Notice(); - $potter - ->setId(687) - ->setTitrePrincipal('Potter') - ->setUrlVignette('NO'); - - $avis_potter = new Class_AvisNotice(); - $avis_potter - ->setId(87) - ->setEntete("Le sorcier") - ->setAvis("A du charme") - ->setNote(4) - ->setDateAvis('2010-03-18 13:00:00') - ->setUser($lolo) - ->setAbonOuBib(0) - ->setStatut(1) - ->setNotices(array($potter)); - - - $this->avis_loader = $this->getMock('MockLoader', array('getAvisFromPreferences', 'delete')); - Storm_Model_Abstract::setLoaderFor('Class_AvisNotice', $this->avis_loader); - - $this->avis_loader - ->expects($this->once()) - ->method('getAvisFromPreferences') - ->will($this->returnValue(array($avis_millenium, $avis_orphan, $avis_potter))); - } -} - + protected $_storm_default_to_volatile = true; + protected $_prefs = []; // subclass responsibility -class CritiquesWithVignettesTest extends CritiquesAvisTestCase { public function setUp() { parent::setUp(); - $params = array('type_module' => 'CRITIQUES', - 'division' => 1, - 'preferences' => array('rss_avis' => true, - 'only_img' => 1, - 'display_order' => 'Random', - 'titre' => 'Livres préférés', - 'nb_aff_avis' => '3', - 'nb_words' => 20, - 'boite' => 'boite_de_la_division_droite')); - - - $profil = new Class_Profil(); - $profil->setId(18); - Class_Profil::setCurrentProfil($profil); + $this->_prepareFixtures(); - $helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $params); + $helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $this->_prefs); $helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->html = $helper->getBoite(); } - public function testMilleniumIsHere() { + + protected function _prepareFixtures() { + Class_AdminVar::set('AVIS_MIN_SAISIE', 0); + Class_AdminVar::set('AVIS_MAX_SAISIE', 1000); + + $lolo = $this->fixture('Class_Users', ['id' => 91, + 'login' => 'lolo', + 'password' => 'il l\'a ?', + 'pseudo' => 'Lolo']); + + $millenium = $this->fixture('Class_Notice', + ['id' => 9867, + 'titre_principal' => 'Millenium (Stieg Larsson)', + 'clef_alpha' => 'MILLENIUM', + 'url_vignette' => 'http://amazon.com/vignette.png']); + + $avis_millenium = $this->fixture('Class_AvisNotice', + ['id' => 23, + 'entete' => 'J\'adore', + 'avis' => 'Suspense intense', + 'note' => 5, + 'date_avis' => '2010-03-18 13:00:00', + 'user' => $lolo, + 'statut' => 1, + 'notices' => [$millenium]]); + + $avis_orphan = $this->fixture('Class_AvisNotice', + ['id' => 34, + 'entete' => 'J\'ai oublié', + 'avis' => 'Ce que c\'était', + 'note' => 2, + 'date_avis' => '2010-03-18 13:00:00', + 'user' => $lolo, + 'abon_ou_bib' => 0, + 'statut' => 1, + 'notices' => []]); + + $potter = $this->fixture('Class_Notice', + ['id' => 687, + 'titre_principal' => 'Potter', + 'url_vignette' => 'NO']); + + $avis_potter = $this->fixture('Class_AvisNotice', + ['id' => 87, + 'entete' => 'Le sorcier', + 'avis' => 'A du charme', + 'note' => 4, + 'date_avis' => '2010-03-18 13:00:00', + 'user' => $lolo, + 'abon_ou_bib' => 0, + 'statut' => 1, + 'notices' => [$potter]]); + + Class_Profil::setCurrentProfil($this->fixture('Class_Profil', ['id' => 18])); + } +} + + + +class CritiquesWithVignettesTest extends CritiquesAvisTestCase { + protected $_prefs = ['type_module' => 'CRITIQUES', + 'division' => 1, + 'preferences' => ['rss_avis' => true, + 'only_img' => 1, + 'display_order' => 'Random', + 'titre' => 'Livres préférés', + 'nb_aff_avis' => '3', + 'nb_words' => 20, + 'boite' => 'boite_de_la_division_droite']]; + + + /** @test */ + public function milleniumShouldBePresent() { $this->assertQueryContentContains($this->html, 'div.critique h2', 'Millenium'); } @@ -154,71 +144,129 @@ class CritiquesWithVignettesTest extends CritiquesAvisTestCase { /** @test */ public function linkToMilleniumShouldContainsRetourAvisIdModuleTwo() { $this->assertXPath($this->html, - '//a[contains(@href, "/recherche/viewnotice/id/9867/clef/MILLENIUM/retour_avis/2")]',$this->html); + '//a[contains(@href, "/recherche/viewnotice/id/9867/clef/MILLENIUM/retour_avis/2")]'); } - public function testPotterIsNotShown() { + + /** @test */ + public function potterShouldNotBePresent() { $this->assertNotQueryContentContains($this->html, 'div.critique h2', 'Potter'); } - public function testOrphanAvisIsNotShown() { + + /** @test */ + public function orphanShouldNotBePresent() { $this->assertNotQueryContentContains($this->html, 'a', utf8_encode("J'ai oublié")); } - public function testTitreIsLivresPreferes() { + + /** @test */ + public function titleShouldBeLivresPreferes() { $this->assertQueryContentContains($this->html, 'a', utf8_encode('Livres préférés')); } - public function testRSSLinkPresents() { - $this->assertXPath($this->html, "//a[contains(@href, 'rss/critiques?id_module=2&id_profil=18')]"); + + /** @test */ + public function rssLinkShouldBePresent() { + $this->assertXPath($this->html, + "//a[contains(@href, 'rss/critiques?id_module=2&id_profil=18')]"); } - public function testBoiteDivisionDroite() { + + /** @test */ + public function boiteDroiteShouldBePresent() { $this->assertXPath($this->html, "//div[@class='boiteDroite']"); } } -class CritiquesWithEmptyVignettesAllowedTest extends CritiquesAvisTestCase { - public function setUp() { - parent::setUp(); - - $params = array('type_module' => 'CRITIQUES', - 'division' => 1, - 'preferences' => array('rss_avis' => false, - 'only_img' => 0, - 'display_order' => 'Random', - 'titre' => 'Livres préférés', - 'nb_aff_avis' => '3', - 'nb_words' => 20, - 'boite' => null)); +class CritiquesWithEmptyVignettesAllowedTest extends CritiquesAvisTestCase { + protected $_prefs = ['type_module' => 'CRITIQUES', + 'division' => 1, + 'preferences' => ['rss_avis' => false, + 'only_img' => 0, + 'display_order' => 'Random', + 'titre' => 'Livres préférés', + 'nb_aff_avis' => '3', + 'nb_words' => 20, + 'boite' => null]]; - $helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $params); - $helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->html = $helper->getBoite(); - } - - public function testMilleniumIsHere() { + /** @test */ + public function milleniumShouldBePresent() { $this->assertQueryContentContains($this->html, 'div.critique h2', 'Millenium'); } - public function testPotterIsHere() { + + /** @test */ + public function potterShouldNotBePresent() { $this->assertQueryContentContains($this->html, 'div.critique h2', 'Potter'); } - public function testOrphanAvisIsNotShown() { + + /** @test */ + public function orphanShouldNotBePresent() { $this->assertNotQueryContentContains($this->html, 'a', utf8_encode("J'ai oublié")); } - public function testRSSLinkNotPresents() { - $this->assertNotXPath($this->html, "//div[@class='rss']/a[contains(@href, 'rss/critiques?id_module=2&id_profil=2')]"); + + /** @test */ + public function rssLinkShouldNotBePresent() { + $this->assertNotXPath($this->html, + "//a[contains(@href, 'rss/critiques?id_module=2&id_profil=2')]"); } - public function testBoiteDivisionGauche() { + + /** @test */ + public function boiteGaucheShouldBePresent() { $this->assertXPath($this->html, "//div[@class='boiteGauche']"); } } -?> \ No newline at end of file + + +class CritiquesHierarchicalByDomainViewTest extends CritiquesAvisTestCase { + protected $_prefs = ['type_module' => 'CRITIQUES', + 'division' => 1, + 'preferences' => ['rss_avis' => false, + 'only_img' => 0, + 'display_order' => 'Random', + 'titre' => '', + 'nb_aff_avis' => '3', + 'nb_words' => 20, + 'boite' => null, + 'hierarchical' => '1', + 'id_catalogue' => '180']]; + + + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + $this->fixture('Class_Catalogue', + ['id' => 180, + 'libelle' => 'THEME', + 'sous_domaines' => [$this->fixture('Class_Catalogue', + ['id' => 1234, + 'libelle' => 'Art']), + $this->fixture('Class_Catalogue', + ['id' => 1235, + 'libelle' => 'Litterature'])]]); + } + + + /** @test */ + public function shouldDisplayArtLink() { + $this->assertXPathContentContains($this->html, + '//a[contains(@href, "/blog/hierarchical/id/1234/start_id/1234/truncate_at/20")]', + 'Art'); + } + + + /** @test */ + public function shouldDisplayLitteratureLink() { + $this->assertXPathContentContains($this->html, + '//a[contains(@href, "/blog/hierarchical/id/1235/start_id/1235/truncate_at/20")]', + 'Litterature'); + } +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php index b76d286ee227981a4cb975f226f319e83f67ff1e..0252fe5fe09b16daeecee3d4b871182b034bcc60 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; @@ -28,6 +28,14 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserTestCase extends ViewHel public function setUp() { parent::setUp(); + + $this->mock_sql = $this->mock() + ->whenCalled('query')->answers(true) + ->whenCalled('execute')->answers(true); + + $this->old_sql = Zend_Registry::get('sql'); + Zend_Registry::set('sql', $this->mock_sql); + Class_CodifThesaurus::beVolatile(); $this->fixture('Class_Catalogue', @@ -50,6 +58,12 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserTestCase extends ViewHel 'libelle' => 'Acid']) ]])]]); } + + + public function tearDown() { + Zend_Registry::set('sql', $this->old_sql); + parent::tearDown(); + } } @@ -147,7 +161,7 @@ class ZendAfi_View_Helper_Accueil_DomainBrowserWithNoBreadcrumbSettingsTest exte public function divBreadcrumbShouldNotBeDisplay() { $this->assertNotXPath($this->_html, '//div[@class="breadcrumb_domains"]', $this->_html); } - + /** @test */ public function paramsBreadcrumpShouldNotBePresent() { @@ -161,10 +175,10 @@ class ZendAfi_View_Helper_Accueil_DomainBrowserWithDisplayModeSettingTest extend public function setup() { parent::setup(); $this->_html = $this->helper->getBoite(); - + } - + /** @test */ public function renderListShouldDisplayUlLiForChildren() { $this->assertXPath($this->_html, '//div[@class="domains"]//ul[@class="children"]//li//a',$this->_html); diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index a1c8269e52c6d85ac2e606535bc007a1b3afe946..d3bd2a613e3ae31824d3d31af6e7d0af840de5c1 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -25,31 +25,44 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueTestCase extends ViewHelperTes public function setUp() { parent::setUp(); + + $this->mock_sql = $this->mock(); + $this->old_sql = Zend_Registry::get('sql'); + Zend_Registry::set('sql', $this->mock_sql); + defineConstant("PATH_SKIN", "./public/opac/skins/original/"); $this->_helper = new ZendAfi_View_Helper_Accueil_Kiosque(3, $this->getPreferences()); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->_notices = [Class_Notice::newInstanceWithId(2, - ['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", - 'url_vignette' => 'hp.png', - 'url_image' => 'hp_big.png', - 'facettes' => 'D123 A400 Y2', - 'clef_oeuvre' => 'HPELPA', - 'clef_alpha' => 'POTTER', - 'exemplaires' => []]), + $this->_notices = [$this->fixture('Class_Notice', + ['id' => 2, + 'unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", + 'url_vignette' => 'hp.png', + 'url_image' => 'hp_big.png', + 'facettes' => 'D123 A400 Y2', + 'clef_oeuvre' => 'HPELPA', + 'clef_alpha' => 'POTTER', + 'exemplaires' => []]), + + $this->fixture('Class_Notice', + ['id' => 45, + 'unimarc' => "01328ngm0 2200265 450 0010007000001000041000071010013000481020007000611150025000682000071000932100022001642150053001863000035002393000045002743300454003193450027007735100018008006060027008186060039008457000042008847020043009267020033009697020032010028010028010342247456 a20021213i20041975u y0frey0103 ba0 abamjfre aFR ac086baz|zba zz c1 aLa jeune fillebDVDdDen MusofSouleymane Cisse, réal., scénario cPathédcop. 2004 a1 DVD vidéo monoface zone 2 (1 h 26 min)ccoul. aDate de sortie du film : 1975. aFilm en bambara sous-titré en français aSékou est renvoyé de l'usine parce qu'il a osé demander une augmentation. Chômeur, il sort avec Ténin, une jeune fille muette ; il ignore qu'elle est la fille de son ancien patron. Ténin, qui sera violée par Sékou lors d'une sortie entre jeunes, se retrouve enceinte et subit la colère de ses parents. Elle se trouve alors confrontée brutalement à la morale de sa famille et à la lâcheté de Sékou, qui refuse de reconnaiîre l'enfant. b3388334509824d14.00 ?1 aDen Musozbam| 31070135aCinémayMali| 32243367aCinéma30076549yAfrique 131070144aCissébSouleymane43704690 132247457aCoulibalibDounamba Dani4590 132247458aDiabatebFanta4590 132247459aDiarrabOumou4590 0aFRbBNc20011120gAFNOR", + 'url_vignette' => 'jeune_fille.png', + 'url_image' => 'jeune_fille_big.png', + 'facettes' => 'D13 A10 Y1', + 'clef_oeuvre' => 'JF', + 'clef_alpha' => 'JF', + 'exemplaires' => []]) + ]; + } - Class_Notice::newInstanceWithId(45, - ['unimarc' => "01328ngm0 2200265 450 0010007000001000041000071010013000481020007000611150025000682000071000932100022001642150053001863000035002393000045002743300454003193450027007735100018008006060027008186060039008457000042008847020043009267020033009697020032010028010028010342247456 a20021213i20041975u y0frey0103 ba0 abamjfre aFR ac086baz|zba zz c1 aLa jeune fillebDVDdDen MusofSouleymane Cisse, réal., scénario cPathédcop. 2004 a1 DVD vidéo monoface zone 2 (1 h 26 min)ccoul. aDate de sortie du film : 1975. aFilm en bambara sous-titré en français aSékou est renvoyé de l'usine parce qu'il a osé demander une augmentation. Chômeur, il sort avec Ténin, une jeune fille muette ; il ignore qu'elle est la fille de son ancien patron. Ténin, qui sera violée par Sékou lors d'une sortie entre jeunes, se retrouve enceinte et subit la colère de ses parents. Elle se trouve alors confrontée brutalement à la morale de sa famille et à la lâcheté de Sékou, qui refuse de reconnaiîre l'enfant. b3388334509824d14.00 ?1 aDen Musozbam| 31070135aCinémayMali| 32243367aCinéma30076549yAfrique 131070144aCissébSouleymane43704690 132247457aCoulibalibDounamba Dani4590 132247458aDiabatebFanta4590 132247459aDiarrabOumou4590 0aFRbBNc20011120gAFNOR", - 'url_vignette' => 'jeune_fille.png', - 'url_image' => 'jeune_fille_big.png', - 'facettes' => 'D13 A10 Y1', - 'clef_oeuvre' => 'JF', - 'clef_alpha' => 'JF', - 'exemplaires' => []]), - ]; + public function tearDown() { + Zend_Registry::set('sql', $this->old_sql); + Storm_Cache::setDefaultZendCache(null); + parent::tearDown(); } } @@ -239,11 +252,6 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendA ->addNotice(Class_Notice::newInstanceWithId(96, ['titre_principal' => 'Bitches Brew', 'clef_alpha' => 'BB'])); - - $this->old_sql = Zend_Registry::get('sql'); - $this->mock_sql = Storm_Test_ObjectWrapper::mock(); - Zend_Registry::set('sql', $this->mock_sql); - $this->mock_sql ->whenCalled('fetchOne') ->with("select count(*) from notices where notices.clef_alpha in('BB') and url_vignette > '' and url_vignette != 'NO' ") @@ -264,12 +272,6 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendA } - public function tearDown() { - Zend_Registry::set('sql', $this->old_sql); - parent::tearDown(); - } - - public function getPreferences() { return ['type_module' => 'KIOSQUE', 'division' => 3, @@ -332,12 +334,6 @@ class ZendAfi_View_Helper_Accueil_KiosqueRequetesWithCacheEnabledTest extends Ze } - public function tearDown() { - Storm_Cache::setDefaultZendCache(null); - parent::tearDown(); - } - - /** @test */ public function notFoundInCacheShouldDisplayIt() { $this->_html = $this->_helper->getBoite(); @@ -503,10 +499,18 @@ class ZendAfi_View_Helper_Accueil_KiosqueTitle extends ViewHelperTestCase { class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ZendAfi_View_Helper_Accueil_KiosqueTestCase { - - public function setUp() { parent::setUp(); + $this->mock_sql + ->whenCalled('fetchOne') + ->with("select count(*) from notices Where url_vignette > '' and url_vignette != 'NO'") + ->answers(2) + + ->whenCalled('fetchAllByColumn') + ->with("select notices.id_notice from notices Where url_vignette > '' and url_vignette != 'NO' order by date_creation DESC LIMIT 5000") + ->answers([2, 45]) + + ->beStrict(); } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php b/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php index b00789d5cda40089002bd76e6bc418a950227b71..47344cadb7517ed602f704955fae45837ca536ef 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php @@ -16,12 +16,15 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; -class PretsTestWithConnectedUser extends ViewHelperTestCase { +class PretsTestWithConnectedUser extends ViewHelperTestCase { + protected + $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -32,7 +35,7 @@ class PretsTestWithConnectedUser extends ViewHelperTestCase { 'titre' => 'Mes documents']]); $helper->setView(new ZendAfi_Controller_Action_Helper_View()); - + $alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456)); $alice->getExemplaire() @@ -59,14 +62,14 @@ class PretsTestWithConnectedUser extends ViewHelperTestCase { $emprunteur->empruntsAddAll(array( $klein, $alice)); $this->html = $helper->getBoite(); } - + /** @test */ public function h1ShouldContainsMesPrets () { $this->assertXPathContentContains($this->html,'//h1','Mes documents'); } - + /** @test */ public function listShouldDisplayAliceNotice() { $this->assertXPathContentContains($this->html,'//ul//li','Alice'); @@ -110,14 +113,14 @@ class PretsTestWithConnectedUser extends ViewHelperTestCase { public function titleShouldBeLinkedToAbonnePrets () { $this->assertXPath($this->html,'//h1//a[contains(@href,"/abonne/prets")]',$this->html); } - + } -class PretsTestWithNonConnectedUser extends ViewHelperTestCase { +class PretsTestWithNonConnectedUser extends ViewHelperTestCase { public function setUp() { parent::setUp(); @@ -129,7 +132,7 @@ class PretsTestWithNonConnectedUser extends ViewHelperTestCase { $this->helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->html = $this->helper->getBoite(); } - + /** @test */ public function boitePretsShouldNotBeDisplayed () { diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index 8026bc4b4cb3ae112966e7c362c9b4b87ee0b204..df66155a0a2f2dac4696e4c13a4e27626ea8516c 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -21,41 +21,76 @@ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; abstract class SitoViewHelperTestCase extends ViewHelperTestCase { + protected $_storm_default_to_volatile = true; + protected $html; - protected $_preferences = array(); + protected $_preferences = []; + protected $_belgique; + protected $_france; + protected $_creuse; + public function setUp() { parent::setUp(); - Class_Sitotheque::beVolatile(); - Class_SitothequeCategorie::beVolatile(); - Class_AdminVar::beVolatile(); - Class_AdminVar::newInstanceWithId('BLUGA_API_KEY', ['valeur' => ''])->save(); - - $belgique = Class_SitothequeCategorie::newInstanceWithId(5, ['libelle'=>'Belgique']); - $belgique->save(); - $france = Class_SitothequeCategorie::newInstanceWithId(9,['libelle'=>'France']); - - $france->save(); - $site_fosdem = Class_Sitotheque::newInstanceWithId(12, - ['titre'=>'FOSDEM', - 'description' => 'plein de bières belges', - 'url' => 'http://www.fosdem.org', - 'categorie' => $belgique]); - - $site_fosdem->save(); - $site_rmll = Class_Sitotheque::newInstanceWithId(15, - ['titre'=>'RMLL', - 'description' => 'du vin du vin!', - 'url' => 'http://www.rmll.info', - 'categorie' => $france]); + Class_AdminVar::newInstanceWithId('BLUGA_API_KEY', ['valeur' => ''])->save(); + $this->_belgique = $this->fixture('Class_SitothequeCategorie', + ['id' => 5, 'libelle'=>'Belgique']); + + $this->_france = $this->fixture('Class_SitothequeCategorie', + ['id' => 9, 'libelle'=>'France']); + + $this->_creuse = $this->fixture('Class_SitothequeCategorie', + ['id' => 23, + 'parent_categorie' => $this->_france, + 'libelle' => 'La Creuse']); + + $this->_lozere = $this->fixture('Class_SitothequeCategorie', + ['id' => 32, + 'parent_categorie' => $this->_france, + 'libelle' => 'La Lozere']); + + $this->fixture('Class_SitothequeCategorie', + ['id' => 24, + 'parent_categorie' => $this->_creuse, + 'libelle' => 'Gueret']); + + $this->fixture('Class_SitothequeCategorie', + ['id' => 33, + 'parent_categorie' => $this->_lozere, + 'libelle' => 'Mende']); + + Class_Sitotheque::setTimeSource(new TimeSourceForTest('2014-05-02 14:14:14')); + + $site_fosdem = $this->fixture('Class_Sitotheque', + ['id' => 12, + 'titre'=>'FOSDEM', + 'description' => 'plein de bières belges', + 'url' => 'http://www.fosdem.org', + 'categorie' => $this->_belgique]); + + for ($id = 16; $id < 25; $id++) { + $this->fixture('Class_Sitotheque', + ['id' => $id, + 'titre'=> 'Sito numero '.$id, + 'description' => 'lien dupliques', + 'url' => 'http://www.unlien.info', + 'categorie' => $this->_france]); + } - $site_rmll->save(); + Class_Sitotheque::setTimeSource(new TimeSourceForTest('2014-05-20 16:14:14')); + $this->fixture('Class_Sitotheque', + ['id' => 15, + 'titre'=>'RMLL', + 'description' => 'du vin du vin!', + 'url' => 'http://www.rmll.info', + 'categorie' => $this->_france]); $this->_helper = new ZendAfi_View_Helper_Accueil_Sito(2, ['division' => '1', 'type_module' => 'SITO', 'preferences' => $this->_preferences]); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->html = $this->_helper->getBoite(); } @@ -83,7 +118,7 @@ class SitoViewHelperSelectItemsBySelectionOrderTest extends SitoViewHelperTestCa public function secondSiteShouldBeRMLL() { $this->assertXPathContentContains($this->html, '//div/div[2]//h2//a', - 'FOSDEM'); + 'RMLL'); } } @@ -97,12 +132,12 @@ class SitoViewHelperSelectItemsByRandomOrderTest extends SitoViewHelperTestCase 'id_categorie' => '', 'nb_aff' => 2, 'display_order' => 'Random']; + /** @test */ public function itemsShouldBeShuffled() { $htmls = []; - for($i=0; $i<10; $i++) { - $htmls []= $this->_helper->getBoite(); - } + for($i=0; $i < 10; $i++) + $htmls[] = $this->_helper->getBoite(); $this->assertEquals(2, count(array_unique($htmls))); } @@ -147,9 +182,10 @@ class SitoViewHelperSelectItemsAndCatsTest extends SitoViewHelperTestCase { class SitoViewHelperLastTest extends SitoViewHelperTestCase { - protected $_preferences = array('titre' => 'Derniers sites', - 'type_aff' => 2, - 'nb_aff' => 2); + protected $_preferences = ['titre' => 'Derniers sites', + 'type_aff' => 2, + 'nb_aff' => 100, + 'display_order' => 'Random']; /** @test */ public function titleShouldBeDerniersSites() { @@ -163,29 +199,29 @@ class SitoViewHelperLastTest extends SitoViewHelperTestCase { public function h2ShouldContainsRmllDotInfo() { $this->assertXPathContentContains($this->html, '//h2//a[contains(@href, "rmll.info")]', - 'RMLL'); + 'RMLL', + $this->html); } + /** @test */ public function itemsShouldBeShuffled() { $htmls = []; - for($i=0; $i<10; $i++) { - $htmls []= $this->_helper->getBoite(); - } + for ($i=0; $i<10; $i++) + $htmls[] = $this->_helper->getBoite(); - $this->assertEquals(2, count(array_unique($htmls))); + $this->assertTrue(1 < count(array_unique($htmls))); } - } class SitoViewHelperGroupByCategorieTest extends SitoViewHelperTestCase { - protected $_preferences = array('titre' => 'Ma sito', - 'type_aff' => 2, - 'nb_aff' => 2, - 'group_by_categorie' => true); + protected $_preferences = ['titre' => 'Ma sito', + 'type_aff' => 2, + 'nb_aff' => 100, + 'group_by_categorie' => true]; /** @test */ @@ -211,4 +247,56 @@ class SitoViewHelperGroupByCategorieTest extends SitoViewHelperTestCase { } } -?> \ No newline at end of file + + +class SitoViewHelperHierarchicalCategoryTest extends SitoViewHelperTestCase { + protected $_preferences = ['titre' => 'My website library', + 'type_aff' => '3', + 'id_items' => '', + 'id_categorie' => '9', + 'nb_aff' => 1, + 'display_order' => 'Selection']; + + + /** @test */ + public function shouldDisplayTwoCategories() { + $this->assertXPathCount($this->html, + '//a[contains(@href, "/sito/viewcategory")]', + 2, + $this->html); + } + + + /** @test */ + public function categoryGueretShouldNotBeDisplayed() { + $this->assertNotXPathContentContains($this->html, + '//ul[@class="sitotheque"]/li//a', + 'Gueret'); + } + + + /** @test */ + public function rmllShouldBeDisplayed() { + $this->assertXPathContentContains($this->html, + '//ul[@class="sitotheque"]//li//a', + 'RMLL'); + + } + + + /** @test */ + public function fosdemShouldNotBeDisplayed() { + $this->assertNotXPathContentContains($this->html, + '//ul[@class="sitotheque"]//li//a', + 'FOSDEM'); + + } + + + /** @test */ + public function urlShouldRedirectToViewPage() { + $this->assertXPathContentContains($this->html, + '//h2//a[contains(@href, "/sito/viewcategory/id_cat/23/start_cat/23")]', + 'La Creuse'); + } +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Admin/AdminHelpLinkTest.php b/tests/library/ZendAfi/View/Helper/Admin/AdminHelpLinkTest.php index 9c4a26432cdbcbc63f1c143da78fbfa94e55e957..3e0b45bf3f49001ad1357b6e69ce27734ddc14fd 100644 --- a/tests/library/ZendAfi/View/Helper/Admin/AdminHelpLinkTest.php +++ b/tests/library/ZendAfi/View/Helper/Admin/AdminHelpLinkTest.php @@ -37,16 +37,16 @@ class AdminHelpLinkHelperTest extends ViewHelperTestCase { } - protected function assertHelpLink($help_id) { - $html = $this->helper->helpLink(); + protected function assertHelpLink($help_id, $action=null) { + $html = $this->helper->helpLink($action); $this->assertXPath($html, "//a[@href='https://akm.ardans.fr/AFI2/invite/listerFiche.do?idFiche=$help_id']", $html); } - protected function assertWikiLink($page) { - $html = $this->helper->helpLink(); + protected function assertWikiLink($page, $action=null) { + $html = $this->helper->helpLink($action); $path = sprintf('//a[@href="http://wiki.bokeh-library-portal.org/index.php/%s"]', $page); $this->assertXPath($html, $path, $html); @@ -54,39 +54,47 @@ class AdminHelpLinkHelperTest extends ViewHelperTestCase { /** @test */ - public function helpForZorkShouldReturnEmptyString() { + public function helpForZorkShouldBeEmpty() { $this->setControllerAction('Zork'); $this->assertEquals('', $this->helper->helpLink()); } /** @test */ - public function helpForProfilMenusIndexShouldReturnFiche3618() { + public function helpForProfilMenusIndexShouldBeWiki() { $this->setControllerAction('profil', 'menusindex'); $this->assertWikiLink('Configurer_un_menu'); } /** @test */ - public function helpForProfilIndexShouldReturnFiche3612() { + public function helpForProfilIndexShouldBeWiki() { $this->setControllerAction('profil', 'index'); $this->assertWikiLink('Configurer_un_profil'); } /** @test */ - public function helpForProfilIndexUpperCaseShouldReturnFiche3612() { + public function helpForProfilIndexUpperCaseShouldBeWiki() { $this->setControllerAction('ProFil', 'inDex'); $this->assertWikiLink('Configurer_un_profil'); } /** @test */ - public function helpForProfilZorkShouldReturnFiche3612() { + public function helpForProfilZorkShouldBeWiki() { $this->setControllerAction('profil', 'zork'); $this->assertWikiLink('Configurer_un_profil'); } + + /** @test */ + public function helpForAccueilCritiquesShouldBeWiki() { + $this->setControllerAction('accueil', 'critiques'); + $this->assertWikiLink('Boite_Critiques'); + } + + /** @test */ public function helpForProfilAccueiShouldReturnFiche3614() { $this->setControllerAction('profil', 'accueil'); @@ -95,14 +103,14 @@ class AdminHelpLinkHelperTest extends ViewHelperTestCase { /** @test */ - public function helpForCatalogueShouldReturnFiche3613() { + public function helpForCatalogueShouldBeWiki() { $this->setControllerAction('catalogue'); $this->assertWikiLink('Gestions_des_domaines'); } /** @test */ - public function helpForCatalogueEditShouldReturnFiche3613() { + public function helpForCatalogueEditShouldBeWiki() { $this->setControllerAction('catalogue', 'edit'); $this->assertWikiLink('Gestions_des_domaines'); } @@ -116,7 +124,7 @@ class AdminHelpLinkHelperTest extends ViewHelperTestCase { /** @test */ - public function helpForAccueilIndexSouldReturnEmptyString() { + public function helpForAccueilIndexSouldBeEmpty() { $this->setControllerAction('accueil', 'index'); $this->assertEquals('', $this->helper->helpLink()); } @@ -137,21 +145,15 @@ class AdminHelpLinkHelperTest extends ViewHelperTestCase { /** @test */ - public function helpForModuleRechercheViewNoticeSouldReturnFiche3647() { + public function helpForModuleRechercheViewNoticeShouldBeWiki() { $this->setControllerAction('modules', 'recherche'); - - $html = $this->helper->helpLink("recherche_viewnotice"); - $this->assertXPath($html, - "//a[@href='http://wiki.bokeh-library-portal.org/index.php/Affichage_d%27une_notice']"); + $this->assertWikiLink('Affichage_d%27une_notice', 'recherche_viewnotice'); } /** @test */ public function helpForModuleRechercheResultatSouldReturnFiche3643() { $this->setControllerAction('modules', 'recherche'); - - $html = $this->helper->helpLink("recherche_resultat"); - $this->assertXPath($html, - "//a[@href='https://akm.ardans.fr/AFI2/invite/listerFiche.do?idFiche=3643']"); + $this->assertHelpLink(3643, 'recherche_resultat'); } } \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php index a9c3bd3902e05caffb46548edfe240b6488d6780..8933ba6f1c66ee2dc01b6701d59f9641d3a2dc73 100644 --- a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php +++ b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php @@ -41,15 +41,18 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminVariableAsAdminTest extends ZendA public function setUp() { parent::setUp(); + Zend_Registry::get('translate')->setLocale('fr'); $this->login(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL); RessourcesNumeriquesFixtures::activateOrphea(); + RessourcesNumeriquesFixtures::deactivateDilicom(); + RessourcesNumeriquesFixtures::activateJamendo(); $this->html = $this->helper->menuGaucheAdmin(); } /** @test **/ - public function BibNumEpubShouldBePresent() { + public function bibNumEpubShouldBePresent() { $this->assertXPath($this->html, '//a[contains(@href, "/admin/opds")]', $this->html); } @@ -105,10 +108,16 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminVariableAsAdminTest extends ZendA } + /** @test */ + public function menuGaucheAdminShouldContainsJamendo() { + $this->assertXPath($this->html, '//a[contains(@href, "/admin/harvest/jamendo-browse")]'); + } + + /** @test */ public function menuGaucheAdminShouldContainsFusionTemplatesForPrint() { $this->assertXPath($this->html, '//a[contains(@href, "/admin/print/index")]'); - } + } } diff --git a/tests/library/ZendAfi/View/Helper/Admin/TagSelectionChampsTest.php b/tests/library/ZendAfi/View/Helper/Admin/TagSelectionChampsTest.php index cca65de0e19acae3d6f44b211ef434e4201d37c6..fa3098a9cf4465006a0f0da2a89af77302a7575b 100644 --- a/tests/library/ZendAfi/View/Helper/Admin/TagSelectionChampsTest.php +++ b/tests/library/ZendAfi/View/Helper/Admin/TagSelectionChampsTest.php @@ -16,43 +16,53 @@ * * 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_Admin_TagSelectionChampsTest extends ViewHelperTestCase { - protected $_html; + protected + $_storm_default_to_volatile = true, + $_html; public function setUp() { parent::setUp(); + Class_Codification::resetInstance(); $this->_helper = new ZendAfi_View_Helper_Admin_TagSelectionChamps(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->fixture('Class_CodifThesaurus', ['id'=>5, + 'id_thesaurus'=>'PUBL', + 'libelle' => 'Themes ', + 'libelle_facette' => 'Public Electre']); + $this->_result = $this->_helper->TagSelectionChamps("facettes", "AHPUBLYZ"); + $this->_html=$this->_result["bloc_saisie"]; } /** @test */ public function linkToFacettePShouldBePresent() { - $this->assertXPath($this->_html, - '//div[@id="facettes_box_P"]'); + $this->assertXPath($this->_html, + '//div[@id="facettes_box_P"]'); } /** @test */ public function linkToFacetteHPUBLShouldBePresent() { - $this->assertXPath($this->_html, - '//div[@id="facettes_box_HPUBL"]'); + $this->assertXPath($this->_html, + '//div[@id="facettes_box_HPUBL"]', + $this->_html); } /** @test */ public function linkToFacetteYShouldBePresent() { - $this->assertXPath($this->_html, - '//div[@id="facettes_box_Y"]'); + $this->assertXPath($this->_html, + '//div[@id="facettes_box_Y"]'); } - + /** @test */ public function linkToNouveauteShouldBePresent() { $this->_result = $this->_helper->TagSelectionChamps('liste', ''); diff --git a/tests/library/ZendAfi/View/Helper/AvisTest.php b/tests/library/ZendAfi/View/Helper/AvisTest.php index d85bfe77ca4300dd8ee27e8cf0cd622e3f1d0e89..79bdd70afdd5f928947b0728d9400c204110cb1c 100644 --- a/tests/library/ZendAfi/View/Helper/AvisTest.php +++ b/tests/library/ZendAfi/View/Helper/AvisTest.php @@ -134,6 +134,41 @@ class ViewHelperAvisTestWithAvisNotice extends ViewHelperTestCase { } +class ViewHelperAvisTestAsBib extends ViewHelperTestCase { + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil()->setSkin('original'); + + $tintin = new Class_Users(); + $tintin + ->setId(26) + ->setPseudo('Tintin'); + + $orphan_avis = new Class_AvisNotice(); + $orphan_avis + ->setId(67) + ->setEntete("Bof") + ->setAvis("Pas\nterrible") + ->setNote(2.5) + ->setDateAvis('2010-01-02 10:00:00') + ->setUser($tintin) + ->setStatut(0) + ->setAbonOuBib(1) + ->setNotices(array()); + + $helper = new ZendAfi_View_Helper_Avis(); + $helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->html = $helper->avis($orphan_avis); + } + + public function testBrInAvis() { + $this->assertTrue(strpos($this->html, "Pas<br />\nterrible") !== false, $this->html); + } + + +} + class ViewHelperAvisTestWithoutAvisNoticeAndModeration extends ViewHelperTestCase { public function setUp() { parent::setUp(); @@ -232,30 +267,35 @@ class ViewHelperAvisTestWithoutAvisNoticeAndModeration extends ViewHelperTestCas class ViewHelperAvisTestHtmlForCritiquesModule extends ViewHelperTestCase { - public function setUp() { - $tintin = new Class_Users(); - $tintin - ->setId(26) - ->setPseudo('Tintin'); + protected $_storm_default_to_volatile = true; - $millenium = new Class_Notice(); - $millenium - ->setId(9867) - ->setTitrePrincipal('Millenium (Stieg Larsson)') - ->setUrlVignette('http://amazon.com/vignette.png'); + public function setUp() { + parent::setUp(); - $avis_millenium = new Class_AvisNotice(); - $avis_millenium - ->setId(23) - ->setEntete("J'adore") - ->setAvis("Suspense intense très - intéressant longue critique") - ->setNote(5) - ->setDateAvis('2010-03-18 13:00:00') - ->setUser($tintin) - ->setStatut(0) - ->setAbonOuBib(0) - ->setNotices(array($millenium)); + Class_AdminVar::set('AVIS_MIN_SAISIE', 0); + Class_AdminVar::set('AVIS_MAX_SAISIE', 1000); + + $tintin = $this->fixture('Class_Users', + ['id' => 26, + 'login' => 'tintin', + 'password' => 'milou4ever', + 'pseudo' => 'Tintin']); + + $millenium = $this->fixture('Class_Notice', + ['id' => 9867, + 'titre_principal' => 'Millenium (Stieg Larsson)', + 'url_vignette' => 'http://amazon.com/vignette.png']); + + $avis_millenium = $this->fixture('Class_AvisNotice', + ['id' => 23, + 'entete' => 'J\'adore', + 'avis' => "Suspense intense très\n intéressant longue critique", + 'note' => 5, + 'date_avis' => '2010-03-18 13:00:00', + 'user' => $tintin, + 'abon_ou_bib' => 0, + 'statut' => 0, + 'notices' => [$millenium]]); $helper = new ZendAfi_View_Helper_Avis(); $helper->setView(new ZendAfi_Controller_Action_Helper_View()); @@ -265,19 +305,25 @@ class ViewHelperAvisTestHtmlForCritiquesModule extends ViewHelperTestCase { ->avis($avis_millenium); } - public function testVignetteLinkToAvis() { + + /** @test */ + public function vignetteLinkToAvisShouldBePresent() { $this->assertXPath($this->html, "//div[@class='vignette_notice']/a[contains(@href,'/blog/viewavis/id/23')]"); } - public function testAvisCut() { - $this->assertQueryContentContains($this->html, 'p', "Suspense intense [...]"); + + /** @test */ + public function textShouldBeTruncated() { + $this->assertXPathContentContains($this->html, '//p', 'Suspense intense [...]'); } - public function testLinkLireLaSuite() { + + /** @test */ + public function lireLaSuiteShouldBePresent() { $this->assertXPathContentContains($this->html, "//div[@class='lire_la_suite']/a[contains(@href,'/blog/viewavis/id/23')]", - "Lire la suite"); + 'Lire la suite'); } } diff --git a/tests/library/ZendAfi/View/Helper/BiographieTest.php b/tests/library/ZendAfi/View/Helper/BiographieTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0ac5822283f1c5240e0f3ba6bb077bd62d98ab71 --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/BiographieTest.php @@ -0,0 +1,41 @@ +<?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_BiographieAuthorTest extends ViewHelperTestCase { + public function setUp() { + parent::setUp(); + $view = new ZendAfi_Controller_Action_Helper_View(); + $this->_helper = new ZendAfi_View_Helper_Biographie(); + $this->_helper->setView($view); + $this->_html = $this->_helper->renderBiographie(['source' => 'wiki', + 'biographie' => '<p>A html biographie !</p>'], + $this->fixture('Class_Notice', + ['id' => 1])); + } + + + /** @test */ + public function biographieShouldContainsHtml() { + $this->assertEquals('<p>Source : wiki</p><p>A html biographie !</p>', $this->_html); + } +} +?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/CkEditorTest.php b/tests/library/ZendAfi/View/Helper/CkEditorTest.php index 7f445b08b6aa0ab3c2bd3c51475decffc45e9a98..c6fbb603d419d356bb12d8dd63ba1fc0bffded03 100644 --- a/tests/library/ZendAfi/View/Helper/CkEditorTest.php +++ b/tests/library/ZendAfi/View/Helper/CkEditorTest.php @@ -80,4 +80,56 @@ class CkEditorViewHelperTest extends ViewHelperTestCase { public function cmsFormulaireShouldAllowStyleAttribute() { $this->assertContains('"extraAllowedContent":{"audio video":{"attributes":"*"},"source":{"attributes":["src","type"]},"map":{"attributes":"name"},"area":{"attributes":["shape","coords","href","alt"]},"span":{"classes":"*"},"*":{"attributes":"id","styles":"*"}}', $this->_html); } + + + /** @test */ + public function editorShouldNotAllowedContentForSimpleUser() { + $this->assertNotContains('"allowedContent":true',$this->_html); + } + + /** @test */ + public function editorShouldAddParagraphTagsForSimpleUser() { + $this->assertNotContains('"autoParagraph":false',$this->_html); + } + + +} + +class CkEditorAdminViewHelperTest extends ViewHelperTestCase { + public function setUp() { + parent::setUp(); + $annecy = $this->fixture('Class_Bib',['id' => 1, + 'id_zone' => 4, + 'libelle' => 'Annecy' + ]); + $this->_admin_bib = $this->fixture('Class_Users',['id' => 10, + 'login' => 'AdminBibConnected', + 'bib' => $annecy, + 'role' => 'admin_bib', + 'mail' => 'admin@afi-sa.fr', + 'password' => 'toto', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_BIB, + 'user_groups' => [Class_UserGroup::find(22)]]); + + ZendAfi_Auth::getInstance()->logUser($this->_admin_bib); + $this->_helper = new ZendAfi_View_Helper_CkEditor(); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + if (!defined('URL_CSS')) + define('URL_CSS',''); + + $this->_html=$this->_helper->ckeditor('','',''); + } + + + /** @test */ + public function editorShouldAllowedContentForModoUser() { + $this->assertContains('"allowedContent":true',$this->_html); + } + + + /** @test */ + public function editorShouldNotAddParagraphTags() { + $this->assertContains('"autoParagraph":false',$this->_html); + } + } diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3d0ef7c74046c9322a1c939de6daa416bd0bfd11 --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php @@ -0,0 +1,58 @@ +<?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 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; + +class VignettesRGAATest extends ViewHelperTestCase { + public function setUp() { + parent::setUp(); + Storm_Model_Loader::defaultToVolatile(); + defineConstant('PATH_SKIN', './public/opac/skins/original/'); + + $helper = new ZendAfi_View_Helper_ListeNotices_Vignettes(); + $helper->setView($this->view); + + $notice = $this + ->fixture('Class_Notice', + ['id' => 3455, + 'unimarc' => $this->_unimarcFromFile('beatrix_potter.txt')]); + + $this->_html = $helper->listeNotices_Vignettes([$notice]); + } + + + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } + + + /** @test */ + public function withoutAuthorShouldNotHaveEmptyAnchors() { + $this->assertNotXPath($this->_html, '//div[@class="vignette_auteur"]//a[normalize-space(text())]', $this->_html); + } + + + protected function _unimarcFromFile($name) { + return file_get_contents(realpath(dirname(__FILE__)) . '/' . $name); + } +} diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/beatrix_potter.txt b/tests/library/ZendAfi/View/Helper/ListeNotices/beatrix_potter.txt new file mode 100644 index 0000000000000000000000000000000000000000..3a84699bb87214f4163da7d57b8ee4da251247ef --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/beatrix_potter.txt @@ -0,0 +1 @@ +00952cgm0a22001932 450 00100070000000500170000703500150002409000110003910000410005020000650009121500360015633004690019267600150066169000130067680100090068980100220069880100220072095100160074232761420140415011730.0 ablv-X31702 a327614 a20071205u u0frey5003 ba11aBeatrix PottereLes lapins de Flopsaut et deux autres contes a1 DVD, 77mn, CouleurdDVD VIDEO aD'après l'oeuvre originale de Beatrix POTTER (Gallimard Jeunesse)... - Mac Gregor trouve les petits de Benjamin Lapin endormis dans son jardin après avoir dégusté ses salades... Il les enferme dans un sac de toile... + 2 autres contes : "L'aventure des deux souris" et "L'aventure de monsieur Tod". Infos DVD : 1 DVD-5 / 4/3 / Dolby Digital 2.0 / LG : Fre + Fre pour sourds et malentendants / Biographie et bibliographie de Beatrix Potter. Enfant de 3 à 7 ans 3123021aEF 3665aFAN 1bADAV 2aFRbBLVc20130718 3aFRbBLVc20140414 aDKb ** c1 \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php b/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b12d8da768c94abd0c9a4cbd52279e5432151c8d --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Notice_EnteteTest extends ViewHelperTestCase { + protected $_html; + + public function setUp() { + parent::setUp(); + Storm_Model_Loader::defaultToVolatile(); + $this->_helper = new ZendAfi_View_Helper_Notice_Entete(); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_view = new ZendAfi_Controller_Action_Helper_View(); + + $this->fixture('Class_IntBib', + ['id' => 1]); + + $album = $this->fixture('Class_Album', + ['id' => 99, + 'titre' => 'Plein de medias', + 'visible' => 1, + 'status' => Class_Album::STATUS_VALIDATED]) + ->beDiaporama() + ->setNoticeId(500) + ->setIdOrigine("A888") + ->setCote('50') + ->setDateMaj('2012-02-17 10:00:00') + ->setDescription('<p>pour passer la soirée</p>') + ->setNotes(['305$a' => 'XXe siècle', + '200$b' => 'Parchemin', + '316$a' => 'Reliure restaurée en 1980 par la BN.']) + ->setIdLang('lat') + + ->setRessources([Class_AlbumRessource::newInstanceWithId(2) + ->setFichier('mimi_jolie.mp3') + ->setTitre('Emilie jolie') + ->setOrdre(1) + ->setPoster('mimi_jolie.png'), + + Class_AlbumRessource::newInstanceWithId(4) + ->setFichier('dark_night.mp4') + ->setTitre('Batman Dark Knight') + ->setPoster('batman.jpg') + ->setOrdre(2) + ->setDuration('00:02:30') + ->setDescription('Une nouvelle aventure du justicier noir'), + + Class_AlbumRessource::newInstanceWithId(5) + ->setUrl('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4') + ->setTitre('Hunger Games') + ->setOrdre(3) + ->setPoster('hunger.jpg'), + + Class_AlbumRessource::newInstanceWithId(6) + ->setFichier('Monsieur l\'escargot.mp3') + ->setTitre('Monsieur l\'escargot') + ->setOrdre(4) + ->setPoster('l\'escargot.jpg')]); + + $album->index(); + + $notice = $album->getNotice(); + + $this->_html = $this->_helper->Notice_Entete($notice, ['entete' => Class_Codification::CHAMPS]); + } + + + public function tearDown() { + Storm_Model_Loader::defaultToDb(); + parent::tearDown(); + } + + + /** @test */ + public function notesShouldContainsRestoredByBNF() { + $this->assertXPathContentContains($this->_html, '//dl//dd', utf8_encode('<div>XXe siècle</div><div>Reliure restaurée en 1980 par la BN.</div>'), $this->_html); + } + + + /** @test */ + public function resumeShouldCOntainsForTheEvening() { + $this->assertXPathContentContains($this->_html, '//dl//dd', utf8_encode('<p>pour passer la soirée</p>'), $this->_html); + } +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php index 0ab59c377db3edde828b8d8f733eb3d8616a584a..20d07ce947cabac56257d28c27857e7d00f7881d 100644 --- a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php +++ b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +require_once 'tests/fixtures/DilicomFixtures.php'; + abstract class ZendAfi_View_Helper_RenderAlbumTestCase extends ViewHelperTestCase { /** @var ZendAfi_View_Helper_RenderForm */ protected $_helper; @@ -112,7 +114,7 @@ class ZendAfi_View_Helper_RenderAlbumFormationVodeclicTest extends ZendAfi_View_ parent::setUp(); $this->formation = Class_Album::newInstanceWithId(3, ['libelle' => 'Excel 2013', 'external_uri' => 'http://biblio.vodeclic.com/formation/549']) - ->beFormationVodeclic(); + ->beFormationVodeclic(); } @@ -124,11 +126,11 @@ class ZendAfi_View_Helper_RenderAlbumFormationVodeclicTest extends ZendAfi_View_ $this->group_multimedia = $this->fixture('Class_UserGroup', ['id' => '20', 'libelle' => 'Multimedia']) - ->addRight(Class_UserGroup::RIGHT_ACCES_VODECLIC); + ->addRight(Class_UserGroup::RIGHT_ACCES_VODECLIC); $logged_user->beAbonneSIGB() - ->setUserGroups([$this->group_multimedia]); + ->setUserGroups([$this->group_multimedia]); ZendAfi_Auth::getInstance()->logUser($logged_user); $this->_helper->renderAlbum($this->formation); @@ -155,7 +157,7 @@ class ZendAfi_View_Helper_RenderAlbumNumeriquePremiumTest extends ZendAfi_View_H ['id' => 3, 'libelle' => 'Emile Zola', 'external_uri' => 'http://www.numeriquepremium.com/content/books/9782760622173']) - ->beNumeriquePremium(); + ->beNumeriquePremium(); } @@ -179,7 +181,7 @@ class ZendAfi_View_Helper_RenderAlbumNumeriquePremiumTest extends ZendAfi_View_H ['id' => '20', 'libelle' => 'Multimedia', 'rights' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM]])] - ]); + ]); $logged_user->beAbonneSIGB()->assertSave(); @@ -187,7 +189,7 @@ class ZendAfi_View_Helper_RenderAlbumNumeriquePremiumTest extends ZendAfi_View_H $html = $this->_helper->renderAlbum($this->book); $this->assertXPath($html, - '//input[@type="hidden"][@name="url"][@value="http://www.numeriquepremium.com/content/books/9782760622173"]'); + '//input[@type="hidden"][@name="url"][@value="http://www.numeriquepremium.com/content/books/9782760622173"]'); } } @@ -207,7 +209,7 @@ class ZendAfi_View_Helper_RenderAlbumCyberlibrisTest extends ZendAfi_View_Helper 'libelle' => 'Totem et Thora', 'id_origine' => '88817216', 'external_uri' => 'http://www.bibliovox.com/bookdetails.aspx?docID=88817216']) - ->beCyberlibris(); + ->beCyberlibris(); } @@ -231,7 +233,7 @@ class ZendAfi_View_Helper_RenderAlbumCyberlibrisTest extends ZendAfi_View_Helper ['id' => '20', 'libelle' => 'Multimedia', 'rights' => [Class_UserGroup::RIGHT_ACCES_CYBERLIBRIS]])] - ]); + ]); $logged_user->beAbonneSIGB()->assertSave(); @@ -250,18 +252,24 @@ abstract class ZendAfi_View_Helper_RenderAlbumDilicomPNBTestCase extends ZendAfi public function setUp() { parent::setUp(); Storm_Model_Loader::defaultToVolatile(); - $this->book = $this->fixture('Class_Album', - ['id' => 3, - 'libelle' => 'Totem et Thora', - 'id_origine' => 'Dilicom-88817216', - 'external_uri' => 'http://www.edenlivres.fr/p/23416', - 'type_doc_id' => Class_TypeDoc::DILICOM, - 'usage_constraints' => [$this->fixture('Class_Album_UsageConstraint', - ['id' => 1, - 'id_album' => 3, - 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, - 'order_line_id' => 'x321'])]]); + $this->book = (new DilicomFixtures())->albumTotemThora(); RessourcesNumeriquesFixtures::activateDilicom(); + + $this->_http = Storm_Test_ObjectWrapper::mock(); + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($this->_http); + + $this->_time_source = new TimeSourceForTest('2014-05-02 14:14:14'); + Class_WebService_BibNumerique_Dilicom_Hub::setTimeSource($this->_time_source); + Class_Album_UsageConstraint::setTimeSource($this->_time_source); + + + $this->_http + ->whenCalled('setAuth') + ->answers(null) + + ->whenCalled('open_url') + ->answers(DilicomFixtures::getLoanStatusResponse()); + } @@ -318,7 +326,15 @@ class ZendAfi_View_Helper_RenderAlbumDilicomPNBTest extends ZendAfi_View_Helper_ $logged_user->beAbonneSIGB()->assertSave(); ZendAfi_Auth::getInstance()->logUser($logged_user); + $this->fixture('Class_Loan_Pnb', + ['id' => 1, + 'record_origin_id' => 'Dilicom-88817216', + 'user_id' => '6', + 'ongoing' => true]); + $this->_html = $this->_helper->renderAlbum($this->book); + + $this->loan_constraint = Class_Album_UsageConstraint::loanConstraint($this->book); } @@ -334,7 +350,27 @@ class ZendAfi_View_Helper_RenderAlbumDilicomPNBTest extends ZendAfi_View_Helper_ '//a[contains(@href, "/bib-numerique/consult-book/id/3")]', 'Consulter le livre en ligne'); } -} + /** @test */ + public function htmlShouldContainsLinkToLoanBook() { + $this->assertXPathContentContains($this->_html, + '//a[contains(@href, "/bib-numerique/loan-book/id/3")]', + 'Emprunter le livre au format EPUB'); + } + + + /** @test */ + public function htmlShouldContainsLinkToEndLoanBook() { + $this->assertXPathContentContains($this->_html, + '//a[contains(@href, "/bib-numerique/end-loan-book/id/1")]', + utf8_encode('Rendre le livre emprunté')); + } + + + /** @test */ + public function albumShouldHaveBeenUpdateThroughHubGetLoanStatus() { + $this->assertContains('getLoanStatus', $this->_http->getFirstAttributeForLastCallOn('open_url')); + } +} ?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php b/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php index 2b163d2a717ac0668036bafa10629acd6b943f6b..e9ca8b8d72859dee77d4f58c40a60ce93031eeef 100644 --- a/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php +++ b/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once realpath(dirname(__FILE__)) . '/ViewHelperTestCase.php'; @@ -63,8 +63,8 @@ class ZendAfi_View_Helper_ReseauxSociauxNoticeTest extends ZendAfi_View_Helper_R public function setUp() { parent::setUp(); $this->_html = $this->_helper - ->reseauxSociaux($this->fixture('Class_Notice', - ['id' => 777, + ->reseauxSociaux($this->fixture('Class_Notice', + ['id' => 777, 'titre_principal' => 'Tarzan', 'clef_alpha' => 'tarzan', 'resume' => 'Le livre de la jungle', @@ -78,13 +78,13 @@ class ZendAfi_View_Helper_ReseauxSociauxNoticeTest extends ZendAfi_View_Helper_R } } - + class ZendAfi_View_Helper_ReseauxSociauxProfileTest extends ZendAfi_View_Helper_ReseauxSociauxTestCase { protected $_profile; public function setUp() { parent::setUp(); - $this->_profile = $this->fixture('Class_Profil', + $this->_profile = $this->fixture('Class_Profil', ['id' => 77, 'libelle' => 'musique']); $this->_html = $this->_helper->reseauxSociaux($this->_profile); } @@ -92,11 +92,11 @@ class ZendAfi_View_Helper_ReseauxSociauxProfileTest extends ZendAfi_View_Helper_ /** @test **/ public function withProfilLinkMailShouldBeOnClickShareByEMailProfilMusique(){ $this->assertContains('/index/formulairecontact', - $this->_helper->reseauxSociaux($this->_profile, + $this->_helper->reseauxSociaux($this->_profile, ['mail' => 'mail'])); } - + /** @test **/ public function withProfilLinkFacebookShouldBeOnClickShareFacebookProfilMusique(){ $this->assertContains("/social-network/share/on/facebook/url", diff --git a/tests/library/ZendAfi/View/Helper/TagImgTest.php b/tests/library/ZendAfi/View/Helper/TagImgTest.php index 7194f8f87b6ccdaabc1a629b9aa6dd7a647e6140..8b90daa0c260cf26dd858a4b3312bbb2317c3335 100644 --- a/tests/library/ZendAfi/View/Helper/TagImgTest.php +++ b/tests/library/ZendAfi/View/Helper/TagImgTest.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_TagImgTest extends PHPUnit_Framework_TestCase { /** @@ -26,7 +26,7 @@ class ZendAfi_View_Helper_TagImgTest extends PHPUnit_Framework_TestCase { protected function setUp() { $this->_helper = new ZendAfi_View_Helper_TagImg(); - $this->_helper->setView(new Zend_View()); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); } /** @test */ @@ -41,9 +41,7 @@ class ZendAfi_View_Helper_TagImgTest extends PHPUnit_Framework_TestCase { /** @test */ public function pathShouldBeFirstAttribute() { - $path = '/url/de/test.txt'; - - $html = $this->_helper->tagImg($path); + $html = $this->_helper->tagImg('/url/de/test.txt'); $this->assertTrue('<img src=' == substr($html, 0, 9), $html); } diff --git a/tests/library/ZendAfi/View/Helper/TagProgressBarForNewsletterTest.php b/tests/library/ZendAfi/View/Helper/TagProgressBarForNewsletterTest.php index 98b4bcff4810bd7d89a542f8570385a1b083e991..544a40cf262aab241c64bf35cb7c0702ec868e25 100644 --- a/tests/library/ZendAfi/View/Helper/TagProgressBarForNewsletterTest.php +++ b/tests/library/ZendAfi/View/Helper/TagProgressBarForNewsletterTest.php @@ -16,16 +16,16 @@ * * 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_TagProgressBarForNewsletterTest extends ViewHelperTestCase { protected $_helper, $newsletter; - + public function setup() { parent::setup(); - + $this->newsletter = $this->fixture('Class_Newsletter', ['id' => 1, 'titre' => 'News', @@ -58,10 +58,10 @@ class ZendAfi_View_Helper_TagProgressBarForNewsletterTest extends ViewHelperTest $this->_helper->setView($view); } - + /** @test */ public function shouldReturnDivProgressBar() { - $this->assertEquals('<div id="progress_bar_newsletter_1"></div>', $this->_helper->tagProgressBarForNewsletter($this->newsletter)); + $this->assertEquals('<div id="progress_bar_newsletter_1"></div>', $this->_helper->tagProgressBarForNewsletter($this->newsletter)); } diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php index 10058fa512e29b1377ab46b8fbf6dd79c53783ba..cac0e1e06210f0def4267f37de4fc301f10d84dd 100644 --- a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -139,9 +139,24 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe 'visibilite' => 2]); $this->_preferences['select_bib'] = '1'; + + } + + /** @test */ + public function searchButtonWithNoValueShouldBeEmptyValue() { + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertXPath($html,'//input[@type="submit"][@name="button"][@value=""]'); } + /** @test */ + public function searchButtonWithValueShouldContainsRechercherValue() { + $this->_preferences['search_button']= 'Rechercher'; + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertXPath($html,'//input[@type="submit"][@name="button"][@value="Rechercher"]'); + + } + /** @test */ public function withSelectionBibShouldPostExpectedValue() { $this->_session->id_bibs = [1,2,3]; diff --git a/tests/library/ZendAfi/View/Helper/Telephone/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Telephone/KiosqueTest.php index cb093e21fdc33319afeba6381b65507b9d644dfe..7abb77b6b556fa77b5414ac660fb46b267e36d49 100644 --- a/tests/library/ZendAfi/View/Helper/Telephone/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Telephone/KiosqueTest.php @@ -48,6 +48,7 @@ class Telephone_KiosqueTest extends ViewHelperTestCase { $params = ['division' => '2', 'type_module' => 'KIOSQUE', 'preferences' => $options]; + $this->helper = new ZendAfi_View_Helper_Telephone_Kiosque(2, $params); $this->helper->setView(new ZendAfi_Controller_Action_Helper_View()); $_SERVER["REQUEST_URI"] = BASE_URL; diff --git a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php index a78ce5bbc606fd8db0e38d954ea71d97a3bb1b0d..0bdb55b9000d48fa55cbeb2a9bf6222a5a2b05ad 100644 --- a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php +++ b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php @@ -21,6 +21,9 @@ abstract class ViewHelperTestCase extends PHPUnit_Framework_TestCase { use Storm_Test_THelpers; + protected + $_storm_default_to_volatile = false; + public function assertQueryContentContains() { call_user_func_array(array(new Storm_Test_XPath(), __FUNCTION__), func_get_args()); @@ -124,13 +127,20 @@ abstract class ViewHelperTestCase extends PHPUnit_Framework_TestCase { Storm_Cache::setDefaultZendCache(null); Zend_Registry::get('translate')->setLocale('fr'); + + 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(); (new Storm_Cache)->clean(); $this->logout(); + parent::tearDown(); } diff --git a/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php b/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php index 47ece7c259ac40e4d08708f8b0dd4c3db0d6745e..f4f09643e1b084f821d3f0ea510d98e43f7a078a 100644 --- a/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php +++ b/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php @@ -52,7 +52,7 @@ class ViewHelperWebThumbnailTestReturnedUrl extends ViewHelperWebThumbnailTestCa ->whenCalled('dirExists')->answers(true); $this->helper->setFileWriter($this->_file_writer); -$this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg'; + $this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg'; } @@ -98,17 +98,10 @@ $this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg public function subpageUrlWithParams() { $this->_file_writer ->whenCalled('fileExists') - ->with(USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg') + ->with(USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter_test.jpg') ->answers(true); - - $this->thumbnailer - ->whenCalled('fetchUrlToFile') - ->with('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter', - USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg') - ->answers(true); - - $url = $this->helper->webThumbnail('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter'); - $this->assertEquals(BASE_URL . '/userfiles/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg', + $url = $this->helper->webThumbnail('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter%3Atest'); + $this->assertEquals(BASE_URL . '/userfiles/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter_test.jpg', $url); }