/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { Node } from "../../types/javax/jcr/Node"; import type { String } from "../../types/java/lang/String"; import type { List } from "../../types/java/util/List"; import type { Filter } from "../../types/senselogic/sitevision/api/base/Filter"; /** * Node tree utility interface. * *

* An instance of the Sitevision class implementing this interface can be obtained via * {@link senselogic.sitevision.api.Utils#getNodeTreeUtil()}. * See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the Utils interface. *

* @author Magnus Lövgren */ export interface NodeTreeUtil { /** * Gets a node relative to another node. * *

* * Note! This is mere a convenience alias for {@link javax.jcr.Node#getNode(String)} but unlike the original, * this method returns null instead of throwing an exception if no node could be retrieved at a specified path. * *

* @param aNode the node * @param aRelPath the relative path (of aNode) to the node to retrieve * @return the node at aRelPath, or null if no such node could be retrieved * @since Sitevision 4.0 */ getNode(aNode: Node, aRelPath: String | string): Node; /** * Gets the parent of a node. * *

* * Note! This is mere a convenience alias for {@link javax.jcr.Item#getParent()} but unlike the original, * this method returns null instead of throwing an exception if no parent node could be retrieved. * *

* @param aNode the node * @return the parent node of aNode, or null if no parent could be retrieved * @since Sitevision 4.0 */ getParent(aNode: Node): Node; /** * Check if a given page tree node is a descendant of another page tree node. * @param aDescendantNode the presumed descendant page tree Node (e.g. "child node") * @param aParentNode the presumed parent page tree Node of the descendant * @return true if aDescendantNode is a descendant of aParentNode, false otherwise */ isDescendantOf(aDescendantNode: Node, aParentNode: Node): boolean; /** * Returns a top-down list of all web nodes from the site page down to a specified page tree node. * *

* This method traverses the site page tree and returns a list of all web nodes, from the site page to a descendant. * The tree traversal will use a maximum tree depth of 50. If the specified node is deeper down in the tree than that, * an incomplete list will be returned (top nodes will be missing). *

* *

* Note! Mentioned "web nodes" are by this method considered to be all child nodes of the site page node you * can see in the Sitevision editor Navigator that are accessible from the location bar of a browser (e.g. pages and articles * but not folders and archives). File and image nodes are also recognized as web nodes - even if they are in the "site global" * archive (i.e. in the site tree, not actually in the site page tree). * * In other words, though they are accessible from the location bar of a browser - a portlet node or layout node is not * considered to be a web node by this method. *

* *

* Tip! If you should render a linked "path to this page", consider using the renderWebPathNodes * utility of {@link senselogic.sitevision.api.render.OutputUtil}. *

* @param aDescendantNode a page tree node that is a descendant/child of the site page, typically a sv:page or sv:article * @return a top-down list of the web nodes that are in the tree path from the site page node downto aDescendantNode (the site page node and the descendant node are both included in the list). An empty list will be returned if aDescendantNode is null or not a descendant of the site page. * @since Sitevision 2.6.1_06 * @see senselogic.sitevision.api.render.OutputUtil#renderWebPathNodes(javax.jcr.Node, senselogic.sitevision.api.render.LinkRenderer, String) */ getWebPathNodes(aDescendantNode: Node): List; /** * Find a portlet with a specific content identifier on a page node. * *

* The content identifier of the portlet is determined by the contentIdentifier property. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aContentIdentifier the content identifier of the sv:portlet that should be found * @return the first occurrence of a sv:portlet with matching aContentIdentifier, or null if no such portlet can be found or if aPageNode is not a page node * @since Sitevision 2025.01.1 */ findPortletByContentIdentifier( aPageNode: Node, aContentIdentifier: String | string ): Node; /** * Find a portlet with a specific name on a page node. * *

* The name of the portlet is determined by the displayName property. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aPortletName the name of the sv:portlet that should be found * @return the first occurrence of a sv:portlet with name aPortletName, or null if no such portlet can be found or if aPageNode is not a page node * @since Sitevision 2.6 * @see #findPortletsByName(Node,String) */ findPortletByName(aPageNode: Node, aPortletName: String | string): Node; /** * Find all portlets with a specific name on a page node. * *

* The name of the portlet is determined by the displayName property. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aPortletName the name of the sv:portlet that should be found * @return all occurrences of portlets with name aPortletName. If no such portlets can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 2.6 * @see #findPortletByName(Node,String) */ findPortletsByName(aPageNode: Node, aPortletName: String | string): List; /** * Find all portlets with a specific name on a page node and applies a node filter to the result. * *

* The name of the portlet is determined by the displayName property. *

* *

* Tip! {@link senselogic.sitevision.api.node.NodeFilterUtil} can be used to create a node filter. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aPortletName the name of the sv:portlet that should be found * @param aNodeFilter a node filter to refine the result of all portlets with specified name * @return all occurrences of portlets with name aPortletName that also applies to the aNodeFilter filter. If no such portlets can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 3.6.2 */ findPortletsByName( aPageNode: Node, aPortletName: String | string, aNodeFilter: Filter ): List; /** * Find all portlets of a specific type on a page node. * *

* The type of the portlet is determined by the portletName property. This is typically * the value that is specified in the <portlet-name> element of the portlet in portlet.xml. *

*

* Types for some common portlets: *

* * @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aPortletType the type of sv:portlet that should be found * @return all occurrences of portlets of type aPortletType. If no such portlets can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 3.6.2 */ findPortletsByType(aPageNode: Node, aPortletType: String | string): List; /** * Find all portlets with a specific type on a page node and applies a node filter to the result. * *

* The type of the portlet is determined by the portletName property. This is typically * the value that is specified in the <portlet-name> element of the portlet in portlet.xml. *

* *

* Types for some common portlets: *

* * *

* Tip! {@link senselogic.sitevision.api.node.NodeFilterUtil} can be used to create a node filter. *

*

* Below is a Velocity example that demonstrates how to extract all Image portlets from the content of a * specified page. A node filter is applied to only return the Image portlets that has a display name that contains the * word logo. *

*
    ## Create a filter that matches nodes that has a displayName that contains "logo"
   *     #set ($nodeFilterUtil = $sitevisionUtils.NodeFilterUtil)
   *     #set ($containsLogoFilter = $nodeFilterUtil.getContainsStringPropertyFilter('displayName', 'logo'))
   *
   *     ## Extract all matching Image portlets from the page
   *     #set ($logoImagePortlets = $nodeTreeUtil.findPortletsByType($thePage, 'image', $containsLogoFilter))
   *     #if (!$logoImagePortlets.isEmpty())
   *        ## Handle matching image portlets
   *        ...
   *     #end
*

* Below is another Velocity example. A node filter is applied to only return the Image portlets that uses * images that has a width between 24px and 132px (an Image portlet has a 'image' property that can be resolved as a sv:image * Node and such node has a 'width' property). *

*
    ## Create a filter that matches nodes that has a nested width between [24..132]
   *     #set ($nodeFilterUtil = $sitevisionUtils.NodeFilterUtil)
   *     #set ($imageWidthFilter = $nodeFilterUtil.getRangeNestedIntPropertyFilter('image', 'width', 24, 132))
   *
   *     ## Extract all Image portlets that uses an "appropriate" image
   *     #set ($foundImagePortlets = $nodeTreeUtil.findPortletsByType($thePage, 'image', $imageWidthFilter))
   *     #if (!$foundImagePortlets.isEmpty())
   *        ## Handle matching image portlets
   *        ...
   *     #end
   *  
* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aPortletType the type of sv:portlet that should be found * @param aNodeFilter a node filter to refine the result of all portlets of specified type * @return all occurrences of portlets of type aPortletType that also applies to the aNodeFilter filter. If no such portlets can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 3.6.2 */ findPortletsByType( aPageNode: Node, aPortletType: String | string, aNodeFilter: Filter ): List; /** * Find all portlets on a page node and applies a node filter to the result. * *

* Tip! {@link senselogic.sitevision.api.node.NodeFilterUtil} can be used to create a node filter. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aNodeFilter a node filter to refine the result of all portlets * @return all occurrences of portlets that also applies to the aNodeFilter filter. If no such portlets can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 2023.07.1 */ findPortlets(aPageNode: Node, aNodeFilter: Filter): List; /** * Find a layout with a specific name on a page node. * *

* The name of the layout is determined by the displayName property. *

*

* This method handles layouts of container-type (layout nodes that can have children), such as: *

* *

* (i.e. this method does not handle the flat, non-container type sv:linkedLayout) *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aLayoutName the name of the layout that should be found * @return the first occurrence of a layout with name aLayoutName, or null if no such layout can be found or if aPageNode is not a page node * @see #findLayoutsByName(Node, String) * @since Sitevision 2023.07.1 */ findLayoutByName(aPageNode: Node, aLayoutName: String | string): Node; /** * Find all layouts with a specific name on a page node. * *

* The name of the layout is determined by the displayName property. *

*

* This method handles layouts of container-type (layout nodes that can have children), such as: *

* *

* (i.e. this method does not handle the flat, non-container type sv:linkedLayout) *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aLayoutName the name of the layouts that should be found * @return all occurrences of layouts with name aLayoutName. If no such layouts can be found or if aPageNode is not a page node, an empty List is returned * @see #findLayoutsByName(Node, String, Filter) * @since Sitevision 2023.07.1 */ findLayoutsByName(aPageNode: Node, aLayoutName: String | string): List; /** * Find all layouts with a specific name on a page node and applies a node filter to the result. * *

* The name of the layout is determined by the displayName property. *

*

* This method handles layouts of container-type (layout nodes that can have children), such as: *

* *

* (i.e. this method does not handle the flat, non-container type sv:linkedLayout) *

* *

* Tip! {@link senselogic.sitevision.api.node.NodeFilterUtil} can be used to create a node filter. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aLayoutName the name of the layouts that should be found * @param aNodeFilter a node filter to refine the result of all layouts with matching name * @return all occurrences of layouts with name aLayoutName that also applies to the aNodeFilter filter. If no such layouts can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 2023.07.1 */ findLayoutsByName( aPageNode: Node, aLayoutName: String | string, aNodeFilter: Filter ): List; /** * Find all layouts on a page node and applies a node filter to the result. * *

* This method handles layouts of container-type (layout nodes that can have children), such as: *

* *

* (i.e. this method does not handle the flat, non-container type sv:linkedLayout) *

* *

* Tip! {@link senselogic.sitevision.api.node.NodeFilterUtil} can be used to create a node filter. *

* @param aPageNode the page node that has content, typically a sv:page or sv:article * @param aNodeFilter a node filter to refine the result of all layouts * @return all occurrences of layouts that also applies to the aNodeFilter filter. If no such layouts can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 2023.07.1 */ findLayouts(aPageNode: Node, aNodeFilter: Filter): List; /** * Find all reference layouts ("content areas") on a page node. * @param aPageNode the page node that has content, typically a sv:page or sv:article * @return all reference layouts for aPageNode. If no such layouts can be found or if aPageNode is not a page node, an empty List is returned * @since Sitevision 2026.01.2 */ findReferenceLayouts(aPageNode: Node): List; } declare namespace NodeTreeUtil {} declare var nodeTreeUtil: NodeTreeUtil; export default nodeTreeUtil;