From 0307c90d1f073fba628d24c6a4ac1458125193d8 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Fri, 20 Feb 2015 17:26:24 +0100 Subject: [PATCH] sandbox fusion search result : refacto , print is now available for all controllers, can print articles view --- .../admin/controllers/PrintController.php | 3 +- .../views/scripts/print/_print_row.phtml | 20 +++++++++++ .../opac/controllers/CmsController.php | 4 ++- .../opac/controllers/RechercheController.php | 2 +- .../opac/views/scripts/cms/articlesview.phtml | 9 +++++ .../modules/opac/views/scripts/print.phtml | 3 ++ .../scripts/recherche/resultatRecherche.phtml | 15 +++++--- library/Class/CollectionFusion.php | 34 +++++++++++++++++++ library/ZendAfi/Controller/Action.php | 20 +++++++++++ 9 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 application/modules/admin/views/scripts/print/_print_row.phtml create mode 100644 application/modules/opac/views/scripts/print.phtml create mode 100644 library/Class/CollectionFusion.php diff --git a/application/modules/admin/controllers/PrintController.php b/application/modules/admin/controllers/PrintController.php index 32804a1fef8..f5274ff5378 100644 --- a/application/modules/admin/controllers/PrintController.php +++ b/application/modules/admin/controllers/PrintController.php @@ -47,7 +47,8 @@ class Admin_PrintController extends ZendAfi_Controller_Action { } public function indexAction() { - $this->_redirectToIndex(); + $this->view->titre=$this->view->_('Modèles d\'impressions'); + $this->view->models= Class_ModeleFusion::findAll(); } diff --git a/application/modules/admin/views/scripts/print/_print_row.phtml b/application/modules/admin/views/scripts/print/_print_row.phtml new file mode 100644 index 00000000000..5a50d733b47 --- /dev/null +++ b/application/modules/admin/views/scripts/print/_print_row.phtml @@ -0,0 +1,20 @@ + + +<li > + +<?php +echo $this->tag('div', $this->model->getLibelle()); +$action_buttons=[]; +$actions = [ +['action' => 'edit', 'icon' => 'ico/edit.gif', 'help' => 'Editer'], +['action' => 'add', 'icon' => 'ico/add_news.gif', 'help' => 'Ajouter un nouveau modèle'], +['action' => 'delete', 'icon' => 'ico/del.gif', 'help' => 'Supprimer']]; + foreach ($actions as $action) { + $action_buttons[]= $this->tagAnchor($this->url(array('action' => $action['action'], + 'id' => $this->model->getId())), + '<img src="'.URL_ADMIN_IMG.$action['icon'].'" alt="'.$action['help'].'" title="'.$action['help'].'" />'); + } +echo $this->tag('div', implode('',$action_buttons),['class' => 'actions']); + +?> +</li> diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index 8caf1120de1..8e71b0a48c9 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -18,7 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class CmsController extends Zend_Controller_Action { +class CmsController extends ZendAfi_Controller_Action { use Trait_TimeSource; public function init() { @@ -389,4 +389,6 @@ class CmsController extends Zend_Controller_Action { $this->renderScript('cms/articlesview.phtml'); } + + } \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 6f7c7470684..2d6fea6cdfd 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -743,7 +743,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function newCriteresRecherches($params) { $criteres = (new Class_CriteresRecherche())->setParams($params); @@ -777,6 +776,7 @@ class RechercheController extends ZendAfi_Controller_Action { $this->renderScript('recherche/print-fusion.phtml'); } + } diff --git a/application/modules/opac/views/scripts/cms/articlesview.phtml b/application/modules/opac/views/scripts/cms/articlesview.phtml index 40ee7276786..55067f36804 100644 --- a/application/modules/opac/views/scripts/cms/articlesview.phtml +++ b/application/modules/opac/views/scripts/cms/articlesview.phtml @@ -4,6 +4,15 @@ if (0 == count($this->articles)) { echo $this->_('Aucun article trouvé'); } +$ids = array_map(function($article) { + return $article->getId(); + +}, $this->articles); + + echo $this->tagAnchor($this->url( ['action' => 'print', + 'ids' => implode(';',$ids), + 'strategy' => 'article', + 'modele_fusion' => 8]), 'imprimer'); foreach ($this->articles as $article) { echo $this->partial( diff --git a/application/modules/opac/views/scripts/print.phtml b/application/modules/opac/views/scripts/print.phtml new file mode 100644 index 00000000000..21af2be2829 --- /dev/null +++ b/application/modules/opac/views/scripts/print.phtml @@ -0,0 +1,3 @@ +<div class="lettre_fusion"> + <?php echo $this->lettre->getContenuFusionne(); ?> +</div> diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index e241c10688b..881391aa180 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -18,13 +18,20 @@ if ($this->is_pertinence) { ?> <div class="print"> <?php + if ($fusion=Class_ModeleFusion::findFirstBy(['nom' => 'recherche'])) { -?> -<a href="<?php echo $this->url(['action' => 'print', - 'modele_fusion' => $fusion->getId()]); ?>">imprimer</a> +$ids = array_map(function($notice) { + return $notice->getId(); + +}, $this->liste); + +echo $this->tagAnchor($this->url(['action' => 'print', + 'strategy' => 'notice', + 'ids' => implode(';',$ids), + 'modele_fusion' => $fusion->getId()]),'imprimer'); -<?php } ?> + } ?> </div> <div class="resultats_page"> <?php diff --git a/library/Class/CollectionFusion.php b/library/Class/CollectionFusion.php new file mode 100644 index 00000000000..35ed52f9135 --- /dev/null +++ b/library/Class/CollectionFusion.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_CollectionFusion extends Storm_Model_Abstract{ + protected $_elements; + + public function __construct($elements) { + $this->_elements=$elements; + } + + public function getElements() { + return $this->_elements; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 49e906b33ee..3a7c4d67cde 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -407,5 +407,25 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { return $parts[1]; } + public function printAction() { + $models=[]; + if ($this->_getParam('strategy')=="article") + $models = Class_Article::findAllBy(['id_article' => explode(';',$this->_getParam('ids',0))]); + + if ($this->_getParam('strategy')=="notice") + $models = Class_Notice::findAllBy(['id_notice' => explode(';',$this->_getParam('ids',0))]); + + $this->view->lettre = Class_ModeleFusion::getBibliorecord($this->_getParam('modele_fusion')); + + $this->view->lettre + ->setDataSource(['results' => new Class_CollectionFusion($models)]); + + $this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml'); + $this->renderScript('print.phtml'); + + } + + + } ?> \ No newline at end of file -- GitLab