1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.web.includes;
35
36 import fr.paris.lutece.portal.service.content.PageData;
37 import fr.paris.lutece.portal.service.datastore.DatastoreService;
38 import fr.paris.lutece.portal.service.includes.PageInclude;
39 import fr.paris.lutece.portal.service.init.AppInfo;
40
41 import java.util.Map;
42
43 import javax.servlet.http.HttpServletRequest;
44
45
46
47
48
49 public class MetasInclude implements PageInclude
50 {
51 private static final String KEY_WEBMASTER_META_AUTHOR = "portal.site.site_property.meta.author";
52 private static final String KEY_WEBMASTER_META_COPYRIGHT = "portal.site.site_property.meta.copyright";
53 private static final String KEY_WEBMASTER_META_KEYWORDS = "portal.site.site_property.meta.keywords";
54 private static final String KEY_WEBMASTER_META_DESCRIPTION = "portal.site.site_property.meta.description";
55 private static final String MARK_PAGE_HEAD_META_AUTHOR = "meta_author";
56 private static final String MARK_PAGE_HEAD_META_COPYRIGHT = "meta_copyright";
57 private static final String MARK_PAGE_HEAD_META_KEYWORDS = "meta_keywords";
58 private static final String MARK_PAGE_HEAD_META_DESCRIPTION = "meta_description";
59 private static final String MARK_PAGE_HEAD_META_GENERATOR = "meta_generator";
60
61
62
63
64
65
66
67
68 @Override
69 public void fillTemplate( Map<String, Object> rootModel, PageData data, int nMode, HttpServletRequest request )
70 {
71 String strMetaAuthor = ( data.getMetaAuthor( ) != null ) ? data.getMetaAuthor( )
72 : DatastoreService.getDataValue( KEY_WEBMASTER_META_AUTHOR,
73 "" );
74 String strMetaCopyright = ( data.getMetaCopyright( ) != null ) ? data.getMetaCopyright( )
75 : DatastoreService.getDataValue( KEY_WEBMASTER_META_COPYRIGHT,
76 "" );
77 String strMetaKeywords = ( ( data.getMetaKeywords( ) != null ) && ( data.getMetaKeywords( ).length( ) > 0 ) )
78 ? ( DatastoreService.getDataValue( KEY_WEBMASTER_META_KEYWORDS, "" ) + ", " + data.getMetaKeywords( ) )
79 : DatastoreService.getDataValue( KEY_WEBMASTER_META_KEYWORDS, "" );
80 String strMetaDescription = ( ( data.getMetaDescription( ) != null ) &&
81 ( data.getMetaDescription( ).length( ) > 0 ) ) ? data.getMetaDescription( )
82 : DatastoreService.getDataValue( KEY_WEBMASTER_META_DESCRIPTION,
83 "" );
84
85 rootModel.put( MARK_PAGE_HEAD_META_AUTHOR, strMetaAuthor );
86 rootModel.put( MARK_PAGE_HEAD_META_COPYRIGHT, strMetaCopyright );
87 rootModel.put( MARK_PAGE_HEAD_META_KEYWORDS, strMetaKeywords );
88 rootModel.put( MARK_PAGE_HEAD_META_DESCRIPTION, strMetaDescription );
89 rootModel.put( MARK_PAGE_HEAD_META_GENERATOR, "LUTECE " + AppInfo.getVersion( ) );
90 }
91 }