Package org.ametys.skinfactory
Class SkinFactoryComponent
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.skinfactory.SkinFactoryComponent
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
public class SkinFactoryComponent extends AbstractLogEnabled implements Component, ThreadSafe, Serviceable
Manager for skin parameters
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
CSS_PARAM_PATTERN
Pattern for CSS parameters.static Pattern
I18N_PARAM_PATTERN
Pattern for i18n text parameters.static String
ROLE
Avalon rolestatic Pattern
TXT_PARAM_PATTERN
Pattern for text parameters.
-
Constructor Summary
Constructors Constructor Description SkinFactoryComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyColorTheme(String modelName, Path skinDir)
Apply new color themevoid
applyModelParameters(String modelName, Path skinDir)
Apply model parameters in given skinvoid
applyModelParameters(String modelName, Path skinDir, Map<String,Object> values)
Apply model parameters in given skinvoid
applyParameter(AbstractSkinParameter parameter, Path skinDir, String modelName, Object value, String lang)
Apply parametervoid
clearModelsParametersCache()
Remove all model parameters from cacheString
getColorTheme(Path skinDir)
Get the current themeAbstractSkinParameter
getModelParamater(String modelName, String paramId)
Get the skin parameter of the given modelMap<String,AbstractSkinParameter>
getModelParameters(String modelName)
Get the skin parameters of a modelObject
getParameterValue(Path skinDir, String modelName, String id)
Get the parameter's valueMap<String,Object>
getParameterValues(Path skinDir, String modelName)
Get all parameters' valuesMap<String,Object>
getParameterValues(Path skinDir, String modelName, List<String> ids)
Get the parameters' valuesboolean
isModelUpToDate(String modelName)
Determines if the model was changedboolean
saveColorTheme(Path skinDir, String themeId)
Modify the color themeboolean
saveParameter(Path skinDir, String id, Object value)
Modify a skin parameter's valueboolean
saveParameters(Path skinDir, Map<String,Object> parameters)
Save skin parametersvoid
service(ServiceManager smanager)
void
updateHash(Path xmlFile, String hash)
Update hash-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
CSS_PARAM_PATTERN
public static final Pattern CSS_PARAM_PATTERN
Pattern for CSS parameters. E.g: color: #EEEEEE /* AMETYS("myuniqueid", "Label", DESCRIPTION_I18N_KEY) *\/;
-
I18N_PARAM_PATTERN
public static final Pattern I18N_PARAM_PATTERN
Pattern for i18n text parameters. E.g: <message key="SKIN_TITLE">Ametys, Web Java Open Source CMS<!-- Ametys("text.i18n.site.title", "Titre du site") --></message>
-
TXT_PARAM_PATTERN
public static final Pattern TXT_PARAM_PATTERN
Pattern for text parameters. E.g: <xsl:variable name="foo">test<!-- Ametys("variable.foo", "Foo", "Foo") --></xsl:variable>
-
-
Constructor Detail
-
SkinFactoryComponent
public SkinFactoryComponent()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
clearModelsParametersCache
public void clearModelsParametersCache()
Remove all model parameters from cache
-
getModelParamater
public AbstractSkinParameter getModelParamater(String modelName, String paramId)
Get the skin parameter of the given model- Parameters:
modelName
- The model nameparamId
- The id of the parameter- Returns:
- The skin parameter or
null
if it doesn't exist
-
isModelUpToDate
public boolean isModelUpToDate(String modelName)
Determines if the model was changed- Parameters:
modelName
- The model name- Returns:
true
if the model was changed
-
getModelParameters
public Map<String,AbstractSkinParameter> getModelParameters(String modelName)
Get the skin parameters of a model- Parameters:
modelName
- the model name- Returns:
- skin parameters in a List
-
getParameterValue
public Object getParameterValue(Path skinDir, String modelName, String id)
Get the parameter's value- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameid
- The parameter id- Returns:
- The parameter's value
-
getParameterValues
public Map<String,Object> getParameterValues(Path skinDir, String modelName, List<String> ids)
Get the parameters' values- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameids
- The parameters' id- Returns:
- The parameters' values
-
getColorTheme
public String getColorTheme(Path skinDir)
Get the current theme- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)- Returns:
- The current theme id
-
getParameterValues
public Map<String,Object> getParameterValues(Path skinDir, String modelName)
Get all parameters' values- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model name- Returns:
- The all parameters' values
-
saveColorTheme
public boolean saveColorTheme(Path skinDir, String themeId)
Modify the color theme- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)themeId
- The id of the theme. Can be null to clear theme.- Returns:
true
is modification success
-
saveParameter
public boolean saveParameter(Path skinDir, String id, Object value)
Modify a skin parameter's value- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)id
- the id of the parametervalue
- the new value- Returns:
true
is modification success
-
saveParameters
public boolean saveParameters(Path skinDir, Map<String,Object> parameters)
Save skin parameters- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)parameters
- The skins parameters to save- Returns:
true
is modification success
-
applyModelParameters
public void applyModelParameters(String modelName, Path skinDir)
Apply model parameters in given skin- Parameters:
modelName
- The model nameskinDir
- The skin directory (could be temp, work or skins)
-
applyModelParameters
public void applyModelParameters(String modelName, Path skinDir, Map<String,Object> values)
Apply model parameters in given skin- Parameters:
modelName
- The model nameskinDir
- The skin directoryvalues
- The values to set
-
updateHash
public void updateHash(Path xmlFile, String hash) throws IOException
Update hash- Parameters:
xmlFile
- the xmlFile
hash
- the new hash of the file- Throws:
IOException
- if an error occurs while manipulating the file
-
applyParameter
public void applyParameter(AbstractSkinParameter parameter, Path skinDir, String modelName, Object value, String lang)
Apply parameter- Parameters:
parameter
- the skin parameterskinDir
- the skin directory (could be temp, work or skins)modelName
- the model namevalue
- the parameter valuelang
- The language
-
applyColorTheme
public void applyColorTheme(String modelName, Path skinDir)
Apply new color theme- Parameters:
skinDir
- the skin directory (could be temp, work or skins)modelName
- the model name
-
-