|
Jive API (3.0.13) Core Javadocs | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jivesoftware.community.util.SkinUtils
public class SkinUtils
A collection of convenience methods.
| Nested Class Summary | |
|---|---|
static class |
SkinUtils.FileType
|
| Field Summary | |
|---|---|
static String |
DEFAULT_COMPRESSED_TYPES
|
static String |
DEFAULT_DOC_TYPES
|
static String |
DEFAULT_PRESENTATION_TYPES
|
static String |
DEFAULT_SPREADSHEET_TYPES
|
static String |
SKIN_ATTACHMENTFILENAMEMAPPINGS
|
static String |
SKIN_DISPLAYFULLNAME
|
static boolean |
SKIN_DISPLAYFULLNAME_DEFAULT
|
| Method Summary | |
|---|---|
static void |
addCommonFileExtensionName(String extension,
String type)
Add a mapping for a file extension to a particular type of file. |
static void |
addIconGenerator(int objectType,
IconGenerator generator)
Add a new or override an existing icon generator for the given object type. |
static String |
dateToText(HttpServletRequest request,
User user,
Date date)
Deprecated. Replaced to com.jivesoftware.util.DateUtils#displayFriendly(long) |
static boolean |
emailResetPasswordInstructions(String username,
HttpServletRequest request)
This method will send the user specified an email with instructions on how to reset their password. |
static Iterator<ForumMessage> |
filterPendingMessages(Iterator<ForumMessage> messages)
Assumes index of iterator is at front of iterator (ie, iterator hasn't been used). |
static String |
formatDate(HttpServletRequest request,
User user,
Date date)
Formats a date for a user, according to their locale and time zone preferences. |
static String |
getCommonFileExtensionName(String filename)
Get the file type of a given file name. |
static String |
getDecoratedDocumentElementName()
|
static String |
getDisplayName(User user)
A simple method to check whether to display a user's full name or their username. |
static String |
getDocumentAdditionClassname()
|
static String |
getDocumentDeletionClassname()
|
static String |
getFavoritedObjectCss(JiveObject favoritedObject,
int size)
Given a bookmark, produce the appropriate CSS class. |
static String |
getIcon(String name,
boolean returnAsCssClass,
int type)
Returns an icon string in the standard Jive format. |
static String |
getImageClassname()
|
static String |
getImageDeletionClassname()
|
static String |
getImageThumbNailClassname()
|
static String |
getJiveObjectCss(JiveObject object,
int size)
Returns a string of css class(es) for the given object and type. |
static String |
getJiveObjectIcon(JiveObject object,
boolean returnAsCssClass,
int type)
Returns an icon path or a css class name for the icon to associate with the given jive object. |
static String |
getJiveObjectIconForType(int objectType,
boolean returnAsCssClass,
int type)
Returns an icon path or a css class name for the icon to associate with the given jive object type constant. |
static String |
getJiveObjectTypeCss(com.jivesoftware.community.objecttype.JiveObjectType jiveObjectType,
int size)
|
static String |
getJiveObjectTypeCssByTypeID(int objectType,
int size)
|
static Date |
getLastLoggedIn(User user)
Returns the time the given user last logged in. |
static long |
getLastVisited(HttpServletRequest request,
HttpServletResponse response)
Returns the Date the user last visited. |
static Locale |
getLocale()
Returns the locale from the struts context if one exists, otherwise we return JiveGlobals.getLocale(). |
static List<Community> |
getParentCommunities(Community community)
Returns a list of parent communities for the given forum in top-down order. |
static String |
getSkinProperty(Community community,
String name)
Searches for the property name in the given community. |
static String |
getText(String locale,
String key)
This method is primarily for accessing the internationalized text bundles when no action context is available (i.e. inside a standalone freemarker context such as the email templating system). |
static String |
getTheme()
Returns the current skin theme or the string "default" to denote the default theme. |
static String |
getUnDecoratedDocumentElementName()
|
static String |
getXMPPPresenceClassname(org.xmpp.packet.Presence presence)
Return the proper css classname for the supplied Presence. |
static String |
getXMPPPresenceMessage(org.xmpp.packet.Presence presence)
Return the show and status message for the supplied Presence. |
static boolean |
isAvatarsEnabled()
Used to tell whether or not avatars are enabled. |
static boolean |
isExternal()
Utility method to determine if the current license is a Jive SBS Community (external) or Jive SBS (internal) license. |
static boolean |
isNew(Community community,
Date time)
Returns true if the community has been modified since the specified time. |
static boolean |
isNew(ForumMessage message,
Date time)
Returns true if the forum message has been modified since the specified time. |
static boolean |
isNew(ForumThread thread,
Date time)
Returns true if the forum thread has been modified since the specified time. |
static boolean |
isSlimLayout()
Used to tell if we should user a slimmer layout |
static boolean |
isValidPasswordToken(long userId,
String token)
Returns true is the supplied token is valid for the userId given. |
static String |
millisecondsToString(long time,
boolean stripEmpty)
Converts time in milliseconds to a String in the format HH:mm:ss.SSS. |
static String |
quoteOriginal(String body,
String delimiter,
int lineLength)
Formats the unfiltered body of a message to make it appear in the "quote original" format. |
static void |
removeCommonFileExtensionName(String extension)
Remove a mapping for a file extension to a particular type of file. |
static void |
removeIconGenerator(int objectType)
Remove an existing custom generator if one exists. |
static boolean |
resetUserPassword(long userId,
String token,
String newPassword)
This method is used in conjunction with the emailResetPasswordInstructions method to reset a user's password. |
static String |
secondsToString(long time,
boolean stripEmpty)
Converts time in seconds to a String in the format HH:mm:ss. |
static String |
test_getBinaryObjectCss(String prefix,
String contentType,
String name)
Exposed for test cases |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_DOC_TYPES
public static String DEFAULT_SPREADSHEET_TYPES
public static final String DEFAULT_PRESENTATION_TYPES
public static final String DEFAULT_COMPRESSED_TYPES
public static final String SKIN_DISPLAYFULLNAME
public static final boolean SKIN_DISPLAYFULLNAME_DEFAULT
public static final String SKIN_ATTACHMENTFILENAMEMAPPINGS
| Method Detail |
|---|
public static String formatDate(HttpServletRequest request,
User user,
Date date)
request - the servlet request object.user - the User that the date is being formatted for.date - the Date object we're comparing the current time with.
public static Locale getLocale()
public static String quoteOriginal(String body,
String delimiter,
int lineLength)
This method uses message.getBody() in order to get the body of the message. This usually yields better results for the formatting required by this method. However, it also has the potential of being a security risk if malicious HTML code is embedded in the body. Therefore, you should always filter HTML from the result of this method before showing it in an environment where HTML is interpreted. If you are showing the results of this method in an HTML <textarea>, there is no need to worry about malicious HTML.
body - the message body to quote.delimiter - a String that will start each line of the quoted message. For example, "> ";lineLength - the desired length of each line in the quoted message.
public static boolean isNew(Community community,
Date time)
community - the community to check.time - the time to reference the community against.
public static boolean isNew(ForumThread thread,
Date time)
thread - the thread to check.time - the time to reference the thread against.
public static boolean isNew(ForumMessage message,
Date time)
message - the message to check.time - the time to reference the message against.
public static List<Community> getParentCommunities(Community community)
community - the community to return parent communities.
public static String getSkinProperty(Community community,
String name)
This is a useful method for skin writers if they want to apply per-forum or per-community level UI changes. For example, the property for the forum page background color is stored as the global property "skin.default.bgColor". To apply a forum-level background color, simply create an extended property of the forum named "skin.default.bgColor" and call this method when retrieving the property from the skin.
community - the community to checkname - the name of the property we're looking for.
public static long getLastVisited(HttpServletRequest request,
HttpServletResponse response)
request - the HttpServletRequest object, known as "request" on a JSP page.response - the HttpServletRequest object, known as "response" on a JSP page.
public static Iterator<ForumMessage> filterPendingMessages(Iterator<ForumMessage> messages)
messages - the message (and its replies) to examine
public static boolean emailResetPasswordInstructions(String username,
HttpServletRequest request)
throws IllegalArgumentException
If the user has already been sent a password reset email in the last 72 hours, the token will not be regenerated but will instead be reused in the instructional email. Conversely, if the user has been sent an email prior to the last 72 hours, the token will be regenerated and saved. In either case, no more than 1 email every 24 hours will be sent. Attempts to send more than 1 email per 24 hours will result in this method returning false.
You can insert the following tokens into the subject or body of the email message and they'll be dynamically replaced with the appropriate values when the email is sent: {userID}, {username}, {name}, {email}, {token}, {requestIP}, {host}, {port} and {webAppDir}.
The details of the email can be changed using the Jive admin skin, the default email is below:
{host} - Jive SBS reset password request.
We have received a request from {requestIP} to reset your password. If you have requested to reset your password, please follow the instructions below. If you do not wish to reset your password, please simply disregard this message.
To reset your Jive password at {host} you can either:
- Click the following url:
http://{host}:{port}{webAppDir}/resetPassword.jsp?userid={userID}&token={token}
- Goto http://{host}:{port}{webAppDir}/resetPassword.jsp and enter the following information into the fields provided:
UserID: {userID}
Token: {token}
username - the usename of the user for whom we wish to send an email with instructions on how to reset their
passwordrequest - the servlet request object
IllegalArgumentException - if either username or request is null
public static boolean isValidPasswordToken(long userId,
String token)
userId - the id of the user for whom we are validating the password reset token.token - the password reset token associated with the above user.
public static boolean resetUserPassword(long userId,
String token,
String newPassword)
userId - the id of the user for whom the password should be changed.token - the password reset token associated with the above user.newPassword - the password to use for the specified user.
public static String dateToText(HttpServletRequest request,
User user,
Date date)
com.jivesoftware.util.DateUtils#displayFriendly(long)
Date parameter relative to the current time. For
instance, if the passed in date was 39 seconds ago, this method returns:"Less than 1 min ago"
Similiarly, a date 1 ago would be:
"Yesterday at 3:53 PM"
The method obeys user preferences for time zone if they exist.
request - the servlet request object.user - the User that the date is being formatted for, or null if an anonymmous user.date - the Date object we're comparing the current time with.
public static void addCommonFileExtensionName(String extension,
String type)
jive-icon-doctype-${yourFileType}
You can override any of the existing mappings by adding the extension with a different file type grouping.
extension - the file extension you want add (example: doc, xls, ppt)type - the file type you want the extension grouped withpublic static void removeCommonFileExtensionName(String extension)
extension - the file extension to remove the mapping for
public static void addIconGenerator(int objectType,
IconGenerator generator)
objectType - the object type of the generator you want to addgenerator - the generatorpublic static void removeIconGenerator(int objectType)
objectType - the object type of the generator you want to remove.public static String getCommonFileExtensionName(String filename)
filename - the file name to attempt to find a file type for.
public static String getJiveObjectCss(JiveObject object,
int size)
object - the object to return the css class forsize - 0 for small, 1 for medium, 2 for big. Default is medium for any other provided side.
public static String getFavoritedObjectCss(JiveObject favoritedObject,
int size)
favoritedObject - the favorite to produce an icon forsize - the prefix (example: jive-icon-...)
public static String test_getBinaryObjectCss(String prefix,
String contentType,
String name)
public static String getJiveObjectTypeCss(com.jivesoftware.community.objecttype.JiveObjectType jiveObjectType,
int size)
public static String getJiveObjectTypeCssByTypeID(int objectType,
int size)
public static String getJiveObjectIconForType(int objectType,
boolean returnAsCssClass,
int type)
getJiveObjectIcon(JiveObject, boolean, int) is preferable since
it will return more specific icons for things like binary documents and comments.
objectType - the objectType to return the icon image forreturnAsCssClass - true to return a css class (may be partial), false to return the path to the image (not
including the context root i.e. /clearspace/)type - 0 for small, 1 for medium, 2 for large, 3 for xlarge, 4 for a label icon, 5 for no type
public static String getJiveObjectIcon(JiveObject object,
boolean returnAsCssClass,
int type)
IconGenerator and registering the implementation with addIconGenerator(int, IconGenerator).
object - the content object to return the icon image forreturnAsCssClass - true to return a css class (may be partial), false to return the path to the image (not
including the context root i.e. /clearspace/)type - 0 for small, 1 for medium, 2 for large, 3 for xlarge, 4 for a label icon, 5 for no type
public static String getIcon(String name,
boolean returnAsCssClass,
int type)
Returns an icon string in the standard Jive format. The format can be configured through Jive Properties, the default returned format is:
images/jive-icon-community-16x16.gif
name - controls the name portion of the String returned.returnAsCssClass - true to return a CSS class or false to return a file name.type - 0 for small, 1 for medium, 2 for large, 3 for xlarge, 4 for a label icon, 5 for no type.
JiveGlobals.setJiveProperty(String, String)public static String getDisplayName(User user)
user - the user to return the display name for
public static String getTheme()
public static boolean isSlimLayout()
public static boolean isAvatarsEnabled()
public static String getXMPPPresenceClassname(org.xmpp.packet.Presence presence)
Presence.
presence - the presence to return a classname for.
Presence.public static String getXMPPPresenceMessage(org.xmpp.packet.Presence presence)
Presence. Or "Offline" if the
presence is null.
presence - the presence to return a status message for.
Presence.public static Date getLastLoggedIn(User user)
user - the user to check
public static String getDocumentAdditionClassname()
public static String getDocumentDeletionClassname()
public static String getImageDeletionClassname()
public static String getImageThumbNailClassname()
public static String getImageClassname()
public static String getDecoratedDocumentElementName()
public static String getUnDecoratedDocumentElementName()
public static boolean isExternal()
public static String getText(String locale,
String key)
locale - key -
public static String secondsToString(long time,
boolean stripEmpty)
String in the format HH:mm:ss.
time - the time in seconds.stripEmpty - - remove for times formatted 00:01:00 strip the leading 00: so it's 01:00. For 00:00 return 0
String representing the time in the format HH:mm:ss.
lazily adapted (jacked) from here: http://www.uk-dave.com/bytes/java/time_long_to_string.html (public domain)
public static String millisecondsToString(long time,
boolean stripEmpty)
String in the format HH:mm:ss.SSS.
time - the time in milliseconds.stripEmpty - - remove for times formatted 00:01:00 strip the leading 00: so it's 01:00. For 00:00 return 0
String representing the time in the format HH:mm:ss.SSS.
lazily adapted (jacked) from here: http://www.uk-dave.com/bytes/java/time_long_to_string.html (public domain)
|
Jive Product Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||