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.service.editor;
35
36 import fr.paris.lutece.portal.business.editor.RichTextEditor;
37 import fr.paris.lutece.portal.business.editor.RichTextEditorHome;
38 import fr.paris.lutece.portal.service.datastore.DatastoreService;
39 import fr.paris.lutece.portal.service.i18n.I18nService;
40 import fr.paris.lutece.portal.service.util.AppPropertiesService;
41 import fr.paris.lutece.util.ReferenceItem;
42 import fr.paris.lutece.util.ReferenceList;
43
44 import java.util.Collection;
45 import java.util.Locale;
46
47
48
49
50 public final class RichTextEditorService
51 {
52 public static final String MARK_DEFAULT_TEXT_EDITOR = "default_text_editor";
53 private static final String PARAMETER_DEFAULT_EDITOR_BACK_OFFICE = "core.backOffice.defaultEditor";
54 private static final String PARAMETER_DEFAULT_EDITOR_FRONT_OFFICE = "core.frontOffice.defaultEditor";
55 private static final String PROPERTY_DEFAULT_EDITOR_BACK_OFFICE = "lutece.backOffice.defaultEditor";
56 private static final String PROPERTY_DEFAULT_EDITOR_FRONT_OFFICE = "lutece.frontOffice.defaultEditor";
57
58
59
60
61 private RichTextEditorService( )
62 {
63 }
64
65
66
67
68
69
70 public static String getBackOfficeDefaultEditor( )
71 {
72 String strDefaultEditorName = AppPropertiesService.getProperty( PROPERTY_DEFAULT_EDITOR_BACK_OFFICE );
73
74 return DatastoreService.getDataValue( PARAMETER_DEFAULT_EDITOR_BACK_OFFICE, strDefaultEditorName );
75 }
76
77
78
79
80
81
82 public static String getFrontOfficeDefaultEditor( )
83 {
84 String strDefaultEditorName = AppPropertiesService.getProperty( PROPERTY_DEFAULT_EDITOR_FRONT_OFFICE );
85
86 return DatastoreService.getDataValue( PARAMETER_DEFAULT_EDITOR_FRONT_OFFICE, strDefaultEditorName );
87 }
88
89
90
91
92
93
94
95 public static void updateBackOfficeDefaultEditor( String strEditorUrl )
96 {
97 DatastoreService.setDataValue( PARAMETER_DEFAULT_EDITOR_BACK_OFFICE, strEditorUrl );
98 }
99
100
101
102
103
104
105
106 public static void updateFrontOfficeDefaultEditor( String strEditorUrl )
107 {
108 DatastoreService.setDataValue( PARAMETER_DEFAULT_EDITOR_FRONT_OFFICE, strEditorUrl );
109 }
110
111
112
113
114
115
116
117
118 public static ReferenceList getListEditorsForBackOffice( Locale locale )
119 {
120 Collection<RichTextEditor> listRichTextEditor = RichTextEditorHome.findListEditorsForBackOffice( );
121 ReferenceListList.html#ReferenceList">ReferenceList refList = new ReferenceList( );
122
123 for ( RichTextEditor editor : listRichTextEditor )
124 {
125 ReferenceItemItem.html#ReferenceItem">ReferenceItem refItem = new ReferenceItem( );
126 refItem.setCode( editor.getEditorName( ) );
127 refItem.setName( I18nService.getLocalizedString( editor.getDescription( ), locale ) );
128 refList.add( refItem );
129 }
130
131 return refList;
132 }
133
134
135
136
137
138
139
140
141 public static ReferenceList getListEditorsForFrontOffice( Locale locale )
142 {
143 Collection<RichTextEditor> listRichTextEditor = RichTextEditorHome.findListEditorsForFrontOffice( );
144 ReferenceListList.html#ReferenceList">ReferenceList refList = new ReferenceList( );
145
146 for ( RichTextEditor editor : listRichTextEditor )
147 {
148 ReferenceItemItem.html#ReferenceItem">ReferenceItem refItem = new ReferenceItem( );
149 refItem.setCode( editor.getEditorName( ) );
150 refItem.setName( I18nService.getLocalizedString( editor.getDescription( ), locale ) );
151 refList.add( refItem );
152 }
153
154 return refList;
155 }
156 }