info.magnolia.module.templatingkit.functions
Class STKTemplatingFunctions

java.lang.Object
  extended by info.magnolia.module.templatingkit.functions.STKTemplatingFunctions

@Singleton
public class STKTemplatingFunctions
extends Object

This is an component exposing a couple of methods useful for STK templates. It's exposed in templates as "stkfn".

Version:
$Id$

Field Summary
protected static String METADATA_NODE_NAME
           
protected static String SITE_TITLE_PROP_NAME
           
static String SITEROOT_TEMPLATE_CATEGORY
           
protected static String TEMPLATE_PROP_NAME
           
protected static String TITLE_PROP_NAME
           
 
Constructor Summary
STKTemplatingFunctions(info.magnolia.templating.functions.TemplatingFunctions templatingFunctions, CssSelectorBuilder cssSelectorBuilder, CategorizationSupport categorizationSupport, SiteManager siteManager, javax.inject.Provider<STKModule> moduleProvider)
           
 
Method Summary
 String abbreviateString(String stringToCut, int size)
           
 String abbreviateString(String stringToCut, int size, String closureString)
           
 List<info.magnolia.jcr.util.ContentMap> ancestorsInSite(info.magnolia.jcr.util.ContentMap content)
           
 List<info.magnolia.jcr.util.ContentMap> ancestorsInSite(info.magnolia.jcr.util.ContentMap content, String nodeTypeName)
           
 List<javax.jcr.Node> ancestorsInSite(javax.jcr.Node content)
           
 List<javax.jcr.Node> ancestorsInSite(javax.jcr.Node content, String nodeTypeName)
           
 int count(String name)
          Increases the context bound counter and returns the value.
 List<javax.jcr.Node> cutList(List<javax.jcr.Node> itemsList, int maxResults)
          Return a Node List with a maximum number or result less or equal to maxResults.
 Asset getAsset(info.magnolia.jcr.util.ContentMap content, String nodeDataPrefix)
           
 Asset getAsset(javax.jcr.Node content, String nodeDataPrefix)
           
 Asset getAsset(javax.jcr.Node content, String nodeDataPrefix, String variationName)
          FIXME review: should this function be provided by this class?
 String getAssetLink(info.magnolia.jcr.util.ContentMap content, String nodeDataPrefix)
          FIXME review: should this function be provided by this class?
 String getAssetLink(info.magnolia.jcr.util.ContentMap content, String nodeDataPrefix, AbstractSTKTemplateModel<? extends info.magnolia.rendering.template.TemplateDefinition> model)
           
 String getAssetLink(info.magnolia.jcr.util.ContentMap content, String nodeDataPrefix, String variationName)
           
 String getAssetLink(javax.jcr.Node content, String nodeDataPrefix)
          FIXME review: should this function be provided by this class?
 String getAssetLink(javax.jcr.Node content, String nodeDataPrefix, String variationName)
           
 Asset getAssetVariation(Asset original, String variationName)
           
 List<info.magnolia.jcr.util.ContentMap> getCategories(javax.jcr.Node page)
          FIXME review: should this function be provided by this class?
 String getCategoryLink(javax.jcr.Node page, String categoryName)
          FIXME review: should this function be provided by this class?
 List<javax.jcr.Node> getContentListByTemplateCategorySubCategory(javax.jcr.Node siteRoot, String category, String subCategory)
          FIXME review: should this function be provided by this class?
