View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.web.admin;
35  
36  import fr.paris.lutece.portal.business.right.FeatureGroup;
37  import fr.paris.lutece.portal.business.right.FeatureGroupHome;
38  import fr.paris.lutece.portal.business.right.Right;
39  import fr.paris.lutece.portal.business.user.AdminUser;
40  import fr.paris.lutece.portal.business.user.AdminUserHome;
41  import fr.paris.lutece.portal.business.user.authentication.LuteceDefaultAdminUser;
42  import fr.paris.lutece.portal.service.admin.AdminAuthenticationService;
43  import fr.paris.lutece.portal.service.admin.AdminUserService;
44  import fr.paris.lutece.portal.service.dashboard.DashboardService;
45  import fr.paris.lutece.portal.service.dashboard.IDashboardComponent;
46  import fr.paris.lutece.portal.service.datastore.DatastoreService;
47  import fr.paris.lutece.portal.service.i18n.I18nService;
48  import fr.paris.lutece.portal.service.init.AppInfo;
49  import fr.paris.lutece.portal.service.message.AdminMessage;
50  import fr.paris.lutece.portal.service.message.AdminMessageService;
51  import fr.paris.lutece.portal.service.plugin.Plugin;
52  import fr.paris.lutece.portal.service.plugin.PluginService;
53  import fr.paris.lutece.portal.service.portal.PortalService;
54  import fr.paris.lutece.portal.service.spring.SpringContextService;
55  import fr.paris.lutece.portal.service.template.AppTemplateService;
56  import fr.paris.lutece.portal.service.util.AppPathService;
57  import fr.paris.lutece.portal.service.util.AppPropertiesService;
58  import fr.paris.lutece.portal.web.constants.Markers;
59  import fr.paris.lutece.portal.web.constants.Messages;
60  import fr.paris.lutece.portal.web.constants.Parameters;
61  import fr.paris.lutece.portal.web.l10n.LocaleService;
62  import fr.paris.lutece.util.html.HtmlTemplate;
63  import fr.paris.lutece.util.password.IPassword;
64  import fr.paris.lutece.util.password.IPasswordFactory;
65  
66  import org.apache.commons.lang.StringUtils;
67  
68  import java.io.Serializable;
69  
70  import java.util.ArrayList;
71  import java.util.Collections;
72  import java.util.HashMap;
73  import java.util.List;
74  import java.util.Locale;
75  import java.util.Map;
76  
77  import javax.servlet.http.HttpServletRequest;
78  
79  
80  /**
81   * This class provides the user interface to manage admin features ( manage, create, modify, remove)
82   */
83  public class AdminMenuJspBean implements Serializable
84  {
85      /////////////////////////////////////////////////////////////////////////////////
86      // Constants
87      public static final String PROPERTY_LOGOUT_URL = "lutece.admin.logout.url";
88      public static final String PROPERTY_MENU_DEFAULT_POS = "top";
89      public static final String PROPERTY_MENU_DATASTORE_POS = "portal.site.site_property.menu.position";
90      private static final long serialVersionUID = -8939026727319948581L;
91  
92      // Markers
93      private static final String MARK_FEATURE_GROUP_LIST = "feature_group_list";
94      private static final String MARK_LANGUAGES_LIST = "languages_list";
95      private static final String MARK_CURRENT_LANGUAGE = "current_language";
96      private static final String MARK_USER = "user";
97      private static final String MARK_ADMIN_URL = "admin_url";
98      private static final String MARK_ADMIN_LOGOUT_URL = "admin_logout_url";
99      private static final String MARK_ADMIN_SUMMARY_DOCUMENTATION_URL = "admin_summary_documentation_url";
100     private static final String MARK_SITE_NAME = "site_name";
101     private static final String MARK_MENU_POS = "menu_pos";
102     private static final String MARK_MODIFY_PASSWORD_URL = "url_modify_password";
103     private static final String MARK_DASHBOARD_ZONE = "dashboard_zone_";
104     private static final String MARK_URL_CSS = "css_url";
105     private static final String MARK_JAVASCRIPT_FILE = "javascript_file";
106     private static final String MARK_JAVASCRIPT_FILES = "javascript_files";
107     private static final String MARK_PLUGIN_NAME = "plugin_name";
108     private static final String MARK_ADMIN_AVATAR = "adminAvatar";
109 
110     // Templates
111     private static final String TEMPLATE_ADMIN_HOME = "admin/user/admin_home.html";
112     private static final String TEMPLATE_ADMIN_MENU_HEADER = "admin/user/admin_header.html";
113     private static final String TEMPLATE_ADMIN_MENU_FOOTER = "admin/user/admin_footer.html";
114     private static final String TEMPLATE_MODIFY_PASSWORD_DEFAULT_MODULE = "admin/user/modify_password_default_module.html";
115     private static final String TEMPLATE_STYLESHEET_LINK = "admin/stylesheet_link.html";
116     private static final String TEMPLATE_JAVASCRIPT_FILE = "admin/javascript_file.html";
117 
118     // Parameter
119     private static final String PARAMETER_LANGUAGE = "language";
120 
121     // Properties
122     private static final String PROPERTY_DEFAULT_FEATURE_ICON = "lutece.admin.feature.default.icon";
123     private static final String PROPERTY_DOCUMENTATION_SUMMARY_URL = "lutece.documentation.summary.url";
124     private static final String PROPERTY_DASHBOARD_ZONES = "lutece.dashboard.zones.count";
125     private static final int PROPERTY_DASHBOARD_ZONES_DEFAULT = 4;
126     private static final String REFERER = "referer";
127 
128     // Jsp
129     private static final String PROPERTY_JSP_URL_ADMIN_LOGOUT = "lutece.admin.logout.url";
130     private static final String MESSAGE_CONTROL_PASSWORD_NO_CORRESPONDING = "portal.users.message.password.confirm.error";
131     private static final String PASSWORD_ERROR = "portal.users.message.password.wrong.current";
132     private static final String PASSWORD_CURRENT_ERROR = "portal.users.message.password.new.equals.current";
133     private static final String MESSAGE_PASSWORD_REDIRECT = "portal.users.message.password.ok.redirect";
134     
135     private static String _strStylesheets;
136     private static String _strJavascripts;
137     private boolean _bAdminAvatar = PluginService.isPluginEnable( "adminavatar" );
138 
139     /**
140      * Returns the Administration header menu
141      *
142      * @param request The HttpServletRequest
143      * @return The html code of the header
144      */
145     public String getAdminMenuHeader( HttpServletRequest request )
146     {
147         Map<String, Object> model = new HashMap<String, Object>(  );
148         String strVersion = AppInfo.getVersion(  );
149         String strSiteName = PortalService.getSiteName(  );
150         AdminUser user = AdminUserService.getAdminUser( request );
151         Locale locale = user.getLocale(  );
152         List<FeatureGroup> aFeaturesGroupList = getFeatureGroupsList( user );
153 
154         // Displays the menus accroding to the rights of the users
155         model.put( Markers.VERSION, strVersion );
156         model.put( MARK_SITE_NAME, strSiteName );
157         model.put( MARK_MENU_POS,
158             DatastoreService.getInstanceDataValue( PROPERTY_MENU_DATASTORE_POS, PROPERTY_MENU_DEFAULT_POS ) );
159         model.put( MARK_FEATURE_GROUP_LIST, aFeaturesGroupList );
160         model.put( MARK_ADMIN_URL, AppPathService.getBaseUrl( request ) + AppPathService.getAdminMenuUrl(  ) );
161         model.put( MARK_USER, user );
162         model.put( MARK_LANGUAGES_LIST, I18nService.getAdminLocales( locale ) );
163         model.put( MARK_CURRENT_LANGUAGE, locale.getLanguage(  ) );
164 
165         String strLogoutUrl = AppPropertiesService.getProperty( PROPERTY_LOGOUT_URL );
166         model.put( MARK_ADMIN_LOGOUT_URL, ( strLogoutUrl == null ) ? "" : strLogoutUrl );
167 
168         String strDocumentationUrl = AppPropertiesService.getProperty( PROPERTY_DOCUMENTATION_SUMMARY_URL );
169         model.put( MARK_ADMIN_SUMMARY_DOCUMENTATION_URL, ( strDocumentationUrl == null ) ? null : strDocumentationUrl );
170 
171         int nZoneMax = AppPropertiesService.getPropertyInt( PROPERTY_DASHBOARD_ZONES, PROPERTY_DASHBOARD_ZONES_DEFAULT );
172         setDashboardData( model, user, request, nZoneMax );
173         
174         model.put( MARK_ADMIN_AVATAR , _bAdminAvatar );
175 
176         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_ADMIN_MENU_HEADER, user.getLocale(  ), model );
177 
178         return template.getHtml(  );
179     }
180 
181     /**
182      * Returns the Administration footer menu
183      *
184      * @param request The HttpServletRequest
185      * @return The html code of the header
186      */
187     public String getAdminMenuFooter( HttpServletRequest request )
188     {
189         Map<String, Object> model = new HashMap<String, Object>(  );
190         String strFooterVersion = AppInfo.getVersion(  );
191         String strFooterSiteName = PortalService.getSiteName(  );
192         AdminUser user = AdminUserService.getAdminUser( request );
193         Locale locale = ( user != null ) ? user.getLocale(  ) : LocaleService.getDefault(  );
194         model.put( Markers.VERSION, strFooterVersion );
195         model.put( MARK_SITE_NAME, strFooterSiteName );
196         model.put( MARK_JAVASCRIPT_FILES, getAdminJavascripts(  ) );
197 
198         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_ADMIN_MENU_FOOTER, locale, model );
199 
200         return template.getHtml(  );
201     }
202 
203     /**
204      * Returns the html code of the menu of the users
205      * @param request The Http request
206      * @return The html code of the users menu
207      */
208     public String getAdminMenuUser( HttpServletRequest request )
209     {
210         AdminUser user = AdminUserService.getAdminUser( request );
211 
212         Locale locale = user.getLocale(  );
213 
214         // Displays the menus according to the users rights
215         List<FeatureGroup> listFeatureGroups = getFeatureGroupsList( user );
216 
217         Map<String, Object> model = new HashMap<String, Object>(  );
218 
219         model.put( MARK_FEATURE_GROUP_LIST, listFeatureGroups );
220         model.put( MARK_USER, user );
221         model.put( MARK_LANGUAGES_LIST, I18nService.getAdminLocales( locale ) );
222         model.put( MARK_CURRENT_LANGUAGE, locale.getLanguage(  ) );
223         model.put( MARK_MODIFY_PASSWORD_URL, AdminAuthenticationService.getInstance(  ).getChangePasswordPageUrl(  ) );
224 
225         setDashboardData( model, user, request );
226 
227         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_ADMIN_HOME, locale, model );
228 
229         return template.getHtml(  );
230     }
231 
232     /**
233      * Add dashboard data to the template's model
234      * @param model The template's model
235      * @param user The Admin User
236      * @param request HttpServletRequest
237      */
238     private void setDashboardData( Map<String, Object> model, AdminUser user, HttpServletRequest request )
239     {
240         List<IDashboardComponent> listDashboards = DashboardService.getInstance(  ).getDashboards( user, request );
241         int nZoneMax = AppPropertiesService.getPropertyInt( PROPERTY_DASHBOARD_ZONES, PROPERTY_DASHBOARD_ZONES_DEFAULT );
242 
243         if ( ( listDashboards != null ) && ( listDashboards.size(  ) > 0 ) )
244         {
245             int nColumnCount = DashboardService.getInstance(  ).getColumnCount(  );
246 
247             // Personnalized dashboards for the nColumnCount first zones
248             for ( int i = 1; i <= nColumnCount; i++ )
249             {
250                 model.put( MARK_DASHBOARD_ZONE + i,
251                     DashboardService.getInstance(  ).getDashboardData( listDashboards, user, i, request ) );
252             }
253 
254             // Default dashboards for the nColumnCount to nZoneMax zones
255             for ( int i = nColumnCount + 1; i < nZoneMax; i++ )
256             {
257                 model.put( MARK_DASHBOARD_ZONE + i,
258                     DashboardService.getInstance(  ).getDashboardData( user, i, request ) );
259             }
260         }
261         else
262         {
263             for ( int i = 1; i < nZoneMax; i++ )
264             {
265                 model.put( MARK_DASHBOARD_ZONE + i,
266                     DashboardService.getInstance(  ).getDashboardData( user, i, request ) );
267             }
268         }
269     }
270 
271     /**
272      * Add a specific dashboard data to the template's model
273      * @param model The template's model
274      * @param user The Admin User
275      * @param request HttpServletRequest
276      * @param nDashboardZone the dashboard zone
277      */
278     private void setDashboardData( Map<String, Object> model, AdminUser user, HttpServletRequest request,
279         int nDashboardZone )
280     {
281         model.put( MARK_DASHBOARD_ZONE + nDashboardZone,
282             DashboardService.getInstance(  ).getDashboardData( user, nDashboardZone, request ) );
283     }
284 
285     /**
286      * Returns an array that contains all feature groups corresponding to the user
287      *
288      * @param user The Admin user
289      * @return An array of FeatureGroup objects
290      */
291     private List<FeatureGroup> getFeatureGroupsList( AdminUser user )
292     {
293         // structure that will be returned
294         ArrayList<FeatureGroup> aOutFeatureGroupList = new ArrayList<FeatureGroup>(  );
295 
296         // get the list of user's features
297         Map<String, Right> featuresMap = user.getRights(  );
298         List<Right> features = new ArrayList<Right>( featuresMap.values(  ) );
299 
300         List<Right> rightsToDelete = new ArrayList<Right>(  );
301 
302         //delete features which have a null URL : these features does not have to be displayed in the menu
303         for ( Right right : features )
304         {
305             if ( right.getUrl(  ) == null )
306             {
307                 rightsToDelete.add( right );
308             }
309         }
310 
311         features.removeAll( rightsToDelete );
312 
313         Collections.sort( features );
314 
315         // for each group, load the features
316         for ( FeatureGroup featureGroup : FeatureGroupHome.getFeatureGroupsList(  ) )
317         {
318             ArrayList<Right> aLeftFeatures = new ArrayList<Right>(  );
319 
320             for ( Right right : features )
321             {
322                 right.setLocale( user.getLocale(  ) );
323                 right.setIconUrl( getFeatureIcon( right ) );
324 
325                 String strFeatureGroup = right.getFeatureGroup(  );
326 
327                 if ( featureGroup.getId(  ).equalsIgnoreCase( strFeatureGroup ) )
328                 {
329                     featureGroup.addFeature( right );
330                 }
331                 else
332                 {
333                     aLeftFeatures.add( right );
334                 }
335             }
336 
337             if ( !featureGroup.isEmpty(  ) )
338             {
339                 featureGroup.setLocale( user.getLocale(  ) );
340                 aOutFeatureGroupList.add( featureGroup );
341             }
342 
343             features = aLeftFeatures;
344         }
345 
346         // add the features with no group to the last group
347         if ( aOutFeatureGroupList.size(  ) > 0 )
348         {
349             FeatureGroup lastFeatureGroup = aOutFeatureGroupList.get( aOutFeatureGroupList.size(  ) - 1 );
350 
351             for ( Right right : features )
352             {
353                 lastFeatureGroup.addFeature( right );
354 
355                 // FIXME ????         itFeatures.remove(  );
356             }
357         }
358 
359         return aOutFeatureGroupList;
360     }
361 
362     /**
363      * Change the current language of the user
364      *
365      * @param request The HTTP request
366      * @return The forward Url
367      */
368     public String doChangeLanguage( HttpServletRequest request )
369     {
370         String strLanguage = request.getParameter( PARAMETER_LANGUAGE );
371         AdminUser user = AdminUserService.getAdminUser( request );
372         Locale locale = new Locale( strLanguage );
373         user.setLocale( locale );
374         AppPathService.getBaseUrl( request );
375 
376         return AppPathService.getBaseUrl( request ) + AppPathService.getAdminMenuUrl(  );
377     }
378 
379     /**
380      * Gets the feature icon
381      * @param right The right
382      * @return The icon
383      */
384     private String getFeatureIcon( Right right )
385     {
386         String strIconUrl = AppPropertiesService.getProperty( PROPERTY_DEFAULT_FEATURE_ICON );
387 
388         if ( ( right.getIconUrl(  ) != null ) && ( !right.getIconUrl(  ).equals( "" ) ) )
389         {
390             strIconUrl = right.getIconUrl(  );
391         }
392         else
393         {
394             String strPluginName = right.getPluginName(  );
395             Plugin plugin = PluginService.getPlugin( strPluginName );
396 
397             if ( plugin != null )
398             {
399                 strIconUrl = plugin.getIconUrl(  );
400             }
401         }
402 
403         return strIconUrl;
404     }
405 
406     /**
407      * Display the modification form for user password.
408      * This is used only by the default module.
409      * For other modules, custom implementation should be provided.
410      * @param request the http request
411      * @return the form allowing the modification of the user's password
412      */
413     public String getModifyDefaultAdminUserPassword( HttpServletRequest request )
414     {
415         AdminUser user = AdminUserService.getAdminUser( request );
416         Locale locale = user.getLocale(  );
417         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_PASSWORD_DEFAULT_MODULE, locale );
418 
419         return template.getHtml(  );
420     }
421 
422     /**
423      * Perform the user password modification.
424      * This is used only by the default module.
425      * For other modules, custom implementation should be provided.
426      * @param request the http request
427      * @return the form allowing the modification of the user's password
428      */
429     public String doModifyDefaultAdminUserPassword( HttpServletRequest request )
430     {
431         AdminUser user = AdminUserService.getAdminUser( request );
432 
433         String strCurrentPassword = request.getParameter( Parameters.PASSWORD_CURRENT );
434         String strNewPassword = request.getParameter( Parameters.NEW_PASSWORD );
435         String strConfirmNewPassword = request.getParameter( Parameters.CONFIRM_NEW_PASSWORD );
436 
437         LuteceDefaultAdminUser userStored = AdminUserHome.findLuteceDefaultAdminUserByPrimaryKey( user.getUserId(  ) );
438 
439         IPassword password = userStored.getPassword(  );
440 
441         // Mandatory Fields
442         if ( StringUtils.isEmpty( strCurrentPassword ) || StringUtils.isEmpty( strNewPassword ) || StringUtils.isEmpty( strConfirmNewPassword ) )
443         {
444             return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP );
445         }
446 
447         // Test the difference between the two fields of new password
448         if ( !strNewPassword.equals( strConfirmNewPassword ) )
449         {
450             return AdminMessageService.getMessageUrl( request, MESSAGE_CONTROL_PASSWORD_NO_CORRESPONDING,
451                 AdminMessage.TYPE_STOP );
452         }
453 
454         String strUrl = AdminUserService.checkPassword( request, strNewPassword, user.getUserId(  ) );
455 
456         if ( StringUtils.isNotEmpty( strUrl ) )
457         {
458             return strUrl;
459         }
460 
461         // Test of the value of the current password
462         if ( !password.check( strCurrentPassword ) )
463         {
464             return AdminMessageService.getMessageUrl( request, PASSWORD_ERROR, AdminMessage.TYPE_STOP );
465         }
466 
467         // Test of control of difference between the new password and the current one
468         if ( strCurrentPassword.equals( strNewPassword ) )
469         {
470             return AdminMessageService.getMessageUrl( request, PASSWORD_CURRENT_ERROR, AdminMessage.TYPE_STOP );
471         }
472 
473         // Successful tests
474         IPasswordFactory passwordFactory = SpringContextService.getBean( IPasswordFactory.BEAN_NAME );
475         userStored.setPassword( passwordFactory.getPasswordFromCleartext( strNewPassword ) );
476         userStored.setPasswordReset( Boolean.FALSE );
477         userStored.setPasswordMaxValidDate( AdminUserService.getPasswordMaxValidDate(  ) );
478         AdminUserHome.update( userStored );
479         AdminUserHome.insertNewPasswordInHistory( userStored.getPassword(  ), userStored.getUserId(  ) );
480 
481         return AdminMessageService.getMessageUrl( request, MESSAGE_PASSWORD_REDIRECT,
482             AppPropertiesService.getProperty( PROPERTY_JSP_URL_ADMIN_LOGOUT ), AdminMessage.TYPE_INFO );
483     }
484 
485     /**
486      * Change the mode accessibility
487      * @param request {@link HttpServletRequest}
488      * @return The forward Url
489      */
490     public String doModifyAccessibilityMode( HttpServletRequest request )
491     {
492         AdminUser user = AdminUserService.getAdminUser( request );
493 
494         if ( user != null )
495         {
496             boolean bIsAccessible = !user.getAccessibilityMode(  );
497             user.setAccessibilityMode( bIsAccessible );
498             AdminUserHome.update( user );
499         }
500 
501         String strReferer = request.getHeader( REFERER );
502 
503         if ( StringUtils.isNotBlank( strReferer ) )
504         {
505             return strReferer;
506         }
507 
508         return AppPathService.getBaseUrl( request ) + AppPathService.getAdminMenuUrl(  );
509     }
510 
511     /**
512      * Return the stylesheets block to include in the footer
513      * @return the stylesheets files block to include in the footer
514      * @since 5.1
515      */
516     public String getAdminStyleSheets(  )
517     {
518         if ( _strStylesheets == null )
519         {
520             StringBuilder sbCssLinks = new StringBuilder(  );
521             List<Plugin> listPlugins = new ArrayList<Plugin>(  );
522             listPlugins.add( PluginService.getCore(  ) );
523             listPlugins.addAll( PluginService.getPluginList(  ) );
524 
525             for ( Plugin plugin : listPlugins )
526             {
527                 if ( plugin.getAdminCssStyleSheets(  ) != null )
528                 {
529                     for ( String strStyleSheet : plugin.getAdminCssStyleSheets(  ) )
530                     {
531                         Map<String, Object> model = new HashMap<String, Object>(  );
532                         model.put( MARK_URL_CSS, strStyleSheet );
533                         model.put( MARK_PLUGIN_NAME, plugin.getName(  ) );
534                         sbCssLinks.append( AppTemplateService.getTemplate( TEMPLATE_STYLESHEET_LINK,
535                                 LocaleService.getDefault(  ), model ).getHtml(  ) );
536                     }
537                 }
538             }
539 
540             _strStylesheets = sbCssLinks.toString(  );
541         }
542 
543         return _strStylesheets;
544     }
545 
546     /**
547      * Return the javascript files block to include in the footer
548      * @return the javascript files block to include in the footer
549      * @since 5.1
550      */
551     private String getAdminJavascripts(  )
552     {
553         if ( _strJavascripts == null )
554         {
555             StringBuilder sbJavascripts = new StringBuilder(  );
556             List<Plugin> listPlugins = new ArrayList<Plugin>(  );
557             listPlugins.add( PluginService.getCore(  ) );
558             listPlugins.addAll( PluginService.getPluginList(  ) );
559 
560             for ( Plugin plugin : listPlugins )
561             {
562                 if ( plugin.getAdminJavascriptFiles(  ) != null )
563                 {
564                     for ( String strJavascript : plugin.getAdminJavascriptFiles(  ) )
565                     {
566                         Map<String, Object> model = new HashMap<String, Object>(  );
567                         model.put( MARK_JAVASCRIPT_FILE, strJavascript );
568                         model.put( MARK_PLUGIN_NAME, plugin.getName(  ) );
569                         sbJavascripts.append( AppTemplateService.getTemplate( TEMPLATE_JAVASCRIPT_FILE,
570                                 LocaleService.getDefault(  ), model ).getHtml(  ) );
571                     }
572                 }
573             }
574 
575             _strJavascripts = sbJavascripts.toString(  );
576         }
577 
578         return _strJavascripts;
579     }
580 }