diff --git a/application/modules/opac/controllers/JavaController.php b/application/modules/opac/controllers/JavaController.php index d04f8ebcc2a0c340d899837557f07157ea3352af..05077481662436b4ef8dc223b454c6b2b3c211c7 100644 --- a/application/modules/opac/controllers/JavaController.php +++ b/application/modules/opac/controllers/JavaController.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class JavaController extends Zend_Controller_Action { +class JavaController extends ZendAfi_Controller_Action { public function init() { $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->setLayoutScript('iframe.phtml'); @@ -37,10 +37,8 @@ class JavaController extends Zend_Controller_Action { public function kiosqueAction() { - $id_module = $this->_getParam('id_module'); - $preferences = array_merge( - Class_Systeme_ModulesAccueil::getInstance()->getValeursParDefaut('KIOSQUE'), - $this->view->profil->getModuleAccueilPreferences($id_module, 'KIOSQUE')); + $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance()->getValeursParDefaut('KIOSQUE'), + $this->getPreferenceProfile()->getModuleAccueilPreferences($this->getPreferenceIdModule(), 'KIOSQUE')); $this->view->preferences = $preferences; $params = $this->_request->getParams(); @@ -62,6 +60,16 @@ class JavaController extends Zend_Controller_Action { } + protected function getPreferenceIdModule() { + if (!($id_module = $this->_getParam('id_module')) + || 2 > count($parts = explode('-', $id_module))) + return $id_module; + + return $parts[1]; + } + + + public function kiosquedescAction() { $this->getHelper('ViewRenderer')->setNoRender(); echo $this->view->_('Kiosque de notices'); diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index b2b0582b834cf5dfdd23da97fae7d52bb87cff29..fb843a23a1dfea0a2bd0aa71a558b96be49f73db 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -306,16 +306,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function getPreferenceProfile() { - if (!($id_module = $this->_getParam('id_module')) - || 2 > count($parts = explode('-', $id_module))) - return Class_Profil::getCurrentProfil(); - - return ($profile = Class_Profil::find($parts[0])) - ? $profile : Class_Profil::getCurrentProfil(); - } - - public function readnoticeAction() { $this ->getHelper('ViewRenderer') diff --git a/library/Class/Systeme/ModulesAccueil/Kiosque.php b/library/Class/Systeme/ModulesAccueil/Kiosque.php index 7106db038f432547db74cde6a1fd5ec5caca3808..e228fceb61fd34e3604e1e0d18b7a421347e9e21 100644 --- a/library/Class/Systeme/ModulesAccueil/Kiosque.php +++ b/library/Class/Systeme/ModulesAccueil/Kiosque.php @@ -49,6 +49,11 @@ class Class_Systeme_ModulesAccueil_Kiosque extends Class_Systeme_ModulesAccueil_ 'op_hauteur_img' => 0, // hauteur des vignettes 'op_transition' => '', //type de transition pour le diaporama 'op_largeur_img' => 0, //largeur des vignettes + 'op_hauteur_boite' => 0, + 'op_captions' => 0, + 'op_autoplay' => 0, + 'op_visible' => 0, + 'op_speed' => 0, 'op_auto' => 0, // Animation (0 = aucune) 'op_scroll' => 1, // Défilement (1 = image par image) 'rss_avis' => 1, // afficher les RSS diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index f654366c440bbe627a2ebba662e6c8eaead99c3c..e9d05a9d4afd2acc22370422538c8b31237e9d9f 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -345,5 +345,15 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { $this->_redirect($router->getCurrentRoute()->assemble($token_params)); } + + + protected function getPreferenceProfile() { + if (!($id_module = $this->_getParam('id_module')) + || 2 > count($parts = explode('-', $id_module))) + return Class_Profil::getCurrentProfil(); + + return ($profile = Class_Profil::find($parts[0])) + ? $profile : Class_Profil::getCurrentProfil(); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Kiosque.php b/library/ZendAfi/View/Helper/Accueil/Kiosque.php index db3c7c7946680987a09e4bdc77d1b82c55be5690..0297c5fd3bc927a320810163ef167d51e53f710d 100644 --- a/library/ZendAfi/View/Helper/Accueil/Kiosque.php +++ b/library/ZendAfi/View/Helper/Accueil/Kiosque.php @@ -24,6 +24,10 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba public function __construct($id_module, $params) { parent::__construct($id_module, $params); + + $this->preferences['id_module'] = $id_module; + $this->preferences['id_profil'] = Class_Profil::getCurrentProfil()->getId(); + if ('' != $this->preferences['profil_redirect']) { $this->preferences['id_profil'] = $this->preferences['profil_redirect']; $this->preferences['id_module'] = Class_Profil::getCurrentProfil()->getId() @@ -140,97 +144,91 @@ 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, - 'id_profil' => Class_Profil::getCurrentProfil()->getId()); - - $action = "kiosque"; - switch($style_liste) { - case "slide_show": - $controler = "java"; - $args["vue"]="slide_show"; - $hauteur = $op_hauteur_img + 7; + $action = 'kiosque'; + switch($this->preferences['style_liste']) { + case 'slide_show': + $controler = 'java'; + $this->preferences['vue']='slide_show'; + $hauteur = $this->preferences['op_hauteur_img'] + 7; if ($hauteur == 7) $hauteur = 117; break; - case "protoflow": - $controler = "java"; - $args["vue"] = "protoflow"; + case 'protoflow': + $controler = 'java'; + $this->preferences['vue'] = 'protoflow'; $hauteur = 350; break; - case "cube": - $controler = "java"; - $args["vue"] = "cube"; - $hauteur = $op_hauteur_img + 20; + case 'cube': + $controler = 'java'; + $this->preferences['vue'] = 'cube'; + $hauteur = $this->preferences['op_hauteur_img'] + 20; break; - case "diaporama": - $controler = "java"; - $args["vue"] = "diaporama"; - $hauteur = $op_hauteur_boite; + case 'diaporama': + $controler = 'java'; + $this->preferences['vue'] = 'diaporama'; + $hauteur = $this->preferences['op_hauteur_boite']; break; - case "jcarousel": - $controler = "java"; - $args["vue"] = "jcarousel"; - $hauteur = $op_hauteur_img + 10; + case 'jcarousel': + $controler = 'java'; + $this->preferences['vue'] = 'jcarousel'; + $hauteur = $this->preferences['op_hauteur_img'] + 10; break; - case "mycarousel_horizontal": - $controler = "java"; - $args["vue"] = "mycarousel_horizontal"; - $hauteur = $op_hauteur_img + 5; + case 'mycarousel_horizontal': + $controler = 'java'; + $this->preferences['vue'] = 'mycarousel_horizontal'; + $hauteur = $this->preferences['op_hauteur_img'] + 5; break; - case "mycarousel_vertical": - $controler = "java"; - $args["vue"] = "mycarousel_vertical"; - $hauteur = ($op_visible * $op_hauteur_img) + 15; + case 'mycarousel_vertical': + $controler = 'java'; + $this->preferences['vue'] = 'mycarousel_vertical'; + $hauteur = ($this->preferences['op_visible'] * $this->preferences['op_hauteur_img']) + 15; break; - case "coverflow": - $controler = "flash"; - $action = "coverflow"; + case 'coverflow': + $controler = 'flash'; + $action = 'coverflow'; $hauteur = 270; break; - case "carrousel_horizontal": - $controler = "flash"; - $action = "carrouselhorizontal"; + case 'carrousel_horizontal': + $controler = 'flash'; + $action = 'carrouselhorizontal'; $hauteur = 310; break; - case "carrousel_vertical": - $controler = "flash"; - $action = "carrouselvertical"; + case 'carrousel_vertical': + $controler = 'flash'; + $action = 'carrouselvertical'; $hauteur = 500; break; - case "dockmenu_horizontal": - $controler = "flash"; - $action = "dockmenuh"; + case 'dockmenu_horizontal': + $controler = 'flash'; + $action = 'dockmenuh'; $hauteur = 170; break; - case "dockmenu_vertical": - $controler = "flash"; - $action = "dockmenuv"; + case 'dockmenu_vertical': + $controler = 'flash'; + $action = 'dockmenuv'; $hauteur = 300; break; - case "pyramid_gallery": - $controler = "flash"; - $action = "pyramidhorizontal"; + case 'pyramid_gallery': + $controler = 'flash'; + $action = 'pyramidhorizontal'; $hauteur = 290; break; } // Iframe $iframe = $this->view->getHelper('IframeContainer'); - $iframe->iframeContainer("100%", + $iframe->iframeContainer('100%', $hauteur, array_merge(['controller' => $controler, 'action' => $action], $this->preferences, - $args)); + $this->preferences)); return sprintf('<div class="embedcode">'. '<div><></div>'. '<div style="display:none">%s<textarea cols="20" rows="10" readonly="readonly">%s</textarea></div>'. '</div>', - $this->view->_("Copier le code suivant sur le site où vous voulez afficher le kiosque"), + $this->view->_('Copier le code suivant sur le site où vous voulez afficher le kiosque'), htmlspecialchars($iframe->getHtml())) .$iframe->getHtml(); } diff --git a/tests/application/modules/opac/controllers/JavaControllerTest.php b/tests/application/modules/opac/controllers/JavaControllerTest.php index 06fa6598cf1fc825919b4633be1982c16a977cb0..f4921cb290a5c92d5251f55e668c23f28bba223f 100644 --- a/tests/application/modules/opac/controllers/JavaControllerTest.php +++ b/tests/application/modules/opac/controllers/JavaControllerTest.php @@ -30,9 +30,9 @@ class JavaControllerWidthDefaultKiosqueTest extends AbstractControllerTestCase { $this->profil_cache = Class_Profil::getLoader()->newInstanceWithId(5345) - ->setBrowser('opac') - ->setLibelle('Profil cache') - ->setCfgAccueil($cfg_accueil); + ->setBrowser('opac') + ->setLibelle('Profil cache') + ->setCfgAccueil($cfg_accueil); Class_Profil::setCurrentProfil(Class_Profil::getLoader()->newInstanceWithId(2) ->setLibelle('Accueil')); @@ -77,7 +77,7 @@ class JavaControllerCarrouselHorizontalTest extends AbstractControllerTestCase { ['id_notice' => 4, 'titre' => 'Madagascar', 'vignette' => 'http://thumbnail.com/madagascar.jpg' - ] + ] ]); $this->dispatch('java/kiosque/id_module/1/titre/title+%2F+with+some+%2F+slashes/vue/mycarousel_horizontal', true); } @@ -175,7 +175,7 @@ class JavaControllerKiosqueSlideShowWidthWrongParamsTest extends AbstractControl $this->mock_sql ->whenCalled('fetchAll') ->with("select notices.id_notice, notices.editeur, notices.annee, notices.date_creation, notices.date_maj, notices.facettes, notices.clef_oeuvre from notices where url_vignette > '' and url_vignette != 'NO' order by date_creation DESC LIMIT 0,50", - false) + false) ->answers([]) ->beStrict(); @@ -189,4 +189,49 @@ class JavaControllerKiosqueSlideShowWidthWrongParamsTest extends AbstractControl } } -?> \ No newline at end of file + + + +class JavaControllerKiosqueSlideShowWithRedirectSettingsTest extends AbstractControllerTestCase { + + + public function setUp() { + parent::setUp(); + $this->mock_sql = Storm_Test_ObjectWrapper::mock(); + Zend_Registry::set('sql', $this->mock_sql); + + $this->mock_sql + ->whenCalled('fetchAll') + ->answers([$this->fixture('Class_Notice', + ['id' => 11, + 'clef_oeuvre' => 'POT' + ])->toArray()]); + } + + + protected function javaUrlWithPreferences($display_mode, $redirect_profil) { + return 'java/kiosque/id_module/3-1/titre/title+%2F+with+some+%2F+slashes/vue/' . $display_mode. '/id_profil/'.$redirect_profil; + + } + + + public function datas() { + return [[$this->javaUrlWithPreferences('slide_show', 123), '//div[@id="theImages"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('protoflow', 123), '//div[@id="protoflow"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('cube', 123), '//div[@id="linksCube"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('diaporama', 123), '//div[@class="slideshow"]//img[contains(@onclick, "id_profil/123")][contains(@onclick, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('jcarousel', 123), '//ul[@id="mycarousel"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('mycarousel_horizontal', 123), '//div[@class="jMyCarousel"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]'], + [$this->javaUrlWithPreferences('mycarousel_vertical', 123), '//div[@class="jMyCarousel"]//a[contains(@href, "id_profil/123")][contains(@href, "id_module/3-1")]']]; + } + + + /** + * @test + * @dataProvider datas + */ + public function recordLinksShouldBeAsExpected($url, $xpath) { + $this->dispatch($url, true); + $this->assertXPath($xpath); + } +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index a198d514a71585f9391666eef2f30122d03c8ffc..5a3fb467cece32da2f892e7731b4b47e7683d241 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -503,6 +503,13 @@ class ZendAfi_View_Helper_Accueil_KiosqueTitle extends ViewHelperTestCase { class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ZendAfi_View_Helper_Accueil_KiosqueTestCase { + + + public function setUp() { + parent::setUp(); + } + + public function getPreferences() { return ['type_module' => 'KIOSQUE', 'division' => 3, @@ -510,25 +517,26 @@ class ZendAfi_View_Helper_Accueil_KiosqueProfileRedirectTest extends ZendAfi_Vie } - protected function getPreferencesWith($prefs) { + protected function getPreferencesWith($display_mode, $id_profil) { $result = $this->getPreferences(); - $result['preferences'] = $prefs; + $result['preferences'] = ['style_liste' => $display_mode, + 'profil_redirect' => $id_profil]; return $result; } public function datas() { - return [ - [$this->getPreferencesWith(['style_liste' => 'mur', - 'profil_redirect' => '142']), - '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], - [$this->getPreferencesWith(['style_liste' => 'vignettes', - 'profil_redirect' => '142']), - '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], - [$this->getPreferencesWith(['style_liste' => 'chrono', - 'profil_redirect' => '142']), - '//script[contains(., "id_profil\\/142")][contains(., "id_module\\/2-3")]'] - ]; + return + [[$this->getPreferencesWith('mur','142'), '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], + [$this->getPreferencesWith('vignettes', '142'), '//a[contains(@href, "id_profil/142")][contains(@href, "id_module/2-3")]'], + [$this->getPreferencesWith('chrono', '142'), '//script[contains(., "id_profil\\/142")][contains(., "id_module\\/2-3")]'], + [$this->getPreferencesWith('slide_show', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('protoflow', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('cube', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('diaporama', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('jcarousel', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('mycarousel_horizontal', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]'], + [$this->getPreferencesWith('mycarousel_vertical', '142'), '//iframe[contains(@src, "id_profil/142")][contains(@src, "id_module/2-3")]']]; }