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 public class MetasInclude implements PageInclude
49 {
50 private static final String KEY_WEBMASTER_META_AUTHOR = "portal.site.site_property.meta.author";
51 private static final String KEY_WEBMASTER_META_COPYRIGHT = "portal.site.site_property.meta.copyright";
52 private static final String KEY_WEBMASTER_META_KEYWORDS = "portal.site.site_property.meta.keywords";
53 private static final String KEY_WEBMASTER_META_DESCRIPTION = "portal.site.site_property.meta.description";
54 private static final String MARK_PAGE_HEAD_META_AUTHOR = "meta_author";
55 private static final String MARK_PAGE_HEAD_META_COPYRIGHT = "meta_copyright";
56 private static final String MARK_PAGE_HEAD_META_KEYWORDS = "meta_keywords";
57 private static final String MARK_PAGE_HEAD_META_DESCRIPTION = "meta_description";
58 private static final String MARK_PAGE_HEAD_META_GENERATOR = "meta_generator";
59
60
61
62
63
64
65
66
67
68
69
70
71
72 @Override
73 public void fillTemplate( Map<String, Object> rootModel, PageData data, int nMode, HttpServletRequest request )
74 {
75 String strMetaAuthor = ( data.getMetaAuthor( ) != null ) ? data.getMetaAuthor( ) : DatastoreService.getDataValue( KEY_WEBMASTER_META_AUTHOR, "" );
76 String strMetaCopyright = ( data.getMetaCopyright( ) != null ) ? data.getMetaCopyright( )
77 : DatastoreService.getDataValue( KEY_WEBMASTER_META_COPYRIGHT, "" );
78 String strMetaKeywords = ( ( data.getMetaKeywords( ) != null ) && ( data.getMetaKeywords( ).length( ) > 0 ) )
79 ? ( DatastoreService.getDataValue( KEY_WEBMASTER_META_KEYWORDS, "" ) + ", " + data.getMetaKeywords( ) )
80 : DatastoreService.getDataValue( KEY_WEBMASTER_META_KEYWORDS, "" );
81 String strMetaDescription = ( ( data.getMetaDescription( ) != null ) && ( data.getMetaDescription( ).length( ) > 0 ) ) ? data.getMetaDescription( )
82 : DatastoreService.getDataValue( KEY_WEBMASTER_META_DESCRIPTION, "" );
83
84 rootModel.put( MARK_PAGE_HEAD_META_AUTHOR, strMetaAuthor );
85 rootModel.put( MARK_PAGE_HEAD_META_COPYRIGHT, strMetaCopyright );
86 rootModel.put( MARK_PAGE_HEAD_META_KEYWORDS, strMetaKeywords );
87 rootModel.put( MARK_PAGE_HEAD_META_DESCRIPTION, strMetaDescription );
88 rootModel.put( MARK_PAGE_HEAD_META_GENERATOR, "LUTECE " + AppInfo.getVersion( ) );
89 }
90 }