static List<javax.jcr.Node> getContentListByTemplateCategorySubCategory(javax.jcr.Node siteRoot, String category, String subCategory, int maxResultSize, String andClause, String orderBy)
          FIXME review: should this function be provided by this class?
 String getDivIdAbbreviation(String divID)
           
 String getDivIdAbbreviation(String divID, String delimiter)
           
 javax.jcr.Node getNearestContentByTemplateCategorySubCategory(javax.jcr.Node siteRoot, String category, String subCategory, javax.jcr.Node current)
          FIXME review: should this function be provided by this class?
 javax.jcr.Node getReferencedContent(javax.jcr.Node content, String idPropertyName, String referencedWorkspace)
          Returns a Node object which is referenced by its id, stored in the @param propertyName.
 String homeLink(info.magnolia.jcr.util.ContentMap content)
           
 String homeLink(javax.jcr.Node content)
          Return the home link of this site.
 String homeName(info.magnolia.jcr.util.ContentMap content)
           
 String homeName(javax.jcr.Node content)
          Return the Home Site Name = the physical node's object name.
 String homeTitle(info.magnolia.jcr.util.ContentMap content)
           
 String homeTitle(javax.jcr.Node content)
          Return the HomeTitle value.
 String metaDataProperty(info.magnolia.jcr.util.ContentMap content, String property)
           
 String metaDataProperty(javax.jcr.Node content, String property)
          Return a property from the metaData of the node.
 String metaDataTemplate(info.magnolia.jcr.util.ContentMap content)
           
 String metaDataTemplate(javax.jcr.Node content)
          Return the template id associated with this content.
 String resolveImageVariationName(AbstractSTKTemplateModel<? extends info.magnolia.rendering.template.TemplateDefinition> model)
           
 String searchPageLink(info.magnolia.jcr.util.ContentMap content)
           
 String searchPageLink(javax.jcr.Node content)
          Method used to get the SearchPageLink.
 void setCategorizationSupport(CategorizationSupport categorizationSupport)
          For test purpose only.
 void setCssSelectorBuilder(CssSelectorBuilder cssSelectorBuilder)
          For test purpose only.
 Site site()
           
 Site site(info.magnolia.jcr.util.ContentMap content)
          Returns the according Site of the passed content ContentMap.
 Site site(javax.jcr.Node content)
          Returns the according Site of the passed content Node.
 info.magnolia.jcr.util.ContentMap siteRoot(info.magnolia.jcr.util.ContentMap content)
          Returns the site's root ContentMap of the @param content ContentMap.
 info.magnolia.jcr.util.ContentMap siteRoot(info.magnolia.jcr.util.ContentMap content, String siteRootTemplateCategory)
          Returns the site's root Node of the passed @param content Node.
 javax.jcr.Node siteRoot(javax.jcr.Node content)
          Returns the site's root Node of the @param content Node.
 javax.jcr.Node siteRoot(javax.jcr.Node content, String siteRootTemplateCategory)
          Returns the site's root Node of the passed @param content Node.
 String siteTitle(info.magnolia.jcr.util.ContentMap content)
           
 String siteTitle(javax.jcr.Node content)
          Return the SiteTitle value.
 Theme theme(Site site)
           
 javax.jcr.Node wrap(javax.jcr.Node content)
          FIXME review: should this function be provided by this class? FIXME I18nContentWrapper --> I18nNodeWrapper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SITEROOT_TEMPLATE_CATEGORY

public static final String SITEROOT_TEMPLATE_CATEGORY
See Also:
Constant Field Values

TITLE_PROP_NAME

protected static final String TITLE_PROP_NAME
See Also:
Constant Field Values

SITE_TITLE_PROP_NAME

protected static final String SITE_TITLE_PROP_NAME
See Also:
Constant Field Values

METADATA_NODE_NAME

protected static final String METADATA_NODE_NAME
See Also:
Constant Field Values

TEMPLATE_PROP_NAME

protected static final String TEMPLATE_PROP_NAME
See Also:
Constant Field Values
Constructor Detail

STKTemplatingFunctions

@Inject
public STKTemplatingFunctions(info.magnolia.templating.functions.TemplatingFunctions templatingFunctions,
                                     CssSelectorBuilder cssSelectorBuilder,
                                     CategorizationSupport categorizationSupport,
                                     SiteManager siteManager,
                                     javax.inject.Provider<STKModule> moduleProvider)
Method Detail

searchPageLink

public String searchPageLink(javax.jcr.Node content)
Method used to get the SearchPageLink. This Search page Link is defined on the Main PageInfo/Site configuration (Search Page Path to search result page). Method is used from a STKComponent and STKArea Model.

Parameters:
content: - Current Content node.
Returns:
relative path to the defined result page i.e. '/magnolia-empty-webapp/demo-project/service/search-result.html'

searchPageLink

public String searchPageLink(info.magnolia.jcr.util.ContentMap content)

homeName

public String homeName(javax.jcr.Node content)
Return the Home Site Name = the physical node's object name.


homeName

public String homeName(info.magnolia.jcr.util.ContentMap content)

homeTitle

public String homeTitle(javax.jcr.Node content)
Return the HomeTitle value. Referred by the property 'name' of the root Node


homeTitle

public String homeTitle(info.magnolia.jcr.util.ContentMap content)

siteTitle

