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.plugins.extend.modules.comment.web.component;
35
36 import java.util.HashMap;
37 import java.util.List;
38 import java.util.Locale;
39 import java.util.Map;
40 import java.util.Map.Entry;
41
42 import javax.inject.Inject;
43 import javax.inject.Named;
44 import javax.servlet.http.HttpServletRequest;
45 import javax.servlet.http.HttpSession;
46
47 import org.apache.commons.lang3.StringUtils;
48
49 import fr.paris.lutece.plugins.extend.business.extender.ResourceExtenderDTO;
50 import fr.paris.lutece.plugins.extend.business.extender.config.IExtenderConfig;
51 import fr.paris.lutece.plugins.extend.modules.comment.business.AddCommentPosition;
52 import fr.paris.lutece.plugins.extend.modules.comment.business.Comment;
53 import fr.paris.lutece.plugins.extend.modules.comment.business.CommentFilter;
54 import fr.paris.lutece.plugins.extend.modules.comment.business.config.CommentExtenderConfig;
55 import fr.paris.lutece.plugins.extend.modules.comment.service.CommentListenerService;
56 import fr.paris.lutece.plugins.extend.modules.comment.service.CommentPlugin;
57 import fr.paris.lutece.plugins.extend.modules.comment.service.ICommentService;
58 import fr.paris.lutece.plugins.extend.modules.comment.service.extender.CommentResourceExtender;
59 import fr.paris.lutece.plugins.extend.modules.comment.util.constants.CommentConstants;
60 import fr.paris.lutece.plugins.extend.service.ExtendPlugin;
61 import fr.paris.lutece.plugins.extend.service.content.ExtendableContentPostProcessor;
62 import fr.paris.lutece.plugins.extend.service.extender.IResourceExtenderService;
63 import fr.paris.lutece.plugins.extend.service.extender.ResourceExtenderService;
64 import fr.paris.lutece.plugins.extend.service.extender.config.IResourceExtenderConfigService;
65 import fr.paris.lutece.plugins.extend.util.ExtendErrorException;
66 import fr.paris.lutece.plugins.extend.web.component.AbstractResourceExtenderComponent;
67 import fr.paris.lutece.portal.business.user.AdminUser;
68 import fr.paris.lutece.portal.service.admin.AdminUserService;
69 import fr.paris.lutece.portal.service.captcha.CaptchaSecurityService;
70 import fr.paris.lutece.portal.service.content.ContentPostProcessor;
71 import fr.paris.lutece.portal.service.i18n.I18nService;
72 import fr.paris.lutece.portal.service.mailinglist.AdminMailingListService;
73 import fr.paris.lutece.portal.service.plugin.PluginService;
74 import fr.paris.lutece.portal.service.prefs.UserPreferencesService;
75 import fr.paris.lutece.portal.service.resource.IExtendableResource;
76 import fr.paris.lutece.portal.service.security.LuteceUser;
77 import fr.paris.lutece.portal.service.security.SecurityService;
78 import fr.paris.lutece.portal.service.spring.SpringContextService;
79 import fr.paris.lutece.portal.service.template.AppTemplateService;
80 import fr.paris.lutece.portal.service.util.AppPathService;
81 import fr.paris.lutece.portal.service.util.AppPropertiesService;
82 import fr.paris.lutece.portal.service.workflow.WorkflowService;
83 import fr.paris.lutece.portal.web.constants.Parameters;
84 import fr.paris.lutece.portal.web.util.LocalizedDelegatePaginator;
85 import fr.paris.lutece.util.ReferenceList;
86 import fr.paris.lutece.util.html.HtmlTemplate;
87 import fr.paris.lutece.util.html.IPaginator;
88 import fr.paris.lutece.util.html.Paginator;
89 import fr.paris.lutece.util.url.UrlItem;
90
91
92
93
94
95
96 public class CommentResourceExtenderComponent extends AbstractResourceExtenderComponent
97 {
98
99 private static final String TEMPLATE_COMMENT = "skin/plugins/extend/modules/comment/comment.html";
100 private static final String TEMPLATE_COMMENT_CONFIG = "admin/plugins/extend/modules/comment/comment_config.html";
101 private static final String TEMPLATE_MANAGE_COMMENTS = "admin/plugins/extend/modules/comment/comment_info.html";
102
103 private static final String JSP_URL_MANAGE_COMMENTS = "jsp/admin/plugins/extend/ViewExtenderInfo.jsp";
104
105 @Inject
106 private ICommentService _commentService;
107 @Inject
108 @Named( CommentConstants.BEAN_CONFIG_SERVICE )
109 private IResourceExtenderConfigService _configService;
110 @Inject
111 @Named( ResourceExtenderService.BEAN_SERVICE )
112 private IResourceExtenderService _resourceExtenderService;
113
114 private int _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( CommentConstants.PROPERTY_DEFAULT_LIST_COMMENTS_PER_PAGE, 50 );
115
116 private volatile ContentPostProcessor _contentPostProcessor;
117
118
119
120
121 @Override
122 public void buildXmlAddOn( String strIdExtendableResource, String strExtendableResourceType, String strParameters, StringBuffer strXml )
123 {
124
125 }
126
127
128
129
130 @Override
131 public String getPageAddOn( String strIdExtendableResource, String strExtendableResourceType, String strParameters, HttpServletRequest request )
132 {
133 CommentExtenderConfig config = _configService.find( getResourceExtender( ).getKey( ), strIdExtendableResource, strExtendableResourceType );
134
135 int nNbComments = 1;
136 boolean bAuthorizedsubComments = true;
137 boolean bUseBBCodeEditor = false;
138 boolean bDisplaySubComments = true;
139 boolean bTriCommentsByDateCreation = false;
140 int nAddCommentPosition = 0;
141 String strAdminBadge = StringUtils.EMPTY;
142
143 if ( config != null )
144 {
145 nNbComments = config.getNbComments( );
146 bAuthorizedsubComments = config.getAuthorizeSubComments( );
147 nAddCommentPosition = config.getAddCommentPosition( );
148 bUseBBCodeEditor = config.getUseBBCodeEditor( );
149 strAdminBadge = config.getAdminBadge( );
150 bDisplaySubComments = config.isDisplaySubComments( );
151 bTriCommentsByDateCreation = config.isTriCommentsByCreation( );
152 }
153
154 List<Comment> listComments = _commentService.findLastComments( strIdExtendableResource, strExtendableResourceType, nNbComments, true, true,
155 bAuthorizedsubComments, bDisplaySubComments, config.isTriCommentsByCreation( ) );
156
157 int nNbPublishedComments = _commentService.getCommentNb( strIdExtendableResource, strExtendableResourceType, !bDisplaySubComments, true );
158 Map<String, Object> model = new HashMap<String, Object>( );
159 model.put( CommentConstants.MARK_COMMENT_CONFIG,
160 _configService.find( CommentResourceExtender.EXTENDER_TYPE_COMMENT, strIdExtendableResource, strExtendableResourceType ) );
161 model.put( CommentConstants.MARK_LIST_COMMENTS, listComments );
162 model.put( CommentConstants.MARK_ID_EXTENDABLE_RESOURCE, strIdExtendableResource );
163 model.put( CommentConstants.MARK_EXTENDABLE_RESOURCE_TYPE, strExtendableResourceType );
164 model.put( CommentConstants.MARK_ADD_COMMENT_POSITION, nAddCommentPosition );
165 model.put( CommentConstants.MARK_USE_BBCODE, bUseBBCodeEditor );
166 model.put( CommentConstants.MARK_ADMIN_BADGE, strAdminBadge );
167 model.put( CommentConstants.MARK_ALLOW_SUB_COMMENTS, bAuthorizedsubComments );
168 model.put( CommentConstants.MARK_DISPLAY_SUB_COMMENTS, bDisplaySubComments );
169 model.put( CommentConstants.MARK_NB_PUBLISHED_COMMENTS, nNbPublishedComments );
170 model.put( CommentConstants.MARK_TRI_COMMENTS_BY_DATE_CREATION, bTriCommentsByDateCreation );
171
172 if ( nAddCommentPosition != AddCommentPosition.NEW_PAGE )
173 {
174
175 boolean bIsCaptchaEnabled = PluginService.isPluginEnable( CommentConstants.JCAPTCHA_PLUGIN )
176 && Boolean.parseBoolean( AppPropertiesService.getProperty( CommentConstants.PROPERTY_USE_CAPTCHA, Boolean.TRUE.toString( ) ) );
177 model.put( CommentConstants.MARK_IS_ACTIVE_CAPTCHA, bIsCaptchaEnabled );
178
179 if ( bIsCaptchaEnabled )
180 {
181 CaptchaSecurityService captchaService = new CaptchaSecurityService( );
182 model.put( CommentConstants.MARK_CAPTCHA, captchaService.getHtmlCode( ) );
183 }
184
185 if ( config != null && config.isEnabledAuthMode( ) )
186 {
187 LuteceUser user = SecurityService.getInstance( ).getRegisteredUser( request );
188 if ( user != null )
189 {
190 model.put( CommentConstants.MARK_NICKNAME, UserPreferencesService.instance( ).getNickname( user ) );
191 }
192
193 if ( CommentListenerService.canComment( user, strIdExtendableResource, strExtendableResourceType ) )
194 {
195 model.put( CommentConstants.MARK_CAN_DELETE_COMMENTS, config.getDeleteComments( ) );
196 }
197 else
198 {
199 model.put( CommentConstants.MARK_COMMENT_CLOSED, true );
200 }
201 }
202
203 if ( SecurityService.isAuthenticationEnable( ) )
204 {
205 LuteceUser user = SecurityService.getInstance( ).getRegisteredUser( request );
206
207 if ( user != null )
208 {
209 model.put( CommentConstants.MARK_MYLUTECE_USER, user );
210 }
211 }
212
213
214 if ( request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADD_MESSAGE_RESULT + strIdExtendableResource ) != null )
215 {
216 model.put( CommentConstants.MARK_ADD_COMMENT_MESSAGE_RESULT,
217 (String) request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADD_MESSAGE_RESULT + strIdExtendableResource ) );
218 request.getSession( ).removeAttribute( CommentConstants.SESSION_COMMENT_ADD_MESSAGE_RESULT + strIdExtendableResource );
219 }
220
221 request.getSession( ).setAttribute( ExtendPlugin.PLUGIN_NAME + CommentConstants.PARAMETER_FROM_URL,
222 request.getRequestURI( ) + "?" + request.getQueryString( ) );
223 model.put( CommentConstants.PARAMETER_FROM_URL, CommentConstants.FROM_SESSION );
224 }
225
226 LuteceUser user = SecurityService.getInstance( ).getRegisteredUser( request );
227
228 if ( user != null )
229 {
230 model.put( CommentConstants.MARK_REGISTERED_USER_EMAIL, user.getEmail( ) );
231 }
232
233 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_COMMENT, request.getLocale( ), model );
234 String strContent = template.getHtml( );
235
236 ContentPostProcessor postProcessor = getExtendPostProcessor( );
237 if ( postProcessor != null )
238 {
239 strContent = postProcessor.process( request, strContent );
240 }
241
242 return strContent;
243 }
244
245
246
247
248 @Override
249 public String getConfigHtml( ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request )
250 {
251 ReferenceList listIdsMailingList = new ReferenceList( );
252 listIdsMailingList.addItem( -1, I18nService.getLocalizedString( CommentConstants.PROPERTY_COMMENT_CONFIG_LABEL_NO_MAILING_LIST, locale ) );
253 listIdsMailingList.addAll( AdminMailingListService.getMailingLists( AdminUserService.getAdminUser( request ) ) );
254
255 Map<String, Object> model = new HashMap<String, Object>( );
256 model.put( CommentConstants.MARK_COMMENT_CONFIG, _configService.find( resourceExtender.getIdExtender( ) ) );
257 model.put( CommentConstants.MARK_LIST_IDS_MAILING_LIST, listIdsMailingList );
258 model.put( CommentConstants.MARK_ADD_COMMENT_POSITIONS, AddCommentPosition.getAllPositions( ) );
259 model.put( CommentConstants.MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
260 model.put( CommentConstants.MARK_LOCALE, AdminUserService.getLocale( request ) );
261 if ( WorkflowService.getInstance( ).isAvailable( ) )
262 {
263 AdminUser adminUser = AdminUserService.getAdminUser( request );
264 ReferenceList referenceList = WorkflowService.getInstance( ).getWorkflowsEnabled( adminUser, locale );
265 model.put( CommentConstants.MARK_WORKFLOW_REF_LIST, referenceList );
266 }
267
268 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_COMMENT_CONFIG, request.getLocale( ), model );
269
270 return template.getHtml( );
271 }
272
273
274
275
276 @Override
277 public IExtenderConfig getConfig( int nIdExtender )
278 {
279 return _configService.find( nIdExtender );
280 }
281
282
283
284
285 @Override
286 public String getInfoHtml( ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request )
287 {
288 if ( resourceExtender != null )
289 {
290 CommentExtenderConfig config = _configService.find( getResourceExtender( ).getKey( ), resourceExtender.getIdExtendableResource( ),
291 resourceExtender.getExtendableResourceType( ) );
292 if ( config != null )
293 {
294
295
296 String strPostBackUrl = getPostBackUrl( request );
297 request.getSession( ).setAttribute( CommentPlugin.PLUGIN_NAME + CommentConstants.SESSION_COMMENT_ADMIN_POST_BACK_URL, strPostBackUrl );
298
299
300 Integer nItemsPerPage = _nDefaultItemsPerPage;
301 String strCurrentPageIndex = CommentConstants.CONSTANT_FIRST_PAGE_NUMBER;
302 Boolean bIsAscSort = false;
303 String strSortedAttributeName = null;
304 String strFilterState = null;
305 String strFilterMarkAsImportant = null;
306 String strFilterPinned = null;
307 Object object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_ITEMS_PER_PAGE );
308 if ( object != null )
309 {
310 nItemsPerPage = (Integer) object;
311 }
312 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_CURRENT_PAGE_INDEX );
313 if ( object != null )
314 {
315 strCurrentPageIndex = (String) object;
316 }
317 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_IS_ASC_SORT );
318 if ( object != null )
319 {
320 bIsAscSort = (Boolean) object;
321 }
322 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_SORTED_ATTRIBUTE_NAME );
323 if ( object != null )
324 {
325 strSortedAttributeName = (String) object;
326 }
327
328 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_FILTER_STATE );
329 if ( object != null )
330 {
331 strFilterState = (String) object;
332 }
333
334 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_FILTER_PINNED );
335 if ( object != null )
336 {
337 strFilterPinned = (String) object;
338 }
339
340 object = request.getSession( ).getAttribute( CommentConstants.SESSION_COMMENT_ADMIN_FILTER_MARK_AS_IMPORTANT );
341 if ( object != null )
342 {
343 strFilterMarkAsImportant = (String) object;
344 }
345
346 int nItemsCount = _commentService.getCommentNb( resourceExtender.getIdExtendableResource( ), resourceExtender.getExtendableResourceType( ),
347 config.getAuthorizeSubComments( ), false );
348 String strFromUrl = StringUtils.replace( request.getParameter( CommentConstants.PARAMETER_FROM_URL ), CommentConstants.CONSTANT_AND,
349 CommentConstants.CONSTANT_AND_HTML );
350 strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, strCurrentPageIndex );
351 int nOldITemsPerPage = nItemsPerPage;
352 nItemsPerPage = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, nItemsPerPage, _nDefaultItemsPerPage );
353 if ( nItemsPerPage <= 0 )
354 {
355 nItemsPerPage = _nDefaultItemsPerPage;
356 }
357
358 if ( nItemsPerPage != nOldITemsPerPage )
359 {
360 strCurrentPageIndex = CommentConstants.CONSTANT_FIRST_PAGE_NUMBER;
361 }
362 String strNewSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME );
363 if ( strNewSortedAttributeName != null )
364 {
365
366 strSortedAttributeName = strNewSortedAttributeName;
367 bIsAscSort = Boolean.parseBoolean( request.getParameter( Parameters.SORTED_ASC ) );
368 }
369
370 if ( request.getParameter( CommentConstants.PARAMETER_FILTER_STATE ) != null )
371 {
372 strFilterState = request.getParameter( CommentConstants.PARAMETER_FILTER_STATE );
373 }
374
375 if ( request.getParameter( CommentConstants.PARAMETER_FILTER_PINNED ) != null )
376 {
377 strFilterPinned = request.getParameter( CommentConstants.PARAMETER_FILTER_PINNED );
378 }
379
380 if ( request.getParameter( CommentConstants.PARAMETER_FILTER_MARK_AS_IMPORTANT ) != null )
381 {
382 strFilterMarkAsImportant = request.getParameter( CommentConstants.PARAMETER_FILTER_MARK_AS_IMPORTANT );
383 }
384
385 int nItemsOffset = nItemsPerPage * ( Integer.parseInt( strCurrentPageIndex ) - 1 );
386
387 CommentFilterend/modules/comment/business/CommentFilter.html#CommentFilter">CommentFilter commentFilter = new CommentFilter( );
388 if ( StringUtils.isNotBlank( strFilterState ) && StringUtils.isNumeric( strFilterState ) )
389 {
390 commentFilter.setCommentState( Integer.parseInt( strFilterState ) );
391 }
392 if ( StringUtils.isNotBlank( strFilterPinned ) )
393 {
394 commentFilter.setPinned( new Boolean( strFilterPinned ) );
395 }
396 if ( StringUtils.isNotBlank( strFilterMarkAsImportant ) )
397 {
398 commentFilter.setImportant( new Boolean( strFilterMarkAsImportant ) );
399 }
400 commentFilter.setSortedAttributeName( strSortedAttributeName );
401 commentFilter.setAscSort( bIsAscSort );
402
403 List<Comment> listComments = _commentService.findByResource( resourceExtender.getIdExtendableResource( ),
404 resourceExtender.getExtendableResourceType( ), commentFilter, nItemsOffset, nItemsPerPage, config.getAuthorizeSubComments( ) );
405
406
407 UrlItem url = new UrlItem( strPostBackUrl );
408 url.addParameter( CommentConstants.PARAMETER_EXTENDER_TYPE, CommentResourceExtender.EXTENDER_TYPE_COMMENT );
409 url.addParameter( CommentConstants.PARAMETER_ID_EXTENDABLE_RESOURCE, resourceExtender.getIdExtendableResource( ) );
410 url.addParameter( CommentConstants.PARAMETER_EXTENDABLE_RESOURCE_TYPE, resourceExtender.getExtendableResourceType( ) );
411 url.addParameter( CommentConstants.PARAMETER_FROM_URL, strFromUrl );
412
413
414 IPaginator<Comment> paginator = new LocalizedDelegatePaginator<Comment>( listComments, nItemsPerPage, url.getUrl( ), Paginator.PARAMETER_PAGE_INDEX,
415 strCurrentPageIndex, nItemsCount, AdminUserService.getLocale( request ) );
416
417 Map<String, Object> model = new HashMap<String, Object>( );
418 List<Comment> listCommentDisplay = paginator.getPageItems( );
419 AdminUser adminUser = AdminUserService.getAdminUser( request );
420 if ( adminUser != null && WorkflowService.getInstance( ).isAvailable( ) )
421 {
422 for ( Comment comment : listCommentDisplay )
423 {
424
425 comment.setListWorkflowActions( WorkflowService.getInstance( ).getActions( comment.getIdComment( ),
426 _commentService.getResourceType( comment.getExtendableResourceType( ) ), config.getIdWorkflow( ), adminUser ) );
427
428 }
429 }
430 if ( !CommentConstants.CONSTANT_ALL_RESSOURCE_ID.equals( resourceExtender.getIdExtendableResource( ) ) )
431 {
432
433 IExtendableResource resourceExtenderInfo = _resourceExtenderService.getExtendableResource( resourceExtender );
434 model.put( CommentConstants.MARK_RESOURCE_EXTENDER, resourceExtenderInfo );
435 model.put( CommentConstants.MARK_ALL_RESOURCES, false );
436 }
437 else
438 {
439 HashMap<String, IExtendableResource> mapResourceExtender = new HashMap<>( );
440 for ( Comment comment : listCommentDisplay )
441 {
442 if ( !mapResourceExtender.containsKey( comment.getIdExtendableResource( ) ) )
443 {
444
445 mapResourceExtender.put( comment.getIdExtendableResource( ), _resourceExtenderService
446 .getExtendableResource( comment.getIdExtendableResource( ), resourceExtender.getExtendableResourceType( ) ) );
447 }
448
449 }
450 model.put( CommentConstants.MARK_ALL_RESOURCES, true );
451 model.put( CommentConstants.MARK_RESOURCE_EXTENDER_MAP, mapResourceExtender );
452 }
453
454 model.put( CommentConstants.MARK_ID_EXTENDABLE_RESOURCE, resourceExtender.getIdExtendableResource( ) );
455 model.put( CommentConstants.MARK_EXTENDABLE_RESOURCE_TYPE, resourceExtender.getExtendableResourceType( ) );
456
457 model.put( CommentConstants.MARK_LIST_COMMENTS, listCommentDisplay );
458 model.put( CommentConstants.PARAMETER_FROM_URL, strFromUrl );
459 model.put( CommentConstants.MARK_PAGINATOR, paginator );
460 model.put( CommentConstants.MARK_NB_ITEMS_PER_PAGE, Integer.toString( paginator.getItemsPerPage( ) ) );
461 model.put( CommentConstants.MARK_ASC_SORT, bIsAscSort );
462 model.put( Parameters.SORTED_ATTRIBUTE_NAME, strSortedAttributeName );
463 model.put( CommentConstants.PARAMETER_ID_COMMENT, request.getParameter( CommentConstants.PARAMETER_ID_COMMENT ) );
464 model.put( CommentConstants.MARK_USE_BBCODE, config.getUseBBCodeEditor( ) );
465 model.put( CommentConstants.MARK_ADMIN_BADGE, config.getAdminBadge( ) );
466 model.put( CommentConstants.MARK_ALLOW_SUB_COMMENTS, config.getAuthorizeSubComments( ) );
467 model.put( CommentConstants.MARK_FILTER_STATE, strFilterState );
468 model.put( CommentConstants.MARK_FILTER_MARK_AS_IMPORTANT, strFilterMarkAsImportant );
469 model.put( CommentConstants.MARK_FILTER_PINNED, strFilterPinned );
470 model.put( CommentConstants.MARK_LIST_COMMENT_STATES, _commentService.getRefListCommentStates( locale ) );
471 model.put( CommentConstants.MARK_LIST_MARK_AS_IMPORTANT_FILTER, _commentService.getRefListFilterAsImportant( locale ) );
472 model.put( CommentConstants.MARK_LIST_PINNED_FILTER, _commentService.getRefListFilterAsPinned( locale ) );
473
474 model.put( CommentConstants.PARAMETER_POST_BACK_URL, strPostBackUrl );
475
476 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_COMMENTS, request.getLocale( ), model );
477
478
479 HttpSession session = request.getSession( );
480 session.setAttribute( CommentConstants.SESSION_COMMENT_ADMIN_ITEMS_PER_PAGE, nItemsPerPage );
481 session.setAttribute( CommentConstants.SESSION_COMMENT_ADMIN_CURRENT_PAGE_INDEX, strCurrentPageIndex );
482 session.setAttribute( CommentConstants.SESSION_COMMENT_ADMIN_IS_ASC_SORT, bIsAscSort );
483 session.setAttribute( CommentConstants.SESSION_COMMENT_ADMIN_SORTED_ATTRIBUTE_NAME, strSortedAttributeName );
484 session.setAttribute( CommentConstants.SESSION_COMMENT_ADMIN_FILTER_STATE, strFilterState );
485
486 String strContent = template.getHtml( );
487
488 ContentPostProcessor postProcessor = getExtendPostProcessor( );
489 if ( postProcessor != null )
490 {
491 strContent = postProcessor.process( request, strContent );
492 }
493
494 return strContent;
495 }
496 }
497
498 return StringUtils.EMPTY;
499 }
500
501
502
503
504 @Override
505 public void doSaveConfig( HttpServletRequest request, IExtenderConfig config ) throws ExtendErrorException
506 {
507 _configService.update( config );
508 }
509
510
511
512
513 @Override
514 public String getPostBackUrl( HttpServletRequest request )
515 {
516 UrlItem urlItem = new UrlItem( request.getRequestURI( ) );
517 Map<String, String [ ]> mapParameters = new HashMap<String, String [ ]>( request.getParameterMap( ) );
518
519 mapParameters.remove( CommentConstants.MARK_ID_EXTENDABLE_RESOURCE );
520 mapParameters.remove( CommentConstants.MARK_EXTENDABLE_RESOURCE_TYPE );
521 mapParameters.remove( CommentConstants.PARAMETER_EXTENDER_TYPE );
522 mapParameters.remove( CommentConstants.PARAMETER_FROM_URL );
523 mapParameters.remove( CommentConstants.PARAMETER_ID_COMMENT );
524 mapParameters.remove( Paginator.PARAMETER_PAGE_INDEX );
525 mapParameters.remove( Paginator.PARAMETER_ITEMS_PER_PAGE );
526 mapParameters.remove( Parameters.SORTED_ATTRIBUTE_NAME );
527 mapParameters.remove( Parameters.SORTED_ASC );
528 for ( Entry<String, String [ ]> entry : mapParameters.entrySet( ) )
529 {
530 urlItem.addParameter( entry.getKey( ), entry.getValue( ) [0] );
531 }
532 return urlItem.getUrl( );
533 }
534
535
536
537
538
539
540 private ContentPostProcessor getExtendPostProcessor( )
541 {
542 if ( _contentPostProcessor == null )
543 {
544 synchronized( this )
545 {
546 if ( _contentPostProcessor == null )
547 {
548 _contentPostProcessor = SpringContextService.getBean( ExtendableContentPostProcessor.BEAN_NAME );
549 }
550 }
551 }
552 return _contentPostProcessor;
553 }
554
555 }