diff --git a/library/ZendAfi/View/Helper/Accueil/Kiosque.php b/library/ZendAfi/View/Helper/Accueil/Kiosque.php index 96b191e940ad95d72825a2510cd32ffe975560ff..5047e744d310e5067b9bdf67f5396a9ac6a36e5a 100644 --- a/library/ZendAfi/View/Helper/Accueil/Kiosque.php +++ b/library/ZendAfi/View/Helper/Accueil/Kiosque.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Base { protected $_nombre_notices_par_page; @@ -34,7 +34,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function shouldCacheContent() { - return parent::shouldCacheContent() && in_array($this->preferences['style_liste'], + return parent::shouldCacheContent() && in_array($this->preferences['style_liste'], ['mur', 'vignettes', 'chrono']); } @@ -60,7 +60,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba $this->contenu = (in_array($this->preferences['style_liste'], ['mur', 'vignettes', 'chrono'])) ? $this->getKiosqueHtml() : $this->getKiosqueIFrame(); - $this->contenu = + $this->contenu = $this->getAddEditLinks() .$this->getChangeKiosqueData() .$this->contenu; @@ -80,7 +80,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba 'controller' => 'catalogue', 'action' => 'edit', 'id_catalogue' => $this->preferences['id_catalogue']]), - $this->view->tagImg(URL_ADMIN_IMG.'ico/edit.gif',['title' => $this->view->_('Modifier le domaine affiché')]), + $this->view->tagImg(URL_ADMIN_IMG.'ico/edit.gif',['title' => $this->view->_('Modifier le domaine affiché')]), ['data-popup' => 'true']); if (!$domaine_parent = $catalogue->getDomaineParent()) @@ -91,7 +91,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba 'action' => 'add', 'id_catalogue' => $domaine_parent->getId(), 'id_module' => $this->id_module]), - $this->view->tagImg(URL_ADMIN_IMG.'ico/add.gif',['title' => $this->view->_('Afficher un nouveau domaine')]), + $this->view->tagImg(URL_ADMIN_IMG.'ico/add.gif',['title' => $this->view->_('Afficher un nouveau domaine')]), ['data-popup' => 'true']); return $edit_link.$add_link; @@ -102,24 +102,24 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba if (!Class_Users::isCurrentUserCanAccesBackend()) return '<div style="display:none"></div>'; - $id_panier = isset($this->preferences['id_panier']) - ? $this->preferences['id_panier'] + $id_panier = isset($this->preferences['id_panier']) + ? $this->preferences['id_panier'] : 0; - $id_catalogue = isset($this->preferences['id_catalogue']) - ? $this->preferences['id_catalogue'] + $id_catalogue = isset($this->preferences['id_catalogue']) + ? $this->preferences['id_catalogue'] : 0; - - $change_kiosque_selection_url = - $this->view->url(['module' => 'admin', - 'controller' => 'modules', - 'action' => 'kiosque-change-data', + + $change_kiosque_selection_url = + $this->view->url(['module' => 'admin', + 'controller' => 'modules', + 'action' => 'kiosque-change-data', 'id_module' => $this->id_module ],null,true); - - return + + return '<div class="change_kiosque_data">'. - $this->view->tagAnchor($change_kiosque_selection_url, + $this->view->tagAnchor($change_kiosque_selection_url, $this->view->tagImg(URL_ADMIN_IMG.'picto/domaines_16.png', ['title' => $this->view->_('Modifier la source de données du kiosque')]), ['data-popup'=>'true']). @@ -130,9 +130,9 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function getKiosqueIFrame() { extract($this->preferences); - + // Proprietes en fonction du type de liste - $args = array("id_module" => $this->id_module, + $args = array("id_module" => $this->id_module, 'id_profil' => Class_Profil::getCurrentProfil()->getId()); $action = "kiosque"; @@ -141,7 +141,7 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba $controler = "java"; $args["vue"]="slide_show"; $hauteur = $op_hauteur_img + 7; - if ($hauteur == 7) + if ($hauteur == 7) $hauteur = 117; break; case "protoflow": @@ -230,17 +230,21 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba '1' => 'date_creation desc', '2' => 'nb_visu desc', '3' => 'annee desc']; + + if (isset($this->preferences['titre'])) + $this->preferences['titre'] = str_replace(['/', '%2F'], ' ', $this->preferences['titre']); + $url_options = array_merge(['controller' => 'recherche', 'action' => 'simple'], $this->preferences); $url_options['tri'] = ($this->preferences['tri']) ? $tris[$this->preferences['tri']] : $tris[0]; return sprintf('<a href="%s">%s</a>', - $this->view->url($url_options, null, true), - htmlentities($this->preferences['titre'])); + $this->view->url($url_options, null, true), + urlencode($this->preferences['titre'])); } public function getRss() { - return $this->preferences['rss_avis'] + return $this->preferences['rss_avis'] ? $this->rss_interne = $this->_getRSSurl('rss', 'kiosque') : ''; } diff --git a/tests/application/modules/opac/controllers/JavaControllerTest.php b/tests/application/modules/opac/controllers/JavaControllerTest.php index 7e97001da7aff0f02e081134168c291a140494a6..db2d92631e6741b70b9775b1cf84ba57abe277a3 100644 --- a/tests/application/modules/opac/controllers/JavaControllerTest.php +++ b/tests/application/modules/opac/controllers/JavaControllerTest.php @@ -78,16 +78,19 @@ class JavaControllerCarrouselHorizontalTest extends AbstractControllerTestCase { 'vignette' => 'http://thumbnail.com/madagascar.jpg' ] ]); - $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes', true); + $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal', true); } /** @test */ public function titleShouldBeRemovedBecauseOfPossibleApacheMisconfigurationOfAllowEncodedSlashes() { - $this->assertContains('onclick="window.parent.location=\'/recherche/viewnotice/id_module/1/id/4\';"', - $this->_response->getBody() + $this->assertXPath('//div[@class="jMyCarousel"]//a[@href="/recherche/viewnotice/id_module/1/vue/mycarousel_horizontal/id/4"]'); + } + - ); + /** @test */ + public function jMyCarouselShouldBeLoaded() { + $this->assertContains('jMyCarousel', $this->_response->getBody()); } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index c1bce55ee9ce84502bbc07cc68810cbf53418d0f..4d0dc61bacc511ac9f71d144f21d9f64d0c8e5eb 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,7 +29,7 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueTestCase extends ViewHelperTes $this->_helper = new ZendAfi_View_Helper_Accueil_Kiosque(3, $this->getPreferences()); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - + $this->_notices = [Class_Notice::newInstanceWithId(2, ['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", 'url_vignette' => 'hp.png', @@ -71,7 +71,7 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueMurTestCase extends ZendAfi_Vi $this->getExtraPreferences())]; } - + abstract public function getExtraPreferences(); } @@ -89,7 +89,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_Vi public function firstNoticeTitleShouldLinkToNotice2WithIdCatalogue12() { $this->assertXPath($this->_html, '//div[@class="notice"]//span/a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/1/id_catalogue/12")]', - $this->_html); + $this->_html); } @@ -97,7 +97,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_Vi public function firstNoticeImgShouldLinkToNotice2WithIdCatalogue12() { $this->assertXPath($this->_html, '//div[@class="notice"]//a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/1/id_catalogue/12")]//img', - $this->_html); + $this->_html); } } @@ -116,14 +116,14 @@ class ZendAfi_View_Helper_Accueil_KiosqueVignettesWithCatalogueTest extends Zend public function firstNoticeTitleShouldLinkToNotice2WithIdCatalogue12() { $this->assertXPath($this->_html, '//div[@class="vignette_titre"]//a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/1/id_catalogue/12")]', - $this->_html); + $this->_html); } /** @test */ public function firstNoticeImgShouldLinkToNotice2WithIdCatalogue12() { $this->assertXPath($this->_html, '//div[@class="vignette_img"]//a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/1/id_catalogue/12")]//img', - $this->_html); + $this->_html); } } @@ -187,7 +187,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithPanierAndTriTest extends ZendAfi public function firstNoticeTitleShouldLinkToNotice2WithIdPanier15() { $this->assertXPath($this->_html, '//div[@class="notice"]//span/a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/date_creation+desc/id_panier/15")]', - $this->_html); + $this->_html); } @@ -195,7 +195,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithPanierAndTriTest extends ZendAfi public function firstNoticeImgShouldLinkToNotice2WithIdPanier15() { $this->assertXPath($this->_html, '//div[@class="notice"]//a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/tri/date_creation+desc/id_panier/15")]//img', - $this->_html); + $this->_html); } } @@ -262,7 +262,7 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendA Class_AdminVar::newInstanceWithId('CACHE_ACTIF', ['valeur'=>0 ]); } - + public function tearDown() { Zend_Registry::set('sql', $this->old_sql); parent::tearDown(); @@ -329,12 +329,12 @@ class ZendAfi_View_Helper_Accueil_KiosqueRequetesWithCacheEnabledTest extends Ze parent::setUp(); $this->mock_cache = Storm_Test_ObjectWrapper::mock(); - Storm_Cache::setDefaultZendCache($this->mock_cache); + Storm_Cache::setDefaultZendCache($this->mock_cache); Class_AdminVar::newInstanceWithId('CACHE_ACTIF', ['valeur'=>1]); $this->mock_cache ->whenCalled('load')->answers(false) - ->whenCalled('save')->answers(true); + ->whenCalled('save')->answers(true); $this->_html = $this->_helper->getBoite(); @@ -345,7 +345,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueRequetesWithCacheEnabledTest extends Ze /** @test */ public function findAllByRequeteRechercheQueryWithCacheEnabled() { $this->mock_cache->whenCalled('load')->answers($this->_html); - + $this->mock_sql->clearAllRedirections(); $this->_html = $this->_helper->getBoite(); @@ -356,7 +356,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueRequetesWithCacheEnabledTest extends Ze class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAfi_View_Helper_Accueil_KiosqueMurTestCase{ - + public function getExtraPreferences() { return ['id_panier' => 15, 'tri' => '2', @@ -387,10 +387,10 @@ class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAf $mes_bd = Class_PanierNotice::newInstanceWithId(47, ['libelle' => 'Mes BD', 'date_maj' => '09/10/2013']); - + $mes_partitions = Class_PanierNotice::newInstanceWithId(65, ['libelle' => 'Mes partitions', 'date_maj' => '08/10/2013']); - + $mes_jeux = Class_PanierNotice::newInstanceWithId(18, ['libelle' => 'Mes jeux', 'date_maj' => '07/10/2013']); @@ -399,11 +399,11 @@ class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAf $redacteur = Class_Users::newInstanceWithId(54) ->beModoBib() - ->setPaniers([$mes_livres, - $mes_musiques, - $mes_partitions, - $mes_recettes, - $mes_jeux, + ->setPaniers([$mes_livres, + $mes_musiques, + $mes_partitions, + $mes_recettes, + $mes_jeux, $mes_bd]); $domaine_printemps = Class_Catalogue::newInstanceWithId(1338, ['libelle' => 'Catalogue pour le printemps']); @@ -414,18 +414,18 @@ class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAf $domaine_hiver = Class_Catalogue::newInstanceWithId(1341, ['libelle' => 'Catalogue pour l\'hiver']); - $catalogue_saison = Class_Catalogue::newInstanceWithId(1337, + $catalogue_saison = Class_Catalogue::newInstanceWithId(1337, ['libelle' => 'Catalogue pour chaque saison']) ->setSousDomaines([$domaine_printemps, - $domaine_ete, - $domaine_automne, + $domaine_ete, + $domaine_automne, $domaine_hiver]) ->setPanierNotices([$series, $photos, $custom_roms, $custom_kernels]); - + ZendAfi_Auth::getInstance()->logUser($redacteur); @@ -443,7 +443,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAf ->whenCalled('find') ->with(15) ->answers($panier_du_kiosque) - + ->beStrict(); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') @@ -453,7 +453,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueChangeSelectRequetesTest extends ZendAf ->whenCalled('findAllBy') ->answers($catalogue_saison->getSousDomaines()) ; - + $this->_html = $this->_helper->getChangeKiosqueData(); } @@ -488,10 +488,10 @@ class ZendAfi_View_Helper_Accueil_KiosqueTitle extends ViewHelperTestCase { } /** @test */ - public function titleShouldContainEncodedSlashesInUrl() { + public function titleShouldRemoveSlashesInUrl() { $this->assertContains( - '/recherche/simple/titre/Title+with+%2F+slash/style_liste/mur/nb_notices/20/only_img/1/aleatoire/1/tri/date_creation+desc/nb_analyse/50/op_hauteur_img/0/op_transition//op_largeur_img/0/op_auto/0/op_scroll/1/rss_avis/1/id_catalogue/0/id_panier/0">Title with / slash</a>', - $this->_helper->getTitre()); + '/recherche/simple/titre/Title+with+++slash/style_liste/mur', + $this->_helper->getTitre()); } }