public String siteTitle(javax.jcr.Node content)
Return the SiteTitle value. Referred by the property 'siteTitle' of the root Node


siteTitle

public String siteTitle(info.magnolia.jcr.util.ContentMap content)

homeLink

public String homeLink(javax.jcr.Node content)
Return the home link of this site.


homeLink

public String homeLink(info.magnolia.jcr.util.ContentMap content)

site

public Site site()

site

public Site site(javax.jcr.Node content)
Returns the according Site of the passed content Node.

Parameters:
content - The Node to determine its Site from
Returns:
Site The according Site of the passed @param content

theme

public Theme theme(Site site)

site

public Site site(info.magnolia.jcr.util.ContentMap content)
Returns the according Site of the passed content ContentMap.

Parameters:
content - The ContentMap to determine its Site from
Returns:
Site The according Site of the passed @param content

siteRoot

public javax.jcr.Node siteRoot(javax.jcr.Node content)
Returns the site's root Node of the @param content Node. The root Node is defined as the page Node having template category TemplateCategory.HOME. If no ancestor page exists with category TemplateCategory.HOME, the JCR workspace root is returned.

Parameters:
content - The Node to determine its site root
Returns:
Node The site root Node of the passed content Node

siteRoot

public info.magnolia.jcr.util.ContentMap siteRoot(info.magnolia.jcr.util.ContentMap content)
Returns the site's root ContentMap of the @param content ContentMap. The root ContentMap is defined as the page Node having template category TemplateCategory.HOME. If no ancestor page exists with category TemplateCategory.HOME, the JCR workspace root is returned.

Parameters:
content - The ContentMap to determine its site root
Returns:
ContentMap The site root ContentMap of the passed @param content

siteRoot

public info.magnolia.jcr.util.ContentMap siteRoot(info.magnolia.jcr.util.ContentMap content,
                                                  String siteRootTemplateCategory)
Returns the site's root Node of the passed @param content Node. The root Node is defined as the page Node with template its category as @param siteRootTemplateCategory. If no ancestor page exists with category TemplateCategory.HOME, the JCR workspace root is returned.

Parameters:
content - The Node to determine its site root
siteRootTemplateCategory - The TemplateCategory value of the site root to detect. If null or EMPTY is passed, the default value SITEROOT_TEMPLATE_CATEGORY is used instead.
Returns:
Node The site root Node of the passed content Node

siteRoot

public javax.jcr.Node siteRoot(javax.jcr.Node content,
                               String siteRootTemplateCategory)
Returns the site's root Node of the passed @param content Node. The root Node is defined as the page Node with template its category as @param siteRootTemplateCategory. If no ancestor page exists with category TemplateCategory.HOME, the JCR workspace root is returned.

Parameters:
content - The Node to determine its site root
siteRootTemplateCategory - The TemplateCategory value of the site root to detect. If null or EMPTY is passed, the default value SITEROOT_TEMPLATE_CATEGORY is used instead.
Returns:
Node The site root Node of the passed content Node

ancestorsInSite

public List<info.magnolia.jcr.util.ContentMap> ancestorsInSite(info.magnolia.jcr.util.ContentMap content)
                                                        throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

ancestorsInSite

public List<javax.jcr.Node> ancestorsInSite(javax.jcr.Node content)
                                     throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

ancestorsInSite

public List<info.magnolia.jcr.util.ContentMap> ancestorsInSite(info.magnolia.jcr.util.ContentMap content,
                                                               String nodeTypeName)
                                                        throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

ancestorsInSite

public List<javax.jcr.Node> ancestorsInSite(javax.jcr.Node content,
                                            String nodeTypeName)
                                     throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

getAssetLink

public String getAssetLink(javax.jcr.Node content,
                           String nodeDataPrefix)
FIXME review: should this function be provided by this class?


getAssetLink

public String getAssetLink(info.magnolia.jcr.util.ContentMap content,
                           String nodeDataPrefix)
FIXME review: should this function be provided by this class?


getAssetLink

public String getAssetLink(info.magnolia.jcr.util.ContentMap content,
                           String nodeDataPrefix,
                           AbstractSTKTemplateModel<? extends info.magnolia.rendering.template.TemplateDefinition> model)

getAssetLink

public String getAssetLink(info.magnolia.jcr.util.ContentMap content,
                           String nodeDataPrefix,
                           String variationName)

