fr.paris.lutece.plugins.newsletter.util
Class NewsletterUtils

java.lang.Object
  extended by fr.paris.lutece.plugins.newsletter.util.NewsletterUtils

public final class NewsletterUtils
extends java.lang.Object

This classe provides utility methods for newsletters.


Method Summary
static void addHeaderResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String strFileName, java.lang.String strFileExtension)
          Addition of information as header of the http response
static void addParameters(fr.paris.lutece.util.url.UrlItem urlItem, java.lang.String strParameterName, java.lang.String[] values)
          Adds all parameter values to the urlItem
static java.lang.String convertForJavascript(java.lang.String strIn)
          Cleans a string in order to make it usable in a javascript script
static java.lang.String encodeForURL(java.lang.String strEntry)
          Encode a string for passage in parameter in URL
static java.lang.String fillTemplateWithDocumentInfos(java.lang.String strTemplatePath, fr.paris.lutece.plugins.document.business.Document document, int nPortletId, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale, java.lang.String strBaseUrl)
          Fills a given document template with the document data
static java.lang.String getHtmlTemplatePath(int nTemplateId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Retrieve the html template for the given template id
static NewsletterUtils getInstance()
          Fetches the singleton instance
static java.lang.String rewriteUrls(java.lang.String strContent, java.lang.String strBaseUrl)
          Rewrite relatives url to absolutes urls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NewsletterUtils getInstance()
Fetches the singleton instance

Returns:
The singleton instance

getHtmlTemplatePath

public static java.lang.String getHtmlTemplatePath(int nTemplateId,
                                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
Retrieve the html template for the given template id

Parameters:
nTemplateId - the id of the template to retrieve
plugin - the plugin
Returns:
the html template to use of null if no NewsletterTemplate found for this Id

convertForJavascript

public static java.lang.String convertForJavascript(java.lang.String strIn)
Cleans a string in order to make it usable in a javascript script

Parameters:
strIn - the string to clean
Returns:
the javascript escaped String

fillTemplateWithDocumentInfos

public static java.lang.String fillTemplateWithDocumentInfos(java.lang.String strTemplatePath,
                                                             fr.paris.lutece.plugins.document.business.Document document,
                                                             int nPortletId,
                                                             fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                             java.util.Locale locale,
                                                             java.lang.String strBaseUrl)
Fills a given document template with the document data

Parameters:
strBaseUrl - The base url of the portal
strTemplatePath - The path of the template file
document - the object gathering the document data
nPortletId - the portlet id
plugin - the plugin needed to retrieve properties
locale - the locale used to build the template
Returns:
the html code corresponding to the document data

rewriteUrls

public static java.lang.String rewriteUrls(java.lang.String strContent,
                                           java.lang.String strBaseUrl)
Rewrite relatives url to absolutes urls

Parameters:
strContent - The content to analyze
strBaseUrl - The base url
Returns:
The converted content

encodeForURL

public static java.lang.String encodeForURL(java.lang.String strEntry)
Encode a string for passage in parameter in URL

Parameters:
strEntry - the string entry
Returns:
the string encoding

addHeaderResponse

public static void addHeaderResponse(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.String strFileName,
                                     java.lang.String strFileExtension)
Addition of information as header of the http response

Parameters:
request - The Http Request
response - The Http Response
strFileName - THe filename of the file
strFileExtension - The file extension

addParameters

public static void addParameters(fr.paris.lutece.util.url.UrlItem urlItem,
                                 java.lang.String strParameterName,
                                 java.lang.String[] values)
Adds all parameter values to the urlItem

Parameters:
urlItem - the urlItem
strParameterName - the name of the parameter which has multiple values
values - parameter values


Copyright © 2011 Mairie de Paris. All Rights Reserved.