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
afi
opacce
Commits
eaf050f2
Commit
eaf050f2
authored
Feb 01, 2019
by
Ghislain Loas
Browse files
dev #64573 improve rating rendering
parent
4c95a090
Pipeline
#6236
failed with stage
in 25 minutes and 6 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
106 additions
and
46 deletions
+106
-46
application/modules/opac/controllers/AbonneController.php
application/modules/opac/controllers/AbonneController.php
+7
-3
library/Class/AvisNotice.php
library/Class/AvisNotice.php
+23
-0
library/templates/Intonation/Library/Link.php
library/templates/Intonation/Library/Link.php
+1
-4
library/templates/Intonation/Library/View/Wrapper/Abstract.php
...ry/templates/Intonation/Library/View/Wrapper/Abstract.php
+7
-2
library/templates/Intonation/Library/View/Wrapper/Review.php
library/templates/Intonation/Library/View/Wrapper/Review.php
+12
-5
library/templates/Intonation/Library/Widget/Carousel/Definition.php
...mplates/Intonation/Library/Widget/Carousel/Definition.php
+1
-0
library/templates/Intonation/Library/Widget/Carousel/Form.php
...ary/templates/Intonation/Library/Widget/Carousel/Form.php
+3
-2
library/templates/Intonation/Library/Widget/Carousel/Review/Definition.php
.../Intonation/Library/Widget/Carousel/Review/Definition.php
+1
-1
library/templates/Intonation/Library/Widget/Carousel/ReviewsByRecord/View.php
...tonation/Library/Widget/Carousel/ReviewsByRecord/View.php
+5
-4
library/templates/Intonation/Library/Widget/Carousel/View.php
...ary/templates/Intonation/Library/Widget/Carousel/View.php
+31
-16
library/templates/Intonation/View/Cardify.php
library/templates/Intonation/View/Cardify.php
+2
-4
library/templates/Intonation/View/CardifyOnlyDescription.php
library/templates/Intonation/View/CardifyOnlyDescription.php
+4
-2
library/templates/Intonation/View/Notice/Exemplaires.php
library/templates/Intonation/View/Notice/Exemplaires.php
+1
-3
tests/scenarios/Templates/TemplatesTest.php
tests/scenarios/Templates/TemplatesTest.php
+8
-0
No files found.
application/modules/opac/controllers/AbonneController.php
View file @
eaf050f2
...
...
@@ -1341,10 +1341,11 @@ class AbonneController extends ZendAfi_Controller_Action {
->
setIdNotice
(
$this
->
_getParam
(
'record_id'
))
->
setClefOeuvre
(
$this
->
_getParam
(
'record_key'
))
->
setUserRole
(
$this
->
_user
)
->
setModerationOK
()
->
updateAttributes
(
$post
);
if
(
!
$this
->
_getPost
(
'entete'
)
&&
!
$this
->
_getPost
(
'avis'
))
$rating
->
setModerationOK
();
if
(
$this
->
_getPost
(
'entete'
)
||
$this
->
_getPost
(
'avis'
))
$rating
->
setModeration
N
OK
();
if
(
!
$form
->
isValidModelAndArray
(
$rating
,
$post
))
return
$this
->
_redirectToReferer
();
...
...
@@ -1352,7 +1353,10 @@ class AbonneController extends ZendAfi_Controller_Action {
if
(
!
$rating
->
save
())
return
false
;
$this
->
_helper
->
notify
(
$this
->
_
(
'Votre avis a été pris en compte.'
));
$this
->
_helper
->
notify
(
$this
->
_
(
'Votre avis %s / %s a été pris en compte.'
,
$this
->
_getPost
(
'note'
),
5
));
return
$this
->
_redirectToReferer
();
}
}
\ No newline at end of file
library/Class/AvisNotice.php
View file @
eaf050f2
...
...
@@ -210,6 +210,29 @@ class AvisNoticeLoader extends Storm_Model_Loader {
public
function
findAllUserIds
()
{
return
Zend_Registry
::
get
(
'sql'
)
->
fetchAllByColumn
(
'select distinct(id_user) as id from notices_avis'
);
}
public
function
groupByRecords
(
$reviews
)
{
$reviews_by_records
=
[];
foreach
(
$reviews
as
$review
)
{
if
(
!
$record
=
$review
->
getFirstNotice
())
continue
;
if
(
!
isset
(
$reviews_by_records
[
$record
->
getId
()]))
$reviews_by_records
[
$record
->
getId
()]
=
[
'Record'
=>
$record
,
'Reviews'
=>
[]];
$reviews_by_records
[
$record
->
getId
()][
'Reviews'
]
=
array_merge
(
$reviews_by_records
[
$record
->
getId
()][
'Reviews'
],
[
$review
]);
}
return
array_map
(
function
(
$element
)
{
return
new
Class_ReviewsByRecord
(
$element
);
},
$reviews_by_records
);
}
}
...
...
library/templates/Intonation/Library/Link.php
View file @
eaf050f2
...
...
@@ -20,7 +20,4 @@
*/
class
Intonation_Library_Link
extends
Class_Entity
{
}
?>
\ No newline at end of file
class
Intonation_Library_Link
extends
Class_Entity
{}
\ No newline at end of file
library/templates/Intonation/Library/View/Wrapper/Abstract.php
View file @
eaf050f2
...
...
@@ -34,12 +34,17 @@ class Intonation_Library_View_Wrapper_Abstract {
}
public
function
setModel
(
$
record
)
{
$this
->
_model
=
$
record
;
public
function
setModel
(
$
model
)
{
$this
->
_model
=
$
model
;
return
$this
;
}
public
function
getModel
()
{
return
$this
->
_model
;
}
public
function
getSecondaryLink
()
{
return
null
;
}
...
...
library/templates/Intonation/Library/View/Wrapper/Review.php
View file @
eaf050f2
...
...
@@ -23,7 +23,13 @@
class
Intonation_Library_View_Wrapper_Review
extends
Intonation_Library_View_Wrapper_Abstract
{
public
function
getTitle
()
{
return
$this
->
_view
->
rating
(
$this
->
_model
->
getNote
())
.
' '
.
$this
->
_model
->
getEntete
();
$title
=
(
$title
=
$this
->
_model
->
getEntete
())
?
BR
.
$title
:
''
;
return
$this
->
_view
->
rating
(
$this
->
_model
->
getNote
())
.
$title
;
}
...
...
@@ -34,11 +40,11 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra
public
function
getExplicitTitle
()
{
if
(
$author
=
$this
->
getAuthor
())
return
$this
->
_
(
'
"%s" écrit
par "%s"'
,
return
$this
->
_
(
'
Avis "%s" donné
par "%s"'
,
$this
->
getTitle
(),
$this
->
getAuthor
());
return
$this
->
_
(
'"%s"'
,
return
$this
->
_
(
'
Avis
"%s"'
,
$this
->
getTitle
());
}
...
...
@@ -50,14 +56,15 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra
public
function
getDocTypeLabel
()
{
$type_doc
=
Class_TypeDoc
::
find
(
$this
->
getDocType
());
return
$type_doc
?
$type_doc
->
getLabel
()
:
''
;
;
return
$type_doc
?
$type_doc
->
getLabel
()
:
''
;
}
public
function
getMainLink
()
{
return
new
Intonation_Library_Link
([
'Url'
=>
$this
->
_model
->
getUrl
(),
'Text'
=>
$this
->
_
(
'Lire l\'avis'
),
'Title'
=>
$this
->
_getMainLinkTitle
()]);
'Title'
=>
$this
->
_getMainLinkTitle
(),
'Popup'
=>
true
]);
}
...
...
library/templates/Intonation/Library/Widget/Carousel/Definition.php
View file @
eaf050f2
...
...
@@ -28,6 +28,7 @@ class Intonation_Library_Widget_Carousel_Definition extends Class_Systeme_Module
MULTIPLE_CAROUSEL
=
'multiple_carousel'
,
CARD_OVERLAY
=
'card-overlay'
,
CARD_DESCRIPTION
=
'card-description'
,
CARD
=
'card'
;
...
...
library/templates/Intonation/Library/Widget/Carousel/Form.php
View file @
eaf050f2
...
...
@@ -99,7 +99,8 @@ class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Configuration
public
function
getRenderings
()
{
return
[
Intonation_Library_Widget_Carousel_Definition
::
CARD_OVERLAY
=>
$this
->
_
(
'Media'
),
Intonation_Library_Widget_Carousel_Definition
::
CARD
=>
$this
->
_
(
'Media suivi par une description'
)];
return
[
Intonation_Library_Widget_Carousel_Definition
::
CARD_OVERLAY
=>
$this
->
_
(
'Média'
),
Intonation_Library_Widget_Carousel_Definition
::
CARD
=>
$this
->
_
(
'Média suivi par une description'
),
Intonation_Library_Widget_Carousel_Definition
::
CARD_DESCRIPTION
=>
$this
->
_
(
'Uniquement une description'
)];
}
}
\ No newline at end of file
library/templates/Intonation/Library/Widget/Carousel/Review/Definition.php
View file @
eaf050f2
...
...
@@ -38,7 +38,7 @@ class Intonation_Library_Widget_Carousel_Review_Definition extends Intonation_Li
public
function
__construct
()
{
$this
->
_libelle
=
$this
->
_
(
'Boite d\'avis'
);
$this
->
_form
=
'Intonation_Library_Widget_Carousel_Review_Form'
;
$this
->
_view_helper
=
'Intonation_Library_Widget_Carousel_Review_View'
;
$this
->
_view_helper
=
'Intonation_Library_Widget_Carousel_Review
sByRecord
_View'
;
$this
->
_defaultValues
=
[
'titre'
=>
$this
->
_libelle
,
'rendering'
=>
static
::
CARD_OVERLAY
,
'layout'
=>
static
::
WALL
,
...
...
library/templates/Intonation/Library/Widget/Carousel/Review/View.php
→
library/templates/Intonation/Library/Widget/Carousel/Review
sByRecord
/View.php
View file @
eaf050f2
...
...
@@ -20,16 +20,17 @@
*/
class
Intonation_Library_Widget_Carousel_Review_View
extends
Intonation_Library_Widget_Carousel_View
{
class
Intonation_Library_Widget_Carousel_Review
sByRecord
_View
extends
Intonation_Library_Widget_Carousel_View
{
protected
$_all_reviews
=
[];
protected
function
_findElements
()
{
$loader
=
Class_AvisNotice
::
getLoader
();
$reviews_to_show
=
$loader
->
getAvisFromPreferences
(
$this
->
preferences
);
$reviews_to_show
=
$loader
->
getAvisFromPreferences
(
$this
->
preferences
,
[
0
,
1000
],
true
);
$this
->
_all_reviews
=
$reviews_to_show
;
return
$reviews_to_show
;
return
$loader
->
groupByRecords
(
$reviews_to_show
);
}
...
...
@@ -61,6 +62,6 @@ class Intonation_Library_Widget_Carousel_Review_View extends Intonation_Library_
protected
function
_getWrapper
()
{
return
'Intonation_Library_View_Wrapper_Review'
;
return
'Intonation_Library_View_Wrapper_Review
sByRecord
'
;
}
}
\ No newline at end of file
library/templates/Intonation/Library/Widget/Carousel/View.php
View file @
eaf050f2
...
...
@@ -80,7 +80,7 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help
'aria-expanded'
=>
'false'
])
.
$this
->
_tag
(
'div'
,
$this
->
view
->
tagPre
(
$this
->
_tag
(
'iframe'
,
''
,
''
,
[
'src'
=>
$this
->
view
->
absoluteUrl
([
'module'
=>
'opac'
,
'controller'
=>
'widget'
,
...
...
@@ -111,24 +111,16 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help
if
(
!
$elements
=
$this
->
_findElements
())
return
$this
->
_tag
(
'p'
,
$this
->
_
(
'Aucun document'
));
$content_callback
=
$this
->
_settings
->
getRendering
()
==
Intonation_Library_Widget_Carousel_Definition
::
CARD_OVERLAY
?
(
function
(
$element
)
{
return
$this
->
view
->
cardifyWithOverlay
(
$element
);
})
:
(
function
(
$element
)
{
return
$this
->
view
->
cardify
(
$element
);
});
$content_callback
=
$this
->
_getContentCallback
();
$elements
=
array_slice
(
$elements
,
0
,
$this
->
_settings
->
getSize
());
$elements
=
array_map
(
function
(
$element
)
{
$wrapper
=
$this
->
_getWrapper
();
return
(
new
$wrapper
)
->
setView
(
$this
->
view
)
->
setModel
(
$element
);
},
$elements
);
{
$wrapper
=
$this
->
_getWrapper
();
return
(
new
$wrapper
)
->
setView
(
$this
->
view
)
->
setModel
(
$element
);
},
$elements
);
$elements
=
new
Storm_Collection
(
$elements
);
...
...
@@ -144,6 +136,29 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help
}
protected
function
_getContentCallback
()
{
if
(
$this
->
_settings
->
getRendering
()
==
Intonation_Library_Widget_Carousel_Definition
::
CARD_OVERLAY
)
return
function
(
$element
)
{
return
$this
->
view
->
cardifyWithOverlay
(
$element
);
};
if
(
$this
->
_settings
->
getRendering
()
==
Intonation_Library_Widget_Carousel_Definition
::
CARD
)
return
function
(
$element
)
{
return
$this
->
view
->
cardify
(
$element
);
};
if
(
$this
->
_settings
->
getRendering
()
==
Intonation_Library_Widget_Carousel_Definition
::
CARD_DESCRIPTION
)
return
function
(
$element
)
{
return
$this
->
view
->
cardifyOnlyDescription
(
$element
);
};
return
function
()
{
return
''
;};
}
abstract
protected
function
_findElements
();
abstract
protected
function
_getWrapper
();
abstract
protected
function
_getLinkToAllUrl
();
...
...
library/templates/Intonation/View/Cardify.php
View file @
eaf050f2
...
...
@@ -22,9 +22,7 @@
class
Intonation_View_Cardify
extends
ZendAfi_View_Helper_BaseHelper
{
public
function
cardify
(
$element
)
{
return
$this
->
_tag
(
'div'
,
$this
->
_cardWithPicture
(
$element
),
[
'class'
=>
'card no_overflow'
]);
return
$this
->
_cardWithPicture
(
$element
);
}
...
...
@@ -37,6 +35,6 @@ class Intonation_View_Cardify extends ZendAfi_View_Helper_BaseHelper {
:
$this
->
_
(
'Aïe, aïe, aïe ! Pas d\'image pour "%s".'
,
$element
->
getTitle
()))]);
return
$img
.
$this
->
view
->
cardifyOnlyDescription
(
$element
);
return
$this
->
view
->
cardifyOnlyDescription
(
$element
,
$img
);
}
}
\ No newline at end of file
library/templates/Intonation/View/CardifyOnlyDescription.php
View file @
eaf050f2
...
...
@@ -22,7 +22,7 @@
class
Intonation_View_CardifyOnlyDescription
extends
ZendAfi_View_Helper_BaseHelper
{
public
function
cardifyOnlyDescription
(
$element
)
{
public
function
cardifyOnlyDescription
(
$element
,
$img
=
''
)
{
$content
=
[];
if
(
$title
=
$element
->
getTitle
())
...
...
@@ -68,6 +68,8 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHel
implode
(
$links
),
[
'class'
=>
'card-footer d-flex flex-column flex-md-row justify-content-between'
]);
return
implode
(
$html
);
return
$this
->
_tag
(
'div'
,
$img
.
implode
(
$html
),
[
'class'
=>
'card no_overflow'
]);
}
}
\ No newline at end of file
library/templates/Intonation/View/Notice/Exemplaires.php
View file @
eaf050f2
...
...
@@ -24,9 +24,7 @@ class Intonation_View_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper
public
function
Notice_Exemplaires
(
$exemplaires
,
$nb_notices_oeuvre
=
0
,
$aff
=
"normal"
)
{
$callback
=
function
(
$element
)
{
return
$this
->
_tag
(
'div'
,
$this
->
view
->
cardifyOnlyDescription
(
$element
),
[
'class'
=>
'card'
]);
return
$this
->
view
->
cardifyOnlyDescription
(
$element
);
};
usort
(
$exemplaires
,
...
...
tests/scenarios/Templates/TemplatesTest.php
View file @
eaf050f2
...
...
@@ -1873,15 +1873,23 @@ class TemplatesReviewsWidgetTest extends TemplatesIntonationTestCase {
'link_to_all'
=>
1
,
'embeded_code'
=>
1
,
'IntonationShowFooter'
=>
1
,
'rendering'
=>
'card'
,
'layout'
=>
'multiple_carousel'
])
->
updateProfile
();
$this
->
fixture
(
'Class_AvisNotice'
,
[
'id'
=>
4
,
'id_notice'
=>
2
,
'clef_oeuvre'
=>
'PSYKO'
,
'note'
=>
'4'
,
'entete'
=>
'Le Roi'
,
'avis'
=>
'Le Roi des cons sur son throne'
]);
$this
->
fixture
(
'Class_Notice'
,
[
'id'
=>
2
,
'clef_oeuvre'
=>
'PSYKO'
,
]);
$this
->
dispatch
(
'/opac/index/index/id_profil/72'
,
true
);
$this
->
assertXPathContentContains
(
'//div'
,
'Le Roi'
);
}
...
...
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