getAssetLink

public String getAssetLink(javax.jcr.Node content,
                           String nodeDataPrefix,
                           String variationName)

resolveImageVariationName

public String resolveImageVariationName(AbstractSTKTemplateModel<? extends info.magnolia.rendering.template.TemplateDefinition> model)

getAssetVariation

public Asset getAssetVariation(Asset original,
                               String variationName)

wrap

public javax.jcr.Node wrap(javax.jcr.Node content)
FIXME review: should this function be provided by this class? FIXME I18nContentWrapper --> I18nNodeWrapper


getCategories

public List<info.magnolia.jcr.util.ContentMap> getCategories(javax.jcr.Node page)
FIXME review: should this function be provided by this class?


getCategoryLink

public String getCategoryLink(javax.jcr.Node page,
                              String categoryName)
FIXME review: should this function be provided by this class?


getContentListByTemplateCategorySubCategory

public List<javax.jcr.Node> getContentListByTemplateCategorySubCategory(javax.jcr.Node siteRoot,
                                                                        String category,
                                                                        String subCategory)
                                                                 throws javax.jcr.RepositoryException
FIXME review: should this function be provided by this class?

Throws:
javax.jcr.RepositoryException

getContentListByTemplateCategorySubCategory

public static List<javax.jcr.Node> getContentListByTemplateCategorySubCategory(javax.jcr.Node siteRoot,
                                                                               String category,
                                                                               String subCategory,
                                                                               int maxResultSize,
                                                                               String andClause,
                                                                               String orderBy)
                                                                        throws javax.jcr.RepositoryException
FIXME review: should this function be provided by this class?

Throws:
javax.jcr.RepositoryException

getNearestContentByTemplateCategorySubCategory

public javax.jcr.Node getNearestContentByTemplateCategorySubCategory(javax.jcr.Node siteRoot,
                                                                     String category,
                                                                     String subCategory,
                                                                     javax.jcr.Node current)
                                                              throws javax.jcr.RepositoryException
FIXME review: should this function be provided by this class?

Throws:
javax.jcr.RepositoryException

getReferencedContent

public javax.jcr.Node getReferencedContent(javax.jcr.Node content,
                                           String idPropertyName,
                                           String referencedWorkspace)
Returns a Node object which is referenced by its id, stored in the @param propertyName.

Parameters:
content - the node with a property containing the referenced id value.
idPropertyName - The name of the property which contains the id of the referenced Node.
referencedWorkspace - The workspace in which the referenced Node exists.
Returns:
the referenced Node

getAsset

public Asset getAsset(javax.jcr.Node content,
                      String nodeDataPrefix,
                      String variationName)
FIXME review: should this function be provided by this class?


getAsset

public Asset getAsset(javax.jcr.Node content,
                      String nodeDataPrefix)

getAsset

public Asset getAsset(info.magnolia.jcr.util.ContentMap content,
                      String nodeDataPrefix)

cutList

public List<javax.jcr.Node> cutList(List<javax.jcr.Node> itemsList,
                                    int maxResults)
Return a Node List with a maximum number or result less or equal to maxResults.


abbreviateString

public String abbreviateString(String stringToCut,
                               int size)

abbreviateString

public String abbreviateString(String stringToCut,
                               int size,
                               String closureString)

count

public int count(String name)
Increases the context bound counter and returns the value. This is for instance useful to create unique page wide ids.


getDivIdAbbreviation

public String getDivIdAbbreviation(String divID)

getDivIdAbbreviation

public String getDivIdAbbreviation(String divID,
                                   String delimiter)

metaDataProperty

public String metaDataProperty(javax.jcr.Node content,
                               String property)
Return a property from the metaData of the node.


metaDataProperty

public String metaDataProperty(info.magnolia.jcr.util.ContentMap content,
                               String property)

metaDataTemplate

public String metaDataTemplate(javax.jcr.Node content)
Return the template id associated with this content.


metaDataTemplate

public String metaDataTemplate(info.magnolia.jcr.util.ContentMap content)

setCssSelectorBuilder

public void setCssSelectorBuilder(CssSelectorBuilder cssSelectorBuilder)
For test purpose only.


setCategorizationSupport

public void setCategorizationSupport(CategorizationSupport categorizationSupport)
For test purpose only.



Copyright © 2008-2012 Magnolia International Ltd.. All Rights Reserved.