diff --git a/VERSIONS_HOTLINE/merge_fix_on_patch_250 b/VERSIONS_HOTLINE/merge_fix_on_patch_250 new file mode 100644 index 0000000000000000000000000000000000000000..f208d6709e86dcbae60373622af12da76adc270e --- /dev/null +++ b/VERSIONS_HOTLINE/merge_fix_on_patch_250 @@ -0,0 +1 @@ + - hotine : correction du patch 250.php \ No newline at end of file diff --git a/VERSIONS_WIP/21425 b/VERSIONS_WIP/21425 new file mode 100644 index 0000000000000000000000000000000000000000..f0e014bc58bf3dae0fe5ff98855e68f6401044ba --- /dev/null +++ b/VERSIONS_WIP/21425 @@ -0,0 +1 @@ + - ticket #21425 : Boîte critiques : nouveau mode d'affichage en navigation hiérarchique par domaine \ No newline at end of file diff --git a/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes b/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes new file mode 100644 index 0000000000000000000000000000000000000000..7b7d1e07dc1e2ec6f5d9651734803cd3ba130337 --- /dev/null +++ b/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes @@ -0,0 +1,2 @@ + - dev#19572: Possibilité d'import des vignettes des sites web depuis typo3 vers bokeh. + php scripts/import_typo3.ph sito diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index d0ae3ef64c61f6ead94a7264126cdfdcced9c20b..81636cabfe13bccc444210cb543fcf23e24c5a8d 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -34,11 +34,11 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { public function indexAction() { - if(Class_AdminVar::get('ALBUMS_LIST_MODE')) { + if (Class_AdminVar::get('ALBUMS_LIST_MODE')) return $this->_renderList(); - } - $categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0, 'order' => 'libelle']); + $categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0, + 'order' => 'libelle']); $categories []= Class_AlbumCategorie::defaultCategory() ->setAlbums(Class_Album::findAllBy(['cat_id' => 0])); @@ -50,7 +50,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { . (int)$this->_getParam('cat_id') . ';' . 'var treeViewAjaxBaseUrl = "' . $this->view->url(['action' => 'items-of']) . '"'); $this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js'); - } @@ -692,15 +691,15 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $cat_id = $this->_getParam('cat_id', ''); $category = Class_AlbumCategorie::find($cat_id); - if('0' === $cat_id) + if ('0' === $cat_id) $category = Class_AlbumCategorie::defaultCategory(); - $this->view->list = $this->_helper->listViewMode(['model' => $category, - 'page' => $this->_getParam('page', 0), - 'strategy_label' => 'album', - 'search_value' => $this->_getParam('title_search', '')]); + $this->view->list = $this->_helper + ->albumListViewMode(['model' => $category, + 'page' => $this->_getParam('page', 0), + 'search_value' => $this->_getParam('title_search', '')]); - return $this->getHelper('ViewRenderer')->renderScript('admin/listViewMode.phtml'); + return $this->renderScript('admin/listViewMode.phtml'); } } ?> \ No newline at end of file diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index d54f185fcd6da7ac3a15779a265287f1bc25bee1..4dd0ffdc261b059725b80a7c527c4a408f0a8901 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -65,7 +65,8 @@ class Admin_CmsController extends ZendAfi_Controller_Action { protected function _renderList() { $bibs = $this->_getBibs(); - $ids = array_map(function($model) {return $model->getId();}, $bibs); + $ids = array_map(function($model) { return $model->getId(); }, $bibs); + $search = $this->_getParam('title_search', ''); $id_bib = $this->_getParam('id_bib', $this->identity->isRoleLibraryLimited() @@ -73,30 +74,32 @@ class Admin_CmsController extends ZendAfi_Controller_Action { : null); $id_cat = $this->_getParam('id_cat', 0); - $params = ($id_bib && in_array($id_bib, $ids)) || $id_cat || ($id_bib == '0') || ($search) - ? ['model' => Class_ArticleCategorie::find($id_cat), - 'strategy_label' => 'article'] - : ['model' => null, - 'strategy_label' => 'bib', - 'bibs' => $bibs]; + $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); - $this->view->list = $this->_helper->listViewMode(array_merge(['page' => $this->_getParam('page', 0), - 'search_value' => $search, - 'bib' => $this->_bib, - 'id_bib' => $id_bib, - 'id_cat' => $id_cat], - $params)); + return $this->renderScript('admin/listViewMode.phtml'); + } - return $this->getHelper('ViewRenderer')->renderScript('admin/listViewMode.phtml'); + $params['model'] = null; + $params['bibs'] = $bibs; + $this->view->list = $this->_helper->bibListViewMode($params); + + return $this->renderScript('admin/listViewMode.phtml'); } public function indexAction() { $this->view->titre = $this->view->_('Articles'); - if (Class_AdminVar::isArticlesListMode()) { + if (Class_AdminVar::isArticlesListMode()) return $this->_renderList(); - } $bibs = $this->_getBibs(); 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/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/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/SitoController.php b/application/modules/opac/controllers/SitoController.php index 6f2b37a070f4db45316709868ca5e430d3a13d7c..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,22 +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() { - $this->view->id_category=$this->_getParam('id_cat'); + $id_category = $this->_getParam('id_cat'); $search = $this->_getParam('title_search', ''); - $this->view->list = $this->_helper->listViewMode( - ['model' => Class_SitothequeCategorie::find($this->view->id_category), - 'strategy_label' => 'sitotheque', - 'search_value' => $search, - 'id_cat'=>$this->view->id_category, - 'page' => $this->_getParam('page',1)]); - + $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'); @@ -81,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"); } @@ -96,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/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/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index c3219fcd2db7d1fba09115ac4047a23fde4f9f91..54eddcdb0e3b4839b64b14e04d269ed49e59287c 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -2,7 +2,7 @@ // Constantes error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","253"); +define("PATCH_LEVEL","254"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/sql/patch/patch_242.php b/cosmogramme/sql/patch/patch_242.php index 3b5012374ae80f2d347716fd5f223176af47dae3..c4239c7dcc4542b40df8bf48b4cdaf0e49093f30 100644 --- a/cosmogramme/sql/patch/patch_242.php +++ b/cosmogramme/sql/patch/patch_242.php @@ -7,4 +7,4 @@ Zend_Registry::get('sql')->query('CREATE TABLE `album_item` ( ' . 'primary key (id),' . 'key (`album_id`)' . ') engine=MyISAM default charset=utf8'); -?> \ No newline at end of file +?> diff --git a/cosmogramme/sql/patch/patch_250.php b/cosmogramme/sql/patch/patch_250.php index db8d4a6fe51cd36febe78c6a5d061c48944f72d5..67c94a5742572786e8c7c2ae67750c31231a4b64 100644 --- a/cosmogramme/sql/patch/patch_250.php +++ b/cosmogramme/sql/patch/patch_250.php @@ -1,4 +1,2 @@ <?php -$adapter = Zend_Db_Table::getDefaultAdapter(); -$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_253.php b/cosmogramme/sql/patch/patch_253.php index 66bd425df7f5cc5442f41a53cbfe9ed2aee825bf..277a8ec3432ab3b4aadf77fbd2a8e5b736d2a6cb 100644 --- a/cosmogramme/sql/patch/patch_253.php +++ b/cosmogramme/sql/patch/patch_253.php @@ -1,10 +1,5 @@ <?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'); +$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/library/Class/AlbumCategorie.php b/library/Class/AlbumCategorie.php index 6a59beb5051680fcd7d8650f3b77a716356a281b..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 = ['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/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/Catalogue.php b/library/Class/Catalogue.php index e99b3633754e6c6a20f18feb87a60ca68bc8ba0b..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('catalogue', $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 . "'"; @@ -1167,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/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/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/Users.php b/library/Class/Users.php index 45b58221d4eaff95e00a7125a0cc31189ff065c6..6a0434c7a8da4541141eb431a4d993cb07f76b17 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'], ]; @@ -383,11 +383,11 @@ class Class_Users extends Storm_Model_Abstract { */ 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 + ] ); } @@ -442,9 +442,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; } @@ -594,8 +594,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); } @@ -813,25 +813,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); @@ -893,7 +893,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()) @@ -1192,7 +1192,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; @@ -1246,7 +1246,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); } @@ -1259,7 +1259,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); } @@ -1272,7 +1272,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/Vignette.php b/library/Class/WebService/Vignette.php index bf2434ac13ce49854ff613e1df667ac3e508438e..abca3011ce1c08f63177a1e1561e16e92140cde3 100644 --- a/library/Class/WebService/Vignette.php +++ b/library/Class/WebService/Vignette.php @@ -311,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/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/ListViewMode/Strategy/Album.php b/library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php similarity index 53% rename from library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Album.php rename to library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php index 0c3b399359caa2c1e0235e61f3672dec75355afe..bbac05e179cad0059f9719d9fddae6370c2b8d1d 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Album.php +++ b/library/ZendAfi/Controller/Action/Helper/AlbumListViewMode.php @@ -20,15 +20,23 @@ */ -class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Album extends ZendAfi_Controller_Action_Helper_ListViewMode_Strategy{ - public function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'album']; +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 getBreadcrumbUrl() { - return array_merge($this->getBaseUrl(), ['action' => 'index']); + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'album']; } @@ -37,18 +45,14 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Album extends ZendA } - public function getCategories() { $categories = []; - if(!($this->_visitor->getModel() == Class_AlbumCategorie::defaultCategory())) - $categories = !$this->_visitor->getModel() - ? Class_AlbumCategorie::findAllBy(['parent_id' => 0, - 'order' => 'libelle']) - : Class_AlbumCategorie::findAllBy(['parent_id' => $this->_visitor->getModelId(), - 'order' => 'libelle']); + if ($this->getModel() != Class_AlbumCategorie::defaultCategory()) + $categories = Class_AlbumCategorie::findAllBy(['parent_id' => $this->getModelId(), + 'order' => 'libelle']); - if(($this->_visitor->getPage() == 0 || $this->_visitor->getPage() == '1') && !$this->_visitor->getModel()) + if (in_array($this->getPage(), [0, 1]) && !$this->getModel()) $categories[] = Class_AlbumCategorie::defaultCategory() ->setAlbums(Class_Album::findAllBy(['cat_id' => 0])); @@ -57,39 +61,40 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Album extends ZendA public function getItems() { - return $this->getItemsParams()->findItemsOfClass('Class_Album'); + return Class_Album::findAllBy($this->getItemsParams()); } - public function getCountSearchResult() { - return $this->getSearchParams()->countItemsOfClass('Class_Album'); + public function getItemsParams() { + return array_merge(parent::getItemsParams(), ['order' => 'titre']); } - public function getBreadcrumb() { - $breadcrumb = []; - $breadcrumb[] = ['url' => ['module' => 'admin', - 'controller' => 'album', - 'action' => 'index'], - 'label' => $this->_('Racine'), - 'options' => []]; + public function getCountSearchResult() { + return Class_Album::countBy($this->getSearchParams()); + } - if(!$this->_visitor->getModel() || $this->_visitor->getModel() == Class_AlbumCategorie::defaultCategory()) { - return array_merge($breadcrumb, $this->getBreadcrumbFor($this->_visitor->getModel())); - } - return array_merge($breadcrumb, $this->getBreadcrumbFor($this->_visitor->getModel())); + 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 $this->_visitor->getModel() ? $this->_visitor->getModel() : Class_AlbumCategorie::defaultCategory(); + return ($model = $this->getModel()) ? + $model : Class_AlbumCategorie::defaultCategory(); } public function countItemsFor($model) { - $id = $model ? $model->getId() : 0; - return Class_Album::countBy(['cat_id' => $id]); + return $model ? $model->numberOfAlbums() : 0; } @@ -111,5 +116,9 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Album extends ZendA public function getItemsLabelAttrib() { return 'titre'; } -} -?> \ No newline at end of file + + + public function getStrategyLabel() { + return 'album'; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Article.php b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php similarity index 52% rename from library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Article.php rename to library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php index 50d203059dc5355f6d2860a69f6bc067c86bbdc6..f54a3f5ce8c9654e9df17f56c25e92b1db998afe 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Article.php +++ b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php @@ -20,10 +20,21 @@ */ -class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends ZendAfi_Controller_Action_Helper_ListViewMode_Strategy { - protected $_filtred_categories, - $_filtred_categories_ids, - $_current_bib; +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', @@ -49,9 +60,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen public function getCategories() { - $categories = []; - - $categories = (!$id_cat = $this->_visitor->getParams()['id_cat']) + $categories = (!$id_cat = $this->getParam('id_cat')) ? $this->getBib()->getArticleCategories() : Class_ArticleCategorie::findAllBy(['id_cat_mere' => $id_cat]); @@ -60,10 +69,10 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen protected function getCurrentBib() { - if($this->_current_bib) + if ($this->_current_bib) return $this->_current_bib; - if(!$this->_current_bib = Class_Bib::find($this->_visitor->getParams()['id_bib'])) + if (!$this->_current_bib = Class_Bib::find($this->getParam('id_bib'))) $this->_current_bib = Class_Bib::getPortail(); return $this->_current_bib; @@ -73,36 +82,41 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen protected function getFiltredCategories($categories) { $cms_permissions = Class_Permission::getCmsPermissions(); - $categories_filter = function($category) use ($cms_permissions){ + $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 $this->getItemsParams()->findItemsOfClass('Class_Article'); + return Class_Article::findAllBy($this->getItemsParams()); + } + + + protected function getItemsParams() { + return array_merge(parent::getItemsParams(), + ['order' => 'titre']); } protected function getSearchParams() { - $filtred_categories = $this->_filtred_categories_ids - ? null - : $this->getFiltredCategories($this->getCategoriesForUser()); + return parent::getSearchParams() + ['id_cat' => $this->getFilteredCategoriesIds()]; + } - $this->_filtred_categories_ids = $this->_filtred_categories_ids - ? $this->_filtred_categories_ids - : array_map(function($model) {return $model->getId();}, $filtred_categories); - $filtred_categories = null; + protected function getFilteredCategoriesIds() { + if ($this->_filtred_categories_ids) + return $this->_filtred_categories_ids; - $params = parent::getSearchParams(); - $params->offsetSet('id_cat', $this->_filtred_categories_ids); - return $params; + $categories = $this->getFiltredCategories($this->getCategoriesForUser()); + $this->_filtred_categories_ids = array_map(function($model) { return $model->getId(); }, + $categories); + + return $this->_filtred_categories_ids; } @@ -112,36 +126,36 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen public function getCountSearchResult() { - return $this->getSearchParams()->countItemsOfClass('Class_Article'); + return Class_Article::countBy($this->getSearchParams()); } public function getBreadcrumb() { - $breadcrumb = []; - $breadcrumb[] = ['url' => ['module' => 'admin', - 'controller' => 'cms', - 'action' => 'index'], - 'label' => $this->_('Racine'), - 'options' => []]; - - $breadcrumb[] = ['url' => ['module' => 'admin', - 'controller' => 'cms', - 'action' => 'index', - 'id_bib' => $this->getBibId()], - 'label' => $this->getBibLabel(), - 'options' => []]; - - if($this->_visitor->getSearchValue()) + $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->_visitor->getParams()['bib']->getLibelle(), - 'options' => []]]; + 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->_visitor->getModel())); + return array_merge($breadcrumb, + $this->getBreadcrumbFor($this->getModel())); } @@ -156,24 +170,44 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen protected function getBib() { - if($bib = Class_Bib::find($this->_visitor->getParams()['id_bib'])) + if ($bib = Class_Bib::find($this->getParam('id_bib'))) return $bib; - if($id_cat = $this->_visitor->getParams()['id_cat']) - return $this->_visitor->getModel()->getBib(); + if ($id_cat = $this->getParam('id_cat')) + return $this->getModel()->getBib(); return Class_Bib::getPortail(); } public function getDefaultModel() { - return $this->_visitor->getModel() ? $this->_visitor->getModel() : $this->getBib(); + return $this->getModel() ? $this->getModel() : $this->getBib(); } public function countItemsFor($model) { - $id = $model ? $model->getId() : 0; - return Class_Article::countBy([$this->getParamKey() => $id]); + 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; } @@ -195,5 +229,9 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Article extends Zen public function getItemsLabelAttrib() { return 'titre'; } -} -?> \ No newline at end of file + + + public function getStrategyLabel() { + return 'article'; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Bib.php b/library/ZendAfi/Controller/Action/Helper/BibListViewMode.php similarity index 75% rename from library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Bib.php rename to library/ZendAfi/Controller/Action/Helper/BibListViewMode.php index f2f3acbfcc14bce3c9c222ae7e2e7b77e3c9f365..1d34920527f532b9145aaaf4c840948443373790 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Bib.php +++ b/library/ZendAfi/Controller/Action/Helper/BibListViewMode.php @@ -20,7 +20,20 @@ */ -class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Bib extends ZendAfi_Controller_Action_Helper_ListViewMode_Strategy { +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']; @@ -32,6 +45,10 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Bib extends ZendAfi } + public function isCountEnabled() { + return false; + } + public function getParamKey() { return 'id_bib'; @@ -39,7 +56,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Bib extends ZendAfi public function getCategories() { - return $this->_visitor->getParams()['bibs']; + return $this->getParam('bibs', []); } @@ -59,8 +76,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Bib extends ZendAfi } - public function getItemsPaginator() { - return null; + public function getStrategyLabel() { + return 'bib'; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode.php deleted file mode 100644 index eddc062b2fbc73bbaefde9f3c7b994072b1059c9..0000000000000000000000000000000000000000 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode.php +++ /dev/null @@ -1,42 +0,0 @@ -<?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_ListViewMode extends Zend_Controller_Action_Helper_Abstract { - - public function listViewMode($params) { - if(!$strategy = $params['strategy_label']) - return null; - - $list = new ZendAfi_Controller_Action_Helper_ListViewMode_List($params); - $helper_class = 'ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_'.ucfirst($strategy); - - return $list - ->setStrategy(new $helper_class($this)) - ->buildList(); - } - - - public function direct($params) { - return $this->listViewMode($params); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/List.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/List.php deleted file mode 100644 index de34816f7ddcd45934fd9ca30a952dd0d6ddc8d6..0000000000000000000000000000000000000000 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/List.php +++ /dev/null @@ -1,246 +0,0 @@ -<?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_ListViewMode_List { - - protected $_model, - $_params, - $_page, - $_search, - $_strategy, - $_categories = [], - $_items = [], - $_items_paginator, - $_breadcrumb; - - - public function __construct($params) { - $this->_model = $params['model']; - $this->_page = $params['page']; - $this->_search = $params['search_value']; - $this->_strategy_label = $params['strategy_label']; - $this->_params = $params; - } - - - public function buildList() { - if(!$this->_search) - $this->setCategories($this->_strategy->getCategories()); - - return $this->setItems($this->_strategy->getItems()) - ->setItemsPaginator($this->_strategy->getItemsPaginator()) - ->setBreadcrumb($this->_strategy->getBreadcrumb()); - } - - - public function setStrategy($strategy) { - $this->_strategy = $strategy; - $this->_strategy->visit($this); - return $this; - } - - - public function setCategories($categories) { - $this->_categories = $categories; - return $this; - } - - - public function setItems($items) { - $this->_items = $items; - return $this; - } - - - public function setItemsPaginator($items_paginator) { - $this->_items_paginator = $items_paginator; - return $this; - } - - - public function setBreadcrumb($breadcrumb) { - $this->_breadcrumb = $breadcrumb; - return $this; - } - - - public function getModel() { - return $this->_model; - } - - - public function getParams() { - return $this->_params; - } - - - public function getPage() { - return $this->_page; - } - - - public function getSearch() { - return $this->_search; - } - - - public function getStrategyLabel() { - return $this->_strategy_label; - } - - - public function getBaseUrl() { - return $this->_strategy->getBaseUrl(); - } - - - public function getSearchUrl() { - return $this->_strategy->getSearchUrl(); - } - - - public function getDefaultModel() { - return $this->_strategy->getDefaultModel(); - } - - - public function getCategoriesCols() { - return $this->_strategy->getCategoriesCols(); - } - - - public function getCategoriesAttribs() { - return $this->_strategy->getCategoriesAttribs(); - } - - - public function getCategoriesId() { - return $this->_strategy->getCategoriesId(); - } - - - public function getCategoriesGroupBy() { - return $this->_strategy->getCategoriesGroupBy(); - } - - - public function getCategoriesLabelAttrib() { - return $this->_strategy->getCategoriesLabelAttrib(); - } - - - public function getItemsCols() { - return $this->_strategy->getItemsCols(); - } - - - public function getItemsAttribs() { - return $this->_strategy->getItemsAttribs(); - } - - - public function getItemsId() { - return $this->_strategy->getItemsId(); - } - - - public function getItemsGroupBy() { - return $this->_strategy->getItemsGroupBy(); - } - - - public function getItemsLabelAttrib() { - return $this->_strategy->getItemsLabelAttrib(); - } - - public function countItemsFor($model) { - return $this->_strategy->countItemsFor($model); - } - - - public function countRecursiveItemsFor($model) { - return $this->_strategy->countRecursiveItemsFor($model); - } - - - public function getBreadcrumbFor($model) { - return $this->_strategy->getBreadcrumbFor($model); - } - - - public function getCategoryFor($model) { - return $this->_strategy->getCategoryFor($model); - } - - - public function getParamKey() { - return $this->_strategy->getParamKey(); - } - - - public function getModelId() { - return $this->_model->getId(); - } - - - public function getStrategy() { - return $this->_strategy; - } - - - public function getSearchValue() { - return $this->_search; - } - - - public function getCategories() { - return $this->_categories; - } - - - public function getitems() { - return $this->_items; - } - - - public function getItemsPaginator() { - if(!$this->_items_paginator) - return (new Zend_Paginator(new Zend_Paginator_Adapter_Null(0))); - return $this->_items_paginator; - } - - - public function getBreadcrumb() { - return $this->_breadcrumb; - } - - - public function isSearchEnabled() { - return $this->_strategy->isSearchEnabled(); - } - - - public function getUrlParams($model) { - return $this->_strategy->getUrlParams($model); - - } - -} diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy.php deleted file mode 100644 index e25945f32b6821046951ac45229bb84cee2695a0..0000000000000000000000000000000000000000 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy.php +++ /dev/null @@ -1,184 +0,0 @@ -<?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_ListViewMode_Strategy { - use Trait_Translator; - - const ITEMS_PAGINATION = 25; - - protected $_visitor; - - protected $_helper; - - - public function __construct($helper) { - $this->_helper = $helper; - } - - - public function visit($visitor) { - $this->_visitor = $visitor; - } - - - public function isSearchEnabled() { - return true; - } - - public function getSearchUrl() { - return $this->getBaseUrl() + ['action' => 'index', - 'title_search' => '']; - } - - protected function _shouldCheckParent($start_key,$model) { - return ($start_key && ($this->getRequestParam($start_key,'')==$model->getId())); - } - - - public function getBreadcrumbFor($model, $breadcrumb = [],$start_key='') { - if(!$model) - return $breadcrumb; - - if (!$this->_shouldCheckParent($start_key,$model) && $parent = $model->getParentCategorie()) - $breadcrumb = $this->getBreadcrumbFor($parent, $breadcrumb,$start_key); - - $breadcrumb[] = ['url' => array_merge($this->getBreadcrumbUrl(), - [$this->getParamKey() => $model->getId()]), - 'label' => $model->getLibelle(), - 'options' => []]; - - return $breadcrumb; - } - - - public function getCategoryFor($model) { - return $model->getCategorie(); - } - - - public function getItemsPaginator() { - $count = $this->_visitor->getSearchValue() ? $this->getCountSearchResult() : $this->countItemsFor($this->_visitor->getModel()); - - return (new Zend_Paginator(new Zend_Paginator_Adapter_Null($count))) - ->setItemCountPerPage(self::ITEMS_PAGINATION) - ->setCurrentPageNumber($this->_visitor->getPage()); - } - - - protected function getItemsParams() { - $cat_id = 0; - if($this->_visitor->getModel()) - $cat_id = $this->_visitor->getModelId(); - - $default_params = ['order' => 'titre', - 'limitPage' => [$this->_visitor->getPage(), self::ITEMS_PAGINATION]]; - - $params = $this->_visitor->getSearchValue() - ? $this->getSearchParams() - : new ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_SearchParams([$this->getParamKey() => $cat_id]); - - $params->addAll($default_params); - return $params; - } - - - protected function getSearchParams() { - return ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_SearchParams::where('titre like \'%' . trim($this->_visitor->getSearch()) . '%\''); - } - - - public function getCategoriesAttribs() { - return [$this->getCategoriesLabelAttrib()]; - } - - - public function getDefaultModel() { - return null; - } - - - public function getCategoriesGroupBy() { - return null; - } - - - public function getCategoriesId() { - return 'categories'; - } - - - public function getItemsAttribs() { - return [$this->getitemslabelattrib()]; - } - - - public function getItemsGroupBy() { - return null; - } - - - public function getItemsId() { - return 'items'; - } - - - protected function countItems() { - return $this->_visitor->getModel()->getLoader()->count(); - } - - - - public function getItems() { - return []; - } - - - public function getBreadcrumb() { - return []; - } - - - public function getItemsCols() { - return []; - } - - - public function getItemsLabelAttrib() { - return ''; - } - - - public function getRequestParam($key, $default = null) { - return $this->_helper->getRequest()->getParam($key, $default); - } - - public function countRecursiveItemsFor($model) { - return $this->countItemsFor($model); - } - - public function getUrlParams($model) { - return array_merge($params,$this->getBaseUrl(), - [ $this->getParamKey() => $model->getId()]); - - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/SearchParams.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/SearchParams.php deleted file mode 100644 index 2c5408c613e2eddc7445cb2ead55a8ac2a860382..0000000000000000000000000000000000000000 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/SearchParams.php +++ /dev/null @@ -1,50 +0,0 @@ -<?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_ListViewMode_Strategy_SearchParams extends Storm_Collection { - public static function where($where) { - return new static(['where' => $where]); - } - - - public function addAll($collection) { - foreach($collection as $key => $value) - $this->offsetSet($key, $value); - return $collection; - } - - - public function getFilteredArrayCopy() { - return array_filter($this->getArrayCopy()); - } - - - public function findItemsOfClass($class_name) { - return $class_name::getLoader()->findAllBy($this->getFilteredArrayCopy()); - } - - - public function countItemsOfClass($class_name) { - return $class_name::getLoader()->countBy($this->getFilteredArrayCopy()); - } -} - -?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php deleted file mode 100644 index 3f66553621d0bebc319578c5286ab8daabe06c49..0000000000000000000000000000000000000000 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php +++ /dev/null @@ -1,162 +0,0 @@ -<?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_ListViewMode_Strategy_Sitotheque extends ZendAfi_Controller_Action_Helper_ListViewMode_Strategy { - - const ITEMS_PAGINATION = 5; - protected $_filtred_categories, - $_filtred_categories_ids, - $_current_bib; - - public function getBaseUrl() { - return ['module' => 'opac', - 'controller' => 'sito', - 'action' => 'viewcategory']; - } - - - public function getSearchUrl() { - return $this->getBaseUrl() + ['title_search' => '']; - } - - - public function getBreadcrumbUrl() { - return array_merge($this->getStartParams(), - $this->getBaseUrl()); - } - - - public function getParamKey() { - return 'id_cat'; - } - - - public function getUrlParams($model) { - return array_merge($this->getStartParams(), - $this->getBaseUrl(), - [$this->getParamKey() => $model->getId()]); - } - - - protected function getStartParams() { - return ($start_cat = $this->getRequestParam('start_cat')) ? - ['start_cat' => $start_cat] : []; - } - - - public function getCategories() { - $categories = (!$id_cat = $this->_visitor->getParams()['id_cat']) - ? Class_SitothequeCategorie::findAll() - : Class_SitothequeCategorie::findAllBy(['id_cat_mere' => $id_cat]); - - return $categories; - } - - - public function getItems() { - return Class_Sitotheque::findAllBy(array_merge(['order' => 'date_maj desc'], - (array)$this->getItemsParams())); - } - - - public function getCountSearchResult() { - return Class_Article::countBy(parent::getSearchParams()); - } - - - public function getBreadcrumb() { - $breadcrumb = []; - if($this->_visitor->getSearchValue()) - return $breadcrumb; - - return array_merge($breadcrumb, - $this->getBreadcrumbFor($this->_visitor->getModel(), - [], - 'start_cat')); - } - - - protected function _shiftBreadcrumb($breadcrumb = []) { - $start_cat = $this->getRequestParam('start_cat'); - foreach ($breadcrumb as $cat) { - if ($cat['url']['id_cat'] != $start_cat) { - array_shift($breadcrumb); - return $breadcrumb;} - } - - return $breadcrumb; - } - - - public function getDefaultModel() { - return Class_SitothequeCategorie::find($this->_visitor->getParams()['id_cat']); - - } - - - public function countItemsFor($model) { - $id = $model ? $model->getId() : 0; - return Class_Sitotheque::countBy([$this->getParamKey() => $id]); - } - - - public function countRecursiveItemsFor($model) { - if (!$model) - return Class_Sitotheque::count(); - - $ids = array_map(function($cat) {return $cat->getId();}, - $model->getRecursiveSousCategories()); - - $ids[] = $model->getId(); - return Class_Sitotheque::countBy([$this->getParamKey() => $ids]); - } - - - public function getCategoriesCols() { - return [$this->_('Catégories d\'articles')]; - } - - - public function getCategoriesLabelAttrib() { - return 'libelle'; - } - - - public function getCategoriesId() { - return 'sitotheque-category'; - } - - - public function getItemsId() { - return 'sitotheque'; - } - - - public function getItemsCols() { - return [$this->_('Liste des articles')]; - } - - - public function getItemsLabelAttrib() { - return 'titre'; - } -} \ 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/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/Admin/HelpLink.php b/library/ZendAfi/View/Helper/Admin/HelpLink.php index 2d8887c10276c21ab1c7affae54ef8fea8991eef..faa9cb748cdc8fdfb11c81a893755ab040e53079 100644 --- a/library/ZendAfi/View/Helper/Admin/HelpLink.php +++ b/library/ZendAfi/View/Helper/Admin/HelpLink.php @@ -131,14 +131,11 @@ 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']]; } ?> diff --git a/library/ZendAfi/View/Helper/Admin/ListViewMode.php b/library/ZendAfi/View/Helper/Admin/ListViewMode.php index 32f451b8131301990fbd94ebbcccd11b48fe56c3..b8a5e1d287822245dd9fb35ca13feceda892dde0 100644 --- a/library/ZendAfi/View/Helper/Admin/ListViewMode.php +++ b/library/ZendAfi/View/Helper/Admin/ListViewMode.php @@ -39,24 +39,27 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel protected function getSearchFormHTML() { - if(!$this->_list->isSearchEnabled()) + 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->view->tag('input', '', ['type' => 'text', - 'name' => 'title_search', - 'id' => 'list_title_search', - 'placeholder' => $this->view->_('titre du document'), - 'value' => $this->_list->getSearchValue()]); + $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->view->tag('button', $this->view->_('Filtrer'), ['id' => 'list_filter_button']); + $search_button = $this->_tag('button', $this->_('Filtrer'), + ['id' => 'list_filter_button']); - return $this->view->tag('form', $search_input . $search_button, ['style' => 'text-align: right;', - 'id' => 'list_search_form']); + return $this->_tag('form', $search_input . $search_button, + ['style' => 'text-align: right;', + 'id' => 'list_search_form']); } @@ -64,8 +67,8 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel $html = $this->getBreadcrumbHTMLFor($this->_list->getBreadcrumb()) . ' ' . $this->view->modelActions($this->_list->getDefaultModel(), $this->getCategoriesActions($this->_list->getModel()), true); - return $this->view->tag('div', $html, - ['style' => 'font-size:140%;']); + return $this->_tag('div', $html, + ['style' => 'font-size:140%;']); } @@ -73,7 +76,9 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel $breadcrumb_html = []; foreach($breadcrumb as $loc) { - $breadcrumb_html[] = $this->view->tagAnchor($this->view->url($loc['url'], null, true), $loc['label'], $loc['options']); + $breadcrumb_html[] = $this->view->tagAnchor($this->view->url($loc['url'], null, true), + $loc['label'], + $loc['options']); } return implode(' > ',$breadcrumb_html); @@ -81,48 +86,61 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel protected function getCategoriesHTML() { - if($this->_list->getSearchValue()) + if ($this->_list->getSearchValue()) return ''; $labelWithCount = function($model, $attrib) { - return $this->view->tagAnchor($this->view->url(array_merge($this->_list->getBaseUrl(), - ['action' => 'index', - $this->_list->getParamKey() => $model->getId()]), null, true), - $this->view->tagImg(URL_ADMIN_IMG . 'ico/cat.gif') - . $model->$attrib - . ' (' . $this->_list->countItemsFor($model) . ')');}; - - 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]); + 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 ''; + if (!$this->_list->getModel() && !$this->_list->getSearchValue()) + return ''; $labelWithBreadcrumb = function($model, $attrib) { - return $this->view->tag('span', $model->$attrib ) - . $this->view->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] : []); + 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] : []); } @@ -139,5 +157,4 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel protected function getItemsActions($model) { return $this->view->itemsActions($model, $this->_list->getStrategyLabel()); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Avis.php b/library/ZendAfi/View/Helper/Avis.php index afcbfedd4b9572a0208a0dbe5df67a0b2bb48a91..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' => nl2br($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/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/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/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/PublicListViewMode.php b/library/ZendAfi/View/Helper/PublicListViewMode.php index 313c4964b12308ce48f081f83b42d085845abcae..6548899b801df4995ac071067168f3f9b7c7a289 100644 --- a/library/ZendAfi/View/Helper/PublicListViewMode.php +++ b/library/ZendAfi/View/Helper/PublicListViewMode.php @@ -20,23 +20,33 @@ */ -class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ListViewMode { - public function publicListViewMode($list) { +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(); + $html = $this->getSearchFormHtml() + . $this->getBreadcrumbHtml() + . $this->getCategoriesHtml() + . $this->getItemsHtml() + . $this->getItemsPaginatorHtml(); return $html; } - protected function getCategoriesHTML() { - if($this->_list->getSearchValue()) + protected function getCategoriesHtml() { + if ($this->_list->getSearchValue()) return ''; $html = ''; @@ -50,9 +60,9 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ protected function getCategoryHtml($category) { $label_attrib = $this->_list->getCategoriesLabelAttrib(); - $label = sprintf('%s (%s)', - $category->$label_attrib, - $this->_list->countRecursiveItemsFor($category)); + $label = $category->$label_attrib; + if ($this->_list->isCountEnabled()) + $label .= ' (' . $this->_list->countRecursiveItemsFor($category) . ')'; return $this ->_tag('li', @@ -62,8 +72,8 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ } - protected function getItemsHTML() { - if(!$this->_list->getModel() && !$this->_list->getSearchValue()) + protected function getItemsHtml() { + if (!$this->_list->getModel() && !$this->_list->getSearchValue()) return ''; $html = ''; @@ -78,8 +88,9 @@ class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ if (!$item) return ''; + $renderer = $this->_item_renderer; return $this->_tag('div', - $this->view->getHelper('SitoTree')->renderSite($item), - ['class' => 'sitotheque']); + $renderer($item), + ['class' => $this->_list->getItemsId()]); } -} \ No newline at end of file +} diff --git a/library/ZendAfi/View/Helper/TagList.php b/library/ZendAfi/View/Helper/TagList.php index 34261c8be7ebbb69039f297bdf367e8ad6622402..cbb32f3fa489ff0c88b760dfc3f85b9f758fda23 100644 --- a/library/ZendAfi/View/Helper/TagList.php +++ b/library/ZendAfi/View/Helper/TagList.php @@ -18,48 +18,43 @@ * 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 Zend_View_Helper_HtmlElement { - protected $id_list; - public function tagList($models, $attribs, $id, $callbacks = []) { - $this->id_list=$id; - return $this->renderModelsAsUlLi($models, $attribs, $callbacks); - } +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 renderModelsAsUlLi($models, $attribs, $callbacks) { - $rows = ''; + public function renderModels() { + $html = ''; - foreach ($models as $model) { - $rows .= $this->renderModelAsUlLi($model, $attribs,$callbacks); - } + foreach ($this->models as $model) + $html .= $this->renderModel($model); - return $rows; + return $html; } - public function renderModelAsUlLi($model, $attribs, $callbacks) { - $cols = ''; + public function renderModel($model) { + $html = ''; $default_callback = function ($model, $attrib) { - return $this->view->escape($model->callGetterByAttributeName($attrib)); + return $this->view->escape($model->$attrib); }; - foreach ($attribs as $attrib) { - $callback = (array_key_exists($attrib, $callbacks)) ? $callbacks[$attrib] : $default_callback; - $cols .= $this->tag('li', $callback($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', $cols,['class' => $this->id_list]); - } - - - /** shortcut to $this->view->tag() */ - protected function tag() { - return call_user_func_array([$this->view, 'tag'], func_get_args()); + return $this->_tag('ul', $html, ['class' => $this->css_class]); } } - -?> 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/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/AlbumControllerListViewModeTest.php b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php index 00f824895541d3d5a411100c66daebac0d567bcf..fe86cc2dd2d5507000deda97b55e05d9675b7ee5 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php @@ -134,7 +134,8 @@ class Admin_AlbumControllerListViewModeSearchTest extends Admin_AlbumControllerL ->answers([Class_Album::find(2)]) ->whenCalled('countBy') - ->with(['where' => 'titre like \'%Second%\'']) + ->with(['where' => 'titre like \'%Second%\'', + 'order' => 'titre']) ->answers(200) ->beStrict(); @@ -157,7 +158,8 @@ class Admin_AlbumControllerListViewModeSearchTest extends Admin_AlbumControllerL /** @test */ public function paginationShouldContainsSearch() { - $this->assertXPath('//div[@class="paginationControl"]//a[contains(@href,"admin/album/index/title_search/Second/page/2")]'); + $this->assertXPath('//div[@class="paginationControl"]//a[contains(@href,"admin/album/index/title_search/Second/page/2")]', + $this->_response->getBody()); } @@ -279,4 +281,36 @@ class AlbumControllerListModeEditPostWithPaginationTest public function redirectShouldContainPage34() { $this->assertContains('/admin/album/edit_album/id/2/page/34/title_search/erik', $this->_response->getHeaders()[0]); } -} \ No newline at end of file +} + + + + +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/CmsControllerListModeTest.php b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php index ae65e0b082c057226a73ada0d1df549514a73764..3e676ebfb85e2f18f9e70d94862865fb21cad8d3 100644 --- a/tests/application/modules/admin/controllers/CmsControllerListModeTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerListModeTest.php @@ -53,7 +53,6 @@ class CmsControllerListModeAdminRootTest extends CmsControllerListModeTestCase { } - /** @test */ public function portalShouldHaveDefaultPermissionsAction() { $this->assertXPath('//td//a[contains(@href, "bib/permissions/id/0")]', @@ -191,7 +190,6 @@ class CmsControllerListModeAdminBibSubCategoryTest $this->assertXPath('//td//a[contains(@href, "cms/add/id_cat/23")]', $this->_response->getBody()); } - } @@ -224,7 +222,8 @@ class CmsControllerListModeAdminBibSearchTest ->whenCalled('countBy') ->with(['where' => 'titre like \'%news%\'', - 'id_cat' => [1],]) + 'id_cat' => [1], + 'order' => 'titre']) ->answers(2) ->beStrict(); @@ -294,37 +293,4 @@ class CmsControllerListModeEditPostTest extends CmsControllerListModeTestCase { } } - - -class CmsControllerListModeSearchParamsTest extends Storm_Test_ModelTestCase { - public function setUp() { - parent::setUp(); - $this->_params = ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_SearchParams::where('titre like "%test%"'); - $this->_params->addAll(['id_cat' => 0]); - } - - - /** @test */ - public function findItemsShouldFilterEmptyValues() { - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') - ->whenCalled('findAllBy') - ->with(['where' => 'titre like "%test%"']) - ->answers(['some data']); - - $this->assertEquals(['some data'], $this->_params->findItemsOfClass('Class_Article')); - } - - - /** @test */ - public function countItemsShouldFilterEmptyValues() { - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') - ->whenCalled('countBy') - ->with(['where' => 'titre like "%test%"']) - ->answers(2); - - $this->assertEquals(2, $this->_params->countItemsOfClass('Class_Article')); - - } -} - ?> \ No newline at end of file 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/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 655189bcff56fd9b57bd4c7cc2a3139216dce780..623666b79d0f11fae02b2d8e4b946cc8264a9471 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -58,76 +58,66 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { } -class SitoControllerHierarchicViewTest extends SitoControllerTestCase { +class SitoControllerViewCategoyTest extends SitoControllerTestCase { public function setUp() { parent::setUp(); - $collectif=$this->fixture('Class_SitothequeCategorie', - ['id' => 12, - 'parent_categorie' => $this->hackers, - 'libelle' => 'Collectifs' ]); + $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' ]); - - $this->fixture('Class_SitothequeCategorie', - ['id' => 19, - 'parent_categorie' => $this->fixture('Class_SitothequeCategorie', - ['id' => 17, - 'parent_categorie' => $collectif, - 'libelle' => 'Associations' ]), - - 'libelle' => 'Libre' ]); - + $libre = $this->fixture('Class_SitothequeCategorie', + ['id' => 19, + 'parent_categorie' => $associations, + 'libelle' => 'Libre' ]); $this->fixture('Class_Sitotheque', ['id' => 280, - 'id_cat' => 19, + 'categorie' => $libre, 'titre' => 'La quadrature du net', 'description' => 'Internet et libertés', 'url' => 'http://laquadrature.net']); - $this->fixture('Class_Sitotheque', ['id' => 282, - 'id_cat' => 17, + 'categorie' => $associations, 'titre' => 'April', 'description' => 'Promouvoir le logiciel libre', 'url' => 'http://april.org']); - $this->fixture('Class_Sitotheque', ['id' => 281, - 'id_cat' => 12, + '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' => []]); + ->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() { + public function linuxFrShouldNotBeShown() { $this->assertNotXPath('//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', - $this->_response->getBody()); + $this->_response->getBody()); } /** @test */ - public function FramasoftShouldBeShown() { + public function framasoftShouldBeShown() { $this->assertXPath('//div[@class="sitotheque"]//a[@href="http://framasoft.org"]', $this->_response->getBody()); } @@ -135,7 +125,7 @@ class SitoControllerHierarchicViewTest extends SitoControllerTestCase { /** @test */ public function catAssocShouldContains2sites() { - $this->assertXPathContentContains('//div//a[@href="/sito/viewcategory/start_cat/12/id_cat/17"]','Associations (2)', + $this->assertXPathContentContains('//div//a[@href="/sito/viewcategory/start_cat/12/id_cat/17"]', 'Associations (2)', $this->_response->getBody()); } diff --git a/tests/fixtures/RessourcesNumeriquesFixtures.php b/tests/fixtures/RessourcesNumeriquesFixtures.php index 3babce9846ec52bcf5ba8fbd626217e0ce517eb5..4ebd1f73f00f347c3d807ae88be62e39ee6bb024 100644 --- a/tests/fixtures/RessourcesNumeriquesFixtures.php +++ b/tests/fixtures/RessourcesNumeriquesFixtures.php @@ -261,4 +261,5 @@ class RessourcesNumeriquesFixtures { Class_AdminVar::newInstanceWithId('DILICOM_PNB_GLN_CONTRACTOR', ['valeur' => '']); } } + ?> 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/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/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/AvisTest.php b/tests/library/ZendAfi/View/Helper/AvisTest.php index 37cad32e3a5e6eb95c7e6968ab684bb37fca0e3f..79bdd70afdd5f928947b0728d9400c204110cb1c 100644 --- a/tests/library/ZendAfi/View/Helper/AvisTest.php +++ b/tests/library/ZendAfi/View/Helper/AvisTest.php @@ -267,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()); @@ -300,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/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); }