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
f16a4c09
Commit
f16a4c09
authored
Dec 15, 2017
by
efalcy
Browse files
dev #56107 : display widget inside article
parent
c2100896
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
135 additions
and
65 deletions
+135
-65
application/modules/opac/controllers/CmsController.php
application/modules/opac/controllers/CmsController.php
+0
-17
library/ZendAfi/View/Helper/Article/RenderAbstract.php
library/ZendAfi/View/Helper/Article/RenderAbstract.php
+5
-3
library/ZendAfi/View/Helper/Article/RenderFullContent.php
library/ZendAfi/View/Helper/Article/RenderFullContent.php
+1
-1
library/ZendAfi/View/Helper/Article/ReplaceWidgets.php
library/ZendAfi/View/Helper/Article/ReplaceWidgets.php
+50
-0
public/opac/js/ckeditor_plugins/bokeh-kiosk/dialogs/kiosk.js
public/opac/js/ckeditor_plugins/bokeh-kiosk/dialogs/kiosk.js
+15
-7
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.css
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.css
+1
-1
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.js
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.js
+6
-6
tests/application/modules/admin/controllers/WidgetControllerTest.php
...cation/modules/admin/controllers/WidgetControllerTest.php
+0
-23
tests/application/modules/opac/controllers/CmsControllerTest.php
...pplication/modules/opac/controllers/CmsControllerTest.php
+57
-7
No files found.
application/modules/opac/controllers/CmsController.php
View file @
f16a4c09
...
...
@@ -39,23 +39,6 @@ class CmsController extends ZendAfi_Controller_Action {
'action'
=>
'widget'
,
'code'
=>
'KIOSQUE'
,
'render'
=>
'popup'
]);
Class_ScriptLoader
::
getInstance
()
->
addJQueryReady
(
'
$(\'.bokeh-widget\').each(function(index,element) {
$.ajax({
url:"'
.
$url
.
'",
type: "POST",
data: $(this).attr("data-form"),
dataType: "json",
success: function(data) {
var div = data["content"];
$($(element)[index]).html(div);
}
});
});
'
);
}
...
...
library/ZendAfi/View/Helper/Article/RenderAbstract.php
View file @
f16a4c09
...
...
@@ -45,6 +45,7 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
}
public
function
tagArticleEvent
(
$article
)
{
return
$this
->
view
->
tagArticleEvent
(
$article
);
}
...
...
@@ -90,10 +91,11 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
public
function
renderContent
(
$article
)
{
if
(
!
$article
->
hasSummary
())
return
$article
->
getFullContent
();
$content
=
(
!
$article
->
hasSummary
())
?
$this
->
renderSummary
(
$article
)
:
$article
->
getFullContent
();
return
$this
->
view
->
article_ReplaceWidgets
(
$content
);
return
$this
->
renderSummary
(
$article
);
}
...
...
library/ZendAfi/View/Helper/Article/RenderFullContent.php
View file @
f16a4c09
...
...
@@ -28,7 +28,7 @@ class ZendAfi_View_Helper_Article_RenderFullContent extends ZendAfi_View_Helper_
}
public
function
renderContent
(
$article
)
{
return
$article
->
getFullContent
();
return
$this
->
view
->
article_ReplaceWidgets
(
$article
->
getFullContent
()
)
;
}
}
?>
\ No newline at end of file
library/ZendAfi/View/Helper/Article/ReplaceWidgets.php
0 → 100644
View file @
f16a4c09
<?php
/**
* Copyright (c) 2012-2017, 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_Article_ReplaceWidgets
extends
ZendAfi_View_Helper_BaseHelper
{
public
function
article_ReplaceWidgets
(
$content
)
{
// '|<div[^>]+data-code="(?P<code>\w+)"[^>]+data-form="(?P<form>\w+)"[^>]*>[^<]+</div>|',
return
preg_replace_callback
(
'|(?P<alldiv><div[^>]+data-code="(?P<code>\w+)"[^>]+data-form="(?P<form>[^"]+)[^>]*>[^<]+</div>)|'
,
function
(
$matches
)
{
return
$this
->
_renderWidget
(
$matches
[
'code'
],
$matches
[
'form'
]);
},
$content
);
}
protected
function
_renderWidget
(
$code
,
$form
)
{
$prefs
=
[];
parse_str
(
html_entity_decode
(
$form
),
$prefs
);
$params
=
[
'type_module'
=>
$code
,
'preferences'
=>
$prefs
];
xdebug_break
();
$helper
=
ZendAfi_View_Helper_Accueil_Base
::
getModuleHelperFromParams
(
null
,
$params
,
$this
->
view
);
return
$helper
->
getBoite
();
//Class_Systeme_ModulesAccueil::moduleByCode($code)
}
}
?>
\ No newline at end of file
public/opac/js/ckeditor_plugins/bokeh-kiosk/dialogs/kiosk.js
View file @
f16a4c09
CKEDITOR
.
dialog
.
add
(
'
kioskDialog
'
,
function
(
editor
)
{
return
{
var
dialog
=
{
title
:
'
Bokeh Kiosk Properties
'
,
minWidth
:
400
,
minHeight
:
200
,
...
...
@@ -44,11 +43,17 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
],
isBokehKiosk
:
function
(
element
)
{
return
(
$
(
element
.
$
).
hasClass
(
'
bokeh-kiosk
'
)
||
$
(
element
.
$
).
closest
(
'
bokeh-kiosk
'
).
size
);
},
onShow
:
function
()
{
var
selection
=
editor
.
getSelection
();
var
element
=
selection
.
getStartElement
();
this
.
insertMode
=
true
;
if
(
$
(
element
.
$
).
hasClass
(
'
b
okeh
-k
iosk
'
)
||
$
(
element
.
$
).
closest
(
'
bokeh-kiosk
'
).
size
)
{
if
(
dialog
.
isB
okeh
K
iosk
(
element
)
)
{
element
=
$
(
element
.
$
).
closest
(
'
bokeh-kiosk
'
);
this
.
insertMode
=
false
;
}
...
...
@@ -57,13 +62,11 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
return
this
.
setupContent
(
this
.
element
);
this
.
setupContent
(
null
);
},
onOk
:
function
()
{
var
dialog
=
this
;
var
selection
=
editor
.
getSelection
();
var
widget
=
selection
.
getStartElement
();
if
(
!
widget
)
{
if
(
!
widget
||
!
dialog
.
isBokehKiosk
(
widget
)
)
{
widget
=
editor
.
document
.
createElement
(
'
div
'
);
editor
.
insertElement
(
widget
);
}
...
...
@@ -74,9 +77,14 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
$
(
widget
)
.
attr
(
'
data-form
'
,
$
(
'
.bokeh-kiosk-form form
'
).
serialize
())
.
attr
(
'
data-code
'
,
'
KIOSQUE
'
)
.
attr
(
'
class
'
,
'
bokeh-kiosk
'
);
},
10
);
}
};
});
return
dialog
;
}
)
;
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.css
View file @
f16a4c09
.bokeh-
widget
{
.bokeh-
kiosk
{
background-color
:
red
;
width
:
100px
;
height
:
100px
;
...
...
public/opac/js/ckeditor_plugins/bokeh-kiosk/plugin.js
View file @
f16a4c09
...
...
@@ -8,17 +8,17 @@ CKEDITOR.plugins.add( 'bokeh-kiosk', {
editor
.
addContentsCss
(
this
.
path
+
'
plugin.css
'
);
if
(
editor
.
contextMenu
)
{
editor
.
addMenuGroup
(
'
bokeh
Widget
Group
'
);
editor
.
addMenuItem
(
'
bokeh
Widget
Item
'
,
{
label
:
'
Edit
widget
'
,
editor
.
addMenuGroup
(
'
bokeh
Kiosk
Group
'
);
editor
.
addMenuItem
(
'
bokeh
Kiosk
Item
'
,
{
label
:
'
Edit
kiosk
'
,
icon
:
this
.
path
+
'
icons/basket.png
'
,
command
:
'
editKiosk
'
,
group
:
'
bokeh
Widget
Group
'
group
:
'
bokeh
Kiosk
Group
'
});
editor
.
contextMenu
.
addListener
(
function
(
element
)
{
if
(
$
(
element
.
$
).
hasClass
(
'
bokeh-
widget
'
)
||
$
(
element
.
$
).
closest
(
'
bokeh-
widget
'
).
size
)
{
return
{
bokeh
Widget
Item
:
CKEDITOR
.
TRISTATE_OFF
};
if
(
$
(
element
.
$
).
hasClass
(
'
bokeh-
kiosk
'
)
||
$
(
element
.
$
).
closest
(
'
bokeh-
kiosk
'
).
size
)
{
return
{
bokeh
Kiosk
Item
:
CKEDITOR
.
TRISTATE_OFF
};
}
});
}
...
...
tests/application/modules/admin/controllers/WidgetControllerTest.php
View file @
f16a4c09
...
...
@@ -2350,26 +2350,3 @@ class WidgetControllerGetFormPostTest extends Admin_AbstractControllerTestCase {
}
class
WidgetControllerCmsKioskTest
extends
WidgetControllerWidgetConfigurationTestCase
{
public
function
setUp
()
{
$this
->
_type_module
=
'KIOSQUE'
;
$article_en
=
$this
->
fixture
(
'Class_Article'
,
[
'id'
=>
2241
,
'titre'
=>
'Feast of fried'
,
'contenu'
=>
'
an appetizing feast</div>'
]);
parent
::
setUp
();
$this
->
dispatch
(
'/opac/cms/articleview/id/2241'
,
true
);
}
/** @test */
public
function
kioskShouldBeDisplayed
()
{
$this
->
assertXPath
(
'//div'
,
$this
->
_response
->
getBody
());
}
}
\ No newline at end of file
tests/application/modules/opac/controllers/CmsControllerTest.php
View file @
f16a4c09
...
...
@@ -954,11 +954,6 @@ class CmsControllerArticleViewInEnglishTest extends CmsControllerWithFeteDeLaFri
class
CmsControllerArticleViewOnPortalTest
extends
CmsControllerWithFeteDeLaFriteTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
Class_Article
::
find
(
224
)
->
setContent
(
'<div class="bokeh-widget" data-form="titre=ma%20boiboite&style_liste=mycarousel_horizontal&styles_reload=0&op_speed=100&op_largeur_img=120&op_hauteur_img=150&profil_redirect=&id_catalogue=&id_panier=&aleatoire=1&tri=1&nb_notices=20&nb_analyse=50&only_img=1&boite=&rss_avis=0"> </div>'
)
->
getCategorie
()
->
setBib
(
null
)
->
assertSave
();
$this
->
dispatch
(
'/cms/articleview/id/224'
,
true
);
}
...
...
@@ -977,8 +972,9 @@ class CmsControllerArticleViewOnPortalTest extends CmsControllerWithFeteDeLaFrit
/** @test */
public
function
withKioskShouldDisplayJs
()
{
$this
->
postdispatch
(
'/java/widget'
,
[
'titre'
=>
'Mon kiosque'
,
'style_liste'
=>
'mycarousel_horizontal'
]);
// $this->assertXPathContentContains('//',);
'style_liste'
=>
'mycarousel_horizontal'
]);
}
...
...
@@ -1675,4 +1671,58 @@ class CmsControllerDispatchViewSummaryTest extends AbstractControllerTestCase {
public
function
profilShouldBe3
()
{
$this
->
assertXpath
(
'//body[contains(@class, "profil_1")]'
);
}
}
class
CmsControllerWithArticleWithKioskTest
extends
AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
;
public
function
setUp
()
{
parent
::
setUp
();
$records
=
[
$this
->
fixture
(
'Class_Notice'
,
[
'id'
=>
2
,
'unimarc'
=>
file_get_contents
(
ROOT_PATH
.
'/tests/fixtures/dvd_potter.uni'
),
'url_vignette'
=>
'hp.png'
,
'url_image'
=>
'hp_big.png'
,
'facettes'
=>
'D123 A400 Y2'
,
'clef_oeuvre'
=>
'HPELPA'
,
'clef_alpha'
=>
'POTTER'
,
'exemplaires'
=>
[]]),
$this
->
fixture
(
'Class_Notice'
,
[
'id'
=>
45
,
'unimarc'
=>
file_get_contents
(
ROOT_PATH
.
'/tests/fixtures/jeune_fille_dvd.uni'
),
'url_vignette'
=>
'jeune_fille.png'
,
'url_image'
=>
'jeune_fille_big.png'
,
'facettes'
=>
'D13 A10 Y1'
,
'clef_oeuvre'
=>
'JF'
,
'clef_alpha'
=>
'JF'
,
'exemplaires'
=>
[]]),
];
Storm_Test_ObjectWrapper
::
onLoaderOfModel
(
'Class_Notice'
)
->
whenCalled
(
'findAllByRequeteRecherche'
)
->
answers
(
$records
);
$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>'
]);
$this
->
dispatch
(
'/cms/articleview/id/55'
,
true
);
}
/** @test */
public
function
bokehKioskShouldBeRemoved
()
{
$this
->
assertNotXPath
(
'//div[@class="bokeh-kiosk"]'
);
}
/** @test */
public
function
pageShouldContainsKiosk
()
{
$this
->
assertXPath
(
'//div[@class="liste_mur"]'
);;
}
}
\ 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