Class MemberInitialsManager

java.lang.Object
com.jalios.jcms.MemberInitialsManager
All Implemented Interfaces:
JPropertiesListener

public class MemberInitialsManager extends Object implements JPropertiesListener
Utility class to produce a Member photo using member's initials.
Since:
jcms-10.0.4 JCMS-6025
Author:
Sylvain Devaux
  • Field Details

  • Method Details

    • getInstance

      public static MemberInitialsManager getInstance()
      Get the manager.
      Returns:
      MemberInitialsManager the singleton instance
    • reloadProperties

      protected void reloadProperties()
    • propertiesChange

      public void propertiesChange(JProperties arg0)
      Description copied from interface: JPropertiesListener
      Invoked after properties have been modified in JCMS and save on disk.

      You cannot alter the value received in parameters.

      Note that properties parameter may be null, a limited set of site properties, or all site properties.

      To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

      Specified by:
      propertiesChange in interface JPropertiesListener
      Parameters:
      arg0 - the properties which have been submitted to change
    • getInitials

      public String getInitials(String firstName, String name, Locale userLocale)
      Returns letters initials.
      Parameters:
      firstName - the firstname
      name - the name
      userLocale - the locale to use with String.toUpperCase(Locale)
      Returns:
      First letter of name + First letter of firstname if available
      Since:
      jcms-10.0.4 JCMS-6025
    • getInitials

      public String getInitials(Member member, Locale userLocale)
      Returns letters initials.
      Parameters:
      member - the member to compute its initials
      userLocale - the locale to use with String.toUpperCase(Locale)
      Returns:
      member's initials
      Since:
      jcms-10.0.4 JCMS-6025
    • getInitialsColor

      public String getInitialsColor(Member member)
      Return a CSS var of a jpalette color based on Member metadata.
      Parameters:
      member - the member to compute a color from
      Returns:
      a CSS var of a jpalette color
      Since:
      jcms-10.0.4 JCMS-6025
    • getInitialsColorFromEmail

      public String getInitialsColorFromEmail(String email)
      Return a CSS var of a jpalette color based on given email String.
      Parameters:
      email - the email to get a color.

      Extracts name and firstname from email.

      Returns:
      a CSS var of a jpalette color
      Since:
      jcms-10.0.8
    • getInitialsTextColor

      public String getInitialsTextColor(String initialsColor)
      Return the text color to use with the given initials background color.
      Parameters:
      initialsColor - an initials background color, as returned by getInitialsColor(Member)
      Returns:
      the 700 variant CSS var for an Untitled UI color family, a white CSS var for other colors, null if initialsColor is empty
      Since:
      jplatform-11
    • getInitialsTextColor

      public String getInitialsTextColor(Member member)
      Return the text color to use with the initials background color of the given member.
      Parameters:
      member - the member to compute a color from
      Returns:
      a CSS var of a color
      Since:
      jplatform-11
    • getInitialsJPaletteColorVar

      public String getInitialsJPaletteColorVar(String initialsColor)
      Return the closest jpalette color of the given initials background color.

      An Untitled UI color family is converted using its 700 variant (or 600 if not available) declared in jpalette.color.* properties.

      Parameters:
      initialsColor - an initials background color, as returned by getInitialsColor(Member)
      Returns:
      a CSS var of a jpalette color, or initialsColor if not an Untitled UI color family
      Since:
      jplatform-11
    • getInitialsFromEmail

      public String getInitialsFromEmail(String email)
      Parameters:
      email - the email to get initials.

      Extracts name and firstname from email.

      Returns:
      a color hex hexadecimal code
      Since:
      jcms-10.0.8
    • resetInitialsColor

      public void resetInitialsColor(Member member)
      Reset the cached color code based on Member metaDatas.
      Parameters:
      member - the member to reset its cached color
      Since:
      jcms-10.0.5
    • getAvailableColors

      protected List<String> getAvailableColors()