Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
bibliossimo
opacce
Commits
812ccfb5
Commit
812ccfb5
authored
Dec 20, 2017
by
efalcy
Browse files
dev #56107 kiosk configuration: style properties loaded with ajax
parent
920c3dd1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
48 deletions
+143
-48
application/modules/admin/controllers/WidgetController.php
application/modules/admin/controllers/WidgetController.php
+16
-6
application/modules/opac/controllers/JavaController.php
application/modules/opac/controllers/JavaController.php
+10
-23
library/ZendAfi/View/Helper/TagObjetsImgProperties.php
library/ZendAfi/View/Helper/TagObjetsImgProperties.php
+15
-17
tests/application/modules/admin/controllers/WidgetControllerTest.php
...cation/modules/admin/controllers/WidgetControllerTest.php
+69
-0
tests/application/modules/opac/controllers/CmsControllerTest.php
...pplication/modules/opac/controllers/CmsControllerTest.php
+33
-2
No files found.
application/modules/admin/controllers/WidgetController.php
View file @
812ccfb5
...
...
@@ -183,14 +183,24 @@ class Admin_WidgetController extends ZendAfi_Controller_Action {
public
function
updateStyleAction
()
{
$profil
=
$this
->
extractProfilFromUrl
();
$preferences
=
array_merge
(
Class_Systeme_ModulesAccueil
::
getInstance
()
->
getValeursParDefaut
(
'KIOSQUE'
),
$profil
->
getModuleAccueilPreferences
(
$id_module
,
'KIOSQUE'
));
$viewRenderer
=
$this
->
getHelper
(
'ViewRenderer'
);
$viewRenderer
->
setNoRender
();
$preferences
=
Class_Systeme_ModulesAccueil
::
getInstance
()
->
getValeursParDefaut
(
'KIOSQUE'
);
if
(
$id_module
=
$this
->
_getParam
(
'id'
))
{
$profil
=
$this
->
extractProfilFromUrl
();
$preferences
=
array_merge
(
$preferences
,
$profil
->
getModuleAccueilPreferences
(
$id_module
,
'KIOSQUE'
));
}
$this
->
getHelper
(
'ViewRenderer'
)
->
setNoRender
();
$html
=
$this
->
view
->
imgObjectPropertiesReader
(
$this
->
_getParam
(
'style_liste'
,
''
),
$preferences
,
true
);
$html
=
Class_ScriptLoader
::
getInstance
()
->
beAjax
()
->
html
()
.
$html
;
$this
->
getResponse
()
->
setHeader
(
'Content-Type'
,
'application/json; charset=utf-8'
);
$this
->
getResponse
()
->
setBody
(
json_encode
([
'content'
=>
$
this
->
view
->
imgObjectPropertiesReader
(
$this
->
_getParam
(
'style_liste'
,
''
),
$preferences
,
true
)]
));
$this
->
getResponse
()
->
setBody
(
json_encode
([
'content'
=>
$
html
]
));
}
...
...
application/modules/opac/controllers/JavaController.php
View file @
812ccfb5
...
...
@@ -35,19 +35,20 @@ class JavaController extends ZendAfi_Controller_Action {
// rien ici -> tout est fait par le view-helper
}
public
function
widgetAction
()
{
$id_module
=
$this
->
_getParam
(
'code'
,
'KIOSQUE'
);
public
function
kiosqueAction
()
{
$profil
=
$this
->
extractProfilFromUrl
();
$id_module
=
$this
->
extractIdModuleFromUrl
();
$preferences
=
array_merge
(
Class_Systeme_ModulesAccueil
::
getInstance
()
->
getValeursParDefaut
(
'KIOSQUE'
),
$this
->
_request
->
getParams
());
$profil
->
getModuleAccueilPreferences
(
$id_module
,
'KIOSQUE'
));
$preferences
=
Class_Systeme_ModulesAccueil_Kiosque
::
updatePreferencesForProfileRedirect
(
$id_module
,
$preferences
);
$this
->
view
->
notices
=
Class_Catalogue
::
getNoticesByPreferences
(
$preferences
);
$this
->
view
->
preferences
=
$preferences
;
$this
->
renderView
();
}
protected
function
renderView
()
{
$viewRenderer
=
$this
->
getHelper
(
'ViewRenderer'
);
if
(
!
$this
->
view
->
notices
)
{
...
...
@@ -56,23 +57,9 @@ class JavaController extends ZendAfi_Controller_Action {
return
;
}
// Redirection vers la bonne vue
$vue
=
'/java/'
.
$this
->
_getParam
(
'vue'
,
'diaporama'
)
.
'.phtml'
;
$viewRenderer
->
renderScript
(
$vue
);
}
public
function
kiosqueAction
()
{
$profil
=
$this
->
extractProfilFromUrl
();
$id_module
=
$this
->
extractIdModuleFromUrl
();
$preferences
=
array_merge
(
Class_Systeme_ModulesAccueil
::
getInstance
()
->
getValeursParDefaut
(
'KIOSQUE'
),
$profil
->
getModuleAccueilPreferences
(
$id_module
,
'KIOSQUE'
));
$preferences
=
Class_Systeme_ModulesAccueil_Kiosque
::
updatePreferencesForProfileRedirect
(
$id_module
,
$preferences
);
$this
->
view
->
notices
=
Class_Catalogue
::
getNoticesByPreferences
(
$preferences
);
$this
->
view
->
preferences
=
$preferences
;
$this
->
renderView
();
}
...
...
library/ZendAfi/View/Helper/TagObjetsImgProperties.php
View file @
812ccfb5
...
...
@@ -38,23 +38,21 @@ class ZendAfi_View_Helper_TagObjetsImgProperties
private
function
getComboStyles
(
$styles
,
$valeur_select
)
{
// $submit_script = '$("select[name=\'style_liste\']").change(function() {$("#styles_reload").val("1");var form=$(this).closest("form"); form.submit();});';
$script
=
'$("select[name=\'style_liste\']").change(function() {$("#styles_reload").val("1");
$.ajax({
url: "/stl/admin/widget/update-style/style_liste/"+$("#style_liste").val() ,
type: "GET",
dataType: "json",
success: function(data) {
var div = data["content"];
$("#objet_props").html(div);
}
});
});
'
;
//$(.style_liste option:selected).each( function(index,element) {$($(element)[index]).html(div)
$update_url
=
$this
->
view
->
url
([
'module'
=>
'admin'
,
'controller'
=>
'widget'
,
'action'
=>
'update-style'
]);
$script
=
'$("select[name=\'style_liste\']").change(
function() {
$.ajax({
url: "'
.
$update_url
.
'/style_liste/" + $("#style_liste").val(),
dataType: "json",
success: function(data) {
var div = data["content"];
$("#objet_props").html(div);
}
});
});'
;
Class_ScriptLoader
::
getInstance
()
->
addJQueryReady
(
$script
);
...
...
tests/application/modules/admin/controllers/WidgetControllerTest.php
View file @
812ccfb5
...
...
@@ -2323,6 +2323,75 @@ class WidgetControllerGetFormTest extends Admin_AbstractControllerTestCase {
class
WidgetControllerUpdateStyleTest
extends
Admin_AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
,
$_json
,
$_xpath
;
public
function
setUp
()
{
parent
::
setUp
();
$this
->
_xpath
=
new
Storm_Test_XPath
();
}
protected
function
_dispatchUpdateStyle
()
{
$this
->
dispatch
(
'/admin/widget/update-style/style_liste/cube'
,
true
);
$this
->
_json
=
json_decode
(
$this
->
_response
->
getBody
(),
true
);
}
/** @test */
public
function
withoutIdModuleResponseShouldContainsSliderOpHauteurImg
()
{
$this
->
_dispatchUpdateStyle
();
$this
->
_xpath
->
assertXPath
(
$this
->
_json
[
'content'
],
'//input[@name="op_hauteur_img"]'
,
$this
->
_json
[
'content'
]);
}
/** @test */
public
function
responseShouldContainsSliderJavascriptInAjaxMode
()
{
$this
->
_dispatchUpdateStyle
();
$this
->
_xpath
->
assertXPathContentContains
(
$this
->
_json
[
'content'
],
'//script'
,
'setTimeout'
);
}
/** @test */
public
function
withoutIdModuleResponseShouldContainsDefaultValue150
()
{
$this
->
_dispatchUpdateStyle
();
$this
->
_xpath
->
assertXPathContentContains
(
$this
->
_json
[
'content'
],
'//script'
,
'value: 150'
);
}
/** @test */
public
function
withoutIdModuleResponseShouldContainsValue80
()
{
$cfg_accueil
=
[
'modules'
=>
[
'12'
=>
[
'division'
=>
'2'
,
'type_module'
=>
'KIOSQUE'
,
'preferences'
=>
[
'style_liste'
=>
'vignettes'
,
'op_hauteur_img'
=>
80
]]]];
$this
->
fixture
(
'Class_Profil'
,
[
'id'
=>
5
,
'libelle'
=>
'my profile'
,
'cfg_accueil'
=>
$cfg_accueil
])
->
beCurrentProfil
();
$this
->
dispatch
(
'/admin/widget/update-style/style_liste/cube/id/12/id_profil/5'
,
true
);
$this
->
_json
=
json_decode
(
$this
->
_response
->
getBody
(),
true
);
$this
->
_xpath
->
assertXPathContentContains
(
$this
->
_json
[
'content'
],
'//script'
,
'value: 80'
);
}
}
class
WidgetControllerGetFormPostTest
extends
Admin_AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
;
...
...
tests/application/modules/opac/controllers/CmsControllerTest.php
View file @
812ccfb5
...
...
@@ -1676,13 +1676,16 @@ class CmsControllerDispatchViewSummaryTest extends AbstractControllerTestCase {
class
CmsControllerWithArticleWithKioskTest
extends
AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
;
class
CmsControllerWithArticleWithKioskTestCase
extends
AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
;
protected
function
_loginHook
(
$account
)
{
$account
->
ROLE_LEVEL
=
ZendAfi_Acl_AdminControllerRoles
::
ADMIN_PORTAIL
;
$account
->
PSEUDO
=
"admin"
;
}
public
function
setUp
()
{
parent
::
setUp
();
$records
=
[
$this
->
fixture
(
'Class_Notice'
,
[
'id'
=>
2
,
...
...
@@ -1707,8 +1710,16 @@ class CmsControllerWithArticleWithKioskTest extends AbstractControllerTestCase {
Storm_Test_ObjectWrapper
::
onLoaderOfModel
(
'Class_Notice'
)
->
whenCalled
(
'findAllByRequeteRecherche'
)
->
answers
(
$records
);
}
}
class
CmsControllerWithArticleWithWallKioskTest
extends
CmsControllerWithArticleWithKioskTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
$this
->
fixture
(
'Class_Article'
,
[
'id'
=>
55
,
'titre'
=>
'Mes dvds'
,
'contenu'
=>
'<div class="bokeh-kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&style_liste=mur&styles_reload=0&op_speed=100&op_largeur_img=120&op_hauteur_img=150&profil_redirect=&id_catalogue=0&id_panier=&aleatoire=1&tri=1&nb_notices=20&nb_analyse=50&only_img=1&boite=&rss_avis=0">KIOSQUE</div>'
]);
...
...
@@ -1733,6 +1744,26 @@ class CmsControllerWithArticleWithKioskTest extends AbstractControllerTestCase {
public
function
adminButtonShouldNotBeenShow
()
{
$this
->
assertNotXPath
(
'//a[contains(@href,"widget/edit-widget")]'
,
$this
->
_response
->
getBody
());
}
}
class
CmsControllerWithArticleWithCubeKioskTest
extends
CmsControllerWithArticleWithKioskTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
$this
->
fixture
(
'Class_Article'
,
[
'id'
=>
55
,
'titre'
=>
'Mes dvds'
,
'contenu'
=>
'<div class="bokeh-kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&style_liste=cube&styles_reload=0&op_speed=100&op_largeur_img=120&op_hauteur_img=150&profil_redirect=&id_catalogue=0&id_panier=&aleatoire=1&tri=1&nb_notices=20&nb_analyse=50&only_img=1&boite=&rss_avis=0">KIOSQUE</div>'
]);
$this
->
dispatch
(
'/cms/articleview/id/55'
,
true
);
}
/** @test */
public
function
pageShouldContainsIFrameForCubeKiosque
()
{
$this
->
assertXPath
(
'//iframe[contains(@src, "style_liste/cube")]'
);;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment